mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
copy(cloud): state the running-sandbox cap where it's enforced (limit cards, workspace start error) and in the plans fine print
This commit is contained in:
@@ -306,8 +306,11 @@ export function PlansView(props: PlansViewProps): React.JSX.Element {
|
||||
<div className="space-y-1 text-center text-xs text-muted-foreground text-pretty">
|
||||
<p>
|
||||
{t(
|
||||
'auto.components.billing.plans.footHours3',
|
||||
'Hours reset every month, including on annual plans.'
|
||||
'auto.components.billing.plans.footHours4',
|
||||
'Hours reset every month, including on annual plans. Each seat can run {{value0}} sandboxes at once.',
|
||||
// The cap is enforced by the control plane; the fine print states it before anyone
|
||||
// reaches the limit card, while the Team card keeps to the marketing bullets.
|
||||
{ value0: String(offers.team.concurrentSandboxesPerSeat) }
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copy for control-plane error codes from the team workspace registry.
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import { getLastBillingStatus } from '@/components/billing/billing-summary-store'
|
||||
import { sandboxLimitFromBilling } from '@/components/worktree-creation/vm-build-failure-copy'
|
||||
|
||||
export function describeError(error: string, reason?: string, t: Translate = translate): string {
|
||||
if (error === 'not_found') {
|
||||
@@ -10,10 +12,23 @@ export function describeError(error: string, reason?: string, t: Translate = tra
|
||||
)
|
||||
}
|
||||
if (error === 'entitlement_denied') {
|
||||
return reason === 'concurrency_limit'
|
||||
if (reason === 'concurrency_limit') {
|
||||
const limit = sandboxLimitFromBilling(getLastBillingStatus())
|
||||
return limit
|
||||
? t(
|
||||
'auto.components.cloudWorkspaces.errorConcurrencyLimitCount',
|
||||
"You're at your team's limit: your team can run {{value0}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again.",
|
||||
{ value0: String(limit.team), value1: String(limit.perSeat) }
|
||||
)
|
||||
: t(
|
||||
'auto.components.cloudWorkspaces.errorConcurrencyLimit',
|
||||
"You're at your team's limit of running sandboxes. Put one to sleep or delete it, then try again."
|
||||
)
|
||||
}
|
||||
return reason === 'member_concurrency_limit'
|
||||
? t(
|
||||
'auto.components.cloudWorkspaces.errorConcurrencyLimit',
|
||||
"You're at your team's limit of running sandboxes. Put one to sleep or delete it, then try again."
|
||||
'auto.components.cloudWorkspaces.errorMemberConcurrencyLimit',
|
||||
"You're at your limit of running sandboxes. Put one to sleep or delete it, then try again."
|
||||
)
|
||||
: t(
|
||||
'auto.components.cloudWorkspaces.errorEntitlementDenied',
|
||||
|
||||
@@ -3,7 +3,8 @@ import { cn } from '@/lib/utils'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { VmBuildReveal } from './VmBuildReveal'
|
||||
import { isAccountGate, type VmBuildFailure } from './vm-build-failure'
|
||||
import { vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { getLastBillingStatus } from '@/components/billing/billing-summary-store'
|
||||
import { sandboxLimitFromBilling, vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { FailureActionRow, type VmBuildFailureActions } from './VmBuildFailureActions'
|
||||
import { CheckRow } from './VmBuildCheckRow'
|
||||
|
||||
@@ -54,7 +55,16 @@ export function VmBuildFailureCard({
|
||||
}
|
||||
const visible = failure ?? shown
|
||||
const copy = visible
|
||||
? vmBuildFailureCopy(visible, { cloud, canManageBilling, repoName }, t)
|
||||
? vmBuildFailureCopy(
|
||||
visible,
|
||||
{
|
||||
cloud,
|
||||
canManageBilling,
|
||||
repoName,
|
||||
sandboxLimit: sandboxLimitFromBilling(getLastBillingStatus())
|
||||
},
|
||||
t
|
||||
)
|
||||
: null
|
||||
const headingRef = React.useRef<HTMLHeadingElement>(null)
|
||||
const cardRef = React.useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -1,18 +1,38 @@
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import type { OrcaBillingStatusResult } from '../../../../shared/orca-billing'
|
||||
import type { VmBuildFailure } from './vm-build-failure'
|
||||
|
||||
/** The running-sandbox caps billing enforces: per member, and per team (per seat × seats). */
|
||||
export type SandboxLimit = { perSeat: number; team: number }
|
||||
|
||||
/** Mirrors billing's checkStart limits; null until the plan has loaded. */
|
||||
export function sandboxLimitFromBilling(
|
||||
status: OrcaBillingStatusResult | null
|
||||
): SandboxLimit | null {
|
||||
if (status?.status !== 'ok') {
|
||||
return null
|
||||
}
|
||||
const perSeat = status.entitlement.offers?.team.concurrentSandboxesPerSeat
|
||||
if (!perSeat) {
|
||||
return null
|
||||
}
|
||||
return { perSeat, team: perSeat * Math.max(1, status.entitlement.seats) }
|
||||
}
|
||||
|
||||
export type VmBuildFailureCopyContext = {
|
||||
cloud: boolean
|
||||
/** How the user knows the repository: its GitHub owner/name, else its name in Orca. */
|
||||
repoName: string
|
||||
/** False for team members who can't change billing; they are told to ask an owner or admin. */
|
||||
canManageBilling: boolean
|
||||
/** States the cap on the limit cards; omitted or null falls back to copy without numbers. */
|
||||
sandboxLimit?: SandboxLimit | null
|
||||
}
|
||||
|
||||
/** The card's cause-specific title and one plain-language sentence on what to do next. */
|
||||
export function vmBuildFailureCopy(
|
||||
failure: VmBuildFailure,
|
||||
{ cloud, canManageBilling, repoName }: VmBuildFailureCopyContext,
|
||||
{ cloud, canManageBilling, repoName, sandboxLimit }: VmBuildFailureCopyContext,
|
||||
t: Translate
|
||||
): { title: string; body: string | null } {
|
||||
switch (failure.kind) {
|
||||
@@ -104,10 +124,16 @@ export function vmBuildFailureCopy(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.teamLimitTitle',
|
||||
'You’re at your team’s limit of running sandboxes'
|
||||
),
|
||||
body: t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.limitBody',
|
||||
'Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.'
|
||||
)
|
||||
body: sandboxLimit
|
||||
? t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.teamLimitBody',
|
||||
'Your team can run {{value0}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.',
|
||||
{ value0: String(sandboxLimit.team), value1: String(sandboxLimit.perSeat) }
|
||||
)
|
||||
: t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.limitBody',
|
||||
'Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.'
|
||||
)
|
||||
}
|
||||
case 'memberConcurrency':
|
||||
return {
|
||||
@@ -115,10 +141,16 @@ export function vmBuildFailureCopy(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.memberLimitTitle',
|
||||
'You’re at your limit of running sandboxes'
|
||||
),
|
||||
body: t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.limitBody',
|
||||
'Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.'
|
||||
)
|
||||
body: sandboxLimit
|
||||
? t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.memberLimitBody',
|
||||
'Each person can run {{value0}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.',
|
||||
{ value0: String(sandboxLimit.perSeat) }
|
||||
)
|
||||
: t(
|
||||
'auto.components.worktree.creation.VmBuildFailureCard.limitBody',
|
||||
'Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.'
|
||||
)
|
||||
}
|
||||
case 'githubNotConnected':
|
||||
return {
|
||||
|
||||
@@ -4,7 +4,8 @@ import type { Translate } from '@/i18n/use-translate'
|
||||
import { openPlansPage } from '@/components/billing/plans/plans-page-store'
|
||||
import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation'
|
||||
import { classifyVmBuildFailure, type VmBuildFailure } from './vm-build-failure'
|
||||
import { vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { getLastBillingStatus } from '@/components/billing/billing-summary-store'
|
||||
import { sandboxLimitFromBilling, vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { isOrcaCloudBuild } from './vm-build-steps'
|
||||
import { orcaCloudRepoName } from './vm-build-repo-actions'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
@@ -26,7 +27,11 @@ export function vmBuildFailureSummary(
|
||||
recipe ? repos.find((repo) => repo.id === recipe.sourceRepoId) : undefined
|
||||
)
|
||||
// Unknown here; the card itself refines the copy for members once billing status loads.
|
||||
return { failure, ...vmBuildFailureCopy(failure, { cloud, canManageBilling: true, repoName }, t) }
|
||||
const sandboxLimit = sandboxLimitFromBilling(getLastBillingStatus())
|
||||
return {
|
||||
failure,
|
||||
...vmBuildFailureCopy(failure, { cloud, canManageBilling: true, repoName, sandboxLimit }, t)
|
||||
}
|
||||
}
|
||||
|
||||
/** The build sheet's card as a toast, for a VM build that failed while its sheet was off screen. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { classifyVmBuildFailure, isAccountGate, type VmBuildFailure } from './vm-build-failure'
|
||||
import { vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { sandboxLimitFromBilling, vmBuildFailureCopy } from './vm-build-failure-copy'
|
||||
import { orcaCloudRepoName } from './vm-build-repo-actions'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
|
||||
@@ -104,6 +104,38 @@ describe('vmBuildFailureCopy', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('states the running-sandbox cap on the limit cards once the plan is known', () => {
|
||||
const copy = (kind: VmBuildFailure, sandboxLimit: { perSeat: number; team: number } | null) =>
|
||||
vmBuildFailureCopy(
|
||||
kind,
|
||||
{ cloud: true, canManageBilling: true, repoName: 'acme/web', sandboxLimit },
|
||||
t
|
||||
).body
|
||||
expect(copy({ kind: 'concurrency' }, { perSeat: 3, team: 12 })).toContain(
|
||||
'Your team can run 12 sandboxes at once (3 per seat). Put one to sleep or delete it'
|
||||
)
|
||||
expect(copy({ kind: 'memberConcurrency' }, { perSeat: 3, team: 12 })).toContain(
|
||||
'Each person can run 3 sandboxes at once. Put one to sleep or delete it'
|
||||
)
|
||||
expect(copy({ kind: 'concurrency' }, null)).toMatch(/^Put one to sleep or delete it/)
|
||||
})
|
||||
|
||||
it('derives the caps the way billing enforces them', () => {
|
||||
const status = (seats: number, perSeat: number | null) =>
|
||||
({
|
||||
status: 'ok',
|
||||
entitlement: {
|
||||
seats,
|
||||
offers: perSeat === null ? null : { team: { concurrentSandboxesPerSeat: perSeat } }
|
||||
}
|
||||
}) as unknown as Parameters<typeof sandboxLimitFromBilling>[0]
|
||||
expect(sandboxLimitFromBilling(status(4, 3))).toEqual({ perSeat: 3, team: 12 })
|
||||
// Billing counts at least one seat.
|
||||
expect(sandboxLimitFromBilling(status(0, 3))).toEqual({ perSeat: 3, team: 3 })
|
||||
expect(sandboxLimitFromBilling(status(4, null))).toBeNull()
|
||||
expect(sandboxLimitFromBilling(null)).toBeNull()
|
||||
})
|
||||
|
||||
it('names the repository GitHub needs to reach', () => {
|
||||
const { title } = vmBuildFailureCopy(
|
||||
{ kind: 'githubNotConnected' },
|
||||
|
||||
@@ -4108,6 +4108,8 @@
|
||||
"paymentFailedBodyMember": "New sandboxes can’t start until the payment goes through. Ask an owner or admin to update the payment method. Nothing was created, and you weren’t charged.",
|
||||
"teamLimitTitle": "You’re at your team’s limit of running sandboxes",
|
||||
"limitBody": "Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.",
|
||||
"teamLimitBody": "Your team can run {{value0}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.",
|
||||
"memberLimitBody": "Each person can run {{value0}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.",
|
||||
"memberLimitTitle": "You’re at your limit of running sandboxes",
|
||||
"githubNotConnectedTitle": "GitHub isn’t connected for {{repo}}",
|
||||
"githubNotConnectedBody": "Orca Cloud clones your code from GitHub and needs access to this repository first. Connect GitHub, then try again. Nothing was created, and you weren’t charged.",
|
||||
@@ -20540,7 +20542,7 @@
|
||||
"vpSecretsTitle3": "API keys stay out of the sandbox",
|
||||
"billedYearlyAmount2": "{{value0}} per seat, billed yearly",
|
||||
"entPriced2": "Priced for your team",
|
||||
"footHours3": "Hours reset every month, including on annual plans.",
|
||||
"footHours4": "Hours reset every month, including on annual plans. Each seat can run {{value0}} sandboxes at once.",
|
||||
"perSeatPerMonth": "per seat per month",
|
||||
"seatsPerMember_one": "{{count}} seat, one per team member",
|
||||
"seatsPerMember_other": "{{count}} seats, one per team member",
|
||||
@@ -20676,6 +20678,8 @@
|
||||
"emptyTeamTitle": "No team workspaces yet",
|
||||
"environmentName": "{{value0}} (cloud)",
|
||||
"errorConcurrencyLimit": "You're at your team's limit of running sandboxes. Put one to sleep or delete it, then try again.",
|
||||
"errorConcurrencyLimitCount": "You're at your team's limit: your team can run {{value0}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again.",
|
||||
"errorMemberConcurrencyLimit": "You're at your limit of running sandboxes. Put one to sleep or delete it, then try again.",
|
||||
"errorConflict": "This workspace is still starting or going to sleep. Nothing was changed. Try again in a moment.",
|
||||
"errorConflictInline": "This workspace is still starting or going to sleep. Nothing was changed.",
|
||||
"errorEntitlementDenied": "Your team's plan can't start this workspace right now. Your files are safe. Ask an owner or admin to check the plan.",
|
||||
|
||||
Reference in New Issue
Block a user