The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): settle a warm resume through activate when replay is lost
teknium132cf269d9153
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.tsindex e87c6acdad5..3feafb7f131 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts@@ -1293,8 +1293,17 @@ export function useSessionActions({try {const replay = pendingSessionReplay(cachedRuntimeId)- if (replay && (!(await replay) || !isCurrentResume())) {- return+ // Only ordering matters here. A lost socket (false) still goes on+ // to session.activate so its existing branches own the outcome:+ // degraded warm cache on a transport error, cold resume when the+ // runtime is gone, or a normal rebind on a redialed socket (whose+ // history publication is re-gated after the REST read below).+ if (replay) {+ await replay++ if (!isCurrentResume()) {+ return+ }}let activated: SessionResumeResult | null = nulldiff --git a/apps/desktop/src/app/session/hooks/warm-resume-replay-barrier.test.tsx b/apps/desktop/src/app/session/hooks/warm-resume-replay-barrier.test.tsxindex 42702125d98..b348449d2ce 100644--- a/apps/desktop/src/app/session/hooks/warm-resume-replay-barrier.test.tsx+++ b/apps/desktop/src/app/session/hooks/warm-resume-replay-barrier.test.tsx@@ -245,3 +245,36 @@ it('waits for reconnect replay before activating and reading warm history', asynclient.close()}})++it('still settles a warm resume through session.activate when its replay socket is lost', async () => {+ const { result, client, requestGateway } = await mountWithPendingReplay()++ requestGateway.mockImplementation(async (method: string) => {+ if (method === 'session.activate') {+ throw new Error('session not found')+ }++ return snapshot+ })++ try {+ let pending!: Promise<void>+ await act(async () => {+ pending = result.current.actions.resumeSession(storedId, true)+ })+ expect(activateCalls(requestGateway)).toHaveLength(0)++ await act(async () => {+ client.invalidate()+ await pending+ })++ // A lost socket is not proof the runtime is alive or gone: activation+ // decides, and a gone runtime falls back to a cold resume instead of+ // leaving the view on an unrebound warm cache.+ expect(activateCalls(requestGateway)).toHaveLength(1)+ expect(requestGateway.mock.calls.some(([method]) => method === 'session.resume')).toBe(true)+ } finally {+ client.close()+ }+})