Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(mobile): mobile onboarding (#4430)
Peter Chinmanf2cff846aae6
diff --git a/js/app/packages/app/component/AddInboxDialog.tsx b/js/app/packages/app/component/AddInboxDialog.tsxindex 9f828f288f..5dc2e77a35 100644--- a/js/app/packages/app/component/AddInboxDialog.tsx+++ b/js/app/packages/app/component/AddInboxDialog.tsx@@ -1,5 +1,3 @@-import { useHasPaidAccess } from '@core/auth';-import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';import { useAddInboxFlow } from '@core/email-link';import { Button, Dialog, Panel } from '@ui';import { createSignal, onCleanup } from 'solid-js';@@ -10,26 +8,14 @@ const [isOpen, setIsOpen] = createSignal(false);* Requests the add-inbox confirmation dialog. The dialog itself is rendered* by the settings Account panel, so callers elsewhere (e.g. the mail inbox* selector) open settings first and the dialog appears once it mounts.+ *+ * Entitlement is enforced by the backend: `POST /link/gmail` answers 402 when+ * the user isn't allowed another inbox, and `useAddInboxFlow` maps that to the+ * multi-inbox paywall — so callers can invoke the add-inbox flow directly+ * without a client-side gate that would have to mirror the backend's rule.*/export const openAddInboxDialog = () => setIsOpen(true);-/**- * Connecting more than one inbox is a paid feature. Returns a guard that runs- * `proceed` for paid users and otherwise opens the paywall, so every add-inbox- * entry point gates on the same key.- */-export function useAddInboxGate() {- const hasPaidAccess = useHasPaidAccess();- const { showPaywall } = usePaywallState();- return (proceed: () => void) => {- if (!hasPaidAccess()) {- showPaywall(PaywallKey.MULTI_INBOX);- return;- }- proceed();- };-}-/*** Confirmation step before the add-inbox OAuth redirect. Confirming kicks off* `useAddInboxFlow`, which navigates the page to Google's consent screen.diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex a6d7b19bd4..ecc652838a 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -94,6 +94,8 @@ import {systemThemeEffect,} from '../../theme/utils/themeUtils';import { Login } from './auth/Login';+import { MobileAuthWelcome } from './auth/mobile-onboarding/MobileAuthWelcome';+import { MobileOnboarding } from './auth/mobile-onboarding/MobileOnboarding';import { setCookie } from './auth/Shared';import { Signup } from './auth/Signup';import { makeEmailAuthComponents } from './EmailAuth';@@ -356,7 +358,21 @@ const ROUTES: RouteDefinition[] = [},{path: '/welcome',- component: () => <Navigate href="/login" />,+ component: () =>+ isNativeMobilePlatform() ? (+ <MobileAuthWelcome />+ ) : (+ <Navigate href="/login" />+ ),+ },+ {+ path: '/onboarding',+ component: () =>+ isNativeMobilePlatform() ? (+ <MobileOnboarding />+ ) : (+ <Navigate href="/login" />+ ),},{path: '/team-invite',@@ -481,6 +497,7 @@ function InitialInteractiveOnboardingModal() {const modalOpen = () =>open() &&+ !isNativeMobilePlatform() &&userInfoQuery.data?.authenticated === true &&(userInfoQuery.data.tutorialComplete === false || onboardingStarted());diff --git a/js/app/packages/app/component/auth/mobile-onboarding/MobileAuthWelcome.tsx b/js/app/packages/app/component/auth/mobile-onboarding/MobileAuthWelcome.tsxnew file mode 100644index 0000000000..6a43fe1115--- /dev/null+++ b/js/app/packages/app/component/auth/mobile-onboarding/MobileAuthWelcome.tsx@@ -0,0 +1,63 @@+import { useAnalytics } from '@app/component/analytics-context';+import { PcNoiseGrid } from '@core/component/PcNoiseGrid';+import LogoIcon from '@icon/macro-logo.svg';+import { useNavigate } from '@solidjs/router';+import { Button, Surface } from '@ui';+import { onMount } from 'solid-js';++/**+ * Native-mobile entry screen shown to unauthenticated users (via `/welcome`).+ * Routes new users into the mobile onboarding wizard and existing users to the+ * standard Login screen.+ */+export function MobileAuthWelcome() {+ const navigate = useNavigate();+ const analytics = useAnalytics();++ onMount(() => {+ analytics.pageView('mobile_auth_welcome');+ });++ return (+ <div class="flex items-center justify-center size-full p-8 overflow-hidden relative">+ <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>++ <div class="w-full max-w-105">+ <Surface depth={1}>+ <div class="flex flex-col items-center gap-2 py-10">+ <LogoIcon class="size-20 text-ink" />+ <div class="text-lg font-medium">Welcome to Macro</div>+ </div>+ <div class="flex flex-col gap-3 px-8 pb-8">+ <Button+ variant="contrast"+ size="lg"+ onClick={() => navigate('/onboarding')}+ >+ Create new account+ </Button>+ <Button+ size="lg"+ class="ring ring-edge-muted"+ onClick={() => navigate('/login')}+ >+ Log into existing account+ </Button>+ </div>+ </Surface>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/auth/mobile-onboarding/MobileOnboarding.tsx b/js/app/packages/app/component/auth/mobile-onboarding/MobileOnboarding.tsxnew file mode 100644index 0000000000..59aaee47c3--- /dev/null+++ b/js/app/packages/app/component/auth/mobile-onboarding/MobileOnboarding.tsx@@ -0,0 +1,121 @@+import { useAnalytics } from '@app/component/analytics-context';+import { PcNoiseGrid } from '@core/component/PcNoiseGrid';+import { useIsAuthenticated } from '@core/context/user';+import LogoIcon from '@icon/macro-logo.svg';+import { useNavigate } from '@solidjs/router';+import { Button, Surface } from '@ui';+import { Stepper } from '@ui/components/Stepper';+import { createEffect, createSignal, onMount, Show } from 'solid-js';+import { OnboardingConnectAccounts } from './OnboardingConnectAccounts';+import { OnboardingCreateAccount } from './OnboardingCreateAccount';+import { OnboardingInbox } from './OnboardingInbox';++const CREATE_ACCOUNT_STEP = 0;+const LAST_STEP = 2;++/**+ * `Stepper.transitions.scale` uses solid-transition-group's `mode: 'outin'`,+ * which mounts the entering step only after the exiting step's transition emits+ * `transitionend`. When that event never arrives (e.g. the exit transition is+ * cancelled or runs instantly), the switch wedges: the old step is left frozen+ * at `opacity-0` and the next step never mounts — exactly the "blank step 2"+ * symptom. A simultaneous transition (no `mode`) mounts the entering step+ * immediately so it can't wedge; the exiting step is positioned absolutely so+ * the two overlap during the cross-fade, and `pointer-events-none` keeps a+ * lingering exit node from eating taps.+ */+const STEP_TRANSITION = {+ enterActiveClass: 'transition-all duration-200 ease-out',+ enterClass: 'opacity-0 scale-95',+ enterToClass: 'opacity-100 scale-100',+ exitActiveClass:+ 'transition-all duration-150 ease-in absolute inset-0 pointer-events-none',+ exitClass: 'opacity-100 scale-100',+ exitToClass: 'opacity-0 scale-95',+};++/**+ * Native-mobile sign-up wizard: a logo-topped, Continue-footed pager that walks+ * a new user through creating an account, connecting their accounts, and info+ * panels. The first step has no Continue button — it auto-advances once the+ * user authenticates by connecting their primary Gmail.+ */+export function MobileOnboarding() {+ const [step, setStep] = createSignal(CREATE_ACCOUNT_STEP);+ const navigate = useNavigate();+ const analytics = useAnalytics();+ const isAuthenticated = useIsAuthenticated();++ onMount(() => {+ analytics.pageView('mobile_onboarding');+ });++ // The create-account step has no Continue button; advance to the connect step+ // as soon as the SSO sign-in flips the user to authenticated.+ createEffect(() => {+ if (step() === CREATE_ACCOUNT_STEP && isAuthenticated()) {+ setStep(CREATE_ACCOUNT_STEP + 1);+ }+ });++ const onContinue = () => {+ if (step() >= LAST_STEP) {+ navigate('/', { replace: true });+ return;+ }+ setStep(step() + 1);+ };++ return (+ <div class="relative flex size-full overflow-hidden px-4 pt-[calc(var(--safe-top)+2rem)] pb-[calc(var(--safe-bottom)+2rem)]">+ <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>++ <Surface depth={1} class="flex flex-col mt-(--mobile-content-inset-top)">+ <div class="flex shrink-0 items-center justify-center pt-8 pb-4">+ <LogoIcon class="size-16 text-ink" />+ </div>++ <div class="min-h-0 grow overflow-y-auto px-6">+ <div class="mx-auto w-full max-w-md h-full">+ <Stepper class="h-full" step={step()} transition={STEP_TRANSITION}>+ <Stepper.Step>+ <OnboardingCreateAccount />+ </Stepper.Step>+ <Stepper.Step>+ <OnboardingConnectAccounts />+ </Stepper.Step>+ <Stepper.Step>+ <OnboardingInbox />+ </Stepper.Step>+ </Stepper>+ </div>+ </div>++ <Show when={step() > CREATE_ACCOUNT_STEP}>+ <div class="mx-auto w-full max-w-md shrink-0 px-6 pt-6 pb-6">+ <Button+ variant="contrast"+ size="lg"+ class="w-full"+ onClick={onContinue}+ >+ {step() >= LAST_STEP ? 'Get started' : 'Continue'}+ </Button>+ </div>+ </Show>+ </Surface>+ </div>+ );+}diff --git a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsxnew file mode 100644index 0000000000..2eb388bf50--- /dev/null+++ b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx@@ -0,0 +1,188 @@+import { toast } from '@core/component/Toast/Toast';+import { useIsAuthenticated } from '@core/context/user';+import { useAddInboxFlow } from '@core/email-link';+import { getNativeMobilePlatform } from '@core/util/platform';+import IconGoogle from '@icon/macro-google.svg';+import GithubIcon from '@icon/mcp-github.svg';+import {+ invalidateGithubLinkStatus,+ useGithubLinkStatusQuery,+ useInitGithubLinkMutation,+} from '@queries/auth';+import { useEmailLinksQuery } from '@queries/email/link';+import { invoke } from '@tauri-apps/api/core';+import { Button } from '@ui';+import { createSignal, For, type JSX, Show } from 'solid-js';++/**+ * DEBUG: flip to `true` to simulate a connected GitHub account without running. Leave `false`+ * in committed code.+ */+const DEBUG_FAKE_GITHUB = false;+const DEBUG_FAKE_GITHUB_USERNAME = 'octocat';++/**+ * Onboarding step 1 — connect additional accounts once the user is signed in:+ * extra Gmail inboxes (up to the free limit, then the paywall) and their+ * GitHub account. The bottom of the page lists everything currently connected.+ */+export function OnboardingConnectAccounts() {+ const isAuthenticated = useIsAuthenticated();++ const linksQuery = useEmailLinksQuery();+ const addInbox = useAddInboxFlow();++ const githubLink = useGithubLinkStatusQuery();+ const initGithubLink = useInitGithubLinkMutation();++ // Locally-simulated GitHub connection, gated behind DEBUG_FAKE_GITHUB. Starts+ // connected when the flag is on; also set by connectGithub's debug shortcut.+ const [debugGithubConnected, setDebugGithubConnected] =+ createSignal(DEBUG_FAKE_GITHUB);++ const githubLinked = () =>+ debugGithubConnected() || githubLink.data?.status === 'linked';+ const githubLabel = () => {+ const username = debugGithubConnected()+ ? DEBUG_FAKE_GITHUB_USERNAME+ : githubLink.data?.username;+ return username ? `@${username}` : 'GitHub';+ };++ const hasConnectedAccounts = () =>+ (linksQuery.data?.links.length ?? 0) > 0 || githubLinked();++ const connectGithub = async () => {+ if (githubLinked()) return;+ if (DEBUG_FAKE_GITHUB) {+ setDebugGithubConnected(true);+ toast.success('GitHub connected (debug)', { mobile: true });+ return;+ }+ const isIos = getNativeMobilePlatform() === 'ios';+ try {+ const authorizationUrl = await initGithubLink.mutateAsync(+ isIos ? 'macro://github-link-callback' : window.location.href+ );++ if (!isIos) {+ // Web / non-iOS native: the OAuth callback redirects back to original_url.+ window.location.href = authorizationUrl;+ return;+ }++ // iOS: run the OAuth inline in an ASWebAuthenticationSession via the Tauri+ // auth plugin; the GitHub link is completed server-side when the callback+ // fires, so we just refresh the status afterwards.+ const auth = await invoke<{+ success: boolean;+ token?: string;+ error?: string;+ }>('plugin:auth|authenticate', {+ payload: {+ authUrl: authorizationUrl,+ callbackScheme: 'macro',+ ephemeralSession: true,+ },+ });++ if (!auth.success) {+ if (auth.error !== 'User canceled login') {+ toast.failure('Failed to connect GitHub', { mobile: true });+ }+ return;+ }++ await invalidateGithubLinkStatus();+ toast.success('GitHub connected', { mobile: true });+ } catch (error) {+ console.error('connect github failed', error);+ toast.failure('Failed to connect GitHub', { mobile: true });+ }+ };++ return (+ <div class="h-full flex flex-col gap-6 justify-between">+ <h1 class="text-2xl font-semibold tracking-tight text-ink">+ Connect More Accounts+ </h1>+ <div>+ <div class="flex flex-col gap-2">+ <Button+ variant="contrast"+ size="lg"+ class="ring ring-edge-muted"+ disabled={!isAuthenticated()}+ onClick={() => void addInbox()}+ >+ <IconGoogle />+ Connect Another Gmail+ </Button>+ <p class="text-sm/relaxed text-ink-muted">+ Connect multiple accounts to see all your emails in one inbox.+ </p>+ </div>++ <div class="h-8" />++ <div class="flex flex-col gap-2">+ <Button+ variant="contrast"+ size="lg"+ class="ring ring-edge-muted"+ disabled={+ !isAuthenticated() || githubLinked() || initGithubLink.isPending+ }+ onClick={() => void connectGithub()}+ >+ <GithubIcon />+ {githubLinked() ? 'GitHub Connected' : 'Connect GitHub'}+ </Button>+ <p class="text-sm/relaxed text-ink-muted">+ Connect GitHub account to see pull requests in your inbox.+ </p>+ </div>+ </div>++ <Show when={hasConnectedAccounts()}>+ <div>+ <h1 class="pb-2">Connected Accounts</h1>+ <div class="flex flex-col overflow-hidden rounded-lg border border-edge-muted">+ <For each={linksQuery.data?.links ?? []}>+ {(link) => (+ <AccountRow+ icon={<IconGoogle />}+ label={link.email_address}+ badge={link.is_primary ? 'Primary' : undefined}+ />+ )}+ </For>+ <Show when={githubLinked()}>+ <AccountRow icon={<GithubIcon />} label={githubLabel()} />+ </Show>+ </div>+ </div>+ </Show>+ </div>+ );+}++function AccountRow(props: {+ icon: JSX.Element;+ label: string;+ badge?: string;+}) {+ return (+ <div class="bg-surface flex min-h-12 items-center justify-between gap-3 border-b border-edge-muted px-4 py-2 last:border-b-0">+ <span class="flex min-w-0 items-center gap-4">+ <span class="size-4 shrink-0">{props.icon}</span>+ <span class="ph-no-capture truncate text-sm">{props.label}</span>+ </span>+ <Show when={props.badge}>+ <span class="rounded bg-edge-muted px-1.5 py-0.5 text-xxs font-medium uppercase">+ {props.badge}+ </span>+ </Show>+ </div>+ );+}diff --git a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingCreateAccount.tsx b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingCreateAccount.tsxnew file mode 100644index 0000000000..9f5ccfc841--- /dev/null+++ b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingCreateAccount.tsx@@ -0,0 +1,52 @@+import { GOOGLE_GMAIL_IDP } from '@core/auth/email';+import IconGoogle from '@icon/macro-google.svg';+import { useNavigate } from '@solidjs/router';+import { Button } from '@ui';+import { useSsoLogin } from '../useSsoLogin';++/**+ * Onboarding step 0 — create the account by connecting the primary Gmail via+ * SSO sign-in. There is no Continue button here: once the SSO flow completes+ * `useIsAuthenticated()` flips true and `MobileOnboarding` auto-advances to the+ * next step. The escape hatch creates an account without connecting email.+ */+export function OnboardingCreateAccount() {+ const navigate = useNavigate();+ const startSsoLogin = useSsoLogin({ signupMode: true });++ return (+ <div class="flex flex-col gap-6">+ <div class="flex flex-col gap-4">+ <h1 class="text-2xl font-semibold tracking-tight text-ink">+ Welcome to Macro+ </h1>+ <p class="text-sm/relaxed text-ink-muted">+ Connect a Gmail account to start syncing your emails, contacts, and+ attachments.+ </p>+ <p class="text-sm/relaxed text-ink-muted">+ This will be your primary email account that you will use to sign in+ to Macro.+ </p>+ </div>++ <div class="flex flex-col gap-2 pt-2">+ <Button+ variant="contrast"+ size="lg"+ onClick={() => startSsoLogin(GOOGLE_GMAIL_IDP)}+ >+ <IconGoogle />+ Connect Gmail+ </Button>+ <button+ type="button"+ class="self-start pt-4 text-xs text-ink-muted/70 underline hover:text-ink/70"+ onClick={() => navigate('/signup')}+ >+ Create account without connecting email+ </button>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsx b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsxnew file mode 100644index 0000000000..20fae70ce1--- /dev/null+++ b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsx@@ -0,0 +1,236 @@+import { EntityRowProvider } from '@app/component/mobile/EntityRow';+import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import { touchHandler } from '@core/directive/touchHandler';+import {+ type EmailEntity,+ InlineEntity,+ ListEntity,+ ListLayoutProvider,+} from '@entity';+import CheckIcon from '@phosphor/check.svg';+import { cn } from '@ui';+import { createSignal, For, Show } from 'solid-js';++const CURRENT_USER_ID = 'macro|[email protected]';++const mockEmail = (+ id: string,+ minutesAgo: number,+ senderName: string,+ senderEmail: string,+ subject: string,+ snippet: string+): EmailEntity => {+ const ts = new Date(Date.now() - minutesAgo * 60_000);+ return {+ type: 'email',+ id,+ name: subject,+ ownerId: CURRENT_USER_ID,+ isRead: false,+ isDraft: false,+ isImportant: false,+ done: false,+ senderName,+ senderEmail,+ snippet,+ participants: [{ email: senderEmail, name: senderName }],+ createdAt: ts,+ updatedAt: ts,+ };+};++/** A believable inbox for the onboarding preview — a mix of a colleague ask, an+ * automated notification, a personal note, and a receipt. Purely local mock+ * data; senders are other people so they render as the row identity. */+const MOCK_EMAILS: EmailEntity[] = [+ mockEmail(+ 'onboarding_email_1',+ 9,+ 'Sarah Kim',+ '[email protected]',+ 'Can you gut-check the launch headline before 3?',+ 'Both options are at the top of the doc — I keep flip-flopping. Marketing wants to schedule the post this afternoon, so a quick yes/no would unblock them.'+ ),+ mockEmail(+ 'onboarding_email_3',+ 3 * 60,+ 'Dad',+ '[email protected]',+ 'thanksgiving flights',+ "Found a decent fare out on the 26th, back the 30th. Want me to just book two? The price already jumped $80 since yesterday so don't sit on it."+ ),+ mockEmail(+ 'onboarding_email_4',+ 22 * 60,+ 'Streep',+ '[email protected]',+ 'Receipt from Acme, Inc. — $2,400.00',+ 'Payment of $2,400.00 succeeded. Invoice A1B2-0042, Visa ending 4242. Thanks for your business.'+ ),+];++type DrawerAction = {+ label: string;+ destructive?: boolean;+ onClick: () => void;+};+type DrawerActionGroup = { label?: string; items: DrawerAction[] };++/**+ * Onboarding inbox step — a hands-on inbox preview. Renders the real soup-view+ * email row (`ListEntity`) with mocked data so the new user can try the two+ * core gestures before entering the app: swipe left to mark done, and+ * long-press to open an action drawer. All state is local; nothing hits the+ * network.+ */+export function OnboardingInbox() {+ const [emails, setEmails] = createSignal<EmailEntity[]>(MOCK_EMAILS);+ const [drawerEmail, setDrawerEmail] = createSignal<EmailEntity | null>(null);+ const [listRef, setListRef] = createSignal<HTMLElement>();++ const markDone = (id: string) =>+ setEmails((prev) => prev.filter((email) => email.id !== id));++ const closeDrawer = () => setDrawerEmail(null);++ // Grouped like the real SoupEntityActionDrawer: each group renders as its own+ // rounded section, with a gap between groups.+ const drawerActionGroups = (): DrawerActionGroup[] => {+ const email = drawerEmail();+ const removeEmail = () => {+ if (email) markDone(email.id);+ };+ return [+ { items: [{ label: 'Mark done', onClick: removeEmail }] },+ {+ items: [+ { label: 'Move to folder', onClick: () => {} },+ { label: 'Copy link', onClick: () => {} },+ ],+ },+ {+ label: 'Sender',+ items: [+ { label: 'Signal', onClick: () => {} },+ { label: 'Block sender', onClick: () => {} },+ ],+ },+ {+ items: [{ label: 'Delete', destructive: true, onClick: removeEmail }],+ },+ ];+ };++ return (+ <div class="flex flex-col gap-4">+ <h1 class="text-2xl font-semibold tracking-tight text-ink">The Inbox</h1>+ <p class="text-sm/relaxed text-ink/60">+ Swipe an email left to mark it done, or press and hold for more actions.+ </p>++ <ListLayoutProvider ref={listRef}>+ <EntityRowProvider+ container={listRef}+ canSwipeLeft={() => true}+ onSwipeLeft={(entityId) => markDone(entityId)}+ >+ <div ref={setListRef} class="overflow-hidden border-t border-edge">+ <For+ each={emails()}+ fallback={+ <div class="flex flex-col items-center justify-center gap-1 py-12 text-center">+ <p class="text-sm font-medium text-ink">Inbox zero 🎉</p>+ <p class="text-sm text-ink/60">You've cleared every email.</p>+ </div>+ }+ >+ {(email) => (+ <div+ ref={(el) =>+ touchHandler(el, () => ({+ onLongPress: () => setDrawerEmail(email),+ }))+ }+ >+ <ListEntity+ entity={email}+ timestamp={email.updatedAt}+ hideCheckbox+ entityRowConfig={{+ swipeLeftColor: 'bg-success',+ swipeLeftRevealedComponent: (+ <CheckIcon class="size-8 text-panel" />+ ),+ }}+ />+ </div>+ )}+ </For>+ </div>+ </EntityRowProvider>+ </ListLayoutProvider>++ {/* Long-press action drawer (markup modeled on SoupEntityActionDrawer). */}+ <MobileDrawer+ side="bottom"+ open={!!drawerEmail()}+ // The long-press opens the drawer while the finger is still down; with+ // Corvu's default "pointerup" strategy the release lands outside the+ // drawer and immediately dismisses it. Close only on a *new* outside+ // pointer-down instead (same as the real SoupEntityActionDrawer).+ closeOnOutsidePointerStrategy="pointerdown"+ onOpenChange={(open) => {+ if (!open) closeDrawer();+ }}+ >+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay" />+ <MobileDrawer.Content aria-label="Entity actions">+ <MobileDrawer.Handle />++ <Show when={drawerEmail()}>+ {(email) => (+ <div class="px-4 pb-4 shrink-0 text-sm font-medium text-ink-muted">+ <InlineEntity entity={email()} />+ </div>+ )}+ </Show>++ <For each={drawerActionGroups()}>+ {(group, groupIndex) => (+ <>+ <Show when={groupIndex() > 0}>+ <div class="mt-3" />+ </Show>+ <Show when={group.label}>+ <MobileDrawer.Label>{group.label}</MobileDrawer.Label>+ </Show>+ <MobileDrawer.Section class="flex flex-col shrink-0">+ <For each={group.items}>+ {(action) => (+ <button+ type="button"+ class={cn(+ 'flex items-center gap-3 px-4 py-3 text-sm text-left not-last:mb-px bg-surface hover:bg-hover hover-transition-bg',+ action.destructive ? 'text-failure-ink' : 'text-ink'+ )}+ onClick={() => {+ action.onClick();+ closeDrawer();+ }}+ >+ {action.label}+ </button>+ )}+ </For>+ </MobileDrawer.Section>+ </>+ )}+ </For>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ </MobileDrawer>+ </div>+ );+}diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsxindex 4a9dc31324..8088c0f033 100644--- a/js/app/packages/app/component/mobile/MobileDock.tsx+++ b/js/app/packages/app/component/mobile/MobileDock.tsx@@ -85,7 +85,7 @@ function MobileDockButton(props: MobileDockButtonProps) {props.class)}>- <div class={cn('size-6 [&_svg]:size-6', props.iconClass)}>+ <div class={cn('size-6 [&_svg]:size-6 shrink-0', props.iconClass)}>{props.animateIcon === false ? (<Dynamic component={props.icon} />) : (@@ -93,7 +93,7 @@ function MobileDockButton(props: MobileDockButtonProps) {)}</div><Show when={props.label}>- <span class="text-sm font-medium">{props.label}</span>+ <span class="text-sm font-medium truncate">{props.label}</span></Show></button>);@@ -175,7 +175,11 @@ function CreateMenu() {);}-export function MobileDock() {+type MobileDockProps = {+ class?: string;+};++export function MobileDock(props: MobileDockProps) {const { openWithSplit } = useSplitLayout();const location = useLocation();@@ -199,26 +203,31 @@ export function MobileDock() {};return (- <div class="flex items-center gap-3 px-(--mobile-chrome-gutter)">+ <div+ class={cn(+ 'flex items-center gap-3 px-(--mobile-chrome-gutter)',+ props.class+ )}+ ><MobileDockButtonicon={HomeIcon}ariaLabel="Home"animateIcon={false}- class="size-10 rounded-full"+ class="size-10 rounded-full shrink-0"active={isActive('home')}onClick={() => navigate('home')}/><MobileDockButtonicon={AnimatedInboxIcon}ariaLabel="Inbox"- class="size-10 rounded-full"+ class="size-10 rounded-full shrink-0"active={isActive('inbox')}onClick={() => navigate('inbox')}/><MobileDockButtonicon={AnimatedSearchIcon}label="Search"- class="h-10 flex-1 gap-1 rounded-full px-3"+ class="h-10 flex-1 min-w-0 gap-1 rounded-full px-3"onClick={() => {SearchState.maybeResetState();// Arm the focus before opening: iOS only raises the keyboard for adiff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsxindex c4e2f97a9a..806ff5d623 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx@@ -1,7 +1,4 @@-import {- openAddInboxDialog,- useAddInboxGate,-} from '@app/component/AddInboxDialog';+import { openAddInboxDialog } from '@app/component/AddInboxDialog';import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';import { CollapsibleHeaderItem } from '@app/component/split-layout/components/CollapsibleHeaderItem';import { useFeatureFlag } from '@app/lib/analytics/posthog';@@ -33,7 +30,6 @@ export function InboxSelector() {enabledOverride: ENABLE_MULTI_INBOX_OVERRIDE,});const { openSettings } = useSettingsState();- const guardAddInbox = useAddInboxGate();const label = () => {const ids = inboxFilter();@@ -57,11 +53,10 @@ export function InboxSelector() {? {label: 'Add inbox',icon: () => <PlusIcon class="size-4" />,- onSelect: () =>- guardAddInbox(() => {- openSettings('Connected');- openAddInboxDialog();- }),+ onSelect: () => {+ openSettings('Connected');+ openAddInboxDialog();+ },}: undefined}diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsxindex 633e204fe2..83b746a1c6 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx@@ -1,4 +1,3 @@-import { useAddInboxGate } from '@app/component/AddInboxDialog';import {MobileDrawer,scrollToFocusedInput,@@ -113,7 +112,6 @@ export const MobileFilterDrawer = () => {enabledOverride: ENABLE_MULTI_INBOX_OVERRIDE,});const addInbox = useAddInboxFlow();- const guardAddInbox = useAddInboxGate();// Mirrors the desktop InboxSelector's visibility rule so the "Add inbox"// action stays discoverable with zero or one inbox connected. Also stays@@ -442,7 +440,7 @@ export const MobileFilterDrawer = () => {<buttontype="button"class="w-full flex items-center gap-3 px-3 py-2.5 text-sm hover:bg-hover transition-colors text-left bg-surface not-last:mb-px"- onClick={() => guardAddInbox(() => void addInbox())}+ onClick={() => void addInbox()}><span class="size-4 flex items-center justify-center shrink-0"><PlusIcon class="size-4 text-ink-muted" />diff --git a/js/app/packages/app/component/settings/Email.tsx b/js/app/packages/app/component/settings/Email.tsxindex 74d1ac3e83..1fe8b0fcda 100644--- a/js/app/packages/app/component/settings/Email.tsx+++ b/js/app/packages/app/component/settings/Email.tsx@@ -32,11 +32,7 @@ import {useEmailLinks,useEmailLinksStatus,} from '@core/email-link';-import {- AddInboxDialog,- openAddInboxDialog,- useAddInboxGate,-} from '../AddInboxDialog';+import { AddInboxDialog, openAddInboxDialog } from '../AddInboxDialog';import { useRemoveInboxMutation } from '@queries/email/link';import { IntegrationRow, SettingsCard, SettingsRow } from './primitives';import { ConnectAction, StatusDot } from './integration-ui';@@ -59,7 +55,6 @@ export function EmailCard() {const multiInboxFlag = useFeatureFlag('enable-multi-inbox', {enabledOverride: ENABLE_MULTI_INBOX_OVERRIDE,});- const guardAddInbox = useAddInboxGate();const { query: emailLinksQuery, resyncInbox } = useEmailLinks();const emailActive = useEmailLinksStatus();@@ -229,7 +224,7 @@ export function EmailCard() {size="icon-sm"depth={3}aria-label="Add inbox"- onClick={() => guardAddInbox(openAddInboxDialog)}+ onClick={openAddInboxDialog}><PlusIcon class="size-4" /></Button>diff --git a/js/app/packages/core/constant/PaywallState.tsx b/js/app/packages/core/constant/PaywallState.tsxindex bd89a007b0..ff1eead0bc 100644--- a/js/app/packages/core/constant/PaywallState.tsx+++ b/js/app/packages/core/constant/PaywallState.tsx@@ -80,7 +80,7 @@ export const PaywallMessages: Record<PaywallKey, PaywallMessageMetadata> = {},[PaywallKey.MULTI_INBOX]: {title: 'Connect more inboxes',- description: 'Upgrade to manage multiple email inboxes from one workspace.',+ description: 'Upgrade your plan to connect more than two inboxes.',learnMoreUrl: 'https://docs.macro.com/product/inbox',learnMoreSubject: 'multiple inboxes',},diff --git a/js/app/packages/core/email-link/index.ts b/js/app/packages/core/email-link/index.tsindex d0e75309e5..d01349ebe4 100644--- a/js/app/packages/core/email-link/index.ts+++ b/js/app/packages/core/email-link/index.ts@@ -1,6 +1,7 @@import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';import { updateUserAuth } from '@core/auth';import { toast } from '@core/component/Toast/Toast';+import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';import { getNativeMobilePlatform } from '@core/util/platform';import { useInitGmailLink } from '@queries/auth';import { invalidateUserInfo } from '@queries/auth/user-info';@@ -175,6 +176,17 @@ export function initAndStartEmailSync() {return initEmailLink().map(startEmailPolling).map(invalidations);}+/**+ * The backend gates additional inboxes behind a paid subscription and answers+ * `POST /link/gmail` with 402 when the user isn't entitled. The auth client maps+ * that to a `PAYMENT_REQUIRED` error code; the add-inbox flow surfaces the+ * paywall instead of a generic failure so the backend stays the source of truth+ * on entitlement.+ */+function isPaymentRequired(errors: ReadonlyArray<{ code: string }>): boolean {+ return errors.some((error) => error.code === 'PAYMENT_REQUIRED');+}+/*** Starts the add-inbox flow: fetches the Gmail link authorization URL and* navigates the browser to the OAuth consent page. The callback returns to@@ -189,6 +201,7 @@ export function initAndStartEmailSync() {export function useAddInboxFlow() {const initGmailLink = useInitGmailLink();const { query, initEmailLink } = useEmailLinks();+ const { showPaywall } = usePaywallState();const completeNativeLink = async (linkId: string, forceShare: boolean) => {await initEmailLink({ linkId, forceShare }).match(@@ -219,6 +232,10 @@ export function useAddInboxFlow() {'macro://inbox-link-callback');if (result.isErr()) {+ if (isPaymentRequired(result.error)) {+ showPaywall(PaywallKey.MULTI_INBOX);+ return;+ }toast.failure('Failed to start Gmail link flow', { mobile: true });return;}@@ -258,6 +275,8 @@ export function useAddInboxFlow() {const result = await initGmailLink.mutateAsync(callbackUrl);if (result.isOk()) {window.location.href = result.value.authorization_url;+ } else if (isPaymentRequired(result.error)) {+ showPaywall(PaywallKey.MULTI_INBOX);} else {toast.failure('Failed to start Gmail link flow');}diff --git a/js/app/packages/icon/macro-logo.svg b/js/app/packages/icon/macro-logo.svgindex ca465d7fc7..1f4ed7bc88 100644--- a/js/app/packages/icon/macro-logo.svg+++ b/js/app/packages/icon/macro-logo.svg@@ -1,3 +1,5 @@<svg width="100%" height="100%" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">- <path d="m6.25 4.038-2.242 0.8792v5.8184l-1.756-1.6582-2.242 0.8792v6.6766c0 0.2568 0.106 0.502 0.292 0.6784l2.794 2.6422 2.244-0.879v-5.8184l7.084 6.6974 2.244-0.879v-5.8184l7.086 6.6976 2.24-0.8792v-6.6766c0-0.2568-0.104-0.5022-0.292-0.6784l-8.124-7.6816-2.244 0.879v5.8184z"/>+ <path d="M0 10.014v6.801a.75.75 0 0 0 .225.513l2.742 2.644 2.002-.8v-7.099l-2.97-2.859z"/>+ <path d="M4.078 4.8v5.786l1.36 1.309v1.313L12.481 20l2.002-.8-.001-7.1L6.078 4z"/>+ <path d="M13.594 4.8v5.786l1.36 1.311-.013 1.3L22 20 24 19.2V12.42a.75.75 0 0 0-.225-.533L15.595 4z"/></svg>diff --git a/js/app/packages/service-clients/service-auth/client.ts b/js/app/packages/service-clients/service-auth/client.tsindex 7ee76ebd5c..5fcc3b7418 100644--- a/js/app/packages/service-clients/service-auth/client.ts+++ b/js/app/packages/service-clients/service-auth/client.ts@@ -566,8 +566,18 @@ export const authServiceClient = {? `${authHost}/link/gmail?original_url=${encodeURIComponent(originalUrl)}`: `${authHost}/link/gmail`;return (- await fetchWithAuth<InitGmailLinkResponse>(url, {+ await fetchWithAuth<InitGmailLinkResponse, 'PAYMENT_REQUIRED'>(url, {method: 'POST',+ // The backend returns 402 when the user isn't entitled to additional+ // inboxes; surface it as a distinct code so the add-inbox flow can open+ // the paywall instead of showing a generic failure.+ errorResponseHandler: async (response) =>+ response.status === 402+ ? { code: 'PAYMENT_REQUIRED', message: 'Payment required' }+ : {+ code: 'HTTP_ERROR',+ message: `HTTP error! status: ${response.status}`,+ },})).map((result) => result);},diff --git a/js/app/packages/ui/components/Button.tsx b/js/app/packages/ui/components/Button.tsxindex 15da379901..ab3a47b4e8 100644--- a/js/app/packages/ui/components/Button.tsx+++ b/js/app/packages/ui/components/Button.tsx@@ -44,6 +44,7 @@ export type ButtonVariant =| 'active'| 'success'| 'danger'+ | 'contrast'| 'cta';const variantStyles: Record<ButtonVariant, string> = {@@ -56,6 +57,8 @@ const variantStyles: Record<ButtonVariant, string> = {'bg-success-bg not-disabled:hover:bg-success/30 text-success disabled:opacity-30 ',ghost:'bg-transparent text-ink-muted not-disabled:hover:bg-hover not-disabled:hover:text-ink active:bg-active disabled:opacity-30 ',+ contrast:+ 'bg-ink text-surface border border-transparent not-disabled:hover:bg-ink/90 active:bg-ink/80 disabled:opacity-30 focus-visible:bg-ink/90',cta: 'bg-accent text-surface border border-transparent not-disabled:hover:bg-accent/90 active:bg-accent/80 disabled:opacity-30 focus-visible:bg-accent/90',};diff --git a/js/app/packages/ui/components/ButtonGroup.tsx b/js/app/packages/ui/components/ButtonGroup.tsxindex 3fae89e111..86b357358f 100644--- a/js/app/packages/ui/components/ButtonGroup.tsx+++ b/js/app/packages/ui/components/ButtonGroup.tsx@@ -33,6 +33,7 @@ const groupVariantStyles: Record<ButtonVariant, string> = {active: 'border border-accent ',success: 'border border-success ',ghost: ' ',+ contrast: 'border border-transparent',cta: 'border border-transparent ',};@@ -42,6 +43,7 @@ const dividerVariantStyles: Record<ButtonVariant, string> = {active: 'bg-accent',success: 'bg-success',ghost: 'bg-edge-muted',+ contrast: 'bg-surface/50',cta: 'bg-surface/50',};