Skip to content

fix(app): select the session's project when switching sides - #303

Merged
quickbeard merged 2 commits into
mainfrom
fix/side-switch-project
Aug 22, 2026
Merged

quickbeard merged 2 commits into
mainfrom
fix/side-switch-project

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Follow-up to #300. That PR made an unselected project list nothing — correct, and what you observed — but switching Code/Work is a path that leaves the project unselected while restoring a session, so the two combined into a sidebar with an open session and an empty Recents.

Problem

useWorkspaceSwitch's enter() sets a selection carrying a server only, then returns the moment it resumes the side's last session:

if (layout.home.selection().server !== server) layout.home.setSelection({ server })   // no directory
...
if (last && lastServer && (await folder.sessionAlive(...))) {
  navigate(sessionHref(last.server, last.sessionId))
  return                                                    // never picks a folder
}

So the session and its tabs came back while the sidebar sat on no project: Projects unhighlighted, Pinned and Recents empty. The fallback path below it does not have this problem — it ends in enterFolder, which selects a folder.

Fix

When resuming, also select the project that session lives in — the folder of the server's project list that owns the session's directory, since a session can sit in a subdirectory of one. That folder is also recorded as the server's last project, so a later launch seeds the same one #300 would pick.

The rule is extracted as a pure sessionProjectSelection in workspace/side.ts, beside folderEntry and for the reason that file already documents: the Work side has no sandbox platform in the web e2e harness, so this decision cannot be driven from a browser.

Verification

Three unit tests: the plain case, a session nested inside its project, and selecting nothing rather than guessing when the directory has not loaded or belongs to no listed project.

test:browser 130 pass, test:unit 690 pass, #300's two e2e specs still pass, typecheck clean.

Not verified in the running app. Code↔Work needs a real sandbox platform, which neither the browser harness nor my environment can drive — the same limitation side.ts already calls out. Worth one switch each way before merging.

DIVERGENCES: the Code/Work split row extended with this behaviour. CHANGELOG entry under Desktop / Web UI.

🤖 Generated with Claude Code

quickbeard and others added 2 commits August 22, 2026 17:49
enter() set a selection carrying a server only, then returned as soon as
it resumed the side's last session — so switching Code/Work restored the
session and its tabs while the sidebar sat on no project, with Projects
unhighlighted and Recents empty. Select the project that owns the
resumed session's directory, and record it as that server's last.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@quickbeard
quickbeard merged commit e4bac3a into main Aug 22, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the fix/side-switch-project branch August 22, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant