Skip to content

feat(client): one code field for a 6- to 12-digit sign-in code (wiki-v2 #815) - #88

Merged
PMQ9 merged 2 commits into
wiki-v2from
feat/815-otp-code-field
Nov 11, 2026
Merged

PMQ9 merged 2 commits into
wiki-v2from
feat/815-otp-code-field

Conversation

@PMQ9

@PMQ9 PMQ9 commented Nov 10, 2026 •

Copy link
Copy Markdown

What

The wiki sign-in page's code entry is now ONE text field instead of a 6-cell PinInput. This is PR C of https://github.com/cccvu/wiki-v2/issues/815 (wiki-v2 issue 815): the emailed code moves from 6 to 8 digits one release AFTER this ships. It is paired with a super-repo PR (console + e2e + gitlink), https://github.com/cccvu/wiki-v2/pull/820.

Why. The PinInput was hard-coded to 6 (length={6}, otp.length < 6). It could not take a pasted 1234 5678, and 8 cells overflow a 360 px phone.

The field (pages/public/passwordless-login.tsx)

  • inputMode="numeric", autoComplete="one-time-code", the visible label "One-time code". Plain text, never type="number", which drops a leading zero and refuses the space.
  • It takes 6 to 12 digits once spaces and hyphens are stripped, so 6 and 8 both work across the rollout and a rollback. Submit is offered from the sixth digit; a malformed value is explained on submit and never sent.
  • A paste or an autofill of a whole code submits it once. Typing never does: typing adds one character per input event, so the field only auto-submits on a bulk input type (insertFromPaste, insertReplacementText, …) or a jump of more than one character. The same code is not auto-submitted twice.
  • Its error is the field's own (role="alert", aria-invalid), so it is announced: the bad-code message moved there from a toast. WCAG 2.2 SC 3.3.8: paste and autofill both work.
  • A 60 s countdown on "Resend email" after a send, the hint "Can't find it? Check your Junk or Clutter folder." after a send, and an honest 429: "Too many requests. Wait a few minutes, then try again.", or the wait from Retry-After when the response has one. On verify, a 429 keeps the code (it may still be good). On request (use-passwordless.ts), a 429 no longer reads as "we couldn't send".

One rule per tree. features/public/otp-code.ts holds normalize/validate/bulk-entry/429 text; hooks/use-resend-cooldown.ts is the deadline-based countdown. The console keeps its own copy (services/admin-ui/src/otp-code.ts), since the fork cannot import super-repo code.

Upstream boundary. Every file is fork-owned (features/public/**, pages/public/**, both excluded prefixes). No upstream seam, no UPSTREAM_MODIFICATIONS.md entry. scripts/check-upstream-boundary.sh passes.

Tests

  • passwordless-login.test.tsx: 26 pass (11 kept + 15 new), including a paste of 1234 5678, a 6-digit paste, an autofill with no input type, auto-submit once, typing never auto-submits, the hyphen strip, the malformed-code alert, the bad-code alert, the 429 with and without Retry-After, the Junk hint, and the countdown (fake timers).
    • Mutation-checked: dropping the length-jump rule, the input-type rule, the once guard or the countdown start each turns a test red.
  • otp-code.test.ts (new) and three 429 cases in use-passwordless.test.tsx.
  • pnpm --filter client test: 990 run, 988 pass. The 2 failures also fail on wiki-v2 without this change: use-user-role.test.tsx (native mode, on Node 26 locally), and the date-locale scan, a 6.5 s timeout under full-suite load that passes when run alone.
  • tsc --noEmit clean, eslint clean on the touched files, and the BUNDLE_BUDGET_STRICT=1 production build passes.

🤖 Generated with Claude Code

PMQ9 and others added 2 commits November 10, 2026 17:45
docmost#815)

The emailed code moves from 6 to 8 digits one release after this ships. The 6-cell
PinInput was hard-coded to 6, could not take a pasted "1234 5678", and 8 cells
overflow a 360 px phone. It is now ONE text field:

- inputMode numeric, autocomplete one-time-code, a visible label;
- 6 to 12 digits once spaces and hyphens are stripped; submit from the sixth digit;
- a paste or autofill of a whole code submits once; typing never does;
- its error is the field's own, announced (role="alert");
- a 60 s resend countdown, the Junk/Clutter hint after a send, and an honest 429
  ("Too many requests. Wait a few minutes, then try again.", naming Retry-After when
  the response carries one) on both the request and the verify.

The rule lives in features/public/otp-code.ts (the console keeps its own copy: the
fork cannot import super-repo code). All files are fork-owned (features/public/**,
pages/public/**): no upstream seam.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ct after a 429 (wiki-v2 docmost#815 review)

Review round 1 of wiki-v2 PR 820 / docmost PR 88:
- The copy leads with the code ("Email me a sign-in code", "enter the code below"): PR B
  makes the email code-only, and the page must stay true before and after it. The
  link-incomplete notice no longer says "6-digit".
- requestEmail takes onRetryAfter, so a 429 that names its wait holds "Resend email"
  that long (useResendCooldown.start(seconds)), as the console already does.
- After a verify error the remaining text is selected, so a pasted fresh code replaces
  a code kept after a 429 instead of appending to it.
- Tests: the bridge-failure branch (a toast, the code kept, no field alert), the
  selection after a 429, the Retry-After hold, and onRetryAfter in the hook.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PMQ9
PMQ9 merged commit c54db16 into wiki-v2 Nov 11, 2026
@PMQ9
PMQ9 deleted the feat/815-otp-code-field branch November 11, 2026 00: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.

1 participant