Fix stale legacy file inventory generation guard

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-09 15:35:05 -04:00
parent 1ec6db4a4e
commit 55865697a2
@@ -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<RpcClient['sendRequest']>((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<RpcClient['sendRequest']>(async (method, params) => {
if (method === 'files.searchPaths') {