Skip to content

Add copy action to error toast messages#1416

Merged
juliusmarminge merged 5 commits intomainfrom
t3code/copy-git-errors
Mar 25, 2026
Merged

Add copy action to error toast messages#1416
juliusmarminge merged 5 commits intomainfrom
t3code/copy-git-errors

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 25, 2026

Summary

  • Added a copy button to error toasts so users can quickly copy the error description.
  • Reused the existing clipboard hook and swapped the icon to a checkmark after a successful copy.
  • Made toast descriptions selectable so error text is easier to inspect or copy manually.
  • Applied the new copy affordance to both floating and anchored toast layouts.

Testing

  • Not run (PR content only).

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 CopyErrorButton to toast.tsx and renders it for error toasts when the description is a string, copying the description to the clipboard and swapping CopyIcon to CheckIcon on success.

Toast descriptions are now select-text to allow manual selection/copying, and the copy affordance is applied consistently to both the standard Toasts and AnchoredToasts layouts.

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 CopyErrorButton component to error toasts in both Toasts and AnchoredToasts in toast.tsx. The button copies the error description to the clipboard and switches from a CopyIcon to a CheckIcon to confirm success. The description text also gains select-text to allow manual selection.

Macroscope summarized 73688f6.

- Let users copy error toast descriptions
- Keep toast text selectable for manual copy
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3ab39e7b-f77a-43b4-8183-c4da84723f1a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/copy-git-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 25, 2026
- 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
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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-between class to the anchored toast title row wrapper div to match the floating toast layout.

Create PR

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">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

…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().
@cursor
Copy link
Copy Markdown
Contributor

cursor bot commented Mar 25, 2026

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Missing type guard for toast description in anchored toast
    • Added typeof toast.description === "string" type guard to the anchored toast at line 408 to match the existing guard in the floating toast at line 314, preventing non-string values from being passed to CopyErrorButton.

Create PR

Or push these changes by commenting:

@cursor push 30497a89f2
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>

@juliusmarminge
Copy link
Copy Markdown
Member Author

@cursor push 30497a8

…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
@juliusmarminge juliusmarminge merged commit 8888f6a into main Mar 25, 2026
11 checks passed
@juliusmarminge juliusmarminge deleted the t3code/copy-git-errors branch March 25, 2026 20:01
emrezeytin pushed a commit to emrezeytin/t3code that referenced this pull request Mar 25, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
aaditagrawal pushed a commit to aaditagrawal/t3code that referenced this pull request Mar 26, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
kkorenn pushed a commit to kkorenn/k1code that referenced this pull request Mar 26, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
apexsloth pushed a commit to apexslothforks/t3code that referenced this pull request Mar 26, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants