Add copy action to error toast messages#1416
Conversation
- Let users copy error toast descriptions - Keep toast text selectable for manual copy
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Restrict the error copy button to string descriptions - Avoid passing non-string toast content into the clipboard action
- Restrict the copy-error action to string descriptions - Avoid passing non-string toast descriptions to the clipboard
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Inconsistent justify-between in anchored toast title row
- Added the missing
justify-betweenclass to the anchored toast title row wrapper div to match the floating toast layout.
- Added the missing
Or push these changes by commenting:
@cursor push 5b654fcb7a
Preview (5b654fcb7a)
diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx
--- a/apps/web/src/components/ui/toast.tsx
+++ b/apps/web/src/components/ui/toast.tsx
@@ -400,7 +400,7 @@
)}
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
- <div className="flex items-center gap-1">
+ <div className="flex items-center justify-between gap-1">
<Toast.Title
className="min-w-0 break-words font-medium"
data-slot="toast-title"| className="min-w-0 break-words font-medium" | ||
| data-slot="toast-title" | ||
| /> | ||
| <div className="flex items-center gap-1"> |
There was a problem hiding this comment.
Inconsistent justify-between in anchored toast title row
Low Severity
The title-row wrapper in Toasts uses justify-between to push the CopyErrorButton to the far right, but the equivalent wrapper in AnchoredToasts omits it. This causes the copy button to render immediately adjacent to the title text in anchored toasts instead of being right-aligned, resulting in inconsistent placement between the two toast layouts.
Additional Locations (1)
…oast The floating toast correctly guarded with typeof toast.description === 'string' before passing to CopyErrorButton, but the anchored toast only checked truthiness. This could pass non-string values (e.g. React nodes) to clipboard.writeText().
|
Bugbot Autofix prepared a fix for the issue found in the latest run.
Or push these changes by commenting: Preview (30497a89f2)diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx
--- a/apps/web/src/components/ui/toast.tsx
+++ b/apps/web/src/components/ui/toast.tsx
@@ -405,7 +405,7 @@
className="min-w-0 break-words font-medium"
data-slot="toast-title"
/>
- {toast.type === "error" && toast.description && (
+ {toast.type === "error" && typeof toast.description === "string" && (
<CopyErrorButton text={toast.description} />
)}
</div> |
…oast The floating toast correctly guarded with typeof toast.description === 'string' before passing to CopyErrorButton, but the anchored toast only checked truthiness. This could pass non-string values (e.g. React nodes) to clipboard.writeText(). Applied via @cursor push command
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>



Summary
Testing
Note
Low Risk
Low risk UI-only change that reuses the existing clipboard hook; main risk is minor layout/interaction regressions in toast rendering.
Overview
Adds a
CopyErrorButtontotoast.tsxand renders it for error toasts when the description is a string, copying the description to the clipboard and swappingCopyIcontoCheckIconon success.Toast descriptions are now
select-textto allow manual selection/copying, and the copy affordance is applied consistently to both the standardToastsandAnchoredToastslayouts.Written by Cursor Bugbot for commit 73688f6. This will update automatically on new commits. Configure here.
Note
Add copy-to-clipboard button to error toast messages
Adds a
CopyErrorButtoncomponent to error toasts in bothToastsandAnchoredToastsin toast.tsx. The button copies the error description to the clipboard and switches from aCopyIconto aCheckIconto confirm success. The description text also gainsselect-textto allow manual selection.Macroscope summarized 73688f6.