Skip to content

feat: back the notification centre with error and warning toasts - #653

Open
KUASWoodyLIN wants to merge 1 commit into
mainfrom
652-persist-error-and-warning-toasts-in-the-notification-centre
Open

feat: back the notification centre with error and warning toasts#653
KUASWoodyLIN wants to merge 1 commit into
mainfrom
652-persist-error-and-warning-toasts-in-the-notification-centre

Conversation

@KUASWoodyLIN

Copy link
Copy Markdown
Collaborator

Summary

Failures in the dashboard surface as toasts and disappear with them — once a
toast fades there is no way to find out what went wrong. This PR turns the
notification sheet into a real notification centre: error and warning toasts are
recorded as they are raised, persisted across reloads, and surfaced behind a bell
in the sidebar with an unread count.

Closes #

Notification store

A NotificationCenter holding a newest-first list, capped at 200 entries and
backed by localStorage, so notifications survive a reload. On load the stored
JSON is revived — dates restored, malformed entries dropped, anything older than
7 days pruned.

Toast recorder

Bridges svelte-sonner into the store. sync() reads sonner's live toast state,
so a single $effect in the root layout subscribes to it — existing toast.*
call sites are untouched.

  • Only error and warning toasts are filed; a loading toast is filed if and
    when it resolves into an error.
  • Toasts are keyed by a level + title + content signature, so a toast updated
    in place — or toast.promise reusing one id — updates instead of duplicating.
  • Repeats collapse: a failing polling loop increments a count on the latest
    notification rather than filing hundreds of rows.

Notification centre

The sheet now lists recorded notifications with their level and read state, and
supports mark-all-as-read, clear-all, per-entry copy and delete. It opens from a
new bell in the sidebar header showing the unread count, which replaces the entry
in the user dropdown and keeps the Ctrl+N shortcut.

…toasts

Failures surface as toasts and disappear with them. Record them so users can
review what went wrong after the fact.

- Add NotificationCenter: a capped (200), localStorage-backed, newest-first
  store that revives dates on load and prunes entries older than 7 days
- Add ToastRecorder: syncs svelte-sonner's active toasts from the root
  layout, filing error/warning toasts and collapsing repeats into a count
  so a failing polling loop does not flood the list
- Move the trigger out of the user dropdown into a sidebar bell button with
  an unread badge, keeping the Ctrl+N shortcut
- Rework the sheet with mark-all-as-read, clear-all, per-item delete and
  expand/collapse for long messages
- Wire the notification store into $lib/stores and cover both stores with
  unit tests
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.

Persist error and warning toasts in the notification centre

1 participant