From 30252eccce6284d5b6be342e3753aa769cb9911f Mon Sep 17 00:00:00 2001 From: mashenchina-max <268528998+mashenchina-max@users.noreply.github.com> Date: Thu, 27 Aug 2026 09:44:21 +0800 Subject: [PATCH] fix(desktop): navigate to branched session --- .../src/app/session/hooks/use-session-actions.test.tsx | 6 +++++- .../src/app/session/hooks/use-session-actions/index.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) 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.tsx index 4071ac1f31..aaa6c312e3 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 @@ -1714,8 +1714,11 @@ describe('branchStoredSession desktop source tagging', () => { await expect(branchStoredSession!('stored-parent')).resolves.toBe(true) // The branch becomes the primary session — this is what routes the main - // workspace area to it, not just a new sidebar row. + // workspace area to it, not just a new sidebar row. Selection alone is not + // enough: leaving the URL on the parent makes chat/index see a permanent + // routeSessionMismatch and keeps the central loader mounted. expect($selectedStoredSessionId.get()).toBe('branch-stored') + expect(navigate).toHaveBeenCalledWith(sessionRoute('branch-stored'), { replace: true }) // It must not ALSO exist as a tile: a session is either the main thread or // a tile, never both (resumeSession closes any tile with the same id). expect($sessionTiles.get().some(tile => tile.storedSessionId === 'branch-stored')).toBe(false) @@ -1767,6 +1770,7 @@ describe('branchStoredSession desktop source tagging', () => { // Branching a session that is not the one currently open must not steal // the user's active view — "stored-other" stays selected. expect($selectedStoredSessionId.get()).toBe('stored-other') + expect(navigate).not.toHaveBeenCalled() // The branch instead opens as its own tile. expect($sessionTiles.get().some(tile => tile.storedSessionId === 'branch-stored')).toBe(true) }) 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.ts index 5ea1994202..e73ddf147f 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 @@ -2079,6 +2079,7 @@ export function useSessionActions({ // unconditionally). resumeSession reuses the runtime warm-cached above // (ensureSessionState/updateSessionState) instead of an extra resume RPC. if (parentStoredId !== null && selectedStoredSessionIdRef.current === parentStoredId) { + navigate(sessionRoute(routedSessionId), { replace: true }) await resumeSession(routedSessionId) } else { // Carry the exact owner onto the tile: its persisted ownerRoute is @@ -2113,6 +2114,7 @@ export function useSessionActions({ copy, creatingSessionRef, ensureSessionState, + navigate, requestGateway, resumeSession, selectedStoredSessionIdRef,