Repository navigation
feat(mosaic): wire up sign-up with step routing - #10881
austincalvelage wants to merge 130 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
🦋 Changeset detectedLatest commit: 847af67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen 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 |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-biometrics
@clerk/expo-google-signin
@clerk/expo-native-components
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/mosaic
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
…uest was blocked The model read the notice from Clerk's sign-up error signal, which outlives the component, so a remount showed Request blocked with no way back to the form. The model's create now resolves with the blocked details and the controller keeps them for the mount, as the legacy card error does.
…arriving visitor picks an organization
…anization task is done A visitor who arrived with the choose-organization task pending never went through sign-up's finish, so after picking an organization the card stayed on the task route with an empty step and mounted the task's own continuation, which navigated a second time. A signed-in session on the task route now ends the flow.
…instance's own password rules
…ance's password rules A password error from sign-up's create or update went through the shared error catalog, whose entry for a too-short password is a fixed 8-character sentence, so an instance with another minimum contradicted its own while-typing hint. Sign-up now maps a rejected password through the mapping user profile uses, which reads the instance's password settings and FAPI's strength suggestions. Other fields rejected in the same answer keep their catalog copy.
…nd fold repeated tests The tests that asserted sign-up left once, or showed nothing, waited two event-loop turns first. They now wait for the card to empty, or re-render the mounted component, before counting navigations. The two too-short password tests are one table over the start form and the continue screen, the two tests of a sign-up that stays mounted are one table over the session mode, and the two signature tests are one test with its control.
…rop its error on Edit
… clock during render
…unfinished sign-up In single-session mode a visitor who arrives signed in must leave for the after sign-up URL. The model read the sign-up before the session, so an unfinished sign-up left on the client showed the start form instead.
…d the step separately The model merged the session into the sign-up step, and the controller undid the merge in three places with state only it holds. The model now returns the step and the session phase as two facts. flowOutcome in features/auth-flow decides resource, hold, task, leave or done from the session, the session at mount and the finish machine's state, so sign-in can share it. The decision runs during render, which removes the handingOff state, the isNextScreenLoading context and the recheck() layout effect. routeFor and allowedRoute see only sign-up steps. A signed-in visitor now leaves in single-session mode even when the client holds an unfinished sign-up.
Replace the three model-added steps with the session phases and the five outcomes, and point the hold-past-the-action rule at the render-time decision that replaced handingOff.
…ds left empty Continue was disabled until every required field was filled, which gave no hint about what was missing. It now stays enabled. Pressing it with a required field or legal consent missing shows an error under each one, moves focus to the first, and sends nothing. The errors appear only after Continue is pressed. The first field is autofocused, so marking fields as visited on blur would flag a form nobody has typed in yet.
controllers.md says to prevent submissions with canSubmit, which disables the button. The sign-up details form validates its required fields on submit instead, so the doc now describes that exception and why its inputs do not report blur.
The fake FAPI filled supported_strategies with the instance's full verification list on every sign-up response. FAPI sends only the strategy that was already prepared, and nothing before a prepare. The fake now leaves the field empty until a prepare and then sets it to the prepared strategy. "offers Start over on an instance that verifies email by link" fails after this change, because the model reads that field to tell that an instance verifies by link. The next commit fixes the model.
… email by link The model checked supportedStrategies on the sign-up to decide whether the instance verifies email by link. That field holds only a strategy that was already prepared, and sign-up creates without one, so the check was never true against FAPI. On an instance that verifies by link the user reached the code screen, and sending the code was rejected. The model now reads the instance's email verification settings, as the legacy sign-up does. An instance that enables the email link shows Start over, including one that also enables the code, because legacy sends a link there and the link screen is not built yet. models.md named supportedStrategies as the field to read before a code is sent, so it now gives this case as one that reads the settings.
…n mode A session that appeared while the form was open, with no sign-up finished in this flow, kept the form on screen. In single-session mode the legacy sign-up renders nothing in that case and does not navigate, and FAPI rejects a new sign-up from a signed-in client, so the form could only fail. flowOutcome now answers done for that case, so sign-up renders nothing. A visit that arrives signed in still leaves for the after sign-up URL, and multi-session mode still shows the form so the user can add an account.
The previous commit hid sign-up on every route when another tab signed in, in single-session mode. The legacy sign-up guards per screen: SignUpStart renders nothing, while SignUpContinue and the verify screens have no guard, so a sign-up that was already started can still finish. flowOutcome now takes whether the route is start. On start the outcome is done, because FAPI rejects a new sign-up from a signed-in client. Past start it is resource, so the form stays.
…n-up A sign-up that stayed mounted showed the previous user's verify screen, with their email and a busy button, while a later sign-out ran. Clerk reports no session during a sign-out, the same as during an activation, so the outcome was hold, and hold rendered the model kept from the finished sign-up. flowOutcome now answers done when the session goes away after this flow has finalized, so sign-up keeps rendering nothing until the start form shows. The kept model is reached only while the flow is finishing, or has finalized with its task still loading. The legacy sign-up also renders nothing while Clerk reports no session.
…tinue screens When activating the new session failed after the sign-up had completed, pressing Continue again on start sent the same details as a new sign-up. The user already existed, so FAPI answered that the email address is taken and the user was stuck until a reload. Continue on the continue screen failed the same way. create and update now skip the request when the sign-up is already complete and return its step, so Continue runs the activation again, as entering the code again already does. The fake FAPI now treats an email address as taken once its sign-up completes, so a test cannot pass by creating a second user.
A visitor who arrives signed in, in single-session mode, is sent to the after sign-up URL from an effect. StrictMode runs an effect twice when a component mounts, so the navigation ran twice in development. The controller now remembers that it has left, so the navigation runs once for as long as the component stays mounted.
…en sign-up finishes The sign-up form lives above the screens, so its values outlived the screen they were typed on. After Edit on a verify screen the password was still filled in and could be shown. A sign-up that stayed mounted through a sign-out came back with the previous user's email address and password. Edit on a verify screen now clears the password before the form shows again and keeps the address. A sign-up that finishes clears every field. The password stays when activating the new session fails on the screen it was typed on, so Continue can run the activation again.
SignUp took its routing type from the shared location options, so it accepted path, hash and query routing once those landed. Its screens were built and tested with virtual routing only. In a URL mode the browser's Back button returns to the details form without going through Edit, so the password is still filled in. The routing prop now accepts only virtual. The URL modes come with the routing wire-up, where reaching a screen from the browser's history can be handled and tested.
This reverts commit 3e87389.
…Back in a URL routing mode Edit on a verify screen clears the password. In path, hash or query routing the browser's Back button returns to the form without going through Edit, so the password is still filled in. The todo marks that for the routing wire-up.
…s note The note said the hash params wait for path routing in #10860. Path routing landed in another pull request, and sign-up still does not read the hash.
Description
Wires up the Mosaic
<SignUp />component, building on Alex's flow guide (packages/mosaic/docs/internals/sign-in-sign-up-flow.md). Each sign-up screen is its own component, and it mounts when its route is active. Routing is virtual for now, and should be easy to move to path routing once #10860 lands.SignUptakes someone from the first form to a signed-in session: details, email or phone code, then on to the app. It is not exported from the package entry yet.Stacked on #10985, which lets sign-up's card hold the organization task as one step. The PRs it built on, #10867, #10868 and #10883, have merged. The alternative-channel fix (#10957) has merged too.
channelonSignUpFuture.create()(#10955), which the WhatsApp PR above uses, and theAuthStartOverblock (#10956) have merged. #10955 is a@clerk/sharedtype change, since clerk-js already sendschannel.Shared changes (for Mosaic reviewers)
docs/views.md, a new "Exception: sign-up" bullet: sign-up's view takesscreenand one props object per screen, because its screens follow its routes.src/routing/use-route-guard.ts: replaces a route the owner's state does not allow, with no history entry. AGENTS.md lists it in the reuse list.localization/errors.messages.ts:signup_rate_limit_exceededgets legacy's copy, "Too many requests. Please try again in a bit."passwordonSignUpFutureUpdateParamscomes from feat(shared): accept channel on create and password on update in SignUpFuture params #10955.views.md,useTaskChooseOrganizationFlow,TaskChooseOrganizationContentand the task'senabledoption are in refactor(mosaic): let another card hold the organization task as one step #10985.features/auth-flow/auth-flow.utils.ts:flowOutcomedecides whether an auth flow shows its form, holds the screen it left from, shows a session task, leaves, or renders nothing. It has no sign-up types, so sign-in can call it.docs/internals/sign-in-sign-up-flow.mdlists the outcomes, anddocs/controllers.mddescribes the hold.passwordErrorinuser-profile-password-errors.tsis exported for sign-up's password errors.controllers.mdlists sign-up's use as a known gap, because the model formats the error.Clerk guards the route if the sign-up isn't ready for that screen
1. The route you're on is the screen you get, unless the sign-up's step or the session says otherwise.
routeForandallowedRoutesee only FAPI's sign-up steps. Item 8 covers whereoutcomecomes from.2. The code screen sends its code when it mounts if one hasn't been sent yet, and starts the resend countdown either way. Edit stays disabled until that first code is out.
The verify screen runs its own controller, so the wrapper builds it and passes it to the view as a slot:
3. The form lives above the screens, so start and continue share it. Edit on the code screen clears the password, and finishing a sign-up clears the whole form.
4. Clerk wipes the sign-up once the code is accepted, which would flash the first form before the app navigates. So while finishing, we keep rendering the model we left from, like the switcher's
frozenModel.The finish machine keeps that model in its context, and the controller uses it only while the outcome is
hold. The outcome isholdwhilefinalizeruns, while the session is activating, and afterfinalizewhile the task's data hasn't loaded. The hold is decided during render, so no effect copies the live model into the machine. The wrapper runsuseTaskChooseOrganizationFlowonce, passes its controller toTaskChooseOrganizationContentand tells the controller when the task has loaded, so the task replaces the code screen in the same card with no skeleton in between. If the app set its own URL for that task intaskUrls, sign-up goes there. Once the hold ends with the session signed in, the outcome isdoneand a<SignUp />that stays mounted renders nothing. The same holds for a visitor who arrives signed in with the organization task pending and picks an organization: sign-up navigates once.5. The continue screen asks for what FAPI says is still missing, instead of rebuilding that list from the instance settings. The rules (
continueFields,continueCanSatisfy,missesEitherIdentifier) live insign-up.utils.ts.A missing email, phone or username that's also in
optional_fieldsmeans any one will do, so the form shows one field with the email/phone switch. A password typed there goes out with theupdate. An email or phone that is set but unverified stays on the form, prefilled, so Edit on a verify screen reached from continue has an address to change.6. If FAPI needs something the continue screen can't ask for, like a required OAuth provider, you get Start over instead of a form you can't finish.
7. Continue stays enabled, and pressing it with a required field empty says what is missing.
Formskips the browser's validation popup, so the form checks required fields itself. Each empty required field gets an error, and so does legal consent that isn't accepted. Focus moves to the first one, and nothing is sent.The errors appear only after Continue is pressed. The first field is autofocused, so an error on blur would flag a form nobody has typed in. The other Mosaic forms disable their submit button through
canSubmit. Sign-up differs so that the form can say what is missing.8. The model reports the sign-up step and the session as two facts, and
flowOutcomedecides between them. The model returnsflow.step, which is FAPI's next step, andflow.session, which isnone,activating,taskoractive. The controller adds the three facts only it has: the session it saw at mount, where the finish machine is, and whether the route isstart.resourceholdtaskleavedoneA signed-in visitor doesn't see the form in single-session mode, even with an unfinished sign-up on the client. Only a visit that arrives signed in leaves. Finishing a sign-up doesn't count as one. If another tab signs in while the start form is open, the form goes without navigating. Past the start form it stays so the sign-up can finish. Both match legacy.
flowOutcomehas a table test infeatures/auth-flow/__tests__/auth-flow.utils.test.ts.9.
redirect_urlin the query decides where sign-up lands, and the sign-in and waitlist links keep it.The model is grouped by screen
The model reads Clerk in one place and returns
flow,app,navigation,detailsandverification.email/verification.phone. Each screen folder takes its group whole, so one screen is one folder to read.features.mdnow describes this as the shape for a flow with several screens.Known gaps
completesign-up on reload, are not built.SignUpPropsare not supported yet, because they add public API. Onlyredirect_urlfrom the query is read.redirect_urlonly, not the rest of the query.transferstep.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change