Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(onboarding): tutorial modal (#3664)

dev-rbb8415ddad851
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index 07f669fcab..8d158a0f0b 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -90,7 +90,6 @@ function LayoutInner(props: RouteSectionProps) {
isAuthenticated() === true &&
!AUTH_URLS.includes(location.pathname)
);
-
useAppSquishHandlers();
// save last_path to cookie
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index d355fbeebc..51fe1ddc29 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -89,6 +89,7 @@ import { setCookie } from './auth/Shared';
import { Signup } from './auth/Signup';
import { makeEmailAuthComponents } from './EmailAuth';
import { GlobalAppStateProvider } from './GlobalAppState';
+import { InteractiveOnboardingModal } from './interactive-onboarding/InteractiveOnboardingModal';
import { Layout } from './Layout';
import { SearchProvider } from './next-soup/search-context';
import { usePendingNotificationNavigationEffect } from './PendingNotificationNavigationEffect';
@@ -445,6 +446,38 @@ function QuerySyncProviderWithUserId() {
return <QuerySyncProvider userId={userId} />;
}
+function InitialInteractiveOnboardingModal() {
+ const userInfoQuery = useUserInfoQuery();
+ const [open, setOpen] = createSignal(true);
+ const [onboardingStarted, setOnboardingStarted] = createSignal(false);
+
+ const modalOpen = () =>
+ open() &&
+ userInfoQuery.data?.authenticated === true &&
+ (userInfoQuery.data.tutorialComplete === false || onboardingStarted());
+
+ createEffect(() => {
+ if (modalOpen()) {
+ setOnboardingStarted(true);
+ }
+ });
+
+ const handleOpenChange = (nextOpen: boolean) => {
+ setOpen(nextOpen);
+ if (!nextOpen) {
+ setOnboardingStarted(false);
+ }
+ };
+
+ return (
+ <InteractiveOnboardingModal
+ open={modalOpen()}
+ isFirstTimeOnboarding
+ onOpenChange={handleOpenChange}
+ />
+ );
+}
+
export function Root() {
setHotkeyRoot(useHotKeyRoot());
@@ -502,6 +535,7 @@ export function Root() {
}}
</IsomorphicRouter>
</Suspense>
+ <InitialInteractiveOnboardingModal />
<ToastRegion />
</SearchProvider>
</QuickAccessProvider>
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index b3bed8b857..82bf9c5bad 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -9,6 +9,7 @@ import {
SidebarPromoHint,
} from '@app/component/app-sidebar/sidebar-promo';
import { CommandState } from '@app/component/command';
+import { InteractiveOnboardingModal } from '@app/component/interactive-onboarding/InteractiveOnboardingModal';
import { createMenuOpen, setCreateMenuOpen } from '@app/component/Launcher';
import { requestSearchFocus } from '@app/component/next-soup/soup-view/search-controllers';
import { useSplitLayout } from '@app/component/split-layout/layout';
@@ -71,6 +72,7 @@ import CaretUpIcon from '@phosphor/caret-up.svg';
import DeviceMobileIcon from '@phosphor/device-mobile-speaker.svg';
import KeyboardIcon from '@phosphor/keyboard.svg';
import PaintBucketIcon from '@phosphor/paint-bucket.svg';
+import PlayIcon from '@phosphor/play.svg';
import PlugIcon from '@phosphor/plug.svg';
import UserIconPhosphor from '@phosphor/user.svg';
import UsersThreeIcon from '@phosphor/users-three.svg';
@@ -645,6 +647,7 @@ type SidebarSettingsWidgetProps = {
const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
const userId = useUserId();
+ const [onboardingModalOpen, setOnboardingModalOpen] = createSignal(false);
const topItems = createMemo(() =>
SETTINGS_MENU_TOP_ITEMS.filter((item) => props.isTabAvailable(item.tab))
@@ -691,6 +694,17 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
<CaretUpIcon class="size-3 text-ink-extra-muted shrink-0 group-data-[slim=true]/sidebar:hidden" />
</Dropdown.Trigger>
<Dropdown.Content>
+ <Dropdown.Group>
+ <Dropdown.Item
+ class="flex items-center gap-2 px-2.5 py-2 text-sm cursor-default outline-none text-ink-muted"
+ onSelect={() => setOnboardingModalOpen(true)}
+ >
+ <span class="size-5 flex items-center justify-center">
+ <PlayIcon class="size-4 shrink-0 text-ink-extra-muted" />
+ </span>
+ <span class="text-ink">Play tutorial</span>
+ </Dropdown.Item>
+ </Dropdown.Group>
<Dropdown.Group>
<For each={topItems()}>
{(item) => (
@@ -728,6 +742,10 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
</For>
</Dropdown.Group>
</Dropdown.Content>
+ <InteractiveOnboardingModal
+ open={onboardingModalOpen()}
+ onOpenChange={setOnboardingModalOpen}
+ />
</Dropdown>
);
};
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
index 4960c0a18a..25aecf0315 100644
--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
@@ -1,199 +1,48 @@
import { useAnalytics } from '@app/component/analytics-context';
import { CommandState } from '@app/component/command';
-import { PLANS } from '@app/component/paywall/plans';
import { useSplitPanel } from '@app/component/split-layout/layoutUtils';
-import { useFeatureFlag } from '@app/lib/analytics/posthog';
-import { useIsAuthenticated } from '@core/auth';
-import { useHasPaidAccess } from '@core/auth/license';
-import MacroLogo from '@core/component/MacroLogo';
-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
-import { toast } from '@core/component/Toast/Toast';
-import { ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE } from '@core/constant/featureFlags';
import { useTutorialCompleted } from '@core/context/user';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { fetchToken } from '@core/util/fetchWithToken';
-import LogoIcon from '@icon/macro-logo.svg';
-import ArrowLeftIcon from '@phosphor/arrow-left.svg';
-import InfoIcon from '@phosphor/info.svg';
-import { useSendMobileWelcomeEmail } from '@queries/auth';
import { useCompleteTutorialMutation } from '@queries/auth/tutorial';
-import { useUserTeamsQuery } from '@queries/team';
import { useLocation, useNavigate } from '@solidjs/router';
-import { Button, cn, Surface, Tooltip } from '@ui';
import {
createEffect,
createMemo,
createSignal,
- For,
+ type JSX,
on,
onCleanup,
onMount,
- Show,
} from 'solid-js';
-import { Dynamic } from 'solid-js/web';
-import { ContinueButton } from './components-lib';
import { createOnboardingState } from './create-onboarding-state';
import { LESSONS } from './lessons';
import { commandKOpen, setCommandKOpen } from './lessons/command-k';
-import MobileWebSignupSent from './MobileWebSignupSent';
-import MobileWebWelcome from './MobileWebWelcome';
-import { OnboardingProgress } from './OnboardingProgress';
-import { OnboardingProvider, useOnboarding } from './onboarding-context';
+import { OnboardingProvider } from './onboarding-context';
import { resetSandbox } from './sandbox/sandbox-store';
-export default function InteractiveOnboarding() {
- const isAuthenticated = useIsAuthenticated();
- const [mobileWebStep, setMobileWebStep] = createSignal<
- 'welcome' | 'signup-sent'
- >('welcome');
- const [submittedEmail, setSubmittedEmail] = createSignal<string | undefined>(
- undefined
- );
- const sendMobileWelcomeEmail = useSendMobileWelcomeEmail();
-
- // Mobile web users who aren't authenticated get a dedicated welcome screen
- // with email signup instead of the full lesson flow.
- const isMobileWeb = isTouchDevice() && !isNativeMobilePlatform();
-
- const handleMobileSignUp = async (email: string) => {
- if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
- toast.failure('Invalid email address.');
- return;
- }
-
- const result = await sendMobileWelcomeEmail.mutateAsync(email);
-
- if (result.isOk()) {
- if (result.value.sent) {
- setSubmittedEmail(email);
- setMobileWebStep('signup-sent');
- } else {
- toast.alert('Email already sent.');
- }
- } else {
- const code = result.error?.[0]?.code;
- if (code === 'RATE_LIMITED') {
- toast.failure('Rate limit exceeded.');
- } else if (code === 'INVALID_EMAIL') {
- toast.failure('Invalid email address.');
- } else {
- toast.failure('Internal error. Please try again.');
- }
- }
- };
-
- return (
- <Show
- when={!isMobileWeb || isAuthenticated() === true}
- fallback={
- <Show
- when={mobileWebStep() === 'welcome'}
- fallback={<MobileWebSignupSent email={submittedEmail()} />}
- >
- <MobileWebWelcome onSignUp={handleMobileSignUp} />
- </Show>
- }
- >
- <OnboardingProvider>
- <InteractiveOnboardingInner />
- </OnboardingProvider>
- </Show>
- );
+interface InteractiveOnboardingProps {
+ onDismiss?: () => void;
+ ignoreTutorialCompleted?: boolean;
+ isFirstTimeOnboarding?: boolean;
+ children: JSX.Element;
}
-function OnboardingCostSummary() {
- const onboarding = useOnboarding();
-
- const selectedPlan = () => {
- const tier = onboarding.selectedPlan();
- return PLANS.find((p) => p.tier === tier);
- };
-
- const teamByTier = () => {
- const groups: Record<
- string,
- { plan: (typeof PLANS)[number]; count: number }
- > = {};
- const order: string[] = [];
- for (const member of onboarding.invitedMembers()) {
- const plan = PLANS.find((p) => p.tier === member.tier);
- if (plan) {
- if (groups[member.tier]) {
- groups[member.tier].count++;
- } else {
- groups[member.tier] = { plan, count: 1 };
- order.push(member.tier);
- }
- }
- }
- return order.map((tier) => groups[tier]);
- };
-
- const hasTeam = () =>
- onboarding.invitedMembers().length > 0 ||
- onboarding.teamName().trim() !== '';
-
+export default function InteractiveOnboarding(
+ props: InteractiveOnboardingProps
+) {
return (
- <Show when={selectedPlan() && selectedPlan()!.price > 0}>
- <div class="px-4 py-3 border-t border-ink/10">
- <div class="flex items-center justify-between">
- <div class="flex items-baseline gap-1">
- <span class="text-3xl font-bold text-accent">
- ${onboarding.userSeatCost()}
- </span>
- <span class="text-ink/40">/mo</span>
- </div>
- <div class="flex items-center gap-1.5 min-w-0 ml-4">
- <Show when={hasTeam() && onboarding.teamName()}>
- <span class="text-xs text-ink/50 truncate max-w-[50ch]">
- {onboarding.teamName()}
- </span>
- <span class="text-ink/30">·</span>
- </Show>
- <span class="px-2 py-0.5 rounded-xs bg-accent/15 text-accent text-xs font-medium shrink-0">
- {hasTeam() ? 'Team plan' : selectedPlan()?.name}
- </span>
- </div>
- </div>
- <Show when={hasTeam()}>
- <div class="flex flex-col gap-1.5 mt-1.5 text-xs text-ink/40">
- <div class="flex justify-between">
- <span>{selectedPlan()?.name}</span>
- <span>${onboarding.userSeatCost()}/mo</span>
- </div>
- <For each={teamByTier()}>
- {(group) => (
- <div class="flex justify-between italic">
- <span>
- Team · {group.plan.name} ×{group.count}
- </span>
- <span class="border-b border-dashed border-ink/40">
- ${group.plan.price * group.count}/mo
- </span>
- </div>
- )}
- </For>
- </div>
- <div class="flex justify-between items-center mt-2 pt-2 border-t border-ink/10 text-xs">
- <span class="text-ink/40 flex items-center gap-1">
- Total with team
- <Tooltip label="Team charges begin when members accept their invite">
- <InfoIcon class="size-3 text-ink/30" />
- </Tooltip>
- </span>
- <span class="text-ink/50 font-medium">
- ${onboarding.totalCost()}/mo
- </span>
- </div>
- </Show>
- </div>
- </Show>
+ <InteractiveOnboardingInner
+ onDismiss={props.onDismiss}
+ ignoreTutorialCompleted={props.ignoreTutorialCompleted}
+ isFirstTimeOnboarding={props.isFirstTimeOnboarding}
+ >
+ {props.children}
+ </InteractiveOnboardingInner>
);
}
-function InteractiveOnboardingInner() {
+function InteractiveOnboardingInner(props: InteractiveOnboardingProps) {
const analytics = useAnalytics();
const splitPanel = useSplitPanel();
@@ -203,46 +52,7 @@ function InteractiveOnboardingInner() {
const isTouch = isTouchDevice();
- const hasPaid = useHasPaidAccess();
- const isAuthenticated = useIsAuthenticated();
- const userTeamsQuery = useUserTeamsQuery();
- const hasExistingTeam = () => (userTeamsQuery.data?.length ?? 0) > 0;
- const inviteTeamEnabled = useFeatureFlag('enable-teams-onboarding', {
- enabledOverride: ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE,
- });
- const allLessons = createMemo(() =>
- LESSONS.filter((l) => {
- if (l.id === 'choose-plan' && hasPaid()) return false;
- if (l.id === 'about-us' && isAuthenticated()) return false;
- // Skip team/payment lessons when feature flag disabled
- if (
- (l.id === 'team-choice' ||
- l.id === 'invite-team' ||
- l.id === 'review-pay') &&
- !inviteTeamEnabled().enabled
- )
- return false;
- // Skip review-pay if user already has subscription
- if (l.id === 'review-pay' && hasPaid()) return false;
- // Skip invite-team if user already has a team
- if (l.id === 'invite-team' && hasExistingTeam()) return false;
- // Skip team-choice if user has both subscription and team
- if (l.id === 'team-choice' && hasPaid() && hasExistingTeam())
- return false;
- return true;
- })
- );
- const lessons = createMemo(() =>
- isTouch
- ? allLessons().filter(
- (l) =>
- l.id === 'welcome' ||
- l.id === 'about-us' ||
- l.id === 'choose-plan' ||
- l.id === 'launch'
- )
- : allLessons()
- );
+ const lessons = createMemo(() => LESSONS);
const testMode = new URLSearchParams(location.search).has('test');
@@ -265,34 +75,24 @@ function InteractiveOnboardingInner() {
// Detect a return-from-external-flow param synchronously so we can pre-populate
// completed lessons before the first render, avoiding a flash of the first slide.
- // Search the unfiltered LESSONS list — the returning lesson (e.g. about-us) may
- // have been filtered out now that the user is authenticated.
- const returningLesson = LESSONS.findLast(
- (l) => l.completeOnParam && params.has(l.completeOnParam)
- );
- const returnCompleted = returningLesson
- ? new Set(
- sortedLessons()
- .filter((l) => (l.order ?? 0) <= (returningLesson.order ?? 0))
- .map((l) => l.id)
- )
- : undefined;
-
+ // Search the unfiltered LESSONS list so return params can still complete
+ // lessons even if the visible lesson list changes.
const state = createOnboardingState({
definitions: lessons,
- initialCompleted: debugCompleted ?? returnCompleted ?? new Set(),
+ initialCompleted: debugCompleted ?? new Set(),
});
const [readyToContinue, setReadyToContinue] = createSignal(false);
const [continueLabel, setContinueLabel] = createSignal<string | undefined>(
undefined
);
- const [lessonKey, setLessonKey] = createSignal(0);
const navigate = useNavigate();
const navigateAway = () => {
- if (splitPanel) {
+ if (props.onDismiss) {
+ props.onDismiss();
+ } else if (splitPanel) {
splitPanel.handle.replace({
next: { type: 'component', id: 'unified-list' },
});
@@ -305,7 +105,7 @@ function InteractiveOnboardingInner() {
// Skip the redirect when returning from external flow — we just marked it
// complete ourselves and still have remaining lessons to show.
createEffect(() => {
- if (tutorialCompleted() && hasPaid() && !returningLesson && !testMode) {
+ if (tutorialCompleted() && !props.ignoreTutorialCompleted && !testMode) {
navigateAway();
}
});
@@ -330,7 +130,7 @@ function InteractiveOnboardingInner() {
};
// Programmatic advance for lessons that progress on their own interaction
- // (e.g. clicking a plan card) rather than the Continue button.
+ // rather than the Continue button.
const advanceLesson = () => {
const current = state.currentLesson();
if (!current) return;
@@ -345,7 +145,24 @@ function InteractiveOnboardingInner() {
state.completeLesson(current.definition.id);
setReadyToContinue(false);
setContinueLabel(undefined);
- setLessonKey((k) => k + 1);
+ };
+
+ const handleSkipLesson = () => {
+ const current = state.currentLesson();
+ if (!current) return;
+
+ analytics.track(
+ `onboarding_step_${current.definition.id.replaceAll('-', '_')}`,
+ {
+ id: current.definition.id,
+ index: current.index,
+ state: 'skipped',
+ }
+ );
+
+ state.skipLesson(current.definition.id);
+ setReadyToContinue(false);
+ setContinueLabel(undefined);
};
const handleContinue = () => {
@@ -361,36 +178,15 @@ function InteractiveOnboardingInner() {
}
);
- if (current.definition.onContinue) {
- // On web this redirects (returns void). On native mobile it resolves
- // with true after inline auth succeeds, so we advance the lesson.
- const result = current.definition.onContinue();
- if (result instanceof Promise) {
- result.then((shouldAdvance) => {
- if (shouldAdvance) {
- state.completeLesson(current.definition.id);
- setReadyToContinue(false);
- setContinueLabel(undefined);
- setLessonKey((k) => k + 1);
- }
- });
- }
- return;
- }
-
state.completeLesson(current.definition.id);
setReadyToContinue(false);
setContinueLabel(undefined);
- setLessonKey((k) => k + 1);
};
- const onboarding = useOnboarding();
-
const getBackContext = () => ({
- onboarding,
isLessonSkipped: (id: string) =>
state.lessons().find((l) => l.definition.id === id)?.skipped ?? false,
- hasPaidAccess: hasPaid(),
+ hasPaidAccess: false,
});
const getPreviousLesson = () => {
@@ -414,34 +210,37 @@ function InteractiveOnboardingInner() {
state.goToLessonById(targetLesson);
};
+ const resetTutorial = () => {
+ state.reset();
+ setReadyToContinue(false);
+ setContinueLabel(undefined);
+ };
+
// cmd+enter hotkey to continue
let shellRef: HTMLDivElement | undefined;
- const [attachHotkeys, scopeId] = useHotkeyDOMScope('onboarding-shell');
+ // Detached so onboarding hotkeys do not bubble up to app/global hotkeys.
+ // Any lesson hotkeys registered with this scope still work while this shell
+ // is focused, but unhandled keys stop at this scope instead of falling back
+ // to the app-level handlers.
+ const [attachHotkeys, scopeId] = useHotkeyDOMScope('onboarding-shell', true);
onMount(() => {
if (shellRef) {
attachHotkeys(shellRef);
shellRef.focus();
- }
- // When returning from an external flow, clean the return param from the URL
- // and run side-effects. The lessons are already pre-completed synchronously.
- if (returningLesson?.completeOnParam) {
- const cleanParams = new URLSearchParams(window.location.search);
- cleanParams.delete(returningLesson.completeOnParam);
- const qs = cleanParams.toString();
- window.history.replaceState(
- null,
- '',
- qs ? `${window.location.pathname}?${qs}` : window.location.pathname
- );
-
- // Ensure the JWT is refreshed before making authenticated API calls.
- // On a fresh page load after OAuth redirect, the session cookie is set
- // but no fetchWithToken call has triggered a token refresh yet.
- if (returningLesson.onCompleteParam) {
- fetchToken().then(() => returningLesson.onCompleteParam!());
- }
+ // Keep raw bubbling keyboard events inside onboarding without blocking
+ // target-level handlers like Lexical's editor input/mentions handling.
+ // App-level hotkeys are handled separately by the detached hotkey scope.
+ const stopKeyboardPropagation = (event: KeyboardEvent) => {
+ event.stopPropagation();
+ };
+ shellRef.addEventListener('keydown', stopKeyboardPropagation);
+ shellRef.addEventListener('keyup', stopKeyboardPropagation);
+ onCleanup(() => {
+ shellRef?.removeEventListener('keydown', stopKeyboardPropagation);
+ shellRef?.removeEventListener('keyup', stopKeyboardPropagation);
+ });
}
});
@@ -510,26 +309,15 @@ function InteractiveOnboardingInner() {
})
);
- // Mark tutorial complete on the backend the moment the user lands on the
- // Launch screen — the semantic end of the onboarding experience. Guarded so
- // the effect fires the mutation at most once.
- let tutorialMarkedComplete = false;
- createEffect(() => {
- if (testMode || tutorialMarkedComplete) return;
- const current = state.currentLesson();
- if (current?.definition.id === 'launch') {
- tutorialMarkedComplete = true;
- completeTutorial.mutate(undefined);
- }
- });
-
createEffect(
on(
() => state.isFinished(),
(finished) => {
if (finished && !testMode) {
- analytics.track('onboarding_completed');
- navigateAway();
+ if (props.isFirstTimeOnboarding) {
+ analytics.track('onboarding_completed');
+ completeTutorial.mutate(undefined);
+ }
}
}
)
@@ -538,12 +326,7 @@ function InteractiveOnboardingInner() {
onMount(() => {
if (state.currentIndex() > 0) return;
- analytics.track('onboarding_start', {
- source:
- params.get('mobile_welcome_email') === 'true'
- ? 'mobile_welcome_email'
- : undefined,
- });
+ analytics.track('onboarding_start');
});
createEffect(
@@ -573,301 +356,57 @@ function InteractiveOnboardingInner() {
)
);
- const bodyStyle = () => ({
- animation: `onboarding-fade-up 300ms ease-out both`,
- '--onboarding-key': String(lessonKey()),
- });
+ const setContinueButtonRef = (el: HTMLButtonElement) => {
+ continueButtonRef = el;
+ };
- const headerStyle = () => ({
- animation: `onboarding-fade-up 200ms ease-out both`,
- '--onboarding-key': String(lessonKey()),
- });
+ const contextValue = {
+ state,
+ scopeId,
+ testMode,
+ readyToContinue,
+ continueLabel,
+ setContinueButtonRef,
+ handleLessonComplete,
+ handleLessonUnready,
+ advanceLesson,
+ handleSkipLesson,
+ handleContinue,
+ resetTutorial,
+ getPreviousLesson,
+ handleBack,
+ };
return (
- <div
- ref={shellRef}
- class="flex items-center justify-center size-full p-6 sm:p-8 overflow-hidden relative"
- tabIndex={-1}
- >
- {/* Scoped keyframes */}
- <style>{
- /*css*/ `
- @keyframes onboarding-fade-up {
- from { opacity: 0; transform: translateY(8px); }
- to { opacity: 1; transform: translateY(0); }
- }
- @keyframes onboarding-scale-in {
- from { opacity: 0; transform: scale(0.92); }
- to { opacity: 1; transform: scale(1); }
- }
- .onboarding-stagger > * {
- animation: onboarding-fade-up 300ms ease-out both;
- }
- .onboarding-stagger > *:nth-child(1) { animation-delay: 50ms; }
- .onboarding-stagger > *:nth-child(2) { animation-delay: 120ms; }
- .onboarding-stagger > *:nth-child(3) { animation-delay: 190ms; }
- .onboarding-stagger > *:nth-child(4) { animation-delay: 260ms; }
- .onboarding-stagger > *:nth-child(5) { animation-delay: 330ms; }
- `
- }</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>
-
- {/* Centered card */}
- <div class="size-full max-w-400 max-h-225">
- <Surface depth={1}>
- <div class="size-full flex">
- <Show
- when={state.currentLesson()}
- fallback={
- <Show when={testMode && state.isFinished()}>
- <div
- class="flex flex-col items-center justify-center w-full gap-4"
- style={{
- animation: 'onboarding-scale-in 300ms ease-out both',
- }}
- >
- <p class="text-sm text-ink/60">All lessons complete.</p>
- <button
- type="button"
- class="px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent/80 transition-colors"
- onClick={() => window.location.reload()}
- >
- Replay
- </button>
- </div>
- </Show>
- }
- >
- {(lesson) => (
- <Show
- when={!isTouch}
- fallback={
- /* Touch layout — single vertical column */
- <div class="size-full flex flex-col items-center overflow-y-auto p-6">
- <div
- style={bodyStyle()}
- class="flex flex-col items-start text-left gap-6 w-full max-w-md mt-4"
- >
- <Show
- when={
- lesson().definition.id === 'welcome' ||
- lesson().definition.id === 'launch'
- }
- >
- <LogoIcon class="size-16 text-accent self-center" />
- </Show>
- <h2 class="text-3xl font-semibold text-ink">
- {lesson().definition.title}
- </h2>
- <Show when={lesson().definition.subtitle}>
- <p class="text-base text-ink/60">
- {lesson().definition.subtitle}
- </p>
- </Show>
- <div class="onboarding-stagger">
- <Dynamic
- component={lesson().definition.content}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- </div>
- <Show when={lesson().definition.demo}>
- {(Demo) => (
- <div class="w-full">
- <Dynamic
- component={Demo()}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- </div>
- )}
- </Show>
- <Show when={!lesson().definition.hideContinue}>
- <div class="w-full flex flex-col gap-2 mt-2">
- <ContinueButton
- ref={(el) => {
- continueButtonRef = el;
- }}
- onClick={handleContinue}
- label={continueLabel()}
- disabled={!readyToContinue()}
- centered={lesson().definition.centeredButton}
- />
- <Show when={lesson().definition.secondaryAction}>
- {(Action) => (
- <Dynamic
- component={Action()}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- )}
- </Show>
- </div>
- </Show>
- </div>
- </div>
- }
- >
- {/* Left panel — text content (~1/3) */}
- <div class="w-1/3 h-full min-w-0 flex flex-col border-r border-edge-muted">
- {/* Header */}
- <div class="p-4">
- <div style={headerStyle()}>
- <div class="bg-ink text-surface text-xs font-mono size-4 flex items-center justify-center font-bold rounded-xs">
- {lesson().index + 1}
- </div>
- <Show when={getPreviousLesson()}>
- {(prevLesson) => (
- <Button
- variant="ghost"
- size="sm"
- onClick={() => handleBack(prevLesson())}
- class="mt-6 gap-1.5 rounded-xs"
- >
- <ArrowLeftIcon class="size-4" />
- Back
- </Button>
- )}
- </Show>
- <h2
- class={cn(
- 'text-3xl font-semibold text-ink-muted',
- getPreviousLesson() ? 'mt-4' : 'mt-12'
- )}
- >
- {lesson().definition.title}
- </h2>
- </div>
- </div>
-
- {/* Body */}
- <div class="flex-1 overflow-y-auto px-4 flex flex-col">
- <div style={bodyStyle()}>
- <Show when={lesson().definition.subtitle}>
- <p class="text-sm text-ink/60 mb-4">
- {lesson().definition.subtitle}
- </p>
- </Show>
- <Dynamic
- component={lesson().definition.content}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- </div>
- <Show when={!lesson().definition.hideContinue}>
- <div class="mt-8 pt-4 flex flex-col gap-2">
- <ContinueButton
- ref={(el) => {
- continueButtonRef = el;
- }}
- onClick={handleContinue}
- label={continueLabel()}
- disabled={!readyToContinue()}
- centered={lesson().definition.centeredButton}
- />
- <Show when={lesson().definition.secondaryAction}>
- {(Action) => (
- <Dynamic
- component={Action()}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- )}
- </Show>
- </div>
- </Show>
- </div>
-
- {/* Cost Summary */}
- <Show when={lesson().definition.id !== 'review-pay'}>
- <OnboardingCostSummary />
- </Show>
-
- {/* Footer */}
- <div class="flex flex-col gap-3 px-4 py-3 border-t border-ink/10">
- <div class="flex items-center justify-between gap-2">
- <OnboardingProgress
- lessons={[...state.lessons()]}
- currentIndex={state.currentIndex()}
- />
- <span class="text-xs text-ink-extra-muted/50 font-mono">
- {state.currentIndex() + 1} / {state.lessons().length}
- </span>
- </div>
- </div>
- </div>
-
- {/* Right panel — demo (~2/3) */}
- <div class="flex-1 min-w-0 flex items-center justify-center bg-surface-secondary/30 overflow-hidden">
- <div style={bodyStyle()} class="size-full">
- <Show
- when={lesson().definition.demo}
- fallback={
- <div class="flex items-center justify-center h-full">
- <div class="w-full m-12 opacity-10 max-w-80">
- <MacroLogo class="fill-ink" />
- </div>
- </div>
- }
- >
- {(Demo) => (
- <Dynamic
- component={Demo()}
- onComplete={handleLessonComplete}
- onUnready={handleLessonUnready}
- advance={advanceLesson}
- skipLesson={state.skipLesson}
- goToLesson={state.goToLessonById}
- isActive={true}
- scopeId={scopeId}
- />
- )}
- </Show>
- </div>
- </div>
- </Show>
- )}
- </Show>
- </div>
- </Surface>
+ <OnboardingProvider value={contextValue}>
+ <div
+ ref={shellRef}
+ class="flex items-center justify-center size-full p-3 sm:p-4 overflow-hidden relative"
+ tabIndex={-1}
+ >
+ <style>{
+ /*css*/ `
+ @keyframes onboarding-fade-up {
+ from { opacity: 0; transform: translateY(8px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+ @keyframes onboarding-scale-in {
+ from { opacity: 0; transform: scale(0.92); }
+ to { opacity: 1; transform: scale(1); }
+ }
+ .onboarding-stagger > * {
+ animation: onboarding-fade-up 300ms ease-out both;
+ }
+ .onboarding-stagger > *:nth-child(1) { animation-delay: 50ms; }
+ .onboarding-stagger > *:nth-child(2) { animation-delay: 120ms; }
+ .onboarding-stagger > *:nth-child(3) { animation-delay: 190ms; }
+ .onboarding-stagger > *:nth-child(4) { animation-delay: 260ms; }
+ .onboarding-stagger > *:nth-child(5) { animation-delay: 330ms; }
+ `
+ }</style>
+
+ <div class="size-full max-w-400 max-h-225 flex">{props.children}</div>
</div>
- </div>
+ </OnboardingProvider>
);
}
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx
new file mode 100644
index 0000000000..7a7c76cd82
--- /dev/null
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx
@@ -0,0 +1,326 @@
+import MacroLogo from '@core/component/MacroLogo';
+import { isMobile } from '@core/mobile/isMobile';
+import LogoIcon from '@icon/macro-logo.svg';
+import ArrowRightIcon from '@phosphor/arrow-right.svg';
+import CloseIcon from '@phosphor/x.svg';
+import { useCompleteTutorialMutation } from '@queries/auth/tutorial';
+import { Button, Dialog, Hotkey } from '@ui';
+import { type Component, createSignal, Match, Show, Switch } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import InteractiveOnboarding from './InteractiveOnboarding';
+import { OnboardingProgress } from './OnboardingProgress';
+import { useOnboarding } from './onboarding-context';
+import type { LessonContentProps, LessonState } from './types';
+
+interface InteractiveOnboardingModalProps {
+ open?: boolean;
+ defaultOpen?: boolean;
+ isFirstTimeOnboarding?: boolean;
+ onOpenChange?: (open: boolean) => void;
+}
+
+function LessonContent(props: {
+ lesson: LessonState;
+ component: Component<LessonContentProps>;
+}) {
+ const onboarding = useOnboarding();
+
+ return (
+ <Dynamic
+ component={props.component}
+ onComplete={onboarding.handleLessonComplete}
+ onUnready={onboarding.handleLessonUnready}
+ advance={onboarding.advanceLesson}
+ skipLesson={onboarding.state.skipLesson}
+ goToLesson={onboarding.state.goToLessonById}
+ isActive={true}
+ scopeId={onboarding.scopeId}
+ />
+ );
+}
+
+function DemoFallback() {
+ return (
+ <div class="flex items-center justify-center h-full">
+ <div class="w-full m-12 opacity-10 max-w-80">
+ <MacroLogo class="fill-ink" />
+ </div>
+ </div>
+ );
+}
+
+type ModalPhase = 'start' | 'lessons' | 'end';
+
+function ModalHeader() {
+ return (
+ <div class="shrink-0 flex items-center justify-between gap-4">
+ <Dialog.CloseButton
+ as={Button}
+ variant="ghost"
+ size="icon-sm"
+ class="ml-auto"
+ >
+ <CloseIcon class="size-4" />
+ </Dialog.CloseButton>
+ </div>
+ );
+}
+
+function StartScreen(props: { onStart: () => void; onSkip: () => void }) {
+ return (
+ <div class="flex-1 flex items-center justify-center px-6">
+ <div class="max-w-2xl flex flex-col items-center text-center gap-5 onboarding-stagger">
+ <LogoIcon class="size-16 text-accent" />
+ <Show
+ when={!isMobile()}
+ fallback={
+ <>
+ <div class="flex flex-col gap-2">
+ <h3 class="text-3xl font-semibold text-ink">
+ Tutorial unavailable on mobile
+ </h3>
+ <p class="text-base text-ink/60 text-balance">
+ Try the tutorial on web for the best interactive experience.
+ </p>
+ </div>
+ <div class="w-full max-w-xs flex flex-col gap-2 pt-2">
+ <Button variant="cta" size="lg" onClick={props.onSkip}>
+ Continue
+ <ArrowRightIcon />
+ </Button>
+ </div>
+ </>
+ }
+ >
+ <div class="flex flex-col gap-2">
+ <h3 class="text-3xl font-semibold text-ink">Welcome to Macro</h3>
+ <p class="text-base text-ink/60 text-balance">
+ Take a quick tour of Macro’s core features.
+ </p>
+ </div>
+ <div class="w-full max-w-xs flex flex-col gap-2 pt-2">
+ <Button variant="cta" size="lg" onClick={props.onStart}>
+ Play tutorial
+ <ArrowRightIcon />
+ </Button>
+ <Button variant="ghost" size="lg" onClick={props.onSkip}>
+ Skip tutorial
+ </Button>
+ </div>
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+function EndScreen(props: { onFinish: () => void; onReplay: () => void }) {
+ return (
+ <div class="flex-1 flex items-center justify-center px-6">
+ <div class="max-w-xl flex flex-col items-center text-center gap-5 onboarding-stagger">
+ <LogoIcon class="size-16 text-accent" />
+ <div class="flex flex-col gap-2">
+ <h3 class="text-3xl font-semibold text-ink">You’re ready to go</h3>
+ <p class="text-base text-ink/60 text-balance">
+ You can revisit these lessons anytime if you want a refresher.
+ </p>
+ </div>
+ <div class="w-full max-w-xs flex flex-col gap-2 pt-2">
+ <Button variant="cta" size="lg" onClick={props.onFinish}>
+ Let’s go
+ <ArrowRightIcon />
+ </Button>
+ <Button variant="ghost" size="lg" onClick={props.onReplay}>
+ Replay tutorial
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function ModalFooter(props: { lesson: LessonState }) {
+ const onboarding = useOnboarding();
+
+ return (
+ <footer class="shrink-0 px-4 pt-3 pb-0 bg-surface flex items-center justify-between gap-4">
+ <div class="flex items-center gap-3 min-w-0">
+ <OnboardingProgress
+ lessons={[...onboarding.state.lessons()]}
+ currentIndex={onboarding.state.currentIndex()}
+ />
+ <span class="text-xs text-ink-extra-muted/50 font-mono shrink-0">
+ {onboarding.state.currentIndex() + 1} /{' '}
+ {onboarding.state.lessons().length}
+ </span>
+ </div>
+
+ <Show when={!props.lesson.definition.hideContinue}>
+ <div class="flex items-center justify-end gap-2 shrink-0">
+ <Button
+ variant="ghost"
+ size="lg"
+ onClick={onboarding.handleSkipLesson}
+ >
+ Skip lesson
+ </Button>
+ <Button
+ ref={onboarding.setContinueButtonRef}
+ variant="cta"
+ size="lg"
+ onClick={onboarding.handleContinue}
+ disabled={!onboarding.readyToContinue()}
+ >
+ {onboarding.continueLabel() ?? 'Continue'}
+ <Hotkey shortcut="cmd+enter" />
+ </Button>
+ </div>
+ </Show>
+ </footer>
+ );
+}
+
+function LessonsScreen(props: { onFinish: () => void; onReplay: () => void }) {
+ const onboarding = useOnboarding();
+ const lesson = () => onboarding.state.currentLesson();
+ const bodyStyle = () => ({
+ animation: 'onboarding-fade-up 300ms ease-out both',
+ });
+
+ return (
+ <Show
+ when={lesson()}
+ fallback={
+ <EndScreen onFinish={props.onFinish} onReplay={props.onReplay} />
+ }
+ >
+ {(currentLesson) => (
+ <>
+ <div class="flex-1 min-h-0 flex gap-12">
+ <aside class="w-105 shrink-0 flex flex-col">
+ <div class="flex-1 overflow-y-auto p-4">
+ <div style={bodyStyle()}>
+ <div class="bg-ink text-surface text-xs font-mono size-4 flex items-center justify-center font-bold rounded-xs mb-8">
+ {currentLesson().index + 1}
+ </div>
+ <h3 class="text-3xl font-semibold text-ink-muted">
+ {currentLesson().definition.title}
+ </h3>
+ <Show when={currentLesson().definition.subtitle}>
+ <p class="text-sm text-ink/60 mt-4">
+ {currentLesson().definition.subtitle}
+ </p>
+ </Show>
+ <div class="mt-5">
+ <LessonContent
+ lesson={currentLesson()}
+ component={currentLesson().definition.content}
+ />
+ </div>
+ </div>
+ </div>
+ </aside>
+
+ <main class="flex-1 min-w-0 flex flex-col bg-surface-secondary/30">
+ <div class="flex-1 min-h-0 overflow-hidden">
+ <div style={bodyStyle()} class="size-full">
+ <Show
+ when={currentLesson().definition.demo}
+ fallback={<DemoFallback />}
+ >
+ {(Demo) => (
+ <LessonContent
+ lesson={currentLesson()}
+ component={Demo()}
+ />
+ )}
+ </Show>
+ </div>
+ </div>
+ </main>
+ </div>
+ <ModalFooter lesson={currentLesson()} />
+ </>
+ )}
+ </Show>
+ );
+}
+
+function InteractiveOnboardingModalLayout(props: {
+ isFirstTimeOnboarding: boolean;
+ onClose: () => void;
+}) {
+ const [phase, setPhase] = createSignal<ModalPhase>('start');
+ const completeTutorial = useCompleteTutorialMutation();
+ const onboarding = useOnboarding();
+
+ const handleSkip = () => {
+ if (props.isFirstTimeOnboarding) {
+ completeTutorial.mutate(undefined);
+ }
+ setPhase('end');
+ };
+
+ const handleReplay = () => {
+ onboarding.resetTutorial();
+ setPhase('lessons');
+ };
+
+ return (
+ <div class="size-full flex flex-col gap-4 bg-surface text-ink">
+ <ModalHeader />
+ <Switch>
+ <Match when={phase() === 'start'}>
+ <StartScreen
+ onStart={() => setPhase('lessons')}
+ onSkip={handleSkip}
+ />
+ </Match>
+ <Match when={phase() === 'end' || onboarding.state.isFinished()}>
+ <EndScreen onFinish={props.onClose} onReplay={handleReplay} />
+ </Match>
+ <Match when={true}>
+ <LessonsScreen onFinish={props.onClose} onReplay={handleReplay} />
+ </Match>
+ </Switch>
+ </div>
+ );
+}
+
+export function InteractiveOnboardingModal(
+ props: InteractiveOnboardingModalProps
+) {
+ const [internalOpen, setInternalOpen] = createSignal(
+ props.defaultOpen ?? false
+ );
+
+ const open = () => props.open ?? internalOpen();
+
+ const setOpen = (nextOpen: boolean) => {
+ setInternalOpen(nextOpen);
+ props.onOpenChange?.(nextOpen);
+ };
+
+ return (
+ <Dialog
+ open={open()}
+ onOpenChange={setOpen}
+ position="center"
+ class="w-[min(1600px,calc(100vw-32px))] h-[min(900px,calc(100vh-32px))] max-w-none rounded-xl bg-surface shadow-2xl"
+ >
+ <div class="relative size-full overflow-hidden rounded-xl flex flex-col">
+ <Show when={open()}>
+ <InteractiveOnboarding
+ onDismiss={() => setOpen(false)}
+ ignoreTutorialCompleted
+ isFirstTimeOnboarding={props.isFirstTimeOnboarding}
+ >
+ <InteractiveOnboardingModalLayout
+ isFirstTimeOnboarding={props.isFirstTimeOnboarding === true}
+ onClose={() => setOpen(false)}
+ />
+ </InteractiveOnboarding>
+ </Show>
+ </div>
+ </Dialog>
+ );
+}
diff --git a/js/app/packages/app/component/interactive-onboarding/OnboardingLesson.tsx b/js/app/packages/app/component/interactive-onboarding/OnboardingLesson.tsx
new file mode 100644
index 0000000000..29b1e987be
--- /dev/null
+++ b/js/app/packages/app/component/interactive-onboarding/OnboardingLesson.tsx
@@ -0,0 +1,285 @@
+import MacroLogo from '@core/component/MacroLogo';
+import ArrowLeftIcon from '@phosphor/arrow-left.svg';
+import { Button, cn } from '@ui';
+import { type Accessor, type Component, type JSX, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import { ContinueButton } from './components-lib';
+import { OnboardingProgress } from './OnboardingProgress';
+import { useOnboarding } from './onboarding-context';
+import type { LessonContentProps, LessonState } from './types';
+
+interface LessonProps {
+ lesson: LessonState;
+}
+
+interface LessonStyleProps extends LessonProps {
+ bodyStyle: Accessor<JSX.CSSProperties>;
+}
+
+interface LessonActionsProps extends LessonProps {
+ continueLabel: Accessor<string | undefined>;
+}
+
+export function OnboardingLessonContent(props: {
+ lesson: LessonState;
+ component: Component<LessonContentProps>;
+}) {
+ const onboarding = useOnboarding();
+
+ return (
+ <Dynamic
+ component={props.component}
+ onComplete={onboarding.handleLessonComplete}
+ onUnready={onboarding.handleLessonUnready}
+ advance={onboarding.advanceLesson}
+ skipLesson={onboarding.state.skipLesson}
+ goToLesson={onboarding.state.goToLessonById}
+ isActive={true}
+ scopeId={onboarding.scopeId}
+ />
+ );
+}
+
+export function OnboardingLessonActions(props: LessonActionsProps) {
+ const onboarding = useOnboarding();
+
+ return (
+ <Show when={!props.lesson.definition.hideContinue}>
+ <div class="flex flex-col gap-2">
+ <ContinueButton
+ ref={onboarding.setContinueButtonRef}
+ onClick={onboarding.handleContinue}
+ label={props.continueLabel()}
+ disabled={!onboarding.readyToContinue()}
+ centered={props.lesson.definition.centeredButton}
+ />
+ <Show when={props.lesson.definition.secondaryAction}>
+ {(Action) => (
+ <OnboardingLessonContent
+ lesson={props.lesson}
+ component={Action()}
+ />
+ )}
+ </Show>
+ <button
+ type="button"
+ onClick={onboarding.handleSkipLesson}
+ class={cn(
+ 'w-full px-3 py-2.5 text-lg font-bold rounded-xs flex items-center gap-2 border-none bg-transparent text-ink/60 hover:bg-hover ring-1 ring-edge-muted',
+ props.lesson.definition.centeredButton
+ ? 'justify-center'
+ : 'justify-between'
+ )}
+ >
+ Skip lesson
+ </button>
+ </div>
+ </Show>
+ );
+}
+
+export function OnboardingLessonTitle(props: LessonProps) {
+ return <>{props.lesson.definition.title}</>;
+}
+
+export function OnboardingLessonSubtitle(
+ props: LessonProps & { class: string }
+) {
+ return (
+ <Show when={props.lesson.definition.subtitle}>
+ <p class={props.class}>{props.lesson.definition.subtitle}</p>
+ </Show>
+ );
+}
+
+export function OnboardingDesktopHeader(
+ props: LessonProps & { headerStyle: Accessor<JSX.CSSProperties> }
+) {
+ const onboarding = useOnboarding();
+ const previousLesson = () => onboarding.getPreviousLesson();
+
+ return (
+ <div class="p-4">
+ <div style={props.headerStyle()}>
+ <div class="bg-ink text-surface text-xs font-mono size-4 flex items-center justify-center font-bold rounded-xs">
+ {props.lesson.index + 1}
+ </div>
+ <Show when={previousLesson()}>
+ {(prevLesson) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => onboarding.handleBack(prevLesson())}
+ class="mt-6 gap-1.5 rounded-xs"
+ >
+ <ArrowLeftIcon class="size-4" />
+ Back
+ </Button>
+ )}
+ </Show>
+ <h2
+ class={cn(
+ 'text-3xl font-semibold text-ink-muted',
+ previousLesson() ? 'mt-4' : 'mt-12'
+ )}
+ >
+ <OnboardingLessonTitle lesson={props.lesson} />
+ </h2>
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingLessonBody(props: LessonStyleProps) {
+ return (
+ <div style={props.bodyStyle()}>
+ <OnboardingLessonSubtitle
+ lesson={props.lesson}
+ class="text-sm text-ink/60 mb-4"
+ />
+ <OnboardingLessonContent
+ lesson={props.lesson}
+ component={props.lesson.definition.content}
+ />
+ </div>
+ );
+}
+
+export function OnboardingLessonFooter() {
+ const onboarding = useOnboarding();
+
+ return (
+ <div class="flex flex-col gap-3 px-4 py-3">
+ <div class="flex items-center justify-between gap-2">
+ <OnboardingProgress
+ lessons={[...onboarding.state.lessons()]}
+ currentIndex={onboarding.state.currentIndex()}
+ />
+ <span class="text-xs text-ink-extra-muted/50 font-mono">
+ {onboarding.state.currentIndex() + 1} /{' '}
+ {onboarding.state.lessons().length}
+ </span>
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingDemoFallback() {
+ return (
+ <div class="flex items-center justify-center h-full">
+ <div class="w-full m-12 opacity-10 max-w-80">
+ <MacroLogo class="fill-ink" />
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingDemoPanel(props: LessonStyleProps) {
+ return (
+ <div class="flex-1 min-w-0 flex items-center justify-center bg-surface-secondary/30 overflow-hidden">
+ <div style={props.bodyStyle()} class="size-full">
+ <Show
+ when={props.lesson.definition.demo}
+ fallback={<OnboardingDemoFallback />}
+ >
+ {(Demo) => (
+ <OnboardingLessonContent lesson={props.lesson} component={Demo()} />
+ )}
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingDesktopSidebar(
+ props: LessonStyleProps & {
+ headerStyle: Accessor<JSX.CSSProperties>;
+ continueLabel: Accessor<string | undefined>;
+ }
+) {
+ return (
+ <div class="w-1/3 h-full min-w-0 flex flex-col">
+ <OnboardingDesktopHeader
+ lesson={props.lesson}
+ headerStyle={props.headerStyle}
+ />
+
+ <div class="flex-1 overflow-y-auto px-4 flex flex-col">
+ <OnboardingLessonBody
+ lesson={props.lesson}
+ bodyStyle={props.bodyStyle}
+ />
+ <div class="mt-8 pt-4">
+ <OnboardingLessonActions
+ lesson={props.lesson}
+ continueLabel={props.continueLabel}
+ />
+ </div>
+ </div>
+
+ <OnboardingLessonFooter />
+ </div>
+ );
+}
+
+export function OnboardingMobileLesson(
+ props: LessonStyleProps & { continueLabel: Accessor<string | undefined> }
+) {
+ return (
+ <div class="size-full flex flex-col items-center overflow-y-auto p-6">
+ <div
+ style={props.bodyStyle()}
+ class="flex flex-col items-start text-left gap-6 w-full max-w-md mt-4"
+ >
+ <h2 class="text-3xl font-semibold text-ink">
+ <OnboardingLessonTitle lesson={props.lesson} />
+ </h2>
+ <OnboardingLessonSubtitle
+ lesson={props.lesson}
+ class="text-base text-ink/60"
+ />
+ <div class="onboarding-stagger">
+ <OnboardingLessonContent
+ lesson={props.lesson}
+ component={props.lesson.definition.content}
+ />
+ </div>
+ <Show when={props.lesson.definition.demo}>
+ {(Demo) => (
+ <div class="w-full">
+ <OnboardingLessonContent
+ lesson={props.lesson}
+ component={Demo()}
+ />
+ </div>
+ )}
+ </Show>
+ <div class="w-full mt-2">
+ <OnboardingLessonActions
+ lesson={props.lesson}
+ continueLabel={props.continueLabel}
+ />
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingDesktopLesson(
+ props: LessonStyleProps & {
+ headerStyle: Accessor<JSX.CSSProperties>;
+ continueLabel: Accessor<string | undefined>;
+ }
+) {
+ return (
+ <>
+ <OnboardingDesktopSidebar
+ lesson={props.lesson}
+ bodyStyle={props.bodyStyle}
+ headerStyle={props.headerStyle}
+ continueLabel={props.continueLabel}
+ />
+ <OnboardingDemoPanel lesson={props.lesson} bodyStyle={props.bodyStyle} />
+ </>
+ );
+}
diff --git a/js/app/packages/app/component/interactive-onboarding/OnboardingModalLayout.tsx b/js/app/packages/app/component/interactive-onboarding/OnboardingModalLayout.tsx
new file mode 100644
index 0000000000..566c200eea
--- /dev/null
+++ b/js/app/packages/app/component/interactive-onboarding/OnboardingModalLayout.tsx
@@ -0,0 +1,127 @@
+import MacroLogo from '@core/component/MacroLogo';
+import { Button, Hotkey } from '@ui';
+import { type Component, type JSX, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import { OnboardingProgress } from './OnboardingProgress';
+import { useOnboarding } from './onboarding-context';
+import type { LessonContentProps, LessonState } from './types';
+
+interface OnboardingModalLayoutProps {
+ lesson: LessonState;
+ bodyStyle: () => JSX.CSSProperties;
+}
+
+function LessonContent(props: {
+ lesson: LessonState;
+ component: Component<LessonContentProps>;
+}) {
+ const onboarding = useOnboarding();
+
+ return (
+ <Dynamic
+ component={props.component}
+ onComplete={onboarding.handleLessonComplete}
+ onUnready={onboarding.handleLessonUnready}
+ advance={onboarding.advanceLesson}
+ skipLesson={onboarding.state.skipLesson}
+ goToLesson={onboarding.state.goToLessonById}
+ isActive={true}
+ scopeId={onboarding.scopeId}
+ />
+ );
+}
+
+function ModalFooter(props: { lesson: LessonState }) {
+ const onboarding = useOnboarding();
+
+ return (
+ <footer class="shrink-0 px-4 pt-3 pb-0 bg-surface flex items-center justify-between gap-4">
+ <div class="flex items-center gap-3 min-w-0">
+ <OnboardingProgress
+ lessons={[...onboarding.state.lessons()]}
+ currentIndex={onboarding.state.currentIndex()}
+ />
+ <span class="text-xs text-ink-extra-muted/50 font-mono shrink-0">
+ {onboarding.state.currentIndex() + 1} /{' '}
+ {onboarding.state.lessons().length}
+ </span>
+ </div>
+
+ <Show when={!props.lesson.definition.hideContinue}>
+ <div class="flex items-center justify-end gap-2 shrink-0">
+ <Button
+ variant="base"
+ // size="lg"
+ onClick={onboarding.handleSkipLesson}
+ >
+ Skip lesson
+ </Button>
+ <Button
+ ref={onboarding.setContinueButtonRef}
+ variant="cta"
+ // size="lg"
+ onClick={onboarding.handleContinue}
+ disabled={!onboarding.readyToContinue()}
+ >
+ {onboarding.continueLabel() ?? 'Continue'}
+ <Hotkey shortcut="cmd+enter" theme="current" />
+ </Button>
+ </div>
+ </Show>
+ </footer>
+ );
+}
+
+function DemoFallback() {
+ return (
+ <div class="flex items-center justify-center h-full">
+ <div class="w-full m-12 opacity-10 max-w-80">
+ <MacroLogo class="fill-ink" />
+ </div>
+ </div>
+ );
+}
+
+export function OnboardingModalLayout(props: OnboardingModalLayoutProps) {
+ return (
+ <div class="size-full flex flex-col bg-surface text-ink">
+ <div class="flex-1 min-h-0 flex gap-12">
+ <aside class="w-105 shrink-0 flex flex-col">
+ <div class="flex-1 overflow-y-auto px-4 py-4">
+ <div style={props.bodyStyle()}>
+ <h3 class="text-3xl font-semibold text-ink">
+ {props.lesson.definition.title}
+ </h3>
+ <Show when={props.lesson.definition.subtitle}>
+ <p class="text-sm text-ink/60 mt-2 mb-4">
+ {props.lesson.definition.subtitle}
+ </p>
+ </Show>
+
+ <LessonContent
+ lesson={props.lesson}
+ component={props.lesson.definition.content}
+ />
+ </div>
+ </div>
+ </aside>
+
+ <main class="flex-1 min-w-0 flex flex-col bg-surface-secondary/30">
+ <div class="flex-1 min-h-0 overflow-hidden">
+ <div style={props.bodyStyle()} class="size-full">
+ <Show
+ when={props.lesson.definition.demo}
+ fallback={<DemoFallback />}
+ >
+ {(Demo) => (
+ <LessonContent lesson={props.lesson} component={Demo()} />
+ )}
+ </Show>
+ </div>
+ </div>
+ </main>
+ </div>
+ <ModalFooter lesson={props.lesson} />
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx b/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
index 36405249d1..e151b76319 100644
--- a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
@@ -1,5 +1,5 @@
import CheckIcon from '@phosphor/check.svg';
-import { cn } from '@ui';
+import { cn, Layer } from '@ui';
import {
type Component,
createSignal,
@@ -20,16 +20,18 @@ interface CalloutShellProps {
function CalloutShell(props: CalloutShellProps) {
return (
- <div class="flex items-center gap-3 rounded-xs bg-hover/50 px-4 py-3 border border-edge-muted">
- <span class="text-sm text-muted">{props.leader}</span>
- <div class="flex items-center gap-2.5">{props.children}</div>
- <span class="text-sm text-muted">{props.label}</span>
- <Show when={props.completed}>
- <div class="bg-accent text-surface size-5 rounded xs flex items-center justify-center ml-auto">
- <CheckIcon class="size-4" />
- </div>
- </Show>
- </div>
+ <Layer depth={2}>
+ <div class="flex items-center gap-3 rounded-md bg-surface px-4 py-3 border border-edge-muted">
+ <span class="text-sm text-muted">{props.leader}</span>
+ <div class="flex items-center gap-2.5">{props.children}</div>
+ <span class="text-sm text-muted">{props.label}</span>
+ <Show when={props.completed}>
+ <div class="bg-accent text-surface size-5 rounded-xs flex items-center justify-center ml-auto">
+ <CheckIcon class="size-4" />
+ </div>
+ </Show>
+ </div>
+ </Layer>
);
}
@@ -109,8 +111,8 @@ export function HotkeyCallout(props: HotkeyCalloutProps) {
<CalloutShell leader="Type" label={props.label} completed={props.completed}>
<style>{`
@keyframes hotkey-pulse {
- 0% { outline: 2px solid rgb(from var(--color-edge) r g b / 0.3); outline-offset: 0px; }
- 100% { outline: 2px solid rgb(from var(--color-edge) r g b / 0); outline-offset: 10px; }
+ 0% { outline: 2px solid rgb(from var(--color-accent) r g b / 0.8); outline-offset: 0px; }
+ 100% { outline: 2px solid rgb(from var(--color-accent) r g b / 0); outline-offset: 10px; }
}
.hotkey-pulsing {
animation: hotkey-pulse 1.4s cubic-bezier(0.2, 0.8, 0.4, 1);
@@ -156,7 +158,7 @@ export function HotkeyCallout(props: HotkeyCalloutProps) {
class={cn(
'inline-grid place-items-center rounded-sm border px-2.5 py-1 text-base',
isPressed() || props.completed
- ? 'bg-ink/20 border-edge text-ink'
+ ? 'bg-accent/20 border-accent text-accent shadow-[0_0_0_1px_rgb(from_var(--color-accent)_r_g_b_/_0.35)]'
: 'bg-ink/10 border-edge text-ink'
)}
>
diff --git a/js/app/packages/app/component/interactive-onboarding/components/MockAppChrome.tsx b/js/app/packages/app/component/interactive-onboarding/components/MockAppChrome.tsx
index 4a5c2a07d9..b5fcf4317e 100644
--- a/js/app/packages/app/component/interactive-onboarding/components/MockAppChrome.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/components/MockAppChrome.tsx
@@ -85,6 +85,8 @@ interface MockAppChromeProps {
onCreateClick?: () => void;
/** When true, glows the create button until it's clicked for the first time. */
highlightCreate?: boolean;
+ /** Scope to bind mock app hotkeys into. Defaults to global for legacy use. */
+ scopeId?: string;
}
export function MockAppChrome(props: MockAppChromeProps) {
@@ -127,20 +129,28 @@ export function MockAppChrome(props: MockAppChromeProps) {
const group = createHotkeyGroup();
onMount(() => {
- registerHotkey({
+ const leaderRegistration = registerHotkey({
hotkey: GO_TO_LEADER_KEY,
- scopeId: 'global',
+ scopeId: props.scopeId ?? 'global',
description: 'Go to page',
keyDownHandler: () => false,
- activateCommandScopeId: GO_TO_COMMAND_SCOPE,
hide: true,
registrationType: 'add',
+ ...(props.scopeId
+ ? { activateCommandScope: true as const }
+ : { activateCommandScopeId: GO_TO_COMMAND_SCOPE }),
}).withGroup(group);
+ const commandScopeId = props.scopeId
+ ? leaderRegistration.commandScopeId
+ : GO_TO_COMMAND_SCOPE;
+
+ if (!commandScopeId) return;
+
for (const link of MOCK_SIDEBAR_LINKS) {
registerHotkey({
hotkey: link.hotkey as ValidHotkey,
- scopeId: GO_TO_COMMAND_SCOPE,
+ scopeId: commandScopeId,
description: `Go to ${link.label}`,
keyDownHandler: () => {
setFilter(link.id as SandboxSidebarFilter);
diff --git a/js/app/packages/app/component/interactive-onboarding/create-onboarding-state.ts b/js/app/packages/app/component/interactive-onboarding/create-onboarding-state.ts
index be52b471f6..2959308b08 100644
--- a/js/app/packages/app/component/interactive-onboarding/create-onboarding-state.ts
+++ b/js/app/packages/app/component/interactive-onboarding/create-onboarding-state.ts
@@ -95,6 +95,13 @@ export function createOnboardingState(options: OnboardingStateOptions) {
}
};
+ const reset = () => {
+ for (let i = 0; i < store.length; i++) {
+ setStore(i, 'skipped', false);
+ setStore(i, 'completed', false);
+ }
+ };
+
const dismiss = () => {
setDismissed(true);
};
@@ -110,6 +117,7 @@ export function createOnboardingState(options: OnboardingStateOptions) {
advanceToNext,
goToLesson,
goToLessonById,
+ reset,
dismiss,
};
}
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsx
deleted file mode 100644
index 2f96a74a94..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
-// Singleton is correct here — onContinue/onCompleteParam are plain callbacks outside Solid context.
-import { analytics } from '@app/lib/analytics/analytics';
-import { startSsoLogin } from '@core/auth/sso';
-import { initAndStartEmailSync } from '@core/email-link';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { isTauri } from '@core/util/platform';
-import EyeSlash from '@phosphor-icons/core/regular/eye-slash.svg?component-solid';
-import UsersThree from '@phosphor-icons/core/regular/users-three.svg?component-solid';
-import type { JSX } from 'solid-js';
-import { For, onMount } from 'solid-js';
-import type { LessonContentProps, LessonDefinition } from '../types';
-
-function AboutUsContent(props: LessonContentProps) {
- onMount(() => {
- setTimeout(() => props.onComplete('Connect with Google'));
- });
-
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>
- Macro connects to your calendar and inbox for our AI, email client, and
- unified inbox features. We will never share your data or send emails
- without your explicit permission.
- </p>
- </div>
- );
-}
-
-const PANELS: { icon: () => JSX.Element; label: string }[] = [
- {
- icon: () => (
- <svg
- viewBox="0 0 48 48"
- fill="none"
- class="size-12 text-accent"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M24 4L6 12v12c0 11.1 7.7 21.5 18 24 10.3-2.5 18-12.9 18-24V12L24 4z"
- fill="currentColor"
- opacity="0.15"
- />
- <path
- d="M24 4L6 12v12c0 11.1 7.7 21.5 18 24 10.3-2.5 18-12.9 18-24V12L24 4z"
- stroke="currentColor"
- stroke-width="2.5"
- stroke-linejoin="round"
- fill="none"
- />
- <path
- d="M17 24l5 5 9-10"
- stroke="currentColor"
- stroke-width="2.5"
- stroke-linecap="round"
- stroke-linejoin="round"
- />
- </svg>
- ),
- label: 'SOC 2 certified and pen tested',
- },
- {
- icon: () => <EyeSlash class="size-12 text-accent" />,
- label: 'Your data is never used to train AI models',
- },
- {
- icon: () => <UsersThree class="size-12 text-accent" />,
- label: 'Trusted by over 200k users',
- },
-];
-
-function AboutUsDemo() {
- return (
- <div class="size-full flex items-center justify-center px-8">
- <div
- class="w-full max-w-2xl items-start"
- classList={{
- 'flex flex-col gap-3': isTouchDevice(),
- 'flex gap-4': !isTouchDevice(),
- }}
- >
- <For each={PANELS}>
- {(panel) => (
- <div class="flex-1 w-full flex flex-col">
- <div class="border border-edge-muted bg-surface rounded-xs overflow-hidden">
- <div class="p-6 flex flex-col items-center gap-4 text-center">
- {panel.icon()}
- <p class="text-sm text-ink/70 font-medium">{panel.label}</p>
- </div>
- </div>
- </div>
- )}
- </For>
- </div>
- </div>
- );
-}
-
-export const aboutUsLesson: LessonDefinition = {
- id: 'about-us',
- title: 'Security and privacy',
- content: AboutUsContent,
- centeredButton: true,
- demo: AboutUsDemo,
- order: 60,
- onContinue: async () => {
- analytics.track('sign_up', { method: 'google' }, [
- 'ga',
- 'meta-pixel',
- 'posthog',
- ]);
-
- const success = await startSsoLogin({
- returnPath: `${ROUTER_BASE_CONCAT}welcome?google=1`,
- });
- // On web, startSsoLogin redirects and never resolves.
- // On native mobile, auth completes inline. Reload the page with the
- // return param so it goes through the normal completeOnParam flow —
- // this avoids Suspense blanking the screen when auth state changes.
- if (success) {
- // Reload into the completeOnParam flow. Tauri uses HashRouter so the
- // route + query must go inside the hash fragment.
- if (isTauri()) {
- window.location.hash = '#/welcome?google=1';
- window.location.reload();
- } else {
- window.location.href = `${window.location.origin}${ROUTER_BASE_CONCAT}welcome?google=1`;
- }
- }
- // Never resolves — page reloads (native) or redirects (web).
- return new Promise<boolean>(() => {});
- },
- completeOnParam: 'google',
- onCompleteParam: () =>
- initAndStartEmailSync().match(
- () => {
- analytics.track('email_authorized');
- return true;
- },
- (e) => {
- if (e.tag === 'AlreadyInitialized') {
- analytics.track('email_authorized');
- return true;
- }
- analytics.track('email_unauthorized');
- console.error('Failed to init email link after Google auth', e);
- return false;
- }
- ),
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
deleted file mode 100644
index 00a8157fb1..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
+++ /dev/null
@@ -1,146 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import { PlanGrid } from '@app/component/paywall/PlanGrid';
-import type { PaidPlanTier, PlanTier } from '@app/component/paywall/plans';
-import { useFeatureFlag } from '@app/lib/analytics/posthog';
-import { useIsAuthenticated } from '@core/auth';
-import { toast } from '@core/component/Toast/Toast';
-import { ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE } from '@core/constant/featureFlags';
-import CheckIcon from '@phosphor/check.svg';
-import SpinnerIcon from '@phosphor/spinner.svg';
-import { createSignal, onMount, Show } from 'solid-js';
-import { useOnboarding } from '../onboarding-context';
-import type { LessonContentProps, LessonDefinition } from '../types';
-import { useOnboardingCheckoutMutation } from '../use-onboarding-checkout';
-
-function ChoosePlanContent(props: LessonContentProps) {
- onMount(() => props.onComplete());
-
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>Pick the plan that matches how you want to use Macro.</p>
- </div>
- );
-}
-
-function ChoosePlanDemo(props: LessonContentProps) {
- const { selectedPlan, setSelectedPlan } = useOnboarding();
- const analytics = useAnalytics();
- const isAuthenticated = useIsAuthenticated();
- const [isRedirecting, setIsRedirecting] = createSignal(false);
-
- const inviteTeamEnabled = useFeatureFlag('enable-teams-onboarding', {
- enabledOverride: ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE,
- });
-
- // Returns to /welcome?subscriptionSuccess=true on success, which completes
- // all lessons except launch, landing the user on the launch lesson.
- const checkoutMutation = useOnboardingCheckoutMutation({
- onSuccess: (result) => {
- analytics.track('subscription_start', {
- type: selectedPlan(),
- seats: 1,
- });
- 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 handleSelectPlan = (tier: PlanTier) => {
- if (isPending()) return;
-
- setSelectedPlan(tier);
-
- if (tier === 'free') {
- // Free bypasses Stripe, so fire subscription_success directly here to
- // stay symmetric with the paid path (which fires it on Stripe return
- // via Root.tsx's ?subscriptionSuccess handler).
- analytics.track('subscription_success', { type: tier });
- props.skipLesson('team-choice');
- props.skipLesson('invite-team');
- props.skipLesson('review-pay');
- props.advance();
- return;
- }
-
- // When teams feature is disabled, go directly to checkout
- if (!inviteTeamEnabled().enabled) {
- if (!isAuthenticated()) {
- props.goToLesson('about-us');
- return;
- }
-
- props.skipLesson('team-choice');
- props.skipLesson('invite-team');
- props.skipLesson('review-pay');
-
- checkoutMutation.mutate({ tier: tier as PaidPlanTier });
- return;
- }
-
- props.advance();
- };
-
- return (
- <div class="size-full flex items-center justify-center px-8">
- <PlanGrid
- footer={(plan) => (
- <button
- type="button"
- onClick={(e) => {
- e.stopPropagation();
- handleSelectPlan(plan.tier);
- }}
- disabled={isPending()}
- class="w-full py-2 rounded-xs text-base font-semibold flex items-center justify-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed"
- classList={{
- 'bg-accent text-surface':
- plan.highlighted && selectedPlan() !== plan.tier,
- 'bg-accent/20 text-accent': selectedPlan() === plan.tier,
- 'bg-ink/8 text-ink hover:bg-ink/12':
- selectedPlan() !== plan.tier && !plan.highlighted,
- }}
- >
- <Show
- when={isPending() && selectedPlan() === plan.tier}
- fallback={
- <>
- <Show
- when={selectedPlan() === plan.tier && plan.tier !== 'free'}
- >
- <CheckIcon class="size-4" />
- </Show>
- {plan.tier === 'free'
- ? 'Start free'
- : selectedPlan() === plan.tier
- ? 'Selected'
- : 'Select'}
- </>
- }
- >
- <SpinnerIcon class="size-4 animate-spin" />
- Redirecting…
- </Show>
- </button>
- )}
- />
- </div>
- );
-}
-
-export const choosePlanLesson: LessonDefinition = {
- id: 'choose-plan',
- title: 'Choose your plan',
- content: ChoosePlanContent,
- demo: ChoosePlanDemo,
- order: 80,
- hideContinue: true,
- completeOnParam: 'subscriptionSuccess',
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/command-k.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/command-k.tsx
index 01ad89b07f..abcf6d71fe 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/command-k.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/command-k.tsx
@@ -42,29 +42,29 @@ const CATEGORY_TO_BUCKETS: Record<CategoryFilter, string[] | null> = {
function CommandKContent(_props: LessonContentProps) {
return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>
+ <div class="flex flex-col gap-8 onboarding-stagger">
+ <p class="text-ink-muted mt-2">
The Command Menu allows you to search for documents, tasks, channels,
and more — and navigate to them instantly.
</p>
- <div class="mt-2">
+ <div class="flex flex-col gap-3">
<HotkeyCallout
keys={[IS_MAC ? '⌘' : 'Ctrl', 'K']}
separator="+"
label=""
completed={completed()}
/>
+ <div class="flex items-center gap-3 text-sm text-ink/40">
+ <div class="h-px w-8 bg-edge-muted" />
+ or
+ <div class="h-px flex-1 bg-edge-muted" />
+ </div>
+ <ClickCallout
+ icon={AnimatedCommandIcon}
+ label="in the sidebar (bottom)"
+ completed={completed()}
+ />
</div>
- <div class="flex items-center gap-3 text-sm text-ink/40">
- <div class="h-px w-8 bg-edge-muted" />
- or
- <div class="h-px flex-1 bg-edge-muted" />
- </div>
- <ClickCallout
- icon={AnimatedCommandIcon}
- label="in the sidebar (bottom)"
- completed={completed()}
- />
</div>
);
}
@@ -149,6 +149,7 @@ function CommandKDemo(props: LessonContentProps) {
<MockAppChrome
onCommandClick={() => setCommandKOpen((v) => !v)}
highlightCommand
+ scopeId={props.scopeId}
>
<OnboardingEntityList soup={soup} />
</MockAppChrome>
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/create-entity.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/create-entity.tsx
index c527fe5ca5..4698eee812 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/create-entity.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/create-entity.tsx
@@ -106,25 +106,25 @@ function CreateEntityContent(props: LessonContentProps) {
<div
ref={containerRef}
tabIndex={0}
- class="flex flex-col gap-3 outline-none onboarding-stagger"
+ class="flex flex-col gap-8 outline-none onboarding-stagger"
>
- <p>
+ <p class="mt-2">
The <strong>Create Launcher</strong> lets you create Macro Editor
quickly, from anywhere.
</p>
- <div class="mt-2">
+ <div class="flex flex-col gap-3">
<HotkeyCallout keys={['C']} label="" completed={completed()} />
+ <div class="flex items-center gap-3 text-sm text-ink/40">
+ <div class="h-px w-8 bg-edge-muted" />
+ or
+ <div class="h-px flex-1 bg-edge-muted" />
+ </div>
+ <ClickCallout
+ icon={AnimatedPlusIcon}
+ label="in the sidebar"
+ completed={completed()}
+ />
</div>
- <div class="flex items-center gap-3 text-sm text-ink/40">
- <div class="h-px w-8 bg-edge-muted" />
- or
- <div class="h-px flex-1 bg-edge-muted" />
- </div>
- <ClickCallout
- icon={AnimatedPlusIcon}
- label="in the sidebar"
- completed={completed()}
- />
</div>
);
}
@@ -175,6 +175,7 @@ function CreateEntityDemo(props: LessonContentProps) {
<MockAppChrome
onCreateClick={() => setLauncherOpen((v) => !v)}
highlightCreate
+ scopeId={props.scopeId}
>
<Show when={sharedSoup()}>
{(s) => <OnboardingEntityList soup={s()} />}
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/index.ts b/js/app/packages/app/component/interactive-onboarding/lessons/index.ts
index 00eea31630..fa1358152c 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/index.ts
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/index.ts
@@ -1,28 +1,14 @@
import type { LessonDefinition } from '../types';
// import { composersPreviewLesson } from './composers-preview';
-import { aboutUsLesson } from './about-us';
-import { choosePlanLesson } from './choose-plan';
import { commandKLesson } from './command-k';
import { createEntityLesson } from './create-entity';
-import { inviteTeamLesson } from './invite-team';
-import { launchLesson } from './launch';
import { markdownMentionsLesson } from './markdown-mentions';
-import { reviewPayLesson } from './review-pay';
import { sidebarNavLesson } from './sidebar-nav';
-import { teamChoiceLesson } from './team-choice';
-import { welcomeLesson } from './welcome';
export const LESSONS: LessonDefinition[] = [
- welcomeLesson,
sidebarNavLesson,
- commandKLesson,
createEntityLesson,
+ commandKLesson,
markdownMentionsLesson,
// composersPreviewLesson,
- aboutUsLesson,
- choosePlanLesson,
- teamChoiceLesson,
- inviteTeamLesson,
- reviewPayLesson,
- launchLesson,
];
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx
deleted file mode 100644
index 77728e2a86..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx
+++ /dev/null
@@ -1,421 +0,0 @@
-import type { PaidPlanTier } from '@app/component/paywall/plans';
-import { TierSelect } from '@app/component/teams/TierSelect';
-import { useFeatureFlag } from '@app/lib/analytics/posthog';
-import { ENABLE_TEAM_INVITE_TIERS_OVERRIDE } from '@core/constant/featureFlags';
-import { useEmail } from '@core/context/user';
-import CheckIcon from '@phosphor/check.svg';
-import PlusIcon from '@phosphor/plus.svg';
-import TrashIcon from '@phosphor/trash-simple.svg';
-import XIcon from '@phosphor/x.svg';
-import { cn, Tooltip } from '@ui';
-import { createMemo, createSignal, Index, onMount, Show } from 'solid-js';
-import { z } from 'zod';
-import { useOnboarding } from '../onboarding-context';
-import type { LessonContentProps, LessonDefinition } from '../types';
-
-const inviteFormSchema = z.object({
- teamName: z
- .string()
- .min(1, 'Team name is required')
- .max(50, 'Team name is too long'),
- emails: z
- .array(z.string())
- .transform((emails) => emails.filter((e) => e.trim() !== ''))
- .pipe(z.array(z.string().email('Invalid email address'))),
-});
-
-const INVITE_FORM_ID = 'invite-team-form';
-const TEAM_NAME_MAX_LENGTH = 50;
-
-function InviteTeamContent() {
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>Your team gets:</p>
- <div class="flex flex-col gap-2">
- <div class="flex items-start gap-2">
- <CheckIcon class="size-4 text-accent shrink-0 mt-0.5" />
- <span class="text-sm text-ink/70">
- Shared calls and tasks across your team
- </span>
- </div>
- <div class="flex items-start gap-2">
- <CheckIcon class="size-4 text-accent shrink-0 mt-0.5" />
- <span class="text-sm text-ink/70">Unified team AI memory</span>
- </div>
- <div class="flex items-start gap-2">
- <CheckIcon class="size-4 text-accent shrink-0 mt-0.5" />
- <span class="text-sm text-ink/70">Add or remove members anytime</span>
- </div>
- </div>
- </div>
- );
-}
-
-type FormErrors = {
- teamName?: string;
- emails?: Record<number, string | undefined>;
-};
-
-type InviteEntry = { email: string; tier: PaidPlanTier };
-
-function InviteTeamDemo(props: LessonContentProps) {
- const onboarding = useOnboarding();
- const tierFlag = useFeatureFlag('enable-team-invite-tiers', {
- enabledOverride: ENABLE_TEAM_INVITE_TIERS_OVERRIDE,
- });
- const showTier = () => tierFlag().enabled;
-
- const initialEntries = (): InviteEntry[] => {
- const members = onboarding.invitedMembers();
- if (members.length > 0) {
- return members
- .filter((m) => m.tier !== 'free')
- .map((m) => ({ email: m.email, tier: m.tier as PaidPlanTier }));
- }
- return [{ email: '', tier: 'haiku' }];
- };
-
- const [teamName, setTeamName] = createSignal(onboarding.teamName());
- const [inviteEntries, setInviteEntries] = createSignal<InviteEntry[]>(
- initialEntries()
- );
- const [errors, setErrors] = createSignal<FormErrors>({});
-
- const emails = () => inviteEntries().map((e) => e.email);
-
- const syncInvitedMembers = (entries: InviteEntry[]) => {
- const validMembers = entries
- .filter(
- (e) =>
- e.email.trim() !== '' && z.string().email().safeParse(e.email).success
- )
- .map((entry) => ({ email: entry.email, tier: entry.tier }));
- onboarding.setInvitedMembers(validMembers);
- };
-
- const userEmail = useEmail();
-
- const emailPlaceholder = createMemo(() => {
- const email = userEmail();
- if (!email) return '[email protected]';
- const domain = email.split('@')[1];
- return domain ? `colleague@${domain}` : '[email protected]';
- });
-
- const isValid = () => {
- const trimmed = teamName().trim();
- return trimmed.length >= 1 && trimmed.length <= TEAM_NAME_MAX_LENGTH;
- };
-
- const charCountColor = () => {
- const len = teamName().length;
- if (len > TEAM_NAME_MAX_LENGTH) return 'text-failure-ink';
- if (len > TEAM_NAME_MAX_LENGTH - 10) return 'text-alert-ink';
- return 'text-ink/40';
- };
-
- const updateReadyState = () => {
- if (isValid()) {
- props.onComplete('Continue', { skipFocus: true });
- } else {
- props.onUnready();
- }
- };
-
- onMount(() => {
- queueMicrotask(updateReadyState);
- });
-
- const canAddEmail = () => {
- const entries = inviteEntries();
- if (entries.length === 0) {
- return true;
- }
- const lastEntry = entries[entries.length - 1];
- return lastEntry?.email.trim() !== '';
- };
-
- const addEmailField = () => {
- if (!canAddEmail()) return;
- const newIndex = inviteEntries().length;
- setInviteEntries((prev) => [...prev, { email: '', tier: 'haiku' }]);
- requestAnimationFrame(() => {
- const input = document.getElementById(`invite-email-${newIndex}`);
- input?.focus();
- });
- };
-
- const updateEmail = (index: number, value: string) => {
- const next = [...inviteEntries()];
- next[index] = { ...next[index], email: value };
- setInviteEntries(next);
- syncInvitedMembers(next);
- if (errors().emails?.[index]) {
- setErrors((prev) => {
- const emailErrors = { ...prev.emails };
- delete emailErrors[index];
- return { ...prev, emails: emailErrors };
- });
- }
- };
-
- const updateTier = (index: number, tier: PaidPlanTier) => {
- const next = [...inviteEntries()];
- next[index] = { ...next[index], tier };
- setInviteEntries(next);
- syncInvitedMembers(next);
- };
-
- const updateTeamName = (value: string) => {
- setTeamName(value);
- onboarding.setTeamName(value);
- if (errors().teamName) {
- setErrors((prev) => ({ ...prev, teamName: undefined }));
- }
- const trimmed = value.trim();
- if (trimmed.length >= 1 && trimmed.length <= TEAM_NAME_MAX_LENGTH) {
- props.onComplete('Continue', { skipFocus: true });
- } else {
- props.onUnready();
- }
- };
-
- const removeEmail = (index: number) => {
- const next = inviteEntries().filter((_, i) => i !== index);
- setInviteEntries(next);
- syncInvitedMembers(next);
- setErrors((prev) => {
- const emailErrors = { ...prev.emails };
- delete emailErrors[index];
- return { ...prev, emails: emailErrors };
- });
- };
-
- const validateField = (
- field: 'teamName' | 'email',
- index: number,
- value: string
- ) => {
- if (field === 'teamName') {
- const result = z
- .string()
- .min(1, 'Team name is required')
- .max(50, 'Team name is too long')
- .safeParse(value);
- setErrors((prev) => ({
- ...prev,
- teamName: result.success ? undefined : result.error.issues[0]?.message,
- }));
- } else if (field === 'email' && value.trim() !== '') {
- const result = z.string().email('Invalid email address').safeParse(value);
- setErrors((prev) => ({
- ...prev,
- emails: {
- ...prev.emails,
- [index]: result.success ? undefined : result.error.issues[0]?.message,
- },
- }));
- }
- };
-
- const handleSubmit = (e: SubmitEvent) => {
- e.preventDefault();
-
- const result = inviteFormSchema.safeParse({
- teamName: teamName(),
- emails: emails(),
- });
-
- if (!result.success) {
- const newErrors: FormErrors = {};
- for (const error of result.error.issues) {
- if (error.path[0] === 'teamName') {
- newErrors.teamName = error.message;
- } else if (
- error.path[0] === 'emails' &&
- typeof error.path[1] === 'number'
- ) {
- newErrors.emails = newErrors.emails || {};
- newErrors.emails[error.path[1]] = error.message;
- }
- }
- setErrors(newErrors);
- return;
- }
-
- setErrors({});
- props.advance();
- };
-
- return (
- <div class="size-full flex items-start justify-center p-12 pt-[12%] overflow-hidden">
- <form
- id={INVITE_FORM_ID}
- onSubmit={handleSubmit}
- class="w-full max-w-md flex flex-col gap-6"
- >
- <div class="flex flex-col gap-2 shrink-0 px-2">
- <label class="text-base font-medium text-ink" for="team-name">
- Team name
- </label>
- <input
- id="team-name"
- type="text"
- value={teamName()}
- onInput={(e) => updateTeamName(e.currentTarget.value)}
- onBlur={() => validateField('teamName', 0, teamName())}
- placeholder="Enter your team name"
- disabled={false}
- aria-describedby="team-name-counter"
- class={cn(
- 'w-[calc(100%-36px)] px-3 py-2 text-base rounded-xs border bg-surface text-ink placeholder:text-ink/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-surface',
- errors().teamName
- ? 'border-failure focus-visible:ring-failure'
- : 'border-edge focus-visible:ring-accent',
- false
- )}
- />
- <div class="flex justify-between items-center w-[calc(100%-36px)]">
- <Show when={errors().teamName}>
- <p class="text-sm text-failure-ink" role="alert">
- {errors().teamName}
- </p>
- </Show>
- <p
- id="team-name-counter"
- class={cn('text-sm ml-auto', charCountColor())}
- >
- {teamName().length}/{TEAM_NAME_MAX_LENGTH}
- </p>
- </div>
- </div>
-
- <div class="flex flex-col gap-2 min-h-0 flex-1 overflow-hidden pb-4">
- <div class="shrink-0 px-2">
- <label
- class="text-base font-medium text-ink"
- id="invite-members-label"
- >
- Invite members{' '}
- <span class="font-normal text-ink/50">(optional)</span>
- </label>
- <p class="text-sm text-ink/50" id="invite-members-description">
- We'll send them an invite to join your workspace
- </p>
- </div>
- <div class="flex flex-col gap-3 overflow-y-auto min-h-0 p-2">
- <Index each={inviteEntries()}>
- {(entry, index) => (
- <div class="flex flex-col gap-1 shrink-0">
- <div class="flex items-center gap-2">
- <input
- id={`invite-email-${index}`}
- type="email"
- value={entry().email}
- onInput={(e) => updateEmail(index, e.currentTarget.value)}
- onBlur={(e) =>
- validateField('email', index, e.currentTarget.value)
- }
- placeholder={emailPlaceholder()}
- disabled={false}
- aria-labelledby="invite-members-label"
- aria-describedby="invite-members-description"
- aria-invalid={!!errors().emails?.[index]}
- class={cn(
- 'flex-1 px-3 py-2 text-base rounded-xs border bg-surface text-ink placeholder:text-ink/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-surface',
- errors().emails?.[index]
- ? 'border-failure focus-visible:ring-failure'
- : 'border-edge focus-visible:ring-accent',
- false
- )}
- />
- <Show when={showTier()}>
- <TierSelect
- value={entry().tier}
- onChange={(tier) => updateTier(index, tier)}
- disabled={false}
- triggerClass="flex items-center justify-between gap-1 w-28 px-3 py-2 text-base border border-edge rounded-xs bg-surface text-ink outline-none shrink-0 hover:bg-ink/5 data-[expanded]:bg-ink/5 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-1 focus-visible:ring-offset-surface [&>svg]:data-[expanded]:rotate-180 [&>svg]:transition-transform"
- />
- </Show>
- <Tooltip
- label={inviteEntries().length > 1 ? 'Remove' : 'Clear'}
- placement="top"
- >
- <button
- type="button"
- onClick={() =>
- inviteEntries().length === 1
- ? updateEmail(0, '')
- : removeEmail(index)
- }
- disabled={false}
- aria-label={
- inviteEntries().length > 1
- ? `Remove email ${index + 1}`
- : 'Clear email'
- }
- class={cn(
- 'shrink-0 p-1.5 text-ink/40 hover:text-ink hover:bg-ink/5 rounded-xs focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-1 focus-visible:ring-offset-surface'
- )}
- >
- <Show
- when={inviteEntries().length > 1}
- fallback={<XIcon class="size-4" />}
- >
- <TrashIcon class="size-4" />
- </Show>
- </button>
- </Tooltip>
- </div>
- <Show when={errors().emails?.[index]}>
- <p class="text-sm text-failure-ink" role="alert">
- {errors().emails?.[index]}
- </p>
- </Show>
- </div>
- )}
- </Index>
- </div>
- <button
- type="button"
- onClick={addEmailField}
- disabled={!canAddEmail()}
- aria-label="Add another email invite"
- class={cn(
- 'mx-2 flex items-center gap-2 px-3 py-2 text-sm rounded-xs focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-1 focus-visible:ring-offset-surface shrink-0',
- canAddEmail()
- ? 'text-ink bg-ink/8 hover:bg-ink/12'
- : 'text-ink/30 bg-ink/4 cursor-not-allowed'
- )}
- >
- <PlusIcon class="size-4" />
- Add another
- </button>
- <p class="text-sm text-ink/40 shrink-0 px-2">
- You can always invite more people later from Settings
- </p>
- </div>
- </form>
- </div>
- );
-}
-
-export const inviteTeamLesson: LessonDefinition = {
- id: 'invite-team',
- title: 'Create your team',
- content: InviteTeamContent,
- demo: InviteTeamDemo,
- order: 90,
- completeOnParam: 'subscriptionSuccess',
- previousLesson: 'team-choice',
- onBack: ({ onboarding }) => {
- onboarding.setTeamName('');
- onboarding.setInvitedMembers([]);
- },
- onContinue: () => {
- const form = document.getElementById(
- INVITE_FORM_ID
- ) as HTMLFormElement | null;
- form?.requestSubmit();
- },
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsx
deleted file mode 100644
index 8ed3147135..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import {
- SIGNUP_LEAD_VALUE_BY_TIER,
- SIGNUP_LEAD_VALUE_DEFAULT,
-} from '@app/lib/analytics/leadValues';
-import { McpSetupCards } from '@core/component/AI/component/McpSetupCards';
-import { ENABLE_APP_STORE_QR_CODE } from '@core/constant/featureFlags';
-import { useUserId } from '@core/context/user';
-import AppStoreQr from '@design/app-store.svg';
-import { useSearchParams } from '@solidjs/router';
-import { SegmentedControl } from '@ui';
-import { createSignal, onMount, Show } from 'solid-js';
-import type { LessonContentProps, LessonDefinition } from '../types';
-
-function LaunchContent(props: LessonContentProps) {
- const analytics = useAnalytics();
- const [searchParams] = useSearchParams();
- const userId = useUserId();
-
- onMount(() => {
- // `type` is set on the Stripe success redirect (see choose-plan.tsx). Free
- // users skip Stripe entirely so the param is absent — default to 'free'.
- const rawTier = searchParams.type;
- const tier = (Array.isArray(rawTier) ? rawTier[0] : rawTier) ?? 'free';
- const value = SIGNUP_LEAD_VALUE_BY_TIER[tier] ?? SIGNUP_LEAD_VALUE_DEFAULT;
- analytics.trackMeta('CompleteRegistration', {
- content_name: 'onboarding_launch',
- content_category: tier,
- value,
- currency: 'USD',
- });
- analytics.trackGoogleConversion('signup', {
- value,
- currency: 'USD',
- transaction_id: userId(),
- });
- setTimeout(() => props.onComplete('Launch'));
- });
-
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- {ENABLE_APP_STORE_QR_CODE ? (
- <>
- <p>You're all set!</p>
- <p>
- Before you dive in, install our mobile iOS app or connect Macro to
- your favorite AI tools via MCP.
- </p>
- <p>Both are always accessible from the settings panel.</p>
- </>
- ) : (
- <p>You're all set! Let's dive in.</p>
- )}
- </div>
- );
-}
-
-type LaunchTab = 'mobile' | 'mcp';
-
-const LAUNCH_TAB_OPTIONS: Array<{ value: LaunchTab; label: string }> = [
- { value: 'mobile', label: 'Mobile app' },
- { value: 'mcp', label: 'MCP instructions' },
-];
-
-function MobilePanel() {
- return (
- <div class="size-full flex flex-col items-center justify-center gap-6">
- <AppStoreQr class="size-[55cqw] max-w-115 max-h-115" />
- <p class="text-ink font-medium text-center">
- Download on the
- <br />
- <a
- href="https://apps.apple.com/us/app/macro-app/id6743133649"
- rel="noopener noreferrer"
- class="underline"
- target="_blank"
- >
- App Store
- </a>
- </p>
- </div>
- );
-}
-
-function LaunchDemo() {
- const [tab, setTab] = createSignal<LaunchTab>('mobile');
-
- return (
- <div class="size-full flex flex-col items-center p-8 @container">
- <SegmentedControl
- value={tab()}
- options={LAUNCH_TAB_OPTIONS}
- onChange={setTab}
- aria-label="Launch options"
- />
- <div class="flex-1 w-full min-h-0 mt-6 flex items-start justify-center overflow-y-auto">
- <Show when={tab() === 'mobile'} fallback={<McpSetupCards />}>
- <MobilePanel />
- </Show>
- </div>
- </div>
- );
-}
-
-export const launchLesson: LessonDefinition = {
- id: 'launch',
- title: 'Welcome to Macro',
- content: LaunchContent,
- ...(ENABLE_APP_STORE_QR_CODE && { demo: LaunchDemo, centeredButton: true }),
- order: 100,
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/markdown-mentions.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/markdown-mentions.tsx
index 364f43f6f4..a0bbbe41db 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/markdown-mentions.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/markdown-mentions.tsx
@@ -16,17 +16,18 @@ const [completed, setCompleted] = createSignal(false);
function MarkdownMentionsContent(_props: LessonContentProps) {
return (
- <div class="flex flex-col gap-3 onboarding-stagger">
+ <div class="flex flex-col gap-8 onboarding-stagger">
+ <p class="text-ink-muted mt-2">
+ Macro's editor supports rich markdown, mentions, and emoji. Try
+ mentioning someone or something by typing <strong>@</strong> in the
+ editor.
+ </p>
+
<HotkeyCallout
keys={['@']}
label="to mention someone or something"
completed={completed()}
/>
- <p>
- Macro's editor supports rich markdown, mentions, and emoji. Try
- mentioning someone or something by typing <strong>@</strong> in the
- editor.
- </p>
</div>
);
}
@@ -67,7 +68,7 @@ function MarkdownMentionsDemo(props: LessonContentProps) {
.withSkipPreviewFetch();
return (
- <MockAppChrome>
+ <MockAppChrome scopeId={props.scopeId}>
<div class="h-full flex flex-col px-8 py-6">
<h1 class="text-3xl font-semibold text-ink mb-4">Daily Note</h1>
<MarkdownShell
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx
deleted file mode 100644
index 1523344e74..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx
+++ /dev/null
@@ -1,388 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import {
- type PaidPlanTier,
- PLAN_FEATURES,
- PLANS,
-} from '@app/component/paywall/plans';
-import { analytics } from '@app/lib/analytics/analytics';
-import { useIsAuthenticated } from '@core/auth';
-import { toast } from '@core/component/Toast/Toast';
-import { throwOnErr } from '@core/util/result';
-import ArrowRightIcon from '@phosphor/arrow-right.svg';
-import InfoIcon from '@phosphor/info.svg';
-import LockIcon from '@phosphor/lock.svg';
-import { invalidateUserTeams } from '@queries/team';
-import { authServiceClient } from '@service-auth/client';
-import { Button, cn, Tooltip } from '@ui';
-import { createMemo, createSignal, For, Show } from 'solid-js';
-import { useOnboarding } from '../onboarding-context';
-import type { LessonContentProps, LessonDefinition } from '../types';
-import {
- clearPendingTeam,
- getPendingTeam,
- savePendingTeam,
- useOnboardingCheckoutMutation,
-} from '../use-onboarding-checkout';
-
-function ReviewPayContent() {
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>Review your plan and complete your subscription.</p>
- </div>
- );
-}
-
-function ReviewPayDemo(props: LessonContentProps) {
- const analytics = useAnalytics();
- const onboarding = useOnboarding();
- const isAuthenticated = useIsAuthenticated();
- const [isRedirecting, setIsRedirecting] = createSignal(false);
-
- // Returns to /welcome?subscriptionSuccess=true on success, which completes
- // all lessons except launch and runs onCompleteParam to create the pending team.
- const checkoutMutation = useOnboardingCheckoutMutation({
- onSuccess: (result) => {
- analytics.track('subscription_start', {
- type: onboarding.selectedPlan(),
- seats: onboarding.seatCount(),
- });
- 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 selectedPlan = () => {
- const tier = onboarding.selectedPlan();
- return PLANS.find((p) => p.tier === tier);
- };
-
- const hasTeam = () =>
- onboarding.invitedMembers().length > 0 ||
- onboarding.teamName().trim() !== '';
-
- const teamByTier = createMemo(() => {
- const groups: Record<
- string,
- { plan: (typeof PLANS)[number]; count: number }
- > = {};
- const order: string[] = [];
- for (const member of onboarding.invitedMembers()) {
- const plan = PLANS.find((p) => p.tier === member.tier);
- if (plan) {
- if (groups[member.tier]) {
- groups[member.tier].count++;
- } else {
- groups[member.tier] = { plan, count: 1 };
- order.push(member.tier);
- }
- }
- }
- return order.map((tier) => groups[tier]);
- });
-
- const handleCheckout = () => {
- const tier = onboarding.selectedPlan();
- if (!tier || tier === 'free' || isPending()) return;
-
- if (!isAuthenticated()) {
- toast.failure('Please sign in to continue');
- props.goToLesson('about-us');
- return;
- }
-
- const teamName = onboarding.teamName();
- const members = onboarding
- .invitedMembers()
- .filter((m) => m.tier !== 'free')
- .map((m) => ({ email: m.email, tier: m.tier as PaidPlanTier }));
-
- if (teamName) {
- savePendingTeam({ name: teamName, members });
- } else {
- clearPendingTeam();
- }
-
- checkoutMutation.mutate({ tier: tier as PaidPlanTier });
- };
-
- return (
- <div class="size-full flex items-start justify-center p-12 pt-[12%]">
- <Show
- when={hasTeam()}
- fallback={
- /* Solo layout */
- <div class="w-full max-w-md flex flex-col">
- {/* Price */}
- <div class="px-5 py-4 border-b border-edge flex items-baseline justify-between">
- <div class="flex items-end gap-1.5">
- <span class="text-4xl font-bold text-ink leading-none">
- ${onboarding.userSeatCost()}
- </span>
- <span class="text-ink/50 text-base pb-0.5">/month</span>
- </div>
- <span class="px-2 py-0.5 rounded-xs bg-accent/15 text-accent text-xs font-medium">
- {selectedPlan()?.name}
- </span>
- </div>
-
- {/* What's included */}
- <div class="px-5 py-4 border-b border-edge">
- <span class="text-xs text-ink/40 uppercase tracking-wide">
- What's included
- </span>
- <div class="flex flex-col gap-1 mt-2">
- <For each={PLAN_FEATURES}>
- {(feature) => (
- <div class="flex justify-between text-sm">
- <span class="text-ink/60">{feature.label}</span>
- <span class="text-ink">
- {feature.values[onboarding.selectedPlan() ?? 'free']}
- </span>
- </div>
- )}
- </For>
- </div>
- </div>
-
- {/* CTA */}
- <div class="px-5 py-4 flex flex-col gap-2 mt-auto">
- <Button
- variant="active"
- size="lg"
- onClick={handleCheckout}
- disabled={isPending()}
- class="w-full rounded-xs"
- >
- {isPending()
- ? 'Redirecting to checkout…'
- : 'Continue to payment'}
- <Show when={!isPending()}>
- <ArrowRightIcon class="size-4" />
- </Show>
- </Button>
- <span class="text-xs text-ink/40 flex items-center justify-center gap-1">
- <LockIcon class="size-3" />
- Secure checkout via Stripe
- </span>
- </div>
- </div>
- }
- >
- {/* Team layout */}
- <div class="w-full max-w-md">
- {/* Header */}
- <Show when={onboarding.teamName()}>
- <div class="mb-1">
- <span class="text-xs text-ink/40 uppercase tracking-wide">
- Team
- </span>
- <p class="text-lg font-semibold text-ink -mt-0.5">
- {onboarding.teamName()}
- </p>
- </div>
- </Show>
-
- {/* Price */}
- <div class="pb-4 border-b border-ink/10 flex items-baseline justify-between">
- <div class="flex items-end gap-1.5">
- <span class="text-4xl font-bold text-ink leading-none">
- ${onboarding.totalCost()}
- </span>
- <span class="text-ink/50 text-base pb-0.5">/month</span>
- </div>
- <span class="px-2 py-0.5 rounded-xs bg-accent/15 text-accent text-xs font-medium">
- Team plan
- </span>
- </div>
-
- {/* Summary */}
- <div class="py-4 border-b border-ink/10">
- <span class="text-xs text-ink/40 uppercase tracking-wide">
- Summary
- </span>
- <div class="flex flex-col text-sm mt-2">
- <div
- class={cn(
- 'flex justify-between py-2',
- onboarding.invitedMembers().length > 0 &&
- 'border-b border-ink/10'
- )}
- >
- <span class="text-ink/60">
- Your seat · {selectedPlan()?.name}
- </span>
- <span>
- <span class="text-ink">${onboarding.userSeatCost()}</span>
- <span class="text-ink/40"> /month</span>
- </span>
- </div>
- <For each={teamByTier()}>
- {(group) => (
- <div class="flex justify-between py-2 border-b border-ink/10">
- <span class="text-ink/60">
- Team · {group.plan.name} × {group.count}
- </span>
- <Tooltip label="Charged when invite is accepted">
- <span class="underline decoration-dotted underline-offset-4 italic cursor-help">
- <span class="text-ink">
- ${group.plan.price * group.count}
- </span>
- <span class="text-ink/40"> /month</span>
- </span>
- </Tooltip>
- </div>
- )}
- </For>
- <Show when={onboarding.invitedMembers().length > 0}>
- <div class="flex justify-between items-center py-2">
- <span class="text-ink/60 flex items-center gap-1">
- Total
- <Tooltip label="Team charges begin when members accept their invite">
- <InfoIcon class="size-3.5 text-ink/40" />
- </Tooltip>
- </span>
- <span>
- <span class="text-ink font-medium">
- ${onboarding.totalCost()}
- </span>
- <span class="text-ink/40"> /month</span>
- </span>
- </div>
- </Show>
- </div>
-
- {/* What's included - inline when no invites */}
- <Show when={onboarding.invitedMembers().length === 0}>
- <div class="mt-4 pt-4 border-t border-ink/10">
- <span class="text-xs text-ink/40 uppercase tracking-wide">
- What's included
- </span>
- <div class="flex flex-col gap-1 mt-2">
- <For each={PLAN_FEATURES}>
- {(feature) => (
- <div class="flex justify-between text-sm">
- <span class="text-ink/60">{feature.label}</span>
- <span class="text-ink">
- {feature.values[onboarding.selectedPlan() ?? 'free']}
- </span>
- </div>
- )}
- </For>
- </div>
- </div>
- </Show>
- </div>
-
- {/* Invites */}
- <Show when={onboarding.invitedMembers().length > 0}>
- <div class="py-4 border-b border-ink/10">
- <span class="text-xs text-ink/40 uppercase tracking-wide">
- Invites ({onboarding.invitedMembers().length})
- </span>
- <div class="flex flex-col gap-1.5 mt-2">
- <For each={onboarding.invitedMembers()}>
- {(member) => (
- <div class="flex items-center justify-between text-sm">
- <span class="text-ink/70 truncate mr-2">
- {member.email}
- </span>
- <span class="text-xs text-ink/40 shrink-0">
- {PLANS.find((p) => p.tier === member.tier)?.name}
- </span>
- </div>
- )}
- </For>
- </div>
- <p class="text-xs text-ink/40 pt-2">
- You can invite more from Settings
- </p>
- </div>
- </Show>
-
- {/* CTA */}
- <div class="pt-4 flex flex-col gap-2">
- <Button
- variant="active"
- size="lg"
- onClick={handleCheckout}
- disabled={isPending()}
- class="w-full rounded-xs"
- >
- {isPending() ? 'Redirecting to checkout…' : 'Continue to payment'}
- <Show when={!isPending()}>
- <ArrowRightIcon class="size-4" />
- </Show>
- </Button>
- <span class="text-xs text-ink/40 flex items-center justify-center gap-1">
- <LockIcon class="size-3" />
- Secure checkout via Stripe
- </span>
- </div>
- </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) {
- await throwOnErr(() => authServiceClient.inviteToTeam({ invites }));
- }
-
- 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);
- clearPendingTeam();
- return true;
- }
-}
-
-export const reviewPayLesson: LessonDefinition = {
- id: 'review-pay',
- title: 'Finish setup',
- content: ReviewPayContent,
- demo: ReviewPayDemo,
- order: 95,
- hideContinue: true,
- completeOnParam: 'subscriptionSuccess',
- onCompleteParam: createPendingTeamOnReturn,
- previousLesson: ({ onboarding, isLessonSkipped }) => {
- // When teams feature is disabled, these lessons are skipped
- if (isLessonSkipped('team-choice')) {
- return 'choose-plan';
- }
- const hasTeam =
- onboarding.invitedMembers().length > 0 ||
- onboarding.teamName().trim() !== '';
- return hasTeam ? 'invite-team' : 'team-choice';
- },
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/sidebar-nav.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/sidebar-nav.tsx
index 48d671ca95..490bda403b 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/sidebar-nav.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/sidebar-nav.tsx
@@ -20,34 +20,36 @@ function SidebarNavContent(props: LessonContentProps) {
});
return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>Use the sidebar to quickly jump between views.</p>
- <p>
- Try navigating to <strong>Emails</strong>.
- </p>
- <div class="mt-2">
+ <div class="flex flex-col gap-8 onboarding-stagger">
+ <div class="mt-2 text-ink-muted text-base">
+ <p>Use the sidebar to quickly jump between views.</p>
+ <p>
+ Try navigating to <strong>Emails</strong>.
+ </p>
+ </div>
+ <div class="flex flex-col gap-2">
<HotkeyCallout
keys={['G', 'E']}
separator="then"
label=""
completed={done()}
/>
+ <div class="flex items-center gap-3 text-sm text-ink/40">
+ <div class="h-px w-8 bg-edge-muted" />
+ or
+ <div class="h-px flex-1 bg-edge-muted" />
+ </div>
+ <ClickCallout
+ icon={AnimatedEmailIcon}
+ label="in the sidebar"
+ completed={done()}
+ />
</div>
- <div class="flex items-center gap-3 text-sm text-ink/40">
- <div class="h-px w-8 bg-edge-muted" />
- or
- <div class="h-px flex-1 bg-edge-muted" />
- </div>
- <ClickCallout
- icon={AnimatedEmailIcon}
- label="in the sidebar"
- completed={done()}
- />
</div>
);
}
-function SidebarNavDemo() {
+function SidebarNavDemo(props: LessonContentProps) {
const soup = createSoupState({ wrapNavigation: true });
createEffect(() => {
@@ -59,7 +61,7 @@ function SidebarNavDemo() {
});
return (
- <MockAppChrome highlightId="mail">
+ <MockAppChrome highlightId="mail" scopeId={props.scopeId}>
<OnboardingEntityList soup={soup} />
</MockAppChrome>
);
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx
deleted file mode 100644
index faebb5d0c3..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx
+++ /dev/null
@@ -1,136 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import type { PaidPlanTier } from '@app/component/paywall/plans';
-import { useIsAuthenticated } from '@core/auth';
-import { toast } from '@core/component/Toast/Toast';
-import ArrowRightIcon from '@phosphor/arrow-right.svg';
-import SpinnerIcon from '@phosphor/spinner.svg';
-import UserIcon from '@phosphor/user.svg';
-import UsersIcon from '@phosphor/users.svg';
-import { createEffect, createSignal } from 'solid-js';
-import { useOnboarding } from '../onboarding-context';
-import type { LessonContentProps, LessonDefinition } from '../types';
-import { useOnboardingCheckoutMutation } from '../use-onboarding-checkout';
-
-function TeamChoiceContent() {
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>Continue on your own, or invite your team.</p>
- </div>
- );
-}
-
-function TeamChoiceDemo(props: LessonContentProps) {
- const onboarding = useOnboarding();
- const analytics = useAnalytics();
- const isAuthenticated = useIsAuthenticated();
- const [isRedirecting, setIsRedirecting] = createSignal(false);
-
- // Returns to /welcome?subscriptionSuccess=true on success, which completes
- // all lessons except launch, landing the user on the launch lesson.
- const checkoutMutation = useOnboardingCheckoutMutation({
- onSuccess: (result) => {
- analytics.track('subscription_start', {
- type: onboarding.selectedPlan(),
- seats: 1,
- });
- 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();
-
- createEffect(() => {
- props.onUnready();
- });
-
- const handleChooseTeam = () => {
- props.advance();
- };
-
- const handleChooseSolo = () => {
- const tier = onboarding.selectedPlan();
- if (!tier || tier === 'free' || isPending()) return;
-
- if (!isAuthenticated()) {
- props.goToLesson('about-us');
- return;
- }
-
- analytics.track('onboarding_team_skipped', { plan: tier });
-
- onboarding.setInvitedMembers([]);
- onboarding.setTeamName('');
-
- checkoutMutation.mutate({ tier: tier as PaidPlanTier });
- };
-
- return (
- <div class="size-full flex items-center justify-center p-12">
- <div class="flex flex-col gap-4 w-full max-w-md">
- <button
- type="button"
- onClick={handleChooseTeam}
- disabled={isPending()}
- class="flex items-center gap-4 p-5 rounded-md border border-accent/50 bg-accent/5 hover:bg-accent/10 text-left bracket-never focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface disabled:opacity-50 disabled:cursor-not-allowed"
- >
- <div class="shrink-0 size-11 rounded-full bg-accent/20 flex items-center justify-center">
- <UsersIcon class="size-5 text-accent" />
- </div>
- <div class="flex flex-col gap-0.5">
- <span class="text-base font-semibold text-ink">Create a team</span>
- <span class="text-sm text-ink/50">
- Collaborate with others in a shared workspace
- </span>
- </div>
- </button>
-
- <button
- type="button"
- onClick={handleChooseSolo}
- disabled={isPending()}
- class="flex items-center gap-4 p-5 rounded-md border border-edge bg-surface hover:bg-ink/5 text-left bracket-never focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface disabled:opacity-50 disabled:cursor-not-allowed"
- >
- <div class="shrink-0 size-11 rounded-full bg-ink/10 flex items-center justify-center">
- {isPending() ? (
- <SpinnerIcon class="size-5 text-ink/60 animate-spin" />
- ) : (
- <UserIcon class="size-5 text-ink/60" />
- )}
- </div>
- <div class="flex-1 flex flex-col gap-0.5">
- <span class="text-base font-medium text-ink">
- {isPending() ? 'Redirecting to checkout…' : 'Continue solo'}
- </span>
- <span class="text-sm text-ink/50">
- {isPending() ? '' : 'Use Macro on your own for now'}
- </span>
- </div>
- <ArrowRightIcon class="size-4 text-ink/50 shrink-0" />
- </button>
- </div>
- </div>
- );
-}
-
-export const teamChoiceLesson: LessonDefinition = {
- id: 'team-choice',
- title: 'How will you use Macro?',
- content: TeamChoiceContent,
- demo: TeamChoiceDemo,
- order: 89,
- hideContinue: true,
- completeOnParam: 'subscriptionSuccess',
- previousLesson: ({ isLessonSkipped, hasPaidAccess }) => {
- if (isLessonSkipped('choose-plan') || hasPaidAccess) {
- return undefined;
- }
- return 'choose-plan';
- },
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx
deleted file mode 100644
index 2bd018b431..0000000000
--- a/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { A } from '@solidjs/router';
-import { onMount } from 'solid-js';
-import type { LessonContentProps, LessonDefinition } from '../types';
-
-function WelcomeContent(props: LessonContentProps) {
- onMount(() => props.onComplete('Get Started'));
-
- return (
- <div class="flex flex-col gap-3 onboarding-stagger">
- <p>
- Macro is a unified system for work{'\u2060'}—built for{' '}
- <strong>speed</strong> and <strong>focus</strong>.
- {!isTouchDevice() &&
- ' This short walk-through will introduce a few core features.'}
- </p>
- </div>
- );
-}
-
-function WelcomeSecondaryAction() {
- const analytics = useAnalytics();
-
- return (
- <>
- <p class="text-sm text-ink-extra-muted mt-10">Already have an account?</p>
- <A
- href="/login"
- onClick={() => analytics.track('login_from_onboarding')}
- class="w-full px-3 py-2.5 text-lg rounded-xs flex items-center justify-between gap-2 border-none bg-transparent text-ink-extra-muted hover:bg-hover ring-1 ring-edge-muted"
- >
- Login
- </A>
- </>
- );
-}
-
-export const welcomeLesson: LessonDefinition = {
- id: 'welcome',
- title: 'Welcome to Macro',
- content: WelcomeContent,
- secondaryAction: WelcomeSecondaryAction,
- order: 0,
-};
diff --git a/js/app/packages/app/component/interactive-onboarding/onboarding-context.tsx b/js/app/packages/app/component/interactive-onboarding/onboarding-context.tsx
index 2c2af0f1ed..d6a0a6fd37 100644
--- a/js/app/packages/app/component/interactive-onboarding/onboarding-context.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/onboarding-context.tsx
@@ -1,75 +1,33 @@
-import type { PlanTier } from '@app/component/paywall/plans';
-import { PLANS } from '@app/component/paywall/plans';
-import {
- createContext,
- createMemo,
- createSignal,
- type ParentProps,
- useContext,
-} from 'solid-js';
+import { createContext, type ParentProps, useContext } from 'solid-js';
+import type { createOnboardingState } from './create-onboarding-state';
+import type { LessonContentProps, LessonId } from './types';
-export interface InvitedMember {
- email: string;
- tier: PlanTier;
-}
+type OnboardingState = ReturnType<typeof createOnboardingState>;
export interface OnboardingContextValue {
- selectedPlan: () => PlanTier | null;
- setSelectedPlan: (tier: PlanTier | null) => void;
- invitedMembers: () => InvitedMember[];
- setInvitedMembers: (members: InvitedMember[]) => void;
- teamName: () => string;
- setTeamName: (name: string) => void;
- /** Cost for the current user's seat */
- userSeatCost: () => number;
- /** Total cost for all invited team members */
- teamSeatsCost: () => number;
- /** Total monthly cost (user + team) */
- totalCost: () => number;
- /** Number of seats including the user */
- seatCount: () => number;
+ state: OnboardingState;
+ scopeId: string;
+ testMode: boolean;
+ readyToContinue: () => boolean;
+ continueLabel: () => string | undefined;
+ setContinueButtonRef: (el: HTMLButtonElement) => void;
+ handleLessonComplete: LessonContentProps['onComplete'];
+ handleLessonUnready: LessonContentProps['onUnready'];
+ advanceLesson: LessonContentProps['advance'];
+ handleSkipLesson: () => void;
+ handleContinue: () => void;
+ resetTutorial: () => void;
+ getPreviousLesson: () => LessonId | undefined;
+ handleBack: (targetLesson: LessonId) => void;
}
const OnboardingContext = createContext<OnboardingContextValue>();
-export function OnboardingProvider(props: ParentProps) {
- const [selectedPlan, setSelectedPlan] = createSignal<PlanTier | null>(null);
- const [invitedMembers, setInvitedMembers] = createSignal<InvitedMember[]>([]);
- const [teamName, setTeamName] = createSignal('');
-
- 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(() => {
- return 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 value: OnboardingContextValue = {
- selectedPlan,
- setSelectedPlan,
- invitedMembers,
- setInvitedMembers,
- teamName,
- setTeamName,
- userSeatCost,
- teamSeatsCost,
- totalCost,
- seatCount,
- };
-
+export function OnboardingProvider(
+ props: ParentProps<{ value: OnboardingContextValue }>
+) {
return (
- <OnboardingContext.Provider value={value}>
+ <OnboardingContext.Provider value={props.value}>
{props.children}
</OnboardingContext.Provider>
);
diff --git a/js/app/packages/app/component/interactive-onboarding/types.ts b/js/app/packages/app/component/interactive-onboarding/types.ts
index e7a26bbbe4..9519e6b170 100644
--- a/js/app/packages/app/component/interactive-onboarding/types.ts
+++ b/js/app/packages/app/component/interactive-onboarding/types.ts
@@ -1,10 +1,8 @@
import type { Component } from 'solid-js';
-import type { OnboardingContextValue } from './onboarding-context';
export type LessonId = string;
export interface BackContext {
- onboarding: OnboardingContextValue;
isLessonSkipped: (id: LessonId) => boolean;
hasPaidAccess: boolean;
}