Skip to content

Refocus lock screen when session secures - #9523

Open
mlmrx wants to merge 3 commits into
omacom:quattrofrom
mlmrx:ml/fix-9418-lock-focus
Open

mlmrx wants to merge 3 commits into
omacom:quattrofrom
mlmrx:ml/fix-9418-lock-focus

Conversation

@mlmrx

@mlmrx mlmrx commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • refocus the password field when WlSessionLock.secure becomes true and keyboard input reaches the lock surface
  • retain the existing early focus request while closing the secure-state race
  • add focused regression coverage for the lock service's secure handler

Fixes #9418

Testing

  • bash test/shell.d/lock-focus-test.sh
  • bash test/shell.d/lock-blank-fingerprint-test.sh
  • bash test/shell.d/lock-stranded-recovery-test.sh
  • bash test/shell.d/monitor-recovery-test.sh
  • git diff --cached --check

@isho

isho commented Sep 2, 2026

Copy link
Copy Markdown

I tried this on my own system and it didn't work. I also tried this solution: https://github.com/omacom/omarchy/pull/9181/changes and it did work. So I recommend closing this PR and accepting the other one (as long as it meets your requirements)

lockView is declared inside the per-screen WlSessionLockSurface delegate, so naming it from WlSessionLock's own onSecureStateChanged threw "ReferenceError: lockView is not defined" every time the lock became secure. The throw also aborted the handler before root.startFingerprint(), the call that starts fingerprint unlock when the fingerprint check finishes before the lock is secure. Each surface now refocuses its own field through a Connections on sessionLock, and the test checks the call sits there and not in the session lock's handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5.5 in Claude Code. The second opinion (Codex at medium effort) did not run: the reviewer answered its health check, but its daily review budget was spent, so nothing here has been checked by a second model.

The original change threw instead of refocusing. lockView is declared inside the per-screen WlSessionLockSurface delegate, so WlSessionLock's own onSecureStateChanged cannot see it. On a disposable VM running a real Hyprland session with this branch linked, locking logged Service.qml[241:-1]: ReferenceError: lockView is not defined at the moment of secure=true. The throw also aborted the handler before root.startFingerprint(). When the fingerprint check finishes before the lock is secure, that call is the only thing that starts fingerprint unlock, so on those machines fingerprint unlock would not have been offered. This likely explains @isho's report above that it did not work.

Fixed in 7a2dc84, pushed to this branch. Each lock surface now refocuses its own password field through a Connections on sessionLock, and startFingerprint() runs as before. The test now checks that the call sits in the surface delegate, not in the session lock's handler; it fails on 5a026f6 and passes now.

What ran, on the VM:

  • Locking the fixed build logged no error, and a temporary log line in the new handler fired at the same millisecond as secure=true.
  • A password typed by a virtual keyboard after locking reached the field.
  • lock-focus-test.sh, lock-blank-fingerprint-test.sh, lock-fingerprint-indicator-test.sh, lock-password-overflow-test.sh, lock-stranded-recovery-test.sh and monitor-recovery-test.sh all passed, as did ./test/cli.

What is not proven is the bug itself. On the VM, keyboard input reached the field after the lock became secure even without a working refocus, so the race in #9418 did not reproduce there. It was reported on an NVIDIA desktop, so it needs confirming on hardware that shows it. @work-aalp, could you test this branch at the full commit 7a2dc844ac20cdabf55df869e1cfc215bcc11c06? To install it:

git clone -b ml/fix-9418-lock-focus https://github.com/mlmrx/omarchy.git ~/omarchy-9523
git -C ~/omarchy-9523 checkout 7a2dc844ac20cdabf55df869e1cfc215bcc11c06
omarchy dev link ~/omarchy-9523

After the reboot, lock the screen and type straight away, both after a plain lock and after a resume. Please reply with your hardware and what you saw before and after. omarchy dev unlink puts the packaged version back.

Related: #8560 is a separate open fix for focus lost across suspend. It reclaims focus in LockView.qml whenever the field loses it while the lock is up. It does not overlap this change, which only refocuses at the moment the lock becomes secure.

This now waits on a hardware confirmation from the reporter, then on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds focus management to the lock screen UI.

The PR appears safe to merge; no outstanding finding or new actionable defect was identified.

Summary

The PR refocuses each lock surface’s password field when the session becomes secure and adds a regression test that limits its handler check to the surface delegate.

Reviews (2) · Last reviewed commit: "Bound the lock focus test to the lock su..."

Comment thread test/shell.d/lock-focus-test.sh Resolved
The surface check sliced from WlSessionLockSurface to the end of Service.qml, so a Connections block moved out of the delegate, where lockView is out of scope, would still have passed. The slice now ends at the delegate's closing brace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed again by Claude Opus 5.5 in Claude Code, with Codex at medium effort as the second opinion, after Greptile's note on the test.

Greptile's point holds, and is fixed in f618457, pushed to this branch. lock-focus-test.sh sliced from WlSessionLockSurface { to the end of Service.qml, so a Connections block moved out of the delegate, where lockView is out of scope, would still have passed. The slice now stops at the delegate's closing brace. The change to Service.qml is unchanged.

What ran, on a disposable VM with a real Hyprland session, with this branch merged into current quattro linked as the running shell:

  • lock-focus-test.sh passes on the merge, fails on quattro alone, and fails with the Connections block moved out of the delegate.
  • lock-blank-fingerprint-test.sh, lock-fingerprint-indicator-test.sh, lock-password-overflow-test.sh, lock-stranded-recovery-test.sh, monitor-recovery-test.sh, sleep-lock-test.sh, system-lock-test.sh and hyprland-session-locked-test.sh pass. ./test/cli passes except vscode generated theme references current theme file, which fails the same way on quattro without this change.
  • Locking logged secure=true and no error from the new handler, and a password typed by a virtual keyboard after the lock went secure reached the field.

Second opinion: Codex found no defect in the change and agreed the brace-matched slice now fails if the handler is missing or moved; its agreement follows a review already written down, so its independence is not guaranteed. It added one thing worth knowing: the per-screen lock views are created when sessionLock.locked is set, after the 500 ms stabilising timer, not when lockRequested flips, so the gap this closes is between the view being created and the compositor confirming the lock, not the full 500 ms #9418 describes. Its remaining notes on the test were about hypothetical future edits, and nothing was changed for them.

Still not proven is the bug itself. On the VM, input typed after the lock went secure reached the field with or without a refocus, so the race did not reproduce there. #9418 was closed as a duplicate of #6858, which stays open. @work-aalp, the request above still stands, now at the full commit f618457f67307ce6fba302f44fafea71a4f8cd6f; only the test changed since 7a2dc844a:

git clone -b ml/fix-9418-lock-focus https://github.com/mlmrx/omarchy.git ~/omarchy-9523
git -C ~/omarchy-9523 checkout f618457f67307ce6fba302f44fafea71a4f8cd6f
omarchy dev link ~/omarchy-9523

After the reboot, lock the screen and type straight away, after a plain lock and after a resume, and reply with what you saw. omarchy dev unlink puts the packaged version back.

Related: #8560 (focus lost across suspend) and #13907 (focus lost after a failed password) both change LockView.qml and fix other ways the field loses focus; they complement this one rather than compete with it. #13962 rewrites parts of the same lock surface delegate in Service.qml, so whichever lands second may need a small rebase.

This waits on a hardware confirmation from the reporter, then 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lock screen password field loses keyboard focus race — forcePasswordFocus() fires before WlSessionLock.secure becomes true

3 participants