Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(onboarding): New onboarding flow and layout (#3316)
dev-rbfba43654793e
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex 6930ca5fff..4521f3674f 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -87,7 +87,8 @@ import { ReactiveFavicon } from './ReactiveFavicon';import { LAYOUT_ROUTE } from './split-layout/SplitLayoutRoute';import { TeamInviteAcceptance } from './TeamInviteAcceptance';-const InteractiveOnboarding = lazy(+const NewOnboarding = lazy(() => import('./onboarding/onboarding'));+const OldOnboarding = lazy(() => import('./interactive-onboarding/InteractiveOnboarding'));@@ -95,9 +96,14 @@ import {AnalyticsContextProvider,useAnalytics,} from '@app/component/analytics-context';-import { PosthogProvider, usePosthog } from '@app/lib/analytics/posthog';+import {+ PosthogProvider,+ ShowFeatureFlag,+ usePosthog,+} from '@app/lib/analytics/posthog';import { CallProvider } from '@channel/Call/CallContext';import { CallStartedNotifier } from '@channel/Call/CallStartedNotifier';+import { ENABLE_NEW_ONBOARDING_OVERRIDE } from '@core/constant/featureFlags';import { QuickAccessProvider } from '@core/context/quickAccess';import { Button } from '@ui';@@ -344,7 +350,13 @@ const ROUTES: RouteDefinition[] = [path: '/welcome',component: () => (<div class="flex *:flex-1 size-full overflow-y-hidden">- <InteractiveOnboarding />+ <ShowFeatureFlag+ key="enable-new-onboarding"+ enabledOverride={ENABLE_NEW_ONBOARDING_OVERRIDE}+ fallback={<OldOnboarding />}+ >+ <NewOnboarding />+ </ShowFeatureFlag></div>),},diff --git a/js/app/packages/app/component/onboarding/onboarding-context.tsx b/js/app/packages/app/component/onboarding/onboarding-context.tsxnew file mode 100644index 0000000000..c03d57ac76--- /dev/null+++ b/js/app/packages/app/component/onboarding/onboarding-context.tsx@@ -0,0 +1,156 @@+import type { PaidPlanTier, PlanTier } from '@app/component/paywall/plans';+import { PLANS } from '@app/component/paywall/plans';+import {+ createContext,+ createMemo,+ createSignal,+ type ParentProps,+ useContext,+} from 'solid-js';+import { createStore, type SetStoreFunction } from 'solid-js/store';++export interface InvitedMember {+ email: string;+ tier: PaidPlanTier;+}++export type StepStatus = 'pending' | 'completed' | 'skipped';++export interface StepState {+ id: string;+ label: string;+ status: StepStatus;+}++export interface OnboardingContextValue {+ firstName: () => string;+ setFirstName: (v: string) => void;+ lastName: () => string;+ setLastName: (v: string) => void;+ email: () => string;+ setEmail: (v: string) => void;+ teamName: () => string;+ setTeamName: (v: string) => void;+ selectedPlan: () => PlanTier | null;+ setSelectedPlan: (tier: PlanTier | null) => void;+ invitedMembers: () => InvitedMember[];+ setInvitedMembers: (members: InvitedMember[]) => void;+ userSeatCost: () => number;+ teamSeatsCost: () => number;+ totalCost: () => number;+ seatCount: () => number;+ step: () => number;+ setStep: (step: number) => void;+ next: () => void;+ back: () => void;+ steps: StepState[];+ setSteps: SetStoreFunction<StepState[]>;+ skipStep: (id: string) => void;+ completeStep: (id: string) => void;+ isStepSkipped: (id: string) => boolean;+}++const OnboardingContext = createContext<OnboardingContextValue>();++export function OnboardingProvider(+ props: ParentProps & {+ steps: Array<{ id: string; label: string }>;+ }+) {+ const [firstName, setFirstName] = createSignal('');+ const [lastName, setLastName] = createSignal('');+ const [email, setEmail] = createSignal('');+ const [teamName, setTeamName] = createSignal('');+ const [selectedPlan, setSelectedPlan] = createSignal<PlanTier | null>(null);+ const [invitedMembers, setInvitedMembers] = createSignal<InvitedMember[]>([]);+ const [step, setStep] = createSignal(0);++ const [steps, setSteps] = createStore<StepState[]>(+ props.steps.map((s) => ({ id: s.id, label: s.label, status: 'pending' }))+ );++ const userSeatCost = createMemo(() => {+ const tier = selectedPlan();+ if (!tier) return 0;+ const plan = PLANS.find((p) => p.tier === tier);+ return plan?.price ?? 0;+ });++ const teamSeatsCost = createMemo(() =>+ invitedMembers().reduce((total, member) => {+ const plan = PLANS.find((p) => p.tier === member.tier);+ return total + (plan?.price ?? 0);+ }, 0)+ );++ const totalCost = () => userSeatCost() + teamSeatsCost();+ const seatCount = () => 1 + invitedMembers().length;++ const isStepSkipped = (id: string) =>+ steps.find((s) => s.id === id)?.status === 'skipped';++ const next = () =>+ setStep((s) => {+ let n = s + 1;+ while (n < steps.length && steps[n]?.status === 'skipped') n++;+ return Math.min(n, steps.length - 1);+ });++ const back = () =>+ setStep((s) => {+ let n = s - 1;+ while (n > 0 && steps[n]?.status === 'skipped') n--;+ return Math.max(n, 0);+ });++ const skipStep = (id: string) => {+ const idx = steps.findIndex((s) => s.id === id);+ if (idx !== -1) setSteps(idx, 'status', 'skipped');+ };++ const completeStep = (id: string) => {+ const idx = steps.findIndex((s) => s.id === id);+ if (idx !== -1) setSteps(idx, 'status', 'completed');+ };++ const value: OnboardingContextValue = {+ firstName,+ setFirstName,+ lastName,+ setLastName,+ email,+ setEmail,+ teamName,+ setTeamName,+ selectedPlan,+ setSelectedPlan,+ invitedMembers,+ setInvitedMembers,+ userSeatCost,+ teamSeatsCost,+ totalCost,+ seatCount,+ step,+ setStep,+ next,+ back,+ steps,+ setSteps,+ skipStep,+ completeStep,+ isStepSkipped,+ };++ return (+ <OnboardingContext.Provider value={value}>+ {props.children}+ </OnboardingContext.Provider>+ );+}++export function useOnboarding() {+ const ctx = useContext(OnboardingContext);+ if (!ctx)+ throw new Error('useOnboarding must be used within OnboardingProvider');+ return ctx;+}diff --git a/js/app/packages/app/component/onboarding/onboarding.tsx b/js/app/packages/app/component/onboarding/onboarding.tsxnew file mode 100644index 0000000000..1b55807fc4--- /dev/null+++ b/js/app/packages/app/component/onboarding/onboarding.tsx@@ -0,0 +1,346 @@+import { useAnalytics } from '@app/component/analytics-context';+import { useSplitPanel } from '@app/component/split-layout/layoutUtils';+import { analytics } from '@app/lib/analytics/analytics';+import { useIsAuthenticated } from '@core/auth';+import { PcNoiseGrid } from '@core/component/PcNoiseGrid';+import { toast } from '@core/component/Toast/Toast';+import { useUserInfo } from '@core/context/user';+import { initAndStartEmailSync } from '@core/email-link';+import { fetchToken } from '@core/util/fetchWithToken';+import { throwOnErr } from '@core/util/result';+import ArrowLeftIcon from '@phosphor/arrow-left.svg';+import { useCompleteTutorialMutation } from '@queries/auth/tutorial';+import { invalidateUserTeams, useUserTeamsQuery } from '@queries/team';+import { authServiceClient } from '@service-auth/client';+import { useLocation, useNavigate } from '@solidjs/router';+import { useQuery } from '@tanstack/solid-query';+import { Button, cn, Layer, LogoProgress } from '@ui';+import { Stepper } from '@ui/components/Stepper';+import { createEffect, createMemo, For, on, onMount, Show } from 'solid-js';+import { Dynamic } from 'solid-js/web';+import {+ clearPendingTeam,+ getPendingTeam,+} from '../interactive-onboarding/use-onboarding-checkout';+import { OnboardingProvider, useOnboarding } from './onboarding-context';+import { STEPS } from './steps';++export default function Onboarding() {+ return (+ <OnboardingProvider steps={STEPS}>+ <OnboardingInner />+ </OnboardingProvider>+ );+}++function OnboardingInner() {+ const ctx = useOnboarding();+ const analyticsCtx = useAnalytics();+ const location = useLocation();+ const navigate = useNavigate();+ const splitPanel = useSplitPanel();+ const completeTutorial = useCompleteTutorialMutation();+ const isAuthenticated = useIsAuthenticated();+ const userInfo = useUserInfo();+ const userTeamsQuery = useUserTeamsQuery();++ const params = new URLSearchParams(location.search);++ // Restore locally saved profile data (survives Google/Stripe redirects)+ const saved = sessionStorage.getItem('onboarding_profile');+ if (saved) {+ try {+ const profile = JSON.parse(saved);+ if (profile.firstName) ctx.setFirstName(profile.firstName);+ if (profile.lastName) ctx.setLastName(profile.lastName);+ if (profile.email) ctx.setEmail(profile.email);+ if (profile.teamName) ctx.setTeamName(profile.teamName);+ } catch {+ // ignore malformed data+ }+ sessionStorage.removeItem('onboarding_profile');+ }++ // Fill remaining gaps from authenticated user data+ createEffect(() => {+ if (!isAuthenticated()) return;++ ctx.skipStep('verify');++ const info = userInfo();+ if (!info) return;++ if (info.email && !ctx.email()) ctx.setEmail(info.email);+ });++ // Fetch first/last name separately (userInfo only has a combined display name)+ const userNameQuery = useQuery(() => ({+ queryKey: ['userName'],+ queryFn: async () => {+ const result = await authServiceClient.getUserName();+ if (result.isErr()) return null;+ return result.value;+ },+ enabled: isAuthenticated() === true && !ctx.firstName() && !ctx.lastName(),+ }));++ createEffect(() => {+ const name = userNameQuery.data;+ if (!name) return;+ if (name.first_name && !ctx.firstName()) ctx.setFirstName(name.first_name);+ if (name.last_name && !ctx.lastName()) ctx.setLastName(name.last_name);+ });++ // Prefill team name and skip team step if user already has a team+ createEffect(() => {+ const teams = userTeamsQuery.data;+ if (!teams) return;++ if (teams.length > 0) {+ const team = teams[0];+ if (team.name && !ctx.teamName()) ctx.setTeamName(team.name);+ ctx.skipStep('team');+ }+ });++ const cleanParam = (key: string) => {+ const cleanParams = new URLSearchParams(window.location.search);+ cleanParams.delete(key);+ const qs = cleanParams.toString();+ window.history.replaceState(+ null,+ '',+ qs ? `${window.location.pathname}?${qs}` : window.location.pathname+ );+ };++ const navigateAway = () => {+ if (splitPanel) {+ splitPanel.handle.replace({+ next: { type: 'component', id: 'unified-list' },+ });+ } else {+ navigate('/', { replace: true });+ }+ };++ onMount(() => {+ if (params.has('google')) {+ cleanParam('google');+ ctx.skipStep('verify');++ fetchToken().then(async () => {+ initAndStartEmailSync().match(+ () => analytics.track('email_authorized'),+ (e) => {+ if (e.tag === 'AlreadyInitialized') {+ analytics.track('email_authorized');+ } else {+ console.error('Failed to init email link after Google auth', e);+ }+ }+ );++ if (ctx.firstName() || ctx.lastName()) {+ authServiceClient+ .putUserName({+ first_name: ctx.firstName() || undefined,+ last_name: ctx.lastName() || undefined,+ })+ .catch(() => {});+ }+ });++ const teamStepIndex = STEPS.findIndex((s) => s.id === 'team');+ if (teamStepIndex !== -1) ctx.setStep(teamStepIndex);++ return;+ }++ if (params.has('subscriptionSuccess')) {+ const rawTier = params.get('type');++ cleanParam('subscriptionSuccess');+ cleanParam('type');++ analytics.track('subscription_success', { type: rawTier ?? 'unknown' });++ fetchToken().then(() => createPendingTeamOnReturn());+ completeTutorial.mutate(undefined);++ navigateAway();++ return;+ }++ analyticsCtx.track('onboarding_start');+ });++ createEffect(+ on(+ () => ctx.step(),+ (step) => {+ analyticsCtx.track('onboarding_step', {+ step,+ id: STEPS[step]?.id,+ label: STEPS[step]?.label,+ });+ }+ )+ );++ const showBack = () => ctx.step() > 1;++ // Exclude intro (index 0) and skipped steps from progress count+ const activeStepCount = createMemo(+ () => ctx.steps.filter((s, i) => i > 0 && s.status !== 'skipped').length+ );++ const activeStepPosition = createMemo(() => {+ const current = ctx.step();+ let pos = 0;+ for (let i = 1; i < ctx.steps.length; i++) {+ if (ctx.steps[i]?.status === 'skipped') continue;+ pos++;+ if (i === current) return pos;+ }+ return pos;+ });++ return (+ <div class="flex items-center justify-center size-full relative overflow-y-auto py-8">+ <style>+ {`+ input:-webkit-autofill,+ input:-webkit-autofill:hover,+ input:-webkit-autofill:focus {+ -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;+ -webkit-text-fill-color: var(--color-ink);+ caret-color: var(--color-ink);+ transition: background-color 5000s ease-in-out 0s;+ }+ `}+ </style>++ <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">+ <PcNoiseGrid+ cellSize={30}+ warp={0}+ crunch={0.2}+ freq={0.001}+ size={[0, 0.3]}+ rounding={0}+ fill={0}+ stroke={1}+ speed={[0.017, 0.209]}+ />+ </div>++ <Layer depth={3}>+ <div+ class={cn(+ 'w-full flex flex-col px-8',+ ctx.step() === 0 ? 'max-w-3xl' : 'max-w-md'+ )}+ >+ <Show when={ctx.step() > 0}>+ <div class="w-full flex items-center gap-3 mb-10">+ <LogoProgress+ level={activeStepPosition()}+ total={activeStepCount()}+ class="w-7"+ />+ <Show when={activeStepCount() > 1}>+ <span class="text-xs font-mono text-ink-disabled">+ {activeStepPosition()}/{activeStepCount()}+ </span>+ </Show>+ </div>+ </Show>++ <div class="w-full flex flex-col gap-2">+ <Show when={ctx.step() > 0}>+ <div class={showBack() ? 'visible' : 'invisible'}>+ <button+ type="button"+ tabIndex={0}+ onClick={() => ctx.back()}+ class="flex items-center gap-1 text-xs text-ink-disabled hover:text-ink transition-colors outline-none rounded-sm focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ <ArrowLeftIcon class="size-3" />+ Back+ </button>+ </div>+ </Show>+ <Stepper+ step={ctx.step()}+ transition={Stepper.transitions.slideFull}+ appear+ class={cn(+ 'overflow-clip p-1 -m-1',+ ctx.step() > 0 && 'min-h-125'+ )}+ >+ <For each={STEPS}>+ {(stepDef, i) => (+ <Stepper.Step noTransition={i() === 0}>+ <Dynamic component={stepDef.component} />+ </Stepper.Step>+ )}+ </For>+ </Stepper>+ </div>+ </div>+ </Layer>++ <Show when={import.meta.env.MODE === 'development'}>+ <div class="fixed bottom-4 right-4 z-50">+ <Button variant="ghost" size="sm" onClick={() => ctx.next()}>+ Skip step+ </Button>+ </div>+ </Show>+ </div>+ );+}++async function createPendingTeamOnReturn(): Promise<boolean> {+ const pendingTeam = getPendingTeam();+ if (!pendingTeam) return true;++ try {+ const team = await throwOnErr(() =>+ authServiceClient.createTeam({ name: pendingTeam.name })+ );++ const invites = pendingTeam.members+ .filter((m) => m.email.trim())+ .map((m) => ({ email: m.email }));++ if (invites.length > 0) {+ try {+ await throwOnErr(() => authServiceClient.inviteToTeam({ invites }));+ } catch (inviteError) {+ console.error('Failed to send team invites:', inviteError);+ toast.failure('Team created, but some invites failed to send.');+ }+ }++ await invalidateUserTeams();+ clearPendingTeam();++ analytics.track('onboarding_team_created', {+ inviteCount: invites.length,+ teamId: team.id,+ });++ return true;+ } catch (error) {+ console.error('Failed to create team:', error);+ toast.failure(+ 'Failed to create team. You can set it up later in Settings.'+ );+ clearPendingTeam();+ return false;+ }+}diff --git a/js/app/packages/app/component/onboarding/steps/index.ts b/js/app/packages/app/component/onboarding/steps/index.tsnew file mode 100644index 0000000000..1be2d0e297--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/index.ts@@ -0,0 +1,22 @@+import type { Component } from 'solid-js';+import { IntroStep } from './intro-step';+import { PaymentStep } from './payment-step';+import { ProfileStep } from './profile-step';+import { TeamStep } from './team-step';+import { VerifyStep } from './verify-step';++export { IntroStep, PaymentStep, ProfileStep, TeamStep, VerifyStep };++export interface OnboardingStep {+ id: string;+ label: string;+ component: Component;+}++export const STEPS: OnboardingStep[] = [+ { id: 'intro', label: 'Intro', component: IntroStep },+ { id: 'profile', label: 'Profile', component: ProfileStep },+ { id: 'verify', label: 'Verify', component: VerifyStep },+ { id: 'team', label: 'Team', component: TeamStep },+ { id: 'payment', label: 'Payment', component: PaymentStep },+];diff --git a/js/app/packages/app/component/onboarding/steps/intro-step.tsx b/js/app/packages/app/component/onboarding/steps/intro-step.tsxnew file mode 100644index 0000000000..06c71c566a--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/intro-step.tsx@@ -0,0 +1,127 @@+import LogoIcon from '@icon/macro-logo.svg';+import { AnimatedCallIcon } from '@icon/wide-call';+import { AnimatedChannelIcon } from '@icon/wide-channel';+import { AnimatedEmailIcon } from '@icon/wide-email';+import { AnimatedFileMdIcon } from '@icon/wide-fileMd';+import { AnimatedStarIcon } from '@icon/wide-star';+import { AnimatedTaskIcon } from '@icon/wide-task';+import ArrowRightIcon from '@phosphor/arrow-right.svg';+import { Button, cn } from '@ui';+import { For } from 'solid-js';+import { useOnboarding } from '../onboarding-context';++const BLOCKS = [+ {+ icon: AnimatedEmailIcon,+ color: 'text-email',+ hoverBg: 'hover:bg-email/10',+ hoverBorder: 'hover:border-email/40',+ hoverIconBg: 'group-hover:bg-email/10',+ title: 'Email',+ description: 'Full email client — no tab switching.',+ },+ {+ icon: AnimatedFileMdIcon,+ color: 'text-note',+ hoverBg: 'hover:bg-note/10',+ hoverBorder: 'hover:border-note/40',+ hoverIconBg: 'group-hover:bg-note/10',+ title: 'Docs',+ description: 'Markdown editor with mentions and live collaboration.',+ },+ {+ icon: AnimatedTaskIcon,+ color: 'text-task',+ hoverBg: 'hover:bg-task/10',+ hoverBorder: 'hover:border-task/40',+ hoverIconBg: 'group-hover:bg-task/10',+ title: 'Tasks',+ description: 'Assignments, due dates, and statuses — all linked.',+ },+ {+ icon: AnimatedChannelIcon,+ color: 'text-folder',+ hoverBg: 'hover:bg-folder/10',+ hoverBorder: 'hover:border-folder/40',+ hoverIconBg: 'group-hover:bg-folder/10',+ title: 'Channels',+ description: 'Team messaging with threads and file sharing.',+ },+ {+ icon: AnimatedCallIcon,+ color: 'text-calendar',+ hoverBg: 'hover:bg-calendar/10',+ hoverBorder: 'hover:border-calendar/40',+ hoverIconBg: 'group-hover:bg-calendar/10',+ title: 'Calls',+ description: 'Voice and video — no separate app needed.',+ },+ {+ icon: AnimatedStarIcon,+ color: 'text-chat',+ hoverBg: 'hover:bg-chat/10',+ hoverBorder: 'hover:border-chat/40',+ hoverIconBg: 'group-hover:bg-chat/10',+ title: 'AI Agents',+ description: 'Search, summarize, and act across everything.',+ },+];++export function IntroStep() {+ const ctx = useOnboarding();++ return (+ <div class="flex flex-col items-center text-center gap-10 w-full">+ <div class="flex flex-col items-center gap-5">+ <LogoIcon class="size-12 text-accent" />+ <div class="flex flex-col gap-2">+ <h1 class="text-4xl font-semibold text-ink tracking-tight">+ Welcome to Macro+ </h1>+ <p class="text-sm text-ink-disabled">+ SOC 2 certified · built for teams that move fast+ </p>+ </div>+ </div>++ <div class="grid grid-cols-3 gap-3 w-full">+ <For each={BLOCKS}>+ {(item) => (+ <div+ class={cn(+ 'group flex-1 flex flex-col gap-2.5 p-4 rounded-sm border border-edge-muted text-left transition-colors',+ item.hoverBg,+ item.hoverBorder+ )}+ >+ <div+ class={cn(+ 'size-8 rounded-sm bg-hover flex items-center justify-center transition-colors',+ item.hoverIconBg+ )}+ >+ <item.icon class={cn('size-5', item.color)} />+ </div>+ <div class="flex flex-col gap-0.5">+ <span class="text-sm font-medium text-ink">{item.title}</span>+ <span class="text-xs text-ink-disabled leading-relaxed">+ {item.description}+ </span>+ </div>+ </div>+ )}+ </For>+ </div>++ <Button+ variant="base"+ size="lg"+ onClick={() => ctx.next()}+ class="px-8 bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Get started+ <ArrowRightIcon class="size-4" />+ </Button>+ </div>+ );+}diff --git a/js/app/packages/app/component/onboarding/steps/payment-step.tsx b/js/app/packages/app/component/onboarding/steps/payment-step.tsxnew file mode 100644index 0000000000..95c9961119--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/payment-step.tsx@@ -0,0 +1,236 @@+import { useAnalytics } from '@app/component/analytics-context';+import type { PaidPlanTier } from '@app/component/paywall/plans';+import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';+import { useIsAuthenticated } from '@core/auth';+import { useHasPaidAccess } from '@core/auth/license';+import { toast } from '@core/component/Toast/Toast';+import ArrowRightIcon from '@phosphor/arrow-right.svg';+import LockIcon from '@phosphor/lock.svg';+import SpinnerIcon from '@phosphor/spinner.svg';+import { useNavigate } from '@solidjs/router';+import { Button } from '@ui';+import { createSignal, For, Show } from 'solid-js';+import {+ clearPendingTeam,+ savePendingTeam,+ useOnboardingCheckoutMutation,+} from '../../interactive-onboarding/use-onboarding-checkout';+import { useOnboarding } from '../onboarding-context';++interface TeamPlan {+ price: number;+ seats: number;+ tier: PaidPlanTier;+}++const TEAM_PLANS: TeamPlan[] = [+ { price: 100, seats: 3, tier: 'haiku' },+ { price: 500, seats: 6, tier: 'sonnet' },+ { price: 2500, seats: 10, tier: 'opus' },+ { price: 6000, seats: 25, tier: 'opus' },+];++function planForSeatCount(seats: number): TeamPlan {+ return (+ TEAM_PLANS.find((p) => p.seats >= seats) ??+ TEAM_PLANS[TEAM_PLANS.length - 1]+ );+}++export function PaymentStep() {+ const hasPaidAccess = useHasPaidAccess();++ return (+ <Show when={!hasPaidAccess()} fallback={<AlreadyPaidView />}>+ <CheckoutView />+ </Show>+ );+}++function CheckoutView() {+ const ctx = useOnboarding();+ const analytics = useAnalytics();+ const isAuthenticated = useIsAuthenticated();+ const [isRedirecting, setIsRedirecting] = createSignal(false);++ const teamSize = () => 1 + ctx.invitedMembers().length;+ const plan = () => planForSeatCount(teamSize());++ const checkoutMutation = useOnboardingCheckoutMutation({+ onSuccess: (result) => {+ analytics.track('subscription_start', {+ type: plan().tier,+ seats: teamSize(),+ });+ setIsRedirecting(true);+ window.location.href = result.checkoutUrl;+ },+ onError: (error) => {+ console.error('Checkout error:', error);+ toast.failure(+ error.message || 'Failed to start checkout. Please try again.'+ );+ },+ });++ const isPending = () => checkoutMutation.isPending || isRedirecting();++ const handleCheckout = () => {+ if (isPending()) return;++ if (!isAuthenticated()) {+ toast.failure('Please sign in to continue');+ ctx.setStep(0);+ return;+ }++ const teamName = ctx.teamName();+ const members = ctx+ .invitedMembers()+ .map((m) => ({ email: m.email, tier: plan().tier }));++ if (teamName) {+ savePendingTeam({ name: teamName, members });+ } else {+ clearPendingTeam();+ }++ ctx.setSelectedPlan(plan().tier);+ checkoutMutation.mutate({ tier: plan().tier });+ };++ return (+ <div class="flex flex-col gap-8 w-full">+ <div class="flex flex-col gap-1">+ <h1 class="text-2xl font-semibold text-ink tracking-tight">+ Review your plan+ </h1>+ <p class="text-sm text-ink-disabled">+ Here's a summary of your workspace.+ </p>+ </div>++ <div class="flex flex-col gap-5">+ <Show when={ctx.teamName()}>+ <div>+ <span class="text-xs font-medium text-ink-muted uppercase tracking-wide">+ Team+ </span>+ <p class="text-lg font-semibold text-ink -mt-0.5">+ {ctx.teamName()}+ </p>+ </div>+ </Show>++ <div class="flex items-baseline justify-between pb-4 border-b border-edge-muted">+ <div class="flex items-end gap-1">+ <span class="text-4xl font-bold text-ink leading-none tracking-tight">+ ${plan().price}+ </span>+ <span class="text-ink-muted text-sm pb-0.5">/mo</span>+ </div>+ <span class="text-sm text-ink-muted">Up to {plan().seats} seats</span>+ </div>++ <div class="flex flex-col text-sm">+ <div class="flex justify-between py-2.5 border-b border-edge-muted">+ <span class="text-ink-muted">You</span>+ <span class="text-xs text-ink-disabled">{ctx.email()}</span>+ </div>+ <For each={ctx.invitedMembers()}>+ {(member) => (+ <div class="flex justify-between py-2.5 border-b border-edge-muted">+ <span class="text-ink-muted font-mono text-xs truncate mr-2">+ {member.email}+ </span>+ <span class="text-xs text-ink-disabled shrink-0">Invited</span>+ </div>+ )}+ </For>+ <div class="flex justify-between items-center py-2.5">+ <span class="text-ink-muted">+ {teamSize()} {teamSize() === 1 ? 'seat' : 'seats'} used+ </span>+ <span class="text-xs text-ink-disabled">+ {plan().seats - teamSize()} remaining+ </span>+ </div>+ </div>+ </div>++ <div class="flex flex-col gap-3">+ <Button+ variant="base"+ size="lg"+ onClick={handleCheckout}+ disabled={isPending()}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ <Show+ when={!isPending()}+ fallback={+ <>+ <SpinnerIcon class="size-4 animate-spin" />+ Redirecting to checkout...+ </>+ }+ >+ Continue to payment+ <ArrowRightIcon class="size-4" />+ </Show>+ </Button>++ <span class="text-xs text-ink-disabled flex items-center justify-center gap-1.5">+ <LockIcon class="size-3" />+ Secure checkout via Stripe+ </span>+ </div>+ </div>+ );+}++function AlreadyPaidView() {+ const navigate = useNavigate();++ const handleTakeMeThere = () => {+ navigate('/component/settings', { replace: true });+ };++ const handleTakeMeHome = () => {+ navigate(DEFAULT_ROUTE, { replace: true });+ };++ return (+ <div class="flex flex-col gap-8 w-full">+ <div class="flex flex-col gap-1">+ <h1 class="text-2xl font-semibold text-ink tracking-tight">+ You're all set+ </h1>+ <p class="text-sm text-ink-disabled">+ You already have an active plan. Invite teammates from Settings+ anytime.+ </p>+ </div>++ <div class="flex flex-col gap-2">+ <Button+ variant="base"+ size="lg"+ onClick={handleTakeMeThere}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Take me there+ <ArrowRightIcon class="size-4" />+ </Button>+ <Button+ variant="ghost"+ size="md"+ onClick={handleTakeMeHome}+ class="w-full"+ >+ Take me home+ </Button>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/onboarding/steps/profile-step.tsx b/js/app/packages/app/component/onboarding/steps/profile-step.tsxnew file mode 100644index 0000000000..80efb14fbb--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/profile-step.tsx@@ -0,0 +1,276 @@+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';+import { useIsAuthenticated } from '@core/auth';+import { startSsoLogin } from '@core/auth/sso';+import { toast } from '@core/component/Toast/Toast';+import { isTauri } from '@core/util/platform';+import IconGoogle from '@icon/macro-google.svg';+import ArrowRightIcon from '@phosphor/arrow-right.svg';+import { Button, cn } from '@ui';+import { createSignal, onMount, Show } from 'solid-js';+import { z } from 'zod';+import { useOnboarding } from '../onboarding-context';++const NAME_MAX_LENGTH = 50;+const TEAM_NAME_MAX_LENGTH = 50;+const EMAIL_MAX_LENGTH = 254;++const profileSchema = z.object({+ firstName: z+ .string()+ .min(1, 'First name is required')+ .max(NAME_MAX_LENGTH, 'First name is too long'),+ lastName: z.string().max(NAME_MAX_LENGTH, 'Last name is too long'),+ email: z+ .string()+ .min(1, 'Email is required')+ .email('Invalid email address')+ .max(EMAIL_MAX_LENGTH, 'Email is too long'),+ teamName: z+ .string()+ .min(1, 'Team name is required')+ .max(TEAM_NAME_MAX_LENGTH, 'Team name is too long'),+});++export function ProfileStep() {+ const ctx = useOnboarding();+ const isAuthenticated = useIsAuthenticated();+ const [errors, setErrors] = createSignal<Record<string, string>>({});+ const [authPending, setAuthPending] = createSignal(false);++ let firstNameRef: HTMLInputElement | undefined;+ onMount(() => firstNameRef?.focus());++ const validate = () => {+ const result = profileSchema.safeParse({+ firstName: ctx.firstName().trim(),+ lastName: ctx.lastName().trim(),+ email: ctx.email().trim(),+ teamName: ctx.teamName().trim(),+ });++ if (result.success) {+ setErrors({});+ return true;+ }++ const errs: Record<string, string> = {};+ for (const issue of result.error.issues) {+ const field = issue.path[0];+ if (typeof field === 'string' && !errs[field]) {+ errs[field] = issue.message;+ }+ }+ setErrors(errs);+ return false;+ };++ const clearError = (field: string) => {+ setErrors((prev) => {+ const next = { ...prev };+ delete next[field];+ return next;+ });+ };++ const handleGoogleAuth = async () => {+ if (!validate()) return;+ setAuthPending(true);++ sessionStorage.setItem(+ 'onboarding_profile',+ JSON.stringify({+ firstName: ctx.firstName(),+ lastName: ctx.lastName(),+ email: ctx.email(),+ teamName: ctx.teamName(),+ })+ );++ try {+ const success = await startSsoLogin({+ returnPath: `${ROUTER_BASE_CONCAT}welcome?google=1`,+ loginHint: ctx.email().trim() || undefined,+ });++ if (success) {+ if (isTauri()) {+ window.location.hash = '#/welcome?google=1';+ window.location.reload();+ } else {+ window.location.href = `${window.location.origin}${ROUTER_BASE_CONCAT}welcome?google=1`;+ }+ } else {+ setAuthPending(false);+ }+ } catch (e) {+ console.error('Google sign-in failed:', e);+ toast.failure('Sign-in failed. Please try again.');+ setAuthPending(false);+ }+ };++ const handleContinueWithEmail = () => {+ if (!validate()) return;+ ctx.next();+ };++ const handleContinueAuthed = () => {+ if (!validate()) return;+ ctx.skipStep('verify');+ ctx.next();+ };++ const inputClass = (hasError: boolean) =>+ cn(+ 'w-full px-2.5 h-9 text-sm rounded-sm border bg-transparent text-ink placeholder:text-ink-placeholder transition-colors',+ 'outline-none focus:ring-2 focus:ring-accent focus:ring-offset-1 focus:ring-offset-surface',+ hasError ? 'border-failure' : 'border-edge-muted'+ );++ return (+ <div class="flex flex-col gap-8 w-full">+ <div class="flex flex-col gap-1">+ <h1 class="text-2xl font-semibold text-ink tracking-tight">+ {isAuthenticated() ? 'Your workspace' : 'Create your workspace'}+ </h1>+ <p class="text-sm text-ink-disabled">+ {isAuthenticated()+ ? 'Confirm your details before continuing.'+ : 'Tell us about yourself and your team.'}+ </p>+ </div>++ <div class="flex flex-col gap-5">+ <div class="flex gap-3">+ <div class="flex-1 flex flex-col gap-2">+ <label for="onb-first-name" class="text-sm font-medium text-ink">+ First name+ </label>+ <input+ ref={firstNameRef}+ id="onb-first-name"+ type="text"+ maxLength={NAME_MAX_LENGTH}+ value={ctx.firstName()}+ onInput={(e) => {+ ctx.setFirstName(e.currentTarget.value);+ clearError('firstName');+ }}+ placeholder="Jane"+ class={inputClass(!!errors().firstName)}+ />+ <Show when={errors().firstName}>+ <p class="text-xs text-failure">{errors().firstName}</p>+ </Show>+ </div>+ <div class="flex-1 flex flex-col gap-2">+ <label for="onb-last-name" class="text-sm font-medium text-ink">+ Last name+ </label>+ <input+ id="onb-last-name"+ type="text"+ maxLength={NAME_MAX_LENGTH}+ value={ctx.lastName()}+ onInput={(e) => {+ ctx.setLastName(e.currentTarget.value);+ clearError('lastName');+ }}+ placeholder="Doe"+ class={inputClass(!!errors().lastName)}+ />+ <Show when={errors().lastName}>+ <p class="text-xs text-failure">{errors().lastName}</p>+ </Show>+ </div>+ </div>++ <div class="flex flex-col gap-2">+ <label for="onb-email" class="text-sm font-medium text-ink">+ </label>+ <input+ id="onb-email"+ type="email"+ maxLength={EMAIL_MAX_LENGTH}+ value={ctx.email()}+ onInput={(e) => {+ ctx.setEmail(e.currentTarget.value);+ clearError('email');+ }}+ placeholder="[email protected]"+ class={inputClass(!!errors().email)}+ />+ <Show when={errors().email}>+ <p class="text-xs text-failure">{errors().email}</p>+ </Show>+ </div>++ <div class="flex flex-col gap-2">+ <label for="onb-team-name" class="text-sm font-medium text-ink">+ Team name+ </label>+ <input+ id="onb-team-name"+ type="text"+ maxLength={TEAM_NAME_MAX_LENGTH}+ value={ctx.teamName()}+ onInput={(e) => {+ ctx.setTeamName(e.currentTarget.value);+ clearError('teamName');+ }}+ placeholder="Acme Inc."+ class={inputClass(!!errors().teamName)}+ />+ <Show when={errors().teamName}>+ <p class="text-xs text-failure">{errors().teamName}</p>+ </Show>+ </div>+ </div>++ <Show+ when={!isAuthenticated()}+ fallback={+ <Button+ variant="base"+ size="lg"+ onClick={handleContinueAuthed}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Continue+ <ArrowRightIcon class="size-4" />+ </Button>+ }+ >+ <div class="flex flex-col gap-3">+ <Button+ variant="base"+ size="lg"+ onClick={handleGoogleAuth}+ disabled={authPending()}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface [&_svg]:size-6"+ >+ <IconGoogle />+ {authPending() ? 'Redirecting...' : 'Continue with Google'}+ </Button>++ <div class="flex items-center gap-3 text-xs text-ink-extra-muted">+ <div class="h-px flex-1 bg-edge-muted" />+ or+ <div class="h-px flex-1 bg-edge-muted" />+ </div>++ <Button+ variant="base"+ size="lg"+ onClick={handleContinueWithEmail}+ class="w-full focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Continue with email+ <ArrowRightIcon class="size-4" />+ </Button>+ </div>+ </Show>+ </div>+ );+}diff --git a/js/app/packages/app/component/onboarding/steps/team-step.tsx b/js/app/packages/app/component/onboarding/steps/team-step.tsxnew file mode 100644index 0000000000..759cf66e35--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/team-step.tsx@@ -0,0 +1,276 @@+import ArrowRightIcon from '@phosphor/arrow-right.svg';+import CalendarIcon from '@phosphor/calendar-dots.svg';+import PlusIcon from '@phosphor/plus.svg';+import UsersIcon from '@phosphor/users.svg';+import XIcon from '@phosphor/x.svg';+import { Button, cn, Layer } from '@ui';+import { createSignal, Index, Show } from 'solid-js';+import { z } from 'zod';+import type { InvitedMember } from '../onboarding-context';+import { useOnboarding } from '../onboarding-context';++type InviteEntry = { email: string };++const LARGE_TEAM_THRESHOLD = 25;+const CONTACT_SALES_URL = 'https://cal.com/team/macro/macro-demo-call';++export function TeamStep() {+ const ctx = useOnboarding();++ const initialEntries = (): InviteEntry[] => {+ const members = ctx.invitedMembers();+ if (members.length > 0) {+ return members.map((m) => ({ email: m.email }));+ }+ return [{ email: '' }];+ };++ const [entries, setEntries] = createSignal<InviteEntry[]>(initialEntries());+ const [errors, setErrors] = createSignal<Record<number, string>>({});++ const hasValidEmail = () =>+ entries().some(+ (e) =>+ e.email.trim() !== '' && z.string().email().safeParse(e.email).success+ );++ const isLargeTeam = () => entries().length >= LARGE_TEAM_THRESHOLD;++ const emailPlaceholder = () => {+ const email = ctx.email();+ if (!email) return '[email protected]';+ const domain = email.split('@')[1];+ return domain ? `colleague@${domain}` : '[email protected]';+ };++ const syncMembers = (next: InviteEntry[]) => {+ const valid: InvitedMember[] = next+ .filter(+ (e) =>+ e.email.trim() !== '' && z.string().email().safeParse(e.email).success+ )+ .map((e) => ({ email: e.email, tier: 'opus' }));+ ctx.setInvitedMembers(valid);+ };++ const updateEmail = (index: number, value: string) => {+ const next = [...entries()];+ next[index] = { email: value };+ setEntries(next);+ syncMembers(next);+ if (errors()[index]) {+ setErrors((prev) => {+ const copy = { ...prev };+ delete copy[index];+ return copy;+ });+ }+ };++ const removeEntry = (index: number) => {+ const next = entries().filter((_, i) => i !== index);+ setEntries(next);+ syncMembers(next);+ setErrors((prev) => {+ const reindexed: Record<number, string> = {};+ for (const [key, value] of Object.entries(prev)) {+ const k = Number(key);+ if (k < index) reindexed[k] = value;+ else if (k > index) reindexed[k - 1] = value;+ }+ return reindexed;+ });+ };++ const validateOnBlur = (index: number, value: string) => {+ if (value.trim() === '') return;+ const result = z.string().email().safeParse(value);+ if (!result.success) {+ setErrors((prev) => ({ ...prev, [index]: 'Invalid email address' }));+ }+ };++ const addEntry = () => {+ const idx = entries().length;+ setEntries((prev) => [...prev, { email: '' }]);+ requestAnimationFrame(() => {+ document.getElementById(`onb-invite-${idx}`)?.focus();+ });+ };++ const handleContinue = () => {+ const errs: Record<number, string> = {};+ entries().forEach((e, i) => {+ if (e.email.trim() !== '') {+ const result = z.string().email().safeParse(e.email);+ if (!result.success) errs[i] = 'Invalid email address';+ }+ });+ setErrors(errs);+ if (Object.keys(errs).length > 0) return;++ syncMembers(entries());+ ctx.next();+ };++ return (+ <div class="flex flex-col gap-8 w-full">+ <div class="flex flex-col gap-1">+ <h1 class="text-2xl font-semibold text-ink tracking-tight">+ Invite your team+ </h1>+ <p class="text-sm text-ink-disabled">+ Add teammates to{' '}+ <strong class="text-ink font-medium">{ctx.teamName()}</strong>. You+ can always invite more later.+ </p>+ </div>++ <div class="flex flex-col gap-2">+ <Index each={entries()}>+ {(entry, index) => (+ <div class="flex flex-col gap-1">+ <div class="relative">+ <input+ id={`onb-invite-${index}`}+ type="email"+ value={entry().email}+ onInput={(e) => updateEmail(index, e.currentTarget.value)}+ onBlur={(e) => validateOnBlur(index, e.currentTarget.value)}+ placeholder={emailPlaceholder()}+ class={cn(+ 'w-full px-2.5 h-9 pr-9 text-sm rounded-sm border bg-transparent text-ink placeholder:text-ink-placeholder transition-colors',+ 'outline-none focus:ring-2 focus:ring-accent focus:ring-offset-1 focus:ring-offset-surface',+ errors()[index] ? 'border-failure' : 'border-edge-muted'+ )}+ />+ <Show when={entry().email.trim() !== ''}>+ <Button+ variant="ghost"+ size="icon-sm"+ onClick={() =>+ entries().length > 1+ ? removeEntry(index)+ : updateEmail(index, '')+ }+ class="absolute right-1.5 top-1/2 -translate-y-1/2 text-ink-disabled not-disabled:hover:text-ink-muted"+ noTouchResize+ >+ <XIcon class="size-3.5" />+ </Button>+ </Show>+ </div>+ <Show when={errors()[index]}>+ <p class="text-xs text-failure">{errors()[index]}</p>+ </Show>+ </div>+ )}+ </Index>++ <Show+ when={hasValidEmail()}+ fallback={+ <div class="flex flex-col items-center gap-2 py-8 text-center">+ <div class="size-10 rounded-full bg-accent-bg flex items-center justify-center">+ <UsersIcon class="size-5 text-accent" />+ </div>+ <p class="text-sm text-ink-muted">It's quiet in here...</p>+ <p class="text-xs text-ink-disabled">+ Add your first teammate above+ </p>+ </div>+ }+ >+ <Button+ variant="ghost"+ size="sm"+ onClick={addEntry}+ class="self-start"+ >+ <PlusIcon class="size-4" />+ Add another+ </Button>+ </Show>+ </div>++ <div class="flex flex-col gap-2">+ <Show+ when={isLargeTeam()}+ fallback={+ <Show+ when={hasValidEmail()}+ fallback={+ <Button+ variant="base"+ size="lg"+ onClick={() => {+ ctx.setInvitedMembers([]);+ ctx.next();+ }}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Maybe later+ <ArrowRightIcon class="size-4" />+ </Button>+ }+ >+ <Button+ variant="base"+ size="lg"+ onClick={handleContinue}+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ Continue+ <ArrowRightIcon class="size-4" />+ </Button>+ <Button+ variant="ghost"+ size="md"+ onClick={() => {+ ctx.setInvitedMembers([]);+ ctx.next();+ }}+ class="w-full"+ >+ Maybe later+ </Button>+ </Show>+ }+ >+ <Layer depth={1}>+ <div class="rounded-sm border border-edge-muted bg-surface p-3 flex flex-col gap-1">+ <p class="text-sm font-medium text-ink">+ Inviting more than {LARGE_TEAM_THRESHOLD} teammates?+ </p>+ <p class="text-xs text-ink-muted">+ Let's chat — we'll set you up with a custom plan that fits.+ </p>+ </div>+ </Layer>+ <Button+ variant="base"+ size="lg"+ onClick={() =>+ window.open(CONTACT_SALES_URL, '_blank', 'noopener,noreferrer')+ }+ class="w-full bg-accent text-surface border-accent not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface focus-visible:bg-accent focus-visible:text-surface focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface"+ >+ <CalendarIcon class="size-4" />+ Book a call+ </Button>+ <Button+ variant="ghost"+ size="md"+ onClick={() => {+ ctx.setInvitedMembers([]);+ ctx.next();+ }}+ class="w-full"+ >+ Maybe later+ </Button>+ </Show>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/onboarding/steps/verify-step.tsx b/js/app/packages/app/component/onboarding/steps/verify-step.tsxnew file mode 100644index 0000000000..54a1533eda--- /dev/null+++ b/js/app/packages/app/component/onboarding/steps/verify-step.tsx@@ -0,0 +1,218 @@+import { SERVER_HOSTS } from '@core/constant/servers';+import { initAndStartEmailSync } from '@core/email-link';+import { unsetTokenPromise } from '@core/util/fetchWithToken';+import { platformFetch } from '@core/util/platformFetch';+import SpinnerIcon from '@phosphor/spinner.svg';+import { invalidateAllAfterLogin } from '@queries/auth/user-info';+import { authServiceClient } from '@service-auth/client';+import { cn } from '@ui';+import { createSignal, onCleanup, onMount, Show } from 'solid-js';+import { useOnboarding } from '../onboarding-context';++const RESEND_TIMER = 45;++const protocol = import.meta.hot ? 'http' : 'https';+const REDIRECT_URI = `${protocol}://${window.location.host}/app`;++export function VerifyStep() {+ const ctx = useOnboarding();++ const [code, setCode] = createSignal('');+ const [error, setError] = createSignal<string>();+ const [verifying, setVerifying] = createSignal(false);+ const [sending, setSending] = createSignal(false);+ const [resendTimer, setResendTimer] = createSignal(RESEND_TIMER);++ let resendIntervalId: ReturnType<typeof setInterval> | undefined;++ const startTimer = () => {+ if (resendIntervalId) clearInterval(resendIntervalId);+ setResendTimer(RESEND_TIMER);+ resendIntervalId = setInterval(+ () => setResendTimer((t) => (t > 0 ? t - 1 : 0)),+ 1000+ );+ };++ onCleanup(() => {+ if (resendIntervalId) clearInterval(resendIntervalId);+ });++ const sendCode = async () => {+ setSending(true);+ setError(undefined);++ try {+ const url = new URL(window.location.href);+ const referralCode = url.searchParams.get('referral_code');++ const response = await platformFetch(+ `${SERVER_HOSTS['auth-service']}/login/passwordless`,+ {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ redirect_uri: REDIRECT_URI,+ email: ctx.email(),+ ...(referralCode && { referral_code: referralCode }),+ }),+ }+ );++ if (!response.ok) {+ throw new Error(await response.text());+ }++ if (response.status === 202) {+ setError(+ 'This email requires a different sign-in method. Please use Google instead.'+ );+ return;+ }++ startTimer();+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Failed to send code.');+ } finally {+ setSending(false);+ }+ };++ onMount(() => {+ sendCode();+ });++ const handleVerify = async () => {+ const value = code().trim();+ if (value.length !== 6) return;++ setVerifying(true);+ setError(undefined);++ try {+ const result = await authServiceClient.passwordlessCallback({+ code: value,+ email: ctx.email(),+ });++ if (result.isErr()) {+ if (result.error.some((e) => e.code === 'UNAUTHORIZED')) {+ setError('Invalid code. Please try again.');+ } else {+ setError('Verification failed. Please try again.');+ }+ setVerifying(false);+ return;+ }++ unsetTokenPromise();+ await invalidateAllAfterLogin();++ initAndStartEmailSync().match(+ () => {},+ (e) => {+ if (e.tag !== 'AlreadyInitialized') {+ console.error('Failed to init email link after verify', e);+ }+ }+ );++ if (ctx.firstName() || ctx.lastName()) {+ authServiceClient+ .putUserName({+ first_name: ctx.firstName() || undefined,+ last_name: ctx.lastName() || undefined,+ })+ .catch(() => {});+ }++ ctx.next();+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Verification failed.');+ setVerifying(false);+ }+ };++ const handleCodeInput = (value: string) => {+ const digits = value.replace(/\D/g, '').slice(0, 6);+ setCode(digits);+ setError(undefined);++ if (digits.length === 6) {+ handleVerify();+ }+ };++ const canResend = () => !sending() && resendTimer() === 0;++ const inputClass = cn(+ 'w-full px-2.5 h-9 text-sm rounded-sm border bg-transparent text-ink placeholder:text-ink-placeholder transition-colors text-center tracking-widest font-mono',+ 'outline-none focus:ring-2 focus:ring-accent focus:ring-offset-1 focus:ring-offset-surface',+ 'border-edge-muted'+ );++ return (+ <div class="flex flex-col gap-8 w-full">+ <div class="flex flex-col gap-1">+ <h1 class="text-2xl font-semibold text-ink tracking-tight">+ Verify your email+ </h1>+ <p class="text-sm text-ink-disabled">+ <Show when={!sending()} fallback="Sending a code to ">+ We sent a 6-digit code to{' '}+ </Show>+ <strong class="text-ink font-medium">{ctx.email()}</strong>+ </p>+ </div>++ <div class="flex flex-col gap-4">+ <div class="flex flex-col gap-2">+ <label for="onb-otp" class="text-sm font-medium text-ink">+ Verification code+ </label>+ <input+ id="onb-otp"+ type="text"+ inputMode="numeric"+ value={code()}+ onInput={(e) => handleCodeInput(e.currentTarget.value)}+ placeholder="000000"+ disabled={verifying() || sending()}+ class={inputClass}+ autocomplete="one-time-code"+ />+ </div>++ <Show when={error()}>+ <p class="text-xs text-failure text-center">{error()}</p>+ </Show>++ <Show when={verifying()}>+ <div class="flex items-center justify-center gap-2 text-sm text-ink-muted">+ <SpinnerIcon class="size-4 animate-spin" />+ Verifying...+ </div>+ </Show>++ <div class="flex items-center justify-center">+ <button+ type="button"+ tabIndex={0}+ onClick={sendCode}+ disabled={!canResend()}+ class={cn(+ 'text-xs transition-colors outline-none rounded-sm focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface',+ canResend()+ ? 'text-accent hover:text-accent/80'+ : 'text-ink-disabled'+ )}+ >+ <Show when={resendTimer() > 0} fallback="Resend code">+ Resend in {resendTimer()}s+ </Show>+ </button>+ </div>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/paywall/SubscriptionTier.tsx b/js/app/packages/app/component/paywall/SubscriptionTier.tsxindex 97353d096e..f4b5c2aec4 100644--- a/js/app/packages/app/component/paywall/SubscriptionTier.tsx+++ b/js/app/packages/app/component/paywall/SubscriptionTier.tsx@@ -1,3 +1,4 @@+import { LogoProgress } from '@ui';import type { PaidPlanTier } from './plans';interface SubscriptionTierProps {@@ -5,59 +6,15 @@ interface SubscriptionTierProps {class?: string;}-const SubscriptionTier = (props: SubscriptionTierProps) => {- const active1 = () => props.tier === 'opus';- const active2 = () => props.tier === 'opus' || props.tier === 'sonnet';- const active3 = () => !!props.tier;-- return (- <svg- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 24 16"- class={props.class}- display="block"- >- <path- d="m15.578 0.043946-2.2441 0.87891v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l1.041 0.98242 7.0859 6.6973 2.2402-0.87891v-6.6758c0-0.2568-0.10497-0.50153-0.29297-0.67773z"- fill="var(--b4)"- />- <path- d="m6.25 0.041992-2.2422 0.88086v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l1.0391 0.98242 7.084 6.6973 2.2441-0.87891v-6.6758c0-0.2568-0.10302-0.50153-0.29102-0.67773l-1.043-0.98438-7.082-6.6973z"- fill="var(--b4)"- />- <path- d="m2.252 5.083-2.2422 0.87891v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l2.793 2.6406 2.2441-0.87891v-6.6758c0-0.2568-0.10302-0.50153-0.29102-0.67773z"- fill="var(--b4)"- />-- <path- d="m15.578 0.043946-2.2441 0.87891v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l1.041 0.98242 7.0859 6.6973 2.2402-0.87891v-6.6758c0-0.2568-0.10497-0.50153-0.29297-0.67773z"- style={{- transform: `translateY(${active1() ? 0 : 16}px)`,- transition: 'transform 0.3s ease 0.2s',- fill: 'var(--a0)',- }}- />- <path- d="m6.25 0.041992-2.2422 0.88086v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l1.0391 0.98242 7.084 6.6973 2.2441-0.87891v-6.6758c0-0.2568-0.10302-0.50153-0.29102-0.67773l-1.043-0.98438-7.082-6.6973z"- style={{- transform: `translateY(${active2() ? 0 : 16}px)`,- transition: 'transform 0.3s ease 0.1s',- fill: 'var(--a0)',- }}- />- <path- d="m2.252 5.083-2.2422 0.87891v6.6758c0 0.2568 0.10697 0.50329 0.29297 0.67969l2.793 2.6406 2.2441-0.87891v-6.6758c0-0.2568-0.10302-0.50153-0.29102-0.67773z"- style={{- transform: `translateY(${active3() ? 0 : 16}px)`,- transition: 'transform 0.3s ease 0s',- fill: 'var(--a0)',- }}- />+const TIER_TO_LEVEL: Record<PaidPlanTier, number> = {+ haiku: 1,+ sonnet: 2,+ opus: 3,+};- {/*<path fill="var(--b0)" d="m5.3398 9.2617v5.8164l-2.2441 0.87891-2.793-2.6387c-0.186-0.1764-0.29296-0.42289-0.29297-0.67969v3.3613h23.99l-0.0059-0.91992-2.2402 0.87891-7.0859-6.6973v5.8184l-2.2441 0.87891z"/>*/}- </svg>- );+const SubscriptionTier = (props: SubscriptionTierProps) => {+ const level = () => (props.tier ? TIER_TO_LEVEL[props.tier] : 0);+ return <LogoProgress level={level()} total={3} class={props.class} />;};export default SubscriptionTier;diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsxindex 2ccdda3a87..7120e38ebc 100644--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx@@ -3,11 +3,16 @@ import { getViewPreset } from '@app/component/app-sidebar/soup-filter-presets';import type { SetPredicatesInput } from '@app/component/next-soup/filters/filter-store/predicates-store';import type { Query } from '@app/component/next-soup/filters/filter-store/types';import { SoupView } from '@app/component/next-soup/soup-view/soup-view';+import { ShowFeatureFlag } from '@app/lib/analytics/posthog';import { ChannelCompose } from '@block-channel/component/Compose';import { ComposeTask } from '@block-md/component/ComposeTask';import { useIsAuthenticated } from '@core/auth';import { LoadingBlock } from '@core/component/LoadingBlock';-import { DEV_MODE_ENV, LOCAL_ONLY } from '@core/constant/featureFlags';+import {+ DEV_MODE_ENV,+ ENABLE_NEW_ONBOARDING_OVERRIDE,+ LOCAL_ONLY,+} from '@core/constant/featureFlags';import { useUserContext } from '@core/context/user';import type { ViewId } from '@core/types/view';import NotificationRoute from '@notifications/components/NotificationRoute';@@ -298,12 +303,21 @@ registerComponent();registerComponent('settings', () => <SettingsPanelComponentWrapper />);registerComponent('notification', () => <NotificationRoute />);-registerComponent(- 'welcome',- lazy(- () => import('@app/component/interactive-onboarding/InteractiveOnboarding')- )+const NewOnboarding = lazy(+ () => import('@app/component/onboarding/onboarding')+);+const OldOnboarding = lazy(+ () => import('@app/component/interactive-onboarding/InteractiveOnboarding'));+registerComponent('welcome', () => (+ <ShowFeatureFlag+ key="enable-new-onboarding"+ enabledOverride={ENABLE_NEW_ONBOARDING_OVERRIDE}+ fallback={<OldOnboarding />}+ >+ <NewOnboarding />+ </ShowFeatureFlag>+));if (LOCAL_ONLY) {registerComponent(diff --git a/js/app/packages/core/auth/sso.ts b/js/app/packages/core/auth/sso.tsindex f0ea481fe8..a0e1385ab2 100644--- a/js/app/packages/core/auth/sso.ts+++ b/js/app/packages/core/auth/sso.ts@@ -12,6 +12,8 @@ export type StartSsoLoginParams = {idpName?: string;/** Where to redirect after auth on web. Ignored on native mobile. */returnPath?: string;+ /** Pre-fill the email field on the OAuth provider's login screen. */+ loginHint?: string;};/**@@ -30,6 +32,8 @@ export async function startSsoLogin('referral_code');if (referralCode) authUrl.searchParams.set('referral_code', referralCode);+ if (params.loginHint)+ authUrl.searchParams.set('login_hint', params.loginHint);if (isNativeMobilePlatform()) {authUrl.searchParams.set('is_mobile', 'true');diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex 26996e5a55..7ae63a6a5c 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -330,6 +330,8 @@ export function ENABLE_CALLS(): boolean {return analytics.posthog.isFeatureEnabled('enable-calls') ?? false;}+export const ENABLE_NEW_ONBOARDING_OVERRIDE = DEV_MODE_ENV ? true : undefined;+export const ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE = DEV_MODE_ENV? true: undefined;diff --git a/js/app/packages/ui/components/LogoProgress.tsx b/js/app/packages/ui/components/LogoProgress.tsxnew file mode 100644index 0000000000..4a1366f824--- /dev/null+++ b/js/app/packages/ui/components/LogoProgress.tsx@@ -0,0 +1,30 @@+interface LogoProgressProps {+ level: number;+ total: number;+ class?: string;+}++const LOGO_PATH = 'm15.578 0.044-2.244 0.879v6.676c0 0.257 0.107 0.503 0.293 0.68l1.041 0.982 7.086 6.697 2.24-0.879v-6.676c0-0.257-0.105-0.501-0.293-0.678zM6.25 0.042 4.008 0.923v6.676c0 0.257 0.107 0.503 0.293 0.68l1.039 0.982 7.084 6.697 2.244-0.879v-6.676c0-0.257-0.103-0.501-0.291-0.678l-1.043-0.984zM2.252 5.083 0.01 5.962v6.676c0 0.257 0.107 0.503 0.293 0.68l2.793 2.64 2.244-0.879v-6.676c0-0.257-0.103-0.501-0.291-0.678z';++export function LogoProgress(props: LogoProgressProps) {+ const clipRight = () => `${100 - (props.level / props.total) * 100}%`;++ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 16"+ class={props.class}+ display="block"+ >+ <path d={LOGO_PATH} fill="var(--b4)" />+ <path+ d={LOGO_PATH}+ fill="var(--a0)"+ style={{+ 'clip-path': `inset(0 ${clipRight()} 0 0)`,+ transition: 'clip-path 0.3s ease',+ }}+ />+ </svg>+ );+}diff --git a/js/app/packages/ui/components/Stepper.tsx b/js/app/packages/ui/components/Stepper.tsxnew file mode 100644index 0000000000..f651e26c4e--- /dev/null+++ b/js/app/packages/ui/components/Stepper.tsx@@ -0,0 +1,173 @@+import { children, createMemo, type JSX, Show } from 'solid-js';+import { Transition } from 'solid-transition-group';+import { cn } from '../utils/classname';++/*+<Stepper step={step()} transition={Stepper.transitions.slide}>+ <Stepper.Step><IntroStep /></Stepper.Step>+ <Stepper.Step><ProfileStep /></Stepper.Step>+ <Stepper.Step><TeamStep /></Stepper.Step>+ <Stepper.Step><PaymentStep /></Stepper.Step>+</Stepper>+*/++export type StepperTransition = {+ mode?: 'outin' | 'inout'; /* simultaneous if omitted */+ enterActiveClass?: string;+ enterClass?: string;+ enterToClass?: string;+ exitActiveClass?: string;+ exitClass?: string;+ exitToClass?: string;+};++/* Resolver receives 1 for forward navigation, -1 for backward */+export type StepperTransitionResolver = (direction: 1 | -1) => StepperTransition;++export type StepperProps = {+ step: number; /* current step index */+ transition?: StepperTransition | StepperTransitionResolver; /* transition behavior */+ appear?: boolean; /* animate initial mount */+ children: JSX.Element; /* Stepper.Step slots */+ class?: string; /* container classes */+};++export type StepperStepProps = {+ index?: number; /* override position */+ noTransition?: boolean; /* skip enter+exit anim */+ children: JSX.Element; /* step contents (lazy) */+};++const FADE: StepperTransition = {+ mode: 'outin',+ enterActiveClass: 'transition-opacity duration-200 ease-out',+ enterClass: 'opacity-0',+ enterToClass: 'opacity-100',+ exitActiveClass: 'transition-opacity duration-150 ease-in',+ exitClass: 'opacity-100',+ exitToClass: 'opacity-0',+};++const SLIDE: StepperTransitionResolver = (dir) => ({+ enterActiveClass: 'transition-all duration-300 ease-out',+ enterClass: dir === 1 ? 'opacity-0 translate-x-6' : 'opacity-0 -translate-x-6',+ enterToClass: 'opacity-100 translate-x-0',+ exitActiveClass: 'transition-all duration-300 ease-in',+ exitClass: 'opacity-100 translate-x-0',+ exitToClass: dir === 1 ? 'opacity-0 -translate-x-6' : 'opacity-0 translate-x-6',+});++const SLIDE_FULL: StepperTransitionResolver = (dir) => ({+ enterActiveClass: 'transition-transform duration-300 ease-out',+ enterClass: dir === 1 ? 'translate-x-full' : '-translate-x-full',+ enterToClass: 'translate-x-0',+ exitActiveClass: 'transition-transform duration-300 ease-out',+ exitClass: 'translate-x-0',+ exitToClass: dir === 1 ? '-translate-x-full' : 'translate-x-full',+});++const SCALE: StepperTransition = {+ mode: 'outin',+ enterActiveClass: 'transition-all duration-200 ease-out',+ enterClass: 'opacity-0 scale-95',+ enterToClass: 'opacity-100 scale-100',+ exitActiveClass: 'transition-all duration-150 ease-in',+ exitClass: 'opacity-100 scale-100',+ exitToClass: 'opacity-0 scale-95',+};++/* Same trick as solid-js's Match: returning the props object lets the parent+ Stepper read `index`/`children` without evaluating the JSX subtree. Solid's+ JSX compiler keeps `children` as a getter, so it stays lazy until the+ matching step is actually rendered. */+function Step(props: StepperStepProps): JSX.Element {+ return props as unknown as JSX.Element;+}++function StepperRoot(props: StepperProps) {+ const resolved = children(() => props.children);++ const stepList = createMemo(() => {+ const raw = resolved.toArray() as unknown as StepperStepProps[];+ return Array.isArray(raw) ? raw : [raw];+ });++ const activeStep = createMemo(() =>+ stepList().find((step, i) => (step.index ?? i) === props.step)+ );++ /* Track previous step so we can derive direction and decide whether the+ swap should be instant (when either side opts out of animation). Memo ++ closed-over `prev` is the standard "previous value" pattern — idempotent+ because the memo only re-runs when `props.step` changes. */+ const transitionState = (() => {+ let prevIdx = props.step;+ let prevStep = activeStep();+ return createMemo(() => {+ const nextIdx = props.step;+ const nextStep = activeStep();+ const direction: 1 | -1 = nextIdx >= prevIdx ? 1 : -1;+ const instant = !!(prevStep?.noTransition || nextStep?.noTransition);+ prevIdx = nextIdx;+ prevStep = nextStep;+ return { direction, instant };+ });+ })();++ const transition = createMemo<StepperTransition>(() => {+ const t = props.transition;+ if (!t) return FADE;+ return typeof t === 'function' ? t(transitionState().direction) : t;+ });++ const slot = (step: StepperStepProps) => (+ <div class="min-w-0 min-h-0" style={{ 'grid-area': 'stack' }}>+ {step.children}+ </div>+ );++ return (+ <div+ class={cn('grid relative', props.class)}+ style={{+ 'grid-template-areas': '"stack"',+ 'grid-template-columns': 'minmax(0, 1fr)',+ 'grid-template-rows': 'minmax(0, 1fr)',+ }}+ >+ <Show+ when={!transitionState().instant}+ fallback={+ <Show when={activeStep()} keyed>+ {(step) => slot(step)}+ </Show>+ }+ >+ <Transition+ appear={props.appear}+ mode={transition().mode}+ enterActiveClass={transition().enterActiveClass}+ enterClass={transition().enterClass}+ enterToClass={transition().enterToClass}+ exitActiveClass={transition().exitActiveClass}+ exitClass={transition().exitClass}+ exitToClass={transition().exitToClass}+ >+ <Show when={activeStep()} keyed>+ {(step) => slot(step)}+ </Show>+ </Transition>+ </Show>+ </div>+ );+}++export const Stepper = Object.assign(StepperRoot, {+ Step,+ transitions: {+ fade: FADE,+ slide: SLIDE,+ slideFull: SLIDE_FULL,+ scale: SCALE,+ },+});diff --git a/js/app/packages/ui/index.ts b/js/app/packages/ui/index.tsindex fc098660cb..f1dd03c463 100644--- a/js/app/packages/ui/index.ts+++ b/js/app/packages/ui/index.ts@@ -14,6 +14,7 @@ export { Button } from './components/Button';export { Hotkey } from './components/Hotkey';export { Scroll } from './components/Scroll';export { Panel } from './components/Panel';+export { LogoProgress } from './components/LogoProgress';export { Layer } from './components/Layer';/* types */