fix(desktop): use native clipboard for copy path in v2 sidebar#3462
Conversation
navigator.clipboard.writeText silently fails when focus is elsewhere (e.g., terminal), so the toast showed but nothing was actually copied. Switch to useCopyToClipboard which routes through Electron's native clipboard via tRPC, matching the v1 pathway.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughContext menu path actions were extracted into a new PathActionsMenuItems component; workspace sidebar context menus now receive and use an explicit isLocalWorkspace flag, and the workspace actions hook was extended to resolve worktree paths and perform Open in Finder / Copy Path via host service, electron RPC, and clipboard utilities. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as UI (Context Menu)
participant Path as PathActionsMenuItems
participant Hook as Actions Hook
participant Local as LocalHostService
participant Host as HostServiceClient
participant Electron as electronTrpcClient
participant Clipboard as CopyToClipboard
participant Toast as Toast
UI->>Path: user selects action
Path->>Hook: request resolved path (if needed)
Hook->>Local: get activeHostUrl
Local-->>Hook: activeHostUrl
Hook->>Host: query workspace (worktreePath)
Host-->>Hook: worktreePath
alt reveal in finder
Path->>Electron: openInFinder.mutate(absolutePath)
Electron-->>Path: result / error
Path->>Toast: show error (if any)
else copy path
Path->>Clipboard: copyToClipboard(path)
Clipboard-->>Path: success / error
Path->>Toast: show success / error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR fixes a silent clipboard failure in the v2 workspace sidebar's file/folder context menus. Previously, "Copy Path" and "Copy Relative Path" used
Confidence Score: 5/5Safe to merge — targeted, well-understood fix that aligns v2 with the established v1 pattern. The change is minimal (two symmetrical files), uses a proven hook that is already widely adopted across the desktop renderer, and directly addresses a clear, reproducible bug. The only open item is the lack of error handling on IPC failure, which is a P2 style suggestion consistent with the rest of the codebase — not a blocker. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ContextMenu as FileContextMenu / FolderContextMenu
participant Hook as useCopyToClipboard
participant tRPC as electronTrpc (IPC)
participant Main as Electron Main Process
participant Clipboard as Native Clipboard
User->>ContextMenu: Right-click → Copy Path
Note over ContextMenu: Before fix: navigator.clipboard.writeText()<br/>(fails silently when focus is on terminal)
ContextMenu->>Hook: await copyToClipboard(path)
Hook->>tRPC: mutateAsync(path) → external.copyPath
tRPC->>Main: IPC call (focus-independent)
Main->>Clipboard: clipboard.writeText(path)
Clipboard-->>Main: success
Main-->>tRPC: result
tRPC-->>Hook: resolved
Hook-->>ContextMenu: resolved
ContextMenu->>User: toast.success("Path copied")
Reviews (1): Last reviewed commit: "fix(desktop): use native clipboard for c..." | Re-trigger Greptile |
| <ContextMenuItem | ||
| onSelect={() => { | ||
| navigator.clipboard.writeText(absolutePath); | ||
| onSelect={async () => { | ||
| await copyToClipboard(absolutePath); | ||
| toast.success("Path copied"); | ||
| }} |
There was a problem hiding this comment.
No error feedback if clipboard write fails
If copyToClipboard rejects (e.g., due to an IPC failure), the toast.success call is skipped and the user sees no feedback at all — no success, no error. The old navigator.clipboard path had the same gap (the toast fired regardless of success), but now that the copy is async and awaited, a failure will be completely silent.
This is consistent with other usages of useCopyToClipboard across the codebase, but worth addressing here and in FolderContextMenu since these are user-initiated, one-shot actions where silent failure is confusing. Consider wrapping in try/catch:
| <ContextMenuItem | |
| onSelect={() => { | |
| navigator.clipboard.writeText(absolutePath); | |
| onSelect={async () => { | |
| await copyToClipboard(absolutePath); | |
| toast.success("Path copied"); | |
| }} | |
| onSelect={async () => { | |
| try { | |
| await copyToClipboard(absolutePath); | |
| toast.success("Path copied"); | |
| } catch { | |
| toast.error("Failed to copy path"); | |
| } | |
| }} |
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/FileContextMenu/FileContextMenu.tsx">
<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/FileContextMenu/FileContextMenu.tsx:38">
P2: Unhandled promise rejection: if `copyToClipboard` throws (e.g., IPC failure), the `await` will reject with no `try/catch`, giving the user zero feedback and risking an unhandled rejection in Electron. Wrap in `try/catch` and show an error toast on failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The workspace item context menu's Copy Path just toasted "coming soon". Fetch the worktreePath from the local host service for local workspaces, copy via electronTrpc.external.copyPath (native clipboard), and show a proper success toast. Non-local workspaces fall back to an explanatory error since the path only exists on the owning machine.
Share the local worktreePath resolver between Copy Path and Open in Finder, and route Open in Finder through electronTrpc.external.openInFinder instead of toasting "coming soon".
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts">
<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts:32">
P2: Path lookup is bound to the active host instead of the workspace’s own host, which can break Copy Path/Open in Finder for workspaces on a different local host.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…try/catch Addresses review feedback on PR #3462: - Pulled the Reveal in Finder / Copy Path / Copy Relative Path items shared between FileContextMenu and FolderContextMenu into a single PathActionsMenuItems component. - Wrap useCopyToClipboard calls in try/catch so IPC failures surface a proper error toast instead of failing silently.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/PathActionsMenuItems.tsx:
- Around line 33-36: The ContextMenuItem click handler calls
electronTrpcClient.external.openInFinder.mutate(absolutePath) without error
handling; change the onSelect into an async handler that awaits
electronTrpcClient.external.openInFinder.mutate(absolutePath), wrap it in
try/catch, and on failure show the same user-facing feedback used by the copy
actions (e.g., the existing toast/notification utility) and log the error for
diagnostics; update the handler on the ContextMenuItem and reference the
ContextMenuItem component, the electronTrpcClient.external.openInFinder.mutate
call, and the absolutePath variable when making these changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 066ab3b6-bebf-4301-a58e-dc7a6cd7de87
📒 Files selected for processing (4)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/FileContextMenu/FileContextMenu.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/FolderContextMenu/FolderContextMenu.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/PathActionsMenuItems.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/index.ts
✅ Files skipped from review due to trivial changes (1)
- apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/FolderContextMenu/FolderContextMenu.tsx
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/PathActionsMenuItems.tsx">
<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/FilesTab/components/WorkspaceFilesTreeItem/components/PathActionsMenuItems/PathActionsMenuItems.tsx:35">
P2: Wrap the `openInFinder.mutate()` call in a `try/catch` with `toast.error` feedback, matching how `handleCopy` handles failures. The returned promise is not awaited or caught, so a rejection (e.g., invalid path, permission denied) becomes an unhandled promise rejection — which can crash the Electron renderer process.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…spaces - Gate the Open in Finder / Copy Path items in the dashboard sidebar workspace context menu behind isLocalWorkspace so they only appear for workspaces on the active machine. - Drop the now-redundant hostType guard from the actions hook. - Wrap openInFinder in try/catch in PathActionsMenuItems so native action failures surface a toast (addresses coderabbit/cubic P2 on #3462).
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
…set-sh#3462) * fix(desktop): use native clipboard for copy path in v2 sidebar navigator.clipboard.writeText silently fails when focus is elsewhere (e.g., terminal), so the toast showed but nothing was actually copied. Switch to useCopyToClipboard which routes through Electron's native clipboard via tRPC, matching the v1 pathway. * feat(desktop): wire up Copy Path in v2 dashboard sidebar The workspace item context menu's Copy Path just toasted "coming soon". Fetch the worktreePath from the local host service for local workspaces, copy via electronTrpc.external.copyPath (native clipboard), and show a proper success toast. Non-local workspaces fall back to an explanatory error since the path only exists on the owning machine. * feat(desktop): wire up Open in Finder in v2 dashboard sidebar Share the local worktreePath resolver between Copy Path and Open in Finder, and route Open in Finder through electronTrpc.external.openInFinder instead of toasting "coming soon". * refactor(desktop): extract shared PathActionsMenuItems, wrap copy in try/catch Addresses review feedback on PR superset-sh#3462: - Pulled the Reveal in Finder / Copy Path / Copy Relative Path items shared between FileContextMenu and FolderContextMenu into a single PathActionsMenuItems component. - Wrap useCopyToClipboard calls in try/catch so IPC failures surface a proper error toast instead of failing silently. * refactor(desktop): hide Open in Finder & Copy Path for non-local workspaces - Gate the Open in Finder / Copy Path items in the dashboard sidebar workspace context menu behind isLocalWorkspace so they only appear for workspaces on the active machine. - Drop the now-redundant hostType guard from the actions hook. - Wrap openInFinder in try/catch in PathActionsMenuItems so native action failures surface a toast (addresses coderabbit/cubic P2 on superset-sh#3462).
…ndle chore(upstream): PR1 低リスク修正5件バンドル (superset-sh#3457 superset-sh#3464 superset-sh#3462 superset-sh#3466 superset-sh#3461)
-s ours merge to record that upstream commits a3e34bf through de70163 (13 commits) are semantically already present on origin/main via the PR1-6 cherry-pick series (PRs #176, #177, #178, #179, #180, #182), plus fork-adaptation fixes layered on top. This merge target is de70163 specifically (not upstream/main) so newer upstream commits (9fff075 and later) remain visible in future behind counts. Upstream commits covered by this audit merge: - a3e34bf fix(desktop): restore cmd+click requirement for v1 terminal file links (superset-sh#3457) [PR1/#176] - 57557f8 fix(desktop): gate v2 workspace children on collection readiness (superset-sh#3464) [PR1/#176] - 4ee2e61 fix(desktop): use native clipboard for copy path in v2 sidebar (superset-sh#3462) [PR1/#176] - 87d6e93 feat(desktop): close settings with Escape key (superset-sh#3466) [PR1/#176] - 9c7f5f4 chore(desktop): auto-restart host-service on bundle change in dev (superset-sh#3461) [PR1/#176] - 93140d9 fix(mcp): accept MCP resource URL as valid OAuth audience (superset-sh#3459) [PR2/#177] - be9e000 fix(desktop): drive tray menu off events, fetch real org name (superset-sh#3458) [PR2/#177] - c5f791e feat(v2): unify workspace delete through host-service (superset-sh#3443) [PR3/#178] - 2c24d93 feat(desktop): paginated branch picker with checkout + open actions (superset-sh#3397) [PR4/#179] - 2bf1049 feat(desktop/hotkeys): v1 directional pane focus + best-effort v1 override migrator (superset-sh#3460) [PR5/#180] - 1294a7d feat(desktop/hotkeys): restore Cmd+Alt+Arrow for tab/workspace nav (superset-sh#3472) [PR5/#180] - de70163 feat(desktop): v2 review tab first pass — PR info, checks, comments (superset-sh#3463) [PR6/#182] Intentionally skipped (version bump, fork has independent versioning): - 1e23353 chore(desktop): bump version to 1.5.5 (superset-sh#3473) Fork-adaptation fixes layered on top of the cherry-picks: - PR1: host-service-coordinator alias import fix, settings Escape selector narrowing (role-based + popper wrapper), Escape close uses replace navigation - PR2: dual quit mode preservation (requestQuit "release"/"stop"), trayUpdateToken guard for stale async fetchHostInfo results - PR4: ChangesHeader.normalizeBranchName regex rewrite (lint false positive), worktree add uses fullRef for remote-tracking refs, syncTimedOut reset on pendingId change, GIT_REFS.md barrel example fix - PR5: migrate.ts re-sanitize of existing localStorage overrides (v2 marker bump intent), FOCUS_PANE_* enabled:isActive for KeepAliveWorkspaces, CATEGORY_ORDER merges Navigation (upstream) and Browser (fork) - PR6: normalizeThreadsToComments flattens all thread.comments (not just first), CommentPane overrides <a> (openUrl) and <img> (SafeImage), zero-badge suppression, pr-null comments gate Fork features verified intact (Explore agent audit of combined 36d4de4..35d95f3 range): - BROWSER_RELOAD / BROWSER_HARD_RELOAD hotkeys - dual quit mode menu in tray - v1 terminal cold-restore + retry reconnect (out of range but unaffected) - KeepAliveWorkspaces (FOCUS_PANE_* gated on isActive) - useCommandPalette + addMemoTab in v2 workspace - host-service-coordinator rename alias pattern
Summary
navigator.clipboard.writeText, which silently fails when focus is on another element (e.g., the terminal) — the toast showed but nothing was actually copied.useCopyToClipboardhook, which routes through Electron's native clipboard via tRPC. Matches the v1 pathway.Test plan
Summary by cubic
Uses the native clipboard via
useCopyToClipboardto make copy actions reliable in the v2 sidebar. Adds working “Copy Path” and “Open in Finder” to the dashboard for local workspaces, and hides these options for non-local workspaces.New Features
worktreePathvia the local host service and call native actions.Bug Fixes
useCopyToClipboard(Electron viatRPC), await completion, and toast errors; extract sharedPathActionsMenuItems; wrap “Reveal/Open in Finder” in try/catch.Written for commit 5380421. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes