Skip to content

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

Draft
austincalvelage wants to merge 16 commits into
austin/mosaic-sign-up-protectfrom
austin/mosaic-sign-up-phone-channel
Draft

austincalvelage wants to merge 16 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. clerk-js already sends it, so that PR is a @clerk/shared type change. The AuthAlternativeChannel fix this screen relies on is in #10957.

Review fixes

  • Create sends strategy: 'phone_code' with the channel, as legacy SignUpStart does, so FAPI creates the sign-up and sends the code in one request. The second sendPhoneCode request is gone. fix(mosaic): send the sign-up phone channel in the create request, covered by "sends the phone code over WhatsApp when the user picks it, then signs them up".
  • A phone error stays on the screen that got it. Picking a channel and Use another method clear the phone field's error. fix(mosaic): keep phone errors on the sign-up screen that got them, covered by "shows a rejected phone number on the WhatsApp phone screen and leaves it behind on the form" and "leaves the form's phone error behind when picking WhatsApp".
  • A resend after switching to SMS stays on SMS, and a comment on the verify controller says why a send without a channel is safe. test(mosaic): resend the sign-up phone code by SMS after switching from WhatsApp, covered by "resends the phone code by SMS after switching to SMS from the WhatsApp code screen".
  • The fake FAPI keeps the sign-up a failed WhatsApp send leaves behind, as clerk_go does. test(mosaic): keep the sign-up a failed WhatsApp send leaves behind, covered by "keeps the WhatsApp screen and its error after a failed send, then sends the code on retry" and "signs up over SMS from the form after a failed WhatsApp send left a sign-up".
  • The AuthAlternativeChannel change moved to fix(mosaic): gate the alternative channel Continue and show its phone field errors #10957, with a sign-in test.

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, 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.

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.

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.
  • The form-level error, such as the whatsapp_channel_not_enabled message, still shows after Use another method, as legacy's card error does.

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 Nov 24, 2026 1:29am UTC
mosaic-docs Ready Ready Preview Nov 24, 2026 1:29am UTC
swingset Ready Ready Preview Nov 24, 2026 1:29am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b051363

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

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@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: b051363

When the instance enables WhatsApp for phone numbers, the start screen offers it. Picking it asks for the phone number only, creates the sign-up and sends the code over WhatsApp. The code screen names the channel, resends over it, and can switch to SMS. A phone sign-up also uses the channel the instance prefers for the number's country.
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.

This branch was successfully deployed

2 active deployments
Preview – swingset — b0513631 Deployed Nov 24, 2026 by vercel[bot]
Preview – clerk-js-sandbox — b0513631 Deployed Nov 24, 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.

1 participant