Repository navigation
Close workspace board when selecting a sidebar worktree - #21737
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe sidebar now accepts an optional worktree-card click callback. The callback flows through the virtualized worktree rows to Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Important
Folder-workspace cards in the same sidebar list still leave the workspace board open, so the fix is incomplete for a case the board itself organizes.
Reviewed changes
Reviewed the single commit cb3b284 that threads an onWorktreeCardClick callback from the sidebar into the worktree-card activation handler.
- Callback plumbing —
Sidebarpasses its stablecloseWorkspaceBoarddown throughWorktreeList, the virtualized viewport, and the virtual row context toWorktreeCard, then into the activation handler. - Click-time invocation —
use-worktree-card-activation-actionscallsonWorktreeCardClick?.()after the selection and deletion guards, beforeonImmediateActivateand activation. - Drag safety — drags are already suppressed by the row
onClickCapturehandler and the document capture click listener, so the new call does not run for drags.
⚠️ Folder-workspace cards do not close the board
Clicking a folder-workspace card in the sidebar activates it through the same path (activateWorktreeFromSidebar handles folder scope), but renderFolderWorkspaceVirtualRow never receives onWorktreeCardClick, so the board stays open — the exact behavior this PR fixes for git worktrees. The board's own ordering catalog includes folder workspaces, so these rows are in scope for the same interaction.
Technical details
# Folder workspaces do not close the workspace board
## Affected sites
- `src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts:130` — `onWorktreeCardClick` is wired into the `item` context only.
- `src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts:138` — the `folderWorkspace` context built in the same function omits the callback.
- `src/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsx:112` — `renderFolderWorkspaceVirtualRow` renders `WorktreeCard` without `onWorktreeCardClick`.
## Required outcome
- Clicking a folder-workspace card while the workspace board is open closes the board, matching the git-worktree behavior, while the selection and drag guards continue to apply.
## Suggested approach (optional)
- Add `onWorktreeCardClick` to `FolderWorkspaceRowContext`, populate it from `props.onWorktreeCardClick` in the `folderWorkspace` block, and pass it to the `WorktreeCard` in `folder-row.tsx`.ℹ️ Keyboard worktree switching also leaves the board open
useWorktreeListKeyboardNavigation switches the active worktree on worktree.navigateUp/navigateDown (and the container ArrowUp/ArrowDown handlers) via activateAndRevealWorktree, bypassing the new click callback. The board sheet is modal={false}, so the sidebar list stays keyboard-reachable while it is open. This is likely out of scope for a click-focused fix, but worth confirming whether arrow-key switching should behave the same as a click.
Technical details
# Keyboard activation bypasses the board close
## Affected sites
- `src/renderer/src/components/sidebar/worktree-list/navigation/use-keyboard.ts:90` — `navigateWorktree` calls `activateAndRevealWorktree` directly.
- `src/renderer/src/components/sidebar/WorkspaceKanbanSheet.tsx:66` — the board sheet is `modal={false}`.
## Open questions for the human
- Is closing on keyboard navigation intended, or should the board only close on pointer activation?ℹ️ Nitpicks
- No test file changed in this commit. The PR body marks automated tests as added/updated, but the two suites listed (
WorktreeCard.hosted-review-refresh.test.tsx,WorktreeList.card-memo-stability.test.tsx) only cover hosted-review refresh and memo stability — nothing would fail if the newonWorktreeCardClick?.()call were removed. Consider a focused test that clicking a worktree card closes the board, and one that a suppressed drag does not.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Clicking a worktree in the left sidebar now switches to it and closes an open workspace board. Starting a drag still leaves the board behavior unchanged.
What Changed
The sidebar passes the workspace board close action into the worktree-card activation path. The action runs only after the card click passes selection and deletion guards, so the existing drag click suppression prevents it from running for drags.
Why
The workspace board is a companion view for organizing worktrees. Once someone clicks a worktree to switch, keeping the board open obscures the destination. Connecting the close action to the existing activation path keeps click and drag behavior separate without adding another pointer gesture detector.
Linked Issue
No issue number was provided.
Visual Proof
N/A — this changes interaction behavior only; there is no visual appearance change.
Testing
Validation:
pnpm tc:webpnpm test src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx src/renderer/src/components/sidebar/WorktreeList.card-memo-stability.test.tsxpnpm run check:code-quality:changedgit diff --checkAI Disclosure
Codex (GPT-6)
Review
Agent skill upstream boundary
Notes
The callback is UI-local and does not change remote, SSH, mobile, platform, or wire behavior.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (CI will cover broader checks)