diff --git a/cloud/apps/billing/src/plans.ts b/cloud/apps/billing/src/plans.ts index 28b8577593f..969e14cb847 100644 --- a/cloud/apps/billing/src/plans.ts +++ b/cloud/apps/billing/src/plans.ts @@ -8,7 +8,10 @@ // runs it as Standard, so it also counts 1x. // Included hours are a MONTHLY per-seat allowance pooled across the org, for annual plans too. import { z } from 'zod' -import { ORCA_CLOUD_IDLE_SLEEP_MINUTES } from '../../../../src/shared/hosted-sandbox/hosted-sandbox-wire' +import { + ORCA_CLOUD_IDLE_SLEEP_MINUTES, + ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR +} from '../../../../src/shared/hosted-sandbox/hosted-sandbox-wire' import type { Env } from './env' export const PLAN_IDS = ['team'] as const @@ -70,9 +73,9 @@ export const DEFAULT_PLANS: PlanCatalog = { machineSizes: ['standard', 'large'], // Same constant the control plane enforces and serves (GET /v1/config); never a literal here. idleSleepMinutes: ORCA_CLOUD_IDLE_SLEEP_MINUTES, - // The one overage rate: entitlements, the spend-cap math, the desktop and the e2e all read it from - // here. STRIPE_PRICE_OVERAGE must be a metered price with this unit_amount (stripe-test-setup.ts). - overageCentsPerHour: 100, + // Shared with the control plane's workspace cost; entitlements, the spend-cap math, the desktop and + // the e2e read it from here. STRIPE_PRICE_OVERAGE must be a metered price with this unit_amount. + overageCentsPerHour: ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR, defaultSpendCapCents: 2500, maxSpendCapCents: 500_000, warnAtPercent: [80, 100], diff --git a/cloud/apps/sandbox-control/src/workspace-lifecycle.ts b/cloud/apps/sandbox-control/src/workspace-lifecycle.ts index d46ea65c002..17f70e52d07 100644 --- a/cloud/apps/sandbox-control/src/workspace-lifecycle.ts +++ b/cloud/apps/sandbox-control/src/workspace-lifecycle.ts @@ -35,6 +35,7 @@ import { type SandboxRow } from './store' import { flushUsage } from './usage' +import { ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR } from '../../../../src/shared/hosted-sandbox/hosted-sandbox-wire' const DAY_MS = 86_400_000 export const DEFAULT_ARCHIVE_TTL_MS = 30 * DAY_MS @@ -61,7 +62,11 @@ const ARCHIVE_DRAIN_SECONDS = 60 */ export const DEFAULT_IDLE_SLEEP_MINUTES = ORCA_CLOUD_IDLE_SLEEP_MINUTES // A legacy `large` row is the same 8 vCPU box as standard and billing counts it 1x (U18). -export const DEFAULT_CENTS_PER_HOUR: Record = { standard: 75, large: 75 } +// Billing's overage price (the shared constant); every size counts 1x. COST_CENTS_PER_HOUR can override. +export const DEFAULT_CENTS_PER_HOUR: Record = { + standard: ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR, + large: ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR +} export type WorkspaceConfig = { /** IDLE_SLEEP_MINUTES; DEFAULT_IDLE_SLEEP_MINUTES when unset. */ diff --git a/cloud/apps/sandbox-control/src/workspaces.ts b/cloud/apps/sandbox-control/src/workspaces.ts index ff6082b17be..8052b6075b0 100644 --- a/cloud/apps/sandbox-control/src/workspaces.ts +++ b/cloud/apps/sandbox-control/src/workspaces.ts @@ -14,10 +14,14 @@ import type { MachineSize } from './entitlements' import { getSandbox, touchActivity, updateRegistry, type SandboxRow } from './store' import { memberNamesFor } from './member-names' import { sandboxView } from './wire' +import { ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR } from '../../../../src/shared/hosted-sandbox/hosted-sandbox-wire' export const PRESENCE_TTL_MS = 45_000 -/** Billing's overage rate (75¢ per standard hour, large weighs 2) in USD micros per wall-clock hour. */ -export const COMPUTE_USD_MICROS_PER_HOUR: Record = { standard: 750_000, large: 1_500_000 } +/** Billing's overage price per awake hour in USD micros; every size counts 1x (legacy large too). */ +export const COMPUTE_USD_MICROS_PER_HOUR: Record = { + standard: ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR * 10_000, + large: ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR * 10_000 +} export type WorkspaceAccess = 'owner' | 'granted' | 'can_open' | 'none' diff --git a/cloud/apps/sandbox-control/test/workspace-lifecycle.test.ts b/cloud/apps/sandbox-control/test/workspace-lifecycle.test.ts index 17d8d05ba7c..d45660ef5bf 100644 --- a/cloud/apps/sandbox-control/test/workspace-lifecycle.test.ts +++ b/cloud/apps/sandbox-control/test/workspace-lifecycle.test.ts @@ -139,7 +139,7 @@ describe('status panel', () => { expect(status.state).toBe('ready') expect(status.metrics?.memUsedBytes).toBe(2e9) expect(status.uptimeMs).toBe(90 * 60_000) - expect(status.usage).toEqual({ totalMs: 90 * 60_000, centsPerHour: 75, costCents: 113 }) + expect(status.usage).toEqual({ totalMs: 90 * 60_000, centsPerHour: 100, costCents: 150 }) }) it('says unresponsive when the VM does not answer or orcad is dead, and surfaces OOM kills', async () => { @@ -159,7 +159,7 @@ describe('status panel', () => { let probes = 0 h.vercel.onScript = () => (probes++, undefined) const { status } = HostedWorkspaceStatusResponseSchema.parse((await h.call('GET', `/v1/sandboxes/${id}/status`)).body) - expect(status).toMatchObject({ state: 'sleeping', metrics: null, uptimeMs: null, usage: { totalMs: 60 * 60_000, costCents: 75 } }) + expect(status).toMatchObject({ state: 'sleeping', metrics: null, uptimeMs: null, usage: { totalMs: 60 * 60_000, costCents: 100 } }) expect(probes).toBe(0) }) }) diff --git a/cloud/apps/sandbox-control/test/workspaces.test.ts b/cloud/apps/sandbox-control/test/workspaces.test.ts index 17fe65774f2..536acefc4a1 100644 --- a/cloud/apps/sandbox-control/test/workspaces.test.ts +++ b/cloud/apps/sandbox-control/test/workspaces.test.ts @@ -85,12 +85,12 @@ describe('workspace registry', () => { const t = await team() t.h.advance(90 * MIN) let [w] = (await t.req(t.alice, 'GET', '/v1/team/workspaces?scope=mine')).body.workspaces - expect(w.cost).toMatchObject({ computeMs: 90 * MIN, rateUsdMicrosPerHour: 750_000, computeUsdMicros: 1_125_000, tokenUsdMicros: null }) + expect(w.cost).toMatchObject({ computeMs: 90 * MIN, rateUsdMicrosPerHour: 1_000_000, computeUsdMicros: 1_500_000, tokenUsdMicros: null }) await t.req(t.alice, 'POST', `/v1/sandboxes/${t.id}/suspend`) t.h.advance(600 * MIN) await t.req(t.alice, 'PATCH', `/v1/team/workspaces/${t.id}`, { tokenUsdMicros: 2_500_000 }) ;[w] = (await t.req(t.alice, 'GET', '/v1/team/workspaces?scope=mine')).body.workspaces - expect(w.cost).toMatchObject({ computeMs: 90 * MIN, computeUsdMicros: 1_125_000, tokenUsdMicros: 2_500_000, totalUsdMicros: 3_625_000 }) + expect(w.cost).toMatchObject({ computeMs: 90 * MIN, computeUsdMicros: 1_500_000, tokenUsdMicros: 2_500_000, totalUsdMicros: 4_000_000 }) }) it('labels owners and present teammates with the name claim from their own tokens', async () => { diff --git a/mobile/src/cloud/CloudStatusCard.tsx b/mobile/src/cloud/CloudStatusCard.tsx index c17ea43c4bc..bcd3adbc34d 100644 --- a/mobile/src/cloud/CloudStatusCard.tsx +++ b/mobile/src/cloud/CloudStatusCard.tsx @@ -6,35 +6,50 @@ import { CloudPhaseSteps } from './CloudPhaseSteps' import { CloudStatusDot } from './CloudStatusDot' import { CloudWakeSlowNote } from './CloudWakeSlowNote' import type { CloudWorkspace } from './cloud-control-plane-client' -import { cloudStatusLabel, formatCloudCost } from './cloud-workspace-display' +import { cloudSandboxHours, cloudStatusLabel } from './cloud-workspace-display' import { statusSentence } from './cloud-workspace-copy' import { cloudWorkspaceScreenStyles as styles } from './cloud-workspace-screen-styles' import type { CloudWorkspaceRun } from './use-cloud-workspace-run' -/** Spend once, honestly: what it cost so far, and whether it is using sandbox hours now. Plans - * include hours, so no per-hour dollar figure is quoted as if it were the meter. */ +/** Usage once, honestly: sandbox hours so far (what the plan meters), and whether it is using them + * now. No per-workspace dollars: included hours are not charged. */ function spendLine( workspace: CloudWorkspace, - usage: { costCents: number } | null, + usage: { totalMs: number } | null, awake: boolean, t: Translate ): string | null { - const usd = usage ? usage.costCents / 100 : (workspace.cost?.usd ?? null) - if (usd === null) { + const ms = usage ? usage.totalMs : workspace.sandboxMs + if (ms === null) { return null } - const cost = formatCloudCost(usd) + const { value, label } = cloudSandboxHours(ms) if (!awake) { - return t('cloud.spend.asleep', '{{cost}} so far · no sandbox hours while asleep', { cost }) + return t( + 'cloud.usage.asleep', + '{{hours}} sandbox hours so far · no sandbox hours while asleep', + { + count: value, + hours: label, + defaultValue_one: '{{hours}} sandbox hour so far · no sandbox hours while asleep' + } + ) } - // One sandbox size, so every awake hour counts the same. - return t('cloud.spend.running', '{{cost}} so far · uses sandbox hours while running', { cost }) + return t( + 'cloud.usage.running', + '{{hours}} sandbox hours so far · uses sandbox hours while running', + { + count: value, + hours: label, + defaultValue_one: '{{hours}} sandbox hour so far · uses sandbox hours while running' + } + ) } export function CloudStatusCard(props: { workspace: CloudWorkspace run: CloudWorkspaceRun - usage: { costCents: number } | null + usage: { totalMs: number } | null uptimeMs: number | null /** Shows the "start the agent" step only when a prompt is actually waiting. */ promptsWaiting: boolean diff --git a/mobile/src/cloud/cloud-control-plane-client.ts b/mobile/src/cloud/cloud-control-plane-client.ts index f04d1e612a2..985ee349b69 100644 --- a/mobile/src/cloud/cloud-control-plane-client.ts +++ b/mobile/src/cloud/cloud-control-plane-client.ts @@ -39,7 +39,8 @@ export type CloudWorkspace = { createdAt: number lastActivityAt: number | null /** Compute spend so far, when the registry reports it. */ - cost: { usd: number; usdPerHour: number | null } | null + /** Awake time so far, from the team registry; the plan meters hours, not per-workspace dollars. */ + sandboxMs: number | null createdByUserId: string | null } const SANDBOX_STATUS: Record = { @@ -91,10 +92,7 @@ function fromRegistry(row: TeamWorkspace): CloudWorkspace { machineSize: row.machineSize, createdAt: row.createdAt, lastActivityAt: row.lastActivityAt, - cost: { - usd: row.cost.totalUsdMicros / 1_000_000, - usdPerHour: row.cost.rateUsdMicrosPerHour ? row.cost.rateUsdMicrosPerHour / 1_000_000 : null - }, + sandboxMs: row.cost.computeMs, createdByUserId: row.createdBy } } @@ -109,7 +107,7 @@ function fromSandbox(row: z.infer): CloudWorkspace { machineSize: row.machineSize, createdAt: row.createdAt, lastActivityAt: null, - cost: null, + sandboxMs: null, createdByUserId: null } } diff --git a/mobile/src/cloud/cloud-workspace-display.test.ts b/mobile/src/cloud/cloud-workspace-display.test.ts new file mode 100644 index 00000000000..86276028d77 --- /dev/null +++ b/mobile/src/cloud/cloud-workspace-display.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' +import { cloudSandboxHours } from './cloud-workspace-display' + +const HOUR = 3_600_000 + +describe('cloudSandboxHours', () => { + it('shows one decimal, two under an hour, and returns the plural count it shows', () => { + expect(cloudSandboxHours(3.24 * HOUR)).toEqual({ value: 3.2, label: '3.2' }) + expect(cloudSandboxHours(0.25 * HOUR)).toEqual({ value: 0.25, label: '0.25' }) + expect(cloudSandboxHours(HOUR)).toEqual({ value: 1, label: '1' }) + expect(cloudSandboxHours(0)).toEqual({ value: 0, label: '0' }) + }) +}) diff --git a/mobile/src/cloud/cloud-workspace-display.ts b/mobile/src/cloud/cloud-workspace-display.ts index b603ec92472..98b86e7364f 100644 --- a/mobile/src/cloud/cloud-workspace-display.ts +++ b/mobile/src/cloud/cloud-workspace-display.ts @@ -43,24 +43,25 @@ export function isCloudStatusTransitional(status: CloudWorkspaceStatus): boolean return status === 'creating' || status === 'waking' || status === 'stopping' } -const formatters = new Map() +const hourFormatters = new Map() -function usd(value: number): string { +/** Sandbox hours with one decimal ("3.2"), two under an hour ("0.25"), like the desktop. */ +export function cloudSandboxHours(ms: number): { value: number; label: string } { + const hours = ms / 3_600_000 + const digits = hours < 1 ? 2 : 1 + const value = Math.round(hours * 10 ** digits) / 10 ** digits const locale = getUiIntlLocale() - try { - let format = formatters.get(locale) - if (!format) { - format = new Intl.NumberFormat(locale, { style: 'currency', currency: 'USD' }) - formatters.set(locale, format) + const key = `${locale}:${digits}` + let format = hourFormatters.get(key) + if (!format) { + try { + format = new Intl.NumberFormat(locale, { maximumFractionDigits: digits }) + } catch { + format = new Intl.NumberFormat('en-US', { maximumFractionDigits: digits }) } - return format.format(value) - } catch { - return `$${value.toFixed(2)}` + hourFormatters.set(key, format) } -} - -export function formatCloudCost(value: number): string { - return value > 0 && value < 0.01 ? `<${usd(0.01)}` : usd(value) + return { value, label: format.format(value) } } /** "owner/repo · branch" from a GitHub URL, or null for an empty project. */ diff --git a/mobile/src/i18n/en-runtime-required.json b/mobile/src/i18n/en-runtime-required.json index ff6c952994d..8153545760b 100644 --- a/mobile/src/i18n/en-runtime-required.json +++ b/mobile/src/i18n/en-runtime-required.json @@ -140,6 +140,14 @@ "seconds_other": "{{count}}s" } }, + "cloud": { + "usage": { + "asleep_one": "{{hours}} sandbox hour so far · no sandbox hours while asleep", + "asleep_other": "{{hours}} sandbox hours so far · no sandbox hours while asleep", + "running_one": "{{hours}} sandbox hour so far · uses sandbox hours while running", + "running_other": "{{hours}} sandbox hours so far · uses sandbox hours while running" + } + }, "components": { "codexResetCredit": { "available_one": "{{count}} reset available", diff --git a/mobile/src/i18n/locales/en.json b/mobile/src/i18n/locales/en.json index 6527044f7d5..895610b95f9 100644 --- a/mobile/src/i18n/locales/en.json +++ b/mobile/src/i18n/locales/en.json @@ -4999,10 +4999,6 @@ "errorAgent": "That agent isn’t installed in this workspace", "errorLaunch": "The agent didn’t start" }, - "spend": { - "asleep": "{{cost}} so far · no sandbox hours while asleep", - "running": "{{cost}} so far · uses sandbox hours while running" - }, "status": { "waking": "Waking", "cantConnect": "Can’t connect", @@ -5151,6 +5147,12 @@ "wake": { "slowQueued": "Taking longer than usual. Your files are safe. Your prompt sends as soon as it’s awake.", "slow": "Taking longer than usual. Your files are safe." + }, + "usage": { + "asleep_one": "{{hours}} sandbox hour so far · no sandbox hours while asleep", + "asleep_other": "{{hours}} sandbox hours so far · no sandbox hours while asleep", + "running_one": "{{hours}} sandbox hour so far · uses sandbox hours while running", + "running_other": "{{hours}} sandbox hours so far · uses sandbox hours while running" } } } diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx index d0a2ba297a9..a3ceb12b6e1 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx @@ -15,7 +15,6 @@ import { CloudWorkspaceRowMenu, type RowActions } from './CloudWorkspaceRowMenu' import { formatSandboxHours, formatRelative, - formatUsdMicros, memberName, presenceSummary, presentMembers, @@ -112,7 +111,13 @@ export function CloudWorkspaceRow({ } }, [highlighted]) const canOpen = w.access !== 'none' - const cost = formatUsdMicros(w.cost.totalUsdMicros, intlLocale) + // Hours are what the plan meters; a per-workspace dollar figure would overstate the bill. + const hours = formatSandboxHours(w.cost.computeMs, intlLocale) + const usage = t('auto.components.cloudWorkspaces.rowSandboxHours', '{{hours}} sandbox hours', { + count: sandboxHours(w.cost.computeMs), + hours, + defaultValue_one: '{{hours}} sandbox hour' + }) const lastActive = formatRelative(w.lastActivityAt, now, t, intlLocale) const presence = presenceSummary( presentMembers(w.presence, selfId), @@ -128,15 +133,15 @@ export function CloudWorkspaceRow({ : t('auto.components.cloudWorkspaces.sharedWithTeam', 'Shared with team') const description = presence ? t( - 'auto.components.cloudWorkspaces.rowDescriptionWithPresence', - 'Cost {{cost}}. Last active {{lastActive}}. {{visibility}}. {{presence}}.', - { cost, lastActive, visibility, presence } + 'auto.components.cloudWorkspaces.rowDescriptionWithPresence2', + '{{usage}}. Last active {{lastActive}}. {{visibility}}. {{presence}}.', + { usage, lastActive, visibility, presence } ) : t( - 'auto.components.cloudWorkspaces.rowDescription', - 'Cost {{cost}}. Last active {{lastActive}}. {{visibility}}.', + 'auto.components.cloudWorkspaces.rowDescription2', + '{{usage}}. Last active {{lastActive}}. {{visibility}}.', { - cost, + usage, lastActive, visibility } @@ -290,30 +295,20 @@ export function CloudWorkspaceRow({ /> - {cost} + + {hours} + -
{t('auto.components.cloudWorkspaces.cost', 'Cost')}
+
+ {t('auto.components.cloudWorkspaces.sandboxHoursTitle', 'Sandbox hours')} +
{t( - 'auto.components.cloudWorkspaces.sandboxHoursCost', - '{{hours}} sandbox hours × {{rate}}/hour = {{cost}}', - { - count: sandboxHours(w.cost.computeMs), - hours: formatSandboxHours(w.cost.computeMs, intlLocale), - rate: formatUsdMicros(w.cost.rateUsdMicrosPerHour, intlLocale), - cost: formatUsdMicros(w.cost.computeUsdMicros, intlLocale), - defaultValue_one: '{{hours}} sandbox hour × {{rate}}/hour = {{cost}}' - } + 'auto.components.cloudWorkspaces.sandboxHoursHint', + 'Sandbox hours this workspace has used.' )}
- {w.cost.tokenUsdMicros !== null && ( -
- {t('auto.components.cloudWorkspaces.modelTokensCost', 'Model tokens {{value0}}', { - value0: formatUsdMicros(w.cost.tokenUsdMicros, intlLocale) - })} -
- )}
{/* Last activity, with Open fading in over the same slot on hover or keyboard focus. */} diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx index ba5dab24ac0..7fda018ed6a 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx @@ -17,7 +17,7 @@ import { NEW_SECTION } from './CloudWorkspaceRowMenu' import { ANY, CloudWorkspacesToolbar, type CloudWorkspacesFilters } from './CloudWorkspacesToolbar' import { EmptyState, ErrorState, NewSectionDialog, SkeletonRows } from './CloudWorkspacesStates' import { CloudWorkspaceConfirmDialog, type PendingConfirm } from './CloudWorkspaceConfirmDialog' -import { formatUsdMicros, type MemberDirectory } from './cloud-workspace-format' +import { formatSandboxHours, sandboxHours, type MemberDirectory } from './cloud-workspace-format' import { refreshCloudMessageSenders } from '@/lib/cloud-message-sender' import { describeError } from './cloud-workspace-errors' import { focusCloudChat } from './cloud-chat-focus' @@ -162,7 +162,7 @@ export function CloudWorkspacesHome({ })), [directory, selfId, t] ) - const totalCost = visible.reduce((sum, w) => sum + w.cost.totalUsdMicros, 0) + const totalMs = visible.reduce((sum, w) => sum + w.cost.computeMs, 0) /** Opens the workspace, then (going to a teammate's chat) the chat they have in front. */ const open = useCallback(async (w: CloudWorkspace, chatId?: string | null) => { @@ -261,10 +261,18 @@ export function CloudWorkspacesHome({ metaStale={stale} meta={ state.status === 'ready' - ? t('auto.components.cloudWorkspaces.listMeta', '{{count}} workspaces · {{cost}}', { + ? t('auto.components.cloudWorkspaces.listMeta2', '{{count}} workspaces · {{usage}}', { count: visible.length, - cost: formatUsdMicros(totalCost, intlLocale), - defaultValue_one: '{{count}} workspace · {{cost}}' + usage: t( + 'auto.components.cloudWorkspaces.listSandboxHours', + '{{hours}} sandbox hours used', + { + count: sandboxHours(totalMs), + hours: formatSandboxHours(totalMs, intlLocale), + defaultValue_one: '{{hours}} sandbox hour used' + } + ), + defaultValue_one: '{{count}} workspace · {{usage}}' }) : null } diff --git a/src/renderer/src/components/cloud-workspaces/cloud-workspace-format.ts b/src/renderer/src/components/cloud-workspaces/cloud-workspace-format.ts index fa2497f9d2b..70bcebb9b16 100644 --- a/src/renderer/src/components/cloud-workspaces/cloud-workspace-format.ts +++ b/src/renderer/src/components/cloud-workspaces/cloud-workspace-format.ts @@ -8,18 +8,6 @@ import type { CloudWorkspacePresence } from '../../../../shared/cloud-workspaces const DATE_FORMAT: Intl.DateTimeFormatOptions = {} const HOURS: Intl.NumberFormatOptions = { maximumFractionDigits: 1 } const HOURS_FINE: Intl.NumberFormatOptions = { maximumFractionDigits: 2 } -const USD_CENTS: Intl.NumberFormatOptions = { - style: 'currency', - currency: 'USD', - minimumFractionDigits: 2, - maximumFractionDigits: 2 -} -const USD_WHOLE: Intl.NumberFormatOptions = { - style: 'currency', - currency: 'USD', - minimumFractionDigits: 0, - maximumFractionDigits: 0 -} export type MemberDirectory = Map @@ -50,20 +38,6 @@ export function initials(name: string): string { return letters.toUpperCase() } -/** Cost under a cent reads as "<$0.01", otherwise two decimals (never "$0.00" for a running VM). */ -export function formatUsdMicros(micros: number, intlLocale?: string): string { - if (micros <= 0) { - return uiNumberFormat(USD_WHOLE, intlLocale).format(0) - } - if (micros < 10_000) { - return `<${uiNumberFormat(USD_CENTS, intlLocale).format(0.01)}` - } - const dollars = micros / 1_000_000 - return dollars >= 100 - ? uiNumberFormat(USD_WHOLE, intlLocale).format(Math.round(dollars)) - : uiNumberFormat(USD_CENTS, intlLocale).format(dollars) -} - /** Sandbox hours as shown (one decimal, two under an hour), also the plural count for the copy. */ export function sandboxHours(ms: number): number { const hours = ms / 3_600_000 diff --git a/src/renderer/src/components/cloud-workspaces/cloud-workspaces.test-fixture.ts b/src/renderer/src/components/cloud-workspaces/cloud-workspaces.test-fixture.ts index 0a3d9dbed3f..d8e39892b67 100644 --- a/src/renderer/src/components/cloud-workspaces/cloud-workspaces.test-fixture.ts +++ b/src/renderer/src/components/cloud-workspaces/cloud-workspaces.test-fixture.ts @@ -75,7 +75,7 @@ export function workspace(overrides: Partial): CloudWorkspace { lastActivityBy: SELF_ID, cost: { computeMs: 2.6 * 3_600_000, - rateUsdMicrosPerHour: 750_000, + rateUsdMicrosPerHour: 1_000_000, computeUsdMicros: 1_950_000, tokenUsdMicros: 410_000, totalUsdMicros: 2_360_000 @@ -120,7 +120,7 @@ export function teamWorkspaces(): CloudWorkspace[] { status: 'creating', cost: { computeMs: 6 * 60_000, - rateUsdMicrosPerHour: 750_000, + rateUsdMicrosPerHour: 1_000_000, computeUsdMicros: 75_000, tokenUsdMicros: null, totalUsdMicros: 75_000 diff --git a/src/renderer/src/components/orca-cloud/CloudMoveToComputer.fixture.tsx b/src/renderer/src/components/orca-cloud/CloudMoveToComputer.fixture.tsx index 76cd2164c29..d7bf0d219fd 100644 --- a/src/renderer/src/components/orca-cloud/CloudMoveToComputer.fixture.tsx +++ b/src/renderer/src/components/orca-cloud/CloudMoveToComputer.fixture.tsx @@ -231,7 +231,7 @@ export const panelMovedToComputer = defineFixture({ orcadAlive: true }, uptimeMs: 3_600_000, - usage: { totalMs: 2.4 * 3_600_000, centsPerHour: 75, costCents: 180 }, + usage: { totalMs: 2.4 * 3_600_000, centsPerHour: 100, costCents: 240 }, archive: null, checkedAt: NOW }, diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspace.fixture.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspace.fixture.tsx index cbeef9ddcf8..89957143045 100644 --- a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspace.fixture.tsx +++ b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspace.fixture.tsx @@ -40,7 +40,7 @@ const running: HostedWorkspaceStatus = { orcadAlive: true }, uptimeMs: 2 * 3_600_000 + 3 * 60_000, - usage: { totalMs: 14.6 * 3_600_000, centsPerHour: 75, costCents: 1095 }, + usage: { totalMs: 14.6 * 3_600_000, centsPerHour: 100, costCents: 1460 }, archive: null, checkedAt: NOW } diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index b08d0a8a935..fb5e777f89e 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -236,10 +236,12 @@ } }, "cloudWorkspaces": { - "listMeta_one": "{{count}} workspace · {{cost}}", - "listMeta_other": "{{count}} workspaces · {{cost}}", - "sandboxHoursCost_one": "{{hours}} sandbox hour × {{rate}}/hour = {{cost}}", - "sandboxHoursCost_other": "{{hours}} sandbox hours × {{rate}}/hour = {{cost}}", + "listMeta2_one": "{{count}} workspace · {{usage}}", + "listMeta2_other": "{{count}} workspaces · {{usage}}", + "listSandboxHours_one": "{{hours}} sandbox hour used", + "listSandboxHours_other": "{{hours}} sandbox hours used", + "rowSandboxHours_one": "{{hours}} sandbox hour", + "rowSandboxHours_other": "{{hours}} sandbox hours", "sectionCount_one": "{{count}} workspace", "sectionCount_other": "{{count}} workspaces" }, @@ -1836,6 +1838,12 @@ "resolver": "Answered on {{device}}", "unavailable": "Selected answer unavailable" }, + "rewind": { + "restoreChangedFiles_one": "Also restore {{count}} changed file", + "restoreChangedFiles_other": "Also restore {{count}} changed files", + "restoredFiles_one": "Restored {{count}} file", + "restoredFiles_other": "Restored {{count}} files" + }, "sessionOptionErrors": { "afterStartOnly": "This option is only available after the session starts.", "agentPickerOnly": "This option must be changed in the agent picker.", @@ -2040,12 +2048,6 @@ "waitForStart": "Wait for the agent to finish starting.", "waitForTurn": "Wait for the agent to finish responding, or stop it.", "waitMoment": "Wait a moment." - }, - "rewind": { - "restoreChangedFiles_one": "Also restore {{count}} changed file", - "restoreChangedFiles_other": "Also restore {{count}} changed files", - "restoredFiles_one": "Restored {{count}} file", - "restoredFiles_other": "Restored {{count}} files" } }, "onboarding": { diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 5c0a9b81e62..63c87011e57 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -20746,7 +20746,6 @@ "copyFailed": "Couldn't copy the link. Try again.", "copyLink": "Copy link", "copyWorkspaceLink": "Copy workspace link", - "cost": "Cost", "daysAgo": "{{value0}}d ago", "emptyArchivedBody": "Archived cloud workspaces show up here.", "emptyArchivedTitle": "No archived workspaces", @@ -20786,8 +20785,10 @@ "inRepo": "In {{value0}}", "justNow": "just now", "linkNotFound": "This link points to a private workspace, another team, or a workspace that was deleted.", - "listMeta_one": "{{count}} workspace · {{cost}}", - "listMeta_other": "{{count}} workspaces · {{cost}}", + "listMeta2_one": "{{count}} workspace · {{usage}}", + "listMeta2_other": "{{count}} workspaces · {{usage}}", + "listSandboxHours_one": "{{hours}} sandbox hour used", + "listSandboxHours_other": "{{hours}} sandbox hours used", "loading": "Loading cloud workspaces", "makeOwner": "Make owner", "makePrivate": "Make private", @@ -20798,7 +20799,6 @@ "memberViewing": "{{value0}} is viewing", "memberYou": "{{value0}} (you)", "minutesAgo": "{{value0}}m ago", - "modelTokensCost": "Model tokens {{value0}}", "moreMembers": "{{count}} more", "move": "Move", "moveToSection": "Move to section", @@ -20823,12 +20823,14 @@ "restored": "Restored", "retry": "Retry", "rowActions": "Actions for {{value0}}", - "rowDescription": "Cost {{cost}}. Last active {{lastActive}}. {{visibility}}.", - "rowDescriptionWithPresence": "Cost {{cost}}. Last active {{lastActive}}. {{visibility}}. {{presence}}.", + "rowDescription2": "{{usage}}. Last active {{lastActive}}. {{visibility}}.", + "rowSandboxHours_one": "{{hours}} sandbox hour", + "rowSandboxHours_other": "{{hours}} sandbox hours", + "rowDescriptionWithPresence2": "{{usage}}. Last active {{lastActive}}. {{visibility}}. {{presence}}.", "rowLabel": "{{value0}}, {{value1}}, owned by {{value2}}", "rowLabelOwnedByYou": "{{title}}, {{status}}, owned by you", - "sandboxHoursCost_one": "{{hours}} sandbox hour × {{rate}}/hour = {{cost}}", - "sandboxHoursCost_other": "{{hours}} sandbox hours × {{rate}}/hour = {{cost}}", + "sandboxHoursHint": "Sandbox hours this workspace has used.", + "sandboxHoursTitle": "Sandbox hours", "scopeMine": "Mine", "scopeTeam": "Team", "sectionCount_one": "{{count}} workspace", diff --git a/src/shared/hosted-sandbox/hosted-sandbox-wire.ts b/src/shared/hosted-sandbox/hosted-sandbox-wire.ts index e5187933c26..bd124b0c2a9 100644 --- a/src/shared/hosted-sandbox/hosted-sandbox-wire.ts +++ b/src/shared/hosted-sandbox/hosted-sandbox-wire.ts @@ -9,6 +9,13 @@ import { z } from 'zod' */ export const ORCA_CLOUD_IDLE_SLEEP_MINUTES = 15 +/** + * Overage price per sandbox hour, in cents. The one source: billing's plan (overageCentsPerHour, and + * the Stripe overage price must match it) and the control plane's per-workspace cost both read it. + * Every size counts 1x, so this is also the price of any awake hour. + */ +export const ORCA_CLOUD_OVERAGE_CENTS_PER_HOUR = 100 + /** Median and slow-tail durations of a recent operation, as the control plane measured them. */ export const HostedSandboxTimingSchema = z.object({ p50Ms: z.number().nonnegative(),