feat(desktop): add Copy Path option to worktree sidebar context menu#880
feat(desktop): add Copy Path option to worktree sidebar context menu#880
Conversation
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).
📝 WalkthroughWalkthroughAdds a "Copy Path" option to WorkspaceListItem by implementing a Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
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
worktreePathis 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
| const handleCopyPath = async () => { | ||
| if (worktreePath) { | ||
| try { | ||
| await navigator.clipboard.writeText(worktreePath); | ||
| toast.success("Path copied to clipboard"); | ||
| } catch { | ||
| toast.error("Failed to copy path"); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
| 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
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Test plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.