Skip to content

Foreground the Windows Hello consent dialog (v0.2.8)#203

Merged
jgowdy-godaddy merged 1 commit into
mainfrom
fix-windows-hello-foreground
Jun 4, 2026
Merged

Foreground the Windows Hello consent dialog (v0.2.8)#203
jgowdy-godaddy merged 1 commit into
mainfrom
fix-windows-hello-foreground

Conversation

@jgowdy-godaddy

Copy link
Copy Markdown
Contributor

Problem

gocode-dev's secret agent is a windowless, detached background process. UserConsentVerifier::RequestVerificationAsync (no HWND) therefore shows the Windows Hello / "Windows Security" dialog behind the user's active window — they have to find and click it before authenticating, and it feels like a stall.

Fix

Use the HWND-aware interop API IUserConsentVerifierInterop::RequestVerificationForWindowAsync with a transient, top-most, invisible owner window we create and bring to the foreground (AttachThreadInput to defeat the foreground lock). The dialog inherits foreground activation by construction — no polling for the dialog window, no guessing its class.

Because the dialog is then modal to a window on our thread, that thread must pump messages while awaiting the result (a blocking .get() deadlocks — confirmed empirically). We pump via MsgWaitForMultipleObjectsEx until the async op completes.

Safety: any failure in the windowing/interop path falls back to the original windowless RequestVerificationAsync, so foregrounding can never block a credential decrypt.

Scope

  • crates/hardware-enclave/src/internal/windows/foreground_window.rs (new) — RAII owner window + message pump.
  • …/hello_gate.rsprompt_user_consent split into foreground / windowless-fallback / result-interpretation.
  • Adds Win32_System_WinRT feature (home of IUserConsentVerifierInterop); AttachThreadInput already covered by Win32_System_Threading.
  • Workspace bumped to 0.2.3.
  • The legacy parallel enclaveapp-windows copy is intentionally left untouched (not consumed by gocode-dev); can be synced separately.

Testing

Validated end-to-end on Windows 11 via gocode-dev (patched to this branch): the Hello dialog now appears foregrounded/focused, no hang, and the foreground path adds ~23ms (the residual prompt latency is CredentialUIBroker + the biometric sensor, unchanged). cargo fmt, clippy --all-targets -- -D warnings, and hello_gate tests pass locally.

🤖 Generated with Claude Code

The consent prompt is requested by gocode-dev's windowless, detached secret
agent, so `UserConsentVerifier::RequestVerificationAsync` (no HWND) shows the
"Windows Security" / Hello dialog *behind* the user's active window — they have
to hunt for it before they can authenticate.

Use the HWND-aware interop variant instead: create a transient, top-most,
invisible owner window, bring it to the foreground (AttachThreadInput to defeat
the foreground lock), and pass its HWND to
`IUserConsentVerifierInterop::RequestVerificationForWindowAsync` so the dialog
inherits foreground activation by construction. Because the dialog is then modal
to a window on our thread, that thread must pump messages while awaiting the
result — a blocking `.get()` deadlocks — so we pump via MsgWaitForMultipleObjectsEx
until the async op completes.

Any failure in the windowing / interop path falls back to the original
windowless `RequestVerificationAsync`, so foregrounding can never block a
credential decrypt. Scoped to the `hardware-enclave` Windows backend
(`internal/windows`); the legacy parallel `enclaveapp-windows` copy is left
untouched and can be synced separately. Adds the `Win32_System_WinRT` feature
(home of `IUserConsentVerifierInterop`); `AttachThreadInput` is already covered
by `Win32_System_Threading`.

Bumps the workspace to 0.2.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jgowdy-godaddy jgowdy-godaddy force-pushed the fix-windows-hello-foreground branch from 6c78dcc to a3aaaf5 Compare June 4, 2026 03:19
@jgowdy-godaddy jgowdy-godaddy changed the title Foreground the Windows Hello consent dialog (v0.2.3) Foreground the Windows Hello consent dialog (v0.2.8) Jun 4, 2026
@jgowdy-godaddy jgowdy-godaddy merged commit a150056 into main Jun 4, 2026
3 checks passed
@jgowdy-godaddy jgowdy-godaddy deleted the fix-windows-hello-foreground branch June 4, 2026 03:23
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.

1 participant