Skip to content

Rearm idle monitor after timeout changes - #9570

Merged
omarchybot merged 6 commits into
omacom:quattrofrom
rookepoole:fix/rearm-idle-monitor
Nov 16, 2026
Merged

omarchybot merged 6 commits into
omacom:quattrofrom
rookepoole:fix/rearm-idle-monitor

Conversation

@rookepoole

@rookepoole rookepoole commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Re-arm Quickshell's IdleMonitor when a live shell.json edit changes the effective first idle timeout.

Changing idle.screensaver or idle.lock updates the QML timeout immediately, but affected Quickshell sessions can leave the underlying Wayland idle notification silent. The shell then reports the new values while screensaver, lock, and display-idle events never fire until a restart.

The idle service now pulses the monitor off for 150 ms and declaratively re-enables it with the new timeout. This spans the event-loop delay validated in the issue reproduction, remains gated by Stay Awake, coalesces rapid edits by restarting the one-shot timer, and exposes the re-arm state in idle diagnostics.

Closes #9496

Test plan

  • bash test/shell.d/idle-test.sh
  • /usr/lib/qt6/bin/qmllint -I /usr/lib/qt6/qml -I shell shell/plugins/services/idle/Service.qml (only existing QProcess::ExitStatus import warnings)
  • ./test/shell (changed test passes; suite retains five unrelated baseline failures: three require an omarchy-pkgs checkout, plus the existing launch-about and network-QR assertions)

Fixes #8038

@paulogeyer

Copy link
Copy Markdown
Contributor

Tested on my laptop (ASUS Vivobook, Intel Arc, omarchy 4.0.4, Quickshell 0.3.1). On stock, changing idle.screensaver in shell.json without restarting the shell stops idle from firing at all. With this PR applied, the new timeout takes effect right away (30s, then hot-changed to 60s, both fired on time). 👍

This also fixes #8038 and #12855. It might be worth switching Closes #9496 to Fixes #8038 / Fixes #12855 so they close on merge.

Quickshell does replace the notification when the timeout changes: updateNotification() deletes it and creates a new one. The failure is that the replacement can land at the deleted one's address, so Qt sees bNotification unchanged and isIdle never subscribes to the replacement. Disabling first sends the pointer through null, which is why the pulse works.

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

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining runtime-test gap is non-blocking.

Findings

  1. P2 Re-arm lacks runtime coverage ▶

Summary

Updates the idle service to re-arm IdleMonitor after the effective first timeout changes.

  • The idle monitor rebinds when its first timeout changes.

No new actionable issues were established.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[First timeout changes] --> B{Monitor reports idle?}
  B -->|Yes| C[Keep current notification and deadlines]
  C --> D[Monitor reports activity]
  D --> E[Try retiming again]
  B -->|No| E
  E --> F{Timeout differs?}
  F -->|No| G[Leave monitor unchanged]
  F -->|Yes| H[Set new timeout]
  H --> I{Idle enabled?}
  I -->|Yes| J[Pause monitor for 150 ms]
  J --> K[Enable if existing gates allow]
  I -->|No| L[Keep monitor disabled]
Loading

Reviews (4) · Last reviewed commit: "Merge quattro into fix/rearm-idle-monito..." · Reviewed by Greptile

Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread test/shell.d/idle-test.sh Outdated
Comment on lines +39 to +54
assert(
/onFirstIdleTimeoutSecondsChanged:[\s\S]*?idleMonitorRearmTimer\.restart\(\)/.test(serviceSource),
'idle re-arms its monitor when the configured first timeout changes'
)

const idleMonitor = serviceSource.slice(serviceSource.indexOf(' IdleMonitor {'))
.split('\n }', 1)[0]
assert(
/enabled: root\.idleEnabled && !idleMonitorRearmTimer\.running/.test(idleMonitor),
'idle monitor stays disabled for the re-arm timer turn'
)

const rearmTimer = serviceSource.slice(serviceSource.indexOf(' id: idleMonitorRearmTimer'))
.split('\n }', 1)[0]
assert(/interval: 150/.test(rearmTimer), 'idle re-arm spans a tested event-loop delay')
assert(/repeat: false/.test(rearmTimer), 'idle re-arm only pulses the monitor once per timeout change')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Re-arm lacks runtime coverage

These assertions match QML source text but never change a timeout in a running IdleMonitor. They can pass even if idle notifications fail to resume, so the reported regression has no behavioral test coverage.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot omarchybot added the ready Good to merge label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at ef82132 and run on a stock Omarchy worker VM built from the ISO, with each tree linked as the running shell, idle.screensaver changed from 15 to 20 in shell.json five seconds after start, and no input afterwards.

The bug reproduces and this fixes it. On quattro no idle event came in the next 40s. On this branch the monitor re-armed and idle fired 20s after the edit, launching the screensaver. With Service.qml put back to the base version, it went silent again. Changing the timeout while stay-awake was on and then allowing idle also fired at the new timeout. ./test/cli and test/shell.d/idle-test.sh pass on the worker.

I pushed one commit, ef82132, which corrects the code comment. Quickshell does replace the notification when the timeout changes: updateNotification() deletes it and creates a new one. The replacement can land at the same address, so Qt sees bNotification unchanged and isIdle never subscribes to the new notification. Disabling the monitor first sends the pointer through null, which is why your pulse works. The code is unchanged. The same root cause is tracked upstream as quickshell-mirror/quickshell#938.

Linked issue. #9496 was closed as a duplicate of #8038, so I linked #8038 to this pull request so that it closes when this merges. #12855 includes this trigger, but it also reports idle stopping with no timeout edit (after a restart and after resume). I have not seen this change fix that, so it is not linked.

Compared with the other open fixes for the same bug, this is the smallest and the most targeted. #8086 cancels a running idle cycle whenever either timeout changes, even when the monitor's own timeout stays the same. #12731 builds no monitor when the shortest timeout is 0, which quattro accepts as a valid setting.

One note on the tests: the new assertions in idle-test.sh check the shape of the QML source, so they would still pass if the handler were disabled. The behavioural evidence here is the worker run above.

The second opinion came from Codex at medium effort, over two rounds. It found no runtime defect and agreed with the address-reuse explanation; independence is not guaranteed, since it can read this session's reasoning. It also tightened the wording of the corrected comment and pointed out the source-shape tests, both covered above.

This now waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 4, 2026
quattro now keeps the idle monitor off while both timeouts are 0 and clamps its timeout to at least a second; the monitor stays off for the re-arm pulse on top of that.

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

Copy link
Copy Markdown
Collaborator

This had stopped merging cleanly, because quattro has since changed the same IdleMonitor block: a timeout of 0 now means off, the monitor stays off while both timeouts are 0, and its timeout is clamped to at least a second. I merged quattro into the branch as 3bd9d87. That is a merge, not a rebase, so your commits are unchanged. The monitor is now enabled: root.idleEnabled && root.idleTimersEnabled && !idleMonitorRearmTimer.running with quattro's clamped timeout, and the assertion in idle-test.sh was updated to match. No other line of your change moved.

Re-verified at 3bd9d87 on a stock Omarchy worker VM built from the ISO, with each tree running as the shell, idle.screensaver changed from 15 to 20 in shell.json five seconds after start, and no input afterwards. On current quattro no idle event came in the next 40s. On this branch the monitor re-armed and idle fired 20s after the edit. With Service.qml put back to quattro's version it went silent again. The stay-awake case (change the timeout while stay-awake is on, then allow idle) also fires at the new timeout. ./test/cli and test/shell.d/idle-test.sh (29 assertions) pass on the worker.

One behaviour for the maintainer to weigh. Greptile's comment on line 260 is right in one narrow case, and I reproduced it on the worker. When the screensaver is toggled off (omarchy-toggle-screensaver), a running idle cycle has no screensaver window to keep it armed. A timeout change in that state makes the 150 ms pulse report the monitor active. handleActiveSignal() then cancels the pending lock and runs omarchy-system-wake, and the next cycle locks later. In the run, with screensaver 10 and lock 40, the lock due at 13:05:57 fired at 13:06:19. On quattro the same sequence keeps the lock on its deadline. The obvious alternative, ignoring the pulse's active signal, has its own cost. The re-enabled monitor starts out not idle, so a person who comes back after the change would produce no activity signal and could be locked at the old deadline while typing. Which trade-off is right is a product decision, so I have not changed it. Outside that case Greptile's scenario cannot happen: when a cycle starts, the first action fires at once.

The source-shape assertions in idle-test.sh would still pass with the handler disabled, as noted before. The behavioural evidence is the worker run above.

Competing fixes. #8086 is older, but it cancels a running idle cycle whenever either timeout changes, even when the monitor's own timeout stays the same. That undoes quattro's 3839d0b, which keeps a pending lock on its deadline when the timings change. #12731 rebuilds the whole monitor; it addresses the same cause, but nothing it handles is missed here. Both now conflict with quattro. This one is the fix to take.

The second opinion came from Codex at medium effort. It found the screensaver-off case above, which I then reproduced on the worker. It agreed the merge resolution keeps quattro's zero-timeout behaviour, and it chose this pull request over #8086 and #12731 for the same reasons given here. Independence is not guaranteed, since it can read this session's reasoning.

This is verified and now waits on the maintainer's call on the screensaver-off trade-off.

omarchybot and others added 2 commits November 1, 2026 01:57
quattro dropped the idle test's source-text assertions (omacom#16334), and its AGENTS.md now rules out tests that grep the source, so the resolution takes quattro's idle-test.sh and drops this branch's regex checks of the re-arm timer with them. Service.qml merged cleanly.
Since quattro's idle service closes the screensaver and cancels the cycle on any active signal past the launch grace, the re-arm pulse fired mid-cycle read as the user returning: a shell.json timeout change while the screensaver was up closed it, ran omarchy-system-wake and pushed the lock back by the time already spent idle. Ignoring the pulse's active signal instead would leave a user who then comes back unseen, since the fresh notification starts out active and can only report a return after it first idles.

So the monitor's timeout is no longer bound. It is set, and pulsed, only while the monitor reports active: straight away when the user is at the machine, as when they edit shell.json, and otherwise on the return that ends the cycle. Until then the running cycle keeps its notification, so it still sees the return and keeps its deadlines.

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

Copy link
Copy Markdown
Collaborator

This had stopped merging cleanly again: quattro reworked the idle service on Oct 27. It now closes the screensaver whenever the user is back, it no longer tracks screensaver windows, and #16334 removed the tests that read QML source. I merged quattro into the branch as c6cb1c3, with no rebase, so your commits are unchanged. idle-test.sh now matches quattro's version, which drops the regex checks this branch added, because quattro's AGENTS.md now rules out tests that grep the source. Your Service.qml change merged without conflicts.

The merge made the mid-cycle trade-off from my last comment worse, so I pushed a fix, 23409f3. With quattro's new code, any active signal after the launch grace counts as the user coming back. The 150 ms pulse produces exactly that signal, so changing the first timeout in shell.json while the screensaver was up now closed the screensaver, ran omarchy-system-wake and restarted the cycle. That pushed the lock back by however long the machine had already been idle. I reproduced this on the worker. On quattro the same sequence leaves the screensaver up and locks on time. Ignoring the pulse's active signal would not work either: the fresh notification starts out active, so it could not report a user coming back until it had gone idle first.

So the monitor's timeout is no longer a binding. retimeIdleMonitor() sets it and pulses only while the monitor reports active. That is immediate when someone is at the machine, which is the case when they edit shell.json. Otherwise it happens on the return that ends the idle cycle. Until then the running cycle keeps its notification, so it still sees the user come back and keeps its deadlines. Your pulse, timer, enabled gate and diagnostics field are unchanged.

Verified at 23409f3 on a stock Omarchy worker VM built from the ISO (Quickshell 0.3.2), with each tree linked as the running shell and no input unless stated:

  • Screensaver 15, lock 600, with the screensaver changed to 20 five seconds after start: on quattro, which is this pull request with its change reverted, no idle event came in the next 45s. At the head, idle fired 20s after the edit.
  • Screensaver 10, lock 60, with the screensaver changed to 12 while the screensaver was up: the screensaver stayed up and the lock fired on its original deadline, matching quattro.
  • The same change, followed by a key press five seconds later: the return was detected, the cycle was cancelled and the screensaver closed. The new timeout was applied then, and the next idle came 12s later.
  • ./test/cli, test/shell.d/idle-test.sh and test/shell.d/shell-idle-spawn-test.sh pass on the worker.

One thing for you: the description no longer matches the change. It describes the pulse without the wait while idle, and its test plan lists test assertions that quattro has since removed. Could you update it, and mention quickshell-mirror/quickshell#938, the open upstream issue for the cause? #8038 is already linked, so it closes when this merges.

Competing fixes are unchanged from last time. #8086 is older, but it cancels a running idle cycle on any timeout change, which undoes quattro's fixed per-cycle deadlines. #12731 rebuilds the whole monitor and fixes no case this one misses. Both still conflict with quattro. This is the one to take forward.

The second opinion came from Codex at medium effort and muse-wonder via pi at high thinking, over two rounds. In the first round both confirmed that the merge kept quattro's behaviour and confirmed the mid-cycle defect. Codex proposed retiming the monitor only once the user is back, and the push implements that idea. muse-wonder had found no contained fix, because it assumed the monitor would still be retimed while idle. In the second round, on 23409f3, neither found a defect. They checked startup ordering, stay-awake and zero timeouts, the launch grace, a change carried across a lock, and rapid edits. Both also chose this pull request over #8086 and #12731. Independence is not guaranteed, since both can read this session's reasoning.

This is verified. Once the description is updated, it waits on the maintainer.

@omarchybot
omarchybot merged commit c5f98c6 into omacom:quattro Nov 16, 2026
3 checks passed
omarchybot added a commit that referenced this pull request Nov 16, 2026
quattro's idle service gained retimeIdleMonitor() (#9570) at the spot where lockCommandPending was declared. Both stay; the property moves down beside the rest of the service's state.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ButtercupRobrts pushed a commit to ButtercupRobrts/omarchy that referenced this pull request Nov 28, 2026
* Rearm idle monitor after timeout changes

* Correct why the idle monitor needs re-arming

Quickshell does replace the notification when the timeout changes: updateNotification() deletes it and creates a new one. The failure is that the replacement can land at the deleted one's address, so Qt sees bNotification unchanged and isIdle never subscribes to the replacement. Disabling first sends the pointer through null, which is why the pulse works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>

* Retime the idle monitor only once the user is back

Since quattro's idle service closes the screensaver and cancels the cycle on any active signal past the launch grace, the re-arm pulse fired mid-cycle read as the user returning: a shell.json timeout change while the screensaver was up closed it, ran omarchy-system-wake and pushed the lock back by the time already spent idle. Ignoring the pulse's active signal instead would leave a user who then comes back unseen, since the fresh notification starts out active and can only report a return after it first idles.

So the monitor's timeout is no longer bound. It is set, and pulsed, only while the monitor reports active: straight away when the user is at the machine, as when they edit shell.json, and otherwise on the return that ends the cycle. Until then the running cycle keeps its notification, so it still sees the return and keeps its deadlines.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Codex Medium <noreply@openai.com>
Co-authored-by: David Heinemeier Hansson <david@hey.com>
(cherry picked from commit c5f98c6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

4 participants