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(paywall): new paywall content and plans (behind ff) (#3508)
dev-rb30a4b5728da8
diff --git a/js/app/packages/app/component/paywall/PaywallComponent.tsx b/js/app/packages/app/component/paywall/PaywallComponent.tsxindex 6a4a548e44..e85e6a6b4c 100644--- a/js/app/packages/app/component/paywall/PaywallComponent.tsx+++ b/js/app/packages/app/component/paywall/PaywallComponent.tsx@@ -1,26 +1,10 @@-import { useAnalytics } from '@app/component/analytics-context';-import { useHasPaidAccess } from '@core/auth';-import { toast } from '@core/component/Toast/Toast';-import { type PaywallKey, PaywallMessages } from '@core/constant/PaywallState';-import { usePermissions } from '@core/context/user';-import IconX from '@phosphor/x.svg';-import { invalidateUserInfo } from '@queries/auth/user-info';-import { stripeServiceClient } from '@service-stripe/client';-import { Button, cn } from '@ui';-import { createMemo, createSignal, For, Show } from 'solid-js';-import { match } from 'ts-pattern';-import { type PaidPlanTier, PLAN_FEATURES, PLANS } from './plans';-import SubscriptionTier from './SubscriptionTier';+import { ShowFeatureFlag } from '@app/lib/analytics/posthog';+import { ENABLE_NEW_PRICING_OVERRIDE } from '@core/constant/featureFlags';+import type { PaywallKey } from '@core/constant/PaywallState';+import PaywallComponentLegacy from './PaywallComponentLegacy';+import PaywallComponentNew from './PaywallComponentNew';-// Paid-only plans for the billing paywall — Stripe has no product for the-// 'free' tier, so it must be excluded here. Filtered once at module scope so-// the component doesn't re-filter on every render.-const PAID_PLANS = PLANS.filter(- (p): p is Extract<(typeof PLANS)[number], { tier: PaidPlanTier }> =>- p.tier !== 'free'-);--interface PaywallComponent {+export interface PaywallProps {cb: () => Promise<void> | void;handleGuest?: () => void;isOnboarding?: boolean;@@ -29,230 +13,14 @@ interface PaywallComponent {hideCloseButton?: boolean;}-const PaywallComponent = (props: PaywallComponent) => {- const analytics = useAnalytics();- const permissions = usePermissions();- const hasPaid = useHasPaidAccess();-- // Tier a paying user is currently subscribed to, derived from RBAC permissions- // (sub_opus grants write:opus; sub_sonnet grants write:sonnet + write:haiku;- // sub_haiku grants write:haiku — so check highest-to-lowest).- const currentTier = createMemo((): PaidPlanTier | undefined => {- if (!hasPaid()) return undefined;- const perms = permissions();- if (perms.includes('write:opus')) return 'opus';- if (perms.includes('write:sonnet')) return 'sonnet';- if (perms.includes('write:haiku')) return 'haiku';- return undefined;- });-- // `userSelectedTier` is only set when the user explicitly clicks a plan card. Until- // then the UI derives its selection from `currentTier` (falling back to 'sonnet' for- // non-paying users). This avoids mirroring derived state into a signal via `createEffect`- // and also sidesteps the briefly-wrong-card window before permissions resolve.- const [userSelectedTier, setUserSelectedTier] =- createSignal<PaidPlanTier | null>(null);- const selectedTier = createMemo<PaidPlanTier>(- () => userSelectedTier() ?? currentTier() ?? 'sonnet'- );-- const [updating, setUpdating] = createSignal(false);-- const handleCheckout = async (tier: PaidPlanTier) => {- try {- await props.cb();- const url = await stripeServiceClient.createCheckoutSession({- type: props.customType- ? props.customType- : (props.errorKey ?? undefined),- tier,- });- analytics.track('subscription_start', {- type: tier,- customType: props.customType,- errorKey: props.errorKey,- });- window.location.href = url;- } catch (error) {- console.error(error);- }- };-- const manageSubscription = async () => {- try {- const url = await stripeServiceClient.createPortalSession();- window.location.href = url;- } catch (error) {- console.error(error);- }- };-- const handleContinue = () => {- if (hasPaid()) {- manageSubscription();- return;- }- handleCheckout(selectedTier());- };-- const handleUpdateTier = async () => {- const next = selectedTier();- const prev = currentTier();- if (!prev || next === prev) return;- setUpdating(true);- try {- const result = await stripeServiceClient.updateSubscriptionTier(next);- if (!result.ok) {- // Messages mirror the backend's StripeOperationError `Display` impls, adapted- // to second-person for UI. `.exhaustive()` fails the build if the code union- // grows a new variant without a toast case.- const message = match(result.code)- .with('USER_IN_TEAM', () => 'Contact your team owner to update.')- .with(- 'UPDATE_IN_PROGRESS',- () =>- 'Another subscription update is already in progress. Please try again in a moment.'- )- .with(- 'NO_SUBSCRIPTION',- () => "You don't have an active subscription to update."- )- .with(- 'TIER_UNCHANGED',- () => 'Subscription is already on the requested tier.'- )- .with('UNKNOWN', () => 'Failed to update subscription.')- .exhaustive();- toast.failure(message);- return;- }- analytics.track('subscription_tier_updated', { from: prev, to: next });- // Refetches permissions so `currentTier` reflects the new tier and this button- // auto-hides (selectedTier === currentTier).- await invalidateUserInfo();- toast.success('Subscription updated!');- } finally {- setUpdating(false);- }- };-- return (- <div class="relative space-y-2 w-full">- <Show when={!props.hideCloseButton}>- <button- onClick={props.cb}- class="absolute -top-2 -right-2 sm:-top-3 sm:-right-3 text-ink-extra-muted hover:text-ink transition-colors z-10"- >- <IconX class="size-5 sm:size-6" />- </button>- </Show>- <Show when={!hasPaid()}>- <div class="relative w-full text-center">- <div class="space-y-6 sm:space-y-8">- <div class="text-center">- <h2 class="mb-2 font-semibold text-ink text-xl sm:text-2xl">- Choose your plan- </h2>- <Show when={props.errorKey}>- <p class="mb-4 text-failure-ink text-sm sm:text-base">- {PaywallMessages[props.errorKey as PaywallKey]}- </p>- </Show>- </div>- </div>- </div>- </Show>-- <div class="w-full @container">- <div class="gap-2 grid grid-cols-1 @[530px]:grid-cols-3">- <For each={PAID_PLANS}>- {(plan) => (- <button- onClick={() => setUserSelectedTier(plan.tier)}- class={cn(- selectedTier() === plan.tier- ? 'border-accent bg-active'- : 'border-edge hover:border-edge',- 'p-4 sm:p-5 border flex flex-col transition-all relative text-left rounded-sm'- )}- >- <div class="flex flex-col gap-3 w-full">- <div class="flex justify-between items-start">- <div>- <div class="font-semibold text-ink text-base sm:text-lg">- {plan.name}- </div>- </div>- <SubscriptionTier- class="w-7 shrink-0"- tier={- selectedTier() === plan.tier ? plan.tier : undefined- }- />- </div>- <div class="flex items-baseline gap-0.5">- <span class="text-3xl font-bold text-ink">- ${plan.price}- </span>- <span class="text-base text-ink/40">/mo</span>- </div>- <div class="text-sm text-ink/60 flex flex-col gap-1">- <For each={PLAN_FEATURES}>- {(feature) => (- <span>- {feature.label}: {feature.values[plan.tier]}- </span>- )}- </For>- </div>- </div>- </button>- )}- </For>- </div>- </div>-- <div class="w-full">- <Show- when={hasPaid() && currentTier() && selectedTier() !== currentTier()}- fallback={- <Button- onClick={handleContinue}- variant="base"- size="lg"- depth={3}- class="w-full"- >- <Show when={!hasPaid()} fallback={'Manage Subscription'}>- Get {PLANS.find((p) => p.tier === selectedTier())?.name}- </Show>- </Button>- }- >- <Button- onClick={handleUpdateTier}- disabled={updating()}- variant="active"- size="lg"- depth={3}- class="w-full"- >- {updating() ? 'Updating…' : 'Update Subscription'}- </Button>- </Show>- <Show when={!hasPaid() && props.handleGuest}>- <Button- onClick={() => props.handleGuest?.()}- variant="base"- size="sm"- class="mt-3 text-ink/40 hover:text-ink/60"- >- Continue with free plan- </Button>- </Show>- </div>- </div>- );-};+const PaywallComponent = (props: PaywallProps) => (+ <ShowFeatureFlag+ key="enable-new-pricing"+ enabledOverride={ENABLE_NEW_PRICING_OVERRIDE}+ fallback={<PaywallComponentLegacy {...props} />}+ >+ <PaywallComponentNew {...props} />+ </ShowFeatureFlag>+);export default PaywallComponent;diff --git a/js/app/packages/app/component/paywall/PaywallComponentLegacy.tsx b/js/app/packages/app/component/paywall/PaywallComponentLegacy.tsxnew file mode 100644index 0000000000..e4f4e941b7--- /dev/null+++ b/js/app/packages/app/component/paywall/PaywallComponentLegacy.tsx@@ -0,0 +1,245 @@+import { useAnalytics } from '@app/component/analytics-context';+import { useHasPaidAccess } from '@core/auth';+import { toast } from '@core/component/Toast/Toast';+import { type PaywallKey, PaywallMessages } from '@core/constant/PaywallState';+import { usePermissions } from '@core/context/user';+import IconX from '@phosphor/x.svg';+import { invalidateUserInfo } from '@queries/auth/user-info';+import type { StripeProductTier } from '@service-auth/generated/schemas/stripeProductTier';+import { stripeServiceClient } from '@service-stripe/client';+import { Button, cn } from '@ui';+import { createMemo, createSignal, For, Show } from 'solid-js';+import { match } from 'ts-pattern';+import type { PaywallProps } from './PaywallComponent';+import { LEGACY_PLANS, type PaidPlanTier, PLAN_FEATURES } from './plans';+import SubscriptionTier from './SubscriptionTier';++type LegacyPaidPlan = Exclude<(typeof LEGACY_PLANS)[number], { tier: 'free' }>;++// Paid-only plans for the billing paywall — Stripe has no product for the+// 'free' tier, so it must be excluded here.+const PaywallComponentLegacy = (props: PaywallProps) => {+ const paidPlans = LEGACY_PLANS.filter(+ (p): p is LegacyPaidPlan => p.tier !== 'free'+ );++ const analytics = useAnalytics();+ const permissions = usePermissions();+ const hasPaid = useHasPaidAccess();++ // Tier a paying user is currently subscribed to, derived from RBAC permissions+ // (sub_opus grants write:opus; sub_sonnet grants write:sonnet + write:haiku;+ // sub_haiku grants write:haiku — so check highest-to-lowest).+ const currentTier = createMemo((): PaidPlanTier | undefined => {+ if (!hasPaid()) return undefined;+ const perms = permissions();+ if (perms.includes('write:opus')) return 'opus';+ if (perms.includes('write:sonnet')) return 'sonnet';+ if (perms.includes('write:haiku')) return 'haiku';+ return undefined;+ });++ const [userSelectedTier, setUserSelectedTier] =+ createSignal<PaidPlanTier | null>(null);+ const selectedTier = createMemo<PaidPlanTier>(+ () => userSelectedTier() ?? currentTier() ?? 'sonnet'+ );++ const [updating, setUpdating] = createSignal(false);++ const handleCheckout = async (tier: PaidPlanTier) => {+ try {+ await props.cb();+ const url = await stripeServiceClient.createCheckoutSession({+ type: props.customType+ ? props.customType+ : (props.errorKey ?? undefined),+ tier: tier as StripeProductTier,+ });+ analytics.track('subscription_start', {+ type: tier,+ customType: props.customType,+ errorKey: props.errorKey,+ });+ window.location.href = url;+ } catch (error) {+ console.error(error);+ }+ };++ const manageSubscription = async () => {+ try {+ const url = await stripeServiceClient.createPortalSession();+ window.location.href = url;+ } catch (error) {+ console.error(error);+ }+ };++ const handleContinue = () => {+ if (hasPaid()) {+ manageSubscription();+ return;+ }+ handleCheckout(selectedTier());+ };++ const handleUpdateTier = async () => {+ const next = selectedTier();+ const prev = currentTier();+ if (!prev || next === prev) return;+ setUpdating(true);+ try {+ const result = await stripeServiceClient.updateSubscriptionTier(+ next as StripeProductTier+ );+ if (!result.ok) {+ const message = match(result.code)+ .with('USER_IN_TEAM', () => 'Contact your team owner to update.')+ .with(+ 'UPDATE_IN_PROGRESS',+ () =>+ 'Another subscription update is already in progress. Please try again in a moment.'+ )+ .with(+ 'NO_SUBSCRIPTION',+ () => "You don't have an active subscription to update."+ )+ .with(+ 'TIER_UNCHANGED',+ () => 'Subscription is already on the requested tier.'+ )+ .with('UNKNOWN', () => 'Failed to update subscription.')+ .exhaustive();+ toast.failure(message);+ return;+ }+ analytics.track('subscription_tier_updated', { from: prev, to: next });+ await invalidateUserInfo();+ toast.success('Subscription updated!');+ } finally {+ setUpdating(false);+ }+ };++ return (+ <div class="relative space-y-2 w-full">+ <Show when={!props.hideCloseButton}>+ <button+ onClick={props.cb}+ class="absolute -top-2 -right-2 sm:-top-3 sm:-right-3 text-ink-extra-muted hover:text-ink transition-colors z-10"+ >+ <IconX class="size-5 sm:size-6" />+ </button>+ </Show>+ <Show when={!hasPaid()}>+ <div class="relative w-full text-center">+ <div class="space-y-6 sm:space-y-8">+ <div class="text-center">+ <h2 class="mb-2 font-semibold text-ink text-xl sm:text-2xl">+ Choose your plan+ </h2>+ <Show when={props.errorKey}>+ <p class="mb-4 text-failure-ink text-sm sm:text-base">+ {PaywallMessages[props.errorKey as PaywallKey]}+ </p>+ </Show>+ </div>+ </div>+ </div>+ </Show>++ <div class="w-full @container">+ <div class="gap-2 grid grid-cols-1 @[530px]:grid-cols-3">+ <For each={paidPlans}>+ {(plan) => (+ <button+ onClick={() => setUserSelectedTier(plan.tier)}+ class={cn(+ selectedTier() === plan.tier+ ? 'border-accent bg-active'+ : 'border-edge hover:border-edge',+ 'p-4 sm:p-5 border flex flex-col transition-all relative text-left rounded-sm'+ )}+ >+ <div class="flex flex-col gap-3 w-full">+ <div class="flex justify-between items-start">+ <div>+ <div class="font-semibold text-ink text-base sm:text-lg">+ {plan.name}+ </div>+ </div>+ <SubscriptionTier+ class="w-7 shrink-0"+ total={3}+ tier={+ selectedTier() === plan.tier ? plan.tier : undefined+ }+ />+ </div>+ <div class="flex items-baseline gap-0.5">+ <span class="text-3xl font-bold text-ink">+ ${plan.price}+ </span>+ <span class="text-base text-ink/40">/mo</span>+ </div>+ <div class="text-sm text-ink/60 flex flex-col gap-1">+ <For each={PLAN_FEATURES}>+ {(feature) => (+ <span>+ {feature.label}: {feature.values[plan.tier]}+ </span>+ )}+ </For>+ </div>+ </div>+ </button>+ )}+ </For>+ </div>+ </div>++ <div class="w-full">+ <Show+ when={hasPaid() && currentTier() && selectedTier() !== currentTier()}+ fallback={+ <Button+ onClick={handleContinue}+ variant="base"+ size="lg"+ depth={3}+ class="w-full"+ >+ <Show when={!hasPaid()} fallback={'Manage Subscription'}>+ Get {LEGACY_PLANS.find((p) => p.tier === selectedTier())?.name}+ </Show>+ </Button>+ }+ >+ <Button+ onClick={handleUpdateTier}+ disabled={updating()}+ variant="active"+ size="lg"+ depth={3}+ class="w-full"+ >+ {updating() ? 'Updating…' : 'Update Subscription'}+ </Button>+ </Show>+ <Show when={!hasPaid() && props.handleGuest}>+ <Button+ onClick={() => props.handleGuest?.()}+ variant="base"+ size="sm"+ class="mt-3 text-ink/40 hover:text-ink/60"+ >+ Continue with free plan+ </Button>+ </Show>+ </div>+ </div>+ );+};++export default PaywallComponentLegacy;diff --git a/js/app/packages/app/component/paywall/PaywallComponentNew.tsx b/js/app/packages/app/component/paywall/PaywallComponentNew.tsxnew file mode 100644index 0000000000..0b7626c0eb--- /dev/null+++ b/js/app/packages/app/component/paywall/PaywallComponentNew.tsx@@ -0,0 +1,179 @@+import { useAnalytics } from '@app/component/analytics-context';+import { useHasPaidAccess } from '@core/auth';+import { type PaywallKey, PaywallMessages } from '@core/constant/PaywallState';+import IconX from '@phosphor/x.svg';+import { stripeServiceClient } from '@service-stripe/client';+import { Button, cn } from '@ui';+import { createMemo, createSignal, For, Show } from 'solid-js';+import type { PaywallProps } from './PaywallComponent';+import { NEW_PLANS, PLAN_FEATURES, type PlanTier } from './plans';+import SubscriptionTier from './SubscriptionTier';++const PaywallComponentNew = (props: PaywallProps) => {+ const analytics = useAnalytics();+ const hasPaid = useHasPaidAccess();++ const currentTier = createMemo<PlanTier>(() =>+ hasPaid() ? 'premium' : 'free'+ );++ // `userSelectedTier` is only set when the user explicitly clicks a plan card. Until+ // then the UI reflects `currentTier`. This avoids mirroring derived state into a signal+ // via `createEffect` and sidesteps the briefly-wrong-card window before permissions resolve.+ const [userSelectedTier, setUserSelectedTier] = createSignal<PlanTier | null>(+ null+ );+ const selectedTier = createMemo<PlanTier>(+ () => userSelectedTier() ?? currentTier()+ );++ const handleCheckout = async () => {+ try {+ await props.cb();+ const url = await stripeServiceClient.createCheckoutSessionV2({+ type: props.customType+ ? props.customType+ : (props.errorKey ?? undefined),+ });+ analytics.track('subscription_start', {+ type: 'premium',+ customType: props.customType,+ errorKey: props.errorKey,+ });+ window.location.href = url;+ } catch (error) {+ console.error(error);+ }+ };++ const manageSubscription = async () => {+ try {+ const url = await stripeServiceClient.createPortalSession();+ window.location.href = url;+ } catch (error) {+ console.error(error);+ }+ };++ const handleContinue = () => {+ const tier = selectedTier();+ // Paid users go to the Stripe portal regardless of selection — that's where+ // they cancel (downgrade to free) or manage billing on premium.+ if (hasPaid()) {+ manageSubscription();+ return;+ }+ if (tier === 'free') {+ props.handleGuest?.();+ return;+ }+ handleCheckout();+ };++ const ctaLabel = () => {+ if (hasPaid()) {+ return selectedTier() === 'free' ? 'Downgrade' : 'Manage Subscription';+ }+ if (selectedTier() === 'free') return 'Continue with Free';+ return 'Get Premium';+ };++ return (+ <div class="relative space-y-2 w-full">+ <Show when={!props.hideCloseButton}>+ <button+ onClick={props.cb}+ class="absolute -top-2 -right-2 sm:-top-3 sm:-right-3 text-ink-extra-muted hover:text-ink transition-colors z-10"+ >+ <IconX class="size-5 sm:size-6" />+ </button>+ </Show>+ <Show when={!hasPaid()}>+ <div class="relative w-full text-center">+ <div class="space-y-6 sm:space-y-8">+ <div class="text-center">+ <h2 class="mb-2 font-semibold text-ink text-xl sm:text-2xl">+ Choose your plan+ </h2>+ <Show when={props.errorKey}>+ <p class="mb-4 text-failure-ink text-sm sm:text-base">+ {PaywallMessages[props.errorKey as PaywallKey]}+ </p>+ </Show>+ </div>+ </div>+ </div>+ </Show>++ <div class="w-full @container">+ <div class="gap-2 grid grid-cols-1 @[400px]:grid-cols-2">+ <For each={NEW_PLANS}>+ {(plan) => (+ <button+ onClick={() => setUserSelectedTier(plan.tier)}+ class={cn(+ selectedTier() === plan.tier+ ? 'border-accent bg-active'+ : 'border-edge hover:border-edge',+ 'p-4 sm:p-5 border flex flex-col transition-all relative text-left rounded-sm'+ )}+ >+ <div class="flex flex-col gap-3 w-full">+ <div class="flex justify-between items-start">+ <div class="flex items-center gap-2">+ <div class="font-semibold text-ink text-base sm:text-lg">+ {plan.name}+ </div>+ <Show when={currentTier() === plan.tier}>+ <span class="text-xs text-ink/60 px-1.5 py-0.5 border border-edge-muted rounded">+ Current+ </span>+ </Show>+ </div>+ <SubscriptionTier+ class="w-7 shrink-0"+ total={1}+ tier={plan.tier === 'premium' ? 'premium' : undefined}+ />+ </div>+ <div class="flex items-baseline gap-0.5">+ <span class="text-3xl font-bold text-ink">+ ${plan.price}+ </span>+ <span class="text-base text-ink/40">/mo</span>+ </div>+ <div class="text-sm text-ink/60 flex flex-col gap-1">+ <For each={PLAN_FEATURES}>+ {(feature) => (+ <span>+ {feature.label}: {feature.values[plan.tier]}+ </span>+ )}+ </For>+ </div>+ </div>+ </button>+ )}+ </For>+ </div>+ </div>++ <div class="w-full">+ <Button+ onClick={handleContinue}+ variant="base"+ size="lg"+ depth={3}+ class="w-full"+ disabled={+ !hasPaid() && selectedTier() === 'free' && !props.handleGuest+ }+ >+ {ctaLabel()}+ </Button>+ </div>+ </div>+ );+};++export default PaywallComponentNew;diff --git a/js/app/packages/app/component/paywall/PaywallTeamMemberView.tsx b/js/app/packages/app/component/paywall/PaywallTeamMemberView.tsxnew file mode 100644index 0000000000..61827c42b4--- /dev/null+++ b/js/app/packages/app/component/paywall/PaywallTeamMemberView.tsx@@ -0,0 +1,19 @@+const PaywallTeamMemberView = () => (+ <div class="relative space-y-2 w-full">+ <div class="p-4 sm:p-5 border border-edge flex flex-col gap-3 text-left rounded-sm">+ <div class="flex justify-between items-start">+ <div class="font-semibold text-ink text-base sm:text-lg">+ Team subscription+ </div>+ </div>+ <div class="text-sm text-ink/60 flex flex-col gap-1">+ <span>+ Your subscription is managed by your team owner. Contact them to make+ changes.+ </span>+ </div>+ </div>+ </div>+);++export default PaywallTeamMemberView;diff --git a/js/app/packages/app/component/paywall/PaywallTeamOwnerView.tsx b/js/app/packages/app/component/paywall/PaywallTeamOwnerView.tsxnew file mode 100644index 0000000000..e008723bda--- /dev/null+++ b/js/app/packages/app/component/paywall/PaywallTeamOwnerView.tsx@@ -0,0 +1,63 @@+import { useTeamQuery } from '@queries/team';+import type { Team } from '@service-auth/generated/schemas/team';+import { stripeServiceClient } from '@service-stripe/client';+import { Button } from '@ui';+import { createMemo } from 'solid-js';+import { NEW_PLANS } from './plans';+import SubscriptionTier from './SubscriptionTier';++interface PaywallTeamOwnerViewProps {+ team: Team;+}++const PREMIUM_PRICE = NEW_PLANS.find((p) => p.tier === 'premium')!.price;++const PaywallTeamOwnerView = (props: PaywallTeamOwnerViewProps) => {+ const teamQuery = useTeamQuery(() => props.team.id);+ const memberCount = createMemo(() => teamQuery.data?.members.length ?? 0);+ const totalPrice = createMemo(() => memberCount() * PREMIUM_PRICE);++ const handleManage = async () => {+ try {+ const url = await stripeServiceClient.createPortalSession();+ window.location.href = url;+ } catch (error) {+ console.error(error);+ }+ };++ return (+ <div class="relative space-y-2 w-full">+ <div class="p-4 sm:p-5 bg-active flex flex-col gap-3 text-left rounded-sm">+ <div class="flex justify-between items-start">+ <div class="font-semibold text-ink text-base sm:text-lg">+ {props.team.name}+ </div>+ <SubscriptionTier class="w-7 shrink-0" total={1} tier="premium" />+ </div>+ <div class="flex items-baseline gap-0.5">+ <span class="text-3xl font-bold text-ink">${totalPrice()}</span>+ <span class="text-base text-ink/40">/mo</span>+ </div>+ <div class="text-sm text-ink/60 flex flex-col gap-1">+ <span>Plan: Premium</span>+ <span>Seats: {memberCount()}</span>+ <span>Price per seat: ${PREMIUM_PRICE}/mo</span>+ </div>+ </div>+ <div class="w-full">+ <Button+ onClick={handleManage}+ variant="base"+ size="lg"+ depth={3}+ class="w-full"+ >+ Manage Subscription+ </Button>+ </div>+ </div>+ );+};++export default PaywallTeamOwnerView;diff --git a/js/app/packages/app/component/paywall/SubscriptionTier.tsx b/js/app/packages/app/component/paywall/SubscriptionTier.tsxindex f4b5c2aec4..69799b6461 100644--- a/js/app/packages/app/component/paywall/SubscriptionTier.tsx+++ b/js/app/packages/app/component/paywall/SubscriptionTier.tsx@@ -3,6 +3,7 @@ import type { PaidPlanTier } from './plans';interface SubscriptionTierProps {tier?: PaidPlanTier;+ total: number;class?: string;}@@ -10,11 +11,14 @@ const TIER_TO_LEVEL: Record<PaidPlanTier, number> = {haiku: 1,sonnet: 2,opus: 3,+ premium: 1,};const SubscriptionTier = (props: SubscriptionTierProps) => {const level = () => (props.tier ? TIER_TO_LEVEL[props.tier] : 0);- return <LogoProgress level={level()} total={3} class={props.class} />;+ return (+ <LogoProgress level={level()} total={props.total} class={props.class} />+ );};export default SubscriptionTier;diff --git a/js/app/packages/app/component/paywall/plans.ts b/js/app/packages/app/component/paywall/plans.tsindex bfa56f864f..8e260dcb8e 100644--- a/js/app/packages/app/component/paywall/plans.ts+++ b/js/app/packages/app/component/paywall/plans.ts@@ -1,10 +1,12 @@-export const PLANS = [- {- tier: 'free' as const,- name: 'Level 0',- price: 0,- highlighted: false,- },+const FREE_PLAN = {+ tier: 'free' as const,+ name: 'Level 0',+ price: 0,+ highlighted: false,+};++export const LEGACY_PLANS = [+ { ...FREE_PLAN },{tier: 'haiku' as const,name: 'Level 1',@@ -25,11 +27,39 @@ export const PLANS = [},] as const;-export type PlanTier = (typeof PLANS)[number]['tier'];-export type Plan = (typeof PLANS)[number];+export const NEW_PLANS = [+ {+ tier: 'free' as const,+ name: 'Free',+ price: 0,+ highlighted: false,+ },+ {+ tier: 'premium' as const,+ name: 'Premium',+ price: 40,+ highlighted: true,+ },+] as const;++export type PlanTier = 'free' | 'haiku' | 'sonnet' | 'opus' | 'premium';+export type Plan = {+ tier: PlanTier;+ name: string;+ price: number;+ highlighted: boolean;+};/** Tiers that correspond to real Stripe products. Excludes 'free'. */export type PaidPlanTier = Exclude<PlanTier, 'free'>;+/**+ * Default plan list used for tier lookups in onboarding flows. The paywall+ * components import {LEGACY_PLANS, NEW_PLANS} directly based on the+ * runtime feature flag; everywhere else, PLANS provides a stable catalog+ * for `.find(p => p.tier === ...)` lookups.+ */+export const PLANS: readonly Plan[] = LEGACY_PLANS;+interface PlanFeature {label: string;values: Record<PlanTier, string>;@@ -43,6 +73,7 @@ export const PLAN_FEATURES: PlanFeature[] = [haiku: '1,000',sonnet: '5,000',opus: 'Unlimited',+ premium: 'Unlimited',},},{@@ -52,6 +83,7 @@ export const PLAN_FEATURES: PlanFeature[] = [haiku: 'Haiku',sonnet: 'Sonnet',opus: 'Opus',+ premium: 'All models',},},{@@ -61,6 +93,7 @@ export const PLAN_FEATURES: PlanFeature[] = [haiku: '25 GB',sonnet: '100 GB',opus: '1 TB',+ premium: '1 TB',},},];diff --git a/js/app/packages/app/component/settings/Account.tsx b/js/app/packages/app/component/settings/Account.tsxindex dbacbacb60..739f267b05 100644--- a/js/app/packages/app/component/settings/Account.tsx+++ b/js/app/packages/app/component/settings/Account.tsx@@ -11,12 +11,15 @@ import {blockNameToFileExtensions,blockNameToMimeTypes,} from '@core/constant/allBlocks';+import { ShowFeatureFlag } from '@app/lib/analytics/posthog';import {DEV_MODE_ENV,ENABLE_AUTO_UPDATE_UI,ENABLE_EMAIL,ENABLE_PROFILE_PICTURES,+ ENABLE_NEW_PRICING_OVERRIDE,} from '@core/constant/featureFlags';+import { useUserTeamsQuery } from '@queries/team';import { usePaywallState } from '@core/constant/PaywallState';import { fileSelector } from '@core/directive/fileSelector';import {@@ -33,11 +36,15 @@ import {createResource,createSignal,type JSX,+ Match,Show,+ Switch,} from 'solid-js';import { usePermissions } from '@core/context/user';import { useSettingsState } from '@core/constant/SettingsState';import PaywallComponent from '../paywall/PaywallComponent';+import PaywallTeamMemberView from '../paywall/PaywallTeamMemberView';+import PaywallTeamOwnerView from '../paywall/PaywallTeamOwnerView';import {useEmailLinks,useEmailLinksStatus,@@ -120,6 +127,20 @@ export function Account() {const { disconnect: disconnectEmail } = useEmailLinks();+ const userTeamsQuery = useUserTeamsQuery();+ const ownedTeam = createMemo(() => {+ const teams = userTeamsQuery.data;+ const uid = userId();+ if (!teams || !uid) return undefined;+ return teams.find((t) => t.owner_id === uid);+ });+ const isNonOwnerTeamMember = createMemo(() => {+ const teams = userTeamsQuery.data;+ const uid = userId();+ if (!teams || !uid) return false;+ return teams.some((t) => t.owner_id !== uid);+ });+const userName = useUserName();const [updatedFirstName, setUpdatedFirstName] = createSignal<string | undefined@@ -187,11 +208,34 @@ export function Account() {<Panel.Toolbar class="h-full w-full"><Show when={permissions()?.includes('write:stripe_subscription') && !isNativeMobilePlatform()}><div class="px-4 py-2 w-full">- <PaywallComponent- hideCloseButton- cb={() => {}}- handleGuest={() => toggleSettings()}- />+ <ShowFeatureFlag+ key="enable-new-pricing"+ enabledOverride={ENABLE_NEW_PRICING_OVERRIDE}+ fallback={+ <PaywallComponent+ hideCloseButton+ cb={() => {}}+ handleGuest={() => toggleSettings()}+ />+ }+ >+ <Switch+ fallback={+ <PaywallComponent+ hideCloseButton+ cb={() => {}}+ handleGuest={() => toggleSettings()}+ />+ }+ >+ <Match when={ownedTeam()}>+ {(team) => <PaywallTeamOwnerView team={team()} />}+ </Match>+ <Match when={isNonOwnerTeamMember()}>+ <PaywallTeamMemberView />+ </Match>+ </Switch>+ </ShowFeatureFlag></div></Show></Panel.Toolbar>diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex ef010e1a3e..ff4b0cbebe 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -365,3 +365,6 @@ export const ENABLE_CREATE_PROPERTY = resolveFeatureFlag('ENABLE_CREATE_PROPERTY',false);++export const ENABLE_NEW_PRICING_OVERRIDE =+ resolveFeatureFlag('ENABLE_NEW_PRICING', DEV_MODE_ENV) || undefined;diff --git a/js/app/packages/queries/team/index.ts b/js/app/packages/queries/team/index.tsindex ef8bf757e3..cde91bf9c3 100644--- a/js/app/packages/queries/team/index.ts+++ b/js/app/packages/queries/team/index.ts@@ -3,5 +3,6 @@ export {} from './invites';export {invalidateUserTeams,+ useTeamQuery,useUserTeamsQuery,} from './teams';diff --git a/js/app/packages/service-clients/service-auth/client.ts b/js/app/packages/service-clients/service-auth/client.tsindex 2bf0f013b4..bcd8dcaa70 100644--- a/js/app/packages/service-clients/service-auth/client.ts+++ b/js/app/packages/service-clients/service-auth/client.ts@@ -448,6 +448,32 @@ export const authServiceClient = {).map((result) => result.url);},+ async createCheckoutSessionV2(args: {+ successUrl: string;+ cancelUrl: string;+ discount?: string | null;+ metadata?: {+ gaClientId?: string | null;+ fbp?: string | null;+ fbc?: string | null;+ };+ }) {+ return (+ await fetchWithAuth<{ url: string }>(+ `${authHost}/user/stripe/checkoutv2`,+ {+ method: 'POST',+ body: JSON.stringify({+ successUrl: args.successUrl,+ cancelUrl: args.cancelUrl,+ discount: args.discount ?? undefined,+ metadata: args.metadata,+ }),+ }+ )+ ).map((result) => result.url);+ },+async createPortalSession(args: { returnUrl: string }) {return (await fetchWithAuth<{ url: string }>(`${authHost}/user/stripe/portal`, {diff --git a/js/app/packages/service-clients/service-stripe/client.ts b/js/app/packages/service-clients/service-stripe/client.tsindex 9672d9d170..03eaaa155b 100644--- a/js/app/packages/service-clients/service-stripe/client.ts+++ b/js/app/packages/service-clients/service-stripe/client.ts@@ -77,6 +77,44 @@ export const stripeServiceClient = {return result.value;},+ /**+ * Creates a checkout session via the v2 endpoint. Unlike v1, this does not+ * accept a tier — the backend infers it from the new pricing model.+ * @returns The URL of the checkout session+ */+ createCheckoutSessionV2: async (+ args: {+ type?: string;+ discount?: string;+ /** Override the default success URL. Useful for flows that want the user returned to a specific page. */+ successUrl?: string;+ } = {}+ ) => {+ const { type = '', discount, successUrl } = args;+ const gaClientId = await getGaClientId();+ const { fbp, fbc } = getMetaIds();++ const result = await authServiceClient.createCheckoutSessionV2({+ successUrl:+ successUrl ??+ `${window.location.origin}/app/?subscriptionSuccess=true${type ? `&type=${type}` : ''}`,+ cancelUrl: `${window.location.origin}/app?subscriptionCancel=true`,+ discount: discount ?? null,+ metadata: {+ gaClientId: gaClientId ?? null,+ fbp: fbp ?? null,+ fbc: fbc ?? null,+ },+ });++ if (!result.isOk()) {+ throw new Error(+ result.error?.[0]?.message ?? 'Failed to create checkout session'+ );+ }++ return result.value;+ },/*** Creates a portal session* @returns The URL of the portal session