From 4efaa768e04dc318e1edd57cc32f30c2046fce3b Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 10 Nov 2026 07:11:14 -0800 Subject: [PATCH] feat(cloud): DS-14 build failure card on InlineError with tinted check pills (#272) --- src/renderer/src/components/ui/badge.tsx | 5 + src/renderer/src/components/ui/button.tsx | 5 +- .../src/components/ui/inline-error.tsx | 48 +++++--- .../worktree-creation/VmBuildCheckRow.tsx | 25 ++--- .../VmBuildFailureActions.tsx | 28 +++-- .../VmBuildFailureCard.test.tsx | 88 +++++++++++++++ .../worktree-creation/VmBuildFailureCard.tsx | 104 +++++++++--------- .../VmBuildSheet.fixture.tsx | 20 ++++ .../worktree-creation/VmBuildSheet.tsx | 6 +- .../vm-build-failure-copy.ts | 68 +++++++++--- .../vm-build-failure-toast.ts | 13 ++- .../src/i18n/en-runtime-required.json | 8 ++ src/renderer/src/i18n/locales/en.json | 16 ++- 13 files changed, 312 insertions(+), 122 deletions(-) diff --git a/src/renderer/src/components/ui/badge.tsx b/src/renderer/src/components/ui/badge.tsx index 250d239895c..b4bf239f967 100644 --- a/src/renderer/src/components/ui/badge.tsx +++ b/src/renderer/src/components/ui/badge.tsx @@ -27,6 +27,11 @@ const badgeVariants = cva( /** Small uppercase success chip marking the live item in a list (e.g. the active build). */ statusActive: 'h-4 border-status-success-border bg-status-success-background px-1.5 text-[10px] font-semibold tracking-wide text-status-success uppercase', + /** Tinted status pills for a check's result inside an error card. */ + statusFailed: + 'border-destructive/20 bg-destructive/10 px-1.5 py-0 text-2xs text-destructive-text dark:border-destructive/30', + statusWarning: + 'border-status-warning-border bg-status-warning-background px-1.5 py-0 text-2xs text-status-warning-text', referenceLabel: 'h-3.5 border-border px-1 py-0 text-3xs font-normal text-muted-foreground', /** An uppercase kind label set before a banner title; takes its color from the parent. */ paneLabel: diff --git a/src/renderer/src/components/ui/button.tsx b/src/renderer/src/components/ui/button.tsx index d262046f6d1..06fcfaa9d55 100644 --- a/src/renderer/src/components/ui/button.tsx +++ b/src/renderer/src/components/ui/button.tsx @@ -43,7 +43,10 @@ const buttonVariants = cva( 'pane-title-close': 'pane-title-close', // The worktree card's "rename failed" chip, for a failure the user can open. 'destructive-chip': - 'border border-destructive/40 bg-destructive/10 text-destructive-text hover:bg-destructive/15 hover:text-destructive-text' + 'border border-destructive/40 bg-destructive/10 text-destructive-text hover:bg-destructive/15 hover:text-destructive-text', + // A destructive way out set apart from the recovery actions (e.g. "Delete sandbox"): red text, no fill. + 'destructive-ghost': + 'text-destructive-text hover:bg-destructive/10 hover:text-destructive-text dark:hover:bg-destructive/15' }, size: { default: 'h-9 px-4 py-2 has-[>svg]:px-3', diff --git a/src/renderer/src/components/ui/inline-error.tsx b/src/renderer/src/components/ui/inline-error.tsx index 9a38d8dc069..47a09051109 100644 --- a/src/renderer/src/components/ui/inline-error.tsx +++ b/src/renderer/src/components/ui/inline-error.tsx @@ -1,4 +1,4 @@ -import type React from 'react' +import React from 'react' import { CircleAlert, Info, RotateCw } from 'lucide-react' import { cn } from '@/lib/utils' import { Button } from './button' @@ -22,8 +22,12 @@ type InlineErrorProps = { * (not announced) because it describes something that already happened. */ layout?: 'inline' | 'toast' | 'strip-top' | 'strip-bottom' | 'line' /** A next step other than retry (e.g. "Sign in"), rendered inside the box after the text. - * Pass an outline xs Button with a short verb-first label; never a primary button. */ + * Pass an outline xs Button with a short verb-first label; never a primary button. A card whose recovery is the main + * content (e.g. the build-failure card) puts its own action row in children instead. */ action?: React.ReactNode + /** Richer content under the detail, aligned with the text (a list of problems, a row of + * actions). With children only the title and detail are announced; the rest is read on demand. */ + children?: React.ReactNode className?: string } @@ -42,9 +46,13 @@ function InlineError({ density = 'default', layout = 'inline', action, + children, className }: InlineErrorProps): React.JSX.Element { const Icon = tone === 'error' ? CircleAlert : Info + const liveRole = tone === 'error' ? 'alert' : 'status' + // Why: announcing a whole card would read every button and list row along with the cause. + const announceTextOnly = React.Children.toArray(children).length > 0 if (layout === 'line') { return (

-

-

{title}

- {detail ? ( -

- {detail} -

- ) : null} +
+
+ {/* A div, so a caller can pass a focusable heading as the title. */} +
{title}
+ {detail ? ( +

+ {detail} +

+ ) : null} +
+ {announceTextOnly ?
{children}
: null}
{action ? (
-
- + + {environmentCheckBadge(check.status, t)} - - {message} -
+ + + {message} {remediation ? ( -

{remediation}

+

+ {remediation} +

) : null} ) diff --git a/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx b/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx index 4fefa20b188..ea94f646b88 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx @@ -11,8 +11,7 @@ import { PanelLeft, Pencil, RotateCcw, - SquareArrowOutUpRight, - Trash2 + SquareArrowOutUpRight } from 'lucide-react' import { Button } from '@/components/ui/button' import { @@ -174,9 +173,17 @@ function failureActions( icon: , onClick: actions.onOpenAnyway } - // Hosted sandboxes have no recipe for an agent or the user to edit. + // Hosted sandboxes have no recipe for an agent or the user to edit. Checks rarely pass on a + // rerun without a change, so opening the sandbox to fix them in place leads. Two plain text + // buttons read as a choice between equals rather than a toolbar. return cloud - ? { primary: [retryChecks, openAnyway], more: [] } + ? { + primary: [ + { ...openAnyway, icon: undefined }, + { ...retryChecks, icon: undefined } + ], + more: [] + } : { primary: [fix, retryChecks], more: [openAnyway, editRecipe] } } case 'provision': @@ -298,12 +305,12 @@ export function FailureActionRow({ // Leaving a build that still holds a VM destroys it, so say so on the button. const destroys = vmKept return ( -
+
{primary.map((action, index) => ( @@ -338,13 +345,12 @@ export function FailureActionRow({ ) : null} + + ) + const alert = screen.getByRole('alert') + expect(alert.getAttribute('data-slot')).toBeNull() + expect(alert.textContent).toBe("Couldn't load keys.Try later.") +}) diff --git a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx index 80d170a416e..86b3a6cf127 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { cn } from '@/lib/utils' +import { InlineError } from '@/components/ui/inline-error' import { useTranslate } from '@/i18n/use-translate' import { VmBuildReveal } from './VmBuildReveal' import { isAccountGate, type VmBuildFailure } from './vm-build-failure' @@ -61,7 +61,8 @@ export function VmBuildFailureCard({ cloud, canManageBilling, repoName, - sandboxLimit: sandboxLimitFromBilling(getLastBillingStatus()) + sandboxLimit: sandboxLimitFromBilling(getLastBillingStatus()), + sandboxKept: vmKept }, t ) @@ -94,61 +95,54 @@ export function VmBuildFailureCard({ return ( {visible && copy ? ( -
- {/* Only the cause is announced; the actions and check rows are read on demand. */} -
-

- {copy.title} -

- {copy.body ? ( -

{copy.body}

- ) : null} +
+ {/* InlineError announces only the cause; the check rows and actions are read on demand. + An account limit isn't a broken build, so it reads as a neutral notice. */} + + {copy.title} + + } + detail={copy.body} + > {detail ? ( -

{detail}

+

{detail}

) : null} -
- {visible.kind === 'checks' ? ( -
    - {visible.problems.map((check, index) => ( - - ))} -
- ) : null} - - {visible.kind === 'checks' ? ( -

- {cloud - ? t( - 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningCloud', - 'The sandbox is running and using sandbox hours until you choose.' - ) - : t( - 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningLocal', - 'The VM is running and using hours until you choose.' - )} -

- ) : null} + {visible.kind === 'checks' ? ( +
    + {visible.problems.map((check, index) => ( + + ))} +
+ ) : null} + + {visible.kind === 'checks' ? ( +

+ {cloud + ? t( + 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningCloud', + 'The sandbox is running and using sandbox hours until you choose.' + ) + : t( + 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningLocal', + 'The VM is running and using hours until you choose.' + )} +

+ ) : null} +
) : null} diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheet.fixture.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheet.fixture.tsx index 0f3913ba1ed..85d1dc516f5 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildSheet.fixture.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildSheet.fixture.tsx @@ -254,6 +254,26 @@ export const cloudChecksFailed = frame( ) ) +// One failure plus a warning: the title counts failures only, in the singular. +export const cloudChecksFailedOne = frame( + entry( + { + environmentCheck: { + status: 'failed', + checks: FAILED_CHECKS?.filter((check) => check.id !== 'git.push'), + ...CHECKS_FAILED_AT + } + }, + CLOUD_RECIPE + ) +) + +// A narrow sheet: the pills keep one column and Delete sandbox wraps under the recovery actions. +export const cloudChecksFailedNarrow = defineFixture({ + ...cloudChecksFailed, + width: 420 +}) + // A build replayed on a timer, for recording the transitions: log streams, checks run and fail, // the card opens, Retry collapses it, and a second pass succeeds. const TIMELINE: { at: number; patch: Partial }[] = [ diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx index f0f1f9b00cb..c927f897ea1 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx @@ -194,7 +194,11 @@ export function VmBuildSheet({ ) : ( )} 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 306d33527ab..df01c7576c8 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 @@ -41,33 +41,62 @@ export type VmBuildFailureCopyContext = { canManageBilling: boolean /** States the cap on the limit cards; omitted or null falls back to copy without numbers. */ sandboxLimit?: SandboxLimit | null + /** A sandbox still exists (and uses hours), so the card can't say nothing was created. */ + sandboxKept?: boolean } /** The card's cause-specific title and one plain-language sentence on what to do next. */ export function vmBuildFailureCopy( failure: VmBuildFailure, - { cloud, canManageBilling, repoName, sandboxLimit }: VmBuildFailureCopyContext, + { cloud, canManageBilling, repoName, sandboxLimit, sandboxKept }: VmBuildFailureCopyContext, t: Translate ): { title: string; body: string | null } { switch (failure.kind) { - case 'checks': + case 'checks': { + // Warnings ride along in the list but don't count as failures in the title. + const count = failure.problems.filter((check) => check.status === 'fail').length return { - title: cloud - ? t( - 'auto.components.worktree.creation.VmBuildFailureCard.checksTitleCloud', - 'The sandbox is up, but its environment checks failed' - ) - : t( - 'auto.components.worktree.creation.VmBuildSheet.checksFailed', - 'The VM is up, but its environment checks failed' - ), + title: + count === 0 + ? cloud + ? t( + 'auto.components.worktree.creation.VmBuildFailureCard.checksAttentionTitleCloud', + 'The sandbox is up, but some environment checks need attention' + ) + : t( + 'auto.components.worktree.creation.VmBuildFailureCard.checksAttentionTitleVm', + 'The VM is up, but some environment checks need attention' + ) + : cloud + ? t( + 'auto.components.worktree.creation.VmBuildFailureCard.checksCountTitleCloud', + 'The sandbox is up, but {{count}} environment checks failed', + { + count, + defaultValue_one: 'The sandbox is up, but {{count}} environment check failed' + } + ) + : t( + 'auto.components.worktree.creation.VmBuildFailureCard.checksCountTitleVm', + 'The VM is up, but {{count}} environment checks failed', + { + count, + defaultValue_one: 'The VM is up, but {{count}} environment check failed' + } + ), body: cloud ? t( - 'auto.components.worktree.creation.VmBuildFailureCard.checksBodyCloud', - 'Open anyway to fix these inside the workspace, or retry the checks after changing your project.' + 'auto.components.worktree.creation.VmBuildFailureCard.checksBodyCloud2', + 'Open it anyway and fix them inside the workspace, or run the checks again after changing your project.', + { + count: failure.problems.length, + defaultValue_one: + 'Open it anyway and fix it inside the workspace, or run the checks again after changing your project.' + } ) : null } + } case 'plan': return { title: t( @@ -241,10 +270,15 @@ export function vmBuildFailureCopy( 'auto.components.worktree.creation.VmBuildFailureCard.provisionTitleCloud', 'The sandbox didn’t start' ), - body: t( - 'auto.components.worktree.creation.VmBuildFailureCard.provisionBodyCloud', - 'Something went wrong while starting the sandbox. Try again, or open the logs for details.' - ) + body: sandboxKept + ? t( + 'auto.components.worktree.creation.VmBuildFailureCard.provisionBodyCloudKept', + 'Something went wrong while starting the sandbox. Try again, or delete the sandbox to stop using sandbox hours.' + ) + : t( + 'auto.components.worktree.creation.VmBuildFailureCard.provisionBodyCloud2', + 'Something went wrong while starting the sandbox. Nothing was created, and you weren’t charged.' + ) } : { title: t( diff --git a/src/renderer/src/components/worktree-creation/vm-build-failure-toast.ts b/src/renderer/src/components/worktree-creation/vm-build-failure-toast.ts index 993a1f3c61b..24715b2da10 100644 --- a/src/renderer/src/components/worktree-creation/vm-build-failure-toast.ts +++ b/src/renderer/src/components/worktree-creation/vm-build-failure-toast.ts @@ -30,7 +30,18 @@ export function vmBuildFailureSummary( const sandboxLimit = sandboxLimitFromBilling(getLastBillingStatus()) return { failure, - ...vmBuildFailureCopy(failure, { cloud, canManageBilling: true, repoName, sandboxLimit }, t) + ...vmBuildFailureCopy( + failure, + { + cloud, + canManageBilling: true, + repoName, + sandboxLimit, + // Same rule as the sheet: failed checks or a recorded runtime mean a sandbox is still up. + sandboxKept: failure.kind === 'checks' || Boolean(entry.request.ephemeralVmRuntimeId) + }, + t + ) } } diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index f065424fa73..561e9a73e10 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1333,6 +1333,14 @@ }, "worktree": { "creation": { + "VmBuildFailureCard": { + "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.", + "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" + }, "VmBuildLog": { "hiddenTechnicalLines_one": "{{count}} technical line hidden. Copy log includes it.", "hiddenTechnicalLines_other": "{{count}} technical lines hidden. Copy log includes them." diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 7ed2f196020..d7984804d09 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -4190,7 +4190,6 @@ }, "VmBuildSheet": { "checks": "Check environment", - "checksFailed": "The VM is up, but its environment checks failed", "create": "Create workspace", "editRecipe": "Edit recipe", "fixWithAgent": "Fix with agent", @@ -4222,13 +4221,11 @@ }, "VmBuildFailureCard": { "createFailedTitle": "Couldn’t create workspace", - "checksTitleCloud": "The sandbox is up, but its environment checks failed", "planTitle": "Orca Cloud needs a Team plan", "signInTitle": "Sign in to use Orca Cloud", "unavailableTitle": "Orca Cloud is unavailable right now", "networkTitle": "Couldn’t reach Orca Cloud", "snapshotTitle": "This project’s saved environment is missing", - "provisionBodyCloud": "Something went wrong while starting the sandbox. Try again, or open the logs for details.", "stillRunningCloud": "The sandbox is running and using sandbox hours until you choose.", "stillRunningLocal": "The VM is running and using hours until you choose.", "tryAgain": "Try again", @@ -4237,7 +4234,6 @@ "deleteSandbox": "Delete sandbox", "deleteVm": "Delete VM", "updatePayment": "Update payment method", - "checksBodyCloud": "Open anyway to fix these inside the workspace, or retry the checks after changing your project.", "showWorkspaces": "Show cloud workspaces", "contactSupport": "Contact support", "provisionTitleCloud": "The sandbox didn’t start", @@ -4275,7 +4271,17 @@ "planBodyMember3": "Nothing was created, and you weren’t charged. Ask an owner or admin to choose a Team plan.", "outOfHoursBodyMember3": "Your team has used this month’s sandbox hours, so sandboxes can’t start or keep running. Nothing was created, and you weren’t charged. Ask an owner or admin to add hours.", "spendCapReachedBodyMember4": "Your team has reached this month’s spend cap, so sandboxes can’t start or keep running. Nothing was created, and you weren’t charged. Ask an owner or admin to raise the spend cap.", - "paymentFailedBodyMember2": "New sandboxes can’t start until the payment goes through. Nothing was created, and you weren’t charged. Ask an owner or admin to update the payment method." + "paymentFailedBodyMember2": "New sandboxes can’t start until the payment goes through. Nothing was created, and you weren’t charged. Ask an owner or admin to update the payment method.", + "checksAttentionTitleCloud": "The sandbox is up, but some environment checks need attention", + "checksAttentionTitleVm": "The VM is up, but some environment checks need attention", + "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", + "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." }, "VmBuildLog": { "jumpToError": "Jump to first error",