Skip to content

The agent that grows with you

fix(desktop): retain deferred session reap candidates

fangliquanflq4e926504b051
diff --git a/apps/desktop/src/app/contrib/hooks/live-status-spinner.test.ts b/apps/desktop/src/app/contrib/hooks/live-status-spinner.test.ts
index ac2ac23ae70..55af21d35a7 100644
--- a/apps/desktop/src/app/contrib/hooks/live-status-spinner.test.ts
+++ b/apps/desktop/src/app/contrib/hooks/live-status-spinner.test.ts
@@ -98,6 +98,26 @@ describe('rehydrateLiveSessionStatuses — seeding a turn the renderer never saw
expect($unreadFinishedSessionIds.get()).toContain('stored-race')
})
+ it('retries absence reconciliation after a newer live event', () => {
+ rehydrateLiveSessionStatuses({
+ sessions: [{ id: 'runtime-race', session_key: 'stored-race', status: 'working' }]
+ })
+ const stateAtRequest = $sessionStates.get()
+
+ publishSessionState('runtime-race', {
+ ...createClientSessionState('stored-race'),
+ busy: true,
+ sawAssistantPayload: true,
+ turnLive: true
+ })
+
+ rehydrateLiveSessionStatuses({ sessions: [] }, Date.now(), 'default', stateAtRequest)
+ expect($workingSessionIds.get()).toContain('stored-race')
+
+ rehydrateLiveSessionStatuses({ sessions: [] })
+ expect($workingSessionIds.get()).not.toContain('stored-race')
+ })
+
it('shows the spinner when a runtime id is recycled onto a new stored session', () => {
// A respawned backend can mint the same runtime id for a different stored
// session. The row for the NEW stored id must light up, not the stale one.
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
index e7e04b8cfb5..e6d6bffbab6 100644
--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
@@ -485,6 +485,7 @@ export function rehydrateLiveSessionStatuses(
const existing = $sessionStates.get()[runtimeSessionId]
if (existing !== stateAtRequest[runtimeSessionId]) {
+ seen.add(runtimeSessionId)
continue
}