Skip to content

The agent that grows with you

fix(desktop): preserve transient approval errors

Shinji Kanekoc37181a4ecbd
diff --git a/apps/desktop/src/store/prompts.test.ts b/apps/desktop/src/store/prompts.test.ts
index 015a47542df..6e121c5b9ef 100644
--- a/apps/desktop/src/store/prompts.test.ts
+++ b/apps/desktop/src/store/prompts.test.ts
@@ -17,7 +17,7 @@ import {
setSecretRequest,
setSudoRequest
} from './prompts'
-import { $activeSessionId } from './session'
+import { $activeSessionId, setActiveSessionId } from './session'
import { isSessionGone, resetBackgroundPollingGuard } from './runtime-gone'
// Prompts are parked per-session; the exported $*Request views are scoped to the
@@ -169,6 +169,21 @@ describe('approval prompt store', () => {
expect(isSessionGone('dead-runtime')).toBe(true)
expect($approvalRequest.get()?.requestId).toBe('r1')
})
+
+ it('propagates transient approval receipt failures without latching the runtime', async () => {
+ const request = vi.fn(async () => {
+ throw new Error('gateway timed out')
+ })
+
+ setActiveSessionId('transient-runtime')
+
+ await expect(
+ receiveApprovalRequest({ request }, { command: 'x', description: 'd', requestId: 'r2', sessionId: 'transient-runtime' })
+ ).rejects.toThrow('gateway timed out')
+
+ expect(isSessionGone('transient-runtime')).toBe(false)
+ expect($approvalRequest.get()?.requestId).toBe('r2')
+ })
})
describe('sudo prompt store', () => {
diff --git a/apps/desktop/src/store/prompts.ts b/apps/desktop/src/store/prompts.ts
index 419de6b3a7b..876d37e8f9b 100644
--- a/apps/desktop/src/store/prompts.ts
+++ b/apps/desktop/src/store/prompts.ts
@@ -134,7 +134,11 @@ export async function receiveApprovalRequest(gateway: ApprovalGateway | null, re
} catch (error) {
if (isSessionGoneForBackgroundPolling(error)) {
markSessionGone(request.sessionId)
+
+ return
}
+
+ throw error
}
}
}