Skip to content

feat: a notification bus, so what matters is said once and only once - #41

Merged
fylorn merged 1 commit into
devfrom
feat/notices
Sep 17, 2026
Merged

fylorn merged 1 commit into
devfrom
feat/notices

Conversation

@fylorn

@fylorn fylorn commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Pins core v0.6.0, whose state-change events this builds on (Core#40).

Until now the only thing that reached a user who was not looking at the window was a flagged tool call. A rejected config, a credential that could not be written back, a new scan finding — all lived in React state, and closing the window destroys the webview, so it was as if they had never happened. Quota running out and a login expiring are exactly the events that happen while nobody is watching.

The decision lives in Rust

src-tauri/src/notices/:

File What it does
rules.rs core events and supervisor states → signals: a level, a dedupe key (kind:object), and whether the user is already waiting for this answer
mod.rs the bus: hold, dedupe, suppress, rate-limit, flap-damp, withdraw
sink.rs where it goes: the in-app centre and the system notification
store.rs open notices persist

What the bus does, and why:

  • Hold a fault for a minute before speaking. One that fixes itself inside that minute is never announced. Things the user is already waiting on (safe mode, a flagged tool call, a failed write-back) skip the hold.
  • Dedupe by key: the same thing is said once, and after that only the count moves.
  • Suppress: a gateway that is not forwarding silences everything underneath it. Those notices still appear in the list — they are just not worth a second interruption.
  • Rate-limit with a token bucket of 3, refilled one per 10 minutes. What it holds back is folded into the next one that gets through ("另有 N 项待处理").
  • Flap-damping: something that opens and closes three times within an hour is said once more and then muted, with a line in the list saying it is intermittent.
  • Recovery is silent by default. Only a critical that lasted five minutes says out loud that it is over — a notification that cannot be withdrawn is what makes people turn notifications off.
  • Persisted, so a closed window, an app restart or a core restart does not announce the same thing twice.

Levels: critical is only "nothing is being forwarded right now"; warning is something that needs the user to act; info never interrupts.

Interface

The toolbar has a bell with what is currently open: level, what happened, how many times, and a click that lands on the page that can fix it. Each row can be dismissed.

Deliberately not in this PR

  • Per-category switches and "stop telling me about this" — the next step.
  • The native macOS layer. The plugin in use can only fire and forget: no click-through, no update in place, no withdrawal (confirmed in its source and upstream issues). The sink boundary is where that swap happens, and it should be preceded by a real signed build to confirm a self-signed app can hold notification authorisation.
  • Windows. The sink trait is the extension point; the rules do not change.

Test plan

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (89, of which 12 are new: hold, dedupe, suppression, the bucket and its fold-in, flapping, recovery, dismissal, and the copy rules)
  • pnpm typecheck, pnpm test (88)
  • Walked the bell in the isolated preview against a mocked control plane: the list, the count, dismissal, and click-through to the right page.

🤖 Generated with Claude Code

Pins core v0.6.0 for the state changes it now reports.

Until now the only event that reached a user who was not looking at the
window was a flagged tool call. Everything else — a rejected config, a
credential that could not be written back, a new scan finding — lived in
React state, and closing the window destroys the webview, so it was as if
it had never happened. Quota running out and a login expiring are exactly
the things that happen while nobody is watching.

The decision now lives in Rust (src-tauri/src/notices):

- rules.rs turns core events and supervisor states into signals: a level, a
  dedupe key of kind:object, and whether the user is already waiting for
  this answer. Copy carries no key, prompt or tool argument — a system
  notification is visible on a lock screen.
- mod.rs is the bus: hold a fault for a minute before speaking (one that
  fixes itself is never announced), say the same thing once and update a
  count after that, let a down gateway silence everything under it, spend
  from a token bucket and fold what it holds back into the next one that
  gets through, mute something that flaps, and withdraw silently on
  recovery — only a long critical says out loud that it is over.
- sink.rs is where it goes. The system sink is one implementation; Windows
  adds a sink, not a second set of rules.
- Open notices persist, so they survive a closed window, an app restart and
  a core restart rather than being announced twice.

The toolbar has a bell with what is currently open: level, what happened,
how many times, and a click that lands on the page that can fix it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 3529427 into dev Sep 17, 2026
2 checks passed
@fylorn
fylorn deleted the feat/notices branch September 17, 2026 19:22
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.

1 participant