Skip to content

modify the toast notification system to prevent spamming#293

Open
quinton-8 wants to merge 1 commit into
rmyndharis:mainfrom
quinton-8:feature/server-connection-loss-handling
Open

modify the toast notification system to prevent spamming#293
quinton-8 wants to merge 1 commit into
rmyndharis:mainfrom
quinton-8:feature/server-connection-loss-handling

Conversation

@quinton-8

@quinton-8 quinton-8 commented Jun 17, 2026

Copy link
Copy Markdown

Modify the toast notification system to prevent spamming multiple error notifications on the right side of the screen when the server is
stopped.

Description

Brief description of changes

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Tests added/updated
  • Documentation updated
  • Lint passes
  • Self-reviewed

Screenshots (if applicable)

Related Issues

Closes #

  error notifications on the right side of the screen when the server is
  stopped.
@quinton-8

Copy link
Copy Markdown
Author

Suppressed Duplicate Errors in ToastProvider
In Toast.tsx, added logic to check if a connection error occurs (based
on the server offline state or connection failure messages such as "failed
to fetch" or 502/503 status).
• It now suppresses all incoming error/success/warning toasts when
offline.
• Instead, it displays exactly one persistent error toast titled
"Server Connection Lost" asking the user to start the server. This
toast stays open until connection is restored.

@rmyndharis rmyndharis left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @quinton-8 — appreciate the focus on toast spam, and the happy path (success/warning/info and normal errors) is correctly left untouched. A few things to address before merge:

1. (Blocking) setTimeout is called inside the setToasts updater. State updater functions must be side-effect-free — under React 18 Strict Mode the updater runs twice (so two timers fire), and if an update is replayed/batched the timer can fire for a toast that was never committed, which can leave the dedup in a stuck state. Please mirror the existing addToast structure: compute the id first, do the dedup guard inside the updater (return prev when it's a duplicate), and call setTimeout(() => removeToast(id), 6000) after setToasts, not inside it. (This is the "side effects outside state updates" pattern in the repo's known-issues list.)

2. Extract the dedup sentinel. 'Server Connection Lost' is a hardcoded string used as the dedup key; if it's ever translated, the dedup silently breaks. Please pull it into a module-level constant (or an i18n key).

3. (Optional / follow-up) Scope. This only dedups a fixed list of network-error strings; other rapidly-repeating errors still stack. A more general fix would be a (type, title) dedup inside addToast itself — happy to take that as a separate follow-up if you'd prefer to keep this PR focused.

Items 1 and 2 are needed to merge; 3 is a nice-to-have. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants