Skip to content

feat(mosaic): redeem invitations in sign-up - #10944

Merged
austincalvelage merged 25 commits into
austin/mosaic-sign-up-phone-channelfrom
austin/mosaic-sign-up-invitations
Dec 4, 2026
Merged

austincalvelage merged 25 commits into
austin/mosaic-sign-up-phone-channelfrom
austin/mosaic-sign-up-invitations

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Description

Redeems invitations in Mosaic sign-up. Stacked on #10930.

When someone opens an invitation link, sign-up redeems the ticket, shows the loading screen while it does, and goes to the step the sign-up still needs. That is usually the continue screen for a password, since the invitation already verified the email.

Shared changes (for Mosaic reviewers)

  • The fake FAPI redeems seeded tickets the way clerk_go does: the invited email starts verified, a ticket bypasses the sign-up mode gate, and an unknown or expired ticket returns ticket_invalid_code or ticket_expired_code.

1. Sign-up holds the ticket and the model redeems it. SignUp reads __clerk_ticket or __clerk_invitation_token once, when it mounts, as legacy's start card does, and passes it to the model. redeemTicket returns the next step, or the blocked notice when FAPI blocks the request, and the invited email for the form. When FAPI rejects the ticket, the controller forgets it before the failure renders, so a rejected ticket leaves a normal start form.

// sign-up.tsx
const [ticket, setTicket] = useState(ticketFromUrl);

2. Sign-up redeems the ticket on each visit to start. As in legacy, a reload redeems again, which FAPI accepts until the sign-up completes. A second invitation opened in the same browser therefore replaces an unfinished one. A sign-up is the invitation's while a ticket is held and a sign-up exists, the same rule as legacy's hasExistingSignUpWithTicket. The screen is loading while it runs. A rejected ticket shows its error on the start form until the user submits it.

// sign-up.model.ts
const inTicketSignUp = Boolean(ticket && signUp.id);

3. Going back to start never drops the invitation. While the invitation's sign-up is in progress, start locks the invited email and updates that sign-up instead of creating a new one. WhatsApp is hidden, as in legacy. With a ticket in the URL, start shows the form in restricted and waitlist mode, because FAPI lets a ticket through. The rule follows the held ticket, as legacy's does: if the app resets the sign-up while the ticket is held, start keeps the invited email locked, hides WhatsApp, and creates the new sign-up with the ticket.

// sign-up-details.controller.ts
if (purpose === 'continue' || details.inTicketSignUp) {
  return details.update(submitted);
}

4. The invitation's sign-up finishes on the continue screen. It sends the password with the update, as #10881 already does for any sign-up. An invitation that FAPI completes on redemption keeps the loading screen up until sign-up leaves.

Finishing or starting over removes the ticket parameters from the URL.

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 8:17pm UTC
mosaic-docs Ready Ready Preview Dec 4, 2026 8:17pm UTC
swingset Ready Ready Preview Dec 4, 2026 8:17pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8b31bf6

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

Mosaic sign-up now reads invitation tickets from supported URL parameters and redeems them during sign-up. The flow adopts the invitation email, applies ticket-specific form and creation behavior, and handles blocked or failed redemption. Ticket state is cleared on reset and completion. The controller manages redemption loading and errors. Feature tests cover invitation flows across sign-up modes, and internal documentation describes the updated behavior.

Estimated code review effort: 4 (Complex) | ~35 minutes

Possibly related PRs

  • clerk/javascript#11022: Adds a follow-up enterprise SSO redirect and loading screen that depends on the invitation state and loading behavior in this change.
  • clerk/javascript#10818: Adds the SignUpView interface for locked invitation fields and restricted or waitlist notices that this flow drives.
  • clerk/javascript#10945: Changes sign-up reset behavior for invitations, relating to this change’s ticket retention on reset.
Merge Risk: Moderate · previous review 7c594

An invitation link opened by a signed-in single-session user may send a ticket redemption request before the redirect happens. This could consume or reject the invitation unexpectedly. Gate redemption on the session override before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(mosaic): redeem invitations in sign-up" names the main change: Mosaic sign-up now redeems invitation tickets. The raw summary and objectives confirm the changeset adds ticket redemptio…
Description check Passed The description states that Mosaic sign-up now redeems invitations, shows a loading screen during redemption, and routes to the next step. It also covers the shared fake-FAPI changes and the reset and…
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): redeem invitations in sign-up" names the main change: Mosaic sign-up now redeems invitation tickets. The raw summary and objectives confirm the changeset adds ticket redemption to the sign-up controller, model, and fake FAPI, so the title is related to the primary change.

Full details: Description check

Explanation

The description states that Mosaic sign-up now redeems invitations, shows a loading screen during redemption, and routes to the next step. It also covers the shared fake-FAPI changes and the reset and URL-cleanup behavior, which match the changeset. It is related to the changes in detail.

  • 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 519e5c4 and 7c59469.

Files selected for processing: 1

  • packages/mosaic/src/features/sign-up/sign-up.model.ts
Linked repositories identified

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

Included review availability: This review used your included allowance. 7 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@10944

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-native-components

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 8b31bf6

@austincalvelage
austincalvelage force-pushed the austin/mosaic-sign-up-invitations branch from 8f5cd12 to a36f82f Compare November 21, 2026 01:15
@austincalvelage
austincalvelage force-pushed the austin/mosaic-sign-up-invitations branch from a36f82f to d487ad9 Compare November 21, 2026 04:02
@austincalvelage
austincalvelage force-pushed the austin/mosaic-sign-up-invitations branch from d487ad9 to bd8e06a Compare November 23, 2026 17:09
@austincalvelage
austincalvelage removed this pull request from stack #10873 November 23, 2026 17:12
@austincalvelage
austincalvelage force-pushed the austin/mosaic-sign-up-invitations branch from 2c3f167 to ec7bc61 Compare November 23, 2026 17:19
Sign-up redeems a ticket from __clerk_ticket or __clerk_invitation_token once, showing the loading screen, then goes to the step the sign-up needs, usually continue for the password. A rejected ticket shows its error on the start form, which then works as a normal sign-up. While the invitation's sign-up is in progress, the start form locks the invited email and updates that sign-up instead of creating a new one.
…icted mode

A sign-up is the invitation's when FAPI verified its email with the ticket strategy, so an earlier sign-up on the client no longer blocks redemption or poses as the invitation. With a ticket in the URL, start shows the form in restricted and waitlist mode. Submitting the start form clears a rejected invitation's error, and Start over removes the ticket parameters.
…t is in the URL

An abandoned invitation sign-up stayed on the client, so a later visit to the plain sign-up page locked the start form to the invited email and updated the old sign-up. Sign-up now also needs the ticket in the URL, as legacy `SignUpStart` does with `hasExistingSignUpWithTicket`.
The invitation checks pushed `useSignUpModel` past the cognitive complexity limit. The channels an invitation hides are picked once at the top.
Folds the rejected and expired invitation tests into one table.
…tion is blocked

Fails today. The blocked notice now comes from the result a request resolves with, and redeeming an invitation still rejects with the error, so the start form shows it inline.
…ion is blocked

`redeemTicket` resolves with the blocked result when FAPI answers `action_blocked`, as `create` and the Protect proof do, and the controller keeps it for the mount. Any other error still rejects and shows on the start form.
…finishes signing up

An invitation that leaves nothing to fill in completes on redemption. The
first test holds the session activation and fails today: the start form
shows, locked and busy, between the loading screen and the navigation. It
also pins that the invitation is redeemed once on this path.

The second test passes today. It pins what a failed activation shows: the
error on the start form, with the way to sign in.
…inishes signing up

An invitation that leaves nothing to fill in completes on redemption. The
loading screen showed only while the ticket action was pending, and that
action ends as soon as it hands the step to the finish machine. The finish
froze the model, which says start, so the start form showed, locked and
busy, until the session was active.

The ticket action now hands next the loading screen, and the finish
freezes it with the model. A failed activation ends the hold, so start
shows the error.
The invitation tests move out of the shared sign-up feature test with the helpers they alone use, and are grouped by what the invitee is doing in place of one "SignUp invitations" block.
…hine's arrival state

The controller records why the visitor arrived, and a ticket arrival starts the activity machine in redeemingTicket, whose invoke redeems once. This replaces the ticket's pending-action key, its run-once ref and the effect that ran it. FINALIZE sent while redeeming freezes the loading screen, so next no longer hands the screen over.
…ed notice when one is rejected

Sign-up told an invitation's sign-up by its ticket email verification, so an
unfinished invitation stopped the next ticket from being redeemed. A rejected
ticket only left the URL, which rerenders nothing, so restricted mode kept the
form. The SignUp wrapper now holds the ticket in state, sign-up redeems it on
every visit to start, and the controller forgets it when FAPI rejects it.
…r invitation started

With a ticket held and no sign-up on the client, start created a sign-up without the ticket, so a restricted or waitlist instance refused it and a public one left the invitation pending. The create now carries the ticket, and the fake FAPI gives a ticket sign-up the invitation's email whatever address is sent, as FAPI does. The start form also keeps the invited email locked and offers no alternative phone channel after the reset, because both now follow the held ticket and the email the form holds, not the sign-up.
A visitor who opened sign-up from an invitation link while signed in, in
single-session mode, or with a session task pending, still had the ticket
redeemed: the arrival intent was picked from the route alone, so the
machine started in redeemingTicket while the same render hid the flow and
left. The redemption could create and activate a new session behind the
redirect. The intent now reads the arrival session override and redeems
only when it is none, as ui's withRedirectToAfterSignUp and
withRedirectToSignUpTask keep SignUpStart from mounting.
},
forgetTicket,
finalize: async () => {
forgetTicket();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In restricted or waitlist mode, when an invitation completes on redemption and finalize() fails, the user sees the "Access restricted" notice instead of the start form. forgetTicket() here runs before finalize(), so screenFor (sign-up.controller.ts:149) has no attempt.ticket and returns signUpMode. docs/internals/sign-in-sign-up-flow.md:124 says this case should land on "a normal sign-up form with its sign-in link".

Reproduced with a restricted-mode copy of "shows why on the start form, with the way to sign in, when the new session cannot be activated" (same tkt_complete seed, mode: 'restricted', touch request failed). It fails on 03e119b: expected <h2>Access restricted</h2> to be null. The error alert does show, but on the restricted notice.

One fix is to keep the start form after a failed finalize that began with a ticket. Another is to update the doc if the restricted notice is what you want. Either way, the restricted-mode test should go in with it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ui lands on the restricted notice here too: completeSignUpFlow removes __clerk_ticket before setActive, and SignUpStart's catch clears the form's ticket, so SignUpStart.tsx:395 renders SignUpRestrictedAccess. I kept that and fixed the doc instead, in 8b31bf6, which says start shows what a visit without an invitation does: the form on a public instance and the restricted or waitlist notice with the error otherwise. Your restricted-mode test is in the same commit, along with a waitlist case.

This branch was successfully deployed

2 active deployments
Preview – swingset — 8b31bf65 Deployed Dec 4, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 8b31bf65 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