Skip to content

Close workspace board when selecting a sidebar worktree - #21737

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/np-click-on-worktree-card-w-the-workspace-open-switch
Sep 19, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/np-click-on-worktree-card-w-the-workspace-open-switch

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 0 0 0 0
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

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

  • Automated tests added/updated, or explained why not below

Validation:

  • pnpm tc:web
  • pnpm test src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx src/renderer/src/components/sidebar/WorktreeList.card-memo-stability.test.tsx
  • pnpm run check:code-quality:changed
  • git diff --check

AI Disclosure

Codex (GPT-6)

Review

Agent skill upstream boundary

  • Not applicable

Notes

The callback is UI-local and does not change remote, SSH, mobile, platform, or wire behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (CI will cover broader checks)

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 03cc085f-f116-4872-aa1b-9f6a9eea76da

📥 Commits

Reviewing files that changed from the base of the PR and between 3e7da29 and cb3b284.

📒 Files selected for processing (9)
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/components/sidebar/use-worktree-card-activation-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-controller.ts
  • src/renderer/src/components/sidebar/worktree-card-model.ts
  • src/renderer/src/components/sidebar/worktree-list/rows/item-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/viewport/viewport-props.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The sidebar now accepts an optional worktree-card click callback. The callback flows through the virtualized worktree rows to WorktreeCard. Eligible card clicks invoke the callback before the existing activation actions. The workspace board supplies a callback that closes the board.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: closing the workspace board when a sidebar worktree is selected.
Description check ✅ Passed The description covers the user impact, implementation, rationale, visual-proof exception, validation, scope, and checklist items. It is mostly complete, but it does not provide the required linked is…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — Sidebar passes its stable closeWorkspaceBoard down through WorktreeList, the virtualized viewport, and the virtual row context to WorktreeCard, then into the activation handler.
  • Click-time invocation — use-worktree-card-activation-actions calls onWorktreeCardClick?.() after the selection and deletion guards, before onImmediateActivate and activation.
  • Drag safety — drags are already suppressed by the row onClickCapture handler 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 new onWorktreeCardClick?.() call were removed. Consider a focused test that clicking a worktree card closes the board, and one that a suppressed drag does not.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit b8f67a6 into main Sep 19, 2026
28 of 31 checks passed
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