Repository navigation
fix(source-control): open another workspace from the branch picker like the sidebar - #41930
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…ke the sidebar Open workspace in the branch picker, Git Graph's open-workspace action and the folder workspace Source Control header called the raw setActiveWorktree. A workspace whose tabs were closed on purpose then had no surface and the window stayed blank. Use activateAndRevealWorktree with the user-open intent, the same activation the sidebar uses, while keeping the sidebar filters. Co-authored-by: Neil <[email protected]>
66822c8 to
af93330
Compare
ELI5
In Source Control, the branch picker lets you jump to the workspace that already has a branch checked out ("Open workspace"). If you had closed every tab in that workspace, the jump selected it but showed a blank window. Now it opens the workspace the same way clicking it in the sidebar does, so you get a terminal (or your default agent chat) back.
What Changed
Before: Open workspace in the branch picker, Git Graph's open-workspace action, and the folder-workspace Source Control header all called the raw store action
setActiveWorktree. That only changes the selection. A workspace whose tabs were closed on purpose has a closed-terminal tombstone, which correctly blocks the automatic first-visit shell, so nothing put a surface back and the window stayed blank until the user reopened it from the sidebar.After: all three call
activateAndRevealWorktree(id, { navigationIntent: 'user-open', executionHostId, clearSidebarFilters: false }), the same activation the sidebar uses. That path reseeds an emptied workspace with the user's default surface, resumes sleeping agent sessions, and records the visit.clearSidebarFilters: falsekeeps the user's sidebar search/filters, since these entry points are not in the sidebar. The branch picker handler is a module-level function instead of auseCallback, since it captures nothing.Why
Opening a workspace from the branch picker is a user action, so it should use the existing user-open path instead of a partial copy of it. Seeding a surface inside the picker would duplicate
activateAndRevealWorktree's handling of sleeping agents, pending creations, and host authority.Linked Issue
Fixes #41929
Visual Proof
Real Electron app, right after clicking Open workspace in the Source Control branch picker for a workspace whose tabs were all closed.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced in the app on macOS: create a second workspace, close all its tabs, switch away, then use Open workspace from the Source Control branch picker. Before: blank window. After: a terminal appears (screenshots above).
New
tests/e2e/branch-picker-open-workspace.spec.ts(electron-headless): first checks that the target workspace has zero renderable tabs and a recorded close, then opens it from the branch picker and checks it is active with one visible terminal. Without the fix it fails (renderableTabs: 0,visibleTerminals: 0). With the fix it passes on macOS.Targeted vitest for
source-control/branches,editor/git-graph, andlib/workspace/activation: 36/36 pass.oxlint (anti-slop, code-quality native plugins), ast-grep, oxfmt, and the changed-code quality gate are clean on the touched files.
Platforms: tested on macOS with a local host. The change only swaps which renderer activation function is called, and
executionHostIdis passed through unchanged, so SSH/remote workspaces resolve the same way. Nothing here is platform-specific.Risk
Level: Low
activateAndRevealWorktreedoes more thansetActiveWorktree: it switches to the terminal view, records the visit for Cmd+J recency, and may seed a default surface or resume sleeping agents. That is exactly what the sidebar already does for the same action. To back it out, revert the commit.Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Original fix by @mancunianez in #41930 (squashed with review follow-ups; authorship preserved).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)