diff --git a/mobile/src/session/native-chat/mobile-native-chat-render-data.test.ts b/mobile/src/session/native-chat/mobile-native-chat-render-data.test.ts index 48c20ffab96..05e017fb0e4 100644 --- a/mobile/src/session/native-chat/mobile-native-chat-render-data.test.ts +++ b/mobile/src/session/native-chat/mobile-native-chat-render-data.test.ts @@ -21,120 +21,7 @@ function user(id: string, text: string): NativeChatMessage { const fold = (messages: NativeChatMessage[]) => foldMobileNativeChatMessages(messages, 'claude') -function build( - messages: NativeChatMessage[], - streaming: string | null, - pending: Parameters[0]['pending'] -): NativeChatMessage[] { - return buildMobileNativeChatTransientData({ - folded: fold(messages), - streaming, - pending - }).data -} - describe('buildMobileNativeChatTransientData', () => { - it('places an idle send before the streaming reply it caused', () => { - const data = build([assistant('a1', 'Earlier answer')], 'Starting the tests', [ - { id: 'p1', text: 'Run the tests', sentAt: 100 } - ]) - expect(data.map((message) => message.id)).toEqual(['a1', 'p1', 'streaming']) - }) - - it('folds transcript image marker turns into image-ref blocks (desktop parity)', () => { - const data = build( - [ - user('u1', '[Image: source: /tmp/a.png]'), - user('u2', '[Image #1] look at this'), - assistant('a1', 'nice photo') - ], - null, - [] - ) - const merged = data.find((message) => message.role === 'user') - expect(merged?.blocks).toEqual([ - { type: 'image-ref', path: '/tmp/a.png' }, - { type: 'text', text: 'look at this' } - ]) - }) - - it('folds a trailing-marker image echo into one user bubble', () => { - const data = build( - [user('u1', '[Image: source: /tmp/a.png]'), user('u2', 'look at this[Image #1]')], - null, - [] - ) - - expect(data).toHaveLength(1) - expect(data[0]?.blocks).toEqual([ - { type: 'image-ref', path: '/tmp/a.png' }, - { type: 'text', text: 'look at this' } - ]) - }) - - it('leaves out an unrecognised provider event with no words, but keeps failures and sentences', () => { - const frameRow = ( - id: string, - kind: string, - text: string, - tone?: string - ): NativeChatMessage => ({ - id, - role: 'system', - timestamp: 0, - source: 'transcript', - blocks: [ - { - type: 'text', - text, - ...(tone ? { tone } : {}), - providerFrame: { - provider: 'codex', - kind, - payload: { head: '{}', byteLength: 2, digest: 'digest', truncated: false } - } - } - ] - }) - const folded = fold([ - frameRow('wordless', 'notification:future/event', 'codex · notification:future/event'), - frameRow( - 'failure', - 'notification:future/failure', - 'codex · notification:future/failure', - 'error' - ), - frameRow('sentence', 'notification:warning', 'Sandbox is degraded.'), - assistant('a1', 'done') - ]) - expect(folded.map((message) => message.id)).toEqual(['failure', 'sentence', 'a1']) - }) - - it('draws a turn’s subagents, each written as its own row, as one roster row', () => { - const own = (id: string): NativeChatMessage => ({ - id: `subagent:${id}`, - role: 'system', - blocks: [ - { type: 'text', text: `Kicked off subagent ${id}` }, - { type: 'subagent', id, label: id, state: 'working', groupId: 'turn-1' } - ], - timestamp: 0, - source: 'transcript' - }) - const folded = fold([user('u1', 'audit'), own('a'), assistant('a1', 'started'), own('b')]) - expect(folded.map((message) => message.id)).toEqual(['u1', 'subagent:a', 'a1']) - expect(folded[1]?.blocks).toEqual([ - { - type: 'subagent-group', - groupId: 'turn-1', - agents: [ - { id: 'a', label: 'a', state: 'working' }, - { id: 'b', label: 'b', state: 'working' } - ] - } - ]) - }) - it('keeps the phone-local image visible when the transcript replaces its optimistic echo', () => { const folded = fold([ user('source', '[Image: source: /tmp/a.png]'), @@ -164,14 +51,6 @@ describe('buildMobileNativeChatTransientData', () => { expect(result.data[0]?.blocks).toEqual([{ type: 'image-ref', url: 'file:///phone-photo.jpg' }]) }) - - it('keeps a queued follow-up after the current streaming reply', () => { - const data = build([user('u1', 'hi')], 'thinking out loud', [ - { id: 'p1', text: 'queued', pendingSend: 'queued' } - ]) - expect(data.map((message) => message.id)).toEqual(['u1', 'streaming', 'p1']) - expect(data[1].blocks).toEqual([{ type: 'text', text: 'thinking out loud' }]) - }) }) describe('foldMobileNativeChatMessages', () => { @@ -195,16 +74,6 @@ describe('foldMobileNativeChatMessages', () => { } } - // Read windows may begin after tool_use; leading orphan results must not become raw-output bubbles. - it('drops a leading tool result whose call is older than the read window', () => { - const folded = fold([ - toolResult('orphan', 'Exit code 1\norca-ide not found'), - assistant('a1', 'Falling back to the installed binary.') - ]) - - expect(folded.map((message) => message.id)).toEqual(['a1']) - }) - function planFrame(head: string): NativeChatMessage { return { id: 'plan', @@ -240,60 +109,6 @@ describe('foldMobileNativeChatMessages', () => { blocks: [{ type: 'tool-call', name: 'update_plan', state: 'completed' }] }) }) - - it('still folds a result whose call is inside the window', () => { - const folded = fold([ - assistant('a1', 'Checking which binary is on PATH.'), - toolCall('c1'), - toolResult('r1', 'orca-ide not found') - ]) - - expect(folded).toHaveLength(1) - expect(folded[0]?.blocks.map((block) => block.type)).toEqual([ - 'text', - 'tool-call', - 'tool-result' - ]) - }) - - it('keeps a mixed Claude tool result with a harness sidecar paired', () => { - const folded = fold([ - toolCall('c1'), - { - id: 'mixed', - role: 'user', - blocks: [ - { type: 'tool-result', output: 'important output' }, - { type: 'text', text: 'continue' } - ], - timestamp: 0, - source: 'transcript' - } - ]) - - expect(folded[0]?.blocks).toEqual([ - { type: 'tool-call', name: 'Bash', input: { command: 'command -v orca-ide' } }, - { type: 'tool-result', output: 'important output' } - ]) - }) - - it('draws a skill command the user ran as their message, as desktop does', () => { - const folded = fold([ - { - ...user( - 'd7306d00', - 'hello\n/hello\nKelvin' - ), - parentId: 'f615a2bf' - }, - { ...assistant('0d3481c0', 'Hello, Kelvin!'), parentId: 'fa9d5ee6' } - ]) - - expect(folded.map((message) => [message.role, message.blocks])).toEqual([ - ['user', [{ type: 'text', text: '/hello Kelvin' }]], - ['assistant', [{ type: 'text', text: 'Hello, Kelvin!' }]] - ]) - }) }) // Claude may consume queued commands without a user record; unmatched echoes must stay at their send position rather than trail every later turn. diff --git a/mobile/src/session/native-chat/transcript/MobileNativeChatMessage.status-notices.test.ts b/mobile/src/session/native-chat/transcript/MobileNativeChatMessage.status-notices.test.ts index ef5a04f9c39..31f565395c6 100644 --- a/mobile/src/session/native-chat/transcript/MobileNativeChatMessage.status-notices.test.ts +++ b/mobile/src/session/native-chat/transcript/MobileNativeChatMessage.status-notices.test.ts @@ -164,7 +164,7 @@ describe('MobileNativeChatMessage status notices', () => { ]) }) - it.each(['without reset', 'with reset', 'from an old host'] as const)( + it.each(['with reset', 'from an old host'] as const)( 'draws an OpenCode usage warning %s', (source) => { const hasReset = source === 'with reset' @@ -221,12 +221,9 @@ describe('MobileNativeChatMessage status notices', () => { ) it.each([ - ['Claude', 'system', 'claude auth login'], ['Claude', 'managed', 'claude auth login'], ['Codex', 'system', 'codex login --device-auth'], - ['Codex', 'managed', null], - ['Grok', undefined, 'grok login --device-auth'], - ['Antigravity', undefined, null] + ['Codex', 'managed', null] ] as const)( 'offers %s (%s account) sign-in in a host terminal', (agentName, account, command) => { @@ -263,14 +260,6 @@ describe('MobileNativeChatMessage status notices', () => { 'Codex reported a safety review warning. View details.', 'Codex a signalé un avertissement de sécurité. Voir les détails.', colors.statusAmber - ], - [ - 'claude', - 'message:system:permission_denied', - 'error', - 'Claude denied permission. View details.', - 'Claude a refusé la permission. Voir les détails.', - colors.statusRed ] ] as const)( 'discloses the entire available %s notice without tool-output clipping or recovery',