From dde40cbdeb7d5296af6da430a8614caf8a1e4954 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 9 Nov 2026 04:55:05 -0800 Subject: [PATCH] wip(team): W10 round-1 fixes, return page, docs --- cloud/apps/billing/src/index.ts | 10 +- cloud/apps/billing/src/return-page.ts | 87 ++++++ cloud/apps/billing/test/auth-dev-keys.test.ts | 12 +- cloud/docs/accounts-billing-design.md | 42 +++ src/main/billing/billing-service.ts | 5 +- src/renderer/src/App.tsx | 2 + .../components/billing/PaymentIssueNotice.tsx | 16 +- .../components/billing/PlanBillingSection.tsx | 61 ++-- .../components/billing/PlanBillingUsage.tsx | 98 ++++-- .../components/billing/PlanStatusBadge.tsx | 11 +- .../billing/billing-summary-store.ts | 67 +++++ .../checkout/CheckoutPanel.fixture.tsx | 73 +++++ .../billing/checkout/CheckoutPanel.tsx | 4 +- .../components/billing/plan-billing-copy.ts | 21 +- .../billing/plans/PlansDialogContent.tsx | 50 ++-- .../billing/plans/PlansDialogHost.tsx | 58 +++- .../billing/plans/PlansIntervalToggle.tsx | 2 +- .../billing/plans/PlansView.fixture.tsx | 11 - .../components/billing/plans/PlansView.tsx | 124 +++++--- .../components/billing/plans/TeamPlanCard.tsx | 14 +- .../billing/plans/plans-page-store.ts | 2 +- .../billing/plans/use-org-seat-count.ts | 27 +- .../register-plan-billing-menu-item.test.ts | 77 +++-- .../register-plan-billing-menu-item.ts | 67 ++++- .../components/billing/team/TeamAvatar.tsx | 4 +- .../billing/team/TeamDialogHost.tsx | 235 +++++++++++++++ .../billing/team/TeamInviteComposer.tsx | 54 ++-- .../billing/team/TeamMemberList.tsx | 21 +- .../billing/team/TeamMembersSection.tsx | 114 ------- .../billing/team/TeamMembersView.fixture.tsx | 58 ---- .../billing/team/TeamMembersView.tsx | 280 ------------------ .../billing/team/TeamPageView.fixture.tsx | 220 ++++++++++++++ .../components/billing/team/TeamPageView.tsx | 40 ++- .../billing/team/TeamPlanSummary.tsx | 11 +- .../billing/team/TeamSettingsLink.tsx | 49 +++ .../billing/team/team-page-store.ts | 4 +- .../src/components/billing/team/team-roles.ts | 36 +-- .../components/billing/team/use-org-roster.ts | 89 ++++-- .../billing/team/use-team-actions.ts | 257 ++++++++++++++++ .../billing/use-orca-billing-status.ts | 2 + .../new-workspace/RunTargetSubmenus.tsx | 38 ++- .../accounts/orca/OrcaAccountSettingsPane.tsx | 10 +- .../sidebar/SidebarToolbar.fixture.tsx | 40 ++- .../account-menu/SidebarAccountMenu.tsx | 8 +- .../account-menu/account-menu-items.ts | 2 + .../src/i18n/en-runtime-required.json | 21 ++ 46 files changed, 1724 insertions(+), 810 deletions(-) create mode 100644 cloud/apps/billing/src/return-page.ts create mode 100644 src/renderer/src/components/billing/billing-summary-store.ts create mode 100644 src/renderer/src/components/billing/checkout/CheckoutPanel.fixture.tsx create mode 100644 src/renderer/src/components/billing/team/TeamDialogHost.tsx delete mode 100644 src/renderer/src/components/billing/team/TeamMembersSection.tsx delete mode 100644 src/renderer/src/components/billing/team/TeamMembersView.fixture.tsx delete mode 100644 src/renderer/src/components/billing/team/TeamMembersView.tsx create mode 100644 src/renderer/src/components/billing/team/TeamPageView.fixture.tsx create mode 100644 src/renderer/src/components/billing/team/TeamSettingsLink.tsx create mode 100644 src/renderer/src/components/billing/team/use-team-actions.ts diff --git a/cloud/apps/billing/src/index.ts b/cloud/apps/billing/src/index.ts index c2fe3ab9d34..23d596c93d2 100644 --- a/cloud/apps/billing/src/index.ts +++ b/cloud/apps/billing/src/index.ts @@ -31,6 +31,7 @@ import { OverageRequestSchema, updateOverage } from './overage' import { LiveModeRefusedError, StripeError, createStripeClient, type StripeClient } from './stripe' import { UsageReportSchema, flushMeterReports, recordUsage, validateSegment } from './usage' import { handleStripeWebhook } from './webhook' +import { renderReturnPage, returnOutcome } from './return-page' const MAX_JSON_BYTES = 16 * 1024 @@ -68,13 +69,8 @@ export async function handleRequest(request: Request, env: Env, ctx: ExecutionCo try { switch (route) { case 'GET /return': - // Where Checkout and the Portal send the browser back. Static; reveals nothing. - return new Response( - 'Orca' + - '' + - '

You can close this tab and return to Orca.

', - { headers: { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' } } - ) + // Where Checkout and the Portal send the browser back; hands off to the desktop app. + return renderReturnPage(returnOutcome(url)) case 'POST /v1/stripe/webhook': return await handleStripeWebhook(env, stripe, request, now) diff --git a/cloud/apps/billing/src/return-page.ts b/cloud/apps/billing/src/return-page.ts new file mode 100644 index 00000000000..b3c9c63822e --- /dev/null +++ b/cloud/apps/billing/src/return-page.ts @@ -0,0 +1,87 @@ +// Where Stripe Checkout and the Customer Portal send the browser back. It hands the user back to +// the desktop app through an orca:// link (opened at once, plus a button if the browser asks first). +// Static per outcome: query values only pick one of three fixed pages, nothing is reflected. + +type Outcome = 'checkout-success' | 'checkout-cancel' | 'portal' + +const COPY: Record = { + 'checkout-success': { + title: 'Payment complete', + body: 'Your team is on Orca Cloud. Head back to Orca to invite people and start a cloud workspace.', + link: 'orca://billing/return?checkout=success' + }, + 'checkout-cancel': { + title: 'Checkout canceled', + body: 'Nothing was charged. You can pick a plan again from Orca any time.', + link: 'orca://billing/return?checkout=cancel' + }, + portal: { + title: 'Billing updated', + body: 'Your changes are saved. Orca picks them up when you switch back.', + link: 'orca://billing/return?portal=return' + } +} + +export function returnOutcome(url: URL): Outcome { + if (url.searchParams.get('checkout') === 'success') { + return 'checkout-success' + } + if (url.searchParams.get('checkout') === 'cancel') { + return 'checkout-cancel' + } + return 'portal' +} + +const CHECK = + '' + +export function renderReturnPage(outcome: Outcome): Response { + const copy = COPY[outcome] + const success = outcome === 'checkout-success' + const html = ` + + + + + + +${copy.title} · Orca + + + +
+
${success ? CHECK : ''}
+

${copy.title}

+

${copy.body}

+ Open Orca + You can close this tab. +
+ +` + return new Response(html, { + headers: { + 'content-type': 'text/html; charset=utf-8', + 'cache-control': 'no-store', + // No scripts, no external loads; only inline styles. + 'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'", + 'referrer-policy': 'no-referrer', + 'x-content-type-options': 'nosniff' + } + }) +} diff --git a/cloud/apps/billing/test/auth-dev-keys.test.ts b/cloud/apps/billing/test/auth-dev-keys.test.ts index 6bdbe1d3187..dc198d6dafa 100644 --- a/cloud/apps/billing/test/auth-dev-keys.test.ts +++ b/cloud/apps/billing/test/auth-dev-keys.test.ts @@ -41,6 +41,16 @@ describe('dev operator keys', () => { passThroughOnException() {} } as unknown as ExecutionContext) expect(response.status).toBe(200) - expect(await response.text()).toContain('return to Orca') + const html = await response.text() + expect(html).toContain('Payment complete') + expect(html).toContain('orca://billing/return?checkout=success') + expect(response.headers.get('content-security-policy')).toContain("default-src 'none'") + const cancel = await handleRequest(new Request('https://billing.test/return?checkout=cancel&x=