diff --git a/config/scripts/native-chat-tool-pairing-benchmark.mjs b/config/scripts/native-chat-tool-pairing-benchmark.mjs index cc6479bfe61..937a02050d1 100644 --- a/config/scripts/native-chat-tool-pairing-benchmark.mjs +++ b/config/scripts/native-chat-tool-pairing-benchmark.mjs @@ -27,10 +27,14 @@ async function load(source, sourcefile = 'src/shared/native-chat-tool-fold.ts') setup(builder) { builder.onResolve({ filter: /^\./ }, (args) => { const target = path.resolve(args.resolveDir, args.path) - for (const name of ['native-chat-tool-pairs', 'native-chat-folded-tool-results']) { + for (const [name, directory] of [ + ['native-chat-tool-pairs', 'src/shared/native-chat/tools'], + ['native-chat-folded-tool-results', 'src/shared/native-chat/tools'], + ['native-chat-provider-frame-summary', 'src/shared/native-chat'] + ]) { const previous = path.join(root, 'src/shared', name) if (target === previous || target === `${previous}.ts`) { - return { path: path.join(root, 'src/shared/native-chat/tools', `${name}.ts`) } + return { path: path.join(root, directory, `${name}.ts`) } } } return undefined diff --git a/mobile/src/session/mobile-native-chat-blocks.test.ts b/mobile/src/session/mobile-native-chat-blocks.test.ts index 5d8fe46e41b..8542396aa52 100644 --- a/mobile/src/session/mobile-native-chat-blocks.test.ts +++ b/mobile/src/session/mobile-native-chat-blocks.test.ts @@ -76,7 +76,7 @@ describe('pairToolBlocks', () => { expect(pairs[1]).toEqual({ call: call2, result: result2 }) }) - it('retains the last result while bounding rendered pairs', () => { + it('keeps the first completed pairs at the rendering limit', () => { const blocks = Array.from({ length: 20 }, (_unused, index) => [ { type: 'tool-call' as const, name: 'Bash', input: { index } }, { type: 'tool-result' as const, output: String(index) } diff --git a/mobile/src/session/mobile-native-chat-diff.test.ts b/mobile/src/session/mobile-native-chat-diff.test.ts index 6a1d44b0b61..751031d8277 100644 --- a/mobile/src/session/mobile-native-chat-diff.test.ts +++ b/mobile/src/session/mobile-native-chat-diff.test.ts @@ -1,54 +1,7 @@ import { describe, expect, it } from 'vitest' -import { - diffFromText, - diffFromToolCall -} from '../../../src/shared/native-chat/tools/native-chat-diff' - -describe('diffFromToolCall', () => { - it('builds del/add lines from an Edit tool call', () => { - const lines = diffFromToolCall('Edit', { - file_path: 'src/a.ts', - old_string: 'const a = 1\nconst b = 2', - new_string: 'const a = 10' - }) - expect(lines).toEqual([ - { kind: 'meta', text: 'src/a.ts' }, - { kind: 'del', text: 'const a = 1' }, - { kind: 'del', text: 'const b = 2' }, - { kind: 'add', text: 'const a = 10' } - ]) - }) - - it('returns null for non-edit tools', () => { - expect(diffFromToolCall('Bash', { command: 'ls' })).toBeNull() - }) -}) +import { diffFromText } from '../../../src/shared/native-chat/tools/native-chat-diff' describe('diffFromText', () => { - it('parses unified diff lines with colours', () => { - const lines = diffFromText('@@ -1,2 +1,2 @@\n context\n-old\n+new') - expect(lines).toEqual([ - { kind: 'meta', text: '@@ -1,2 +1,2 @@' }, - { kind: 'context', text: ' context' }, - { kind: 'del', text: 'old' }, - { kind: 'add', text: 'new' } - ]) - }) - - it('does not treat ordinary prose as a diff', () => { - expect(diffFromText('Here is a list:\n- one bullet\nthat is all')).toBeNull() - }) - - it('counts a removed -- comment line despite the --- prefix collision', () => { - const lines = diffFromText('@@ -1,2 +1,2 @@\n ctx\n---sql comment\n+new') - expect(lines).toEqual([ - { kind: 'meta', text: '@@ -1,2 +1,2 @@' }, - { kind: 'context', text: ' ctx' }, - { kind: 'del', text: '--sql comment' }, - { kind: 'add', text: 'new' } - ]) - }) - it('caps large diffs before creating render rows', () => { const text = Array.from( { length: 1_000 }, diff --git a/mobile/src/session/mobile-native-chat-reading-place.test.tsx b/mobile/src/session/mobile-native-chat-reading-place.test.tsx index f50f05c6a66..67725126db8 100644 --- a/mobile/src/session/mobile-native-chat-reading-place.test.tsx +++ b/mobile/src/session/mobile-native-chat-reading-place.test.tsx @@ -90,7 +90,16 @@ vi.stubGlobal( } ) +const mountedRenderers = new Set() + afterEach(() => { + act(() => { + for (const renderer of mountedRenderers) { + renderer.unmount() + } + }) + mountedRenderers.clear() + scrollable.node = null vi.useRealTimers() vi.restoreAllMocks() }) @@ -285,6 +294,7 @@ function mount( let renderer!: ReactTestRenderer act(() => { renderer = create(h('div')) + mountedRenderers.add(renderer) }) const scroller = page(() => renderer.toJSON()) scrollable.node = scroller