Skip to content

fix: auto-dismiss toast notifications after timeout#847

Closed
ranvier2d2 wants to merge 1 commit intopingdotgg:mainfrom
ranvier2d2:fix/toast-auto-dismiss
Closed

fix: auto-dismiss toast notifications after timeout#847
ranvier2d2 wants to merge 1 commit intopingdotgg:mainfrom
ranvier2d2:fix/toast-auto-dismiss

Conversation

@ranvier2d2
Copy link
Copy Markdown
Contributor

@ranvier2d2 ranvier2d2 commented Mar 10, 2026

Summary

Changes

  • Added a DEFAULT_DISMISS_AFTER_VISIBLE_MS = 5_000 constant in apps/web/src/components/ui/toast.tsx
  • Applied it as a fallback when dismissAfterVisibleMs is not explicitly set by the caller
  • The existing ThreadToastVisibleAutoDismiss component already had visibility-aware pause/resume logic, but only 1 of ~15 call sites opted in — this makes 5s auto-dismiss the default

Test plan

  • Trigger various toasts (session start, errors, git actions) and verify they dismiss after ~5s
  • Verify toasts still pause countdown when tab is hidden or window loses focus
  • Verify GitActionsControl.tsx still uses its custom 10s timeout

Note

Auto-dismiss non-loading toast notifications after 5 seconds

Adds a DEFAULT_DISMISS_AFTER_VISIBLE_MS constant (5,000 ms) in toast.tsx and passes it as the default dismissAfterVisibleMs to ThreadToastVisibleAutoDismiss for all non-loading toasts. Loading toasts continue to persist until explicitly dismissed.

Macroscope summarized 88ed0ac.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 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: 2aa814ae-c120-4e36-bb28-cd0fb2c1816a

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
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 10, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3523db7fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

>
<ThreadToastVisibleAutoDismiss
dismissAfterVisibleMs={toast.data?.dismissAfterVisibleMs}
dismissAfterVisibleMs={toast.data?.dismissAfterVisibleMs ?? DEFAULT_DISMISS_AFTER_VISIBLE_MS}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Skip default timeout for manually managed toasts

Using toast.data?.dismissAfterVisibleMs ?? DEFAULT_DISMISS_AFTER_VISIBLE_MS forces a 5s auto-dismiss even when a toast is intentionally long-lived via timeout: 0. In apps/web/src/components/GitActionsControl.tsx, runGitActionWithToast creates a loading toast and later updates that same toastId with success/error; when a git action runs longer than ~5s, this auto-dismiss closes the toast first and the later toastManager.update(...) no longer reliably surfaces the result. This regresses progress/result visibility for longer operations.

Useful? React with 👍 / 👎.

type ToastId = ReturnType<typeof toastManager.add>;
const threadToastVisibleTimeoutRemainingMs = new Map<ToastId, number>();

const DEFAULT_DISMISS_AFTER_VISIBLE_MS = 5_000;
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.

🟡 Medium ui/toast.tsx:30

DEFAULT_DISMISS_AFTER_VISIBLE_MS is unconditionally applied to all toasts, including loading toasts. This causes loading toasts to auto-dismiss after 5 seconds even if the async operation is still running, leaving users without feedback and causing them to miss the eventual success/error state. Consider exempting loading toasts from the default timeout or requiring explicit durations only for non-loading types.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/components/ui/toast.tsx around line 30:

`DEFAULT_DISMISS_AFTER_VISIBLE_MS` is unconditionally applied to all toasts, including `loading` toasts. This causes loading toasts to auto-dismiss after 5 seconds even if the async operation is still running, leaving users without feedback and causing them to miss the eventual success/error state. Consider exempting `loading` toasts from the default timeout or requiring explicit durations only for non-loading types.

Evidence trail:
- apps/web/src/components/ui/toast.tsx line 30: `DEFAULT_DISMISS_AFTER_VISIBLE_MS = 5_000`
- apps/web/src/components/ui/toast.tsx lines 267-270: `ThreadToastVisibleAutoDismiss` rendered for ALL toasts with fallback to default timeout
- apps/web/src/components/ui/toast.tsx lines 64-143: `ThreadToastVisibleAutoDismiss` effect manages timer independent of base-ui's `timeout` property
- apps/web/src/components/GitActionsControl.tsx lines 154-157: `threadToastData` only contains `{ threadId: activeThreadId }`, no `dismissAfterVisibleMs`
- apps/web/src/components/GitActionsControl.tsx lines 308-311, 316-319, 328-330: Loading toasts created with `timeout: 0` but no `dismissAfterVisibleMs` in data

Add a 5s default auto-dismiss for toasts. Loading toasts are excluded
so they persist until their operation completes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ranvier2d2 ranvier2d2 force-pushed the fix/toast-auto-dismiss branch from a3523db to 88ed0ac Compare March 10, 2026 21:18
@laxman-patel
Copy link
Copy Markdown

This is the intended behavior for “Action Failed” toasts, as stated by the maintainer in PR #672. To quote:

i feel like error toasts shouldn't auto dismiss. if i don't pay attention and the toast dismisses before i come back, there's now no indication that the action i performed failed and i'm left wondering if it ever ran

You may consider closing this PR.

@ranvier2d2 ranvier2d2 closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toasts keep hanging

2 participants