diff --git a/src/renderer/src/runtime/hosts/observations/provider-runtime-context.ts b/src/renderer/src/runtime/hosts/observations/provider-runtime-context.ts index ac75e604382..58dde7fa4e6 100644 --- a/src/renderer/src/runtime/hosts/observations/provider-runtime-context.ts +++ b/src/renderer/src/runtime/hosts/observations/provider-runtime-context.ts @@ -29,3 +29,7 @@ export function bumpProviderRuntimeSessionGeneration(): number { providerRuntimeSessionGeneration += 1 return providerRuntimeSessionGeneration } + +export function resetProviderRuntimeSessionGenerationForTests(): void { + providerRuntimeSessionGeneration = 0 +} diff --git a/src/renderer/src/store/testing/app-store-test-fixture.ts b/src/renderer/src/store/testing/app-store-test-fixture.ts index 75587a48103..09b9c3727ee 100644 --- a/src/renderer/src/store/testing/app-store-test-fixture.ts +++ b/src/renderer/src/store/testing/app-store-test-fixture.ts @@ -59,6 +59,7 @@ import '@/i18n/i18n' import { withEditorBufferRecords } from '../slices/editor/buffers/editor-buffer-record-lifecycle' import { withAgentConversationRetention } from '../slices/agent-status/agent-conversation-retention' import { TEST_REPO } from '../repos/repo.test-fixture' +import { resetProviderRuntimeSessionGenerationForTests } from '@/runtime/hosts/observations/provider-runtime-context' const withTestStorePolicies = (creator: StateCreator, check: boolean) => withEditorBufferRecords(withAgentConversationRetention(creator), check) @@ -66,6 +67,8 @@ const withTestStorePolicies = (creator: StateCreator, check: b export function createTestStore( isClaudeAgent: Parameters[3] = undefined ) { + // Why: the session generation is module state; a shared test worker would carry another file's bumps into this store. + resetProviderRuntimeSessionGenerationForTests() // Why the record middleware: views of one file share a record only through it, as in the app. return create()( withTestStorePolicies(