ui: Copy error message from toast to clipboard#4624
Merged
Conversation
Contributor
|
Just looking at the screenshots, I like it a lot! Leaving the code review to @lamppu and others. |
lamppu
requested changes
Mar 6, 2026
| type='button' | ||
| onClick={handleCopyClick} | ||
| > | ||
| <Button variant='ghost' size='sm' onClick={handleCopyClick}> |
Contributor
There was a problem hiding this comment.
Can you test copying the JSON payload from the create run form, IIRC the type='button' was added here to prevent the form from submitting when clicking the copy button.
Contributor
Author
There was a problem hiding this comment.
So that's what it was for! I couldn't understand why we would be forced to tell a Button that it is a Button, but indeed, without it, it does create a new run in that view, so thanks for catching this! Need to remember in case we use CopyToClipboard in some other forms in the future.
Sonner's swipe-to-dismiss and touch action implementation prevents manual text selection from all toasts. There is no Sonner API to disable this selectively for the content area, so making the text manually selectable is not feasible without patching the library. Instead, add copy-to-clipboard button to each error toast, by passing a `ReactNode` to Sonner's cancel option containing a stacked column of "Dismiss" button + `CopyToClipboard`. By centralizing the toast error creation into a `toastError()` helper, also remove ~800 lines of boilerplate UI code from 75 call sites. Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
As the `title`, `message` and `cause` of the error are readily available, separate them in the text which is copied to clipboard. To help readability of the message/cause, also word-wrap the lines on column 75. Resolves #4507. Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.io>
lamppu
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How it looks in a text editor
Please see the commits for details.