Skip to content

feat(mosaic): send sign-up phone codes over WhatsApp - #10930

Merged
austincalvelage merged 31 commits into
austin/mosaic-sign-up-protectfrom
austin/mosaic-sign-up-phone-channel
Dec 4, 2026
Merged

austincalvelage merged 31 commits into
austin/mosaic-sign-up-protectfrom
austin/mosaic-sign-up-phone-channel

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Description

Sends Mosaic sign-up phone codes over WhatsApp. Stacked on #10928.

When an instance turns on WhatsApp for phone numbers, the start screen offers it as a button. Picking it asks for the phone number only, creates the sign-up and sends the code over WhatsApp in the same request. The code screen names the channel, resends over it, and offers "Send code via SMS" instead of going back.

This needs channel on SignUpFutureCreateParams from #10955, which has merged. clerk-js already sends it, so that PR is a @clerk/shared type change. The AuthAlternativeChannel fix this screen relies on is in #10957.

Shared changes (for Mosaic reviewers)

  • The fake FAPI now checks WhatsApp the way FAPI does: it allows the channel when the instance can send WhatsApp, not when the phone attribute lists it, and it can fall back to SMS. A create with strategy: 'phone_code' prepares the phone in the same request. When the send fails, the sign-up stays on the client with the unverified phone number and the error carries the client, as in clerk_go.

1. The details model lists the alternative channels and can create over one. create takes an optional channel and sends it with strategy: 'phone_code', so the code goes out with the create request.

alternativeChannels: userSettings.alternativePhoneCodeChannels.flatMap(channel => {
  const provider = getAlternativePhoneCodeProviderData(channel);
  return provider ? [{ id: channel, name: provider.name, iconUrl: iconImageUrl(channel) }] : [];
}),

const sendOver = channel ?? preferredPhoneChannel(values.phoneNumber);
signUp.create({ ...details(values), ...(sendOver ? { strategy: 'phone_code', channel: sendOver } : {}) });

2. Picking a channel swaps start for the alternative phone screen. The details controller keeps the chosen channel, so the same form asks for the phone number only, and Continue stays disabled until it's filled. Back, Edit from the code screen and Start over all return to the full form. The channel buttons show on start only, as in legacy. A phone error from one screen is cleared when you switch to the other.

3. The verify screen reads the channel from the sign-up. The verification model reports the channel the code went out on, so a reload still names WhatsApp, and the SMS screen shows when FAPI falls back to SMS because the WhatsApp quota is used up. Resend uses that channel, and the code machine gets a SEND_SMS event for the switch to SMS. The screen locks while switching, clears the typed code on resend and on the switch, clears a wrong-code error on the switch, and starts the resend countdown even when a send fails.

4. The first code after the start form uses the channel the instance prefers for the number's country, through getPreferredPhoneCodeChannelByCountry, as legacy does. It goes out with the create request. Resends and a phone entered on continue don't use it. With no preferred channel, create sends no strategy and the code screen sends the SMS code.

5. Errors on the WhatsApp path show where the user looks. A rejected phone number shows under the field, through the AuthAlternativeChannel fix in #10957. A failed WhatsApp send, such as whatsapp_channel_not_enabled, shows FAPI's message instead of the generic one. A blocked request shows the blocked notice in place of the WhatsApp phone screen.

Known gaps

  • A failed WhatsApp send leaves an unverified sign-up with the phone number on the client. FAPI and legacy do the same. A retry sends the code, and going back to the form signs up over SMS.
  • Use another method clears the form-level error, such as the whatsapp_channel_not_enabled message. Legacy keeps its card error there.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 4, 2026 6:55pm UTC
mosaic-docs Ready Ready Preview Dec 4, 2026 6:55pm UTC
swingset Ready Ready Preview Dec 4, 2026 6:55pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d9b8d03

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The sign-up flow now supports SMS and WhatsApp phone-code channels. It can select an alternative channel during sign-up, use a preferred channel when available, and switch to SMS during verification. The fake sign-up API validates channel requests and records SMS when WhatsApp quota is exceeded. Feature tests cover channel selection, verification, retries, and error cases.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#10944: Adds invitation-ticket handling on the start screen and uses the start-screen channel controls introduced here.
Merge Risk: Low · previous review 231cc

The WhatsApp sign-up flow has a few open issues. In some progressive sign-up configurations, a phone number edited on the WhatsApp screen can be replaced by an earlier prefilled number. Optional profile fields can be dropped, form-level errors can be cleared on channel changes, and an SMS switch clicked during a send can be ignored. The impact is narrow, but the phone-number overwrite should be fixed before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(mosaic): send sign-up phone codes over WhatsApp" matches the main change. The PR adds a WhatsApp option for sign-up phone codes, sends the first code over WhatsApp in the create reques…
Description check Passed The description states that Mosaic sign-up phone codes can be sent over WhatsApp and describes the start screen button, the phone-only form, the code screen channel naming and SMS switch, the shared f…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(mosaic): send sign-up phone codes over WhatsApp" matches the main change. The PR adds a WhatsApp option for sign-up phone codes, sends the first code over WhatsApp in the create request, and updates the verify screen, the fake FAPI, and the controllers. The title is specific and concise.

Full details: Description check

Explanation

The description states that Mosaic sign-up phone codes can be sent over WhatsApp and describes the start screen button, the phone-only form, the code screen channel naming and SMS switch, the shared fake FAPI changes, and known gaps. It matches the changeset closely and gives useful context on dependencies (#10928, #10955, #10957).

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 77d9b6c and 231cc55.

Files selected for processing: 3

  • packages/mosaic/src/features/sign-up/sign-up.model.ts
  • packages/mosaic/src/features/sign-up/sign-up.types.ts
  • packages/swingset/src/stories/sign-up.stories.tsx
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Files with no reviewable changes: 1

  • packages/mosaic/src/features/sign-up/sign-up.types.ts

Included review availability: This review used your included allowance. 8 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10930

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10930

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10930

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10930

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10930

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10930

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10930

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10930

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10930

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10930

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10930

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10930

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10930

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10930

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10930

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10930

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10930

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10930

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10930

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10930

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10930

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10930

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10930

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10930

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10930

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10930

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10930

commit: d9b8d03

A phone error from FAPI now shows on the WhatsApp phone screen, since AuthAlternativeChannel reads the phone field's feedback. A failed WhatsApp send shows FAPI's message. The continue screen offers no WhatsApp buttons. Editing from the code screen and Start over return to the main form. The WhatsApp create sends prefilled values the screen does not show. The country's preferred channel applies only to the first send after the start form, not to resends or a phone entered on the continue screen.
FAPI allows the WhatsApp channel when the instance can send WhatsApp messages, not when the phone attribute lists it, and rejects it with whatsapp_channel_not_enabled otherwise. It can also send by SMS when the WhatsApp quota is used up, and always reports the channel a phone code went out on. The fake now does the same.
… sign-up

Continue on the WhatsApp phone screen stays disabled until the phone number is filled. The code screen locks while switching to SMS, starts the resend countdown after a failed send, and clears the typed code on resend and on the switch to SMS.
FAPI creates a sign-up with `strategy: 'phone_code'` and a channel in one transaction, so a code it cannot send creates nothing. The fake now does the same, and the tests check that a WhatsApp sign-up takes one request and that a failed send leaves no sign-up behind.
A WhatsApp sign-up created the sign-up, then sent the code in a second request. When the send failed, the sign-up stayed behind and each retry created another. Create now sends `strategy: 'phone_code'` with the picked or preferred channel, as legacy `SignUpStart` does, so FAPI creates the sign-up and sends the code together. The SMS default still sends no strategy and lets the code screen send the code.
The full form and the WhatsApp phone screen share one form, so a rejected phone number on one stayed under the phone field after switching to the other. Picking a channel and Use another method now clear the phone number's error.
…om WhatsApp

Resend clears the channel the code screen picked, so it relies on the model sending over the channel the sign-up last used. The test pins that a resend after switching to SMS stays on SMS.
The fake FAPI dropped the sign-up when the create request could not send
the WhatsApp code. clerk_go 8bb8f66dde inserts the sign-up and attaches it
to the client before it prepares the code (api/fapi/v1/sign_up/service.go:394-407),
prepares it in a later transaction (:529, channel check in
pkg/usersettings/clerk/strategies/phone_code.go:352-361), and returns the
error with the client (http.go:73-77, wrapper.go:49). clerk-js applies
meta.client from an error response (Client.ts getClientResourceFromPayload).

The fake now keeps the unverified sign-up with the phone number and sends
the client in the error. The test that expected no sign-up now checks that
the user stays on the WhatsApp screen with the error and a retry sends the
code. A new test goes back to the form and signs up over SMS with the
stray sign-up present.
- Fold the one-request create checks into the WhatsApp sign-up test.
- Fold the rejected phone number checks into the test that goes back to the
  form after it.
- Drop the unavailable-channel test, which the failed-send retry test repeats
  before it retries.
- Drop the SMS switch test, which the SMS resend and lock tests cover.
- Drop the back-to-form test, which two other tests do on the way.
The routing PR no longer uses vi, and these tests fake the resend timer.
…the phone channel comments

Merges the two WhatsApp phone screen error tests into one that leaves both a field
and a global error behind.
…SMS instead

After a wrong code on the WhatsApp code screen, Send code via SMS instead emptied the input but kept the Incorrect code error under it, so the SMS screen opened with an error for a code the user had not entered. onSendSms now resets the pending action's error, as legacy does by remounting the code form (SignUpPhoneCodeCard prepareWithSMS).
The SMS and WhatsApp tests move out of the shared sign-up feature test, grouped by what the user is doing, with the phone environment they alone use beside them. The two tests of an error left behind between the form and the WhatsApp phone screen are one test that goes both ways.
…pp phone number

The WhatsApp phone screen validates only the phone number, and the submit
picked values for those same fields, so a name or username typed on the
start form never reached the create request and the continue screen asked
for it again. The submit now picks the start form's fields plus the phone,
as `ui`'s card submits every active field from the shared form state.
… a prefilled one

When the start form hides an optional phone, a prefilled number lands in the
hidden values, and those were spread over the submitted ones. The WhatsApp
phone screen shows that same number, so an edit there was overwritten and the
code went to the prefilled number. A hidden value now fills only a field the
active screen does not show.
…ile a code is still sending

The code machine ignores the SMS switch while a send is in flight, but the
button stays enabled there so the code input is not locked, and pressing it
cleared the typed code and reset the error before sending nothing. The press
now does nothing until the send settles.
…stance asks for an email or a phone number

Submitting from the WhatsApp phone screen sent the start form's fields for
the active identifier, so on an instance that asks for an email or a phone
number, an email typed before choosing WhatsApp went along with the phone and
the user was asked to verify the email first. Choosing WhatsApp makes the phone
the identifier, so the submit now takes the start form's fields and hidden
values for the phone.
…art from the WhatsApp code screen without pressing Edit

This branch was successfully deployed

2 active deployments
Preview – swingset — d9b8d033 Deployed Dec 4, 2026 by vercel[bot]
Preview – clerk-js-sandbox — d9b8d033 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants