Skip to content

refactor(web): one registry decides the sign-in sheet's methods and order - #654

Merged
PastaPastaPasta merged 1 commit into
masterfrom
refactor/sign-in-methods
Nov 22, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
refactor/sign-in-methods

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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 ChooseView in login-modal.tsx. This PR moves it into one pure function, lib/auth/sign-in-methods.ts signInMethods({ network, walletAvailable, walletV2, creating }), and ChooseView now only renders its output. This is Phase 1 of docs/design/wallet-primary.md (#652).

No behavior change. The tiles, their order, badges, copy and DOM are the same:

  • components/login-modal.test.tsx and login-modal-guided.test.tsx pass unchanged (46 tests, with the registry's own).
  • The new sign-in-methods.test.ts pins 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

…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]>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b256bfe5-8ce2-44d6-a9e6-475cb2bdc282
Commits

Reviewing files that changed from the base of the PR and between 30cd475 and e18d057.

Files selected for processing: 3

  • forge-web/components/login-modal.tsx
  • forge-web/lib/auth/sign-in-methods.test.ts
  • forge-web/lib/auth/sign-in-methods.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. nit, forge-web/components/login-modal.tsx (const tile = … switch). The switch has no exhaustiveness check. ReactNode allows undefined, so if someone adds a new SignInMethodId and forgets its case, the code still compiles and that tile silently renders nothing. Phase 2 will add ids, so this will come up. Fix: add default: { const never: never = id; return never }, or give the function a return type that excludes undefined.
  2. nit, forge-web/components/login-modal.tsx (the advancedTiles.length > 0 guard). raw-key is always in the list, so the guard is always true. It is harmless, but it is a branch no test exercises.
  3. 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".
  4. nit, forge-web/lib/auth/sign-in-methods.ts:3. The doc comment points to docs/design/wallet-primary.md, which exists only on #652 (still open). The reference dangles until #652 merges.
  5. 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.

@PastaPastaPasta
PastaPastaPasta merged commit 5da226c into master Nov 22, 2026
19 of 20 checks passed
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