Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
65fb070
fix(native-chat): save every chat reply and tool output whole; bound …
brennanb2025 Oct 17, 2026
f76af6b
test(native-chat): an over-budget history item is shortened and marke…
brennanb2025 Oct 17, 2026
7c5006c
fix(native-chat): format, keep the sink and projection under the line…
brennanb2025 Oct 17, 2026
f89b4ea
fix(chat): preserve complete writes and keep detail current
brennanb2025 Oct 17, 2026
9533770
test(chat): align final tail reservation with captured content
brennanb2025 Oct 17, 2026
e5ed387
Prototype source-batch journal ownership for Claude
brennanb2025 Oct 17, 2026
bdb49ab
Pin the resolved iterator promise in ownership experiment
brennanb2025 Oct 17, 2026
c796b9a
Revert "Pin the resolved iterator promise in ownership experiment"
brennanb2025 Oct 17, 2026
779d3f5
Revert "Prototype source-batch journal ownership for Claude"
brennanb2025 Oct 17, 2026
130ff37
Preserve large received chat content while pacing input
brennanb2025 Oct 17, 2026
b258506
Verify received chat writes wait for journal persistence
brennanb2025 Oct 17, 2026
3659455
Close test journal databases before removing temporary roots
brennanb2025 Oct 17, 2026
21c1b1f
Exercise item detail in the cross-version chat wire manifest
brennanb2025 Oct 17, 2026
a8b9136
Pin complete saved output and fitted client publication
brennanb2025 Oct 17, 2026
6b9151c
Exercise Pi exit retention with real journal write pressure
brennanb2025 Oct 17, 2026
9aba430
Settle terminal web test unmount before DOM teardown
brennanb2025 Oct 17, 2026
5455975
Reuse existing readers and contract support in session tests
brennanb2025 Oct 17, 2026
9f1f88a
Reuse measured chat item sizes in history pages
brennanb2025 Oct 17, 2026
fc3a597
fix(chat): derive page form type from reader contract
brennanb2025 Oct 17, 2026
a56e612
fix(chat): open phone user messages while loading full text
brennanb2025 Oct 17, 2026
e2b2dbd
test(native-chat): reuse imperative context provider construction
brennanb2025 Oct 17, 2026
f40c3e1
test(native-chat): format full-content disclosure fixture
brennanb2025 Oct 17, 2026
1888c65
ci: preserve unit shard diagnostics after a timeout
brennanb2025 Oct 17, 2026
87eec4c
ci: retain unit shard output when tests time out
brennanb2025 Oct 17, 2026
0b4991b
ci: expose unit shard watchdog and output stages
brennanb2025 Oct 17, 2026
a95ac75
Revert "ci: expose unit shard watchdog and output stages"
brennanb2025 Oct 17, 2026
abaa79e
Revert "ci: retain unit shard output when tests time out"
brennanb2025 Oct 17, 2026
c7ed2a3
Revert "ci: preserve unit shard diagnostics after a timeout"
brennanb2025 Oct 17, 2026
39e8f80
test: verify complete Claude tool output without large failure diffs
brennanb2025 Oct 17, 2026
2c810f2
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 17, 2026
4b70297
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 18, 2026
ee09041
Simplify reply extraction in cross-version session test
brennanb2025 Oct 18, 2026
2289a48
Restore full message recovery for grouped phone thoughts
brennanb2025 Oct 18, 2026
e53bf74
Target recovery button in grouped thought fixture
brennanb2025 Oct 18, 2026
bb39669
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 18, 2026
f1fb1d8
Merge commit '7884f6e738decfa7ee0513ac7f6f19fd768c334e' into brennanb…
brennanb2025 Oct 18, 2026
dbe2e3c
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 19, 2026
b03cd95
Merge current main into chat payload retention branch
brennanb2025 Oct 19, 2026
a63e3a4
test(native-chat): count agentSession.item alongside main's new struc…
brennanb2025 Oct 19, 2026
0c273b1
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 19, 2026
460fb97
Merge remote-tracking branch 'origin/main' into brennanb2025/chat-ful…
brennanb2025 Oct 19, 2026
48f7115
fix(chat): reuse strict session subscription schema
brennanb2025 Oct 19, 2026
73f8ba9
test(chat): open Codex before checking received content
brennanb2025 Oct 19, 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
78 changes: 78 additions & 0 deletions mobile/src/session/MobileNativeChatFullContent.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { createElement } from 'react'
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, expect, it, vi } from 'vitest'
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
import type { RpcClient } from '../transport/rpc-client'
import { MobileNativeChatItemSourceContext } from './mobile-native-chat-item-read'
import { useMobileNativeChatFullMessage } from './MobileNativeChatFullContent'

vi.mock('react-native', () => ({
Pressable: 'Pressable',
Text: 'Text',
View: 'View',
StyleSheet: { create: (value: unknown) => value, hairlineWidth: 1 }
}))
const message: NativeChatMessage = {
id: 'message',
role: 'assistant',
source: 'transcript',
timestamp: 1,
shortened: true,
blocks: [{ type: 'text', text: 'head' }]
}
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Only client identity is used; this fixture performs no RPC.
const first = {} as RpcClient
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Only client identity is used; this fixture performs no RPC.
const second = {} as RpcClient
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let renderer: ReactTestRenderer | undefined
afterEach(() => {
act(() => renderer?.unmount())
})
function Probe() {
return useMobileNativeChatFullMessage(message).showFull
}

it.each(['client', 'session'] as const)(
'keeps a pending or failed request with its original %s owner',
async (changed) => {
const pending = Promise.withResolvers<void>()
const oldLoad = vi.fn(() => pending.promise)
const newLoad = vi.fn(async () => {})
const source = (client: RpcClient, sessionId: string, load: () => Promise<void>) => ({
client,
sessionId,
messageDetail: { raw: () => message, state: () => 'available' as const, load }
})
const render = (value: ReturnType<typeof source>) =>
createElement(MobileNativeChatItemSourceContext.Provider, { value }, createElement(Probe))
await act(async () => {
renderer = create(render(source(first, 'session', oldLoad)))
})
const button = () => renderer?.root.findByProps({ accessibilityRole: 'button' })
await act(async () => {
button()?.props.onPress()
})
expect(button()?.props.disabled).toBe(true)
await act(async () => {
renderer?.update(
render(
source(
changed === 'client' ? second : first,
changed === 'session' ? 'other' : 'session',
newLoad
)
)
)
})
expect(button()?.props.disabled).toBe(false)
await act(async () => {
pending.reject(new Error('old host failed'))
await pending.promise.catch(() => {})
})
expect(JSON.stringify(renderer?.toJSON())).not.toContain("couldn't load")
await act(async () => {
button()?.props.onPress()
})
expect(newLoad).toHaveBeenCalledOnce()
}
)
171 changes: 171 additions & 0 deletions mobile/src/session/MobileNativeChatFullContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import { useContext, useEffect, useState } from 'react'
import { Pressable, Text, View } from 'react-native'
import {
truncateToolDetail,
MAX_TOOL_DETAIL_LENGTH
} from '../../../src/shared/native-chat-tool-summary'
import type {
NativeChatMessage,
NativeChatToolResultBlock
} from '../../../src/shared/native-chat-types'
import type {
AgentJournalBoundedPayload,
AgentJournalItemBody
} from '../../../src/shared/agent-session-journal-types'
import { styles } from './mobile-native-chat-message-styles'
import {
MobileNativeChatItemSourceContext,
readMobileNativeChatItem
} from './mobile-native-chat-item-read'

// "Show full output" and "Show full message": a row the phone was sent a head of, read whole from
// the host that keeps it. State is the row's own, so a live revision never fights it.

type Load = 'idle' | 'loading' | 'failed'

function ShowFull({
label,
load,
onPress
}: {
label: string
load: Load
onPress: () => void
}): React.JSX.Element {
return (
<Pressable
style={styles.showFull}
onPress={onPress}
disabled={load === 'loading'}
hitSlop={8}
accessibilityRole="button"
>
<Text style={styles.showFullText}>
{load === 'failed' ? `${label} — couldn't load, tap to retry` : label}
</Text>
</Pressable>
)
}

function outputOf(body: AgentJournalItemBody | null): AgentJournalBoundedPayload | null {
if (body?.kind === 'tool-call') {
return body.output ?? null
}
return body?.kind === 'diff' ? body.patch : null
}

/** A tool's output in an opened line: its head, and the whole of it on request. */
export function MobileNativeChatToolOutput({
body
}: {
body: NativeChatToolResultBlock
}): React.JSX.Element {
const source = useContext(MobileNativeChatItemSourceContext)
const { output, isError, fullOutputItemId } = body
const client = source?.client,
sessionId = source?.sessionId
const [expanded, setExpanded] = useState(false)
const [detail, setDetail] = useState<{
body: typeof body
client: typeof client
sessionId: typeof sessionId
full?: AgentJournalBoundedPayload
load: Load
} | null>(null)
useEffect(
() => () =>
setDetail((held) =>
held?.body === body && held.client === client && held.sessionId === sessionId ? null : held
),
[body, client, sessionId]
)
const current =
detail?.body === body && detail.client === client && detail.sessionId === sessionId
? detail
: null
const full = current?.full
const clipped =
!full &&
(fullOutputItemId !== undefined || (!expanded && output.length > MAX_TOOL_DETAIL_LENGTH))
const showFull = (): void => {
if (fullOutputItemId === undefined || source === null) {
setExpanded(true)
return
}
setDetail({ body, client, sessionId, load: 'loading' })
const finish = (full?: AgentJournalBoundedPayload): void => {
setDetail((held) =>
held?.body === body && held.client === client && held.sessionId === sessionId
? { body, client, sessionId, full, load: full ? 'idle' : 'failed' }
: held
)
}
readMobileNativeChatItem(source, fullOutputItemId)
.then((item) =>
finish(item?.itemId === fullOutputItemId ? (outputOf(item.body) ?? undefined) : undefined)
)
.catch(() => finish())
}
return (
<View>
<View style={[styles.toolResult, isError && styles.toolResultError]}>
<Text style={styles.mono}>
{full ? full.head : expanded ? output : truncateToolDetail(output)}
</Text>
</View>
{full?.truncated ? (
<Text style={styles.showFullText}>
Showing {new TextEncoder().encode(full.head).length} of {full.byteLength} bytes.
</Text>
) : null}
{clipped ? (
<ShowFull label="Show full output" load={current?.load ?? 'idle'} onPress={showFull} />
) : null}
</View>
)
}

/** `message` as drawn: whole once the reader asked for a reply the phone was sent shortened. */
export function useMobileNativeChatFullMessage(message: NativeChatMessage): {
shown: NativeChatMessage
showFull: React.JSX.Element | null
} {
const source = useContext(MobileNativeChatItemSourceContext)
const detail = source?.messageDetail
const client = source?.client,
sessionId = source?.sessionId
const raw = detail?.raw(message.id)
const [request, setRequest] = useState<{
raw: typeof raw
client: typeof client
sessionId: typeof sessionId
load: Load
} | null>(null)
const load =
request?.raw === raw && request?.client === client && request?.sessionId === sessionId
? (request?.load ?? 'idle')
: 'idle'
const state = detail?.state(message.id)
const showFull = (): void => {
setRequest({ raw, client, sessionId, load: 'loading' })
const finish = (load: Load): void =>
setRequest((held) =>
held?.raw === raw && held?.client === client && held?.sessionId === sessionId
? { raw, client, sessionId, load }
: held
)
void detail
?.load(message.id)
.then(() => finish('idle'))
.catch(() => finish('failed'))
}
return {
shown: message,
showFull:
state === 'partial' ? (
<Text style={styles.showFullText}>Showing part of this message.</Text>
) : state === 'available' ? (
<ShowFull label="Show full message" load={load} onPress={showFull} />
) : null
}
}
6 changes: 5 additions & 1 deletion mobile/src/session/MobileNativeChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ import type { NativeChatTurnStatus } from './use-mobile-native-chat-turn-status'
import { styles } from './mobile-native-chat-message-styles'
import { agentMessageAttribution } from './mobile-agent-message-attribution'
import { MobileNativeChatVisualContext } from './mobile-native-chat-visual-context'
import { useMobileNativeChatFullMessage } from './MobileNativeChatFullContent'
import { MobileNativeChatPacedProse } from './MobileNativeChatPacedProse'
import { Prose } from './MobileNativeChatProse'

function MobileNativeChatMessageImpl({
message,
message: rowMessage,
mayStillGrow = false,
toolsExpanded = false,
fontScale = 1,
Expand Down Expand Up @@ -100,6 +101,7 @@ function MobileNativeChatMessageImpl({
userMessageOpen?: boolean
onToggleUserMessage?: (messageId: string) => void
}): React.JSX.Element {
const { shown: message, showFull } = useMobileNativeChatFullMessage(rowMessage)
// Another agent's message is set apart from the person's bubble, left-aligned and named.
const attribution = agentMessageAttribution('Message from', message.from)
const isUser = message.role === 'user' && attribution === null
Expand Down Expand Up @@ -198,6 +200,7 @@ function MobileNativeChatMessageImpl({
onOpenFile={onOpenFile}
onLongPress={onLongPress}
/>
{showFull}
</View>
) : null}
{turnStatusAbove ? null : statusRow}
Expand Down Expand Up @@ -280,6 +283,7 @@ function MobileNativeChatMessageImpl({
{(block, index, shown) => proseRow(block, index, shown.text, shown.revealing)}
</MobileNativeChatPacedProse>
)}
{showFull}
{askRow}
{showToolRun ? (
<ToolRun
Expand Down
Loading
Loading