Skip to content

The agent that grows with you

fix(desktop): navigate to branched session

mashenchina-max30252eccce62
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 4071ac1f311..aaa6c312e34 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 5ea19942020..e73ddf147f4 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,