Skip to content

Don't treat a screensaver closed by losing every output as a dismissal - #15244

Open
juan-LARRAYA wants to merge 2 commits into
omacom:quattrofrom
juan-LARRAYA:fix/issue-12327
Open

juan-LARRAYA wants to merge 2 commits into
omacom:quattrofrom
juan-LARRAYA:fix/issue-12327

Conversation

@juan-LARRAYA

@juan-LARRAYA juan-LARRAYA commented Oct 13, 2026 •

Copy link
Copy Markdown

Cause

When the only output disappears during an idle blank (a sink that drops its link when disabled), the screensaver window goes with it. handleScreensaverWindowClosed() reads that as the user dismissing the screensaver and calls cancelIdleCycle("screensaver-dismissed"), which runs omarchy-system-wake and undoes the blank. Hyprland's resumed signal that follows then goes through handleActiveSignal() and would cancel again as "activity". This is the idle-cycle-cancel: screensaver-dismissed / process-start: wake pair quoted in the issue.

Change

  • IdleModel.hasRealScreen(): a screen counts only if it has a name, is not Hyprland's FALLBACK placeholder, and has a size (same idea as the lock service's realScreenCount() and Ignore Hyprland FALLBACK in external-monitor checks #10586).
  • The idle service treats the outputs as lost when there is no real screen, or for 3 s after a monitorremoved event for a non-FALLBACK monitor (so a screen list that has not updated yet does not defeat it).
  • While lost, a screensaver window closing and a resumed signal are ignored: no cancel, no wake. The pending lock timer is untouched.

Scope (partial)

Refs #12327, does not close it. Covered: the idle-side half (output loss closing the screensaver, and the resumed that follows). Not covered:

Testing

  • test/shell.d/idle-output-loss-test.sh (new) loads the real Service.qml in a throwaway quickshell, injects the screen list, feeds it Hyprland events, and stubs omarchy-system-wake in PATH to record runs. Cases: close with no outputs, FALLBACK-only list, monitorremoved before a stale list, resumed after the loss (cycle kept, no wake); and, still waking, FALLBACK-only removal, a real dismissal, and real activity. It fails against quattro's Service.qml (6 checks) and passes with this change.
  • test/shell.d/idle-test.sh: adds hasRealScreen cases; shell-idle-spawn-test.sh and update-stay-awake-security-test.sh pass.
  • Earlier full ./test/shell run finished with 2 not ok ("the initial background is visible" and "releasing the shared cover reveals the cloned background"), both in test/shell.d/background-instant-reload-test.sh, unrelated to idle. Re-running that file against origin/quattro without my change, the first one fails the same way; the second did not show up in that re-run, so I did not confirm it on the base. I did not re-run the full suite after this second commit.
  • Not tested live: a display whose link drops when its output is disabled.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium impact] Fixes screensaver dismissal logic when monitor outputs disconnect.

Fix the dropped dismissal on remaining monitors and the test’s login-shell stub bypass before merging.

Findings

  1. P1 Dismissal still leads to locking ▶
  2. P1 Test runs the real wake ▶
  3. P2 Wake log order can change ▶

Summary

The PR expands idle output-loss detection and adds tests that call the real QML service.

  • The idle service keeps output loss from waking a blanked display.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Monitor removed during idle] --> B[Start three-second hold]
  C[Screensaver closes or activity arrives] --> D{Hold running or no real screen?}
  B --> D
  D -->|Yes| E[Keep idle cycle and pending lock]
  D -->|No| F[Cancel cycle and wake displays]
Loading

Reviews (2) · Last reviewed commit: "Hold the idle cycle through output loss,..." · Reviewed by Greptile

Comment thread test/shell.d/idle-test.sh Resolved
… it with behavior tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment on lines +187 to +189
} else if (name === "monitorremoved") {
var removed = String(eventParts(event, 1)[0] || "")
if (root.idledThisCycle && removed !== "FALLBACK") root.holdForOutputLoss("monitorremoved " + removed)

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.

P1 Dismissal still leads to locking

Removing one monitor starts outputLossTimer even when another monitor remains connected. For the next three seconds, outputsLost() ignores genuine screensaver dismissal and activity on that remaining monitor. The pending lock stays armed and can lock the session after the user has returned. Limit the hold to losing all usable outputs, and stop suppressing real dismissal once an output is available.

Knowledge Base Used: Shell UI and desktop interactions

Comment on lines +56 to +57
PATH="$TMPDIR/stubs:$ROOT/bin:$PATH" \
quickshell -p "$config_dir" --no-color >"$log" 2>&1 &

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.

P1 Test runs the real wake

The test puts the wake stub first in PATH, but Service.qml runs it through bash -lc. On an installed Omarchy session, the login shell resets PATH, so it can run the real omarchy-system-wake instead. The test then changes the desktop and fails because the expected wake entries are missing. Add the existing bash stub pattern that replaces -lc with -c.


function mark(name) {
var quoted = "'" + name.replace(/'/g, "'\\''") + "'"
Quickshell.execDetached(["bash", "-c", "echo \"S " + name + "\" >> \"$1\"", "_", wakeLog])

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 Wake log order can change

mark() appends each scenario label through a detached process, then the scenario immediately starts wake through another process. Either process can write first, but the test requires one exact order. The 700 ms pause between scenarios does not order these two writes. Wait for the marker to finish before triggering wake, or record and check each scenario separately.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I reviewed this at 87e55ad against quattro and ran it on an Omarchy worker VM. Codex Medium reviewed the same as a second opinion. It agreed with the two findings below, though its independence is not guaranteed. It also added the point about the hold timer outliving the cycle. This needs changes before it can go further.

What ran, on the worker

  • idle-output-loss-test.sh passes three times out of three at the head. Moved onto quattro's Service.qml, it fails on exactly the six checks you list, so it does test the behaviour change.
  • idle-test.sh (29 checks) and shell-idle-spawn-test.sh pass. update-stay-awake-security-test.sh also passes.
  • I wrote a separate probe that loads the real Service.qml from each tree and starts a real idle cycle with the lock timer armed. Every command the service starts is stubbed.

1. Removing one monitor while another stays up can lock someone who is using the machine

monitorremoved starts the 3 s hold for any monitor that is not FALLBACK (Service.qml:189). While the timer runs, outputsLost() returns true even if a working panel is still connected (Service.qml:170). Take a docked laptop with the screensaver up. Unplug the external display, then press a key within three seconds:

  • On quattro: idle-cycle-cancel: screensaver-dismissed, then the wake runs and the lock timer stops.
  • On this head: output-loss: screensaver-closed-with-output, then idle-monitor-active: ignored while outputs are lost. The lock timer keeps running, and lock-system: lock-timeout fired 7 s later in the probe. With stock timeouts, that is a lock up to 150 s later in the middle of typing.

Nothing re-checks the cycle when outputLossTimer expires (Service.qml:323-327), so the cycle stays armed after the hold ends. With the lock disabled, the next idle period then logs idle-cycle-already-running and the screensaver does not start. Neither cancelIdleCycle() nor lockSystem() stops the timer either, so a hold can carry into the next cycle. The PR description lists the multi-monitor case as a known gap, but the cost of that gap is a lock that fires on someone at the keyboard.

2. This does not reach the sequence in #12327

The only blank in an idle cycle is the lock screen's own (shell/plugins/lock/Service.qml:714). lockSystem() clears idledThisCycle, screensaverStartedThisCycle and the tracked screensaver windows before it runs omarchy-system-lock (shell/plugins/services/idle/Service.qml:76-84). omarchy-system-lock then kills the screensaver. So while the display is blank, and when the sink drops HPD about 12 s later, both handlers this PR guards already return early on quattro (Service.qml:149 and :175). Neither can reach cancelIdleCycle(). The guarded path only runs when an output disappears while the screensaver is up and the session is unlocked, and nothing is blanked at that point.

Before #12327 can be addressed here, we need to know what actually logs screensaver-dismissed on the reporter's machine. One candidate is an idle cycle that starts after the shell relaunches with status 255, before the recovered lock is held again. Showing that from a journal with the surrounding lines would settle it. The test fixture sets the cycle flags by hand and never models that path.

Smaller points in the test

  • The service runs its wake through bash -lc. Login profiles on a configured machine can prepend directories to PATH ahead of the stub. shell-idle-spawn-test.sh:155 and theme-set-budget-test.sh:102 stub bash to turn -lc into -c for this reason.
  • The scenario marker and the wake each append from their own detached process. Nothing orders the two writes, so the exact-match check on the wake log can fail by chance. It passed every time here.

What happens next

This is waiting on you, @juan-LARRAYA. Point 1 needs a different way to tell output loss from a dismissal. One option is to hold only while no real screen remains, and to re-check the cycle when the hold ends. Point 2 needs the path in #12327 identified. I have not pushed anything, because both points are design decisions rather than contained defects.

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

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants