-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(web): add close icon for slow request toast #2040
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
Closed
kendalled
wants to merge
1
commit into
pingdotgg:main
from
kendalled:fix/dismiss-slow-requests-banner
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { | |
| InfoIcon, | ||
| LoaderCircleIcon, | ||
| TriangleAlertIcon, | ||
| XIcon, | ||
| } from "lucide-react"; | ||
|
|
||
| import { cn } from "~/lib/utils"; | ||
|
|
@@ -31,6 +32,7 @@ export type ThreadToastData = { | |
| tooltipStyle?: boolean; | ||
| dismissAfterVisibleMs?: number; | ||
| hideCopyButton?: boolean; | ||
| showCloseButton?: boolean; | ||
| }; | ||
|
|
||
| const toastManager = Toast.createToastManager<ThreadToastData>(); | ||
|
|
@@ -302,9 +304,23 @@ function Toasts({ position = "top-right" }: { position: ToastPosition }) { | |
| dismissAfterVisibleMs={toast.data?.dismissAfterVisibleMs} | ||
| toastId={toast.id} | ||
| /> | ||
| {toast.data?.showCloseButton ? ( | ||
| <button | ||
| aria-label="Dismiss notification" | ||
| className={cn( | ||
| buttonVariants({ size: "icon-xs", variant: "ghost" }), | ||
| "absolute top-2 right-2 z-10 size-5 rounded-sm p-0 text-muted-foreground hover:text-foreground", | ||
| )} | ||
| onClick={() => toastManager.close(toast.id)} | ||
| type="button" | ||
| > | ||
| <XIcon className="size-3" /> | ||
| </button> | ||
| ) : null} | ||
| <Toast.Content | ||
| className={cn( | ||
| "pointer-events-auto flex items-center justify-between gap-1.5 overflow-hidden px-3.5 py-3 text-sm transition-opacity duration-250 data-expanded:opacity-100", | ||
| toast.data?.showCloseButton ? "pr-8" : null, | ||
| hideCollapsedContent && | ||
| "not-data-expanded:pointer-events-none not-data-expanded:opacity-0", | ||
| )} | ||
|
|
@@ -397,12 +413,30 @@ function AnchoredToasts() { | |
| data-slot="toast-popup" | ||
| toast={toast} | ||
| > | ||
| {toast.data?.showCloseButton ? ( | ||
| <button | ||
| aria-label="Dismiss notification" | ||
| className={cn( | ||
| buttonVariants({ size: "icon-xs", variant: "ghost" }), | ||
| "absolute top-2 right-2 z-10 size-5 rounded-sm p-0 text-muted-foreground hover:text-foreground", | ||
| )} | ||
| onClick={() => anchoredToastManager.close(toast.id)} | ||
| type="button" | ||
| > | ||
| <XIcon className="size-3" /> | ||
| </button> | ||
| ) : null} | ||
| {tooltipStyle ? ( | ||
| <Toast.Content className="pointer-events-auto px-2 py-1"> | ||
| <Toast.Title data-slot="toast-title" /> | ||
| </Toast.Content> | ||
|
Comment on lines
429
to
432
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. 🟢 Low When {tooltipStyle ? (
- <Toast.Content className="pointer-events-auto px-2 py-1">
+ <Toast.Content
+ className={cn(
+ "pointer-events-auto px-2 py-1",
+ toast.data?.showCloseButton ? "pr-8" : null,
+ )}
+ >
<Toast.Title data-slot="toast-title" />
</Toast.Content>
) : (🤖 Copy this AI Prompt to have your agent fix this: |
||
| ) : ( | ||
| <Toast.Content className="pointer-events-auto flex items-center justify-between gap-1.5 overflow-hidden px-3.5 py-3 text-sm"> | ||
| <Toast.Content | ||
| className={cn( | ||
| "pointer-events-auto flex items-center justify-between gap-1.5 overflow-hidden px-3.5 py-3 text-sm", | ||
| toast.data?.showCloseButton ? "pr-8" : null, | ||
| )} | ||
| > | ||
| <div className="flex min-w-0 flex-1 gap-2"> | ||
| {Icon && ( | ||
| <div | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close button leaves stale ref, preventing toast re-show
Medium Severity
When the user clicks the close button,
toastManager.close(toast.id)dismisses the toast, buttoastIdRef.currentinSlowRpcAckToastCoordinatoris never cleared. On subsequentslowRequestschanges, the coordinator takes thetoastManager.update(toastIdRef.current, ...)branch, which silently no-ops on a closed toast. The slow-request warning never reappears until requests drop to zero and rise again — effectively suppressing the notification permanently after one dismissal.Additional Locations (1)
apps/web/src/components/ui/toast.tsx#L306-L318Reviewed by Cursor Bugbot for commit 17d9bd1. Configure here.