Skip to content

Cap idle timeouts to the largest Qt Timer interval - #13921

Open
Coding-Sparrow wants to merge 3 commits into
omacom:quattrofrom
Coding-Sparrow:fix/idle-timeout-overflow
Open

Coding-Sparrow wants to merge 3 commits into
omacom:quattrofrom
Coding-Sparrow:fix/idle-timeout-overflow

Conversation

@Coding-Sparrow

Copy link
Copy Markdown

Fixes #13920

Summary

Idle timeouts larger than a Qt Timer interval can hold overflowed. Qt then clamped the interval to 1 ms, and the shell logged a warning on every tick until the log filled /run/user/$UID. This PR caps the configured seconds at the largest value that still fits in an interval.

+// Qt Timer intervals are signed 32-bit milliseconds. Anything larger wraps
+// negative, Qt clamps it to 1 ms, and the shell logs a warning every tick.
+var MAX_TIMER_SECONDS = Math.floor(2147483647 / 1000)
+
 function secondsFromConfig(value, fallback) {
   var n = Number(value)
   if (!isFinite(n) || n < 0) return fallback
-  return Math.floor(n)
+  return Math.min(Math.floor(n), MAX_TIMER_SECONDS)
 }

screensaver and lock are both read through secondsFromConfig, so their delays, and the lockDelaySeconds * 1000 interval computed from them, now stay within the int32 limit.

Evidence

test/shell.d/idle-test.sh:

  • Before:
    expected: 2147483
    actual:   999999999
    not ok - idle caps seconds to the largest Timer interval
    
    After:
    ok - idle caps seconds to the largest Timer interval
    ok - idle keeps the largest Timer interval
    ok - idle seconds never overflow a Timer interval
    

I also ran the rest of ./test/shell on this machine. The same 11 files fail with and without this change. They depend on the local environment (migrations, snapper, browser and similar), and none of them touch idle.

Merge Danger

Door: two-way

Blast Radius: tiny

This only changes behavior for values above 2147483 s (about 24.8 days). Those values were already broken. With the fix, the screen locks after about 24.8 days of idle instead of flooding the log.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Caps idle timeout values to prevent timer overflow.

The PR appears safe to merge; no actionable new issue was identified.

Summary

The PR caps configured screensaver and lock timeouts at the largest whole-second value that fits a signed 32-bit millisecond timer interval.

  • Documents the cap and adds boundary tests.
  • The merge retains the cap alongside the base branch’s idle-timer changes.

Reviews (3) · Last reviewed commit: "Merge quattro into fix/idle-timeout-over..." · Reviewed by Greptile

@jandrusk

jandrusk commented Oct 1, 2026

Copy link
Copy Markdown

Clean fix for #13920 — capping at floor(INT32_MAX/1000) is exactly what Qt's signed 32-bit Timer needs, and the unit asserts cover the overflow edge.

Nit (non-blocking): a capped lock still eventually fires (~24.8 days). If the intended UX for "never" is stay-awake / omit the key, a one-line manual note would save the next person who picks a huge number.

@Coding-Sparrow

Copy link
Copy Markdown
Author

Thanks @jandrusk! Added a note to the Idle section of the manual in 9d18dd5: huge values are capped at ~24.8 days and still lock eventually, so use stay awake (Super + Ctrl + I / omarchy toggle idle) for "never". I pointed to stay awake instead of omitting the key, because a missing key falls back to the 300s default.

@omarchybot omarchybot added the bug Something isn't working label Oct 1, 2026
quattro's idle-timeout-zero fix (omacom#12538) added its own assertions beside the ones this branch adds to test/shell.d/idle-test.sh; both sets are kept. The cap in secondsFromConfig still covers both Timer intervals, which quattro now sets imperatively from the same delay properties.

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 ready Good to merge labels Oct 7, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on a disposable VM built from the Omarchy ISO, running the shell from this branch.

Reproduction. I set "idle": {"screensaver": 5, "lock": 999999999} and left the machine idle. On current quattro the shell logged QBasicTimer::start: negative intervals aren't allowed about 33,000 times in 35 seconds and never locked. On this branch the cycle started with lock=2147483, the screensaver ran, and no warnings were logged. With IdleModel.js reverted to quattro's copy, the flood came back. The cap covers every interval derived from these values: screensaverTimer, lockTimer and IdleMonitor.timeout all come from the capped seconds.

Pushed. The branch conflicted with quattro in test/shell.d/idle-test.sh because #12538 (0 disables an action) added assertions next to yours. I merged quattro into the branch in 9fe61ca and kept both sets of assertions. Nothing else changed. The cap and #12538's handling of 0 don't interact: 0 stays 0.

Tests. ./test/cli passed on the VM. The full test/shell.d suite passed on this head, apart from failures that also happen on quattro in the same environment.

Second opinion. Codex Medium read the change and found nothing wrong. Its only note was that the third new assertion would also pass on a zero result; the two exact-value assertions before it are what pin the cap. It had access to this review's reasoning, so its agreement is not independent.

A side note: since #12538, "lock": 0 also turns the idle lock off without stopping the screensaver. The manual doesn't document that yet, so pointing people to stay awake in the new note is still correct.

This now waits on the maintainer.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idle timeouts above ~24.8 days overflow the Qt timer and flood the shell log until /run/user fills up

3 participants