Skip to content

feat(notifications): cap critical popups at max duration instead of forever - #13161

Closed
cristim wants to merge 2 commits into
omacom:quattrofrom
cristim:feat/critical-notification-timeout
Closed

cristim wants to merge 2 commits into
omacom:quattrofrom
cristim:feat/critical-notification-timeout

Conversation

@cristim

@cristim cristim commented Sep 24, 2026 •

Copy link
Copy Markdown

What

A critical notification popup waits for the user: durationFor() returns 0 for
NotificationUrgency.Critical, so it stays on screen until it is clicked,
dismissed or replaced. That is what the first-party senders are for. Taildrop
announcements (manual/35-networking.md promises the toast waits), pending
migrations, a crash to diagnose, the sleep-lock warning and the first-run setup
hooks all send critical with no expire_timeout, because they mean "wait for me".

So the rule is now: critical waits unless the sender states a timeout. A
positive expire_timeout is honoured for critical too, clamped like every other
urgency between the normal floor and the 30s ceiling the rest already had.

if (urgency === criticalUrgency && requested === 0) return 0
var floor = urgency === lowUrgency ? LOW_POPUP_DURATION : NORMAL_POPUP_DURATION
return Math.min(MAX_POPUP_DURATION, Math.max(floor, requested))

The policy moved to NotificationLogic.js so it can be tested, which nothing
covered before. The service passes its NotificationUrgency values in, the way
it already does for shouldBypassDnd.

Why not a flat cap

An earlier commit on this branch capped critical popups at maxPopupDuration. It
was one line, and it broke the contract above: those toasts were gone 30s after
they appeared, so on an unattended machine they were gone before the user came
back, and for the one-time invitations the toast was the only notice there was.

The accumulation this was meant to fix

The source of an unattended pile-up is omarchy-crash-watch, which re-announces a
crash-looping program every 60s, each announcement a critical toast that waits. It
now reads back the id the server gave it and hands that same id back as
replaces_id, so a loop updates one toast instead of adding one per minute. The
id is the server's to hand out, so it is learned with -p (the pattern
omarchy-display-text-size already uses) rather than invented: replaces_id is
matched only against a notification the server still holds, and a number nobody
handed out names whichever live notification happens to hold it.

Fixed in passing: a sender that raises urgency, or asks for a different lifetime,
through replaces_id no longer inherits the countdown fraction it already had, so
a toast escalated at the end of its life is not dropped seconds later.

Verification

  • test/shell.d/notifications-test.sh: the duration policy, including the critical
    case that had no coverage before.
  • test/shell.d/crash-capture-test.sh: the stubbed server now hands out ids the way
    the real one does, and the assertions check that the watcher hands back the id it
    was given, keeps one per program, and gives two different programs different ids.
  • notification-send-test.sh, migrate-notify-test.sh, tailscale-receive-test.sh
    and apply-lock-test.sh pass.
  • bash test/shell: 7 failures on this machine, all pre-existing and none in the
    files this touches (kernel headers, snapper, screenshot sanity, ssh reconnect, an
    untracked /usr/share/owe file, version).
  • Not verified: a live shell. The duration and id behaviour is covered by the tests
    above, but the on-screen countdown was not exercised in a running session.

@llstrk

llstrk commented Sep 24, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: The change does what the description says. A critical toast now counts down from 30 s, pauses while hovered, moves into history on expiry, and can still be dismissed early by right-click, the close button or the dismiss bindings. The accumulation problem is real in the repository: omarchy-crash-watch can add a new critical toast every 60 s per crash-looping program, and before this PR each one stayed until dismissed.

The main concern is that critical was the only way to get a toast that waits for the user, and several first-party senders and the user manual depend on that.

Critical toasts no longer wait for the user, which first-party senders and the manual rely on

Commit 7e469f9 (#7953) made Taildrop arrivals critical specifically so that "a file that arrived while nobody was at the machine" could still be opened later, and manual/35-networking.md tells users: "The notification announcing an arrival waits until you click it open or dismiss it". Other senders use critical for the same purpose:

Sender Purpose of the critical toast After this PR
bin/omarchy-tailscale-receive Received file, click to open Leaves the screen after 30 s; manual text no longer true
bin/omarchy-migrate-notify Pending migrations, shown once per login Missed if not seen within 30 s of login; no re-announcement until next login
bin/omarchy-crash-watch Click-to-diagnose crash toast Leaves the screen after 30 s
bin/omarchy-system-sleep-lock "Screen did not lock before suspend", described in source as the only way anyone finds out Stops being a standing warning after 30 s of shell uptime
migrations/1787494718.sh One-time FIDO2 authfile warning; the migration is marked done and does not warn again Leaves the screen after 30 s
install/user/first-run/*, setup hooks One-time setup invitations (Wi-Fi, update, keybindings, fingerprint, agent, Voxtype) Leave the screen after 30 s; not re-issued

The expired entries still reach history, but history keeps only the newest 10 entries and opens only through the history binding, and nothing shows that a critical toast expired unseen. The freedesktop Desktop Notifications Specification (Urgency Levels) also says critical notifications "should not automatically expire".

Impact: On an unattended machine, which is the case this PR targets, these prompts are gone from the screen by the time the user returns. For the one-time invitations and the FIDO2 warning, the toast is the only notice.

Suggested change: Address accumulation without removing the waiting behavior. Two approaches:

  • Keep critical sticky by default and honor an explicit positive sender timeout. omarchy-battery-low already sends -t 30000, so it would expire at 30 s while Taildrop, migrations, crash and first-run toasts keep waiting:
    case NotificationUrgency.Critical:
      var requested = requestedDuration(expireTimeout)
      return requested > 0 ? Math.min(maxPopupDuration, Math.max(normalPopupDuration, requested)) : 0
    This does not by itself stop crash loops or chat apps that send critical without a timeout.
  • Limit the stack directly: collapse repeated critical toasts (for example replaces_id per program in omarchy-crash-watch), or cap how many critical toasts are shown at once.

If the flat cap is kept, manual/35-networking.md, docs/notifications.md:17-18 ("forever (critical)"), the comment at NotificationLogic.js:386, and the test labels at test/shell.d/notifications-test.sh:511 and test/shell.d/tailscale-receive-test.sh:59-62 describe the old behavior and would need updating. Those tests still pass, and none of them calls durationFor().

Third-party critical notifications are closed as expired, not only hidden

On expiry the service calls ref.expire(), so the sender receives NotificationClosed with reason Expired. History keeps Omarchy's own --exec click command, but not a third-party sender's actions, and a replayed history row cannot invoke them. A script using notify-send -u critical -A ok=OK ... (which waits for an answer) now returns with no answer after 30 s.

Impact: The description's "nothing is lost" holds for the text and for Omarchy's own click actions, but not for interactive third-party notifications.

Suggested change: If the flat cap is kept, state this trade-off in the description and in docs/notifications.md. Alternatively, capping only the visible card while leaving the notification open until the user dismisses it would keep third-party actions usable (not tested).

A notification escalated to critical late in its life can vanish almost immediately

The card countdown stores the remaining lifetime as a fraction, and it is reset only when the summary, body or image changes (Service.qml:1013-1025). When a sender reuses an ID (replaces_id) to raise only the urgency, the remaining fraction carries over into the new 30 s lifetime:

Normal toast (8 s) escalated at Base Head: time left
4 s stays until dismissed 15 s
7 s stays until dismissed about 3.75 s
7.9 s stays until dismissed about 0.4 s

Derived from source; not run.

Impact: An alert raised to critical because it became more urgent can be on screen for less time than a fresh normal toast.

Suggested change: Reset remainingLifetime to 1.0 when urgency changes (at least when it rises to critical).

Pre-existing, now reaches critical toasts: With more than one monitor, each screen's copy of a toast runs its own timer, and hover pauses only the copy under the pointer. The first unhovered copy to reach zero removes the toast everywhere, so a critical toast being read on one monitor still expires at about 30 s. Critical toasts were previously exempt because their lifetime was 0. Confirmed from source only.


Review information

Test scope: Source review of head e88cf11 against base 28ceaae, including every first-party critical sender, related docs and git history, Quickshell 0.3.1 notification server source, Qt 6.11.2 ListModel source, libnotify notify-send, and the freedesktop Desktop Notifications Specification. No code was executed; multi-monitor, suspend and lock-screen behavior were not tested in a live session.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted follow-ups, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

Capping critical popups broke the one thing critical means. Taildrop
announcements, pending migrations, crash toasts, the sleep-lock warning and
the first-run hooks all send critical with no timeout because they want the
toast to wait, and manual/35-networking.md promises exactly that for a file
that arrives while nobody is at the machine. A cap took all of them off the
screen after 30s, and for the one-time invitations the toast was the only
notice there was.

So critical waits again, and the only thing allowed to shorten one is a
sender that says so: a positive expire_timeout is honoured, clamped like any
other urgency between the normal floor and the 30s ceiling the rest already
had. omarchy-battery-low is the first-party sender that asks, and now gets
what it asked for.

The policy moves to NotificationLogic.js so it can be tested, which nothing
covered before. The service passes its NotificationUrgency values in, the
way it already does for shouldBypassDnd.

A sender raising urgency or asking for a different lifetime through
replaces_id also gets the countdown restarted. The card resets its fraction
on new text but not on those two, so a toast escalated at the end of its life
inherited a clock that had almost run out and was dropped seconds after it
became more urgent.
omarchy-crash-watch re-announces a crash-looping program every 60 seconds,
and every one of those toasts is critical, so on a machine nobody is sitting
at they collected one per looping program per minute and stayed there. The
watcher now reads back the id the server gave it and hands the same id back
as replaces_id, so the re-announcement updates that one toast.

The id is the server's to hand out, so it is learned with -p rather than
invented: the server matches a replaces_id only against a notification it
still holds, and a number nobody handed out names whichever live
notification happens to hold it. Reading it back on every announcement also
heals the stored id once the toast has been dismissed.

docs/notifications.md documents the lifetime rule, the two sender flags this
now relies on, and what the crash watcher sends.
@cristim
cristim force-pushed the feat/critical-notification-timeout branch from e88cf11 to 0eb4399 Compare September 26, 2026 15:10
@cristim

cristim commented Sep 26, 2026

Copy link
Copy Markdown
Author

All three findings were right, and the first one changed the design. The branch is now two commits on the current quattro (0eb4399c), so the e88cf11 this reviewed is gone; nothing of the flat cap survives.

1. Critical no longer stops waiting for the user. I had listed the alternative in the description and then picked the flat cap anyway, which was the wrong call: the six senders you found all send critical precisely because they want the toast to wait, and manual/35-networking.md:39 promises it. The rule now is that critical waits unless the sender states a timeout, so omarchy-battery-low, the one first-party sender that asks (-t 30000), gets what it asks for and everything else is untouched.

I took your first option rather than a stack cap. A stack cap has to evict something, and the oldest critical toast is exactly the unopened Taildrop arrival the user came back for.

2. Third-party interactive notifications. This dissolves with the change above: a sender that did not request a timeout is no longer expired at all, so notify-send -A ok=OK still waits for its answer, and one that did request a timeout is getting what it asked for. Nothing left to document, so docs/notifications.md describes the rule instead of a trade-off.

3. Late escalation carrying the countdown over. Fixed, and I extended it one step: expireTimeout is the other thing lifetime is derived from, so a replaces_id update that changes only the timeout has the same defect. Both now restart the countdown, alongside the existing summary/body/image resets.

The accumulation the flat cap was aimed at. With critical waiting again, that has to be fixed at the source, so omarchy-crash-watch now hands the server back the id it gave for the previous announcement as replaces_id and a crash loop updates one toast. Your instinct to use replaces_id per program was right, and the id has to be the server's: it is read back with -p on every send, the way omarchy-display-text-size already does it, because a replaces_id is only matched against a notification the server still holds. I first wrote a client-side counter and a review pass caught exactly that, which is why the test now stubs the server's side of the contract: a replaces_id that matches returns the same id, and the assertion that fails if one is invented is "a program's first announcement carries no id before the server has handed one out".

Your multi-monitor point. Agreed it is pre-existing, and the change leaves less of it exposed: a sticky critical toast has no timer on any monitor to disagree about. Still worth its own issue if you agree it bites the toasts that do expire.

Tests. durationFor moved into NotificationLogic.js, where the node harness can reach it, so the critical case is covered now (it had none). crash-capture-test.sh covers the per-program id. The notifications-test.sh assertion that critical popups never expire on restore still holds as written, because a critical toast with no timeout is duration 0 again.

Not verified: a live shell. The policy and the id handling are covered by tests; I did not watch a toast count down in a running session, since driving the real notification server here would have disturbed it.

Thanks, this made the PR better than the one I opened.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier review and the author's reply, checked at 0eb4399c.

Verified: The redesign resolves the earlier findings. Critical toasts wait again unless the sender asks for a timeout, and the new durationFor tests fail if either the flat cap or the old always-wait rule comes back.

Earlier finding Status at 0eb4399c
Critical toasts no longer wait for the user Resolved. durationFor returns 0 for critical with no requested timeout. None of the six senders listed earlier passes -t, so they all wait again, and manual/35-networking.md:39 is accurate again.
Third-party critical notifications closed as Expired Resolved. An unrequested critical toast has no countdown, so ref.expire() is never reached and notify-send -u critical -A ... keeps waiting.
Late escalation inherits the old countdown Resolved. onUrgencyChanged and onExpireTimeoutChanged now reset remainingLifetime, alongside the existing summary, body and image resets (confirmed from source; not observed in a live shell).
Multi-monitor timers (pre-existing note) No longer affects critical toasts without a timeout, which have no timer on any screen. It still applies to low and normal toasts, as at base, and now also to critical toasts that request a timeout (such as omarchy-battery-low), which at base never had a timer. A separate issue seems reasonable, as the reply suggests.

Verified: Within one shell process, the -p/-r handling in omarchy-crash-watch updates one toast for repeated crashes of one program, keeps separate toasts for separate programs, and gives the next crash a fresh id after a dismissal.

Stored crash-toast ids can outlive the shell that issued them

omarchy-crash-watch is its own long-running user service and keeps notify_ids for its whole run. The notification server is the shell, and each shell process hands out ids from 1 again (docs/notifications.md:37). The shell restarts under a running watcher, for example during omarchy update, from omarchy-font-set or omarchy-refresh-shell, and when the shell itself crashes. Quickshell v0.3.1 honours a replaces_id for any notification it currently holds, whoever sent it.

shell process A: nautilus crashes   -> toast gets id 3, watcher stores 3
shell restarts:  ids start at 1 again
shell process B: Taildrop arrival   -> toast gets id 3
nautilus crashes again              -> watcher sends -r 3
                                     -> the Taildrop toast becomes "Process crashed: nautilus"

This was reproduced in a model: the real omarchy-crash-watch and omarchy-notification-send against a stubbed busctl that implements Quickshell v0.3.1's Notify id rules. It was not run against a real Quickshell server. Base leaves the Taildrop toast alone in the same scenario.

Impact: When the old id collides with a toast the new shell still holds, that toast's text and click command are replaced in place and never reach history. Waiting critical toasts stay held indefinitely, so a collision is plausible, though not frequent. When there is no collision, the server adds a new crash toast, next to the earlier one if that was still on screen at the restart and was restored from disk. As a result, a crash loop that spans restarts still stacks, and so does a crash loop of the shell itself, the crash the watcher's own comment calls the most worth reporting.

Suggested change: Forget the stored ids when the unique bus name that owns org.freedesktop.Notifications changes (for example via GetNameOwner), and add a crash-capture case in which the stubbed server restarts: it drops the ids it holds and numbers from 1 again. That approach has not been tested. It does not merge a new toast with one restored from disk. A shell-side per-program key matched against restored rows would cover both; open PR #11782 takes that route with --group.

Correction to the reply: The reply and commit 3bdce328 describe omarchy-battery-low as the one first-party critical sender with a timeout. omarchy-capture-screenrecording (lines 26, 79 and 234) and omarchy-capture-screenrecording-with-webcam (line 8) send critical with -t 3000 or -t 5000. At base these waited; now they leave after the 8 s floor, including "Recording process had to be force-killed. Video may be corrupted." That may be what those senders intended, but the change is not mentioned. Suggested change: mention it in the description, or drop those senders' -t if their toasts should still wait.

Optional test improvement: In crash-capture-test.sh, each program crashes only twice, so the "different id each time" check compares one id with itself and cannot fail. The stub also numbers ids from 1, so a watcher that counts its own ids gets the same numbers the stub hands out. Two mutant watchers pass the shipped test: one that counts its own ids, and one that switches to a new stored id after each replacement. A copy of the test with the stub counter seeded at 40 and a third crash per program catches both mutants and still passes on head. Separately, the Service.qml call into NotificationLogic.durationFor is not pinned: swapping the Low and Critical arguments, so that low toasts without a requested timeout would wait forever, passes notifications-test.sh. A source regex like the file's other Service.qml checks would catch it.

Related open PRs: #13159 changes the same durationFor lines to give critical toasts from any app other than notify-send and omarchy-action a finite lifetime, even without a timeout. That is the opposite policy for those senders. #11782 changes the same crash-watch path differently: per-program --group toasts that expire after a minute, with the watcher's dedupe window removed. The two PRs overlap with this one and would need reconciling if more than one is taken.

PR title: The title still describes the flat cap; a title describing the current rule (critical waits unless the sender requests a timeout) would match the change.


Review information

Test scope: Follow-up review of head 0eb4399c against merge-base e1614f2b. It included source review of the changed files, every first-party critical sender, omarchy-notification-send, and Quickshell v0.3.1's notification server. In an isolated sandbox: the changed and related tests on head and base, the full test/shell run on both (the same 10 files fail on head and base; the ones checked fail on sandbox limits), mutation checks, and a stub model of the server's id rules. No live shell, D-Bus session or multi-monitor setup was used.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

For the maintainer's comparison: the new durationFor rule here (critical waits unless the sender asks for a timeout, then clamp) is the same one proposed in #13100, #13041 and #12964, all for #12911. Those are worth folding together so only one lands. The omarchy-crash-watch replace-id part is separate and also overlaps your own #11782.

Note that this rule doesn't change the #13153 case (Chrome sends critical with expire_timeout 0, so it still waits forever). #13159 takes the opposite approach for that one, so the two need a product call.

@aholbreich

Copy link
Copy Markdown
Contributor

The explicit-timeout part here overlaps the older, verified #12964, which we've recommended to the maintainers. This PR isn't a pure duplicate though: the omarchy-crash-watch replacement-id change and its #10651 coverage are unique. Could you keep that as a focused follow-up rebased after #12964, so it isn't lost in the timeout consolidation? Credit to @cristim for finding and testing the crash-loop accumulation.

@cristim

cristim commented Oct 18, 2026

Copy link
Copy Markdown
Author

Closing this in favour of #11782, which solves the same two problems (one toast per crashing program, and critical toasts that eventually expire) with a different design, and the two can't both land: rebased onto the current quattro they conflict in omarchy-crash-watch, docs/notifications.md, Service.qml and notifications-test.sh.

A fresh review of the rebased branch also turned up two problems with this approach. The watcher keeps its replaces_id across a shell restart, while a new notification server starts its ids again at 1, so as far as I can tell from the code a stale -r could replace an unrelated live toast, and a shell crash is exactly when crash toasts matter most. And any critical sender that passes -t would now expire, including omarchy-battery-low at 30 seconds, which the description doesn't mention. #11782 only expires critical toasts that opt in with --expire-critical, so existing senders keep waiting.

The one piece worth keeping, restarting the countdown when an update changes only the urgency or the timeout, is now in #11782 (fb286ae). Thanks to everyone who reviewed this, the two rounds shaped that fix.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants