Skip to content

fix: prefill passkey name from device info (#1948) - #1968

Merged
larryro merged 1 commit into
mainfrom
tale/xs76qk7r81s5pxwqv016tcxan9896dy8
Jun 24, 2026
Merged

larryro merged 1 commit into
mainfrom
tale/xs76qk7r81s5pxwqv016tcxan9896dy8

Conversation

@larryro

@larryro larryro commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #1948 — the "Passkey name" field now pre-fills with a best-effort, editable device label (e.g. "Chrome on macOS", "Safari on iPhone") derived from the browser User-Agent, instead of starting empty.

Changes

  • Add lib/utils/device-label.ts — pure deriveDeviceLabel(userAgent) helper mapping a User-Agent to a coarse Browser on OS label, with sensible fallbacks (browser-only, OS-only, or empty for unrecognized agents).
  • Wire it into PasskeyRegisterDialog: on open, prefill the name field with the derived label without clobbering anything the user typed. The field stays editable and falls back to the existing placeholder when the label is empty.
  • Add unit tests covering Chrome/Edge/Firefox/Safari across macOS/Windows/Linux/iPhone/Android plus fallback cases.

Acceptance criteria

  • Opening the register dialog shows a sensible, editable default name.

Verification

  • vitest --project server lib/utils/device-label.test.ts — 10 passed
  • tsc --noEmit — clean
  • oxlint --type-aware on changed files — 0 warnings/errors

Summary by CodeRabbit

  • New Features
    • Passkey registration now automatically suggests a device label based on your current browser and device when creating a new passkey, helping to identify passphrases. You can still customize this name if needed.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: da9b4f38-41d9-4e4a-9386-ba0dcb51fd7f

📥 Commits

Reviewing files that changed from the base of the PR and between b418075 and 440ad36.

📒 Files selected for processing (3)
  • services/platform/app/features/settings/account/components/passkey-register-dialog.tsx
  • services/platform/lib/utils/device-label.test.ts
  • services/platform/lib/utils/device-label.ts

📝 Walkthrough

Walkthrough

A new device-label.ts utility module is added with internal detectBrowser and detectOS functions that parse a User-Agent string using token-based regex matching. The exported deriveDeviceLabel function returns a formatted "Browser on OS" string, whichever part is individually detected, or an empty string. A Vitest suite covers the full range of expected inputs and outputs. The passkey register dialog imports useEffect and deriveDeviceLabel, adding an effect that fires when the dialog opens: if navigator is available and the name field is empty, it pre-fills the name with the derived device label.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: prefill passkey name from device info' accurately reflects the main change—adding device label prefilling to the passkey registration dialog.
Description check ✅ Passed The description provides a clear summary, lists key changes, confirms acceptance criteria are met, and includes verification results. All checklist items are marked N/A with brief reasons or confirmed complete.
Linked Issues check ✅ Passed The PR fully implements the requirement from #1948: deriving a device label from User-Agent and prefilling the passkey name field while keeping it editable, with sensible fallbacks.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the device label derivation and integrating it into the passkey dialog. No unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tale/xs76qk7r81s5pxwqv016tcxan9896dy8

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@larryro

larryro commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — #1948 / PR #1968 "Prefill Passkey name from device info"

Verdict: READY TO MERGE.

Reviewed the full implementation on branch tale/xs76qk7r81s5pxwqv016tcxan9896dy8, not just the diff lines.

CI

All required checks green (gh pr checks): Analyze (js-ts, python), Lint, Format, Knip, Opengrep, Build (platform + all services), Smoke test, Migrations, and the full Playwright matrix (web + platform 1–16). CodeRabbit review completed. No failing or pending required checks.

Tests

Ran the project's own suite for the new code:
bunx vitest --run --project server lib/utils/device-label.test.ts → 10 passed.

Findings (all verified, none blocking)

  • Correctness — device-label.ts: deriveDeviceLabel handles ''/undefined/null → ''; browser+OS → "Browser on OS"; single-recognized → that one; nothing recognized → ''. Ordering in detectBrowser/detectOS is correct for the masquerade hazards: Edge/Opera/Firefox/CriOS matched before Chrome; iPhone/iPad/Android matched before macOS/Linux (iPad reports "Macintosh", Android contains "Linux"), CrOS before Linux. Safari requires both Safari/ and Version/ so Chrome UAs don't false-match.
  • Correctness — dialog useEffect: Prefills only when open flips true; functional updater current || deriveDeviceLabel(...) never clobbers user-typed input and avoids stale-closure issues, so [open] deps are correct; SSR-guarded with typeof navigator === 'undefined'. On close/submit reset() clears the field, so reopening re-derives cleanly.
  • Boundaries/security: UA string is only rendered as text in a controlled <Input> — no injection surface.
  • Elegance: New util follows lib/utils/ conventions (focused single-purpose file + colocated .test.ts, JSDoc). No duplication of an existing helper or UA-parsing library.
  • Tests: Cover Chrome/Edge/Firefox/Safari across macOS/Windows/Linux/iPhone/Android + CriOS + fallbacks. Opera, iPad, and ChromeOS branches are implemented but not directly asserted — a minor, non-blocking coverage gap. No passkey component test harness exists in the repo, so unit-testing the pure helper is the appropriate level.
  • Resolution: Meets the acceptance criterion — the register dialog opens with a sensible, editable default name and falls back to the existing "MacBook Touch ID" placeholder when the UA is unrecognized.

READY TO MERGE.

@larryro
larryro merged commit 4faf0ff into main Jun 24, 2026
66 of 68 checks passed
@larryro
larryro deleted the tale/xs76qk7r81s5pxwqv016tcxan9896dy8 branch June 24, 2026 08:55
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.

Improvement: Prefill "Passkey name" from device info

1 participant