feat(chat) auto-fill server login modal with password manager + auto…#544
feat(chat) auto-fill server login modal with password manager + auto…#544sandexzx wants to merge 5 commits into
Conversation
…-cleanup of bad saved passwords
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
/deploy |
|
Deployed to Vercel Preview: https://prismarine-nhxfw4gr9-zaro.vercel.app |
…iOS Keychain autofill readOnly + controlled value caused iOS Safari Keychain to skip the username field, saving passwords without an associated identifier. Use defaultValue with explicit reset in useEffect when the modal opens so iOS treats it as a normal autofill target on iOS while keeping the identifier stable on every reopen. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/deploy |
|
Deployed to Vercel Preview: https://prismarine-85t1t2wgn-zaro.vercel.app |
Auto-fill server login modal with password manager (partially addresses #527)
This PR implements the auto-fill server login feature requested in #527: a safe, password-manager-friendly way to handle AuthMe-style
/loginand/registerprompts (e.g. onplay.mcraft.fun).It covers the core auto-fill / password-manager part of the issue. Other items mentioned in the issue thread are not in scope for this PR.
What it does
When a server sends a chat message containing
/loginor/register, the client:(server, nick)pair.<form>and properautocompleteattributes (username,current-password,new-password), so browser/OS password managers recognize it./login <password>or/register <password> <password>and starts a 5-second login monitor.navigator.credentials.store()is invoked so Chromium-based browsers prompt to save immediately rather than waiting for navigation.The same monitor is also wired into the existing spawn-time auto-login (
index.ts:825) and the manual/logintyped directly into chat, so a wrong saved password is always cleaned up regardless of how it was originally provided.Race-condition handling
If a password is already saved but the server still sends a
/loginprompt (this happens when the spawn-time auto-login races with a slow handshake and the first/logindoes not reach the server in time — easily reproducible with DevTools throttle x4), the client silently retries/login <saved>once, gated by:login(neverregister— no silent account creation),If the password is wrong, the cleanup path takes over.
Mobile
A small popup hint appears under the chat input on touch devices when the user starts typing
/loginor/register, opening the same modal. Positioning is anchored to the bottom of the input (the mobile chat input lives near the top of the screen, so an upward-anchored popup would clip).Files
New:
src/loginPromptDetector.ts(+.test.ts) — pure detection + per-server debouncer.src/react/AutoFillLoginModal.tsx— modal with real<form>and password-manager-friendly markup.src/loginAttemptMonitor.ts— singleton monitor, failure regex, kicked listener, Credential Management API integration.Modified:
src/react/ChatProvider.tsx— detection + 🔐 injection + silent retry.src/react/MessageFormatted.tsx—clickEventhandlers foropen_auto_fill_login/open_auto_fill_register.src/react/Chat.tsx— mobile popup hint.src/react/serversStorage.ts—saveServerPassword(with asilentoption) +clearServerPassword.src/botUtils.ts—displayClientChatnow acceptsstring | objectto allowextra+clickEvent.src/index.ts— spawn-time auto-login wrapped in the monitor for cleanup-on-failure.src/reactUi.tsx— mounts<AutoFillLoginModal />.Compatibility
autocompleteattributes.Verification
pnpm tsc --noEmit— clean for changed files.pnpm lint— 0 new errors.pnpm test-unit— 16/16 new tests for the detector pass.pnpm build— green.play.mcraft.fun(incognito + existing accounts, desktop Chrome and Pixel 9 Chrome): register flow, login flow, suppression on a successful auto-login, cleanup of a corrupted saved password, race-condition retry under DevTools throttle x4, mobile popup hint, Credential Management API "Save password?" prompt on Android — all confirmed working.