Skip to content

The agent that grows with you

fix(desktop): guard the session-info running=false clarify clear too

Brooklyn Nicholsonadb1cbde320f
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
index 7eef88f402e..3e6d426c6ed 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
@@ -295,6 +295,31 @@ describe('clarify request stream hydration', () => {
expect($clarifyRequests.get()[SID]).toBeUndefined()
})
+ it('keeps a live clarify card through a stale session.info running=false snapshot (#83319)', () => {
+ mountStream()
+
+ // The state a reconnect replays from: the turn was live (busy) when the
+ // backend parked the clarify request. The session.info snapshot riding
+ // the reconnect predates the clarify, so its running=false is stale —
+ // the same wipe class as the spurious turn-end/error clears.
+ const state = createClientSessionState()
+ state.busy = true
+ state.awaitingResponse = true
+ stream.states.set(SID, state)
+
+ clarifyRequest({ choices: ['a', 'b'], question: 'Pick', request_id: 'req-live' })
+
+ act(() =>
+ stream.handleEvent({ payload: { running: false }, session_id: SID, type: 'session.info' })
+ )
+
+ expect($clarifyRequests.get()[SID]?.requestId).toBe('req-live')
+
+ // And the clear still fires once the request truly settles.
+ clarifyExpire('req-live')
+ expect($clarifyRequests.get()[SID]).toBeUndefined()
+ })
+
it('merges a BATCH tool.start row with its clarify.request (no top-level question)', () => {
mountStream()
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/session-info.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/session-info.ts
index 08580ba8669..d8d4785d88c 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/session-info.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/session-info.ts
@@ -1,7 +1,7 @@
import { normalizePersonalityValue } from '@/lib/chat-runtime'
import { modelOptionsQueryKey } from '@/lib/model-options'
import { reconcileApprovalModeForProfile } from '@/store/approval-mode'
-import { clearClarifyRequest } from '@/store/clarify'
+import { clearSettledClarifyRequest } from '@/store/clarify'
import { reconcileSessionCompacting } from '@/store/compaction'
import { requestDesktopOnboardingForCredentialWarning } from '@/store/onboarding'
import { followActiveSessionCwd } from '@/store/projects'
@@ -319,7 +319,11 @@ export function handleSessionInfoEvent(ctx: GatewayEventContext): boolean {
// scoped to this sessionId.
if (!payload!.running && (knownState?.busy || knownState?.awaitingResponse)) {
clearAllPrompts(sessionId)
- clearClarifyRequest(undefined, sessionId)
+ // Same wipe class as the turn-end clears (#83319): a reconnect can
+ // replay a pre-clarify snapshot with running=false while the server
+ // bridge is still parked on the open clarify request — keep the card
+ // while that request is live; clear it when it truly settled.
+ clearSettledClarifyRequest(sessionId)
}
// Set when THIS event releases a confirmed live turn whose terminal