From 55865697a29ebc85ac239c59a08a10b962cb9b73 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Wed, 9 Sep 2026 15:35:05 -0400 Subject: [PATCH] Fix stale legacy file inventory generation guard Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb --- ...ost-session-native-chat-operations.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mobile/src/session/native-host-session-native-chat-operations.test.ts b/mobile/src/session/native-host-session-native-chat-operations.test.ts index dd83768ba8d..7b4522b74cf 100644 --- a/mobile/src/session/native-host-session-native-chat-operations.test.ts +++ b/mobile/src/session/native-host-session-native-chat-operations.test.ts @@ -60,6 +60,27 @@ describe('native host session native chat operations', () => { expect(sendRequest).not.toHaveBeenCalled() }) + it('ignores an older inventory completion after cache reset', async () => { + const deferred: Array<(value: any) => void> = [] + const sendRequest = vi.fn((method) => { + if (method === 'files.searchPaths') + return Promise.resolve({ + ok: false, + error: { code: 'method_not_found', message: 'unsupported' } + }) + return new Promise((resolve) => deferred.push(resolve)) + }) + const operations = nativeHostSessionNativeChatOperations(client(sendRequest)) + const old = operations.searchFiles(target(), 'fresh') + operations.resetFileSearchCache('wt-1') + const fresh = operations.searchFiles(target(), 'fresh') + deferred[1]?.({ ok: true, result: { files: [{ relativePath: 'fresh.ts' }] } }) + await expect(fresh).resolves.toEqual(['fresh.ts']) + deferred[0]?.({ ok: true, result: { files: [{ relativePath: 'old.ts' }] } }) + await old + await expect(operations.searchFiles(target(), 'fresh')).resolves.toEqual(['fresh.ts']) + }) + it('keeps the legacy file inventory scoped to the workspace that produced it', async () => { const sendRequest = vi.fn(async (method, params) => { if (method === 'files.searchPaths') {