diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudSessionToasts.fixture.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudSessionToasts.fixture.tsx index 4e813143d5d..189bd09ef7d 100644 --- a/src/renderer/src/components/orca-cloud/OrcaCloudSessionToasts.fixture.tsx +++ b/src/renderer/src/components/orca-cloud/OrcaCloudSessionToasts.fixture.tsx @@ -59,10 +59,10 @@ function warning(minutesLeft: HostedSessionWarningEvent['minutesLeft']): () => v return () => showOrcaCloudRestartWarningToast({ ...workspace, minutesLeft }, restartActions) } -/** 60 and 15 min left: dismisses itself after 20s. */ +/** 60 minutes left. Every tier stays until the user acts or the restart happens. */ export const restartWarning = toastFixture(warning(60)) -/** 5 min left: stays until the user acts or the restart happens. */ -export const restartWarningPersistent = toastFixture(warning(5)) +/** The last tier, 5 minutes left. */ +export const restartWarningFiveMinutes = toastFixture(warning(5)) export const restarting = toastFixture(() => showOrcaCloudRestartingToast(workspace.workspaceId, workspace.workspaceName) ) diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudToastBody.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudToastBody.tsx new file mode 100644 index 00000000000..5d3fec4c185 --- /dev/null +++ b/src/renderer/src/components/orca-cloud/OrcaCloudToastBody.tsx @@ -0,0 +1,40 @@ +import React from 'react' +import { Button } from '@/components/ui/button' + +export type OrcaCloudToastAction = { + label: string + onClick: () => void + /** The toast's main action; the rest are secondary. */ + primary?: boolean +} + +/** Toast description with real buttons, so a toast can offer two actions without Sonner's + * dismiss-only "cancel" slot standing in for one. */ +export function OrcaCloudToastBody({ + text, + actions +}: { + text: string + actions: readonly OrcaCloudToastAction[] +}): React.JSX.Element { + return ( +
+ {text} + {actions.length > 0 ? ( +
+ {actions.map((action) => ( + + ))} +
+ ) : null} +
+ ) +} diff --git a/src/renderer/src/components/orca-cloud/cloud-state-copy.ts b/src/renderer/src/components/orca-cloud/cloud-state-copy.ts index b95d07721ec..256bfe8d4a2 100644 --- a/src/renderer/src/components/orca-cloud/cloud-state-copy.ts +++ b/src/renderer/src/components/orca-cloud/cloud-state-copy.ts @@ -30,7 +30,7 @@ export function cloudStateDetail(state: CloudDotState, t: Translate = translate) 'Files and chats are saved. Opening it wakes it.' ) case 'waking': - return t('orcaCloudWorkspace.detail.starting', 'Starting…') + return t('orcaCloudWorkspace.detail.waking', 'Waking…') case 'unresponsive': return t('orcaCloudWorkspace.detail.restartKeeps', 'Restart keeps your files; agents resume.') case 'archived': diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx index ac763f6bb63..d7f910d40ae 100644 --- a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx @@ -53,7 +53,7 @@ function getDefaultBranchIdentityLabel(t: Translate = translate): string { return t('auto.components.sidebar.WorktreeCardStatusSlot.branchIdentity', 'Branch') } function getSleepingStatusLabel(t: Translate = translate): string { - return t('auto.components.sidebar.WorktreeCardStatusSlot.sleeping', 'Sleeping') + return t('auto.components.sidebar.WorktreeCardStatusSlot.sleeping', 'Asleep') } // Offset optically left-heavy branch glyphs to align with centered activity dots. const compactReviewAndBranchStatusIconClassName = 'size-[13px] translate-x-px' diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index 3710d2df2bf..40ee8f36343 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1260,6 +1260,10 @@ "permissionDenied": "Permission denied.", "symlink": "Symbolic links cannot be attached.", "unsupported": "Unsupported file type." + }, + "orcaCloudSession": { + "sandboxRestartsInMinutes_one": "Sandbox for {{name}} restarts in {{count}} minute", + "sandboxRestartsInMinutes_other": "Sandbox for {{name}} restarts in {{count}} minutes" } }, "runtime": { diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index d58fa15ea7e..0692f9e34a0 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -2154,7 +2154,6 @@ "seePlans": "See plans", "workspaceGone": "That workspace is no longer in Orca.", "thisWorkspaceLower": "this workspace", - "sandboxRestartSoon": "Sandbox for {{name}} restarts in {{minutes}} min", "sandboxRestartSoonDetail": "Cloud sandboxes restart after 24 hours. Files are kept and Orca resumes your agents after the restart.", "restartNow": "Restart now", "open": "Open", @@ -2165,13 +2164,15 @@ "restartedResumingDetail": "Files are kept and Orca is resuming your agents. The next restart is in 24 hours.", "sandboxRestarting": "Restarting the sandbox for {{name}}…", "restartingDetail": "Usually under a minute. Orca resumes your agents once it is back.", - "cleaningUp": "Cleaning up the Orca Cloud sandbox…", - "cleaningUpDetail": "Creation was cancelled. Deleting the sandbox so it stops using sandbox hours.", - "cleanedUp": "Orca Cloud sandbox cleaned up", - "cleanedUpDetail": "Nothing from the cancelled workspace is left running.", - "cleanupFailed": "Couldn't finish cleaning up the Orca Cloud sandbox", - "cleanupFailedDetail": "It may still be running and using sandbox hours. Retry the cleanup from Settings.", - "openSettings": "Open Settings" + "sandboxRestartsInMinutes_one": "Sandbox for {{name}} restarts in {{count}} minute", + "sandboxRestartsInMinutes_other": "Sandbox for {{name}} restarts in {{count}} minutes", + "deletingSandbox": "Deleting the sandbox…", + "deletingSandboxDetail": "Creating the workspace was canceled, so its sandbox is deleted and stops using sandbox hours.", + "sandboxDeleted": "Sandbox deleted", + "sandboxDeletedDetail": "Nothing from the canceled workspace is left running.", + "sandboxDeleteFailed": "Couldn't delete the sandbox", + "sandboxDeleteFailedDetail": "It may still be running and using sandbox hours.", + "tryAgain": "Try again" }, "runtimePortForwards": { "desktopOnly": "Port forwarding needs the desktop app.", @@ -7389,9 +7390,9 @@ }, "WorktreeCardStatusSlot": { "branchIdentity": "Branch", - "sleeping": "Sleeping", "markAsRead": "Mark as read", - "markAsUnread": "Mark as unread" + "markAsUnread": "Mark as unread", + "sleeping": "Asleep" }, "NewExternalWorktreesInboxLine": { "9f2d4c8b17": "Hide external worktrees permanently for {{value0}}", @@ -25849,9 +25850,9 @@ "restartKeeps": "Restart keeps your files; agents resume.", "restarting": "Orca resumes your agents after the restart.", "asleep": "Files and chats are saved. Opening it wakes it.", - "starting": "Starting…", "archived": "Kept as a snapshot. Unarchive to work in it again.", - "failed": "The last start failed. Your files are saved." + "failed": "The last start failed. Your files are saved.", + "waking": "Waking…" }, "restarting": "Restarting…", "restart": "Restart", diff --git a/src/renderer/src/lib/orca-cloud-cancel-cleanup.test.ts b/src/renderer/src/lib/orca-cloud-cancel-cleanup.test.ts index 8e05b2a9c67..5791e56ead3 100644 --- a/src/renderer/src/lib/orca-cloud-cancel-cleanup.test.ts +++ b/src/renderer/src/lib/orca-cloud-cancel-cleanup.test.ts @@ -29,7 +29,7 @@ describe('Orca Cloud cancel cleanup', () => { const run = deferred() const cleanup = deferred() void trackOrcaCloudCreateStep('c-1', run.promise) - beginOrcaCloudCancelCleanup('c-1', [cleanup.promise], { createStartedAt: 0 }, () => {}) + beginOrcaCloudCancelCleanup('c-1', [cleanup.promise], { createStartedAt: 0, canceledAt: 1000 }) expect(toasts.showOrcaCloudCleanupStartedToast).toHaveBeenCalledWith('c-1') cleanup.resolve(true) @@ -43,7 +43,10 @@ describe('Orca Cloud cancel cleanup', () => { }) it('reports a failure when a cleanup left the sandbox running', async () => { - beginOrcaCloudCancelCleanup('c-2', [Promise.resolve(false)], { createStartedAt: 0 }, () => {}) + beginOrcaCloudCancelCleanup('c-2', [Promise.resolve(false)], { + createStartedAt: 0, + canceledAt: 1000 + }) await flush() expect(toasts.showOrcaCloudCleanupFailedToast).toHaveBeenCalledWith('c-2', expect.any(Function)) expect(toasts.showOrcaCloudCleanupDoneToast).not.toHaveBeenCalled() @@ -70,7 +73,7 @@ describe('Orca Cloud cancel cleanup', () => { } } }) - beginOrcaCloudCancelCleanup('c-3', [], { createStartedAt: 100 }, () => {}) + beginOrcaCloudCancelCleanup('c-3', [], { createStartedAt: 100, canceledAt: 1000 }) await flush() expect(toasts.showOrcaCloudCleanupFailedToast).toHaveBeenCalledWith('c-3', expect.any(Function)) }) @@ -90,8 +93,41 @@ describe('Orca Cloud cancel cleanup', () => { } } }) - beginOrcaCloudCancelCleanup('c-4', [], { createStartedAt: 100 }, () => {}) + beginOrcaCloudCancelCleanup('c-4', [], { createStartedAt: 100, canceledAt: 1000 }) await flush() expect(toasts.showOrcaCloudCleanupDoneToast).toHaveBeenCalledWith('c-4') }) + + it("Try again deletes only this create's sandbox whose delete failed", async () => { + const cleanupCalls: string[] = [] + vi.stubGlobal('window', { + api: { + ephemeralVm: { + listRuntimes: async () => [ + { + id: 'mine', + recipe: { provider: 'orca-cloud' }, + status: 'cleanup_failed', + createdAt: 200 + }, + { id: 'later', recipe: { provider: 'orca-cloud' }, status: 'running', createdAt: 2000 } + ], + cleanup: async ({ runtimeId }: { runtimeId: string }) => { + cleanupCalls.push(runtimeId) + return { cleanupStatus: 'succeeded' } + } + } + } + }) + beginOrcaCloudCancelCleanup('c-5', [Promise.resolve(false)], { + createStartedAt: 100, + canceledAt: 1000 + }) + await flush() + const tryAgain = toasts.showOrcaCloudCleanupFailedToast.mock.calls[0]?.[1] as () => void + tryAgain() + await flush() + expect(cleanupCalls).toEqual(['mine']) + expect(toasts.showOrcaCloudCleanupStartedToast).toHaveBeenCalledTimes(2) + }) }) diff --git a/src/renderer/src/lib/orca-cloud-cancel-cleanup.ts b/src/renderer/src/lib/orca-cloud-cancel-cleanup.ts index 6831f0d985a..8495436da46 100644 --- a/src/renderer/src/lib/orca-cloud-cancel-cleanup.ts +++ b/src/renderer/src/lib/orca-cloud-cancel-cleanup.ts @@ -1,5 +1,5 @@ -// Cancel feedback for an Orca Cloud create: "cleaning up" until every step that can still own the -// sandbox has settled, then "cleaned up" (or a failure the user can act on). +// Cancel feedback for an Orca Cloud create: "Deleting the sandbox…" until every step that can still +// own the sandbox has settled, then "Sandbox deleted" (or a failure with Try again). import { ORCA_CLOUD_RECIPE_ID } from '../../../shared/hosted-sandbox/orca-cloud-recipe-id' import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation' import { @@ -11,18 +11,23 @@ import { /** Resolves false when the step may have left the sandbox running. */ type CleanupStep = Promise -/** Which runtime records belong to the cancelled create. */ -export type OrcaCloudCancelScope = { runtimeId?: string; createStartedAt: number } +/** Which runtime records belong to the canceled create. */ +export type OrcaCloudCancelScope = { + runtimeId?: string + createStartedAt: number + canceledAt: number +} type Cleanup = { pending: number failed: boolean scope: OrcaCloudCancelScope - openServers: () => void + /** A Try again: anything of this create still up afterwards counts as not deleted. */ + retry: boolean timeout?: ReturnType } -// A provision that never settles must not leave "Cleaning up…" spinning forever. +// A provision that never settles must not leave "Deleting the sandbox…" spinning forever. const CLEANUP_TIMEOUT_MS = 3 * 60_000 // Orca Cloud creates still running, by creation id; after a cancel each ends once its own cleanup has. @@ -56,17 +61,17 @@ export function trackOrcaCloudCreateStep(creationId: string, step: Promise return step } -/** The user cancelled an Orca Cloud create; `steps` are the cleanups the cancel itself started. */ +/** The user canceled an Orca Cloud create; `steps` are the cleanups the cancel itself started. */ export function beginOrcaCloudCancelCleanup( creationId: string, steps: readonly CleanupStep[], scope: OrcaCloudCancelScope, - openServers: () => void + retry = false ): void { if (cleanups.has(creationId)) { return } - const cleanup: Cleanup = { pending: 0, failed: false, scope, openServers } + const cleanup: Cleanup = { pending: 0, failed: false, scope, retry } cleanup.timeout = setTimeout(() => finish(creationId, cleanup, true), CLEANUP_TIMEOUT_MS) cleanups.set(creationId, cleanup) showOrcaCloudCleanupStartedToast(creationId) @@ -106,9 +111,14 @@ function finish(creationId: string, cleanup: Cleanup, timedOut: boolean): void { } cleanups.delete(creationId) clearTimeout(cleanup.timeout) - void cleanupLeftSandboxRunning(cleanup, timedOut).then((failed) => { + // A provision still in flight at the cancel can write its record after it; once every tracked + // step has settled, nothing of this create can appear later, so widen the window to now. + if (!timedOut) { + cleanup.scope = { ...cleanup.scope, canceledAt: Math.max(cleanup.scope.canceledAt, Date.now()) } + } + void cleanupLeftSandboxRunning(cleanup, timedOut || cleanup.retry).then((failed) => { if (failed) { - showOrcaCloudCleanupFailedToast(creationId, cleanup.openServers) + showOrcaCloudCleanupFailedToast(creationId, () => retryCleanup(creationId, cleanup.scope)) } else { showOrcaCloudCleanupDoneToast(creationId) } @@ -117,17 +127,56 @@ function finish(creationId: string, cleanup: Cleanup, timedOut: boolean): void { const SETTLED_STATUSES = new Set(['cleaned', 'failed']) +/** This create's Orca Cloud runtimes that may still be up; null when the records can't be read. + * `failedOnly` limits it to sandboxes whose delete failed, the only ones safe to delete again. */ +async function leftoverRuntimeIds( + scope: OrcaCloudCancelScope, + { timedOut, failedOnly }: { timedOut: boolean; failedOnly: boolean } +): Promise { + const runtimes = await window.api.ephemeralVm.listRuntimes().catch(() => null) + if (!runtimes) { + return null + } + return runtimes + .filter( + (runtime) => + runtime.recipe?.provider === 'orca-cloud' && + (scope.runtimeId + ? runtime.id === scope.runtimeId + : // Without an id, only sandboxes created by this attempt, never a later create's. + runtime.createdAt >= scope.createStartedAt && runtime.createdAt <= scope.canceledAt) && + (runtime.status === 'cleanup_failed' || + (!failedOnly && timedOut && !SETTLED_STATUSES.has(runtime.status))) + ) + .map((runtime) => runtime.id) +} + // The create's own cleanups only log failures, so confirm against this create's runtime records. async function cleanupLeftSandboxRunning(cleanup: Cleanup, timedOut: boolean): Promise { if (cleanup.failed) { return true } - const { runtimeId, createStartedAt } = cleanup.scope - const runtimes = await window.api.ephemeralVm.listRuntimes().catch(() => []) - return runtimes.some( - (runtime) => - runtime.recipe?.provider === 'orca-cloud' && - (runtimeId ? runtime.id === runtimeId : runtime.createdAt >= createStartedAt) && - (runtime.status === 'cleanup_failed' || (timedOut && !SETTLED_STATUSES.has(runtime.status))) + const ids = await leftoverRuntimeIds(cleanup.scope, { timedOut, failedOnly: false }) + return ids === null || ids.length > 0 +} + +/** "Try again": delete again every sandbox of this create whose delete failed, with the same feedback. */ +function retryCleanup(creationId: string, scope: OrcaCloudCancelScope): void { + // A second click while the retry runs must not send the deletes twice. + if (cleanups.has(creationId)) { + return + } + const step = leftoverRuntimeIds(scope, { timedOut: false, failedOnly: true }).then((ids) => + ids === null + ? false + : Promise.all( + ids.map((runtimeId) => + window.api.ephemeralVm + .cleanup({ runtimeId }) + .then((runtime) => runtime.cleanupStatus !== 'failed') + .catch(() => false) + ) + ).then((results) => results.every(Boolean)) ) + beginOrcaCloudCancelCleanup(creationId, [step], scope, true) } diff --git a/src/renderer/src/lib/orca-cloud-session-toasts.ts b/src/renderer/src/lib/orca-cloud-session-toasts.ts index 528d40bbd29..40a8068c33c 100644 --- a/src/renderer/src/lib/orca-cloud-session-toasts.ts +++ b/src/renderer/src/lib/orca-cloud-session-toasts.ts @@ -1,5 +1,10 @@ // Toasts for Orca Cloud's session lifecycle: the 24h restart and cancel cleanup. +import { createElement } from 'react' import { toast } from 'sonner' +import { + OrcaCloudToastBody, + type OrcaCloudToastAction +} from '@/components/orca-cloud/OrcaCloudToastBody' import { translate } from '@/i18n/i18n' import type { HostedSessionRestartResult, @@ -7,11 +12,7 @@ import type { HostedSessionWarningEvent } from '../../../shared/hosted-sandbox/hosted-session-events' -/** The final warning tier stays up until the user acts or the restart happens. */ -export const ORCA_CLOUD_PERSISTENT_WARNING_MINUTES = 5 -const WARNING_DURATION_MS = 20_000 -// Sonner merges an update into the toast with the same id; drop the warning's buttons explicitly. -const WITHOUT_WARNING_ACTIONS = { action: undefined, cancel: undefined } +const RESULT_DURATION_MS = 20_000 export type OrcaCloudRestartToastActions = { restartNow: (workspaceId: string) => Promise @@ -43,40 +44,52 @@ export function showOrcaCloudRestartWarningToast( warnedWorkspaces.add(workspaceId) } const id = restartToastId(workspaceId) - const persistent = minutesLeft <= ORCA_CLOUD_PERSISTENT_WARNING_MINUTES + const buttons: OrcaCloudToastAction[] = workspaceId + ? [ + { + label: translate('auto.lib.orcaCloudSession.restartNow', 'Restart now'), + primary: true, + // The toast stays: it turns into the restart's progress and result. + onClick: () => void runOrcaCloudRestartNow(event, actions.restartNow) + }, + { + label: translate('auto.lib.orcaCloudSession.open', 'Open'), + onClick: () => { + toast.dismiss(id) + actions.open(workspaceId) + } + } + ] + : [] toast.warning( translate( - 'auto.lib.orcaCloudSession.sandboxRestartSoon', - 'Sandbox for {{name}} restarts in {{minutes}} min', - { name: workspaceLabel(workspaceName), minutes: minutesLeft } + 'auto.lib.orcaCloudSession.sandboxRestartsInMinutes', + 'Sandbox for {{name}} restarts in {{count}} minutes', + { + name: workspaceLabel(workspaceName), + count: minutesLeft, + defaultValue_one: 'Sandbox for {{name}} restarts in {{count}} minute' + } ), { id, - duration: persistent ? Number.POSITIVE_INFINITY : WARNING_DURATION_MS, - description: translate( - 'auto.lib.orcaCloudSession.sandboxRestartSoonDetail', - 'Cloud sandboxes restart after 24 hours. Files are kept and Orca resumes your agents after the restart.' - ), - ...(workspaceId - ? { - action: { - label: translate('auto.lib.orcaCloudSession.restartNow', 'Restart now'), - onClick: (clickEvent) => { - // Keep the toast: it turns into the restart's progress and result. - clickEvent.preventDefault() - void runOrcaCloudRestartNow(event, actions.restartNow) - } - }, - cancel: { - label: translate('auto.lib.orcaCloudSession.open', 'Open'), - onClick: () => actions.open(workspaceId) - } - } - : {}) + // It offers actions, so it waits for the user (or the restart) instead of timing out. + duration: Number.POSITIVE_INFINITY, + description: toastBody( + translate( + 'auto.lib.orcaCloudSession.sandboxRestartSoonDetail', + 'Cloud sandboxes restart after 24 hours. Files are kept and Orca resumes your agents after the restart.' + ), + buttons + ) } ) } +function toastBody(text: string, actions: readonly OrcaCloudToastAction[]): React.ReactNode { + return createElement(OrcaCloudToastBody, { text, actions }) +} + async function runOrcaCloudRestartNow( event: HostedSessionWarningEvent, restartNow: OrcaCloudRestartToastActions['restartNow'] @@ -113,8 +126,7 @@ function showOrcaCloudRestartFailedToast( ), { id, - ...WITHOUT_WARNING_ACTIONS, - duration: WARNING_DURATION_MS, + duration: RESULT_DURATION_MS, description: status === 'not-running' ? translate( @@ -136,8 +148,7 @@ function showOrcaCloudRestartedToast(workspaceId: string, workspaceName: string }), { id: restartToastId(workspaceId), - ...WITHOUT_WARNING_ACTIONS, - duration: WARNING_DURATION_MS, + duration: RESULT_DURATION_MS, description: translate( 'auto.lib.orcaCloudSession.restartedResumingDetail', 'Files are kept and Orca is resuming your agents. The next restart is in 24 hours.' @@ -189,7 +200,6 @@ export function showOrcaCloudRestartingToast( ), { id: restartToastId(workspaceId), - ...WITHOUT_WARNING_ACTIONS, duration: Number.POSITIVE_INFINITY, description: translate( 'auto.lib.orcaCloudSession.restartingDetail', @@ -204,47 +214,46 @@ function cleanupToastId(creationId: string): string { } export function showOrcaCloudCleanupStartedToast(creationId: string): void { - toast.loading( - translate('auto.lib.orcaCloudSession.cleaningUp', 'Cleaning up the Orca Cloud sandbox…'), - { - id: cleanupToastId(creationId), - duration: Number.POSITIVE_INFINITY, - description: translate( - 'auto.lib.orcaCloudSession.cleaningUpDetail', - 'Creation was cancelled. Deleting the sandbox so it stops using sandbox hours.' - ) - } - ) -} - -export function showOrcaCloudCleanupDoneToast(creationId: string): void { - toast.success(translate('auto.lib.orcaCloudSession.cleanedUp', 'Orca Cloud sandbox cleaned up'), { + toast.loading(translate('auto.lib.orcaCloudSession.deletingSandbox', 'Deleting the sandbox…'), { id: cleanupToastId(creationId), - duration: 6_000, + duration: Number.POSITIVE_INFINITY, description: translate( - 'auto.lib.orcaCloudSession.cleanedUpDetail', - 'Nothing from the cancelled workspace is left running.' + 'auto.lib.orcaCloudSession.deletingSandboxDetail', + 'Creating the workspace was canceled, so its sandbox is deleted and stops using sandbox hours.' ) }) } -export function showOrcaCloudCleanupFailedToast(creationId: string, openServers: () => void): void { +export function showOrcaCloudCleanupDoneToast(creationId: string): void { + toast.success(translate('auto.lib.orcaCloudSession.sandboxDeleted', 'Sandbox deleted'), { + id: cleanupToastId(creationId), + duration: 6_000, + description: translate( + 'auto.lib.orcaCloudSession.sandboxDeletedDetail', + 'Nothing from the canceled workspace is left running.' + ) + }) +} + +export function showOrcaCloudCleanupFailedToast(creationId: string, tryAgain: () => void): void { toast.error( - translate( - 'auto.lib.orcaCloudSession.cleanupFailed', - "Couldn't finish cleaning up the Orca Cloud sandbox" - ), + translate('auto.lib.orcaCloudSession.sandboxDeleteFailed', "Couldn't delete the sandbox"), { id: cleanupToastId(creationId), duration: Number.POSITIVE_INFINITY, - description: translate( - 'auto.lib.orcaCloudSession.cleanupFailedDetail', - 'It may still be running and using sandbox hours. Retry the cleanup from Settings.' - ), - action: { - label: translate('auto.lib.orcaCloudSession.openSettings', 'Open Settings'), - onClick: openServers - } + description: toastBody( + translate( + 'auto.lib.orcaCloudSession.sandboxDeleteFailedDetail', + 'It may still be running and using sandbox hours.' + ), + [ + { + label: translate('auto.lib.orcaCloudSession.tryAgain', 'Try again'), + primary: true, + onClick: tryAgain + } + ] + ) } ) } diff --git a/src/renderer/src/store/slices/worktrees/create/pending-worktree-creation.ts b/src/renderer/src/store/slices/worktrees/create/pending-worktree-creation.ts index 0c3f8999cc2..2aef311c27a 100644 --- a/src/renderer/src/store/slices/worktrees/create/pending-worktree-creation.ts +++ b/src/renderer/src/store/slices/worktrees/create/pending-worktree-creation.ts @@ -133,15 +133,11 @@ export function createRemovePendingWorktreeCreation( } const cleanup = cleanUpCancelledVm(creationId, removedEntry.request, get) if (removedEntry.status === 'creating' && isOrcaCloudCreateRequest(removedEntry.request)) { - beginOrcaCloudCancelCleanup( - creationId, - cleanup ? [cleanup] : [], - { - runtimeId: removedEntry.request.ephemeralVmRuntimeId, - createStartedAt: removedEntry.startedAt - }, - () => get().openSettingsTarget({ pane: 'servers', repoId: null }) - ) + beginOrcaCloudCancelCleanup(creationId, cleanup ? [cleanup] : [], { + runtimeId: removedEntry.request.ephemeralVmRuntimeId, + createStartedAt: removedEntry.startedAt, + canceledAt: Date.now() + }) } } }