Repository navigation
fix(desktop): open a branched session in the main workspace, not just a tile - #93461
chelsealong wants to merge 2 commits into
Conversation
… a tile forkBranch ended by opening the branch as a session-tile and leaving the primary selection on the parent (NousResearch#69750). In the default layout there is no visible tile pane, so branching only added a sidebar row with no feedback in the main area — and openSessionTile no-ops when the target is already the selected session, the common case of branching the chat you're viewing. Load the branch as the primary session via resumeSession instead, which reuses the runtime already warm-cached by forkBranch's ensureSessionState/updateSessionState calls, so it doesn't cost an extra resume RPC. Fixes NousResearch#93444
…ssion forkBranch was unconditionally routing every branched session into the main pane via resumeSession, including sidebar/background branches of a session the user isn't currently viewing. That reintroduces the NousResearch#69750 focus-stealing bug for that path: branching a different session from the sidebar yanked the active view away from whatever was open. Only take over the main pane when the branch's parent is the session already selected; otherwise keep opening it as its own tile.
There was a problem hiding this comment.
AI-generated comment: This comment was produced automatically by AI and may be misleading. Please independently verify the cited evidence.
Verdict
No correctness issue found in the reviewed scope; no author code change is requested.
Author action: The required CI check still needs a rerun or separate baseline fix before merge.
Independent delta: A complementary mutation exercised the selected-parent boundary, and an exact base/head comparison isolated the red required check from this patch.
Incremental evidence
Base/head: 608a56ed7f50926ecfae1db39447b280a0bc4d1e → 2f5be252409ee7c143703e5ea36f55f9436a48e9.
- The PR already mutates to unconditional
resumeSessionto protect the background-session path. I instead replaced the final guard with the pre-fix always-open-tile behavior; only the selected-parent regression failed (1 failed, 57 passed: expectedbranch-stored, receivedstored-parent). Restoring head returned to 58/58. Together, the two mutations exercise both sides of the guard. - Required CI fails in unchanged
apps/desktop/src/app/skills/index.test.tsx. Running that file on exact base and exact head produced the same 11/11 failures; the changed session-action file passed 58/58, so I do not attribute the red check to this patch.
Coverage limits
This independent run used Windows 11 / Node 22.18.0. I did not independently rerun the author's 665-test session-hooks suite or a packaged Electron UI. The required check remains red and still has to be rerun or resolved before merge.
|
Merged via #93663 with your commits cherry-picked (authorship preserved). Thanks @chelsealong! |
Summary
Fixes #93444. Creating a branch from the session you're currently viewing
(right-click → "Branch") only added a new row in the left sidebar — the main
workspace area stayed on the parent session, so branching looked like it did
nothing.
Root cause
In
apps/desktop/src/app/session/hooks/use-session-actions/index.ts,forkBranchended by opening the branch as a session-tile and deliberatelyleaving the primary selection on the parent (introduced in
6326b30c93/#69750, to fix a different bug: branching stealing focus from the parent
chat).
In the default layout there is no visible tile pane, so
openSessionTile(..., 'center')+revealTreePane(...)had almost no visible effect — the onlyobservable result was the new sidebar row. It's worse in the most common
case: branching the session you're currently viewing.
openSessionTileshort-circuits when the target is already
$selectedStoredSessionId, so thetile-open is a straight no-op there.
Fix
forkBranchis shared by every branch entry point (message GitFork button,/branchand/fork, sidebar right-click, tile Branch) — some of thosebranch the session currently open in the main pane, others branch an
unrelated session from the sidebar while looking at something else. Loading
the branch as primary unconditionally (an earlier version of this PR) would
have reintroduced #69750 for the latter case: branching a different
session from the sidebar would yank the active view away from whatever the
user was looking at.
So the fix only takes over the main pane when the session being branched is
the one already selected:
resumeSessionis the canonical "load session as primary" path — it sets$selectedStoredSessionId(which drives the route to the main workspace) andcloses any tile with the same id (a session is either the main thread or a
tile, never both). It also reuses the runtime already warm-cached by
forkBranch's precedingensureSessionState/updateSessionStatecalls(
runtimeIdByStoredSessionIdRef/sessionStateByRuntimeIdRef), so thisdoesn't cost an extra resume RPC beyond what the old tile-open path already
did implicitly. When the branched session isn't the one currently selected,
behavior is unchanged from before this PR: it opens as its own tile.
Test
Updated
use-session-actions.test.tsx'sbranchStoredSession desktop source taggingsuite:selectedStoredSessionIdto the branched parent (the "currently-openchat" case) and asserts the branch becomes primary and does not exist as a
tile.
session from the sidebar (does not reintroduce fix(desktop): open branched chat in a new tab and switch to it #69750)": the harness is
selected on
stored-other, and a different session,stored-parent, isbranched (the sidebar/background path). Asserts
$selectedStoredSessionIdstays on
stored-otherand the branch opens as a tile instead.Confirmed the new test fails without the source fix (i.e. against the
previous, unconditional-
resumeSessionversion of this PR):And passes with the fix restored:
Full session-hooks suite (43 files, 665 tests) also passes:
tsc -p apps/desktop --noEmitandeslinton both changed files are clean.AI assistance disclosure
This change was developed with AI assistance (Claude Code), including
locating the relevant code, implementing the fix, and updating/verifying the
test.