Skip to content

feat(desktop): add Copy Path option to worktree sidebar context menu#880

Merged
Kitenite merged 2 commits intomainfrom
right-click-copy-path-in-wt
Jan 21, 2026
Merged

feat(desktop): add Copy Path option to worktree sidebar context menu#880
Kitenite merged 2 commits intomainfrom
right-click-copy-path-in-wt

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 21, 2026

Summary

  • Adds a new "Copy Path" context menu option to the worktree sidebar
  • Copies the workspace path to clipboard when clicked
  • Shows a toast notification on success/failure
  • Available in all context menus: expanded worktree, collapsed worktree, and branch workspace views

Test plan

  • Right-click on a worktree in the expanded sidebar and verify "Copy Path" option appears
  • Click "Copy Path" and verify the path is copied to clipboard with success toast
  • Right-click on a worktree in the collapsed sidebar and verify "Copy Path" option appears
  • Right-click on a branch workspace and verify "Copy Path" option appears

Summary by CodeRabbit

  • New Features
    • Added "Copy Path" to workspace context menus (collapsed hover, branch workspace, and main content), letting users copy workspace paths to the clipboard. Toast notifications report success or failure of each copy operation.

✏️ Tip: You can customize this high-level summary in your review settings.

Adds a new "Copy Path" context menu option that copies the workspace
path to clipboard. Available in all worktree and branch workspace
context menus (expanded and collapsed sidebar views).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Adds a "Copy Path" option to WorkspaceListItem by implementing a handleCopyPath function that writes worktreePath to the clipboard and shows success/failure toasts; the option is added to three context menus in the component. (48 words)

Changes

Cohort / File(s) Summary
Copy Path feature
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
Imported LuCopy, added handleCopyPath (clipboard write + success/failure toasts), and inserted "Copy Path" menu items into collapsed/workspace hover menu, branch workspace menu, and main content menu; added related icon imports (LuFolderOpen, LuPencil, LuX) for new menu entries.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A path to copy, quick and bright,
I nibble keys and flash a light,
Click "Copy Path", the clipboard sings,
Toasts applaud my little things,
Hoppy code and clipboard delight! ✨📋

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature addition: adding a Copy Path option to the worktree sidebar context menu.
Description check ✅ Passed The description covers the summary and test plan but is missing several required template sections (Related Issues, Type of Change, Testing, Screenshots, Additional Notes).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx`:
- Around line 191-199: The clipboard catch currently swallows the error; update
handleCopyPath to catch the exception as a variable (e.g., err) and call the app
logger with the required prefix (for example "[workspace/copy-path]") along with
err and context (worktreePath), and surface a more informative toast via
toast.error including a short error message or err.message when available;
ensure references to navigator.clipboard.writeText, worktreePath, toast.success
and toast.error remain intact.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx (1)

191-200: Avoid no‑op “Copy Path” when path is missing.

If worktreePath is empty, the menu item still renders but does nothing. Consider disabling the menu item or showing an explicit error toast so users aren’t left without feedback.

Also applies to: 320-324, 560-563, 597-600

Comment on lines +191 to +199
const handleCopyPath = async () => {
if (worktreePath) {
try {
await navigator.clipboard.writeText(worktreePath);
toast.success("Path copied to clipboard");
} catch {
toast.error("Failed to copy path");
}
}
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.

⚠️ Potential issue | 🟡 Minor

Add contextual error logging in clipboard failure path.

The catch block hides the actual error and doesn’t log with the required [domain/operation] prefix. Please log the error and include details in the toast where possible.

🛠️ Suggested fix
-		} catch {
-			toast.error("Failed to copy path");
+		} catch (error) {
+			console.error("[workspace/copy-path] failed to copy path", error);
+			const details =
+				error instanceof Error && error.message ? `: ${error.message}` : "";
+			toast.error(`Failed to copy path${details}`);
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleCopyPath = async () => {
if (worktreePath) {
try {
await navigator.clipboard.writeText(worktreePath);
toast.success("Path copied to clipboard");
} catch {
toast.error("Failed to copy path");
}
}
const handleCopyPath = async () => {
if (worktreePath) {
try {
await navigator.clipboard.writeText(worktreePath);
toast.success("Path copied to clipboard");
} catch (error) {
console.error("[workspace/copy-path] failed to copy path", error);
const details =
error instanceof Error && error.message ? `: ${error.message}` : "";
toast.error(`Failed to copy path${details}`);
}
}
};
🤖 Prompt for AI Agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx`
around lines 191 - 199, The clipboard catch currently swallows the error; update
handleCopyPath to catch the exception as a variable (e.g., err) and call the app
logger with the required prefix (for example "[workspace/copy-path]") along with
err and context (worktreePath), and surface a more informative toast via
toast.error including a short error message or err.message when available;
ensure references to navigator.clipboard.writeText, worktreePath, toast.success
and toast.error remain intact.

Adds consistent icons to context menu items:
- Rename: pencil icon
- Open in Finder: folder-open icon
- Close Worktree: X icon
@Kitenite Kitenite merged commit cd7b867 into main Jan 21, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite deleted the right-click-copy-path-in-wt branch January 21, 2026 22:12
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