feat(desktop): add Copy Branch Name to v1 and v2 sidebar context menus#3635
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe changes introduce a "Copy Branch Name" feature across the dashboard and main workspace sidebars. Users can now copy branch names to their clipboard via context menu items in multiple sidebar components, backed by centralized async handlers with clipboard operations and toast notifications for success/failure feedback. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 adds a Copy Branch Name context menu option to workspace items across both the v1 and v2 dashboard sidebars (expanded and collapsed states), copying the workspace's git branch to the clipboard and surfacing a success toast.
Confidence Score: 4/5Safe to merge after aligning error handling in the v1 sidebar implementation with the v2 pattern. The feature works correctly on the happy path across all six files. The v2 implementation is solid. The only concrete gap is in WorkspaceListItem.tsx where clipboard errors are silently swallowed and the falsy-branch case gives the user no feedback — a targeted one-line fix resolves it. apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx — error handling in handleCopyBranchName needs a try/catch and a toast.error for the empty-branch case.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx | Adds handleCopyBranchName to v1 sidebar, but silently swallows errors and omits the toast when branch is falsy — unlike the v2 implementation which correctly shows toast.error in both cases. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts | Adds handleCopyBranchName to the v2 sidebar hook with proper null guard, try/catch, and error toasts — well-implemented. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarWorkspaceContextMenu/DashboardSidebarWorkspaceContextMenu.tsx | Adds Copy Branch Name menu item for both local and remote workspaces with appropriate separator logic; icons and wiring are correct. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/DashboardSidebarWorkspaceItem.tsx | Wires branch prop and handleCopyBranchName into the context menu for both expanded and collapsed states correctly. |
| apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx | Adds onCopyBranchName prop and menu item to the v1 expanded workspace context menu; straightforward and correct. |
| apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/CollapsedWorkspaceItem.tsx | Adds onCopyBranchName prop and menu item to the v1 collapsed workspace context menu; correct and consistent with expanded view. |
Sequence Diagram
sequenceDiagram
actor User
participant Menu as Context Menu
participant Handler as handleCopyBranchName
participant Clipboard as useCopyToClipboard
participant Toast as toast
User->>Menu: Right-click workspace item
User->>Menu: Select "Copy Branch Name"
Menu->>Handler: onCopyBranchName()
alt branch is empty (v2 sidebar)
Handler->>Toast: toast.error("Branch name is not available")
else branch is empty (v1 sidebar)
Handler-->>Menu: silent return (no feedback)
end
alt branch available
Handler->>Clipboard: copyToClipboard(branch)
alt success
Clipboard-->>Handler: resolved
Handler->>Toast: toast.success("Branch name copied")
else failure (v2 only)
Clipboard-->>Handler: throws
Handler->>Toast: toast.error("Failed to copy branch name: ...")
end
end
Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
Line: 246-250
Comment:
**Silent failure and missing error handling**
The v1 sidebar's `handleCopyBranchName` silently returns without any user feedback when `branch` is falsy, and has no `try/catch` around `copyToClipboard`. If the clipboard write fails the error is swallowed and the success toast is never shown.
The v2 sidebar implementation in `useDashboardSidebarWorkspaceItemActions.ts` handles both cases correctly — it shows a `toast.error` for the missing-branch case and wraps the copy in a try/catch with an error toast. The two implementations should be consistent.
```suggestion
const handleCopyBranchName = async () => {
if (!branch) {
toast.error("Branch name is not available");
return;
}
try {
await copyToClipboard(branch);
toast.success("Branch name copied");
} catch (error) {
toast.error(
`Failed to copy branch name: ${error instanceof Error ? error.message : "Unknown error"}`,
);
}
};
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
Line: 249
Comment:
**Toast message inconsistency between v1 and v2 sidebars**
The success toast here reads `"Branch name copied to clipboard"`, while the equivalent in `useDashboardSidebarWorkspaceItemActions.ts` (v2 sidebar) reads `"Branch name copied"`. The same inconsistency exists for path copying (`"Path copied to clipboard"` vs `"Path copied"`). Keeping messages consistent across both sidebars avoids a jarring UX difference depending on which sidebar the user is in.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "chore(desktop): drop success toast from ..." | Re-trigger Greptile
| const handleCopyBranchName = async () => { | ||
| if (!branch) return; | ||
| await copyToClipboard(branch); | ||
| }; | ||
|
|
There was a problem hiding this comment.
Silent failure and missing error handling
The v1 sidebar's handleCopyBranchName silently returns without any user feedback when branch is falsy, and has no try/catch around copyToClipboard. If the clipboard write fails the error is swallowed and the success toast is never shown.
The v2 sidebar implementation in useDashboardSidebarWorkspaceItemActions.ts handles both cases correctly — it shows a toast.error for the missing-branch case and wraps the copy in a try/catch with an error toast. The two implementations should be consistent.
| const handleCopyBranchName = async () => { | |
| if (!branch) return; | |
| await copyToClipboard(branch); | |
| }; | |
| const handleCopyBranchName = async () => { | |
| if (!branch) { | |
| toast.error("Branch name is not available"); | |
| return; | |
| } | |
| try { | |
| await copyToClipboard(branch); | |
| toast.success("Branch name copied"); | |
| } catch (error) { | |
| toast.error( | |
| `Failed to copy branch name: ${error instanceof Error ? error.message : "Unknown error"}`, | |
| ); | |
| } | |
| }; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
Line: 246-250
Comment:
**Silent failure and missing error handling**
The v1 sidebar's `handleCopyBranchName` silently returns without any user feedback when `branch` is falsy, and has no `try/catch` around `copyToClipboard`. If the clipboard write fails the error is swallowed and the success toast is never shown.
The v2 sidebar implementation in `useDashboardSidebarWorkspaceItemActions.ts` handles both cases correctly — it shows a `toast.error` for the missing-branch case and wraps the copy in a try/catch with an error toast. The two implementations should be consistent.
```suggestion
const handleCopyBranchName = async () => {
if (!branch) {
toast.error("Branch name is not available");
return;
}
try {
await copyToClipboard(branch);
toast.success("Branch name copied");
} catch (error) {
toast.error(
`Failed to copy branch name: ${error instanceof Error ? error.message : "Unknown error"}`,
);
}
};
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
1 issue found across 6 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/screens/main/components/WorkspaceSidebar/WorkspaceListItem/CollapsedWorkspaceItem.tsx">
<violation number="1" location="apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/CollapsedWorkspaceItem.tsx:137">
P2: Collapsed branch workspaces still bypass the context menu, so Copy Branch Name never appears for the local-workspace case.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The collapsed branch-workspace branch returned early with only a Tooltip, so right-click surfaced no menu. Wrap the button in a ContextMenu so Copy Branch Name is reachable.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Copy Branch Name (superset-sh#3635) のupstream版がDeletingWorkspacesProviderに 依存していたが、PR1にファイルが含まれていなかった。
Add v2 project setup section (#3566, #3605, #3606, #3592, #3626, #3632), scheduled agent runs (#3576), Opus 4.7 (#3579), v1 review comments in pane (#3596), configurable v2 link-click (#3600), Copy Branch Name (#3635), safer terminal preset defaults (#3546), and /pricing page (#3639). Expand bug fixes with v2 git correctness, cross-fork PR misattribution, terminal paste/Unicode/Shift+Enter, and security bumps.
…-27) (#3792) * docs: generate weekly changelog 2026-04-27 * docs: reframe weekly changelog around v2 public beta Lead with v2 public beta + Settings → Experimental enable, restructure around the v1→v2 migration story, sidebar overhaul, cross-workspace terminals, and v2 chat. Pull in ~30 v2 PRs the bot missed and demote non-v2 items (Hosts page, marketing menu) to a brief "Also this week". * docs: pull in missed v2 features and bug fixes Add v2 project setup section (#3566, #3605, #3606, #3592, #3626, #3632), scheduled agent runs (#3576), Opus 4.7 (#3579), v1 review comments in pane (#3596), configurable v2 link-click (#3600), Copy Branch Name (#3635), safer terminal preset defaults (#3546), and /pricing page (#3639). Expand bug fixes with v2 git correctness, cross-fork PR misattribution, terminal paste/Unicode/Shift+Enter, and security bumps. * docs(changelog): add v2 public beta hero screenshot * docs(changelog): add Settings → Experimental screenshot, compress hero pngquant compression: v2-public-beta.png 704KB → 166KB (76%), v2-enable-flag.png 160KB → 36KB (78%). No visible quality loss. * docs(changelog): tighten v2 launch prose, condense bullet groups * docs(changelog): reframe cloud-first pillar as remote workspaces * docs(changelog): cut parallel-agents and honest-state pillars, fold into sub-sections * docs(changelog): tweak title and lead phrasing * docs(changelog): rewrite v2 launch lede around Twitter narrative Pull the launch story (physical limits, 3 ex-CTOs, cloud workspaces) into the lede, restructure pillars around Remote workspaces, Reimagined diff view, and Superset CLI, and add v2-remote-workspaces and v2-changes-pane screenshots to back the new sections. * docs(changelog): add CLI install snippet and docs link * docs(changelog): cut narrative lede, match standard changelog tone --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kiet Ho <hoakiet98@gmail.com>
…-27) (#3792) * docs: generate weekly changelog 2026-04-27 * docs: reframe weekly changelog around v2 public beta Lead with v2 public beta + Settings → Experimental enable, restructure around the v1→v2 migration story, sidebar overhaul, cross-workspace terminals, and v2 chat. Pull in ~30 v2 PRs the bot missed and demote non-v2 items (Hosts page, marketing menu) to a brief "Also this week". * docs: pull in missed v2 features and bug fixes Add v2 project setup section (#3566, #3605, #3606, #3592, #3626, #3632), scheduled agent runs (#3576), Opus 4.7 (#3579), v1 review comments in pane (#3596), configurable v2 link-click (#3600), Copy Branch Name (#3635), safer terminal preset defaults (#3546), and /pricing page (#3639). Expand bug fixes with v2 git correctness, cross-fork PR misattribution, terminal paste/Unicode/Shift+Enter, and security bumps. * docs(changelog): add v2 public beta hero screenshot * docs(changelog): add Settings → Experimental screenshot, compress hero pngquant compression: v2-public-beta.png 704KB → 166KB (76%), v2-enable-flag.png 160KB → 36KB (78%). No visible quality loss. * docs(changelog): tighten v2 launch prose, condense bullet groups * docs(changelog): reframe cloud-first pillar as remote workspaces * docs(changelog): cut parallel-agents and honest-state pillars, fold into sub-sections * docs(changelog): tweak title and lead phrasing * docs(changelog): rewrite v2 launch lede around Twitter narrative Pull the launch story (physical limits, 3 ex-CTOs, cloud workspaces) into the lede, restructure pillars around Remote workspaces, Reimagined diff view, and Superset CLI, and add v2-remote-workspaces and v2-changes-pane screenshots to back the new sections. * docs(changelog): add CLI install snippet and docs link * docs(changelog): cut narrative lede, match standard changelog tone --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kiet Ho <hoakiet98@gmail.com>
Summary
useCopyToClipboardhook and surfaces a success toast.Test plan
Summary by cubic
Add Copy Branch Name to workspace context menus in v1 and v2 sidebars (expanded and collapsed) for local and remote/cloud workspaces. Copies the current git branch to the clipboard with a success toast; missing branch is a no-op in v1 and shows an error in v2.
Written for commit 4238f88. Summary will update on new commits.
Summary by CodeRabbit