Skip to content

Honor critical notification expireTimeout when sender requests one - #12964

Closed
kvnloo wants to merge 12 commits into
omacom:quattrofrom
kvnloo:fix/12911-critical-expire-timeout
Closed

kvnloo wants to merge 12 commits into
omacom:quattrofrom
kvnloo:fix/12911-critical-expire-timeout

Conversation

@kvnloo

@kvnloo kvnloo commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

durationFor() mapped every Critical notification to lifetime 0, discarding the sender's expireTimeout. That made critical toasts with an explicit timeout (e.g. battery-low via omarchy-notification-send -u critical -t 30000) immortal on screen and resurrect on every reboot via restorePopups().

Why

FreeDesktop treats expireTimeout == 0 as never-expire. A non-zero timeout should still be honoured for critical urgency. Sticky critical (timeout 0/absent) stays intentional.

Change

In shell/plugins/notifications/Service.qml durationFor():

  • Critical + expireTimeout > 0 → finite lifetime from requestedDuration, clamped to maxPopupDuration
  • Critical + expireTimeout <= 0 → still 0 (sticky until dismiss)

Restore already calls durationFor(entry.urgency, entry.expireTimeout) and archives via popupExpired when the lifetime has elapsed; snapshots already persist expireTimeout. No restore-path change required once duration is correct.

Tests

Extended test/shell.d/notifications-test.sh:

  • Critical with positive timeout → finite duration (and clamp to max)
  • Critical with 0/missing → stays 0
  • Low/Normal floors unchanged
  • Finite-lifetime critical expires on restore once elapsed
bash test/shell.d/notifications-test.sh

Fixes #12911.

Fixes #14639

Critical urgency was hardcoded to duration 0, so battery-low and similar
toasts never expired and resurrected on every reboot. Honour a positive
expireTimeout (clamped to maxPopupDuration); keep sticky behaviour when
the timeout is 0 or absent.

Fixes omacom#12911.
@llstrk

llstrk commented Sep 22, 2026

Copy link
Copy Markdown

Verified: No production defect found in the reviewed scope at 2fc20a7. Evaluating the production duration functions confirms that explicit positive critical timeouts now produce finite lifetimes, while zero or absent timeouts remain sticky. Low/Normal duration floors are unchanged.

Critical timeout Before This PR
30,000 ms Sticky 30,000 ms
60,000 ms Sticky Capped at 30,000 ms
0 or absent Sticky Sticky

Source inspection confirms that live popup countdowns and restart restoration use this duration. With a synthetic persisted critical notification older than its requested 30 seconds, the real expiry helper returns expired using the new computed duration, rather than restoring it indefinitely.

Optional test improvement: The new value assertions in test/shell.d/notifications-test.sh exercise a mirrored function, while regexes check the production source. A synthetic in-memory return 0 inserted at the start of the actual Critical branch restored the sticky behavior, yet the unchanged head tests still passed. Exercising the actual service function and passing its result into the restore-expiry assertion would catch this demonstrated gap. This is test coverage feedback, not a defect in the submitted production code.


Review information

Test scope: Baseline and head notification tests passed. Additional isolated Node diagnostics evaluated extracted, unmodified production JavaScript and a clearly synthetic mutation. No live QML rendering, D-Bus notification delivery, hover timing or actual reboot was tested.

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

Automated AI review: Astra Medium performed initial inspection and synthesis, with independent technical reviews by Opus 5.5 High and GPT 6 Sol Xhigh. Reported claims were checked against source and targeted evidence; a fresh Astra Medium check assessed presentation and disclosures only.

@sanjyay

sanjyay commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Tested in the Omarchy VM running Omarchy 4.0.4-1 with Quickshell 0.3.1 and Node v26.8.2:

  • Ran bash test/shell.d/notifications-test.sh: all 114 tests passed, including:
    • Critical notifications with explicit positive expireTimeout now receive finite lifetimes (clamped to maxPopupDuration of 30s) and expire normally rather than remaining permanently sticky on screen.
    • Critical notifications with expireTimeout of 0, negative values, or omitted remain sticky until explicitly dismissed.
    • Low and Normal urgency minimum duration floors (5s and 8s) remain unaffected.
    • Restoration tests confirm that expired finite-lifetime critical popups are archived rather than restored indefinitely across restarts.

Works as expected with no issues found.

The duration assertions called a durationFor defined inside the test, so a regression in Service.qml passed every test: forcing the critical branch back to sticky, or making requestedDuration return 0, left the suite green. The calculation moves into NotificationLogic.js as popupDuration, like the module's other logic, and Service.qml keeps a thin durationFor passing the urgency constants and durations. The tests call the real function, and the restore-expiry assertions take their duration from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on a disposable Omarchy worker, with the shell linked to this branch merged onto current quattro (821ae58). The bug is real and the fix holds: on quattro, omarchy-notification-send -u critical -t 3000 was still on screen and in ~/.local/state/omarchy/notifications/ after 8 seconds. With this change it expires and is archived. A critical toast sent without -t (the wrapper sends -1) stays until dismissed, and a normal toast asking for 1s still gets the 8s minimum. A stale critical entry left over from the quattro run was archived when the shell restarted, rather than shown again, which is the resurrection in #12911.

I pushed one commit, bf288e9. The new duration assertions in test/shell.d/notifications-test.sh called a copy of durationFor defined inside the test, so a regression in Service.qml went unnoticed. Forcing the critical branch back to sticky still passed all 149 assertions. The calculation now lives in NotificationLogic.js as popupDuration, beside the module's other logic, and durationFor in Service.qml is a thin wrapper. The tests call the real function, including the restore-expiry checks, and both regressions above now fail them. Behaviour is unchanged from your commit.

Tests on the worker: notifications-test.sh (156 passed), notification-send-test.sh and migrate-notify-test.sh pass. ./test/cli has one failure, vscode generated theme references current theme file, which fails the same way on quattro and is unrelated to this change.

Second opinion: Codex Medium reviewed both commits. On yours it agreed the fix is correct and proportionate, which counts for less because its independence from this review is not guaranteed. It also found, on its own, a second regression the copied test missed (requestedDuration returning 0). On the follow-up commit it found nothing. No open findings; this waits on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no blocking issues remain.

Summary

Critical notifications now honor positive sender timeouts, capped at 30 seconds. Critical notifications without a positive timeout remain sticky.

  • Critical toasts now use a sender’s positive timeout, up to 30 seconds.
  • Updated notifications keep their renewed timer across a shell restart.

Reviews (6) · Last reviewed commit: "test(notifications): assert refreshed ro..." · Reviewed by Greptile

The docs, the popupExpired comment and a test label still said every critical toast stays until dismissed, which stopped being true when a sender's timeout began to be honoured. Wording from omacom#13100.

Co-Authored-By: surim0n <suritech@gmail.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the ready Good to merge label Oct 9, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit, 497c45d. It brings in the documentation fix from #13100 by @surim0n, who is credited on the commit. docs/notifications.md, the comment above popupExpired() and one test label still said that every critical toast stays until dismissed. Now they say that only a critical toast sent without a timeout does, and that one sent with a positive timeout lasts what it asked for, capped at 30s. Nothing that runs has changed.

I re-verified this head on a disposable Omarchy worker, with the shell linked to this branch merged onto current quattro (c352b62). On quattro, a toast sent with omarchy-notification-send -u critical -t 3000 was still on screen after 10 seconds. With this change it expires, and the stale one left over from the quattro run was archived when the shell restarted instead of being shown again. A critical toast sent without -t stays until dismissed. notifications-test.sh passes (156), and it fails when the critical rule in popupDuration() is put back to always returning 0. notification-send-test.sh, migrate-notify-test.sh and ./test/cli all pass.

Second opinion: Codex Medium reviewed the full diff at this head in two rounds. It found no defects and agreed that the bug is still present on quattro and that the fix is proportionate. That agreement counts for less because its independence from this review is not guaranteed. Its one suggestion, to say "positive timeout" in the docs, is in the commit. Its second round found nothing.

This waits on the maintainer. One choice remains theirs: #13100 sets a minimum of 8s for timed critical toasts, and this pull request does not, so the 3s and 5s screen-recording errors show for exactly as long as they ask.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 10, 2026
quattro added barClearance() beside popupDuration() in NotificationLogic.js and exported it; both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Oct 11, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch stopped merging cleanly once quattro added barClearance() to NotificationLogic.js, right where popupDuration() sits. I pushed e8492fc, which merges quattro (04b374a) into the branch and keeps both functions and both exports. Nothing else in the change moved, and quattro's new restore deadline goes through durationFor(), so a timed critical toast that survives a restart gets a deadline like any other timed toast.

I re-verified the merged head on a disposable Omarchy worker, with the shell linked to the branch. On quattro, a toast sent with omarchy-notification-send -u critical -t 3000 was still there after 10 seconds. With this change it expires, a critical toast sent without -t stays until dismissed, and the stale toast from the quattro run was archived when the shell restarted instead of being shown again. notifications-test.sh passes (163), and it fails when the critical rule in popupDuration() is put back to always returning 0. notification-send-test.sh, migrate-notify-test.sh and ./test/cli pass.

Second opinion: Codex Medium reviewed the merge resolution and the full diff at e8492fc. It found no defects, and agreed that the resolution loses nothing from either side and works with quattro's restore deadlines and duplicate collapsing. That agreement counts for less because its independence from this review is not guaranteed.

This waits on CI for the new head, then on the maintainer.

Comment thread shell/plugins/notifications/Service.qml Resolved
@paulogeyer

Copy link
Copy Markdown
Contributor

Compared the PRs for critical notifications ignoring the sender's expireTimeout and coming back after every restart (#12911, also the low-battery case in #14639). Tested on my laptop by evaluating each tree's durationFor() (node, no shell); stock quattro returns 0 (never expire) for every critical toast.

PR Critical with 10 s timeout Critical with no timeout stays Critical 10 min request
#12964 pass pass clamped to 30 s
#13100 pass pass clamped to 30 s (8 s floor)
#13041 pass pass not clamped (600 s)

#12964 is the one to merge: it honours the timeout, keeps untimed critical toasts sticky, clamps like the other urgencies, and moves the logic into NotificationLogic.js with a test. #13100 and #13041 are duplicates of it.

Suggestion: add Fixes #14639 to #12964 if the maintainers agree the 30 s low-battery toast should then expire.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed the eight commits since e8492fc, which answer the countdown finding above. They hold up. A replaces_id update that changes any role the card draws, the timeout or urgency included, now restarts the visible countdown. Its file also gets a fresh absolute deadline, so a shell restart judges the replacement by its new lifetime instead of the original timestamp. A sticky replacement clears that deadline, and the deadline never reaches the live model or history.

Verified on a disposable Omarchy worker, with the shell linked to f0f7a5f merged onto current quattro (a6dcc31). On quattro, omarchy-notification-send -u critical -t 3000 was still there after 10 seconds. With this change it expires, and a critical toast sent without -t stays. I sent a critical toast with -t 20000 and replaced it at 12s with -t 10000 and the same text. At e8492fc the replacement was gone 6 seconds later, and a replacement followed by a shell restart was archived at once. At this head both last the full 10 seconds. notifications-test.sh (178), notification-send-test.sh, migrate-notify-test.sh and ./test/cli pass. notifications-test.sh fails if the critical rule in popupDuration() is put back to always returning 0, or if onExpireTimeoutChanged is removed.

The low-battery warning from omarchy-battery-low is a critical toast with -t 30000. On the worker it now expires after 30 seconds, so I linked #14639. This change does not dismiss the warning when the charger is plugged in, which that issue also mentions.

Second opinion: Codex Medium reviewed the new commits at f0f7a5f and found no defects. It agreed that the problem was real and the change proportionate. That agreement counts for less because its independence from this review is not guaranteed. It noted that the renewal test passes a 10s duration on a fixture whose expireTimeout is still 4000, so it tests that the deadline takes precedence rather than going through durationFor(). It also noted that the countdown assertions check the source text, not live signal delivery, which the worker run above covers. Neither changes behaviour.

This waits on the maintainer.

@omarchybot omarchybot removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 20, 2026
@ryanrhughes

Copy link
Copy Markdown
Collaborator

Thanks @kvnloo! In the new notification engine (#15932) that's deliberate: critical means "stays until you dismiss it" (durationFor in Service.qml, and docs/notifications.md). Low and normal get 5s / 8s, stretched up to 30s by expire_timeout. Closing for that reason, but I appreciate the careful write-up.

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

Labels

bug Something isn't working

Projects

None yet

6 participants