From 27898faca3ecaadf58bda811a23e370c41fc72a4 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:01:03 -0400 Subject: [PATCH 1/6] refactor(mosaic): type the Waitlist controller result as its view props --- .../src/features/waitlist/waitlist.controller.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/mosaic/src/features/waitlist/waitlist.controller.ts b/packages/mosaic/src/features/waitlist/waitlist.controller.ts index 3fd82d25df2..e3bb9bf6ca4 100644 --- a/packages/mosaic/src/features/waitlist/waitlist.controller.ts +++ b/packages/mosaic/src/features/waitlist/waitlist.controller.ts @@ -1,8 +1,8 @@ -import type { UseFormResult } from '../../components/form'; import { useForm } from '../../components/form'; import { setup } from '../../machine/setup'; import { useMachine } from '../../machine/use-machine'; -import type { WaitlistModel, WaitlistStep, WaitlistValues } from './waitlist.types'; +import type { WaitlistModel } from './waitlist.types'; +import type { WaitlistViewProps } from './waitlist.view'; export const WAITLIST_REDIRECT_DELAY_MS = 2000; @@ -37,15 +37,7 @@ const waitlistMachine = createMachine({ export type WaitlistReadyModel = Extract; -export interface WaitlistController { - step: WaitlistStep; - form: UseFormResult; - renderBranding: boolean; - isRedirecting: boolean; - onSignIn: () => void; -} - -export function useWaitlistController(model: WaitlistReadyModel): WaitlistController { +export function useWaitlistController(model: WaitlistReadyModel): WaitlistViewProps { const { initialEmailAddress, renderBranding, onJoinWaitlist, onSignIn, onRedirect } = model; const [snapshot, send] = useMachine(waitlistMachine, { context: { onRedirect } }); const form = useForm({ From 53071715d13fdfbe99151253f1a23d9f6d13d050 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:02:00 -0400 Subject: [PATCH 2/6] refactor(swingset): read the live environment through useMosaicEnvironment --- packages/swingset/src/app/(clerk)/live/live-overview.tsx | 9 +++------ .../swingset/src/app/(clerk)/live/misc/waitlist/page.tsx | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/swingset/src/app/(clerk)/live/live-overview.tsx b/packages/swingset/src/app/(clerk)/live/live-overview.tsx index 8199d9fca48..f63a61e5158 100644 --- a/packages/swingset/src/app/(clerk)/live/live-overview.tsx +++ b/packages/swingset/src/app/(clerk)/live/live-overview.tsx @@ -1,7 +1,7 @@ 'use client'; -import { useClerk, useUser } from '@clerk/nextjs'; -import type { EnvironmentResource } from '@clerk/shared/types'; +import { useMosaicEnvironment } from '@clerk/mosaic/hooks/use-mosaic-environment'; +import { useUser } from '@clerk/nextjs'; import { ExternalLinkIcon } from 'lucide-react'; import Link from 'next/link'; @@ -18,11 +18,8 @@ export function LiveOverview({ dashboardUrl: string | null; deployment: { label: string; dashboardUrl: string | null } | null; }) { - const clerk = useClerk(); const { isLoaded, isSignedIn, user } = useUser(); - // The environment resource isn't part of the public Clerk interface; reach through the internal getter. - const environment = (clerk as unknown as { __internal_environment?: EnvironmentResource | null }) - .__internal_environment; + const environment = useMosaicEnvironment(); const applicationName = environment?.displayConfig.applicationName; return ( diff --git a/packages/swingset/src/app/(clerk)/live/misc/waitlist/page.tsx b/packages/swingset/src/app/(clerk)/live/misc/waitlist/page.tsx index 6ebfbb6235e..48727dab817 100644 --- a/packages/swingset/src/app/(clerk)/live/misc/waitlist/page.tsx +++ b/packages/swingset/src/app/(clerk)/live/misc/waitlist/page.tsx @@ -2,9 +2,9 @@ import { Button } from '@clerk/mosaic/components/button'; import { Waitlist } from '@clerk/mosaic/features/waitlist/waitlist'; +import { useMosaicEnvironment } from '@clerk/mosaic/hooks/use-mosaic-environment'; import { MosaicProvider } from '@clerk/mosaic/mosaic-provider'; import { useClerk } from '@clerk/nextjs'; -import type { EnvironmentResource } from '@clerk/shared/types'; import { useState } from 'react'; import { LivePageHeader } from '../../../live-page-header'; @@ -13,8 +13,7 @@ export default function WaitlistLivePage() { const clerk = useClerk(); const [redirect, setRedirect] = useState(false); const [demoKey, setDemoKey] = useState(0); - const environment = (clerk as unknown as { __internal_environment?: EnvironmentResource | null }) - .__internal_environment; + const environment = useMosaicEnvironment(); const signUpMode = environment?.userSettings.signUp.mode; return ( From 0a1aa825a29fc645c70afb199d28b24c84b77c24 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:02:01 -0400 Subject: [PATCH 3/6] chore(repo): add empty changeset --- .changeset/mosaic-waitlist-review-fixes.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/mosaic-waitlist-review-fixes.md diff --git a/.changeset/mosaic-waitlist-review-fixes.md b/.changeset/mosaic-waitlist-review-fixes.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/mosaic-waitlist-review-fixes.md @@ -0,0 +1,2 @@ +--- +--- From 6b30d661f1c14691997e6e29c892484420431ee3 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:09:45 -0400 Subject: [PATCH 4/6] refactor(mosaic): drop the unused redirected state from the Waitlist machine --- .../mosaic/src/features/waitlist/waitlist.controller.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/mosaic/src/features/waitlist/waitlist.controller.ts b/packages/mosaic/src/features/waitlist/waitlist.controller.ts index e3bb9bf6ca4..41d6cba41e8 100644 --- a/packages/mosaic/src/features/waitlist/waitlist.controller.ts +++ b/packages/mosaic/src/features/waitlist/waitlist.controller.ts @@ -24,14 +24,9 @@ const waitlistMachine = createMachine({ }, joined: { after: { - [WAITLIST_REDIRECT_DELAY_MS]: { - target: 'redirected', - guard: context => context.onRedirect !== undefined, - actions: context => context.onRedirect?.(), - }, + [WAITLIST_REDIRECT_DELAY_MS]: { actions: context => context.onRedirect?.() }, }, }, - redirected: { type: 'final' }, }, }); From dcc002a8c691a66c1942ae1b5f5ce6b2e5cd1a08 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:34:45 -0400 Subject: [PATCH 5/6] refactor(mosaic): read the Waitlist email query through the Mosaic router --- packages/mosaic/src/features/waitlist/waitlist.model.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/mosaic/src/features/waitlist/waitlist.model.ts b/packages/mosaic/src/features/waitlist/waitlist.model.ts index a1dc495a124..e906df147cd 100644 --- a/packages/mosaic/src/features/waitlist/waitlist.model.ts +++ b/packages/mosaic/src/features/waitlist/waitlist.model.ts @@ -10,10 +10,6 @@ export type WaitlistModelOptions = Pick save(() => clerk.joinWaitlist({ emailAddress }), WAITLIST_FIELDS), onSignIn: () => void router.navigate(clerk.buildUrlWithAuth(signInUrl)), From 6e0ca0cf59b9705ceed99286ebc559a659e41cb6 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 28 Oct 2026 19:48:49 -0400 Subject: [PATCH 6/6] refactor(mosaic): only fire the Waitlist redirect timer when there is a redirect --- packages/mosaic/src/features/waitlist/waitlist.controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mosaic/src/features/waitlist/waitlist.controller.ts b/packages/mosaic/src/features/waitlist/waitlist.controller.ts index 41d6cba41e8..5ce1f5755e2 100644 --- a/packages/mosaic/src/features/waitlist/waitlist.controller.ts +++ b/packages/mosaic/src/features/waitlist/waitlist.controller.ts @@ -24,7 +24,10 @@ const waitlistMachine = createMachine({ }, joined: { after: { - [WAITLIST_REDIRECT_DELAY_MS]: { actions: context => context.onRedirect?.() }, + [WAITLIST_REDIRECT_DELAY_MS]: { + guard: context => context.onRedirect !== undefined, + actions: context => context.onRedirect?.(), + }, }, }, },