Repository navigation
feat(sidebar): copy workspace name from context menu - #22338
AmethystLiang merged 3 commits into
Conversation
Add Copy Name directly below Copy Path in the workspace context menu. It copies the name through resolveWorktreeDisplayName, the renderer mirror of main's mergeWorktree fallback (custom name, then branch, then folder), so the copied text is what `name:` worktree selectors resolve against and a cleared custom name no longer copies `undefined`. The context-menu model now spreads the command handlers instead of listing each one twice, which keeps it under the file-length limit. Fixes #21980 Linear: STA-8068
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe worktree context menu adds a localized “Copy Worktree Name” action. It copies the resolved display name and is disabled while the worktree is deleting. Tests cover display-name, branch-name, and folder-name clipboard values. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The Copy Name action and its tested name fallbacks have no identified issue that needs resolution before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The implementation copies Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. (6 skipped: 6 unsupported.)
✨ 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.
✅ No new issues found.
Reviewed changes — adds copy-workspace-name to the sidebar context menu.
- Copy Name menu item —
WorktreeContextMenuView.tsxrenders a newDropdownMenuItemdirectly below Copy Path, guarded by the same!isMultiContextblock anddisabled={isDeleting}, so it appears and disables in exactly the same cases. - Clipboard handler —
use-worktree-context-menu-commands.tsaddshandleCopyName, writingresolveWorktreeDisplayName(worktree)through the existingwindow.api.ui.writeClipboardText. No new IPC, state, or platform-specific code. - Command-model refactor —
use-worktree-context-menu-model.tsxreplaces the hand-unpacked handler destructure and re-listing withconst commands = …plus a...commandsspread. I confirmed the spread introduces no key collisions with the explicit keys that follow it and that every previously returned handler is still present. - Localization — a hand-named
copyNamekey is added and translated across all six locale catalogs. - Test — the new
WorktreeContextMenu.copy-name.test.tsxexercises the item order, the custom-name copy, and the branch / folder fallbacks with exact-value assertions.
I verified the copied value lines up with the name: selector: main's name: matches worktree.displayName exactly, and resolveWorktreeDisplayName resolves to that same merged value in normal hydration (custom name → branch short → folder basename), so the copy matches both the selector and the visible card title. The fallback branches are genuinely pinned — swapping the handler to read displayName directly would fail the branch / folder cases.
Locally: pnpm test src/renderer/src/components/sidebar/WorktreeContextMenu.copy-name.test.tsx (4 passed), pnpm tc:web (pass), and pnpm run check:code-quality:changed (0 findings) all pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
- Clarify that this copies the worktree display name, not the path - Update all locale strings and i18n keys - Rename test file to match
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — re-review of the two commits since the prior pullfrog review (5373d50): a label/key rename and a test refactor.
- Menu item + i18n key renamed — the item and its hand-named
auto.components.sidebar.WorktreeContextMenukey moved from "Copy Name"/copyNameto "Copy Worktree Name"/copyWorktreeName, updated consistently across all six locale catalogs and thetranslatecall site. No stalecopyNamereferences remain. - Test file renamed to match —
WorktreeContextMenu.copy-name.test.tsx→WorktreeContextMenu.copy-worktree-name.test.tsx. - Folder-workspace case rebuilt on the real factory — the folder test now builds its fixture with
folderWorkspaceToWorktreeinstead of a hand-cast object, and covers both a named folder (Refund fix) and a blank-name fallback to the folder basename (platform). - Blank-name fallback fixture simplified — the branch-fallback case now passes
displayName: ''rather than anundefinedcast; the runtime-undefinedguard stays covered byresolveWorktreeDisplayName's own unit test (worktree-default-display-name.test.ts).
No production logic changed — the handler still writes resolveWorktreeDisplayName(worktree) and the exact-value assertions still pin the fallback chain. Diminishing note: the "directly below Copy Path" order assertion was dropped in favor of the extra folder coverage, but placement is unchanged in WorktreeContextMenuView.tsx and a static adjacency is trivially visible.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Right-click a workspace in the sidebar and you can now copy its name, the same way you can already copy its path.
What Changed
Before: the workspace context menu had Copy Path but no way to copy the workspace's name. Users had to select or retype it, and long or similar names are easy to get wrong when you're telling another agent which workspace to use.
After: Copy Name appears directly below Copy Path and puts the workspace name on the clipboard. It's hidden in the same cases as Copy Path (for example, when several workspaces are selected) and disabled while a workspace is being deleted.
Mechanism: the new menu item calls
window.api.ui.writeClipboardText(resolveWorktreeDisplayName(worktree)).resolveWorktreeDisplayNameis the existing renderer copy of the main process's naming rule: use the custom name, or the branch name if that's blank, or the folder name if there's no branch. The label is translated in all six shipped languages.The context-menu model file hit the 400-line limit. It listed every command handler twice (once to unpack them, once to return them), so it now spreads the handler object into its return value. Nothing else changes.
Why
This uses the naming rule rather than the raw
displayNamefield, for two reasons:orca … --worktree name:<name>matches. The selector resolves against the same merged name, so the copy works as a routing address.displayNamecomes throughundefinedat runtime after someone clears a custom name, and folder workspaces have no branch. Reading the field directly would copy nothing (or crash) in those cases. The naming rule handles both.We decided against copying the card's visible title. In the new card style, that title can be a linked Linear, Jira, GitHub issue or PR title. That's a task subject, not the workspace's name, so no selector would match it.
This reuses the existing clipboard API. There is no new IPC, state or platform-specific code.
Based on the community PR #21981 by @seonghobae, who is the commit author here.
Linked Issue
Fixes #21980
Linear: STA-8068
Visual Proof
Screenshots from @seonghobae's #21981. The menu placement and label are the same in this PR.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New component test
WorktreeContextMenu.copy-name.test.tsxrenders the real Radix menu, opens it with a right-click and clicks Copy Name. It checks four things: the item sits directly below Copy Path; it copies the custom name; it falls back to the branch when the custom name was cleared (undefined); and it falls back to the folder name for a folder workspace with no branch.pnpm test src/renderer/src/components/sidebar/WorktreeContextMenu src/renderer/src/components/sidebar/WorktreeCard: 272 passedpnpm test src/renderer/src/i18n: 174 passedpnpm tc:webandpnpm run check:code-quality:changed: passReview
Additional independent review on
5373d50ba51: no correctness or maintainability blocker found. Reviewed the existing naming resolver, client-local clipboard boundary, single-selection/deletion guards, and the command-object refactor. The documented choice to copy the canonical workspace name rather than a linked task title is preserved.feature/auth, as intended.Current-head menu proof (the existing Before/After pair above still shows placement):
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Renderer-only clipboard write through the existing preload API. It works the same on macOS, Linux and Windows, and for SSH, local and folder workspaces, because nothing here touches the execution host.
Checklist
N/Awith reason