diff --git a/src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts b/src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts index df01c7576c8..0937b9d822f 100644 --- a/src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts +++ b/src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts @@ -5,6 +5,7 @@ import type { OrcaBillingStatusResult } from '../../../../shared/orca-billing' import type { VmBuildFailure } from './vm-build-failure' +import { sandboxLimitBody } from './vm-build-limit-copy' /** The running-sandbox caps billing enforces: per member, and per team (per seat × seats). */ export type SandboxLimit = { perSeat: number; team: number } @@ -167,16 +168,7 @@ export function vmBuildFailureCopy( 'auto.components.worktree.creation.VmBuildFailureCard.teamLimitTitle', 'You’re at your team’s limit of running sandboxes' ), - 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.' - ) + body: sandboxLimitBody(t, 'team', sandboxLimit) } case 'memberConcurrency': return { @@ -184,16 +176,7 @@ export function vmBuildFailureCopy( 'auto.components.worktree.creation.VmBuildFailureCard.memberLimitTitle', 'You’re at your limit of running sandboxes' ), - body: sandboxLimit - ? t( - 'auto.components.worktree.creation.VmBuildFailureCard.memberLimitBody2', - 'You 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.' - ) + body: sandboxLimitBody(t, 'member', sandboxLimit) } case 'githubNotConnected': return { diff --git a/src/renderer/src/components/worktree-creation/vm-build-limit-copy.ts b/src/renderer/src/components/worktree-creation/vm-build-limit-copy.ts new file mode 100644 index 00000000000..904e7617ace --- /dev/null +++ b/src/renderer/src/components/worktree-creation/vm-build-limit-copy.ts @@ -0,0 +1,37 @@ +import type { Translate } from '@/i18n/use-translate' +import type { SandboxLimit } from './vm-build-failure-copy' + +/** Body of the running-sandbox limit cards, pluralized ("1 sandbox … Put it to sleep"). */ +export function sandboxLimitBody( + t: Translate, + scope: 'team' | 'member', + limit: SandboxLimit | null | undefined +): string { + if (!limit) { + return 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.' + ) + } + if (scope === 'team') { + return t( + 'auto.components.worktree.creation.VmBuildFailureCard.teamLimitBodyCount', + 'Your team can run {{count}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.', + { + count: limit.team, + value1: String(limit.perSeat), + defaultValue_one: + 'Your team can run {{count}} sandbox at once ({{value1}} per seat). Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.' + } + ) + } + return t( + 'auto.components.worktree.creation.VmBuildFailureCard.memberLimitBodyCount', + 'You can run {{count}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.', + { + count: limit.perSeat, + defaultValue_one: + 'You can run {{count}} sandbox at once. Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.' + } + ) +} diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index 7ee315777b4..741ee403c48 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1345,7 +1345,11 @@ "checksCountTitleCloud_one": "The sandbox is up, but {{count}} environment check failed", "checksCountTitleCloud_other": "The sandbox is up, but {{count}} environment checks failed", "checksCountTitleVm_one": "The VM is up, but {{count}} environment check failed", - "checksCountTitleVm_other": "The VM is up, but {{count}} environment checks failed" + "checksCountTitleVm_other": "The VM is up, but {{count}} environment checks failed", + "memberLimitBodyCount_one": "You can run {{count}} sandbox at once. Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "memberLimitBodyCount_other": "You can run {{count}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "teamLimitBodyCount_one": "Your team can run {{count}} sandbox at once ({{value1}} per seat). Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "teamLimitBodyCount_other": "Your team can run {{count}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged." }, "VmBuildLog": { "hiddenTechnicalLines_one": "{{count}} technical line hidden. Copy log includes it.", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index c19daf0e44c..65ea0918edd 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -4255,8 +4255,6 @@ "paymentFailedBody": "New sandboxes can’t start until the payment goes through. 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.", - "memberLimitBody2": "You 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.", @@ -4282,7 +4280,11 @@ "checksBodyCloud2_one": "Open it anyway and fix it inside the workspace, or run the checks again after changing your project.", "checksBodyCloud2_other": "Open it anyway and fix them inside the workspace, or run the checks again after changing your project.", "provisionBodyCloudKept": "Something went wrong while starting the sandbox. Try again, or delete the sandbox to stop using sandbox hours.", - "provisionBodyCloud2": "Something went wrong while starting the sandbox. Nothing was created, and you weren’t charged." + "provisionBodyCloud2": "Something went wrong while starting the sandbox. Nothing was created, and you weren’t charged.", + "teamLimitBodyCount_one": "Your team can run {{count}} sandbox at once ({{value1}} per seat). Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "teamLimitBodyCount_other": "Your team can run {{count}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "memberLimitBodyCount_one": "You can run {{count}} sandbox at once. Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "memberLimitBodyCount_other": "You can run {{count}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged." }, "VmBuildLog": { "jumpToError": "Jump to first error",