Skip to content

Reuse the sleep-lock failure notification - #10686

Open
llirik0 wants to merge 8 commits into
omacom:quattrofrom
llirik0:fix/issue-10651-sleep-lock-notification
Open

llirik0 wants to merge 8 commits into
omacom:quattrofrom
llirik0:fix/issue-10651-sleep-lock-notification

Conversation

@llirik0

@llirik0 llirik0 commented Sep 7, 2026

Copy link
Copy Markdown

Fixes #10651

Every failed pre-suspend lock attempt sent a fresh critical notification. Those cards do not expire and are restored after shell restarts, so a repeating lock fault could leave dozens of permanent warnings.

The lock helper now saves the notification ID returned by omarchy-notification-send and reuses it on later failures. It saves any reassigned ID, serializes concurrent reporters with a bounded lock, and replaces the state file atomically. If state or locking is unavailable, it still sends a normal best-effort warning.

Tests:

  • bash test/shell.d/sleep-lock-test.sh — 22 assertions
  • Bash syntax and git diff --check
  • Mutation checks cover the original no-replacement call, missing serialization, and failure to persist a reassigned ID
  • ./test/all: CLI passed; shell passed 234/235 files. The remaining config-test.sh package-manifest failure also occurs on unmodified quattro.

#10146 groups identical cards visually but keeps each underlying notification and persistence file. This call-site fix prevents those duplicate records from being created.

@llirik0
llirik0 marked this pull request as ready for review September 7, 2026 20:55
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed, reproduced and tested on a disposable Omarchy worker running the real Quickshell notification server. The second opinion was Codex Medium.

The bug is real, and this fixes it. On the fork point of quattro, three sleep-lock failures in a row left three critical cards. With this branch they left one, updated in place.

One defect, fixed in 763ea6d on your branch. The saved id was reused after the notification server changed, and that can overwrite an unrelated notification. Each Quickshell server numbers ids from 1, and its Notify replaces whatever live notification holds replaces_id without checking who sent it. On the worker I saved id 6, restarted the shell, and let an unrelated critical "Battery critically low" card take id 6. The next sleep-lock failure replaced that battery warning with the lock warning. The id file now records the boot id and the notification server's pid next to the id, and -r gets the id only when it is the same server, so after a shell restart, logout or reboot the warning takes a fresh id. Rerunning the same scenario with the fix left the battery card alone. Codex also found that a corrupt saved id longer than a uint32 made every later send fail silently. Such an id now falls back to a fresh notification, and the new server lookup has a timeout like the script's other busctl call. New tests cover a changed server and a corrupt id.

Tests on the worker at 763ea6d: test/shell.d/sleep-lock-test.sh 24/24, and ./test/cli passed. The new tests fail against the base script. In a second round, Codex found nothing further in the final commit. It reviewed with this report's reasoning available to it, so its agreement is not guaranteed to be independent.

For the maintainer, not blocking:

  • Within one server's lifetime, a repeated failure keeps one card. A card restored after a shell restart is never a replacement target, by design, so failures on either side of a restart still leave two cards. Capping critical popups on the shell side (feat(notifications): cap critical popups at max duration instead of forever #13161) or grouping (fix(notifications): group identical notifications the way mako did #10146) would cover that, and both are complementary to this call-site fix.
  • The flock guards against two simultaneous reporters, but omarchy-system-sleep-monitor is the only caller and runs them one at a time. It can add up to 0.75s after the lock budget has run out, and Codex rated it the least necessary part of the change. It is bounded, so I left it as you wrote it.

This is waiting on CI, which has not run on this pull request yet, and then on the maintainer.

@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 2, 2026
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

The PR reuses the critical warning shown when the screen fails to lock before suspend.

  • Repeated sleep-lock failures update the same warning card.
  • The notification shell replaces duplicate restored alerts without losing history.

No new actionable issues were found. The ancestry checks did not pass, so this review used the full PR diff.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Screen fails to lock] --> B[Queue warning worker]
  B --> C[Wait for state lock]
  C --> D[Check notification server]
  D --> E[Send warning using saved ID]
  E -->|Success| F[Save returned ID]
  E -->|Failure| G[Retry without saved ID]
  C -->|Lock unavailable| G
  F --> H[Shell keeps one matching warning]
  G --> H
Loading

Reviews (8) · Last reviewed commit: "Preserve localized sleep-lock warnings a..." · Reviewed by Greptile

Comment thread bin/omarchy-system-sleep-lock Resolved
Comment thread bin/omarchy-system-sleep-lock Resolved
Comment thread bin/omarchy-system-sleep-lock Resolved
@llirik0
llirik0 force-pushed the fix/issue-10651-sleep-lock-notification branch from 763ea6d to ed0a01e Compare October 3, 2026 08:44
Comment thread bin/omarchy-system-sleep-lock Resolved
@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 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed after the rebase onto quattro and ed0a01e, and tested on a disposable Omarchy worker running this branch's own Quickshell. The second opinion was Codex Medium, over two rounds.

The restart case is fixed. On quattro, sleep-lock failures on either side of a shell restart leave two critical cards. At a05f023, before the shell change, they still leave two. With this branch they leave one, because the fresh warning now supersedes the copy restored from disk. Separately, on quattro three failures whose reasons differ leave three cards, since #13522 only collapses identical text. With this branch they leave one. So both halves of the change are doing work.

Two defects in ed0a01e, fixed in 2352461 on your branch:

  • The startup restore reads popupStateDir asynchronously, so it can read back a file this shell has just written for a notification that arrived during the read. The new content match then treated that file as an old shell's copy. If another fresh row had the same text, it deleted the live row's file, after a replaces_id update had made the two rows differ. If the row had already been dismissed, it deleted the image copies its history entry still points at. Codex found this ordering. Files this shell writes before the restore settles are now skipped by the restore, which also stops a popup dismissed during the read from coming back.
  • With the timeout change, every flock failure stopped the warning, not only a timeout behind another reporter. So a state directory that cannot be locked at all got no warning for an unlocked suspend. Only a timeout (flock -E 75) suppresses it now, and any other failure sends the plain warning as before. A new test covers it and fails without the fix.

Tests on the worker at 2352461: sleep-lock-test.sh 28/28 and notifications-test.sh 152/152. ./test/cli fails one test, "vscode generated theme references current theme file". It fails the same way on quattro and has nothing to do with this change. In the second round, Codex found nothing further in 2352461. It reviewed with this report's reasoning available to it, so its agreement is not guaranteed to be independent.

Not changed, for the maintainer: the content match ignores urgency. A restored critical card can be replaced by an identical low-urgency notification that then expires. That is the policy #13522 already applies to live cards, now extended across restarts. The shell part also touches the same files as #10146 and #13161.

The PR description still says that a lock that cannot be taken falls back to a plain warning. That holds again, except for a timeout. The description also doesn't mention the notification service changes. This is waiting on quattro's unrelated CLI failure and CI, then on the maintainer.

Comment thread bin/omarchy-system-sleep-lock Resolved
Comment thread bin/omarchy-system-sleep-lock Resolved
@omarchybot omarchybot removed verified Omarchy Triage has verified that this issue is ready for final review bug Something isn't working labels Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

68f62c4 changes how the warning is delivered, so this was classified again before re-reviewing it, and the two models classifying it did not agree. Claude Opus 5.5 read it as a bug fix: #10651's pile-up of permanent critical cards is still what it fixes. Codex Medium, asked separately, read it as an enhancement: the new push moves the warning into a transient user service sent after the inhibitor is released, adds a --bus-name option to omarchy-notification-send, and widens which fields count as a duplicate popup to include icon, glyph, urgency and expiry, which changes existing behaviour on purpose.

Because the classification is unsettled, the bug label is off and the earlier verification no longer applies: verified came off when the head moved past 2352461, and 68f62c4 has not been run on a worker or reviewed for defects yet. Nothing was pushed to your branch this time.

This is waiting on the maintainer to say which it is. Once that is settled it will be re-reviewed and tested at the then-current head.

Comment thread bin/omarchy-system-sleep-lock Resolved
@llirik0
llirik0 force-pushed the fix/issue-10651-sleep-lock-notification branch from 854e520 to 3021954 Compare October 3, 2026 11:36
@omarchybot

Copy link
Copy Markdown
Collaborator

e4eb27a and 3021954 moved the head since the last classification, so this was classified again before any re-review. It is still unsettled. Claude Opus 5.5 reads it as a bug fix: #10651's pile-up of permanent critical cards is still what it fixes. The second opinion, Codex Medium, could not be asked this time. It answers on the machine, but omabot's daily limit on reviews was already used up, so no independent classification was made. The previous round, at 68f62c4, Codex Medium read it as an enhancement because of the transient user service, the new --bus-name option and the wider duplicate-popup match. The two new commits keep all three.

No class label is on, nothing has been run on a worker at 3021954, and nothing was pushed to your branch. This is waiting on the classification being settled, either by the maintainer or by a run where the second opinion can be asked. After that, it will be re-reviewed and tested at the then-current head.

llirik0 and others added 7 commits October 19, 2026 07:15
Each notification server numbers its ids from 1, and Quickshell's Notify replaces whatever live notification holds replaces_id without checking who sent it. An id saved before a shell restart or a reboot could therefore overwrite an unrelated card that happened to get the same number in the new server, such as a critical battery warning. Save the id with the boot and the server's pid, and offer it only to that same server.

A saved id too long for Notify's uint32 made the send fail, and the file kept it, so every later warning failed too; such an id now falls back to a fresh notification. The server lookup is bounded like the script's other busctl call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
The restore reads popupStateDir asynchronously, so it can read back a file this shell wrote for a notification that arrived meanwhile. Matching that file by content against another fresh row deleted the live row's file, and once its row had been dismissed and archived, the delete took the image copies its history entry still uses. Files this shell wrote before the restore settles are now skipped, which also stops a popup dismissed during the read from reappearing.

A lock attempt that errors, rather than timing out behind another reporter, sends the unlocked-suspend warning again, so a state directory that cannot be locked still gets one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@llirik0
llirik0 force-pushed the fix/issue-10651-sleep-lock-notification branch from 3021954 to 941291c Compare October 19, 2026 14:29
@llirik0

llirik0 commented Oct 19, 2026

Copy link
Copy Markdown
Author

Rebased onto current quattro (81fd2d2) and resolved the conflicts, preserving upstream localization, RTL, and notification placement changes. Added coverage for localized sleep-lock warnings. Focused Linux-container checks passed: sleep-lock, notification-send, notifications, and CLI. The broad suite was not green in the limited container (128/459 shell files failed; not individually baseline-attributed). No live suspend or Quickshell visual validation was performed.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the rebase. The head moved to 941291c, so this was classified again before any re-review, and the two models still do not agree. Claude Opus 5.5 reads it as a bug fix, since #10651's pile-up of permanent critical cards is what it fixes. Codex Medium, asked separately, reads it as an enhancement, as it did at 68f62c4. The transient user service, the new --bus-name option on omarchy-notification-send and the wider duplicate-popup match are all still here. No class label is on, nothing was run on a worker at this head, and nothing was pushed to your branch.

It no longer merges into quattro. 4671ae2 landed on quattro after the commit you rebased onto (81fd2d2). It replaces the notification engine with Omapager's stacks, deletes shell/plugins/notifications/NotificationLogic.js and rewrites Service.qml. So the shell half of this pull request changes code that is gone: the restored-duplicate supersession, ownPopupFiles and appIconSource. Merging current quattro into this branch conflicts in NotificationLogic.js (deleted upstream), Service.qml and test/shell.d/notifications-test.sh. The changes to bin/omarchy-system-sleep-lock and bin/omarchy-notification-send merge cleanly. The new engine stores live cards in live.json and keeps critical ones until they are dismissed after a restart, so whether the restart case still needs a shell change has to be worked out against that code, not the old one.

This is waiting on two things. The maintainer needs to settle whether this is a bug fix or an enhancement. The shell half needs porting to the new engine, or dropping if the sleep-lock half is enough there. After that it will be re-reviewed and tested on a worker at the then-current head.

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.

omarchy-system-sleep-lock posts a new critical notification per failure, so a repeating fault leaves unbounded reboot-persistent toasts

2 participants