From d1969b0e25f23d92be2a16ad9d0624089ad56f68 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Sat, 17 Oct 2026 11:23:56 +0200 Subject: [PATCH 1/2] agentHost: fix flaky chat movability test racing a background catalog write The "movability follows the events" test parks the source session and expects its peer chat to stop being movable. The earlier steps of the test flip the chat's movable flag, which marks the session summary dirty; its debounced (100 ms) flush queues a background catalog write for the session. On a slow machine that write can overlap the parking step: it bumps the session's payload dirty marker, so `_park` declines as superseded, and when it ends pending it also wakes the session. Either way the chat stays movable. Stop queueing background catalog writes and drain those in flight before parking, so the dirty marker the test passes to `_park` stays current. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/vs/platform/agentHost/test/node/agentService.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/platform/agentHost/test/node/agentService.test.ts b/src/vs/platform/agentHost/test/node/agentService.test.ts index 642307281f0ed3..974bcd9abd7ebc 100644 --- a/src/vs/platform/agentHost/test/node/agentService.test.ts +++ b/src/vs/platform/agentHost/test/node/agentService.test.ts @@ -33648,6 +33648,7 @@ suite('AgentService (node dispatcher)', () => { _catalogReconciliationService: { _park(registered: Pick, observedDirty: number | undefined, observedWakeGeneration: number, reason: 'sourceUnresolvable'): Promise; readonly _wakeGeneration: number; wakeParkedSessions(session?: string): void }; _sessionStateStore: { peek(session: URI): { readonly authority: 1 | 2 } | undefined }; _sessionDataService: ISessionDataService; + _queueCatalogSync(session: URI, metadataOverrides: Readonly>): void; }; const movable = () => stateManager.getSessionState(source.toString())?.chats.find(chat => chat.resource === peer.toString())?.movable ?? false; const settled = async () => { @@ -33678,6 +33679,11 @@ suite('AgentService (node dispatcher)', () => { // The catalog reconciliation reports a session it parked, and its release; a parked session's legacy catalog can't convert. const peek = internals._sessionStateStore.peek.bind(internals._sessionStateStore); internals._sessionStateStore.peek = resource => resource.toString() === source.toString() ? { ...peek(resource)!, authority: 1 } : peek(resource); + // Each movability change above updates the session's summary, whose debounced flush queues a background catalog + // write of the session: it bumps the session's payload dirty marker, so `_park` declines as superseded, and a write + // left pending wakes the session again. None are queued from now on, and those in flight finish before it parks. + internals._queueCatalogSync = () => { }; + await service.whenCatalogReconciliationIdle(); await internals._catalogReconciliationService._park({ session: source, provider: 'copilot' }, await getTestAgentHostDatabase(service).getSessionV2PayloadDirty(source.toString()), internals._catalogReconciliationService._wakeGeneration, 'sourceUnresolvable'); const parked = await settled(); internals._catalogReconciliationService.wakeParkedSessions(source.toString()); From e4f75ef6e3d0cb109f731988c7c43642f8df73ac Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Sat, 17 Oct 2026 13:00:04 +0200 Subject: [PATCH 2/2] agentHost: flush the summary instead of disabling catalog writes in the movability test Rather than replacing `_queueCatalogSync` with a no-op, flush the session's dirty summary through `prepareSessionSummariesForListing` (as a listing does), which queues its catalog write now instead of after the 100 ms debounce, and drain it before parking. The test also records `_park`'s reason, so a future regression reports `superseded` instead of only `parked: true`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../agentHost/test/node/agentService.test.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/vs/platform/agentHost/test/node/agentService.test.ts b/src/vs/platform/agentHost/test/node/agentService.test.ts index 974bcd9abd7ebc..47099d606ae6af 100644 --- a/src/vs/platform/agentHost/test/node/agentService.test.ts +++ b/src/vs/platform/agentHost/test/node/agentService.test.ts @@ -33645,10 +33645,9 @@ suite('AgentService (node dispatcher)', () => { const stateManager = getStateManager(service); const internals = service as unknown as IMoveInternals & { _workspaceConversionService: { restoreChatIsolation(session: string, chat: string, storage: string): Promise }; - _catalogReconciliationService: { _park(registered: Pick, observedDirty: number | undefined, observedWakeGeneration: number, reason: 'sourceUnresolvable'): Promise; readonly _wakeGeneration: number; wakeParkedSessions(session?: string): void }; + _catalogReconciliationService: { _park(registered: Pick, observedDirty: number | undefined, observedWakeGeneration: number, reason: 'sourceUnresolvable'): Promise<{ readonly reason: string }>; readonly _wakeGeneration: number; wakeParkedSessions(session?: string): void }; _sessionStateStore: { peek(session: URI): { readonly authority: 1 | 2 } | undefined }; _sessionDataService: ISessionDataService; - _queueCatalogSync(session: URI, metadataOverrides: Readonly>): void; }; const movable = () => stateManager.getSessionState(source.toString())?.chats.find(chat => chat.resource === peer.toString())?.movable ?? false; const settled = async () => { @@ -33679,21 +33678,21 @@ suite('AgentService (node dispatcher)', () => { // The catalog reconciliation reports a session it parked, and its release; a parked session's legacy catalog can't convert. const peek = internals._sessionStateStore.peek.bind(internals._sessionStateStore); internals._sessionStateStore.peek = resource => resource.toString() === source.toString() ? { ...peek(resource)!, authority: 1 } : peek(resource); - // Each movability change above updates the session's summary, whose debounced flush queues a background catalog - // write of the session: it bumps the session's payload dirty marker, so `_park` declines as superseded, and a write - // left pending wakes the session again. None are queued from now on, and those in flight finish before it parks. - internals._queueCatalogSync = () => { }; + // The movability changes above left the session's summary dirty. Its debounced (100 ms) flush queues a catalog write + // of the session, which bumps the session's payload dirty marker (so `_park` declines as superseded) and, when it + // stays pending, wakes the session. Flush the summary now, as a listing does, and let that write finish first. + stateManager.prepareSessionSummariesForListing([stateManager.getSessionSummary(source.toString())!]); await service.whenCatalogReconciliationIdle(); - await internals._catalogReconciliationService._park({ session: source, provider: 'copilot' }, await getTestAgentHostDatabase(service).getSessionV2PayloadDirty(source.toString()), internals._catalogReconciliationService._wakeGeneration, 'sourceUnresolvable'); + const { reason } = await internals._catalogReconciliationService._park({ session: source, provider: 'copilot' }, await getTestAgentHostDatabase(service).getSessionV2PayloadDirty(source.toString()), internals._catalogReconciliationService._wakeGeneration, 'sourceUnresolvable'); const parked = await settled(); internals._catalogReconciliationService.wakeParkedSessions(source.toString()); - outcomes.parked = { parked, released: await settled() }; + outcomes.parked = { reason, parked, released: await settled() }; assert.deepStrictEqual(outcomes, { // A refused move still says why, not just that the chat isn't movable. worktree: { inWorktree: false, worktreeRefusal: AgentChatMoveRefusal.WorktreeFolder, released: true }, conversion: { quarantined: false, released: true }, - parked: { parked: false, released: true }, + parked: { reason: 'sourceUnresolvable', parked: false, released: true }, }); });