Skip to content

fix(ui-react): start passkey autofill only beside a password field (#2555) - #4183

Merged
schlessera merged 3 commits into
mainfrom
fix/2555-passkey-conditional-gate
Nov 17, 2026
Merged

schlessera merged 3 commits into
mainfrom
fix/2555-passkey-conditional-gate

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #2555.

What this does

Conditional UI offers passkeys in the password field's autofill. It needs an input whose autocomplete ends in webauthn, and the login form renders that input only beside a password. A passkey-only login screen (/auth/methods → { password: false, passkey: true }) still started the ceremony on every load. Each load:

  • spent a token of the host's login-options budget (10 per IP per minute), so a few reloads locked the "Sign in with a passkey" button out with a 429;
  • left an unused challenge in the capped pending store;
  • logged [passkeys] conditional UI failed, because @simplewebauthn/browser found no webauthn input.

LoginScreen (packages/ui-react/src/components/connectivity/login-screen.tsx) now returns before the autofill probe, and so before api.passkeyLoginOptions(), when the methods report no password. The explicit passkey button (onPasskeyClick) is unchanged, and so is everything #2556 builds on.

Acceptance criteria

Criterion Proof
Passkey-only: no POST /api/auth/passkey/login-options on load, no [passkeys] warning passkey-login-runtime.test.ts "a passkey-only screen asks for no login options…" (real Chrome, real ui-server routes)
Password and passkey: exactly one login-options request on load, and the field's autofill offers the passkey "beside a password field, conditional UI starts once and its autofill signs in with the passkey". The browser receives one mediation: "conditional" request, usernameless (allowCredentials empty) for RP localhost. The registered passkey answers it, and the app signs in with no button pressed, after exactly one login-options request
The button still signs in on a passkey-only deployment The first runtime test clicks "Sign in with a passkey". The CDP virtual authenticator answers, and the app shows its signed-in content
A stub-API test counts passkeyLoginOptions calls: 1 before, 0 after on passkey-only render-smoke.test.tsx "conditional UI asks for login options never on a passkey-only screen" (and "once beside the password field")
Real-Chrome runtime test with WebAuthn.addVirtualAuthenticator, plus the gate mutation Below

How the runtime test works

packages/ui-react/tests/passkey-login-runtime.test.ts follows auth-expiry-runtime.test.ts. It builds the packages through runtimePackageBuild, now inventoried in scripts/runtime-test-builds.ts. It runs a real ui-server host on loopback and bundles a small client (tests/fixtures/passkey-login-client.ts: the public ConnectionGate). The origin is http://localhost:<port>, because an IP address is not a valid WebAuthn RP ID. An init script reports each PublicKeyCredential.isConditionalMediationAvailable probe and each navigator.credentials.get mediation to the test through an exposed binding, which survives the reload a sign-in does.

  1. With no credential yet, the page signs in with the password and registers a passkey on a CDP virtual authenticator (ctap2, resident key, user verification), using the app's own registerPasskey. The host has no BRAIN_UI_ALLOW_PASSWORD, so /auth/methods reads passkey-only.
  2. The cookies are cleared and the page reloaded. The negative observation uses causal barriers, not a sleep:
    • the screen makes the conditional-mediation probe in the same tick that draws the passkey button;
    • after the passkey button shows and the network is idle, the test asserts no probe, no login-options request, no mediation and no [passkeys] warning.
  3. The passkey button signs in (one login-options request). The credential, with its current signature counter, is read from the authenticator.
  4. The host restarts on the same database with BRAIN_UI_ALLOW_PASSWORD=1, and a new context's authenticator gets that credential. The field appears and the screen probes (positive control for the barrier). The conditional request is usernameless for localhost, the stored passkey answers it, and the app signs in. After network idle there is exactly one login-options request and one conditional mediation.

Proof

  • Failing first: the render test failed on the unfixed tree with Expected length: 0, Received length: 1 for the passkey-only screen. The password-and-passkey case passed before and after.
  • Mutation receipts (each restored):
    • Remove the gate: the passkey-only runtime test fails on "conditional UI never probed" (Expected: 0, Received: 2).
    • Remove the gate, with the probe barrier relaxed: fails on PASSKEY_ONLY_NO_LOGIN_OPTIONS, - [] / + ["POST"]. This is the request-count assertion the issue names.
    • Block conditional UI everywhere (if (methods) return;): the password-and-passkey runtime test fails. The autofill never signs in.
  • Runtime test: 2/2, in three consecutive runs on this host (pinned Chromium 1243).
  • Render tests: render-smoke.test.tsx -t passkey: 9 pass. tests/runtime-build-selection.test.ts passes with the new inventory entry.
  • Typecheck, lint and check:pr pass.

Collisions

bun scripts/collisions.ts --json --pr 4183 at head f6e90cf: closure reports only (shared ui-react test categories and workspaces) with #3054, #3056, #3059, #3069, #3581, #3622, #4002, #4151, #4157, #4168, #4172, #4173, #4175, #4177, #4179 and #4181. No PR edits login-screen.tsx or the new test files.

{"version":1,"kind":"brain-check-pr-receipt","head":"a5d8ac2945803f9e2c45b818c6cc6c2699f2ba15","base":"origin/main","mode":"focused","startedAt":"2026-11-17T13:25:43.769Z","finishedAt":"2026-11-17T13:27:16.339Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13281.967612},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":129.99538600000233},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":89.40745999999854},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.19043000000238},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":79030.384087}]}

🤖 Generated with Claude Code

…2555)

Conditional UI attaches to the password input's `webauthn` autocomplete
token, and a passkey-only login screen renders no password input. The
screen still started the ceremony on every load: it spent a token of the
host's login-options budget (10 per IP per minute), left an unused
challenge, and logged a [passkeys] warning when @simplewebauthn found no
input. The ceremony now starts only when the methods report a password.
The explicit passkey button is unchanged.

A render test counts login-options requests on both screens. A real
Chrome runtime test with a CDP virtual authenticator proves the
passkey-only screen asks for none and its button signs in, and that
conditional mediation still starts once beside the password field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@uploads-sh

uploads-sh Bot commented Nov 17, 2026

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-react/src/components/connectivity/login-screen.tsx and packages/ui-react/tests/render/render-smoke.test.tsx). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4183
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4183 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4183 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4183 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 4183. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head f6e90cf against base 94f5580. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4183,
  "head": "f6e90cfc641d20656ffbc2926d7b7666ba6520a0",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/tests/passkey-login-runtime.test.ts:72 calls runtimePackageBuild(repo, [\"ui-react\",\"ui-server\",\"core\"], hook), but \"passkey-login\" is missing from runtimeTestBuilds in scripts/runtime-test-builds.ts:5-7. tests/runtime-build-selection.test.ts:12-13 asserts exactly 24 runtimePackageBuild( callers equal to Object.keys(runtimeBuildInventory); there are now 25, so that repo test fails and the build-selection wrapper never pre-builds for this file."
    },
    {
      "summary": "PR #4183 has an empty description and no receipt comments, so criterion 5 (record a mutation: remove the `if (!methods.password) return;` gate at packages/ui-react/src/components/connectivity/login-screen.tsx:93, watch the passkey-only case fail on the request-count assertion, restore) and criterion 4's failing-first result (count 1 before the change, 0 after) are unmet."
    },
    {
      "summary": "packages/ui-react/tests/passkey-login-runtime.test.ts:157-172 is titled 'offers the passkey in the field's autofill' (criterion 2), but it opens a new context whose fresh CDP virtual authenticator (line 109) holds no credential; the passkey registered in the first test lived on the closed first context's authenticator. It only asserts that mediation 'conditional' was requested, never that a passkey was offered, so that half of criterion 2 is unproven."
    }
  ]
}

…runtime test (#2555)

The passkey registered in the first runtime case now moves to the second
case's virtual authenticator, taken after the button sign-in so its
signature counter is current. The field's conditional request then signs
the app in through autofill with no button pressed, instead of only
showing that a conditional request was made. Probes and mediations are
recorded through an exposed binding, because that sign-in reloads the
page. The new runtime file is listed in the runtime build inventory, and
the inventory test's count is raised to 25.

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

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head f6e90cf against base 94f5580. Reviewer: agent. 3 findings: 2 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4183,
  "head": "f6e90cfc641d20656ffbc2926d7b7666ba6520a0",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/tests/passkey-login-runtime.test.ts:72 calls runtimePackageBuild(repo, [\"ui-react\",\"ui-server\",\"core\"], hook), but \"passkey-login\" is missing from runtimeTestBuilds in scripts/runtime-test-builds.ts:5-7. tests/runtime-build-selection.test.ts:12-13 asserts exactly 24 runtimePackageBuild( callers equal to Object.keys(runtimeBuildInventory); there are now 25, so that repo test fails and the build-selection wrapper never pre-builds for this file.",
      "disposition": "fixed",
      "commit": "3623d7e30c56fa99023e9f8482bf6643171bec52"
    },
    {
      "summary": "PR #4183 has an empty description and no receipt comments, so criterion 5 (record a mutation: remove the `if (!methods.password) return;` gate at packages/ui-react/src/components/connectivity/login-screen.tsx:93, watch the passkey-only case fail on the request-count assertion, restore) and criterion 4's failing-first result (count 1 before the change, 0 after) are unmet.",
      "disposition": "rejected",
      "reason": "The PR body was empty because a body-writing script truncated its source file; the code was not missing proof. The body now records the failing-first result (Expected length 0, Received 1) and the gate mutation failing on PASSKEY_ONLY_NO_LOGIN_OPTIONS (- [] / + [\"POST\"])."
    },
    {
      "summary": "packages/ui-react/tests/passkey-login-runtime.test.ts:157-172 is titled 'offers the passkey in the field's autofill' (criterion 2), but it opens a new context whose fresh CDP virtual authenticator (line 109) holds no credential; the passkey registered in the first test lived on the closed first context's authenticator. It only asserts that mediation 'conditional' was requested, never that a passkey was offered, so that half of criterion 2 is unproven.",
      "disposition": "fixed",
      "commit": "3623d7e30c56fa99023e9f8482bf6643171bec52"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 3623d7e against base 94f5580. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4183,
  "head": "3623d7e30c56fa99023e9f8482bf6643171bec52",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

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.

ui-react: a passkey-only login screen starts conditional UI with no autofill field and burns the options rate limit

1 participant