Skip to content

feat(sidebar): copy workspace name from context menu - #22338

Merged
AmethystLiang merged 3 commits into
mainfrom
jinjing/sta-8068-add-copy-name-to-the-workspace-context-menu
Sep 23, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
jinjing/sta-8068-add-copy-name-to-the-workspace-context-menu

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9

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)). resolveWorktreeDisplayName is 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 displayName field, for two reasons:

  • The copied text is exactly what orca … --worktree name:<name> matches. The selector resolves against the same merged name, so the copy works as a routing address.
  • displayName comes through undefined at 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.

Before After
Workspace context menu before Copy Name Workspace context menu after Copy Name

Testing

  • I manually tested these changes locally

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

  • New component test WorktreeContextMenu.copy-name.test.tsx renders 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 passed

  • pnpm test src/renderer/src/i18n: 174 passed

  • pnpm tc:web and pnpm run check:code-quality:changed: pass

Review

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.

  • Reran the Copy Name component and display-name resolver suites: 15 tests passed.
  • Built this PR head and exercised the real context menu in hidden Electron with isolated HOME and userData: custom name, a differing linked task title, and both dark/light themes passed. The linked task title copied feature/auth, as intended.
  • The main-process clipboard write was intercepted in this fixture, so the native clipboard was untouched. This validates the renderer-to-main payload, not a new native Windows/Linux or live SSH clipboard run.

Current-head menu proof (the existing Before/After pair above still shows placement):

Dark Light
Current Copy Name menu, dark Current Copy Name menu, light

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • 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)
  • Required PR Checks verification, static analysis, types, tests and packaging pass; focused local checks are listed above

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
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7914dff5-1cdd-404a-921d-c903626fe412

📥 Commits

Reviewing files that changed from the base of the PR and between 5373d50 and 34e2484.

📒 Files selected for processing (9)
  • src/renderer/src/components/sidebar/WorktreeContextMenu.copy-worktree-name.test.tsx
  • src/renderer/src/components/sidebar/WorktreeContextMenuView.tsx
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/components/sidebar/WorktreeContextMenuView.tsx
  • src/renderer/src/i18n/locales/zh.json

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


📝 Walkthrough

Walkthrough

The 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 34e24

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)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The implementation copies resolveWorktreeDisplayName(worktree) and places the action directly below Copy Path. It hides the action for multi-worktree contexts and disables it during deletion. Test… Change the menu fallback and all six translations to the requested Copy Name label, or use the existing localized Copy Name entries. Keep the current clipboard and display-name behavior.
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding workspace-name copying to the sidebar context menu.
Description check ✅ Passed The description is complete and focused. It includes the user impact, implementation details, rationale, linked issues, visual proof, automated testing, review notes, compatibility considerations, and…
Out of Scope Changes check ✅ Passed The changed view, command handler, tests, and translations implement issue #21980. The context-menu model refactor only consolidates and exposes the command handlers needed by the new action. No unrel…
Full details: Linked Issues check

Explanation

The implementation copies resolveWorktreeDisplayName(worktree) and places the action directly below Copy Path. It hides the action for multi-worktree contexts and disables it during deletion. Tests cover the display-name and fallback behavior. The current menu label is Copy Worktree Name, but issue #21980 requires Copy Name. The fallback text and the six locale entries use the longer label.

Full details: Docstring Coverage

Explanation

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.)

  • 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.

✅ No new issues found.

Reviewed changes — adds copy-workspace-name to the sidebar context menu.

  • Copy Name menu item — WorktreeContextMenuView.tsx renders a new DropdownMenuItem directly below Copy Path, guarded by the same !isMultiContext block and disabled={isDeleting}, so it appears and disables in exactly the same cases.
  • Clipboard handler — use-worktree-context-menu-commands.ts adds handleCopyName, writing resolveWorktreeDisplayName(worktree) through the existing window.api.ui.writeClipboardText. No new IPC, state, or platform-specific code.
  • Command-model refactor — use-worktree-context-menu-model.tsx replaces the hand-unpacked handler destructure and re-listing with const commands = … plus a ...commands spread. 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 copyName key is added and translated across all six locale catalogs.
  • Test — the new WorktreeContextMenu.copy-name.test.tsx exercises 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.

Pullfrog  | View workflow run | Using 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

@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.

✅ 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.WorktreeContextMenu key moved from "Copy Name"/copyName to "Copy Worktree Name"/copyWorktreeName, updated consistently across all six locale catalogs and the translate call site. No stale copyName references 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 folderWorkspaceToWorktree instead 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 an undefined cast; the runtime-undefined guard stays covered by resolveWorktreeDisplayName'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.

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

@AmethystLiang
AmethystLiang merged commit a77f87e into main Sep 23, 2026
30 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.

Add Copy Name to the workspace context menu

2 participants