-
Notifications
You must be signed in to change notification settings - Fork 969
feat(desktop): add Copy Branch Name to v1 and v2 sidebar context menus #3635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4b2be93
52c71bc
8755452
b2ef33f
4238f88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -243,6 +243,11 @@ export function WorkspaceListItem({ | |||||||||||||||||||||||||||||||||||||
| await copyToClipboard(worktreePath); | ||||||||||||||||||||||||||||||||||||||
| toast.success("Path copied to clipboard"); | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
| const handleCopyBranchName = async () => { | ||||||||||||||||||||||||||||||||||||||
| if (!branch) return; | ||||||||||||||||||||||||||||||||||||||
| await copyToClipboard(branch); | ||||||||||||||||||||||||||||||||||||||
| toast.success("Branch name copied to clipboard"); | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
AviPeltz marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+246
to
251
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The v1 sidebar's The v2 sidebar implementation in
Suggested change
Prompt To Fix With AIThis 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. |
||||||||||||||||||||||||||||||||||||||
| const pr = githubStatus?.pr; | ||||||||||||||||||||||||||||||||||||||
| const diffStats = | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -270,6 +275,7 @@ export function WorkspaceListItem({ | |||||||||||||||||||||||||||||||||||||
| onClick={handleClick} | ||||||||||||||||||||||||||||||||||||||
| onDeleteClick={handleDeleteClick} | ||||||||||||||||||||||||||||||||||||||
| onCopyPath={handleCopyPath} | ||||||||||||||||||||||||||||||||||||||
| onCopyBranchName={handleCopyBranchName} | ||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -467,6 +473,7 @@ export function WorkspaceListItem({ | |||||||||||||||||||||||||||||||||||||
| onOpenInFinder={handleOpenInFinder} | ||||||||||||||||||||||||||||||||||||||
| onOpenInEditor={handleOpenInEditor} | ||||||||||||||||||||||||||||||||||||||
| onCopyPath={handleCopyPath} | ||||||||||||||||||||||||||||||||||||||
| onCopyBranchName={handleCopyBranchName} | ||||||||||||||||||||||||||||||||||||||
| onSetUnread={(unread) => setUnread.mutate({ id, isUnread: unread })} | ||||||||||||||||||||||||||||||||||||||
| onResetStatus={() => resetWorkspaceStatus(id)} | ||||||||||||||||||||||||||||||||||||||
| onDelete={handleDeleteClick} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.