Skip to content

feat(desktop): add Copy Branch Name to v1 and v2 sidebar context menus#3635

Merged
AviPeltz merged 5 commits into
mainfrom
humdrum-ash
Apr 22, 2026
Merged

feat(desktop): add Copy Branch Name to v1 and v2 sidebar context menus#3635
AviPeltz merged 5 commits into
mainfrom
humdrum-ash

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Apr 22, 2026

Summary

  • Adds a Copy Branch Name option to the right-click context menu on workspace items in both the v1 and v2 dashboard sidebars (expanded and collapsed views).
  • Copies the workspace's git branch to the clipboard via the existing useCopyToClipboard hook and surfaces a success toast.

Test plan

  • v1 sidebar: right-click a worktree workspace (expanded) → Copy Branch Name → paste elsewhere matches the branch
  • v1 sidebar: right-click a local ("branch") workspace → Copy Branch Name works
  • v1 sidebar: collapse the sidebar, right-click a worktree item → Copy Branch Name works
  • v2 sidebar: right-click a local-device workspace → Copy Branch Name works
  • v2 sidebar: right-click a remote/cloud workspace → Copy Branch Name still appears and works
  • v2 sidebar: collapsed variant → Copy Branch Name works
  • Success toast "Branch name copied" shows each time

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.

  • Bug Fixes
    • v1 collapsed local branch workspaces: right-click now opens a context menu, making Copy Branch Name accessible.

Written for commit 4238f88. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added "Copy Branch Name" action to workspace context menus, enabling users to quickly copy branch names to clipboard with automatic success and error notifications.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Dashboard Sidebar Components
DashboardSidebarWorkspaceItem.tsx, DashboardSidebarWorkspaceContextMenu.tsx
Added onCopyBranchName prop threading and "Copy Branch Name" menu item with branch icon to context menu for dashboard workspace items.
Dashboard Sidebar Action Hook
useDashboardSidebarWorkspaceItemActions.ts
Added branch parameter to options, implemented handleCopyBranchName async handler with clipboard copy, validation, and toast notifications for success/failure states.
Main Workspace Sidebar Components
WorkspaceListItem.tsx, CollapsedWorkspaceItem.tsx, WorkspaceContextMenu.tsx
Added handleCopyBranchName handler to WorkspaceListItem and threaded onCopyBranchName prop through both collapsed and expanded render paths; added "Copy Branch Name" context menu items with branch icon across all sidebar variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A branch name here, a copy there,
From dashboard to sidebar, everywhere!
With clipboard magic and toasts that gleam,
We gather your branches in one swift dream. ✨🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a Copy Branch Name feature to both v1 and v2 sidebar context menus.
Description check ✅ Passed The PR description includes a clear summary, detailed test plan with checkboxes, and comprehensive additional context from the auto-generated summary.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch humdrum-ash

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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

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

  • The v2 sidebar implementation (useDashboardSidebarWorkspaceItemActions) is well-structured: it guards against an empty branch, wraps copyToClipboard in a try/catch, and surfaces appropriate error toasts in both failure modes.
  • The v1 sidebar implementation (WorkspaceListItem.handleCopyBranchName) silently returns when branch is falsy (no user feedback) and has no error handling around the clipboard write — inconsistent with the v2 approach and with the existing handleCopyPath pattern in the v2 hook.
  • Minor: the success toast text differs between sidebars (\"Branch name copied to clipboard\" vs \"Branch name copied\"), which creates a small UX inconsistency.

Confidence Score: 4/5

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

Important Files Changed

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
Loading
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

Comment on lines +246 to 250
const handleCopyBranchName = async () => {
if (!branch) return;
await copyToClipboard(branch);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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.
@AviPeltz AviPeltz merged commit a2a7ba5 into main Apr 22, 2026
6 of 7 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! 🎉

MocA-Love added a commit to MocA-Love/superset that referenced this pull request Apr 23, 2026
Copy Branch Name (superset-sh#3635) のupstream版がDeletingWorkspacesProviderに
依存していたが、PR1にファイルが含まれていなかった。
Kitenite added a commit that referenced this pull request May 4, 2026
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.
Kitenite added a commit that referenced this pull request May 6, 2026
…-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>
saddlepaddle pushed a commit that referenced this pull request May 6, 2026
…-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>
@Kitenite Kitenite deleted the humdrum-ash branch May 6, 2026 04:52
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