The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: bind desktop create retries to the explicit draft intent
Tekniumc69bb4db31c5
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsxindex e8550299c1e..40dd746d939 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx@@ -723,6 +723,26 @@ describe('startFreshSessionDraft', () => {})describe('createBackendSessionForSend profile routing', () => {+ it('reuses the create intent after ACK loss but not after New chat', async () => {+ $newChatRoute.set(null)+ $activeGatewayProfile.set('default')+ const calls: Record<string, unknown>[] = []+ const requestGateway = vi.fn(async (method: string, params?: Record<string, unknown>) => {+ if (method === 'session.create') { calls.push(params!); throw new Error('lost create ACK') }+ return {} as never+ })+ let handle: HarnessHandle | null = null+ render(<Harness onReady={value => { handle = value }} requestGateway={requestGateway} />)+ await waitFor(() => expect(handle).not.toBeNull())+ await act(async () => { await expect(handle!.createBackendSessionForSend()).rejects.toThrow('lost create ACK') })+ await act(async () => { await expect(handle!.createBackendSessionForSend()).rejects.toThrow('lost create ACK') })+ expect(calls[0].request_id).toEqual(expect.any(String))+ expect(calls[1].request_id).toBe(calls[0].request_id)+ act(() => handle!.startFreshSessionDraft())+ await act(async () => { await expect(handle!.createBackendSessionForSend()).rejects.toThrow('lost create ACK') })+ expect(calls[2].request_id).not.toBe(calls[0].request_id)+ })+afterEach(() => {cleanup()$newChatProfile.set(null)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 1766b1765bd..ac8c5bdac64 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@@ -382,6 +382,7 @@ export function useSessionActions({const { t } = useI18n()const copy = t.desktopconst resumeRequestRef = useRef(0)+ const createIntentRef = useRef<string | null>(null)const branchCreateFlightsRef = useRef(new Map<string, Promise<SessionCreateResponse>>())// Follow auto-compression's stored-id rotation only while the exact runtime,@@ -448,6 +449,7 @@ export function useSessionActions({(options: boolean | FreshSessionDraftOptions = false) => {const draftOptions = typeof options === 'boolean' ? { replaceRoute: options } : optionsconst preserveRoute = draftOptions.preserveRoute ?? false+ createIntentRef.current = nullconst replaceRoute = draftOptions.replaceRoute ?? falseconst hasWorkspaceTarget =@@ -534,6 +536,7 @@ export function useSessionActions({async (preview: string | null = null): Promise<string | null> => {const startingStoredSessionId = selectedStoredSessionIdRef.currentconst startingRouteToken = getRouteToken()+ const createIntent = createIntentRef.current ??= crypto.randomUUID()creatingSessionRef.current = true@@ -562,6 +565,7 @@ export function useSessionActions({// different socket than the one that minted the runtime.const capturedRoute = resolveNewChatOwnerRoute()const params = await desktopSessionCreateParams(cwd, capturedRoute)+ params.request_id = createIntent// Lease the owner socket for the whole create → owner-publication// sequence (#93602 primitive). The per-request lease inside@@ -646,6 +650,8 @@ export function useSessionActions({}resetViewSync()++ if (createIntentRef.current === createIntent) { createIntentRef.current = null }activeSessionIdRef.current = created.session_idselectedStoredSessionIdRef.current = storedensureSessionState(created.session_id, stored)@@ -760,6 +766,7 @@ export function useSessionActions({const params = {...(await desktopSessionCreateParams(cwd, capturedRoute)),+ request_id: crypto.randomUUID(),...(workspaceScope.workspaceMode === 'bots' ? { hidden: true } : {})}