Skip to content

An open-source, faster Devin alternative

TypeScript

Merge branch 'main' into prepaid-billing

Brian Reardonbdbc83561ffd
diff --cc cloudflare-workers/schema_phase7.sql
index 00000000,00000000..12cd67d1
new file mode 100644
--- /dev/null
+++ b/cloudflare-workers/schema_phase7.sql
@@@ -1,0 -1,0 +1,37 @@@
++-- Phase 7: Autumn billing — per-org billing_provider selector on D1.
++--
++-- The edge is authoritative for billing_provider: signup sets it, the cutover
++-- backfill flips existing orgs, and the cap-token carries it to each cell's
++-- Postgres mirror (like `plan`). The create/wake gates + the dashboard billing
++-- read it directly from D1, so this column MUST exist before the new api-edge
++-- code is deployed.
++--
++-- Apply with:
++-- wrangler d1 execute opencomputer-dev --remote --file cloudflare-workers/schema_phase7.sql
++--
++-- SQLite/D1 has no `ADD COLUMN IF NOT EXISTS`, so this is one-shot like the
++-- earlier phases.
++--
++-- ROLLOUT ORDER MATTERS. Run this migration BEFORE deploying the new api-edge
++-- code: loadOrgPolicy + GET /api/dashboard/billing now SELECT billing_provider
++-- for every org, and a missing column makes those reads error for ALL orgs
++-- (not just Autumn ones).
++--
++-- 'legacy' — in-house pipeline (CreditAccount DO / usage_reporter).
++-- 'autumn' — Autumn owns the credit ledger, metering, top-ups, concurrency.
++--
++-- Defaults to 'legacy' so every existing org is unaffected until explicitly
++-- flipped. Mirrors internal/db/migrations/047 on the cell.
++ALTER TABLE orgs ADD COLUMN billing_provider TEXT NOT NULL DEFAULT 'legacy';
++
++-- Cutover backfill / dashboard reads filter on it; partial index keeps the
++-- "which orgs are on Autumn" sweep tight while almost everyone is still legacy.
++CREATE INDEX IF NOT EXISTS idx_orgs_billing_provider ON orgs(billing_provider) WHERE billing_provider = 'autumn';
++
++-- Per-org watermark (unix seconds) for the edge autumn meter loop: the end of
++-- the last fully-tracked 5-minute bucket. 0 = unseeded; the first cron sight
++-- seeds it to "now" and bills forward only (never retroactively charges usage
++-- accrued before the org moved to Autumn). This is the edge-native replacement
++-- for the cell's orgs.last_usage_synced_at — billing is one place (the edge),
++-- off usage_samples, not per-cell.
++ALTER TABLE orgs ADD COLUMN autumn_usage_watermark INTEGER NOT NULL DEFAULT 0;
diff --cc web/src/pages/Billing.tsx
index 262ab322,eab02069..66bb6b1c
--- a/web/src/pages/Billing.tsx
+++ b/web/src/pages/Billing.tsx
@@@ -3,12 -2,10 +2,11 @@@ import { useState } from 'react
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import {
getBilling, billingSetup, billingPortal, getBillingInvoices, redeemPromoCode,
- listOrgAgentSubscriptions, listAgents, cancelAgentFeature,
- type StripeInvoice,
+ getAutumnBilling, autumnTopup, autumnSubscribeConcurrency, getSandboxUsage, setAutumnAutoTopup,
- type StripeInvoice, type OrgAgentSubscription, type Agent, type AutumnBilling,
++ type StripeInvoice, type AutumnBilling,
} from '../api/client'
- type Tab = 'sandboxes' | 'agents' | 'invoices'
+ type Tab = 'sandboxes' | 'invoices'
export default function Billing() {
const [tab, setTab] = useState<Tab>('sandboxes')
@@@ -263,558 -253,6 +260,352 @@@ function PlanTab()
)
}
+// ───────────── Prepaid (Autumn) plan view ─────────────
+
+const TOPUP_AMOUNTS = [5, 25, 100] // dollars == credits ($1/credit)
+
+const CONCURRENCY_TIERS = [
+ { id: 'concurrency_pro', label: 'Pro', limit: 100, price: 150 },
+ { id: 'concurrency_pro_plus', label: 'Pro+', limit: 600, price: 500 },
+ { id: 'concurrency_pro_plus_plus', label: 'Pro++', limit: 1000, price: 1000 },
+]
+
+function PrepaidPlan() {
+ const { data: autumn, isLoading } = useQuery({
+ queryKey: ['autumn-billing'], queryFn: getAutumnBilling, refetchInterval: 30_000,
+ })
+ const [amount, setAmount] = useState<number>(25)
+ const queryClient = useQueryClient()
+
+ // url present → redirect to hosted checkout (collect a new card); url null →
+ // the existing card was charged server-side, so just refresh the balance.
+ const onPurchase = (data: { url: string | null }) => {
+ if (data.url) window.location.href = data.url
+ else queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
+ }
+ const topupMutation = useMutation({
+ mutationFn: () => autumnTopup(amount),
+ onSuccess: onPurchase,
+ })
+ const planMutation = useMutation({
+ mutationFn: (plan: string) => autumnSubscribeConcurrency(plan),
+ onSuccess: onPurchase,
+ })
+
+
+ if (isLoading) {
+ return (
+ <div style={{ display: 'flex', justifyContent: 'center', padding: 80 }}>
+ <div className="loading-spinner" />
+ </div>
+ )
+ }
+
+ const credits = (autumn?.creditsRemainingCents ?? 0) / 100
+ const halted = autumn?.isHalted ?? false
+ const currentPlan = autumn?.concurrencyPlan ?? 'base'
+
+ return (
+ <>
+ {/* Credits balance */}
+ <div className="glass-card animate-in stagger-1" style={{ padding: 28, marginBottom: 14 }}>
+ <span className="section-title" style={{ marginBottom: 16, display: 'block' }}>
+ Prepaid Credits
+ </span>
+ <div style={{ display: 'flex', alignItems: 'baseline', gap: 12, marginBottom: 8 }}>
+ <span className="metric-value" style={{
+ fontSize: 36, fontWeight: 700, fontFamily: 'var(--font-mono)',
+ color: halted ? 'var(--accent-rose)' : 'var(--accent-emerald)',
+ }}>
+ ${credits.toFixed(2)}
+ </span>
+ <span style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>remaining</span>
+ </div>
+ {halted && (
+ <div style={{
+ fontSize: 13, color: 'var(--accent-rose)', marginBottom: 12,
+ display: 'flex', alignItems: 'center', gap: 6,
+ }}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="12" /><line x1="12" y1="16" x2="12.01" y2="16" />
+ </svg>
+ Credits exhausted — top up to resume your sandboxes
+ </div>
+ )}
+
+ {/* Top-up */}
+ <div style={{ marginTop: 18 }}>
+ <div style={{ fontSize: 13, color: 'var(--text-secondary)', marginBottom: 10 }}>
+ Add credits (billed at the same per-second rates)
+ </div>
+ <div style={{ display: 'flex', gap: 8, marginBottom: 14, flexWrap: 'wrap' }}>
+ {TOPUP_AMOUNTS.map((a) => (
+ <button
+ key={a}
+ onClick={() => setAmount(a)}
+ style={{
+ padding: '8px 16px', borderRadius: 8, cursor: 'pointer',
+ fontFamily: 'var(--font-mono)', fontSize: 14, fontWeight: 600,
+ border: amount === a ? '1px solid var(--accent-indigo)' : '1px solid var(--border-subtle)',
+ background: amount === a ? 'var(--accent-indigo-soft, rgba(99,102,241,0.12))' : 'transparent',
+ color: amount === a ? 'var(--accent-indigo)' : 'var(--text-secondary)',
+ }}
+ >
+ ${a}
+ </button>
+ ))}
+ <input
+ type="number"
+ min={1}
+ value={amount}
+ onChange={(e) => setAmount(Math.max(1, Math.floor(Number(e.target.value) || 0)))}
+ style={{
+ width: 90, padding: '8px 12px', borderRadius: 8,
+ border: '1px solid var(--border-subtle)', background: 'transparent',
+ color: 'var(--text-primary)', fontFamily: 'var(--font-mono)', fontSize: 14,
+ }}
+ />
+ </div>
+ <button
+ className="btn-primary"
+ disabled={topupMutation.isPending || amount < 1}
+ onClick={() => topupMutation.mutate()}
+ style={{ padding: '10px 20px' }}
+ >
+ {topupMutation.isPending ? 'Redirecting…' : `Top up $${amount}`}
+ </button>
+ {topupMutation.isError && (
+ <div style={{ fontSize: 12, color: 'var(--accent-rose)', marginTop: 8 }}>
+ {(topupMutation.error as Error).message}
+ </div>
+ )}
+ </div>
+ </div>
+
+ <AutoTopupCard current={autumn?.autoTopup ?? null} hasToppedUp={autumn?.hasToppedUp ?? false} />
+
+ {/* Concurrency plans */}
+ <div className="glass-card animate-in stagger-3" style={{ padding: 28 }}>
+ <span className="section-title" style={{ marginBottom: 8, display: 'block' }}>
+ Concurrency
+ </span>
+ <div style={{ fontSize: 13, color: 'var(--text-secondary)', marginBottom: 16 }}>
+ You can run <strong style={{ color: 'var(--text-primary)' }}>{autumn?.maxConcurrentSandboxes ?? 5}</strong> sandboxes
+ at once on the <strong style={{ color: 'var(--text-primary)' }}>{currentPlan === 'base' ? 'Base' : currentPlan}</strong> tier.
+ Subscribe to a higher tier for more — billed monthly, separate from usage credits.
+ </div>
+ <div style={{ display: 'grid', gap: 10 }}>
+ {CONCURRENCY_TIERS.map((tier) => {
+ const active = currentPlan === tier.id
+ return (
+ <div
+ key={tier.id}
+ style={{
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
+ padding: '14px 16px', borderRadius: 10,
+ border: active ? '1px solid var(--accent-indigo)' : '1px solid var(--border-subtle)',
+ }}
+ >
+ <div>
+ <div style={{ fontSize: 14, fontWeight: 600, color: 'var(--text-primary)' }}>
+ {tier.label} — {tier.limit} concurrent
+ </div>
+ <div style={{ fontSize: 12, color: 'var(--text-tertiary)', fontFamily: 'var(--font-mono)' }}>
+ ${tier.price}/mo
+ </div>
+ </div>
+ <button
+ className="btn-secondary"
+ disabled={active || planMutation.isPending}
+ onClick={() => planMutation.mutate(tier.id)}
+ style={{ padding: '8px 16px' }}
+ >
+ {active ? 'Current' : 'Subscribe'}
+ </button>
+ </div>
+ )
+ })}
+ <div style={{ fontSize: 12, color: 'var(--text-tertiary)', marginTop: 4 }}>
+ Need more than 1000? <a href="mailto:[email protected]" style={{ color: 'var(--accent-indigo)' }}>Contact us</a>.
+ </div>
+ </div>
+ {planMutation.isError && (
+ <div style={{ fontSize: 12, color: 'var(--accent-rose)', marginTop: 10 }}>
+ {(planMutation.error as Error).message}
+ </div>
+ )}
+ </div>
+
+ <UsageBreakdown />
+ </>
+ )
+}
+
+function UsageBreakdown() {
+ const { data, isLoading } = useQuery({
+ queryKey: ['sandbox-usage'], queryFn: () => getSandboxUsage(30),
+ })
+
+ const rows = data?.sandboxes ?? []
+
+ return (
+ <div className="glass-card animate-in stagger-4" style={{ padding: 28, marginTop: 14 }}>
+ <span className="section-title" style={{ marginBottom: 4, display: 'block' }}>
+ Usage by sandbox
+ </span>
+ <div style={{ fontSize: 12, color: 'var(--text-tertiary)', marginBottom: 16 }}>
+ Compute cost over the last {data?.windowDays ?? 30} days (disk overage not included).
+ </div>
+
+ {isLoading ? (
+ <div style={{ display: 'flex', justifyContent: 'center', padding: 24 }}>
+ <div className="loading-spinner" />
+ </div>
+ ) : rows.length === 0 ? (
+ <div style={{ fontSize: 13, color: 'var(--text-secondary)' }}>
+ No recent sandbox usage to show yet.
+ </div>
+ ) : (
+ <div style={{ display: 'grid', gap: 1 }}>
+ <div style={{
+ display: 'grid', gridTemplateColumns: '1fr auto auto', gap: 12,
+ fontSize: 11, color: 'var(--text-tertiary)', textTransform: 'uppercase',
+ letterSpacing: '0.04em', padding: '0 4px 8px',
+ }}>
+ <span>Sandbox</span><span style={{ textAlign: 'right' }}>Runtime</span><span style={{ textAlign: 'right' }}>Cost</span>
+ </div>
+ {rows.map((r) => (
+ <div
+ key={r.sandboxId}
+ style={{
+ display: 'grid', gridTemplateColumns: '1fr auto auto', gap: 12,
+ alignItems: 'center', padding: '10px 4px',
+ borderTop: '1px solid var(--border-subtle)', fontSize: 13,
+ }}
+ >
+ <span style={{ fontFamily: 'var(--font-mono)', color: 'var(--text-primary)', overflow: 'hidden', textOverflow: 'ellipsis' }}>
+ {r.sandboxId}
+ <span style={{ marginLeft: 8, fontSize: 11, color: 'var(--text-tertiary)', fontFamily: 'var(--font-body)' }}>
+ {r.status}
+ </span>
+ </span>
+ <span style={{ textAlign: 'right', color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)' }}>
+ {formatDuration(r.seconds)}
+ </span>
+ <span style={{ textAlign: 'right', color: 'var(--text-primary)', fontFamily: 'var(--font-mono)', fontWeight: 600 }}>
+ ${(r.costCents / 100).toFixed(2)}
+ </span>
+ </div>
+ ))}
+ <div style={{
+ display: 'grid', gridTemplateColumns: '1fr auto', gap: 12,
+ padding: '12px 4px 0', borderTop: '1px solid var(--border-subtle)',
+ marginTop: 4, fontSize: 13, fontWeight: 600,
+ }}>
+ <span style={{ color: 'var(--text-secondary)' }}>Total</span>
+ <span style={{ textAlign: 'right', color: 'var(--text-primary)', fontFamily: 'var(--font-mono)' }}>
+ ${((data?.totalCents ?? 0) / 100).toFixed(2)}
+ </span>
+ </div>
+ </div>
+ )}
+ </div>
+ )
+}
+
+function formatDuration(seconds: number): string {
+ if (seconds < 60) return `${seconds}s`
+ if (seconds < 3600) return `${Math.round(seconds / 60)}m`
+ return `${(seconds / 3600).toFixed(1)}h`
+}
+
+const autoTopupInputStyle = {
+ width: 80, padding: '6px 10px', borderRadius: 8, border: '1px solid var(--border-subtle)',
+ background: 'transparent', color: 'var(--text-primary)', fontFamily: 'var(--font-mono)', fontSize: 13,
+}
+
+function AutoTopupCard({ current, hasToppedUp }: { current: AutumnBilling['autoTopup']; hasToppedUp: boolean }) {
+ const queryClient = useQueryClient()
+ const [enabled, setEnabled] = useState(current?.enabled ?? false)
+ const [threshold, setThreshold] = useState(current?.threshold ?? 5)
+ const [quantity, setQuantity] = useState(current?.quantity ?? 25)
+ const [saved, setSaved] = useState(false)
+
+ const mutation = useMutation({
+ mutationFn: () => setAutumnAutoTopup({ enabled, threshold, quantity }),
+ onSuccess: (data) => {
+ // Auto-recharge needs a saved off-session card. If enabling without one, the
+ // server returns a no-charge Stripe setup URL — redirect to capture the card,
+ // after which auto-recharge is live. Otherwise just confirm the save.
+ if (data?.url) { window.location.href = data.url; return }
+ queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
+ setSaved(true)
+ setTimeout(() => setSaved(false), 3000)
+ },
+ })
+
+ return (
+ <div className="glass-card animate-in stagger-2" style={{ padding: 28, marginBottom: 14 }}>
+ <span className="section-title" style={{ marginBottom: 8, display: 'block' }}>
+ Automatic Top-up
+ </span>
+ <div style={{ fontSize: 13, color: 'var(--text-secondary)', marginBottom: 16 }}>
+ Keep your balance from running out — when it drops below the threshold we
+ automatically add credits to your saved card.
+ </div>
+ <label style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 16, cursor: 'pointer', fontSize: 13 }}>
+ <input type="checkbox" checked={enabled} onChange={(e) => setEnabled(e.target.checked)} />
+ <span style={{ color: 'var(--text-primary)' }}>Enable automatic top-up</span>
+ </label>
+ {enabled && (
+ <div style={{ display: 'flex', gap: 20, marginBottom: 16, flexWrap: 'wrap' }}>
+ <label style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>
+ When balance falls below
+ <div style={{ display: 'flex', alignItems: 'center', gap: 4, marginTop: 4 }}>
+ <span style={{ color: 'var(--text-secondary)' }}>$</span>
+ <input
+ type="number" min={0} value={threshold}
+ onChange={(e) => setThreshold(Math.max(0, Math.floor(Number(e.target.value) || 0)))}
+ style={autoTopupInputStyle}
+ />
+ </div>
+ </label>
+ <label style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>
+ Add credits
+ <div style={{ display: 'flex', alignItems: 'center', gap: 4, marginTop: 4 }}>
+ <span style={{ color: 'var(--text-secondary)' }}>$</span>
+ <input
+ type="number" min={1} value={quantity}
+ onChange={(e) => setQuantity(Math.max(1, Math.floor(Number(e.target.value) || 0)))}
+ style={autoTopupInputStyle}
+ />
+ </div>
+ </label>
+ </div>
+ )}
+ <button
+ className="btn-secondary"
+ disabled={mutation.isPending}
+ onClick={() => mutation.mutate()}
+ style={{ padding: '8px 16px' }}
+ >
+ {mutation.isPending ? 'Saving…' : saved ? 'Saved ✓' : 'Save'}
+ </button>
+ {enabled && (
+ <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 10 }}>
+ Charges your saved card automatically when the balance drops below the threshold.
+ {!hasToppedUp && ` Since you haven't topped up yet, enabling runs your first $${quantity} recharge now to set up your card.`}
+ </div>
+ )}
+ {mutation.isError && (
+ <div style={{ fontSize: 12, color: 'var(--accent-rose)', marginTop: 8 }}>
+ {(mutation.error as Error).message}
+ </div>
+ )}
+ </div>
+ )
+}
+
- // ───────────── Agents tab ─────────────
-
- function AgentsTab() {
- const queryClient = useQueryClient()
- const { data: subsData, isLoading: subsLoading } = useQuery({
- queryKey: ['org-agent-subscriptions'],
- queryFn: listOrgAgentSubscriptions,
- refetchInterval: 30_000,
- })
- const { data: agentsData } = useQuery({
- queryKey: ['agents'], queryFn: listAgents,
- })
-
- const cancelMutation = useMutation({
- mutationFn: ({ agentId, feature }: { agentId: string; feature: string }) =>
- cancelAgentFeature(agentId, feature),
- onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ['org-agent-subscriptions'] })
- },
- })
-
- // Index agents by ID so we can show display names instead of raw IDs.
- const agentsById = useMemo(() => {
- const map: Record<string, Agent> = {}
- for (const a of agentsData?.agents ?? []) map[a.id] = a
- return map
- }, [agentsData])
-
- // De-duplicate to one row per (agent_id, feature). We sort by created_at
- // desc so the freshest row wins — covers cases where a user canceled then
- // re-subscribed.
- const rows = useMemo(() => {
- const seen = new Set<string>()
- const sorted = [...(subsData?.subscriptions ?? [])].sort((a, b) =>
- b.created_at.localeCompare(a.created_at),
- )
- const out: OrgAgentSubscription[] = []
- for (const sub of sorted) {
- const key = `${sub.agent_id}::${sub.feature}`
- if (seen.has(key)) continue
- seen.add(key)
- out.push(sub)
- }
- return out
- }, [subsData])
-
- const activeRows = rows.filter(r => r.active)
- const inactiveRows = rows.filter(r => !r.active)
-
- const totalMonthlyCents = activeRows.reduce((sum, r) => sum + r.price_monthly_cents, 0)
-
- if (subsLoading) {
- return (
- <div style={{ display: 'flex', justifyContent: 'center', padding: 80 }}>
- <div className="loading-spinner" />
- </div>
- )
- }
-
- return (
- <>
- {/* Summary card */}
- <div className="glass-card animate-in stagger-1" style={{ padding: 28, marginBottom: 14 }}>
- <span className="section-title" style={{ marginBottom: 12, display: 'block' }}>
- Per-agent features
- </span>
- <div style={{ display: 'flex', alignItems: 'baseline', gap: 12, marginBottom: 6 }}>
- <span className="metric-value" style={{ fontSize: 32, fontWeight: 700 }}>
- ${(totalMonthlyCents / 100).toFixed(2)}
- </span>
- <span style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>
- /mo across {activeRows.length} active subscription{activeRows.length === 1 ? '' : 's'}
- </span>
- </div>
- <p style={{ fontSize: 13, color: 'var(--text-secondary)', lineHeight: 1.5, marginTop: 6 }}>
- Each connected channel (e.g. Telegram) is billed per-agent. Subscribe or cancel from each
- agent's page.
- </p>
- </div>
-
- {/* Active subscriptions */}
- <div className="glass-card animate-in stagger-2" style={{ padding: '22px 24px', marginBottom: 14 }}>
- <span className="section-title" style={{ marginBottom: 14, display: 'block' }}>
- Active
- </span>
- {activeRows.length === 0 ? (
- <div style={{ textAlign: 'center', padding: '32px 20px', color: 'var(--text-tertiary)', fontSize: 13 }}>
- No active per-agent subscriptions yet.
- </div>
- ) : (
- <table className="data-table">
- <thead>
- <tr>
- <th>Agent</th>
- <th>Feature</th>
- <th>Status</th>
- <th>Renews</th>
- <th style={{ textAlign: 'right' }}>Price</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- {activeRows.map((sub) => {
- const agent = agentsById[sub.agent_id]
- const label = agent?.display_name || sub.agent_id
- const renewLabel = sub.cancel_at_period_end
- ? `Ends ${formatDate(sub.current_period_end)}`
- : sub.current_period_end
- ? formatDate(sub.current_period_end)
- : '—'
- return (
- <tr key={sub.stripe_subscription_id}>
- <td>
- <Link to={`/agents/${encodeURIComponent(sub.agent_id)}`}
- style={{ color: 'var(--accent-indigo)', textDecoration: 'none', fontWeight: 600 }}>
- {label}
- </Link>
- {agent && (
- <div style={{ fontSize: 11, color: 'var(--text-tertiary)', fontFamily: 'var(--font-mono)' }}>
- {sub.agent_id}
- </div>
- )}
- </td>
- <td style={{ textTransform: 'capitalize', fontSize: 13 }}>{sub.feature}</td>
- <td><SubscriptionStatus status={sub.status} cancelAtPeriodEnd={sub.cancel_at_period_end} /></td>
- <td style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: 'var(--text-secondary)' }}>
- {renewLabel}
- </td>
- <td style={{ fontFamily: 'var(--font-mono)', fontSize: 13, fontWeight: 600, textAlign: 'right' }}>
- ${(sub.price_monthly_cents / 100).toFixed(2)}/mo
- </td>
- <td style={{ textAlign: 'right' }}>
- {!sub.cancel_at_period_end && (
- <button
- onClick={() => {
- if (confirm(`Cancel ${sub.feature} for ${label} at end of billing period?`)) {
- cancelMutation.mutate({ agentId: sub.agent_id, feature: sub.feature })
- }
- }}
- disabled={cancelMutation.isPending}
- style={{
- background: 'none',
- border: '1px solid var(--border-subtle)',
- color: 'var(--text-secondary)',
- fontSize: 12,
- padding: '4px 10px',
- borderRadius: 'var(--radius-sm)',
- cursor: 'pointer',
- fontFamily: 'var(--font-body)',
- }}
- >
- Cancel
- </button>
- )}
- </td>
- </tr>
- )
- })}
- </tbody>
- </table>
- )}
- </div>
-
- {/* Past subscriptions (collapsed-feeling) */}
- {inactiveRows.length > 0 && (
- <div className="glass-card animate-in stagger-3" style={{ padding: '22px 24px' }}>
- <span className="section-title" style={{ marginBottom: 14, display: 'block' }}>
- Past
- </span>
- <table className="data-table">
- <thead>
- <tr>
- <th>Agent</th>
- <th>Feature</th>
- <th>Status</th>
- <th>Ended</th>
- </tr>
- </thead>
- <tbody>
- {inactiveRows.map((sub) => {
- const agent = agentsById[sub.agent_id]
- const label = agent?.display_name || sub.agent_id
- return (
- <tr key={sub.stripe_subscription_id}>
- <td>
- <Link to={`/agents/${encodeURIComponent(sub.agent_id)}`}
- style={{ color: 'var(--text-secondary)', textDecoration: 'none' }}>
- {label}
- </Link>
- </td>
- <td style={{ textTransform: 'capitalize', fontSize: 13 }}>{sub.feature}</td>
- <td><SubscriptionStatus status={sub.status} cancelAtPeriodEnd={false} /></td>
- <td style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: 'var(--text-tertiary)' }}>
- {formatDate(sub.canceled_at || sub.current_period_end)}
- </td>
- </tr>
- )
- })}
- </tbody>
- </table>
- </div>
- )}
- </>
- )
- }
-
// ───────────── Invoices tab ─────────────
function InvoicesTab() {