feat(cloud): plans dialog before the web console; billing serves each plan's card copy

"Plan & billing", "Upgrade to Orca Cloud", "Choose plan" and every "Compare plans" now open an
in-app plans dialog first: the team's plan and status (trial hours left, active with hours and
seats, payment failed, or no plan with the trial billing offers), then billing's plan cards (Team
with a monthly/annual toggle, Enterprise with contact sales). "Continue in browser" opens the
console's billing page through the existing sign-in ticket. Members see the same plan info with
"Ask a team admin to upgrade" (Plan & billing is back in their account menu, read-only). Read-only:
no checkout, usage history or admin settings return to the desktop.

Everything shown is billing's: names, Stripe prices, seat pricing, feature bullets and trial terms
from GET /v1/plans, now also each plan's tagline, feature-list lead and button label (new optional
catalog `marketing`, unversioned copy, plus `omitFeatures` so Enterprise stops advertising egress
controls). Main's lenient parse keeps a newer or older service safe; without the catalog the
entitlement's offers stand in, and with neither the dialog says plans didn't load and still offers
the console. While billing loads the title is neutral, so a paying team never sees an upsell flash.

Settings > Account's billing row opens the dialog ("View plans"); "Update payment method" still
goes straight to the console.
This commit is contained in:
Neil
2026-11-14 16:37:59 -08:00
parent 0fdef56140
commit f2888317b4
30 changed files with 1478 additions and 63 deletions
+13
View File
@@ -10,6 +10,10 @@
"public": true,
"currentVersion": 2,
"supportUrl": "https://orca.dev/enterprise",
"marketing": {
"tagline": "Hosted sandboxes for your whole team, billed per seat",
"ctaLabel": "Continue in browser"
},
"stripe": {
"seatLookupKeys": { "month": "orca_team_seat_monthly", "year": "orca_team_seat_annual" },
"overageLookupKey": "orca_sandbox_overage_per_minute"
@@ -76,6 +80,12 @@
"currentVersion": 2,
"contactUrl": "https://orca.dev/enterprise",
"priceLabel": "Custom",
"marketing": {
"tagline": "Your cloud, your identity provider, your terms",
"featuresLead": "Everything in Team, plus:",
"ctaLabel": "Contact sales",
"omitFeatures": ["egress_controls"]
},
"versions": [
{
"version": 1,
@@ -116,6 +126,9 @@
"sort": 0,
"public": true,
"currentVersion": 1,
"marketing": {
"tagline": "Try Orca Cloud with your team before you pick a plan"
},
"versions": [
{
"version": 1,
+19 -1
View File
@@ -50,6 +50,21 @@ const VersionSchema = z
})
.strict()
// How clients present the plan (desktop plans dialog, console): copy only, never terms. Not
// versioned: changing it never changes what anyone bought.
const MarketingSchema = z
.object({
tagline: z.string().min(1).max(140).optional(),
// Heading over the feature list, e.g. "Everything in Team, plus:".
featuresLead: z.string().min(1).max(60).optional(),
// The plan card's button, e.g. "Continue in browser", "Contact sales".
ctaLabel: z.string().min(1).max(40).optional(),
// Features a version lists that clients should not advertise yet (not offered to teams).
omitFeatures: z.array(z.string().regex(/^[a-z][a-z0-9_]{0,59}$/)).max(20).optional()
})
.strict()
export type PlanMarketing = z.infer<typeof MarketingSchema>
const PlanSchema = z
.object({
id: PlanIdSchema,
@@ -73,6 +88,7 @@ const PlanSchema = z
.regex(/^(https:\/\/[^\s]+|mailto:[^\s@]+@[^\s@]+)$/)
.optional(),
priceLabel: z.string().max(40).optional(),
marketing: MarketingSchema.optional(),
versions: z.array(VersionSchema).min(1)
})
.strict()
@@ -91,6 +107,7 @@ export type PlanConfig = {
contactUrl?: string
supportUrl?: string
priceLabel?: string
marketing?: PlanMarketing
}
export type CatalogVersion = {
@@ -206,7 +223,8 @@ export async function catalogStatements(file: CatalogFile, applied: readonly App
...(plan.stripe ? { stripe: plan.stripe } : {}),
...(plan.contactUrl ? { contactUrl: plan.contactUrl } : {}),
...(plan.supportUrl ? { supportUrl: plan.supportUrl } : {}),
...(plan.priceLabel ? { priceLabel: plan.priceLabel } : {})
...(plan.priceLabel ? { priceLabel: plan.priceLabel } : {}),
...(plan.marketing ? { marketing: plan.marketing } : {})
}
statements.push({
sql: `INSERT INTO plans (plan_id, kind, display_name, sort, public, current_version, config_json, updated_at)
+11 -1
View File
@@ -72,6 +72,14 @@ export async function offersFor(env: Env, now: number) {
return catalogOffers(await loadCatalog(env.BILLING_DB, now), planCatalog(env).team.idleSleepMinutes)
}
function marketingView(plan: CatalogPlan) {
const marketing = plan.config.marketing
if (!marketing) {
return null
}
return { tagline: marketing.tagline ?? null, featuresLead: marketing.featuresLead ?? null, ctaLabel: marketing.ctaLabel ?? null }
}
/** GET /v1/plans: the public catalog. Prices only ever come from Stripe (no price, no checkout). */
export function plansView(catalog: Catalog) {
const plans = [...catalog.plans.values()]
@@ -85,7 +93,9 @@ export function plansView(catalog: Catalog) {
name: plan.name,
version: plan.currentVersion,
entitlements: version.entitlements,
features: version.features,
features: version.features.filter((feature) => !plan.config.marketing?.omitFeatures?.includes(feature.id)),
// Additive: presentation copy (tagline, feature-list lead, button label), or null.
marketing: marketingView(plan),
// "Contact us" for this plan (https: or mailto:); clients fall back to Enterprise's contact.
supportUrl: plan.config.supportUrl ?? null
}
+10
View File
@@ -57,6 +57,16 @@ describe('GET /v1/plans', () => {
expect(JSON.stringify(body)).not.toContain('price_')
})
it('serves each plan\'s presentation copy and leaves out the features it omits', async () => {
const h = await createHarness()
const body = (await h.call('GET', '/v1/plans')).body
const plan = (id: string) => body.plans.find((entry: { id: string }) => entry.id === id)
expect(plan('team').marketing).toEqual({ tagline: 'Hosted sandboxes for your whole team, billed per seat', featuresLead: null, ctaLabel: 'Continue in browser' })
expect(plan('enterprise').marketing).toMatchObject({ featuresLead: 'Everything in Team, plus:', ctaLabel: 'Contact sales' })
expect(plan('enterprise').features.map((feature: { id: string }) => feature.id)).not.toContain('egress_controls')
expect(plan('enterprise').marketing).not.toHaveProperty('omitFeatures')
})
it('answers 304 to a matching ETag, and the ETag changes when a Stripe price changes', async () => {
const h = await createHarness()
const first = await h.call('GET', '/v1/plans')
+19 -3
View File
@@ -24,7 +24,8 @@ const team = {
},
seats: { min: 1, max: 500 },
warnAtPercent: [75, 90, 100],
checkout: { available: true, intervals: ['month', 'year'] }
checkout: { available: true, intervals: ['month', 'year'] },
marketing: { tagline: 'For your team', featuresLead: null, ctaLabel: 'Continue in browser' }
}
const enterprise = {
id: 'enterprise',
@@ -56,7 +57,8 @@ describe('parsePlanCatalog', () => {
seats: { min: 1, max: 500 },
includedHoursPerSeat: 60,
checkoutAvailable: true,
supportUrl: null
supportUrl: null,
marketing: { tagline: 'For your team', featuresLead: null, ctaLabel: 'Continue in browser' }
})
expect(catalog?.plans[1]).toEqual({
kind: 'contact_sales',
@@ -66,7 +68,8 @@ describe('parsePlanCatalog', () => {
features: enterprise.features,
contactUrl: 'https://orca.dev/enterprise',
priceLabel: 'Custom',
supportUrl: null
supportUrl: null,
marketing: null
})
})
@@ -97,6 +100,19 @@ describe('parsePlanCatalog', () => {
expect(catalog?.plans[1]?.kind).toBe('free')
})
it('drops copy that is too long or not text, keeping the rest of the plan', () => {
const catalog = parsePlanCatalog({
schemaVersion: 1,
catalogVersion: 'c_3',
plans: [{ ...team, marketing: { tagline: 'x'.repeat(141), ctaLabel: 7, featuresLead: ' ' } }]
})
expect(catalog?.plans[0]?.marketing).toEqual({
tagline: null,
featuresLead: null,
ctaLabel: null
})
})
it('never offers checkout without a price, and refuses a non-v1 body', () => {
const catalog = parsePlanCatalog({
schemaVersion: 1,
+21
View File
@@ -22,6 +22,14 @@ const Feature = z.object({
text: z.string().min(1).max(200)
})
const Copy = (max: number) => z.string().trim().min(1).max(max).nullable().catch(null).optional()
const Marketing = z
.object({ tagline: Copy(140), featuresLead: Copy(60), ctaLabel: Copy(40) })
.nullable()
.catch(null)
.optional()
const Price = z.object({
interval: z.enum(ORCA_BILLING_INTERVALS),
unitAmountCents: z.number().int().nonnegative(),
@@ -35,6 +43,7 @@ const Base = z.object({
version: z.number().int().nonnegative().catch(0),
features: z.array(z.unknown()).max(100).catch([]),
entitlements: z.record(z.string(), z.unknown()).catch({}).optional(),
marketing: Marketing,
// "Contact us" for this plan. https only: the desktop opens links through shell:openUrl, which
// refuses other schemes (a mailto: from billing falls back to the Enterprise contact).
supportUrl: z.string().url().startsWith('https://').max(500).nullable().catch(null).optional()
@@ -71,6 +80,17 @@ function features(raw: unknown[]): OrcaPlanFeature[] {
})
}
function marketing(raw: z.infer<typeof Marketing>): OrcaPlanCatalogPlan['marketing'] {
if (!raw) {
return null
}
return {
tagline: raw.tagline ?? null,
featuresLead: raw.featuresLead ?? null,
ctaLabel: raw.ctaLabel ?? null
}
}
function prices(raw: unknown[]): OrcaPlanPrice[] {
const seen = new Set<string>()
return raw.flatMap((entry) => {
@@ -102,6 +122,7 @@ function plan(raw: unknown): OrcaPlanCatalogPlan | null {
name: base.data.name,
version: base.data.version,
features: features(base.data.features),
marketing: marketing(base.data.marketing),
supportUrl: base.data.supportUrl ?? null
}
if (base.data.kind === 'self_serve') {
+2
View File
@@ -5,6 +5,7 @@ import { TooltipProvider } from '@/components/ui/tooltip'
import { ConfirmationDialogProvider } from './components/confirmation-dialog'
import { BrowserWebAuthnAccountDialog } from './components/browser-webauthn-account-dialog'
import { BrowserExtensionInstallDialog } from './components/browser-extension-install-dialog'
import { PlansDialogHost } from './components/billing/plans/PlansDialogHost'
import { CloudMoveToComputerDialogMount } from './components/orca-cloud/CloudMoveToComputerDialogMount'
import { CloudPrimaryDeleteDialogMount } from './components/orca-cloud/CloudPrimaryDeleteDialog'
import { CloudSecretsAskDialogHost } from './components/cloud-secrets-ask/CloudSecretsMissingNotice'
@@ -127,6 +128,7 @@ function App(): React.JSX.Element {
/>
<BrowserWebAuthnAccountDialog />
<BrowserExtensionInstallDialog />
<PlansDialogHost />
<CloudMoveToComputerDialogMount />
<CloudPrimaryDeleteDialogMount />
<CloudSecretsAskDialogHost />
@@ -11,7 +11,7 @@ import { useTranslate } from '@/i18n/use-translate'
import { cn } from '@/lib/class-names'
import type { OrcaBillingStatusResult } from '../../../../shared/orca-billing'
import { accountMenuTrialRow } from './plan-billing-usage-copy'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from './plans/plans-dialog-store'
export function AccountMenuTrialRow({
result
@@ -35,7 +35,7 @@ export function AccountMenuTrialRow({
{row.canChoosePlan ? (
<DropdownMenuItem
data-account-menu-trial=""
onSelect={() => void openCloudConsole('billing')}
onSelect={() => openPlansDialog()}
aria-label={t('auto.components.billing.trialRowChoosePlan', '{{trial}}. Choose plan', {
trial: row.label
})}
@@ -0,0 +1,337 @@
// The plans dialog's cards: Team (per-seat prices, monthly or annual) and Enterprise (contact
// sales). Names, prices, bullets, taglines and button labels are billing's catalog; the cards only
// lay them out. Read-only: choosing seats and paying happen in the web console.
import type { ReactNode } from 'react'
import { Building2, Check, ExternalLink, Lock, Users } from 'lucide-react'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { SettingsSegmentedControl } from '@/components/settings/form-controls/SettingsSegmentedControl'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
import type { OrcaBillingInterval } from '../../../../../shared/orca-billing'
import { formatCents } from '../../../../../shared/orca-billing-usage-alerts'
import type { EnterprisePlanModel, TeamPlanModel } from './plans-model'
import { perSeatMonthlyCents } from './plans-pricing'
function PlanCardShell({
id,
title,
badge,
tagline,
price,
priceNote,
featuresLead,
features,
footer
}: {
id: string
title: ReactNode
badge?: ReactNode
tagline: string | null
price: ReactNode
priceNote: ReactNode
featuresLead?: string | null
features: string[]
footer: ReactNode
}): React.JSX.Element {
return (
<section
aria-labelledby={id}
className="flex h-full flex-col gap-5 rounded-xl border border-border bg-card p-5 shadow-xs"
>
<div className="space-y-1">
<div className="flex min-h-6 items-center justify-between gap-3">
<h3 id={id} className="flex items-center gap-2 text-base font-semibold">
{title}
</h3>
{badge}
</div>
{tagline ? <p className="text-xs text-muted-foreground text-pretty">{tagline}</p> : null}
</div>
<div className="space-y-1">
{price}
<p className="text-xs text-muted-foreground">{priceNote}</p>
</div>
<div className="flex-1 space-y-2.5">
{featuresLead && features.length > 0 ? (
<p className="text-xs font-medium text-muted-foreground">{featuresLead}</p>
) : null}
<ul className="space-y-2.5">
{features.map((feature) => (
<li key={feature} className="flex items-start gap-2 text-sm text-pretty">
<Check className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<span>{feature}</span>
</li>
))}
</ul>
</div>
{/* Same footer height on both cards keeps their dividers and buttons level. */}
<div className="flex min-h-[6rem] flex-col justify-start gap-2 border-t border-border/60 pt-4">
{footer}
</div>
</section>
)
}
export function PlansIntervalToggle({
value,
savingsPercent,
onChange
}: {
value: OrcaBillingInterval
savingsPercent: number | null
onChange: (interval: OrcaBillingInterval) => void
}): React.JSX.Element {
const t = useTranslate()
const annual = t('auto.components.billing.plans.annual', 'Annual')
const save =
savingsPercent === null
? null
: t('auto.components.billing.plans.savePercent', 'Save {{value0}}%', {
value0: String(savingsPercent)
})
return (
<div className="mx-auto flex w-72 justify-center">
<SettingsSegmentedControl<OrcaBillingInterval>
value={value}
onChange={onChange}
size="sm"
equalWidth
ariaLabel={t('auto.components.billing.plans.billingPeriod', 'Billing period')}
options={[
{ value: 'month', label: t('auto.components.billing.plans.monthly', 'Monthly') },
{
value: 'year',
label: save ? (
<span className="flex items-center gap-1.5">
{annual}
<span className="rounded-full bg-foreground/10 px-1.5 text-[10px] font-semibold tabular-nums">
{save}
</span>
</span>
) : (
annual
),
ariaLabel: save ? `${annual}, ${save}` : undefined
}
]}
/>
</div>
)
}
export type TeamPlanCardMode =
/** Owner or admin, no plan yet: continue in the browser to choose seats and pay. */
| 'choose'
/** Already on this plan; owners and admins manage it in the browser. */
| 'current'
/** A member: the plan is shown, an owner or admin chooses it. */
| 'member'
export function TeamPlanCard({
team,
interval,
seats,
mode,
opening,
onContinue
}: {
team: TeamPlanModel
interval: OrcaBillingInterval
/** Seats on the current plan, when there is one. */
seats: number | null
mode: TeamPlanCardMode
onContinue: (() => void) | null
opening: boolean
}): React.JSX.Element {
const t = useTranslate()
const locale = useIntlLocale()
const fmt = (cents: number): string => formatCents(cents, locale, team.currency)
const monthly = perSeatMonthlyCents(team, interval)
const fullMonthly = team.monthlyPriceCentsPerSeat
const discounted =
interval === 'year' && monthly !== null && fullMonthly !== null && monthly < fullMonthly
const legacyLabel = team.legacyPriceLabels?.[interval] || null
const price = (
// Keyed so the figure fades in again when the period changes.
<p
key={interval}
className="flex items-baseline gap-1.5 animate-in fade-in-0 slide-in-from-bottom-1 duration-200 motion-reduce:animate-none"
>
{discounted && fullMonthly !== null ? (
<del className="text-lg text-muted-foreground tabular-nums">
<span className="sr-only">{t('auto.components.billing.plans.was', 'Was')} </span>
{fmt(fullMonthly)}
</del>
) : null}
{monthly === null ? (
<span className="text-lg font-semibold tracking-tight">
{legacyLabel ?? t('auto.components.billing.plans.priceInBrowser', 'See price in browser')}
</span>
) : (
<>
<span className="text-3xl font-semibold tracking-tight tabular-nums">{fmt(monthly)}</span>
<span className="text-sm text-muted-foreground">
{t('auto.components.billing.plans.perSeatPerMonth', 'per seat per month')}
</span>
</>
)}
</p>
)
const billed =
interval === 'year'
? team.annualPriceCentsPerSeat === null
? t('auto.components.billing.plans.billedYearly', 'Billed yearly')
: t(
'auto.components.billing.plans.billedYearlyAmount2',
'{{value0}} per seat, billed yearly',
{
value0: fmt(team.annualPriceCentsPerSeat)
}
)
: t('auto.components.billing.plans.billedMonthly', 'Billed monthly')
const priceNote =
seats === null
? billed
: t('auto.components.billing.plans.seatsBilled', '{{count}} seats · {{billed}}', {
count: seats,
billed,
defaultValue_one: '{{count}} seat · {{billed}}'
})
const continueButton = onContinue ? (
<Button
type="button"
variant={mode === 'current' ? 'outline' : 'default'}
className="w-full"
aria-disabled={opening || undefined}
onClick={opening ? undefined : onContinue}
>
{mode === 'current'
? t('settings.cloudConsole.manageInBrowser', 'Manage in browser')
: (team.marketing?.ctaLabel ??
t('auto.components.billing.plans.continueInBrowser', 'Continue in browser'))}
<ExternalLink />
</Button>
) : null
let footer: ReactNode
if (mode === 'member') {
footer = (
<div className="flex items-start gap-2 text-sm">
<Lock className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<p className="text-pretty">
{seats === null
? t('auto.components.billing.plans.askAdmin', 'Ask a team admin to upgrade.')
: t(
'auto.components.billing.plans.adminsManage',
'Your team’s owners and admins manage this plan.'
)}
</p>
</div>
)
} else if (mode === 'current') {
footer = (
<>
{continueButton}
<p className="text-center text-xs text-muted-foreground text-pretty">
{t(
'auto.components.billing.plans.manageHint2',
'Change seats or billing period, see invoices, or update payment.'
)}
</p>
</>
)
} else {
footer = (
<>
{continueButton}
<p className="text-center text-xs text-muted-foreground text-pretty">
{t(
'auto.components.billing.plans.continueHint2',
'Sign in on the web to choose seats and pay.'
)}
</p>
</>
)
}
return (
<PlanCardShell
id="plans-team-title"
title={
<>
<Users className="size-4 text-muted-foreground" />
{team.label}
</>
}
badge={
mode === 'current' || (mode === 'member' && seats !== null) ? (
<Badge variant="secondary">
{t('auto.components.billing.plans.currentPlan', 'Current plan')}
</Badge>
) : null
}
tagline={team.marketing?.tagline ?? null}
price={price}
priceNote={priceNote}
featuresLead={team.marketing?.featuresLead}
features={team.features}
footer={footer}
/>
)
}
export function EnterprisePlanCard({
enterprise,
onContactSales
}: {
enterprise: EnterprisePlanModel
onContactSales: (url: string) => void
}): React.JSX.Element {
const t = useTranslate()
const contactUrl = enterprise.contactUrl
return (
<PlanCardShell
id="plans-enterprise-title"
title={
<>
<Building2 className="size-4 text-muted-foreground" />
{enterprise.label}
</>
}
tagline={enterprise.marketing?.tagline ?? null}
price={
enterprise.priceLabel ? (
<p className="text-3xl font-semibold tracking-tight">{enterprise.priceLabel}</p>
) : null
}
priceNote={t('auto.components.billing.plans.entPriced2', 'Priced for your team')}
featuresLead={enterprise.marketing?.featuresLead}
features={enterprise.features}
footer={
contactUrl ? (
<>
<Button
type="button"
variant="outline"
className="w-full"
onClick={() => onContactSales(contactUrl)}
>
{enterprise.marketing?.ctaLabel ??
t('auto.components.billing.plans.contactSales', 'Contact sales')}
<ExternalLink />
</Button>
<p className="text-center text-xs text-muted-foreground">
{t(
'auto.components.billing.plans.entHint',
'Tell us about your team and where you run.'
)}
</p>
</>
) : null
}
/>
)
}
@@ -0,0 +1,136 @@
// The team's plan as it stands, above the plan cards: a plan with its hours and seats, the
// one-time trial, or (no plan) the trial terms billing's catalog offers.
import { Cloud, Gift } from 'lucide-react'
import { Progress } from '@/components/ui/progress'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
import type { OrcaBillingEntitlement } from '../../../../../shared/orca-billing'
import { PlanStatusBadge } from '../PlanStatusBadge'
import { formatHours, formatHoursUsed, includedUsagePercent } from '../plan-billing-format'
import {
includedUsageTone,
sandboxHoursCount,
sandboxHoursLeftLine,
trialHoursUsedLine
} from '../plan-billing-usage-copy'
import type { TrialPlanModel } from './plans-model'
const STRIP = 'space-y-2 rounded-xl border border-border bg-card p-4 shadow-xs'
export function CurrentPlanStrip({
entitlement
}: {
entitlement: OrcaBillingEntitlement
}): React.JSX.Element {
const t = useTranslate()
const locale = useIntlLocale()
const resets = entitlement.usageWindow
? new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(entitlement.usageWindow.end)
: null
return (
<div className={STRIP}>
<div className="flex flex-wrap items-center gap-2 text-sm">
<span className="font-medium">{entitlement.planLabel}</span>
<PlanStatusBadge entitlement={entitlement} />
</div>
<Progress
value={includedUsagePercent(entitlement)}
tone={includedUsageTone(entitlement)}
aria-label={t('auto.components.billing.sandboxHoursUsedLabel', 'Sandbox hours used')}
/>
<div className="flex flex-wrap justify-between gap-2 text-xs text-muted-foreground tabular-nums">
<span>
{t(
'auto.components.billing.sandboxHoursUsedMonth',
'{{value0}} of {{value1}} sandbox hours used this month',
{
value0: formatHoursUsed(
Math.min(entitlement.usedSeconds, entitlement.includedSeconds)
),
value1: formatHours(entitlement.includedSeconds)
}
)}
</span>
<span>
{resets
? t(
'auto.components.billing.plans.sandboxHoursLeftResets',
'{{count}} sandbox hours left · resets {{date}}',
{
count: sandboxHoursCount(entitlement.remainingIncludedSeconds),
date: resets,
defaultValue_one: '{{count}} sandbox hour left · resets {{date}}'
}
)
: sandboxHoursLeftLine(entitlement, t)}
</span>
</div>
</div>
)
}
export function TrialStrip({
entitlement,
canManage
}: {
entitlement: OrcaBillingEntitlement
canManage: boolean
}): React.JSX.Element {
const t = useTranslate()
const usedUp = entitlement.trial?.exhausted === true
return (
<div className={STRIP}>
<div className="flex flex-wrap items-center gap-2 text-sm">
<Cloud className="size-4 text-muted-foreground" />
<span className="font-medium">
{t('auto.components.billing.trialProduct', 'Orca Cloud')}
</span>
<PlanStatusBadge entitlement={entitlement} />
</div>
<Progress
value={includedUsagePercent(entitlement)}
tone={usedUp ? 'warning' : includedUsageTone(entitlement)}
aria-label={t('auto.components.billing.trialHoursUsedLabel', 'Trial sandbox hours used')}
/>
<div className="flex flex-wrap items-baseline justify-between gap-2 text-xs tabular-nums">
<span className="font-medium">{trialHoursUsedLine(entitlement, t)}</span>
<span className="text-muted-foreground">{sandboxHoursLeftLine(entitlement, t)}</span>
</div>
<p className="text-xs text-muted-foreground text-pretty">
{usedUp
? canManage
? t(
'auto.components.billing.plans.trialUsedUpAdmin',
'Your trial hours are used up. Choose a plan to keep your sandboxes running.'
)
: t(
'auto.components.billing.plans.trialUsedUpMember',
'Your team’s trial hours are used up. Ask a team admin to upgrade.'
)
: t(
'auto.components.billing.plans.trialOneTime2',
'Trial hours are a one-time allowance and don’t reset. Choose a plan any time.'
)}
</p>
</div>
)
}
/** No plan and no trial yet: the trial billing's catalog offers (its own name and terms). */
export function TrialOfferStrip({ trial }: { trial: TrialPlanModel }): React.JSX.Element | null {
if (trial.features.length === 0) {
return null
}
return (
<div className="flex items-start gap-3 rounded-xl border border-border bg-card p-4 shadow-xs">
<span className="flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
<Gift className="size-4" />
</span>
<div className="min-w-0 space-y-0.5">
<p className="text-sm font-medium">{trial.tagline ?? trial.label}</p>
<p className="text-xs leading-5 text-muted-foreground text-pretty">
{trial.features.join(' · ')}
</p>
</div>
</div>
)
}
@@ -0,0 +1,45 @@
import { useState } from 'react'
import { Dialog } from '@/components/ui/dialog'
import { canManageActiveTeam } from '@/lib/orca-cloud/orca-cloud-team-role'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { useAppStore } from '@/store/index'
import { useOrcaBillingStatus } from '../use-orca-billing-status'
import { usePlanCatalog } from '../use-plan-catalog'
import { closePlansDialog, usePlansDialogOpen } from './plans-dialog-store'
import { PlansDialogView } from './PlansDialogView'
/**
* The plans dialog, in front of the web console: what the team has and what billing sells, read
* from billing (GET /v1/plans and the team's entitlement). "Continue in browser" opens the console's
* billing page through a sign-in ticket; choosing seats and paying happen there.
*/
export function PlansDialogHost(): React.JSX.Element {
const open = usePlansDialogOpen()
const billing = useOrcaBillingStatus(open)
const catalog = usePlanCatalog(open)
const canManage = useAppStore((state) => canManageActiveTeam(state.orcaProfileAuthStatus))
const [opening, setOpening] = useState(false)
return (
<Dialog open={open} onOpenChange={(next) => (next ? undefined : closePlansDialog())}>
{open ? (
<PlansDialogView
// The first read shows a skeleton; a re-read on focus keeps the last answer on screen.
billing={billing.result}
catalog={catalog.result}
canManage={canManage}
opening={opening}
onContinue={() => {
setOpening(true)
void openCloudConsole('billing').finally(() => setOpening(false))
}}
onContactSales={(url) => void window.api.shell.openUrl(url)}
onRetry={() => {
billing.refresh()
catalog.refresh()
}}
/>
) : null}
</Dialog>
)
}
@@ -0,0 +1,221 @@
import { Dialog } from '@/components/ui/dialog'
import { defineFixture } from '../../../component-fixtures/component-fixture'
import type {
OrcaBillingEntitlement,
OrcaBillingStatusResult
} from '../../../../../shared/orca-billing'
import type {
OrcaPlanCatalog,
OrcaPlanCatalogResult
} from '../../../../../shared/orca-billing-plans'
import { sampleTeam, sampleTrial } from '../plan-billing-fixtures'
import { PlansDialogView } from './PlansDialogView'
// Shaped like billing-dev's GET /v1/plans after the desktop's parse.
const catalog: OrcaPlanCatalog = {
catalogVersion: 'c_fixture',
plans: [
{
kind: 'trial',
id: 'trial',
name: 'Trial',
version: 1,
supportUrl: null,
marketing: {
tagline: 'Try Orca Cloud with your team before you pick a plan',
featuresLead: null,
ctaLabel: null
},
features: [
{ id: 'trial_hours', params: { hours: 2 }, text: '2 sandbox hours to try Orca Cloud' },
{ id: 'no_card', params: {}, text: 'No card needed' }
]
},
{
kind: 'self_serve',
id: 'team',
name: 'Team',
version: 2,
supportUrl: 'https://orca.dev/enterprise',
marketing: {
tagline: 'Hosted sandboxes for your whole team, billed per seat',
featuresLead: null,
ctaLabel: 'Continue in browser'
},
features: [
{
id: 'included_hours_per_seat',
params: { hours: 60 },
text: '60 sandbox hours per seat each month, pooled across your team'
},
{ id: 'sandbox_spec', params: {}, text: 'Every sandbox gets 8 vCPU and 16 GB' },
{ id: 'ready_in_seconds', params: {}, text: 'Ready in seconds, nothing to set up or host' },
{
id: 'agents_keep_running',
params: {},
text: 'Agents keep running when you close your laptop'
},
{
id: 'idle_sleep',
params: {},
text: 'Sandboxes sleep when idle, so you only use hours while they work'
},
{
id: 'overage_optional',
params: {},
text: 'Optional overage up to a monthly spend cap you set'
}
],
prices: [
{ interval: 'month', unitAmountCents: 5000, currency: 'usd' },
{ interval: 'year', unitAmountCents: 48000, currency: 'usd' }
],
overage: { centsPerHour: 100, defaultSpendCapCents: 2500, maxSpendCapCents: 500000 },
seats: { min: 1, max: 500 },
includedHoursPerSeat: 60,
checkoutAvailable: true
},
{
kind: 'contact_sales',
id: 'enterprise',
name: 'Enterprise',
version: 2,
supportUrl: null,
contactUrl: 'https://orca.dev/enterprise',
priceLabel: 'Custom',
marketing: {
tagline: 'Your cloud, your identity provider, your terms',
featuresLead: 'Everything in Team, plus:',
ctaLabel: 'Contact sales'
},
features: [
{ id: 'byoc', params: {}, text: 'Run sandboxes in your own cloud' },
{ id: 'sso_scim', params: {}, text: 'SSO and SCIM' },
{ id: 'mfa_enforcement', params: {}, text: 'Require multi-factor authentication' },
{ id: 'audit_log', params: {}, text: 'Team audit log' },
{ id: 'custom_limits', params: {}, text: 'Custom limits and pricing' }
]
}
]
}
const live: OrcaPlanCatalogResult = {
status: 'ok',
catalog,
source: 'live',
fetchedAt: Date.UTC(2026, 10, 14)
}
const noPlan: OrcaBillingEntitlement = {
...sampleTeam,
plan: null,
planLabel: null,
status: 'none',
interval: null,
seats: 0,
usageWindow: null,
includedSeconds: 0,
usedSeconds: 0,
remainingIncludedSeconds: 0,
canStartSandbox: false,
reason: 'no_subscription',
offers: { ...sampleTeam.offers!, trial: { includedSeconds: 7200 } }
}
const pastDue: OrcaBillingEntitlement = {
...sampleTeam,
status: 'past_due',
payment: {
pastDueSince: Date.UTC(2026, 10, 12),
graceEndsAt: Date.UTC(2026, 10, 16, 17),
suspendRunning: false
},
canStartSandbox: false,
reason: 'payment_past_due'
}
function Frame({
billing,
plans = live,
canManage = true
}: {
billing: OrcaBillingStatusResult | null
plans?: OrcaPlanCatalogResult | null
canManage?: boolean
}): React.JSX.Element {
return (
<div className="h-[860px]">
<Dialog open modal={false}>
<PlansDialogView
billing={billing}
catalog={plans}
canManage={canManage}
opening={false}
onContinue={() => {}}
onContactSales={() => {}}
onRetry={() => {}}
/>
</Dialog>
</div>
)
}
const ok = (entitlement: OrcaBillingEntitlement): OrcaBillingStatusResult => ({
status: 'ok',
entitlement
})
/** Owner or admin, no plan and the trial still on offer. */
export const none = defineFixture({ width: 1280, render: () => <Frame billing={ok(noPlan)} /> })
export const trial = defineFixture({
width: 1280,
render: () => <Frame billing={ok(sampleTrial)} />
})
export const active = defineFixture({
width: 1280,
render: () => <Frame billing={ok(sampleTeam)} />
})
export const pastDuePlan = defineFixture({
width: 1280,
render: () => <Frame billing={ok(pastDue)} />
})
/** A member of a team with no plan: plan info and "Ask a team admin", no buttons into the console. */
export const member = defineFixture({
width: 1280,
render: () => <Frame billing={ok({ ...noPlan, canManageBilling: false })} canManage={false} />
})
/** Offline, from main's saved copy of the catalog. */
export const offlineSaved = defineFixture({
width: 1280,
render: () => (
<Frame billing={ok(noPlan)} plans={{ ...live, source: 'cache' } as OrcaPlanCatalogResult} />
)
})
/** The catalog can't be read: billing's entitlement offers stand in (prices only, no bullets). */
export const fallbackOffers = defineFixture({
width: 1280,
render: () => <Frame billing={ok(noPlan)} plans={{ status: 'failed', error: 'offline' }} />
})
/** Neither the catalog nor billing answered: no guessed prices, the console is still offered. */
export const unavailable = defineFixture({
width: 1280,
render: () => (
<Frame
billing={{ status: 'failed', error: 'offline' }}
plans={{ status: 'failed', error: 'offline' }}
/>
)
})
/** Billing hasn't answered yet: a neutral title and skeleton, never an upsell. */
export const loading = defineFixture({
width: 1280,
render: () => <Frame billing={null} plans={null} />
})
@@ -0,0 +1,269 @@
// The plans dialog: the team's plan and status, then billing's plan cards, with "Continue in
// browser" into the web console, where the person signs in, picks seats and pays. A read-only sales
// and status surface: no checkout, usage history or admin settings in the desktop.
import { useEffect, useState } from 'react'
import { ExternalLink } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { InlineError } from '@/components/ui/inline-error'
import { Skeleton } from '@/components/ui/skeleton'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
import {
isOrcaCloudTrial,
type OrcaBillingInterval,
type OrcaBillingStatusResult
} from '../../../../../shared/orca-billing'
import type { OrcaPlanCatalogResult } from '../../../../../shared/orca-billing-plans'
import { PaymentIssueNotice } from '../PaymentIssueNotice'
import { isActivePlan } from '../plan-billing-format'
import {
EnterprisePlanCard,
PlansIntervalToggle,
TeamPlanCard,
type TeamPlanCardMode
} from './PlanCards'
import { CurrentPlanStrip, TrialOfferStrip, TrialStrip } from './PlansCurrentPlan'
import { resolvePlansModel } from './plans-model'
import { annualSavingsPercent, shownInterval } from './plans-pricing'
export type PlansDialogViewProps = {
/** null while billing's first answer is on its way. */
billing: OrcaBillingStatusResult | null
/** null while the plan catalog loads. */
catalog: OrcaPlanCatalogResult | null
/** Owner or admin of the active team (the console's billing rule). */
canManage: boolean
/** The console is being opened (a ticket is minted first). */
opening: boolean
onContinue: () => void
onContactSales: (url: string) => void
onRetry: () => void
}
function SkeletonCard(): React.JSX.Element {
return (
<div className="flex h-full flex-col gap-5 rounded-xl border border-border bg-card p-5 shadow-xs">
<Skeleton className="h-4 w-24" />
<div className="space-y-2">
<Skeleton className="h-8 w-32" />
<Skeleton className="h-3 w-28" />
</div>
<div className="flex-1 space-y-3">
{Array.from({ length: 4 }, (_, index) => (
<Skeleton key={index} className={index % 2 ? 'h-3 w-4/5' : 'h-3 w-11/12'} />
))}
</div>
<div className="min-h-[6rem] space-y-2 border-t border-border/60 pt-4">
<Skeleton className="h-9 w-full" />
<Skeleton className="mx-auto h-3 w-3/5" />
</div>
</div>
)
}
function PlansSkeleton(): React.JSX.Element {
const t = useTranslate()
return (
<div
className="space-y-6"
role="status"
aria-label={t('auto.components.billing.plans.loading', 'Loading plans…')}
>
<Skeleton className="h-[5.5rem] w-full rounded-xl" />
<div className="grid items-stretch gap-4 md:grid-cols-2">
<SkeletonCard />
<SkeletonCard />
</div>
</div>
)
}
function useHeading(props: PlansDialogViewProps): { title: string; description: string | null } {
const t = useTranslate()
const entitlement = props.billing?.status === 'ok' ? props.billing.entitlement : null
if (!entitlement || isActivePlan(entitlement)) {
// Never an upsell before billing answers: a paying team must not see one flash by.
return {
title: entitlement
? t('auto.components.billing.plans.titleSubscribed', 'Your Orca Cloud plan')
: t('auto.components.billing.plans.titleNeutral', 'Orca Cloud plans'),
description: null
}
}
return {
title: t('auto.components.billing.plans.title', 'Cloud sandboxes for your whole team'),
description: t(
'auto.components.billing.plans.subtitle2',
'Run Orca agents in hosted sandboxes that keep going when you step away.'
)
}
}
function PlansBody(props: PlansDialogViewProps): React.JSX.Element {
const t = useTranslate()
const locale = useIntlLocale()
const [picked, setPicked] = useState<OrcaBillingInterval>('month')
const plans = resolvePlansModel(props.catalog, props.billing)
const billing = props.billing
if (billing === null || plans.state === 'loading') {
return <PlansSkeleton />
}
if (billing.status === 'signed-out' || billing.status === 'unconfigured') {
return (
<p className="py-12 text-center text-sm text-muted-foreground">
{billing.status === 'signed-out'
? t('auto.components.billing.plans.signedOut', 'Sign in to Orca to see your team’s plan.')
: t('auto.components.billing.openUnconfigured', 'Billing is unavailable in this build.')}
</p>
)
}
const entitlement = billing.status === 'ok' ? billing.entitlement : null
const subscribed = isActivePlan(entitlement)
const trial = entitlement && isOrcaCloudTrial(entitlement) ? entitlement : null
const status = entitlement ? (
subscribed ? (
<>
<PaymentIssueNotice
entitlement={{ ...entitlement, canManageBilling: props.canManage }}
busy={props.opening}
onUpdatePayment={props.onContinue}
/>
<CurrentPlanStrip entitlement={entitlement} />
</>
) : trial ? (
<TrialStrip entitlement={trial} canManage={props.canManage} />
) : plans.state === 'ready' && plans.model.trial && entitlement.offers?.trial ? (
<TrialOfferStrip trial={plans.model.trial} />
) : null
) : null
if (plans.state === 'unavailable') {
// Offline with nothing saved: say so, and still offer the console (it lists the plans).
return (
<div className="space-y-6">
{status}
<InlineError
tone="neutral"
className="mx-auto max-w-md"
title={t('auto.components.billing.plans.loadFailedTitle', 'Plans didn’t load')}
detail={t(
'auto.components.billing.plans.loadFailedConsole',
'Check your connection and try again, or see plans in your browser.'
)}
retryLabel={t('auto.components.billing.plans.retry', 'Try again')}
onRetry={props.onRetry}
/>
{props.canManage ? (
<div className="flex justify-center">
<Button
type="button"
aria-disabled={props.opening || undefined}
onClick={props.opening ? undefined : props.onContinue}
>
{t('auto.components.billing.plans.continueInBrowser', 'Continue in browser')}
<ExternalLink />
</Button>
</div>
) : (
<p className="text-center text-sm text-muted-foreground">
{t('auto.components.billing.plans.askAdmin', 'Ask a team admin to upgrade.')}
</p>
)}
</div>
)
}
const { team, enterprise, source } = plans.model
const mode: TeamPlanCardMode = !props.canManage ? 'member' : subscribed ? 'current' : 'choose'
const interval =
subscribed && entitlement?.interval
? entitlement.interval
: shownInterval(picked, team.intervals)
const fetchedAt = props.catalog?.status === 'ok' ? props.catalog.fetchedAt : null
return (
<div className="space-y-6">
{status}
{!subscribed && team.intervals.length > 1 ? (
<PlansIntervalToggle
value={interval}
savingsPercent={annualSavingsPercent(team)}
onChange={setPicked}
/>
) : null}
<div className={enterprise ? 'grid items-stretch gap-4 md:grid-cols-2' : 'mx-auto max-w-md'}>
<TeamPlanCard
team={team}
interval={interval}
seats={subscribed && entitlement ? entitlement.seats : null}
mode={mode}
opening={props.opening}
onContinue={mode === 'member' ? null : props.onContinue}
/>
{enterprise ? (
<EnterprisePlanCard enterprise={enterprise} onContactSales={props.onContactSales} />
) : null}
</div>
{source === 'cache' && fetchedAt ? (
<p className="text-center text-xs text-muted-foreground">
{t(
'auto.components.billing.plans.savedCopy',
'Offline: plans as of {{date}}. Your browser shows current prices.',
{ date: new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(fetchedAt) }
)}
</p>
) : null}
</div>
)
}
export function PlansDialogView(props: PlansDialogViewProps): React.JSX.Element {
const heading = useHeading(props)
const ready = props.billing !== null && props.catalog !== null
// Land on the heading once plans load, never on a button (Enter would open the browser).
useEffect(() => {
const active = document.activeElement
if (
ready &&
(!active || active === document.body || active.getAttribute('role') === 'dialog')
) {
document.querySelector<HTMLElement>('[role="dialog"] [data-plans-heading]')?.focus()
}
}, [ready])
const t = useTranslate()
return (
<DialogContent
scrollable
className="top-[6vh] max-h-[88vh] translate-y-0 sm:max-w-4xl [@media(max-height:800px)]:top-4 [@media(max-height:800px)]:max-h-[calc(100vh-2rem)]"
onOpenAutoFocus={(event) => {
event.preventDefault()
if (event.currentTarget instanceof HTMLElement) {
const heading = event.currentTarget.querySelector<HTMLElement>('[data-plans-heading]')
;(heading ?? event.currentTarget).focus()
}
}}
>
<DialogHeader className="items-center text-center">
<p className="text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
{t('auto.components.billing.plans.eyebrow', 'Orca Cloud')}
</p>
<DialogTitle size="display" tabIndex={-1} data-plans-heading="">
{heading.title}
</DialogTitle>
<DialogDescription
className={heading.description ? 'mx-auto max-w-xl text-center' : 'sr-only'}
>
{heading.description ??
t(
'auto.components.billing.plans.subtitleSubscribed2',
'Your plan, its sandbox hours, and what Enterprise adds.'
)}
</DialogDescription>
</DialogHeader>
<PlansBody {...props} />
</DialogContent>
)
}
@@ -0,0 +1,30 @@
// Open state for the plans dialog. Every "Plan & billing", "Upgrade", "Choose plan" and "Compare
// plans" entry point calls openPlansDialog(); PlansDialogHost renders it.
import { useSyncExternalStore } from 'react'
let open = false
const listeners = new Set<() => void>()
function set(next: boolean): void {
open = next
for (const listener of listeners) {
listener()
}
}
export function openPlansDialog(): void {
set(true)
}
export function closePlansDialog(): void {
set(false)
}
function subscribe(listener: () => void): () => void {
listeners.add(listener)
return () => listeners.delete(listener)
}
export function usePlansDialogOpen(): boolean {
return useSyncExternalStore(subscribe, () => open)
}
@@ -0,0 +1,166 @@
// What the plans dialog shows, from billing's plan catalog (GET /v1/plans): names, Stripe's prices,
// seat bounds, feature bullets, the trial's terms and each card's copy are billing's. A service from
// before the catalog (or a catalog that can't be read) falls back to the entitlement's `offers`,
// which are billing's numbers too. The desktop never supplies a price or a feature of its own.
import type {
OrcaBillingInterval,
OrcaBillingOffers,
OrcaBillingStatusResult
} from '../../../../../shared/orca-billing'
import {
isContactSalesPlan,
isSelfServePlan,
type OrcaPlanCatalog,
type OrcaPlanCatalogResult,
type OrcaPlanMarketing
} from '../../../../../shared/orca-billing-plans'
export type TeamPlanModel = {
planId: string
label: string
currency: string
monthlyPriceCentsPerSeat: number | null
annualPriceCentsPerSeat: number | null
/** Intervals on sale (priced), in display order. */
intervals: OrcaBillingInterval[]
/** Billing's feature bullets, in catalog order. */
features: string[]
marketing: OrcaPlanMarketing | null
/** An older service's display labels, for a price it sends no cents for. */
legacyPriceLabels: { month: string; year: string } | null
}
export type EnterprisePlanModel = {
label: string
priceLabel: string | null
contactUrl: string | null
features: string[]
marketing: OrcaPlanMarketing | null
}
export type TrialPlanModel = { label: string; tagline: string | null; features: string[] }
export type PlansModel = {
team: TeamPlanModel
enterprise: EnterprisePlanModel | null
trial: TrialPlanModel | null
/** `offers`: an older service's entitlement offers stood in for the catalog. */
source: 'live' | 'cache' | 'offers'
}
function featureLines(features: readonly { text: string }[]): string[] {
return features.flatMap((feature) => {
const text = feature.text.trim()
return text ? [text] : []
})
}
export function plansModelFromCatalog(
catalog: OrcaPlanCatalog,
source: 'live' | 'cache'
): PlansModel | null {
const team = catalog.plans.find(isSelfServePlan)
if (!team) {
return null
}
const price = (interval: OrcaBillingInterval) =>
team.prices.find((entry) => entry.interval === interval) ?? null
const monthly = price('month')
const annual = price('year')
const enterprise = catalog.plans.find(isContactSalesPlan)
const trial = catalog.plans.find((plan) => plan.kind === 'trial')
return {
source,
team: {
planId: team.id,
label: team.name,
currency: (monthly ?? annual)?.currency ?? 'usd',
monthlyPriceCentsPerSeat: monthly?.unitAmountCents ?? null,
annualPriceCentsPerSeat: annual?.unitAmountCents ?? null,
intervals: [monthly, annual].flatMap((entry) => (entry ? [entry.interval] : [])),
features: featureLines(team.features),
marketing: team.marketing,
legacyPriceLabels: null
},
enterprise: enterprise
? {
label: enterprise.name,
priceLabel: enterprise.priceLabel,
contactUrl: enterprise.contactUrl,
features: featureLines(enterprise.features),
marketing: enterprise.marketing
}
: null,
trial: trial
? {
label: trial.name,
tagline: trial.marketing?.tagline ?? null,
features: featureLines(trial.features)
}
: null
}
}
/** An older billing service (no GET /v1/plans): its entitlement offers. No feature bullets. */
export function plansModelFromOffers(offers: OrcaBillingOffers): PlansModel {
const team = offers.team
const intervals: OrcaBillingInterval[] = []
if (team.monthlyPriceCentsPerSeat !== null || team.monthlyPriceLabel) {
intervals.push('month')
}
if (team.annualPriceCentsPerSeat !== null || team.annualPriceLabel) {
intervals.push('year')
}
return {
source: 'offers',
team: {
planId: 'team',
label: team.label,
currency: 'usd',
monthlyPriceCentsPerSeat: team.monthlyPriceCentsPerSeat,
annualPriceCentsPerSeat: team.annualPriceCentsPerSeat,
intervals,
features: [],
marketing: null,
legacyPriceLabels: { month: team.monthlyPriceLabel, year: team.annualPriceLabel }
},
enterprise: offers.enterprise.label
? {
label: offers.enterprise.label,
priceLabel: offers.enterprise.priceLabel || null,
contactUrl: offers.enterprise.contactUrl || null,
features: [],
marketing: null
}
: null,
trial: null
}
}
export type PlansModelState =
| { state: 'loading' }
| { state: 'ready'; model: PlansModel }
/** Nothing from billing to show: the dialog still offers the console, never a guessed price. */
| { state: 'unavailable' }
/** Catalog first; the entitlement's offers only when the catalog can't be had. */
export function resolvePlansModel(
catalog: OrcaPlanCatalogResult | null,
billing: OrcaBillingStatusResult | null
): PlansModelState {
if (catalog?.status === 'ok') {
const model = plansModelFromCatalog(catalog.catalog, catalog.source)
if (model) {
return { state: 'ready', model }
}
}
if (catalog === null) {
return { state: 'loading' }
}
const offers = billing?.status === 'ok' ? billing.entitlement.offers : null
if (offers) {
return { state: 'ready', model: plansModelFromOffers(offers) }
}
// Billing may still answer with offers; wait for it rather than flash "unavailable".
return billing === null ? { state: 'loading' } : { state: 'unavailable' }
}
@@ -0,0 +1,40 @@
// Price math for the plans dialog. Every number is billing's: its catalog (Stripe's prices), or an
// older service's offers.
import type { OrcaBillingInterval } from '../../../../../shared/orca-billing'
type TeamPrices = {
monthlyPriceCentsPerSeat: number | null
annualPriceCentsPerSeat: number | null
}
/** What one seat costs per month on this interval (annual shown as its monthly equivalent). */
export function perSeatMonthlyCents(
team: TeamPrices,
interval: OrcaBillingInterval
): number | null {
if (interval === 'month') {
return team.monthlyPriceCentsPerSeat
}
return team.annualPriceCentsPerSeat === null
? null
: Math.round(team.annualPriceCentsPerSeat / 12)
}
/** Whole-percent saving of annual over twelve monthly payments, or null when not cheaper. */
export function annualSavingsPercent(team: TeamPrices): number | null {
const monthly = team.monthlyPriceCentsPerSeat
const annual = team.annualPriceCentsPerSeat
if (monthly === null || annual === null || monthly <= 0) {
return null
}
const percent = Math.round((1 - annual / (monthly * 12)) * 100)
return percent > 0 ? percent : null
}
/** The interval to show: the one picked when it is on sale, else the first one that is. */
export function shownInterval(
picked: OrcaBillingInterval,
intervals: readonly OrcaBillingInterval[]
): OrcaBillingInterval {
return intervals.includes(picked) ? picked : (intervals[0] ?? picked)
}
@@ -5,7 +5,9 @@ const auth = vi.hoisted(() => {
return state
})
const openCloudConsole = vi.hoisted(() => vi.fn())
const openPlansDialog = vi.hoisted(() => vi.fn())
vi.mock('@/lib/orca-cloud/open-cloud-console', () => ({ openCloudConsole }))
vi.mock('./plans/plans-dialog-store', () => ({ openPlansDialog }))
vi.mock('@/store/index', () => ({
useAppStore: {
getState: () => ({ orcaProfileAuthStatus: auth.status }),
@@ -41,6 +43,7 @@ afterEach(() => {
vi.unstubAllGlobals()
recordBillingStatus({ status: 'signed-out' })
openCloudConsole.mockReset()
openPlansDialog.mockReset()
})
describe('account menu billing items', () => {
@@ -57,11 +60,12 @@ describe('account menu billing items', () => {
).toEqual(['orca.team'])
expect(visible()).toEqual(['orca.team', 'orca.plan-billing'])
expect(visible('Admin')).toEqual(['orca.team', 'orca.plan-billing'])
// The console refuses members Plan & billing, so the menu doesn't offer it (n64 P3 #4).
expect(visible('Member')).toEqual(['orca.team'])
// Members get the read-only plans dialog (the console itself refuses them).
expect(visible('Member')).toEqual(['orca.team', 'orca.plan-billing'])
const plans = getRegisteredAccountMenuItems().find((item) => item.id === 'orca.plan-billing')
plans?.onSelect()
expect(openCloudConsole).toHaveBeenCalledWith('billing')
expect(openPlansDialog).toHaveBeenCalledTimes(1)
expect(openCloudConsole).not.toHaveBeenCalled()
dispose()
expect(getRegisteredAccountMenuItems()).toHaveLength(0)
})
@@ -74,6 +78,7 @@ describe('account menu billing items', () => {
entitlement: { ...sampleTeam, plan: null, planLabel: null, status: 'none' }
})
expect(visible()).toEqual(['orca.upgrade', 'orca.team'])
expect(visible('Member')).toEqual(['orca.team', 'orca.plan-billing'])
expect(getRegisteredAccountMenuItems().find((item) => item.id === 'orca.upgrade')?.tone).toBe(
'accent'
)
@@ -9,6 +9,7 @@ import {
subscribeBillingSummary
} from './billing-summary-store'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from './plans/plans-dialog-store'
/** Cloud capability flag that turns billing on per account (server-controlled rollout). */
export const BILLING_CAPABILITY = 'billing'
@@ -16,22 +17,23 @@ export const BILLING_CAPABILITY = 'billing'
const UPGRADE_ITEM_ID = 'orca.upgrade'
/**
* Account menu: "Team" and "Plan & billing" open the web console in the browser. Accounts without
* a plan get "Upgrade to Orca Cloud" (also the console's billing page) in place of Plan & billing.
* Account menu: "Plan & billing" opens the plans dialog (status and plans, then the web console);
* "Team" opens the console. Owners and admins of a team without a plan get "Upgrade to Orca Cloud"
* (the same dialog) in place of Plan & billing; members keep Plan & billing, read-only.
*/
export function registerPlanBillingMenuItem(): () => void {
const registerBilling = (): (() => void) =>
const registerBilling = (hideFromTeamAdmin: boolean): (() => void) =>
registerAccountMenuItem({
id: 'orca.plan-billing',
label: () => translate('auto.components.billing.menuItem', 'Plan & billing'),
icon: CreditCard,
order: 11,
requiredCapability: BILLING_CAPABILITY,
// The console's billing page is owners and admins only; don't offer members a dead end.
requiresTeamAdmin: true,
onSelect: () => void openCloudConsole('billing')
hideFromTeamAdmin,
onSelect: openPlansDialog
})
let disposeBilling: (() => void) | null = registerBilling()
let billingHiddenFromAdmins = false
let disposeBilling: () => void = registerBilling(false)
const disposeTeam = registerAccountMenuItem({
id: 'orca.team',
label: () => translate('auto.components.billing.team.menuItem', 'Team'),
@@ -46,12 +48,11 @@ export function registerPlanBillingMenuItem(): () => void {
const syncUpgrade = (): void => {
// Only a known "no plan" shows it: never flash an upsell at a paying team while loading.
const show = getBillingSummary().subscribed === false
// One entry at a time: "Upgrade to Orca Cloud" replaces "Plan & billing" until there is a plan.
if (show && disposeBilling) {
// One entry at a time for admins: "Upgrade to Orca Cloud" replaces "Plan & billing".
if (show !== billingHiddenFromAdmins) {
billingHiddenFromAdmins = show
disposeBilling()
disposeBilling = null
} else if (!show && !disposeBilling) {
disposeBilling = registerBilling()
disposeBilling = registerBilling(show)
}
if (show && !disposeUpgrade) {
disposeUpgrade = registerAccountMenuItem({
@@ -62,7 +63,7 @@ export function registerPlanBillingMenuItem(): () => void {
tone: 'accent',
requiredCapability: BILLING_CAPABILITY,
requiresTeamAdmin: true,
onSelect: () => void openCloudConsole('billing')
onSelect: openPlansDialog
})
} else if (!show && disposeUpgrade) {
disposeUpgrade()
@@ -104,7 +105,7 @@ export function registerPlanBillingMenuItem(): () => void {
onAuth()
return () => {
disposeBilling?.()
disposeBilling()
disposeTeam()
disposeUpgrade?.()
unsubscribeSummary()
@@ -1,5 +1,5 @@
import type { OrcaBillingStatusResult } from '../../../../shared/orca-billing'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { useAppStore } from '@/store/index'
import { sandboxHoursLeft } from '@/components/billing/plan-billing-format'
import {
@@ -24,7 +24,7 @@ function signInThenSelectOrcaCloud(): void {
/** Plans are chosen in the web console; the row re-reads billing when the composer reopens. */
function choosePlanInBrowser(): void {
void openCloudConsole('billing')
openPlansDialog()
}
/**
@@ -4,7 +4,7 @@ import React from 'react'
import { Button } from '@/components/ui/button'
import { InlineError } from '@/components/ui/inline-error'
import { useTranslate } from '@/i18n/use-translate'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { useOrcaCloudRunTargetAccess } from '../orca-cloud-billing-cache'
export function OrcaCloudTrialUsedUpNotice({
@@ -32,12 +32,7 @@ export function OrcaCloudTrialUsedUpNotice({
})
: t('components.newWorkspace.trialUsedUp.memberTitleNoTeam', 'Your team’s trial is used up')
const action = canManageBilling ? (
<Button
type="button"
variant="outline"
size="xs"
onClick={() => void openCloudConsole('billing')}
>
<Button type="button" variant="outline" size="xs" onClick={() => openPlansDialog()}>
{t('components.newWorkspace.cloudSetup.choosePlan', 'Choose plan')}
</Button>
) : onAskForPlan ? (
@@ -8,7 +8,7 @@ import { RotateCw } from 'lucide-react'
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import { runSleepWorktree } from '@/components/sidebar/workspace-actions/sleep/sleep-worktree-flow'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { signInAgainMessage } from '@/lib/orca-cloud/orca-sign-in-again'
import { signInAgainToastAction } from '@/lib/orca-cloud/orca-sign-in-again-action'
import type { ConfirmationDialogContextValue } from '@/components/confirmation-dialog-context'
@@ -42,7 +42,7 @@ function failureToast(title: string, result: CloudWorkspaceResult<null>): void {
? {
action: {
label: translate('auto.components.billing.comparePlans', 'Compare plans'),
onClick: () => void openCloudConsole('billing')
onClick: () => openPlansDialog()
}
}
: {})
@@ -1,14 +1,17 @@
// The Settings row that stands in for billing management, which lives in the Orca Cloud web
// console; team and admin are one row on the Account page (AccountTeamAdminRow). The desktop keeps
// only read-only status (the plan and its health, a failed payment) so the person knows when to go.
// The Settings row for billing, which is managed in the Orca Cloud web console; team and admin are
// one row on the Account page (AccountTeamAdminRow). The desktop keeps only read-only status (the
// plan and its health, a failed payment) and the plans dialog, which leads on to the console.
import { Button } from '@/components/ui/button'
import { useTranslate } from '@/i18n/use-translate'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { PaymentIssueNotice } from '../../billing/PaymentIssueNotice'
import { PlanStatusBadge } from '../../billing/PlanStatusBadge'
import { openPlansDialog } from '../../billing/plans/plans-dialog-store'
import { useOrcaBillingStatus } from '../../billing/use-orca-billing-status'
import { CloudConsoleLinkRow } from './CloudConsoleLinkRow'
import { SettingsRow } from '../form-controls/SettingsFormControls'
import { SettingsGroup } from '../section-layout/SettingsGroup'
/** Plan & billing: the plan and its health here; plans, usage, invoices and payment in the console. */
/** Plan & billing: the plan and its health here; the plans dialog, then the console, for the rest. */
export function PlanBillingConsoleLink(): React.JSX.Element {
const t = useTranslate()
const billing = useOrcaBillingStatus(true)
@@ -23,19 +26,25 @@ export function PlanBillingConsoleLink(): React.JSX.Element {
onUpdatePayment={() => void openCloudConsole('billing')}
/>
) : null}
<CloudConsoleLinkRow
section="billing"
label={
<span className="flex flex-wrap items-center gap-2">
{plan ?? t('auto.components.billing.title', 'Plan & billing')}
{entitlement?.plan ? <PlanStatusBadge entitlement={entitlement} /> : null}
</span>
}
description={t(
'settings.cloudConsole.billing.description',
'Change your plan, see sandbox hours and invoices, and update payment.'
)}
/>
<SettingsGroup>
<SettingsRow
label={
<span className="flex flex-wrap items-center gap-2">
{plan ?? t('auto.components.billing.title', 'Plan & billing')}
{entitlement?.plan ? <PlanStatusBadge entitlement={entitlement} /> : null}
</span>
}
description={t(
'settings.cloudConsole.billing.descriptionPlans',
'See your plan and compare plans, then change it, see invoices and update payment in your browser.'
)}
control={
<Button type="button" variant="outline" size="sm" onClick={openPlansDialog}>
{t('settings.cloudConsole.billing.viewPlans', 'View plans')}
</Button>
}
/>
</SettingsGroup>
</div>
)
}
@@ -17,6 +17,8 @@ export type AccountMenuItem = {
requiresSignIn?: boolean
/** Show only to an owner or admin of the active team (the console refuses members). */
requiresTeamAdmin?: boolean
/** Hide from owners and admins of the active team (they get a different entry in its place). */
hideFromTeamAdmin?: boolean
/** 'accent' marks a call to action (e.g. upgrade); default rows stay neutral. */
tone?: 'accent'
onSelect: () => void
@@ -62,6 +64,7 @@ export function selectVisibleAccountMenuItems(
.filter((item) => !item.requiredCapability || flags?.[item.requiredCapability] === true)
.filter((item) => !item.requiresSignIn || authStatus?.state === 'connected')
.filter((item) => !item.requiresTeamAdmin || canManageActiveTeam(authStatus))
.filter((item) => !item.hideFromTeamAdmin || !canManageActiveTeam(authStatus))
.map((item, index) => ({ item, index }))
.sort((a, b) => (a.item.order ?? 0) - (b.item.order ?? 0) || a.index - b.index)
.map(({ item }) => item)
@@ -8,7 +8,7 @@ import type {
OrcaBillingOverageResult
} from '../../../../shared/orca-billing'
import { overageFailureCopy } from '../billing/plan-billing-copy'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { formatCents } from '../../../../shared/orca-billing-usage-alerts'
/** The four ways billing can refuse a create (JA-21 progressive billing). */
@@ -386,7 +386,7 @@ export function VmBuildBillingBlocker({
onRaiseCap={(dollars) => void saveOverage(dollars * 100)}
onComparePlans={() => {
setPhase({ kind: 'browser', checking: false, stillBlocked: false })
void openCloudConsole('billing')
openPlansDialog()
}}
onUpdatePayment={() => {
setPhase({ kind: 'browser', checking: false, stillBlocked: false })
@@ -11,7 +11,7 @@ import {
isAwaitingVmEnvironmentCheckDecision,
resolveVmEnvironmentCheckDecision
} from '@/runtime/ephemeral-vm/ephemeral-vm-environment-check-decision'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { ORCA_BILLING_OVERAGE_SECTION_ID } from '@/components/new-workspace/orca-cloud-run-target-access'
import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation'
import { toast } from 'sonner'
@@ -352,7 +352,7 @@ export function VmBuildSheet({
isBillingFailure(failure) && typedComposerPrompt(entry).trim()
? () => onReturnToComposer({ local: false })
: onDismiss,
onSeePlans: () => void openCloudConsole('billing'),
onSeePlans: () => openPlansDialog(),
onCreateLocally: () => onReturnToComposer({ local: true }),
onOpenBilling: () => {
const store = useAppStore.getState()
@@ -1,7 +1,7 @@
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation'
import { classifyVmBuildFailure, type VmBuildFailure } from './vm-build-failure'
import { getLastBillingStatus } from '@/components/billing/billing-summary-store'
@@ -63,7 +63,7 @@ export function showVmBuildFailureToast(
? {
action: {
label: translate('auto.components.billing.comparePlans', 'Compare plans'),
onClick: () => void openCloudConsole('billing')
onClick: () => openPlansDialog()
}
}
: {})
+11
View File
@@ -217,6 +217,12 @@
}
},
"billing": {
"plans": {
"sandboxHoursLeftResets_one": "{{count}} sandbox hour left · resets {{date}}",
"sandboxHoursLeftResets_other": "{{count}} sandbox hours left · resets {{date}}",
"seatsBilled_one": "{{count}} seat · {{billed}}",
"seatsBilled_other": "{{count}} seats · {{billed}}"
},
"sandboxHoursLeftCount_one": "{{count}} sandbox hour left",
"sandboxHoursLeftCount_other": "{{count}} sandbox hours left",
"sandboxHoursOverIncluded_one": "{{count}} sandbox hour over the included amount this month",
@@ -2665,6 +2671,11 @@
"permissionOverridesKept_one": "{{count}} agent still uses their own permission setting:",
"permissionOverridesKept_other": "{{count}} agents still use their own permission setting:"
},
"cloudConsole": {
"billing": {
"description": "Change your plan, see sandbox hours and invoices, and update payment."
}
},
"diagnostics": {
"errors": {
"creatingDisabled": "creating review files is disabled",
+47 -2
View File
@@ -1504,7 +1504,9 @@
"cloudConsole": {
"manageInBrowser": "Manage in browser",
"billing": {
"description": "Change your plan, see sandbox hours and invoices, and update payment."
"description": "Change your plan, see sandbox hours and invoices, and update payment.",
"descriptionPlans": "See your plan and compare plans, then change it, see invoices and update payment in your browser.",
"viewPlans": "View plans"
},
"openFailed": "Couldn’t open the browser. Try again.",
"teamAdmin": {
@@ -21158,7 +21160,50 @@
"overage": {
"turnOn": "Turn on with a {{cap}} cap",
"turnOnNoCap": "Turn on overage"
}
},
"plans": {
"annual": "Annual",
"savePercent": "Save {{value0}}%",
"billingPeriod": "Billing period",
"monthly": "Monthly",
"was": "Was",
"priceInBrowser": "See price in browser",
"perSeatPerMonth": "per seat per month",
"billedYearly": "Billed yearly",
"billedYearlyAmount2": "{{value0}} per seat, billed yearly",
"billedMonthly": "Billed monthly",
"seatsBilled_one": "{{count}} seat · {{billed}}",
"seatsBilled_other": "{{count}} seats · {{billed}}",
"continueInBrowser": "Continue in browser",
"askAdmin": "Ask a team admin to upgrade.",
"manageHint2": "Change seats or billing period, see invoices, or update payment.",
"continueHint": "Sign in on the web to choose seats and pay. One seat per team member.",
"currentPlan": "Current plan",
"entPriced2": "Priced for your team",
"contactSales": "Contact sales",
"entHint": "Tell us about your team and where you run.",
"sandboxHoursLeftResets_one": "{{count}} sandbox hour left · resets {{date}}",
"sandboxHoursLeftResets_other": "{{count}} sandbox hours left · resets {{date}}",
"trialUsedUpAdmin": "Your trial hours are used up. Choose a plan to keep your sandboxes running.",
"trialUsedUpMember": "Your team’s trial hours are used up. Ask a team admin to upgrade.",
"trialOneTime2": "Trial hours are a one-time allowance and don’t reset. Choose a plan any time.",
"loading": "Loading plans…",
"titleSubscribed": "Your Orca Cloud plan",
"titleNeutral": "Orca Cloud plans",
"title": "Cloud sandboxes for your whole team",
"subtitle2": "Run Orca agents in hosted sandboxes that keep going when you step away.",
"signedOut": "Sign in to Orca to see your team’s plan.",
"loadFailedTitle": "Plans didn’t load",
"loadFailedConsole": "Check your connection and try again, or see plans in your browser.",
"retry": "Try again",
"savedCopy": "Offline: plans as of {{date}}. Your browser shows current prices.",
"eyebrow": "Orca Cloud",
"subtitleSubscribed2": "Your plan, its sandbox hours, and what Enterprise adds."
},
"sandboxHoursUsedLabel": "Sandbox hours used",
"sandboxHoursUsedMonth": "{{value0}} of {{value1}} sandbox hours used this month",
"trialProduct": "Orca Cloud",
"trialHoursUsedLabel": "Trial sandbox hours used"
},
"ports": {
"RuntimePortAutoForwarder": {
@@ -20,7 +20,7 @@ import { translate } from '@/i18n/i18n'
import { useAppStore } from '@/store'
import { findWorktreeById } from '@/store/github/refresh/worktree-refresh'
import { runSleepWorktree } from '@/components/sidebar/workspace-actions/sleep/sleep-worktree-flow'
import { openCloudConsole } from '@/lib/orca-cloud/open-cloud-console'
import { openPlansDialog } from '@/components/billing/plans/plans-dialog-store'
import { activateWorktreeFromSidebar } from '@/lib/workspace/activation/sidebar-worktree-activation'
import { installOrcaCloudWorkspaceStore } from '@/lib/orca-cloud/orca-cloud-workspace-store'
import { installCloudPredictiveWake } from '@/lib/orca-cloud/install-cloud-predictive-wake'
@@ -125,7 +125,7 @@ export function showOrcaCloudPlanUpsell(message: string): void {
toast.error(message, {
action: {
label: translate('auto.components.billing.comparePlans', 'Compare plans'),
onClick: () => void openCloudConsole('billing')
onClick: () => openPlansDialog()
}
})
}
+12
View File
@@ -10,6 +10,15 @@ export type OrcaPlanFeature = {
text: string
}
/** Billing's presentation copy for a plan (English); each field null when the catalog has none. */
export type OrcaPlanMarketing = {
tagline: string | null
/** Heading over the feature list, e.g. "Everything in Team, plus:". */
featuresLead: string | null
/** The plan card's button label. */
ctaLabel: string | null
}
export type OrcaPlanPrice = {
interval: OrcaBillingInterval
unitAmountCents: number
@@ -22,6 +31,7 @@ export type OrcaSelfServePlan = {
name: string
version: number
features: OrcaPlanFeature[]
marketing: OrcaPlanMarketing | null
/** Where "Contact us" goes for this plan (https), or null: fall back to the Enterprise contact. */
supportUrl: string | null
/** Only intervals Stripe has a price for; empty when none is on sale. */
@@ -43,6 +53,7 @@ export type OrcaContactSalesPlan = {
name: string
version: number
features: OrcaPlanFeature[]
marketing: OrcaPlanMarketing | null
/** Where "Contact us" goes for this plan (https), or null: fall back to the Enterprise contact. */
supportUrl: string | null
contactUrl: string | null
@@ -56,6 +67,7 @@ export type OrcaOtherPlan = {
name: string
version: number
features: OrcaPlanFeature[]
marketing: OrcaPlanMarketing | null
/** Where "Contact us" goes for this plan (https), or null: fall back to the Enterprise contact. */
supportUrl: string | null
}