diff --git a/src/main/hosted-sandbox/orca-cloud-sandbox-id.test.ts b/src/main/hosted-sandbox/orca-cloud-sandbox-id.test.ts new file mode 100644 index 00000000000..5a74d61edef --- /dev/null +++ b/src/main/hosted-sandbox/orca-cloud-sandbox-id.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it, vi } from 'vitest' + +const runtimes = vi.hoisted((): { list: unknown[] } => ({ list: [] })) +vi.mock('../../shared/ephemeral-vm-runtime-store', () => ({ + listEphemeralVmRuntimes: () => runtimes.list +})) +vi.mock('../environment-providers/environment-provider-recipe-adapter', () => ({ + environmentHandleFromRecipeResult: (result: { sandboxId?: string } | undefined) => + result?.sandboxId ? { environmentId: result.sandboxId } : null +})) + +const { orcaCloudSandboxIdFor } = await import('./orca-cloud-sandbox-id') + +describe('orcaCloudSandboxIdFor', () => { + it('resolves composer-created cloud workspaces whose recipe has no provider (RA-11)', () => { + runtimes.list = [ + { + runtimeEnvironmentId: 'env-a', + recipe: { id: 'cloud' }, + recipeResult: { sandboxId: 'sbx_a' } + }, + { + runtimeEnvironmentId: 'env-b', + recipe: { id: 'cloud', provider: 'orca-cloud' }, + recipeResult: { sandboxId: 'sbx_b' } + } + ] + expect(orcaCloudSandboxIdFor('/u', 'env-a')).toBe('sbx_a') + expect(orcaCloudSandboxIdFor('/u', 'env-b')).toBe('sbx_b') + }) + + it('never resolves another provider, an unknown runtime, or one without a hosted-sandbox handle', () => { + runtimes.list = [ + { + runtimeEnvironmentId: 'env-c', + recipe: { provider: 'custom' }, + recipeResult: { sandboxId: 'x' } + }, + { runtimeEnvironmentId: 'env-d', recipe: { id: 'cloud' }, recipeResult: {} } + ] + expect(orcaCloudSandboxIdFor('/u', 'env-c')).toBeNull() + expect(orcaCloudSandboxIdFor('/u', 'env-d')).toBeNull() + expect(orcaCloudSandboxIdFor('/u', 'env-zzz')).toBeNull() + }) +}) diff --git a/src/main/hosted-sandbox/orca-cloud-sandbox-id.ts b/src/main/hosted-sandbox/orca-cloud-sandbox-id.ts index d312c200e1a..17e6e98bfe0 100644 --- a/src/main/hosted-sandbox/orca-cloud-sandbox-id.ts +++ b/src/main/hosted-sandbox/orca-cloud-sandbox-id.ts @@ -12,7 +12,9 @@ export function orcaCloudSandboxIdFor( const runtime = listEphemeralVmRuntimes(userDataPath).find( (record) => record.runtimeEnvironmentId === runtimeEnvironmentId && - record.recipe?.provider === 'orca-cloud' + // Composer-created cloud workspaces store the recipe without a provider (like + // cloud-desktop-keys); the hosted-sandbox handle below is what proves it is Orca Cloud. + (record.recipe?.provider === 'orca-cloud' || record.recipe?.provider === undefined) ) const handle = runtime?.recipeResult ? environmentHandleFromRecipeResult(runtime.recipeResult, HOSTED_SANDBOX_DRIVER_ID) diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.fixture.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.fixture.tsx index 5edbf4a35e8..0040d2396f9 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.fixture.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.fixture.tsx @@ -11,6 +11,9 @@ import { type CloudStripActions } from './CloudAgentSignInStrip' import { cloudAgentStripModel } from './cloud-agent-strip-model' +import { cloudRestartAttemptModel, cloudRunningStripModel } from './cloud-running-strip-model' +import type { CloudAgentRestartAttempt } from '@/lib/orca-cloud/cloud-agent-restart-attempt' +import type { CloudRunningStrip } from '@/lib/orca-cloud/cloud-running-agent-signout' const noop = (): void => {} const ACTIONS: CloudStripActions = { @@ -24,29 +27,39 @@ const ACTIONS: CloudStripActions = { const PROMPT = 'Fix the flaky auth test and open a PR' function Pane({ - reason, + reason = 'accountExpired', view = null, agent = 'claude', - width = 900 + width = 900, + running, + restart }: { - reason: CloudAgentStripReason + reason?: CloudAgentStripReason view?: AgentSignInGateView | null agent?: HostAgentSignInAgent width?: number + /** RA-11: the strip over a running agent instead of a held launch. */ + running?: CloudRunningStrip + /** RA-11: a Restart in flight, or one that failed. */ + restart?: CloudAgentRestartAttempt }): React.JSX.Element { - const model = cloudAgentStripModel({ - agent, - reason, - view, - hostLabel: translate('agentSignInStrip.sandbox', 'the sandbox'), - t: translate - }) + const model = restart + ? cloudRestartAttemptModel(restart, translate) + : running + ? cloudRunningStripModel(running, translate) + : cloudAgentStripModel({ + agent, + reason, + view, + hostLabel: translate('agentSignInStrip.sandbox', 'the sandbox'), + t: translate + }) return (
{/* Stands in for a terminal pane: its title row (split, close) stays above the strip. */}
@@ -64,14 +77,21 @@ function Pane({ -
-          ~/acme/web $
-        
+ {/* The terminal: it starts below the strip (reserved, never covered) and keeps its rows. */} +
+ {running ? ( + <> +
⏺ Reading src/auth/session.ts…
+
⏺ API Error: 401 · Not logged in · Run /login
+ + ) : null} +
~/acme/web $
+
) @@ -128,3 +148,37 @@ export const waitingNarrow = fixture({ export const needExpiredNarrow = fixture({ reason: 'accountExpired', width: 520 }) /** Below 360 px: one line and Renew; the detail stays the region's description. */ export const needExpiredCompact = fixture({ reason: 'accountExpired', width: 320 }) + +/** RA-11 state 1: Claude was running when its Orca-account sign-in expired. */ +export const runningExpired = fixture({ running: { phase: 'expired', agent: 'claude' } }) +export const runningExpiredCompact = fixture({ + running: { phase: 'expired', agent: 'claude' }, + width: 320 +}) +/** RA-11 state 2: renewed; this pane's agent still needs a restart (resumes its conversation). */ +export const runningRenewed = fixture({ + running: { phase: 'renewed', agent: 'claude', resumable: true } +}) +/** RA-11 state 2 when the session can't be resumed. */ +export const runningRenewedFresh = fixture({ + running: { phase: 'renewed', agent: 'claude', resumable: false } +}) +export const runningRenewedNarrow = fixture({ + running: { phase: 'renewed', agent: 'claude', resumable: true }, + width: 520 +}) +/** RA-11 after Restart: the strip stays, spinner, button disabled, until the agent reports. */ +export const runningRestarting = fixture({ + restart: { phase: 'restarting', agent: 'claude', resumable: true, ptyId: 'p', launchedAt: null } +}) +/** RA-11: nothing relaunched in time. */ +export const runningRestartFailed = fixture({ + restart: { + phase: 'failed', + agent: 'claude', + resumable: true, + ptyId: 'p', + launchedAt: null, + failure: 'hostUnresponsive' + } +}) diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx index 42db438513f..6773c654d35 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx @@ -23,6 +23,7 @@ import { } from '@/components/ui/dropdown-menu' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' +import { useReservePaneTopSpace } from '../terminal-pane/appearance/pane-top-banner/PaneTopWarningBanner' import type { CloudStripModel, CloudStripPrimary, @@ -69,11 +70,15 @@ function useLiveStripWidth( * buttons stay visible and clickable while it shows (RA-1). The pane and its fixture share it. */ export function CloudStripLayer({ children }: { children: React.ReactNode }): React.JSX.Element { + // A pane-top banner (RA-11): the pane reserves its height and the terminal refits below it, so + // no row sits under the strip. The spacer keeps it below a chromeless pane's title-row buttons. + const ref = useReservePaneTopSpace() return ( -
+
+
{children}
) @@ -237,6 +242,10 @@ export function CloudAgentSignInStrip({ {primary ? (