Repository navigation
refactor(web): one registry decides the sign-in sheet's methods and order - #654
Conversation
…rder lib/auth/sign-in-methods.ts lists the sign-in methods by group (lead, new, existing, advanced) with the one recommended, and ChooseView only renders it. No change to what the sheet shows; tests pin today's order per network. This is the seam that makes the wallet primary (docs/design/wallet-primary.md). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
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. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
I checked the "no behavior change" claim one case at a time against git diff origin/master...e18d0571. It holds. Both walletFirst in ChooseView and leads in the registry call walletSignInReady(network, walletV2) with the same inputs, so they always agree.
| Item | Old | New | Same? |
|---|---|---|---|
| Resume tile | first if creating !== null, highlight, paused |
lead:resume-create when creating; same props |
yes |
| Wallet position | slot 2 if walletFirst, else after dg; only if walletAvailable |
lead if leads, else last in existing; only if walletAvailable |
yes |
| Wallet badge | walletFirst ? (creating===null ? Recommended : null) : Not available yet |
walletFirst ? (leads && !creating ? Recommended : null) : Not available yet; under walletFirst this reduces to !creating |
yes |
Wallet muted, copy, pausedReason |
!walletFirst; network-dependent body |
unchanged text | yes |
| Create badge and highlight | !walletFirst && creating === null |
!leads && !creating |
yes |
| Cost line | <p> right after the create tile |
same <p> inside the create tile's Fragment |
yes |
| Group labels | "New to Dash?", "Already have a Dash identity?" | same text, same position | yes |
| Passkey, import, dg | fixed order, same props | same | yes |
| Advanced | always rendered | rendered when advancedTiles.length > 0, which is always true |
yes |
| DOM | flat siblings | arrays and a Fragment produce the same DOM, so space-y-2's > * + * still applies |
yes |
On reconciliation: the old siblings were positional, with null holding each slot. The new ones are keyed by id inside each group. PasskeySignIn keeps its identity in both versions. The wallet tile moving between lead and existing remounts it in both versions too, because it lands in a different slot in the old code and a different array in the new.
sign-in-methods.test.ts pins the old behavior: the testnet order (with and without v2), mainnet+v2 order, mainnet without v2, creating on both networks (no * anywhere when creating) and walletAvailable: false. The existing component tests in login-modal.test.tsx:495-527 mock walletSignInReady from @/lib/auth/app-connect. That is the module the registry imports, so they still drive both branches and still pass.
Local run on e18d057: vitest for the three files gave 46/46 passed. tsc --noEmit reported no errors, and eslint on the two changed files was clean.
Shape for wallet-primary (#652). The shape is the right size. Phase 2 step 4 ("lead with the wallet on testnet") becomes a change inside walletSignInReady, and both the order and the copy follow it automatically. Step 5 (a "Get DashPay" tile, with in-page create moved under "Other ways") needs a new id and a new group. Because the group labels live in ChooseView (login-modal.tsx, the GroupLabel lines), that change touches both files. That is acceptable, though putting the labels next to SignInGroup would make it a registry-only edit. I'm not asking for that now.
Findings (none blocking):
- nit,
forge-web/components/login-modal.tsx(const tile = …switch). The switch has no exhaustiveness check.ReactNodeallowsundefined, so if someone adds a newSignInMethodIdand forgets itscase, the code still compiles and that tile silently renders nothing. Phase 2 will add ids, so this will come up. Fix: adddefault: { const never: never = id; return never }, or give the function a return type that excludesundefined. - nit,
forge-web/components/login-modal.tsx(theadvancedTiles.length > 0guard).raw-keyis always in the list, so the guard is always true. It is harmless, but it is a branch no test exercises. - nit,
forge-web/lib/auth/sign-in-methods.test.ts:20. The test is titled "takes the badge", but the resume tile has no badge (it is highlighted). What the test actually checks is that no method is recommended while a creation is unfinished. Suggested title: "an unfinished creation comes first and no method is recommended". - nit,
forge-web/lib/auth/sign-in-methods.ts:3. The doc comment points todocs/design/wallet-primary.md, which exists only on #652 (still open). The reference dangles until #652 merges. - nit,
forge-web/components/login-modal.tsx:15-17. The file header says the wallet "on testnet … is last, badged as waiting on wallet support (#591)". That was already true before this PR and still is; it will need updating in Phase 2 step 4, not here.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Making the wallet the primary sign-in means changing which methods the sign-in sheet offers, in what order, and which one it recommends. Today that logic is spread through the JSX of
ChooseViewinlogin-modal.tsx. This PR moves it into one pure function,lib/auth/sign-in-methods.tssignInMethods({ network, walletAvailable, walletV2, creating }), andChooseViewnow only renders its output. This is Phase 1 ofdocs/design/wallet-primary.md(#652).No behavior change. The tiles, their order, badges, copy and DOM are the same:
components/login-modal.test.tsxandlogin-modal-guided.test.tsxpass unchanged (46 tests, with the registry's own).sign-in-methods.test.tspins today's order: testnet, mainnet with and without v2, an unfinished creation, and no wallet source.Wallet-first on testnet is a later PR, and it will change this function and its tests only.
No screenshots, since nothing visible changes.
🤖 Generated with Claude Code