Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7eb0116
feat(mobile): preview chat attachments in a compact swipeable gallery
niconicohu Oct 16, 2026
bd90ad4
fix(mobile): scope image failures and preserve attachment prose spacing
niconicohu Oct 16, 2026
feff5fc
fix(mobile): authorize stored attachment previews on their owning host
niconicohu Oct 16, 2026
7e5d1da
fix(attachments): exclude agent messages from user file provenance
niconicohu Oct 16, 2026
9489933
fix(mobile): preserve prose around stored attachment references
niconicohu Oct 16, 2026
457251c
fix(mobile): keep inline attachment examples as literal code
niconicohu Oct 16, 2026
9121ab4
Merge main and use parser rules and shared image viewer state
niconicohu Oct 17, 2026
cde193a
Keep Android image long-press actions on gallery thumbnails
niconicohu Oct 17, 2026
a55c93b
Type gallery host fixture with JSX children
niconicohu Oct 17, 2026
1806245
Merge main row overlays and streaming while retaining the attachment …
niconicohu Oct 17, 2026
f27ea0d
Consolidate row overlay message type imports
niconicohu Oct 17, 2026
8990655
fix(mobile): support Android gallery zoom and trim unrelated formatting
niconicohu Oct 17, 2026
a916181
fix(mobile): coordinate image pan and pinch transitions
niconicohu Oct 17, 2026
07d1804
chore: remove unrelated formatting from attachments changes
niconicohu Oct 17, 2026
a757f7c
Merge queued editing while retaining host attachment reads and Window…
niconicohu Oct 17, 2026
bdf88cf
fix(chat): preserve image URLs outside the attachment store
niconicohu Oct 17, 2026
0f6c0fe
Merge main and keep attachment gestures in the shared phone page
niconicohu Oct 17, 2026
763bb92
fix(mobile): measure gallery pages and preserve web pinch and swiping
niconicohu Oct 17, 2026
b42cef0
test(mobile): follow gallery pages from web scroll events
niconicohu Oct 17, 2026
20f8897
fix(mobile): anchor page image zoom below headers and safe insets
niconicohu Oct 17, 2026
18a91ab
Merge main while preserving separate message attachments
niconicohu Oct 18, 2026
33523a3
Keep attachment previews alongside the new mobile composer
niconicohu Oct 18, 2026
45d679f
Route phone attachment previews to the execution host
niconicohu Oct 18, 2026
bc2f3f2
Merge main into mobile attachments
niconicohu Oct 19, 2026
f8add2d
fix(mobile): preview and zoom assistant images on their session host
niconicohu Oct 20, 2026
e8544ee
fix(mobile): retain tap-to-open policy for external chat images
niconicohu Oct 20, 2026
678c11e
fix(mobile): admit only supported chat image sources
niconicohu Oct 20, 2026
c866856
Merge upstream main into mobile attachments
niconicohu Oct 20, 2026
f0330fc
Merge main and preserve chat image admission
niconicohu Oct 21, 2026
31d013b
Merge main into mobile attachments and preserve tool disclosure
niconicohu Oct 21, 2026
b15020e
fix(mobile): clear held failure after accepted question answers
niconicohu Oct 21, 2026
479fa8c
Merge upstream/main and preserve OMP question routing with attachment…
niconicohu Oct 21, 2026
de5bfa9
Merge main model and async-question support into chat attachments
niconicohu Oct 22, 2026
de29c03
Merge current main browser prop extraction into mobile attachments
niconicohu Oct 22, 2026
04394c9
Merge main while retaining CJK and attachment parsing
niconicohu Oct 23, 2026
21f8844
Merge main and retain independent mobile attachment capabilities
niconicohu Oct 25, 2026
fd90376
Merge main and follow relocated attachment grant types
niconicohu Oct 25, 2026
771cef9
Merge main and compose mobile chat test fixtures
niconicohu Oct 25, 2026
eeb07ce
Merge upstream main and preserve mobile attachment rendering
niconicohu Oct 25, 2026
5bd23f0
Merge main and update attachment grant filesystem mock
niconicohu Oct 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions mobile/src/session/MobileNativeChatFileAttachments.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useState } from 'react'
import { Pressable, Text, View } from 'react-native'
import { FileText } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { styles } from './mobile-native-chat-message-styles'

export function MobileNativeChatFileAttachments({
files,
onOpenFile
}: {
files: readonly string[]
onOpenFile?: (path: string) => void
}) {
const [expanded, setExpanded] = useState(false)
return (
<View style={[styles.imageGallery, expanded && styles.fileGallery]}>
{(expanded ? files : files.slice(0, 3)).map((path) => {
const name = path.split(/[\\/]/).at(-1) ?? path
return (
<Pressable
key={path}
accessibilityRole="button"
accessibilityLabel={`Open file ${name}`}
disabled={!onOpenFile}
style={[styles.imageGalleryTile, styles.fileTile]}
onPress={() => onOpenFile?.(path)}
>
<FileText size={20} color={colors.textSecondary} />
<Text numberOfLines={2} ellipsizeMode="middle" style={styles.fileName}>
{name}
</Text>
</Pressable>
)
})}
{files.length > 3 ? (
<Pressable
accessibilityRole="button"
accessibilityLabel={expanded ? 'Show fewer files' : `View all ${files.length} files`}
style={[styles.imageGalleryTile, styles.imageGalleryMore]}
onPress={() => setExpanded(!expanded)}
>
<Text style={styles.imageGalleryCount}>{expanded ? '−' : `+${files.length - 3}`}</Text>
</Pressable>
) : null}
</View>
)
}
101 changes: 101 additions & 0 deletions mobile/src/session/MobileNativeChatImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { useContext, useEffect, useState } from 'react'
import {
ActivityIndicator,
Image,
Pressable,
Text,
View,
type ImageStyle,
type StyleProp,
type ImageResizeMode
} from 'react-native'
import { isAgentSessionAttachmentStorePath } from '../../../src/shared/agent-session-attachments'
import { colors } from '../theme/mobile-theme'
import {
MobileNativeChatAttachmentContext,
readMobileNativeChatAttachment
} from './mobile-native-chat-attachment-read'
import { isRenderableImageUri } from './mobile-native-chat-image-preview'
import { styles, TEXT_SIZE } from './mobile-native-chat-message-styles'

export function MobileNativeChatImage({
uri,
alt,
fontScale,
imageStyle = styles.imageThumb,
resizeMode = 'contain'
}: {
uri: string | undefined
alt?: string
fontScale: number
imageStyle?: StyleProp<ImageStyle>
resizeMode?: ImageResizeMode
}) {
const client = useContext(MobileNativeChatAttachmentContext)
const direct = isRenderableImageUri(uri)
const remote =
!direct && client !== null && uri !== undefined && isAgentSessionAttachmentStorePath(uri)
const [attempt, setAttempt] = useState(0)
const [read, setRead] = useState<{
client: typeof client
path: string
uri: string | null
} | null>(null)
const [failed, setFailed] = useState(false)
useEffect(() => {
if (!remote || !client || uri === undefined) {
return
}
let disposed = false
void readMobileNativeChatAttachment(client, uri)
.catch(() => null)
.then((image) => {
if (!disposed) {
setRead({ client, path: uri, uri: image })
}
})
return () => {
disposed = true
}
}, [client, uri, remote, attempt])
const current = read?.client === client && read?.path === uri ? read : null
const imageUri = direct ? uri : current?.uri
if (imageUri && !failed) {
return (
<Image
source={{ uri: imageUri }}
style={imageStyle}
resizeMode={resizeMode}
accessibilityLabel={alt ?? 'Attached image'}
onError={() => setFailed(true)}
/>
)
Comment thread
niconicohu marked this conversation as resolved.
Resolved
}
if (remote && current === null) {
return (
<View style={imageStyle}>
<ActivityIndicator color={colors.textSecondary} accessibilityLabel="Loading image" />
</View>
)
}
const label = (
<Text style={[styles.imageRef, { fontSize: TEXT_SIZE * fontScale }]}>
{remote || failed ? 'Image unavailable · Tap to retry' : `🖼 ${alt ?? uri ?? 'image'}`}
</Text>
)
return remote || failed ? (
<Pressable
accessibilityLabel="Retry image"
accessibilityRole="button"
onPress={() => {
setRead(null)
setFailed(false)
setAttempt((value) => value + 1)
}}
>
{label}
</Pressable>
) : (
label
)
}
56 changes: 56 additions & 0 deletions mobile/src/session/MobileNativeChatImageGallery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { useState } from 'react'
import { Pressable, Text, View } from 'react-native'
import type { NativeChatImageRefBlock } from '../../../src/shared/native-chat-types'
import { MobileNativeChatImage } from './MobileNativeChatImage'
import { MobileNativeChatImageViewer } from './MobileNativeChatImageViewer'
import { styles } from './mobile-native-chat-message-styles'

export function MobileNativeChatImageGallery({
images,
alignToEnd = true
}: {
images: readonly NativeChatImageRefBlock[]
alignToEnd?: boolean
}) {
const [selected, setSelected] = useState<number | null>(null)
const occurrences = new Map<string, number>()
const thumbnails = images.slice(0, 3).map((image) => {
const identity = image.path ?? image.url ?? image.alt ?? 'image'
const occurrence = occurrences.get(identity) ?? 0
occurrences.set(identity, occurrence + 1)
return { image, key: `${identity}:${occurrence}` }
})
return (
<View style={[styles.imageGallery, !alignToEnd && { justifyContent: 'flex-start' }]}>
{thumbnails.map(({ image, key }, index) => (
<Pressable
key={key}
accessibilityRole="button"
accessibilityLabel={`Open image ${index + 1} of ${images.length}`}
style={styles.imageGalleryTile}
onPress={() => setSelected(index)}
>
<MobileNativeChatImage
uri={image.url ?? image.path}
alt={image.alt}
fontScale={1}
imageStyle={styles.imageGalleryFill}
resizeMode="cover"
/>
{index === 2 && images.length > 3 ? (
<View pointerEvents="none" style={styles.imageGalleryScrim}>
<Text style={styles.imageGalleryOverflowCount}>+{images.length - 3}</Text>
</View>
) : null}
</Pressable>
))}
{selected !== null ? (
<MobileNativeChatImageViewer
images={images}
initialIndex={selected}
onClose={() => setSelected(null)}
/>
) : null}
</View>
)
}
83 changes: 83 additions & 0 deletions mobile/src/session/MobileNativeChatImageViewer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { useState } from 'react'
import { FlatList, Modal, Pressable, Text, View, useWindowDimensions } from 'react-native'
import { X } from 'lucide-react-native'
import type { NativeChatImageRefBlock } from '../../../src/shared/native-chat-types'
import { useWindowSafeAreaInsets } from '../layout/side-safe-area'
import { colors } from '../theme/mobile-theme'
import { MobileNativeChatImage } from './MobileNativeChatImage'
import { styles } from './mobile-native-chat-message-styles'

export function MobileNativeChatImageViewer({
images,
initialIndex,
onClose
}: {
images: readonly NativeChatImageRefBlock[]
initialIndex: number
onClose: () => void
}) {
const insets = useWindowSafeAreaInsets()
const window = useWindowDimensions()
const width = Math.max(1, window.width - insets.left - insets.right)
const [index, setIndex] = useState(initialIndex)
return (
<Modal visible presentationStyle="fullScreen" animationType="fade" onRequestClose={onClose}>
<View
style={[
styles.imageViewer,
{
paddingTop: insets.top,
paddingBottom: insets.bottom,
paddingLeft: insets.left,
paddingRight: insets.right
}
]}
>
<View style={styles.imageViewerHeader}>
<Text style={styles.imageViewerTitle}>
{index + 1} / {images.length}
</Text>
<Pressable
accessibilityRole="button"
accessibilityLabel="Close images"
hitSlop={8}
onPress={onClose}
style={styles.imageViewerClose}
>
<X size={20} color={colors.textPrimary} />
</Pressable>
</View>
<FlatList
key={width}
horizontal
pagingEnabled
data={images}
initialScrollIndex={index}
initialNumToRender={1}
windowSize={3}
showsHorizontalScrollIndicator={false}
keyExtractor={(image, at) => `${at}:${image.url ?? image.path}`}
getItemLayout={(_data, at) => ({ length: width, offset: at * width, index: at })}
onMomentumScrollEnd={(event) =>
setIndex(
Math.max(
0,
Math.min(images.length - 1, Math.round(event.nativeEvent.contentOffset.x / width))
)
)
}
renderItem={({ item }) => (
<View style={{ width, flex: 1 }}>
<MobileNativeChatImage
uri={item.url ?? item.path}
alt={item.alt}
fontScale={1}
imageStyle={styles.imageGalleryFill}
/>
</View>
)}
/>
</View>
</Modal>
)
}
3 changes: 3 additions & 0 deletions mobile/src/session/MobileNativeChatMessage.android.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vi.mock('../layout/side-safe-area', () => ({
useWindowSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 })
}))
import { createElement, type ReactNode } from 'react'
import { act, create, type ReactTestInstance, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
Expand Down
Loading