Skip to content

Fix Windows switch capture recovery and WebView focus failures - #792

Merged
enaboapps merged 2 commits into
mainfrom
codex/windows-capture-recovery
Sep 18, 2026
Merged

enaboapps merged 2 commits into
mainfrom
codex/windows-capture-recovery

Conversation

@enaboapps

@enaboapps enaboapps commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Windows keyboard switches could stop responding with Switchify's WebView focused, and hook loss could leave stale held-key state. Run native capture in a private worker of the same executable, before WebView initialization. Detect lost suppression, cancel queued scanning actions and consume a recovery gesture before allowing a separate Select action.

The worker retains the existing native hook and gesture logic. Bounded inherited-pipe IPC preserves generations, cancellation and the parent's time origin. A kill-on-close Windows job contains the worker. Abnormal worker/IPC failure stays stopped until the app is restarted after releasing switches; it never clears uncertain ownership and automatically re-arms. No elevation, driver, signing-identity, BLE, settings-schema or Mac capture changes.

Closes #791

Validation at c1dbf2e:

  • Node 24: lint, 151 frontend tests, five script tests and production build pass.
  • Rust 1.97.1 on Mac: formatting, Clippy, 410 unit tests and seven integration tests pass with fake input.
  • Windows ARM: native build, Clippy, 407 unit tests and seven integration tests pass. The separate interactive native overlay smoke test also passes (408 Windows unit tests total).
  • Isolated native qualification covers hook removal before a press and between down/up; recovery executes no action and a separate later gesture executes once.
  • Full app in Windows ARM VM: Space/Enter and modified A activate scanning with Switchify foreground; assigned switches remain suppressed in the disposable editor with Switchify minimized. Killing the worker displays the restart-required message and does not re-arm capture. Terminating its parent also terminates the worker. VM settings were restored byte-for-byte. The user subsequently requested this PR build for testing; a VM-only diagnostic variant is currently running. The local signed Mac app remains untouched.
  • Independent full-diff review at this exact head found no remaining actionable code issues.

Remaining validation limitations: signed UIAccess self-spawn and signed-build native holds/generated-shortcut validation. All GitHub CI checks pass at this head. Raw-hook fault qualification passed in isolated probes; attempts to inject an equivalent full-app thread/window fault were inconclusive and are not counted as passing. One heartbeat timeout occurred while the VM was compiling; the app stopped capture, and idle reruns succeeded. Do not interpret idle heartbeats as proof that the hook is installed. An event that reveals a lost hook may already have reached the foreground app.

The focus-specific symptom also has independent upstream reports: tauri-apps/wry#1761 and https://github.com/wudaming00/wh-keyboard-ll-chromium. The VM tests, rather than those reports alone, established the need for isolation here.

User desktop follow-up: the reported Space leak opens a macOS file preview for a Windows desktop item. Parallels documents this Quick Look integration (https://kb.parallels.com/en/123351). VM diagnostics observed Space down/up suppression and delivery of Select to the main app. Disabling Quick Look and repeating the desktop test has not yet been performed, so this is a likely explanation rather than completed qualification. The user explicitly requested merge and pull after this finding.

- Diagnose unexpected mapped-key pass-through without treating Raw Input as gesture delivery.
- Replace failed hooks and consume a recovery gesture before rearming scanning.
- Preserve cancellation, held-key ownership and generated-event filtering with regression coverage.

🤖 Auto-generated
@enaboapps enaboapps added this to the v1.0.0-rc.12 milestone Sep 18, 2026
- Run native switch capture in the same signed executable without initializing a WebView
- Use bounded private IPC, generation checks and a shared time origin for gesture events
- Preserve cancellation and latch worker failures until restart so uncertain held keys cannot re-arm actions
- Contain the worker in a kill-on-close job and cover framing, stale events, failure races and clock translation

🤖 Auto-generated
@enaboapps enaboapps changed the title Recover Windows switch capture after hook loss Fix Windows switch capture recovery and WebView focus failures Sep 18, 2026
@enaboapps
enaboapps marked this pull request as ready for review September 18, 2026 18:24
@enaboapps
enaboapps merged commit 0d096ee into main Sep 18, 2026
6 checks passed
@enaboapps
enaboapps deleted the codex/windows-capture-recovery branch September 22, 2026 09:14
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.

Investigate and fix unreliable Windows keyboard switch capture

1 participant