From 03093cc6f64fa764a9015357542e9202bf2036a7 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 19:43:03 -0800 Subject: [PATCH 1/7] feat(cloud): JA-04 focused Orca Cloud sign-in sheet; no duplicate Orca Cloud host row; account-wide copy Every Orca Cloud 'Set up once' / 'Renew' (composer row, sign-in strip, VM build row, A16 panel) opens one sheet with only Claude and Codex (S0's rows) instead of scrolling Settings past this computer's provider accounts. The Hosts table drops its Orca Cloud row: the page's Orca Cloud part below is the one place for it. 'Set up once on this computer' becomes 'Set up once' (setup is account-wide). --- src/renderer/src/App.tsx | 2 + .../open-agent-host-settings.ts | 5 ++ .../CloudAgentSignInStripPortals.tsx | 5 +- .../new-workspace/OrcaCloudAgentSetupRow.tsx | 8 +- .../agent-accounts/OrcaCloudAccounts.tsx | 4 +- .../overview/AgentAccountsOverviewSection.tsx | 51 ++----------- .../sign-in-sheet/OrcaCloudSignInSheet.tsx | 75 +++++++++++++++++++ .../orca-cloud-sign-in-sheet-store.ts | 37 +++++++++ ...ngs-orca-cloud-agent-accounts-sections.tsx | 4 +- .../VmBuildCloudAgentsRow.tsx | 7 +- src/renderer/src/i18n/locales/en.json | 10 ++- 11 files changed, 146 insertions(+), 62 deletions(-) create mode 100644 src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx create mode 100644 src/renderer/src/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store.ts diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 65d9149536e..873546f3b2b 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -8,6 +8,7 @@ import { BrowserExtensionInstallDialog } from './components/browser-extension-in import { PlansDialogHost } from './components/billing/plans/PlansDialogHost' import { CloudMoveToComputerDialogMount } from './components/orca-cloud/CloudMoveToComputerDialogMount' import { CloudSecretsAskDialogHost } from './components/cloud-secrets-ask/CloudSecretsMissingNotice' +import { OrcaCloudSignInSheet } from './components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet' import { AgentHostPanel } from './components/agent-host-panel/AgentHostPanel' import { SecretRequestUnseenNotifier } from './components/agent-pane/SecretRequestUnseenNotifier' import { TeamDialogHost } from './components/billing/team/TeamDialogHost' @@ -127,6 +128,7 @@ function App(): React.JSX.Element { + diff --git a/src/renderer/src/components/agent-host-panel/open-agent-host-settings.ts b/src/renderer/src/components/agent-host-panel/open-agent-host-settings.ts index 3585214c722..b5634b5bdc2 100644 --- a/src/renderer/src/components/agent-host-panel/open-agent-host-settings.ts +++ b/src/renderer/src/components/agent-host-panel/open-agent-host-settings.ts @@ -1,6 +1,7 @@ // The panel's footer links and row actions open Settings over it; the panel closes first so focus // lands in Settings rather than behind the sheet. import { useAppStore } from '@/store' +import { openOrcaCloudSignInSheet } from '@/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store' import type { AgentHostFooterLink } from './agent-host-capabilities' import { closeAgentHostPanel } from './agent-host-panel-store' @@ -16,6 +17,10 @@ const TARGET = { export function openAgentHostSettings(link: AgentHostFooterLink): void { closeAgentHostPanel() + if (link === 'agentAccounts') { + openOrcaCloudSignInSheet() + return + } const target: { pane: (typeof TARGET)[AgentHostFooterLink]['pane']; sectionId?: string } = TARGET[link] const store = useAppStore.getState() diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStripPortals.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStripPortals.tsx index 7999809739f..24cf1ee152c 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStripPortals.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStripPortals.tsx @@ -2,6 +2,7 @@ // private launch hold waits, or #40228's per-workspace gate while the Orca-account path is paused or // never offered. It overlays the top 56 px of the pane while the agent hasn't started, so the // terminal's size never changes. SSH, WSL and paired hosts keep #40228's card. +import { openOrcaCloudSignInSheet } from '@/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store' import React, { useEffect, useSyncExternalStore } from 'react' import { createPortal } from 'react-dom' import { useAppStore } from '@/store' @@ -51,7 +52,7 @@ export function useCloudGatePaneKeys(controller: TerminalPaneController): Readon return new Set(joined ? joined.split('\u0000') : []) } -function openSettings(pane: 'accounts' | 'cloud-secrets', sectionId?: string): void { +function openSettings(pane: 'cloud-secrets', sectionId?: string): void { const store = useAppStore.getState() store.openSettingsTarget({ pane, repoId: null, ...(sectionId ? { sectionId } : {}) }) store.openSettingsPage() @@ -119,7 +120,7 @@ function CloudStripPortal({ primary: (action) => { switch (action.kind) { case 'renew': - openSettings('accounts', 'orca-cloud') + openOrcaCloudSignInSheet() return case 'signIn': gateActions.signIn() diff --git a/src/renderer/src/components/new-workspace/OrcaCloudAgentSetupRow.tsx b/src/renderer/src/components/new-workspace/OrcaCloudAgentSetupRow.tsx index e3d3b0efcd9..5c0ed699d05 100644 --- a/src/renderer/src/components/new-workspace/OrcaCloudAgentSetupRow.tsx +++ b/src/renderer/src/components/new-workspace/OrcaCloudAgentSetupRow.tsx @@ -2,8 +2,8 @@ // Later" hint: it says how the composer's agent will sign in, links to the one-time setup in // Settings → Agent accounts, and never blocks Start or signs in per sandbox. import { useEffect } from 'react' +import { openOrcaCloudSignInSheet } from '@/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store' import { CircleCheck, CircleDashed, Info, TriangleAlert } from 'lucide-react' -import { useAppStore } from '@/store/index' import { useTranslate, type Translate } from '@/i18n/use-translate' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' @@ -19,11 +19,9 @@ import { noteComposerAgentCoverage } from '@/lib/orca-cloud/cloud-first-start-ag import type { OrcaCloudRunTargetAccess } from './orca-cloud-run-target-access' import { agentName, keySourceLabel } from '../settings/agent-accounts/orca-cloud-accounts-copy' -/** Settings → Agent accounts, scrolled to the Orca Cloud section (S0). The composer stays open. */ +/** The focused Orca Cloud sign-in sheet (JA-04), over the composer, which stays open. */ export function openOrcaCloudAgentAccounts(): void { - useAppStore - .getState() - .openSettingsTarget({ pane: 'accounts', repoId: null, sectionId: 'orca-cloud' }) + openOrcaCloudSignInSheet() } export function orcaCloudAgentCoveredLabel( diff --git a/src/renderer/src/components/settings/agent-accounts/OrcaCloudAccounts.tsx b/src/renderer/src/components/settings/agent-accounts/OrcaCloudAccounts.tsx index 893a54ebcd9..66c70cab1ec 100644 --- a/src/renderer/src/components/settings/agent-accounts/OrcaCloudAccounts.tsx +++ b/src/renderer/src/components/settings/agent-accounts/OrcaCloudAccounts.tsx @@ -153,8 +153,8 @@ export function OrcaCloudAccountsView({ )} diff --git a/src/renderer/src/components/settings/agent-accounts/overview/AgentAccountsOverviewSection.tsx b/src/renderer/src/components/settings/agent-accounts/overview/AgentAccountsOverviewSection.tsx index 362ca159749..74951c2e387 100644 --- a/src/renderer/src/components/settings/agent-accounts/overview/AgentAccountsOverviewSection.tsx +++ b/src/renderer/src/components/settings/agent-accounts/overview/AgentAccountsOverviewSection.tsx @@ -1,11 +1,9 @@ -// Wires S3 to the renderer's host list, the per-host sign-in probes and the Orca account. Rows open -// the A16 panel; the Orca Cloud row scrolls to S0 below (one row stands for every cloud workspace). -import React, { useEffect, useMemo, useState } from 'react' +// Wires S3 to the renderer's host list and the per-host sign-in probes. Rows open the A16 panel. +// No Orca Cloud row (JA-04): the page's own Orca Cloud part right below is the one place for it. +import React, { useMemo } from 'react' import { useAppStore } from '@/store' import { useTranslate } from '@/i18n/use-translate' -import { useOrcaCloudAgentAccounts } from '@/lib/orca-cloud/orca-cloud-agent-accounts-store' import { openAgentHostPanel } from '../../../agent-host-panel/agent-host-panel-store' -import { ORCA_CLOUD_ACCOUNTS_SECTION_ID } from '../OrcaCloudAccounts' import { overviewRows, type OverviewAction, @@ -22,28 +20,6 @@ function openSettings(pane: 'accounts', sectionId?: string): void { store.openSettingsPage() } -/** A member can't change team keys: their key cells say "set by your team". */ -function useIsCloudMember(enabled: boolean): boolean { - const [member, setMember] = useState(false) - useEffect(() => { - if (!enabled) { - return - } - let cancelled = false - void (window.api.cloudSecrets?.effective({}) ?? Promise.resolve(null)) - .catch(() => null) - .then((result) => { - if (!cancelled && result?.ok) { - setMember(!result.value.caller.canWrite.org) - } - }) - return () => { - cancelled = true - } - }, [enabled]) - return member -} - export function AgentAccountsOverviewSection({ hideHeader = false }: { @@ -52,28 +28,11 @@ export function AgentAccountsOverviewSection({ const t = useTranslate() const hosts = useOverviewHosts() const { probes, checkAgain, firstPassDone } = useOverviewProbes(hosts) - const accounts = useOrcaCloudAgentAccounts() - const ready = accounts.load.kind === 'ready' - const member = useIsCloudMember(ready) - const signedOutOfOrca = accounts.load.kind === 'failed' && accounts.load.error === 'signed_out' - const rows = useMemo( - () => - overviewRows({ - hosts, - probes, - cloud: - accounts.load.kind === 'ready' - ? { status: accounts.load.status, keyKinds: accounts.keyKinds, member } - : null - }), - [hosts, probes, accounts.load, accounts.keyKinds, member] - ) + const rows = useMemo(() => overviewRows({ hosts, probes, cloud: null }), [hosts, probes]) const hostById = new Map(hosts.map((host) => [host.hostId, host])) const open = (row: OverviewRow, focus?: 'claude' | 'codex'): void => { const host = row.hostId ? hostById.get(row.hostId) : undefined if (!host) { - // Orca Cloud: S0 below owns setup and the Source for every cloud workspace. - document.getElementById(ORCA_CLOUD_ACCOUNTS_SECTION_ID)?.scrollIntoView({ block: 'start' }) return } openAgentHostPanel({ @@ -111,7 +70,7 @@ export function AgentAccountsOverviewSection({ return ( open(row)} diff --git a/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx new file mode 100644 index 00000000000..67ba6b64dfd --- /dev/null +++ b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx @@ -0,0 +1,75 @@ +// JA-04: the focused Orca Cloud sign-in sheet. Only Claude and Codex, each with its one action and +// status (S0's rows), so "Set up once" never lands on this computer's provider accounts. +import React from 'react' +import { useAppStore } from '@/store' +import { useTranslate } from '@/i18n/use-translate' +import { + Sheet, + SheetContent, + SheetDescription, + SheetHeader, + SheetTitle +} from '@/components/ui/sheet' +import { OrcaCloudAccountsSection } from '../OrcaCloudAccountsSection' +import { + closeOrcaCloudSignInSheet, + useOrcaCloudSignInSheetOpen +} from './orca-cloud-sign-in-sheet-store' + +function openAllAgentAccounts(): void { + closeOrcaCloudSignInSheet() + const store = useAppStore.getState() + store.openSettingsTarget({ pane: 'accounts', repoId: null, sectionId: 'orca-cloud' }) + store.openSettingsPage() +} + +/** The sheet's contents; the host owns the Sheet so fixtures can render it open. */ +export function OrcaCloudSignInSheetView({ + body +}: { + /** S0's rows; fixtures pass a fixed view. */ + body: React.ReactNode +}): React.JSX.Element { + const t = useTranslate() + const titleId = React.useId() + return ( + +
+ + + {t('orcaCloudSignInSheet.title', 'Agents in Orca Cloud')} + + + {t( + 'orcaCloudSignInSheet.description', + 'Set up Claude and Codex once. Every cloud workspace uses them, including new, cloned and restarted ones.' + )} + + +
+
{body}
+ +
+ ) +} + +/** Mounted once in App; opened by openOrcaCloudSignInSheet(). */ +export function OrcaCloudSignInSheet(): React.JSX.Element { + const open = useOrcaCloudSignInSheetOpen() + return ( + !next && closeOrcaCloudSignInSheet()}> + {open ? } /> : null} + + ) +} diff --git a/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store.ts b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store.ts new file mode 100644 index 00000000000..4c5c9c5e1e0 --- /dev/null +++ b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store.ts @@ -0,0 +1,37 @@ +// JA-04: every "Set up once" / "Renew" for Orca Cloud opens one focused sheet (Claude and Codex +// only) instead of Settings, so nobody scrolls past this computer's provider accounts to reach it. +import { useSyncExternalStore } from 'react' + +let open = false +const listeners = new Set<() => void>() + +function set(next: boolean): void { + if (open === next) { + return + } + open = next + for (const listener of listeners) { + listener() + } +} + +export function openOrcaCloudSignInSheet(): void { + set(true) +} + +export function closeOrcaCloudSignInSheet(): void { + set(false) +} + +function subscribe(listener: () => void): () => void { + listeners.add(listener) + return () => listeners.delete(listener) +} + +export function useOrcaCloudSignInSheetOpen(): boolean { + return useSyncExternalStore( + subscribe, + () => open, + () => false + ) +} diff --git a/src/renderer/src/components/settings/page/settings-orca-cloud-agent-accounts-sections.tsx b/src/renderer/src/components/settings/page/settings-orca-cloud-agent-accounts-sections.tsx index 81d7aa181ec..71222c6103b 100644 --- a/src/renderer/src/components/settings/page/settings-orca-cloud-agent-accounts-sections.tsx +++ b/src/renderer/src/components/settings/page/settings-orca-cloud-agent-accounts-sections.tsx @@ -30,8 +30,8 @@ export function orcaCloudAgentAccountsParts( id: 'accounts-orca-cloud', title: t('orcaCloudAccounts.title', 'Orca Cloud'), description: t( - 'orcaCloudAccounts.help', - 'Set up once on this computer. Every cloud workspace uses it, including new, cloned and restarted ones.' + 'orcaCloudAccounts.helpAccountWide', + 'Set up once. Every cloud workspace uses it, including new, cloned and restarted ones.' ), content: } diff --git a/src/renderer/src/components/worktree-creation/cloud-agents-row/VmBuildCloudAgentsRow.tsx b/src/renderer/src/components/worktree-creation/cloud-agents-row/VmBuildCloudAgentsRow.tsx index b61d73246f0..f3694cdc101 100644 --- a/src/renderer/src/components/worktree-creation/cloud-agents-row/VmBuildCloudAgentsRow.tsx +++ b/src/renderer/src/components/worktree-creation/cloud-agents-row/VmBuildCloudAgentsRow.tsx @@ -1,6 +1,7 @@ // Live Agents row for an Orca Cloud build. Reads the Orca account once (shared store with S0 and the // composer), never the sandbox; runs S0's setup inline when nothing is set up (R2), and writes the // per-workspace Source from the ⋯ menu (S1-b). +import { openOrcaCloudSignInSheet } from '@/components/settings/agent-accounts/sign-in-sheet/orca-cloud-sign-in-sheet-store' import React, { useCallback, useEffect, useRef, useState } from 'react' import { toast } from 'sonner' import { useAppStore } from '@/store' @@ -32,7 +33,7 @@ import { VmBuildAgentSignInRow } from '../VmBuildAgentSignInRow' import { VmBuildCloudAgentsMenu, type WorkspaceSourcesLoad } from './VmBuildCloudAgentsMenu' import { VmBuildCloudAgentsRowView, type DesktopKeySave } from './VmBuildCloudAgentsRowView' -function openSettings(pane: 'accounts' | 'cloud-secrets', sectionId?: string): void { +function openSettings(pane: 'cloud-secrets', sectionId?: string): void { const store = useAppStore.getState() store.openSettingsTarget({ pane, repoId: null, ...(sectionId ? { sectionId } : {}) }) store.openSettingsPage() @@ -156,7 +157,7 @@ export function VmBuildCloudAgentsRow({ sources={sources} onOpen={readSources} onChoose={choose} - onManage={() => openSettings('accounts', 'orca-cloud')} + onManage={() => openOrcaCloudSignInSheet()} onUseKey={() => openSettings('cloud-secrets')} /> ) @@ -184,7 +185,7 @@ export function VmBuildCloudAgentsRow({ void api?.acknowledge({ agent }) }, retryLoad: () => void reloadOrcaCloudAgentAccounts(), - manage: () => openSettings('accounts', 'orca-cloud'), + manage: () => openOrcaCloudSignInSheet(), saveDesktopKey: saveKey, signInHere: (agent) => { nextRequest.current += 1 diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index ec448c98c22..1ff4d702bcb 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -27814,7 +27814,6 @@ "signIn": "Sign in", "loadFailed": "Couldn’t load your agent accounts.", "title": "Orca Cloud", - "help": "Set up once on this computer. Every cloud workspace uses it, including new, cloned and restarted ones.", "policy": "Your Claude and ChatGPT accounts are used only in your own workspaces. Teammates never use them.", "codeCopied": "Code copied", "agent": { @@ -27843,7 +27842,8 @@ "unavailableDetail": "Signing in once with your {{product}} account isn’t available in Orca Cloud yet. Each new cloud workspace asks you to sign in.", "allUnavailable": "Claude and Codex sign in for each cloud workspace for now.", "pasteTokenInstead": "Paste a token instead", - "rowMenu": "{{agent}} account options" + "rowMenu": "{{agent}} account options", + "helpAccountWide": "Set up once. Every cloud workspace uses it, including new, cloned and restarted ones." }, "vmBuildAgents": { "menu": { @@ -28086,5 +28086,11 @@ }, "untitled": "New cloud workspace", "waitingBrowser": "Waiting for your browser…" + }, + "orcaCloudSignInSheet": { + "title": "Agents in Orca Cloud", + "description": "Set up Claude and Codex once. Every cloud workspace uses them, including new, cloned and restarted ones.", + "footerLabel": "Related settings", + "allAccounts": "All agent accounts" } } From 042fb4ba0b033fddfc80d86619ef8983f25a9d10 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 19:49:39 -0800 Subject: [PATCH 2/7] fix(cloud): the reconnect card only follows a real wake, retries the attach once quietly, and clears when the pane attaches The wake attach hold armed whenever a wake entry it had seen in flight left the store, not only on main's ready, so a stale, quietly failed or dismissed wake (as around an app restart or a pane's account restart) held the restored pane as Connecting and failed it at 8 s. The card then stayed until Try again even after the pane attached. - Arm only on main's ready for the same wake seen in flight. - At the cap, reconnect the pane once on its own; show the card only after a second cap. - Keep watching while the card shows and clear it once the pane attaches (restore, account restart, wake). - Try again still re-runs the pane's attach, not a wake. --- .../orca-cloud/use-wake-attach-hold.test.tsx | 74 +++++++++++++++++-- .../orca-cloud/use-wake-attach-hold.ts | 51 +++++++++---- 2 files changed, 103 insertions(+), 22 deletions(-) diff --git a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx index b806794454b..6acb5bc94e0 100644 --- a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx +++ b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx @@ -23,6 +23,7 @@ const waking: CloudWakeProgressEvent = { startedAt: T0 - 5_000, at: T0 } +const PAST_CAP = WAKE_ATTACH_HOLD_MAX_MS + WAKE_ATTACH_POLL_MS const start: { wake: CloudWakeProgressEvent | undefined } = { wake: waking } beforeEach(() => { @@ -99,18 +100,31 @@ describe('useWakeAttachHold', () => { expect(result.current.wake).toBeUndefined() }) - it('a pane that never takes input becomes "Couldn’t reconnect the terminal"; Try again reconnects it', () => { + it('at the cap reconnects the pane once on its own, and only then shows the card', () => { + const retry = vi.fn(() => true) + const { result, rerender } = hook(() => false, retry) + rerender({ wake: { ...waking, phase: 'ready' } }) + expect(result.current.wake?.phase).toBe('connecting') + act(() => vi.advanceTimersByTime(PAST_CAP)) + // The quiet retry: still Connecting…, no card yet. + expect(retry).toHaveBeenCalledTimes(1) + expect(result.current.terminalStalled).toBe(false) + expect(result.current.wake?.phase).toBe('connecting') + act(() => vi.advanceTimersByTime(PAST_CAP)) + expect(retry).toHaveBeenCalledTimes(1) + expect(result.current.terminalStalled).toBe(true) + expect(result.current.wake?.phase).toBe('failed') + }) + + it('Try again re-runs the attach (not a wake) and waits for the pane once more', () => { let attached: boolean | null = false const retry = vi.fn(() => true) const { result, rerender } = hook(() => attached, retry) rerender({ wake: { ...waking, phase: 'ready' } }) - expect(result.current.wake?.phase).toBe('connecting') - act(() => vi.advanceTimersByTime(WAKE_ATTACH_HOLD_MAX_MS + WAKE_ATTACH_POLL_MS)) + act(() => vi.advanceTimersByTime(PAST_CAP * 2)) expect(result.current.terminalStalled).toBe(true) - expect(result.current.wake?.phase).toBe('failed') - // Try again: the pane reconnects and the pill waits for it once more. act(() => result.current.retry()) - expect(retry).toHaveBeenCalledWith('ws') + expect(retry).toHaveBeenLastCalledWith('ws') expect(result.current.terminalStalled).toBe(false) expect(result.current.wake?.phase).toBe('connecting') attached = true @@ -118,6 +132,48 @@ describe('useWakeAttachHold', () => { expect(result.current.wake).toBeUndefined() }) + it('the card clears by itself once the pane attaches through any path', () => { + let attached: boolean | null = false + const retry = vi.fn(() => true) + const { result, rerender } = hook(() => attached, retry) + rerender({ wake: { ...waking, phase: 'ready' } }) + act(() => vi.advanceTimersByTime(PAST_CAP * 2)) + expect(result.current.terminalStalled).toBe(true) + // A restore or account restart brings the pane back; nobody pressed Try again. + attached = true + act(() => vi.advanceTimersByTime(WAKE_ATTACH_POLL_MS)) + expect(result.current.terminalStalled).toBe(false) + expect(result.current.wake).toBeUndefined() + expect(retry).toHaveBeenCalledTimes(1) + }) + + it('a restart with no wake in flight never shows the card', () => { + const retry = vi.fn(() => true) + const { result } = renderHook(() => useWakeAttachHold('ws', undefined, () => false, retry)) + // The restored pane takes its time to attach; no wake, so nothing holds or fails over it. + act(() => vi.advanceTimersByTime(PAST_CAP * 3)) + expect(result.current.wake).toBeUndefined() + expect(result.current.terminalStalled).toBe(false) + expect(retry).not.toHaveBeenCalled() + }) + + it('an account restart (no wake ready from main) never shows the card', () => { + const retry = vi.fn(() => true) + const { result, rerender } = hook(() => false, retry) + // A wake entry that never settles through main goes away (stale, quiet failure, Dismiss) + // while the pane respawns for its new account: no hold, no card. + rerender({ wake: undefined }) + act(() => vi.advanceTimersByTime(PAST_CAP * 3)) + expect(result.current.wake).toBeUndefined() + expect(result.current.terminalStalled).toBe(false) + // Nor a `ready` from a different wake than the one seen in flight. + rerender({ wake: { ...waking, startedAt: T0 } }) + rerender({ wake: { ...waking, startedAt: T0 + 1, phase: 'ready' } }) + act(() => vi.advanceTimersByTime(PAST_CAP * 3)) + expect(result.current.wake).toBeUndefined() + expect(retry).not.toHaveBeenCalled() + }) + it('counts only visible time toward the reconnect cap', () => { let visibility: DocumentVisibilityState = 'visible' const descriptor = Object.getOwnPropertyDescriptor(document, 'visibilityState') @@ -142,6 +198,9 @@ describe('useWakeAttachHold', () => { act(() => vi.advanceTimersByTime(WAKE_ATTACH_HOLD_MAX_MS / 2 - WAKE_ATTACH_POLL_MS * 2)) expect(result.current.terminalStalled).toBe(false) act(() => vi.advanceTimersByTime(WAKE_ATTACH_POLL_MS * 3)) + // The cap's quiet reconnect, counted in visible time too; the card waits one more cap. + expect(result.current.terminalStalled).toBe(false) + act(() => vi.advanceTimersByTime(PAST_CAP)) expect(result.current.terminalStalled).toBe(true) } finally { if (descriptor) { @@ -155,7 +214,8 @@ describe('useWakeAttachHold', () => { it('Dismiss clears the reconnect card', () => { const { result, rerender } = hook(() => false) rerender({ wake: { ...waking, phase: 'ready' } }) - act(() => vi.advanceTimersByTime(WAKE_ATTACH_HOLD_MAX_MS + WAKE_ATTACH_POLL_MS)) + act(() => vi.advanceTimersByTime(PAST_CAP * 2)) + expect(result.current.terminalStalled).toBe(true) act(() => result.current.dismiss()) expect(result.current.wake).toBeUndefined() }) diff --git a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts index b2578c9ef83..aec9abdd74a 100644 --- a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts +++ b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts @@ -8,7 +8,7 @@ import type { CloudWakeProgressEvent } from '../../../../shared/hosted-sandbox/c /** How often the hold checks the pane in front while it waits. */ export const WAKE_ATTACH_POLL_MS = 100 -/** A pane that hasn't re-attached by now gets the "Couldn't reconnect the terminal" card. */ +/** A pane that hasn't re-attached by now is reconnected once; after a second cap it gets the card. */ export const WAKE_ATTACH_HOLD_MAX_MS = 8_000 type Track = { @@ -38,8 +38,11 @@ export type WakeAttachHold = { * A wake reports ready once the server answers; the pane in front re-attaches to its terminal a * moment later. Until it takes input (attached, with nothing it was given still unsent), this * returns the wake as still `connecting` (same start time and source, so the pill keeps counting - * from the wake's start). A pane that hasn't by the cap becomes a failed card with Try again, - * never a silent dead pane. Then `undefined` hands back to the store's wake. + * from the wake's start). A pane that hasn't by the cap is reconnected once quietly; one that + * still hasn't by the next cap becomes a failed card with Try again (re-runs the attach), never a + * silent dead pane, and the card clears itself if the pane attaches after all. Only main's `ready` + * for a wake seen in flight arms this: a restart or an account restart with no wake never does. + * Then `undefined` hands back to the store's wake. */ export function useWakeAttachHold( workspaceId: string, @@ -65,43 +68,61 @@ export function useWakeAttachHold( if (track.last || track.held || track.stalled) { setTrack({ ...IDLE, attempt: track.attempt }) } - } else if (track.last && (!wake || wake.startedAt === track.last.startedAt)) { - // Ready, or the settled entry already dropped: hold only a wake that was in flight here. + } else if (track.last) { + // Only main's own `ready` for the wake seen in flight here holds the pane. An entry that just + // goes away (a stale or quietly failed wake dropped by the store, a Dismiss) never does: no + // wake brought the pane back, so there is nothing to wait for. + const settled = wake?.phase === 'ready' && wake.startedAt === track.last.startedAt const held = - isAttached(workspaceId) === false + settled && isAttached(workspaceId) === false ? { ...track.last, phase: 'connecting' as const } : undefined setTrack({ ...IDLE, attempt: track.attempt + 1, held }) } - // Release once the pane takes input; at the cap, fail visibly. The store dropping the settled - // wake doesn't cancel this: it is keyed on the hold only. - const holding = track.held !== undefined + // Release once the pane takes input; at the cap, reconnect it once quietly, then fail visibly. + // The card keeps watching too: a pane that attaches later (restore, account restart, a slow + // wake) clears it on its own. The store dropping the settled wake doesn't cancel this. + const waiting = track.held !== undefined || track.stalled !== undefined const attempt = track.attempt useEffect(() => { - if (!holding) { + if (!waiting) { return } // Only visible time counts toward the cap: a hidden window pauses this poll (and the pane's // own re-attach), so time spent hidden must not turn a healthy wake into a stalled card. let visibleMs = 0 let lastAt = Date.now() + let quietRetryDone = false + let shownStalled = false const check = (): void => { const attached = isAttached(workspaceId) - if (attached === false && visibleMs < WAKE_ATTACH_HOLD_MAX_MS) { + if (attached === false && (shownStalled || visibleMs < WAKE_ATTACH_HOLD_MAX_MS)) { return } + if (attached === false && !quietRetryDone) { + // One reconnect on its own before the card: a pane whose attach got lost usually comes + // back from this, and the person never sees a failure for it. + quietRetryDone = true + visibleMs = 0 + retryPane(workspaceId) + return + } + shownStalled = attached === false setTrack((current) => { - if (current.attempt !== attempt || !current.held) { + if (current.attempt !== attempt || (!current.held && !current.stalled)) { return current } - return attached === false + if (attached !== false) { + return { ...current, held: undefined, stalled: undefined } + } + return current.held ? { ...current, held: undefined, stalled: { ...current.held, phase: 'failed', at: Date.now() } } - : { ...current, held: undefined } + : current }) } return installWindowVisibilityInterval({ @@ -118,7 +139,7 @@ export function useWakeAttachHold( }, intervalMs: WAKE_ATTACH_POLL_MS }) - }, [holding, attempt, workspaceId, isAttached]) + }, [waiting, attempt, workspaceId, isAttached, retryPane]) const retry = useCallback(() => { retryPane(workspaceId) From bd6cd6e7f82915c0a8bdeb2d2a864c3e1a712e8d Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:11:12 -0800 Subject: [PATCH 3/7] feat(cloud): JA-04 sheet 600px wide; sidebar row 'Set up once' opens the sheet too --- .../src/components/orca-cloud/CloudAgentRowSignInTarget.tsx | 4 +--- .../agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/components/orca-cloud/CloudAgentRowSignInTarget.tsx b/src/renderer/src/components/orca-cloud/CloudAgentRowSignInTarget.tsx index daba491c714..03c6030286a 100644 --- a/src/renderer/src/components/orca-cloud/CloudAgentRowSignInTarget.tsx +++ b/src/renderer/src/components/orca-cloud/CloudAgentRowSignInTarget.tsx @@ -1,7 +1,6 @@ // The status (dot and text) of a cloud agent row that needs sign-in: clicking it opens // Settings → Agent accounts, where the fix lives. The rest of the row still opens the pane. import React, { useCallback } from 'react' -import { useAppStore } from '@/store' import { cn } from '@/lib/utils' import { AgentStateDot } from '@/components/AgentStateDot' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' @@ -11,10 +10,9 @@ import { openOrcaCloudAgentAccounts } from '@/components/new-workspace/OrcaCloud /** What the status shows: its label, the agent's catalog name, and the tooltip naming the fix. */ export type CloudAgentRowStatusText = { label: string; agentName: string; tooltip: string | null } -/** The composer's "Set up once" target, plus opening Settings, which the sidebar has closed. */ +/** The sidebar row's "Set up once": the focused Orca Cloud sign-in sheet (JA-04). */ export function openCloudAgentAccountsSettings(): void { openOrcaCloudAgentAccounts() - useAppStore.getState().openSettingsPage() } /** diff --git a/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx index 67ba6b64dfd..ebec6ee976d 100644 --- a/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx +++ b/src/renderer/src/components/settings/agent-accounts/sign-in-sheet/OrcaCloudSignInSheet.tsx @@ -33,7 +33,7 @@ export function OrcaCloudSignInSheetView({ const t = useTranslate() const titleId = React.useId() return ( - +
From 27c2dbcbec6eee3d915f9d1201d892cee8ad68c8 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:28:47 -0800 Subject: [PATCH 4/7] feat(cloud): env-check follow-up: no blank before the terminal, no setup nudge in cloud, notices bottom-right, one title on failure cards, Couldn't open row --- .../src/app-shell/AppWorkspaceShell.tsx | 4 + .../orca-cloud/CloudSetupNotices.tsx | 14 ++- .../orca-cloud/OrcaCloudWorkspaceSurface.tsx | 9 +- .../sidebar/SetupScriptPromptCard.tsx | 12 ++ .../worktree-creation/CloudOpenCoverBody.tsx | 44 +++++++ .../worktree-creation/CloudOpenCoverLayer.tsx | 80 +++++++++++++ .../worktree-creation/VmBuildSheet.tsx | 89 +++++++------- .../WorktreeCreationPanel.tsx | 8 ++ src/renderer/src/i18n/locales/en.json | 4 +- .../ephemeral-vm-worktree-creation.test.ts | 113 ++++++++++++++++++ .../orca-cloud/cloud-open-cover-store.test.ts | 36 ++++++ .../lib/orca-cloud/cloud-open-cover-store.ts | 73 +++++++++++ .../creation/pending-worktree-creation.ts | 6 + .../creation/worktree-creation-completion.ts | 11 ++ 14 files changed, 453 insertions(+), 50 deletions(-) create mode 100644 src/renderer/src/components/worktree-creation/CloudOpenCoverBody.tsx create mode 100644 src/renderer/src/components/worktree-creation/CloudOpenCoverLayer.tsx create mode 100644 src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts create mode 100644 src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts create mode 100644 src/renderer/src/lib/orca-cloud/cloud-open-cover-store.ts diff --git a/src/renderer/src/app-shell/AppWorkspaceShell.tsx b/src/renderer/src/app-shell/AppWorkspaceShell.tsx index cddedd2a414..3b58c35221f 100644 --- a/src/renderer/src/app-shell/AppWorkspaceShell.tsx +++ b/src/renderer/src/app-shell/AppWorkspaceShell.tsx @@ -11,6 +11,7 @@ import { FloatingTerminalToggleButton } from '../components/floating-terminal/Fl import { TerminalWorkbenchContainer } from '../components/TerminalWorkbenchContainer' import { WorkspaceLowDiskBanner } from '../components/low-disk/WorkspaceLowDiskBanner' import { CloudSetupPageLayer } from '../components/orca-cloud-setup/CloudSetupPageLayer' +import { CloudOpenCoverLayer } from '../components/worktree-creation/CloudOpenCoverLayer' import type { VirtualizedScrollAnchor } from '../hooks/useVirtualizedScrollAnchor' import { TitlebarLeftControls } from './TitlebarLeftControls' import { RightSidebarToggle, TitlebarMainStrip } from './TitlebarMainStrip' @@ -248,6 +249,9 @@ export function AppWorkspaceShell(props: {
+ {floatingWorkspace.showToggleButton && !capturingPluginShot ? ( + + + ) +} + export function CloudSetupNoticesView({ record, notices, @@ -207,7 +219,7 @@ export function CloudSetupNoticesView({ role="status" aria-labelledby={labelId} data-cloud-notice="setup" - className="pointer-events-auto w-[26rem] max-w-[calc(100%-1.5rem)] rounded-lg border border-border bg-card text-card-foreground shadow-[0_8px_24px_rgba(0,0,0,0.12)] dark:shadow-[0_8px_24px_rgba(0,0,0,0.4)] motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1" + className="pointer-events-auto w-[26rem] max-w-[calc(100%-1.5rem)] rounded-lg border border-border bg-card text-card-foreground shadow-[0_8px_24px_rgba(0,0,0,0.12)] dark:shadow-[0_8px_24px_rgba(0,0,0,0.4)] motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1" >

{t('orcaCloud.setupNotices.label', 'Workspace setup')} diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx index f2223d64523..6d86e12acc1 100644 --- a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx +++ b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx @@ -22,7 +22,7 @@ import type { CloudWakeProgressEvent } from '../../../../shared/hosted-sandbox/c import { CloudArchivedWorkspaceView, type ArchiveLoad } from './CloudArchivedWorkspaceView' import { CloudWakingOverlay } from './CloudWakingOverlay' import { CloudWorkspaceNotice } from './CloudWorkspaceNotice' -import { CloudSetupNotices } from './CloudSetupNotices' +import { CloudSetupNoticesDock } from './CloudSetupNotices' import { useConfirmedRestart } from './use-cloud-panel-actions' import { useCloudVersionSkewNotice } from './use-cloud-version-skew-notice' import { CloudWorkspaceOfflineView } from './offline/CloudWorkspaceOfflineView' @@ -339,10 +339,8 @@ function CloudSurface({ workspaceId }: { workspaceId: string }): React.JSX.Eleme if (layer === null && versionSkewNotice) { notices.push(versionSkewNotice) } - if (layer === null && view.state !== 'sleeping' && view.state !== 'archived') { - // What the environment check found that didn't need to stop the create (env-check-ux). - notices.push() - } + // What the environment check found that didn't need to stop the create (env-check-ux). + const showSetupNotices = layer === null && view.state !== 'sleeping' && view.state !== 'archived' if (layer === null && view.oom) { notices.push( ) : null} + {showSetupNotices ? : null} {notices.length > 0 ? (
{} + +/** The creation panel's last frame, laid out exactly like WorktreeCreationPanel. */ +export default function CloudOpenCoverBody({ + cover, + now, + reserveCollapsedSidebarHeaderSpace +}: { + cover: CloudOpenCover + now: number + reserveCollapsedSidebarHeaderSpace: boolean +}): React.JSX.Element { + const { entry } = cover + return ( +
+ + {/* A picture of the last frame: nothing in it is interactive. */} +
+ +
+
+ ) +} diff --git a/src/renderer/src/components/worktree-creation/CloudOpenCoverLayer.tsx b/src/renderer/src/components/worktree-creation/CloudOpenCoverLayer.tsx new file mode 100644 index 00000000000..5d8808e91d8 --- /dev/null +++ b/src/renderer/src/components/worktree-creation/CloudOpenCoverLayer.tsx @@ -0,0 +1,80 @@ +import React, { useEffect, useSyncExternalStore } from 'react' +import { useAppStore } from '@/store' +import { useNow } from '@/hooks/use-now' +import { + CLOUD_OPEN_COVER_MAX_MS, + releaseCloudOpenCover, + useCloudOpenCover, + workspaceHasAttachedPty +} from '@/lib/orca-cloud/cloud-open-cover-store' +import type CloudOpenCoverBodyComponent from './CloudOpenCoverBody' + +// The body pulls in the build sheet, which the shell must not load at boot. The creation panel +// preloads it, so it is ready (no Suspense frame) by the time a create hands over. +let Body: typeof CloudOpenCoverBodyComponent | null = null +let loading: Promise | null = null +const bodyListeners = new Set<() => void>() + +export function preloadCloudOpenCover(): Promise { + loading ??= import('./CloudOpenCoverBody') + .then((module) => { + Body = module.default + for (const listener of bodyListeners) { + listener() + } + }) + .catch(() => { + loading = null + }) + return loading +} + +function useBody(): typeof CloudOpenCoverBodyComponent | null { + return useSyncExternalStore( + (listener) => { + bodyListeners.add(listener) + return () => bodyListeners.delete(listener) + }, + () => Body + ) +} + +/** + * Keeps the Orca Cloud start screen over a just-created workspace until its terminal's PTY is + * attached (JA-12), so "Open workspace" goes straight to a live prompt with no blank pane between. + */ +export function CloudOpenCoverLayer({ + reserveCollapsedSidebarHeaderSpace +}: { + reserveCollapsedSidebarHeaderSpace: boolean +}): React.JSX.Element | null { + const worktreeId = useAppStore((s) => (s.activeView === 'terminal' ? s.activeWorktreeId : null)) + const cover = useCloudOpenCover(worktreeId) + const attached = useAppStore((s) => + cover ? workspaceHasAttachedPty(s, cover.worktreeId) : false + ) + const BodyComponent = useBody() + const now = useNow(1_000, cover !== null) + useEffect(() => { + if (!cover) { + return + } + if (attached) { + releaseCloudOpenCover(cover.worktreeId) + return + } + void preloadCloudOpenCover() + const left = Math.max(0, cover.heldAt + CLOUD_OPEN_COVER_MAX_MS - Date.now()) + const timer = window.setTimeout(() => releaseCloudOpenCover(cover.worktreeId), left) + return () => window.clearTimeout(timer) + }, [attached, cover]) + if (!cover || attached || !BodyComponent) { + return null + } + // The body is a module-level component loaded once, not one made during render. + return React.createElement(BodyComponent, { + cover, + now: Math.max(now, cover.heldAt), + reserveCollapsedSidebarHeaderSpace + }) +} diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx index e30da2a0085..4efc743720e 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx @@ -187,51 +187,54 @@ export function VmBuildSheet({ return (
-
-
- - {building ? ( - - ) : state === 'ready' ? ( - - ) : gated ? ( - - ) : ( - + {/* JA-24: on Orca Cloud a failure card carries the one title; no page title above it. */} + {cloud && failure ? null : ( +
+
+ + {building ? ( + + ) : state === 'ready' ? ( + + ) : gated ? ( + + ) : ( + + )} + + {/* Retry lands focus here once the failure card collapses. The card announces failures. */} +

+ {headerTitle(state, cloud, t, failure?.kind === 'create')} +

+ {/* Orca Cloud: each step carries its own timer, so the header has none. */} + {gated || cloud ? null : ( + {elapsedLabel} )} - - {/* Retry lands focus here once the failure card collapses. The card announces failures. */} -

- {headerTitle(state, cloud, t, failure?.kind === 'create')} -

- {/* Orca Cloud: each step carries its own timer, so the header has none. */} - {gated || cloud ? null : ( - {elapsedLabel} - )} +
+ {building ? ( + + ) : null}
- {building ? ( - - ) : null} -
+ )}
{/* An account refusal happens before anything starts, so there are no steps to show. */} diff --git a/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx b/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx index e5770626f92..056300b2d23 100644 --- a/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx +++ b/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx @@ -16,6 +16,7 @@ import { } from './worktree-creation-clock' import { VmBuildSheet } from './VmBuildSheet' import { VmDeleteConfirmDialog } from './VmDeleteConfirmDialog' +import { preloadCloudOpenCover } from './CloudOpenCoverLayer' import { composerDataFromRefusedCreate } from './vm-build-composer-return' /** Debounced in-frame creation placeholder: tab strip names the workspace while body shows status, enabling same-frame handoff without duplicating labels. */ @@ -35,6 +36,13 @@ export default function WorktreeCreationPanel({ const now = useWorktreeCreationClock( entry?.status === 'creating' && entry.waitingSince === undefined ) + const cloudCreate = entry?.request.ephemeralVmRecipe?.provider === 'orca-cloud' + React.useEffect(() => { + // The open cover takes over from this panel when the create finishes (JA-12). + if (cloudCreate) { + void preloadCloudOpenCover() + } + }, [cloudCreate]) if (!entry) { return null } diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 0d1e058e6ce..c7b3c5dba1a 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -2290,7 +2290,9 @@ "preparingCloudEnvironment": "Preparing environment…", "startingSandbox": "Starting sandbox…", "cloningRepository": "Cloning the repository…", - "updatingRepository": "Updating the repository…" + "updatingRepository": "Updating the repository…", + "cloudBlockedAsleep": "Asleep", + "cloudCouldNotOpen": "Couldn’t open" }, "duplicatePairedServers": { "ambiguousSameServer": "{{value0}} and {{value1}} are the same server paired twice. Remove one in Settings > Remote Orca Servers." diff --git a/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts b/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts new file mode 100644 index 00000000000..f94f1ffff1e --- /dev/null +++ b/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts @@ -0,0 +1,113 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +// JA-01 tail: Delete sandbox on a create stopped by its environment check must delete THAT sandbox +// (its runtime, hence its control-plane record), and the restart path must delete it before retrying. + +const { state, gate, cleanup, retry } = vi.hoisted(() => { + const entries: Record> = {} + return { + state: { + entries, + repos: [ + { + id: 'repo-src', + displayName: 'Hello-World', + gitRemoteIdentity: { remoteUrl: 'https://github.com/octocat/Hello-World.git' } + } + ] + }, + gate: vi.fn(), + cleanup: vi.fn(async () => true), + retry: vi.fn() + } +}) + +vi.mock('@/store', () => ({ + useAppStore: { + getState: () => ({ + pendingWorktreeCreations: state.entries, + repos: state.repos, + projects: [], + activePendingCreationId: 'c1', + updatePendingWorktreeCreation: (id: string, patch: Record) => { + if (state.entries[id]) { + Object.assign(state.entries[id], patch) + } + }, + setRuntimeEnvironments: vi.fn(), + setupProjectExistingFolder: vi.fn(), + deleteProjectHostSetup: vi.fn() + }) + } +})) +vi.mock('sonner', () => ({ toast: { error: vi.fn(), warning: vi.fn() } })) +vi.mock('@/lib/ephemeral-vm-environment-check', () => ({ gateVmCreateOnEnvironmentCheck: gate })) +vi.mock('@/lib/ephemeral-vm-failed-create-cleanup', () => ({ + cleanupFailedEphemeralVmWorkspace: cleanup +})) +vi.mock('@/lib/vm-create-hidden-checkouts', () => ({ + hideVmCreateCheckout: vi.fn(), + settleVmCreateCheckoutAfterCleanup: vi.fn() +})) +vi.mock('@/lib/workspace/creation/worktree-creation-flow', () => ({ + retryBackgroundWorktreeCreation: retry +})) +vi.mock('@/lib/ephemeral-vm-workspace-target', () => ({ + prepareEphemeralVmWorkspaceTarget: vi.fn(async () => ({ + ok: true, + setup: { + repo: { id: 'repo-vm', path: '/vercel/orca/workspaces/Hello-World/project' }, + setup: { id: 'setup-1', projectId: 'p1', hostId: 'runtime:env-1' } + }, + runtimeId: 'rt-blocked', + checkoutMode: 'provisioned-root', + environmentId: 'env-1', + stderr: '', + warnings: [] + })) +})) + +import { prepareRequestForCreate } from './ephemeral-vm-worktree-creation' +import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation' + +// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the create path reads only these fields. +const request = { + name: 'elephantfish', + setupDecision: 'inherit', + ephemeralVmRecipe: { + sourceRepoId: 'repo-src', + recipeId: 'cloud', + projectId: 'p1', + checkoutMode: 'provisioned-root', + provider: 'orca-cloud' + } +} as unknown as WorktreeCreationRequest + +describe('prepareRequestForCreate on a create stopped by its environment check', () => { + beforeEach(() => { + state.entries.c1 = { request } + vi.stubGlobal('window', { + api: { ephemeralVm: {}, runtimeEnvironments: { list: async () => [] } } + }) + }) + afterEach(() => { + vi.unstubAllGlobals() + vi.clearAllMocks() + }) + + it('Delete sandbox removes that very sandbox and creates nothing', async () => { + gate.mockResolvedValue('stop') + await expect(prepareRequestForCreate('c1', request)).resolves.toBeNull() + expect(cleanup).toHaveBeenCalledOnce() + expect(cleanup.mock.calls[0][0]).toMatchObject({ ephemeralVmRuntimeId: 'rt-blocked' }) + expect(retry).not.toHaveBeenCalled() + }) + + it('Start again deletes the blocked sandbox before starting a new one', async () => { + gate.mockResolvedValue('restart') + await expect(prepareRequestForCreate('c1', request)).resolves.toBeNull() + expect(cleanup.mock.calls[0][0]).toMatchObject({ ephemeralVmRuntimeId: 'rt-blocked' }) + expect(retry).toHaveBeenCalledWith('c1') + expect(cleanup.mock.invocationCallOrder[0]).toBeLessThan(retry.mock.invocationCallOrder[0]) + }) +}) diff --git a/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts new file mode 100644 index 00000000000..83b6cac5ee9 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts @@ -0,0 +1,36 @@ +import { afterEach, describe, expect, it } from 'vitest' +import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation' +import { + getCloudOpenCover, + holdCloudOpenCover, + releaseCloudOpenCover, + resetCloudOpenCovers, + workspaceHasAttachedPty +} from './cloud-open-cover-store' + +// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the store only keeps the entry. +const entry = { creationId: 'c1' } as PendingWorktreeCreation + +afterEach(resetCloudOpenCovers) + +describe('cloud open cover', () => { + it('holds the start screen for one workspace until released', () => { + holdCloudOpenCover('w1', entry, 1_000) + expect(getCloudOpenCover('w1')).toMatchObject({ worktreeId: 'w1', heldAt: 1_000 }) + expect(getCloudOpenCover('w2')).toBeNull() + releaseCloudOpenCover('w1') + expect(getCloudOpenCover('w1')).toBeNull() + }) + + it('counts the workspace as open only once one of its terminals has a PTY', () => { + const state = { + tabsByWorktree: { w1: [{ id: 't1' }, { id: 't2' }] }, + ptyIdsByTabId: { t1: [] as string[] } + } + expect(workspaceHasAttachedPty(state, 'w1')).toBe(false) + expect( + workspaceHasAttachedPty({ ...state, ptyIdsByTabId: { t1: [], t2: ['pty-1'] } }, 'w1') + ).toBe(true) + expect(workspaceHasAttachedPty(state, 'missing')).toBe(false) + }) +}) diff --git a/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.ts b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.ts new file mode 100644 index 00000000000..d170d38e3e1 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.ts @@ -0,0 +1,73 @@ +// JA-12: a just-created Orca Cloud workspace showed a blank pane for ~1 s between the start screen +// and its terminal (the create finishes, then the terminal's PTY attaches over the network). The +// start screen's last frame stays up over the new workspace until its PTY is attached, or a cap. +import { useSyncExternalStore } from 'react' +import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation' + +/** Never cover longer than this: a terminal that is slow to attach shows its own state. */ +export const CLOUD_OPEN_COVER_MAX_MS = 6_000 + +export type CloudOpenCover = { + worktreeId: string + /** The start screen as it was when the create finished ("Open workspace" running). */ + entry: PendingWorktreeCreation + heldAt: number +} + +let covers: Readonly> = {} +const listeners = new Set<() => void>() + +function emit(next: Readonly>): void { + covers = next + for (const listener of listeners) { + listener() + } +} + +export function holdCloudOpenCover( + worktreeId: string, + entry: PendingWorktreeCreation, + now = Date.now() +): void { + emit({ ...covers, [worktreeId]: { worktreeId, entry, heldAt: now } }) +} + +export function releaseCloudOpenCover(worktreeId: string): void { + if (!covers[worktreeId]) { + return + } + const { [worktreeId]: _released, ...rest } = covers + emit(rest) +} + +export function getCloudOpenCover(worktreeId: string | null): CloudOpenCover | null { + return worktreeId ? (covers[worktreeId] ?? null) : null +} + +export function useCloudOpenCover(worktreeId: string | null): CloudOpenCover | null { + return useSyncExternalStore( + (listener) => { + listeners.add(listener) + return () => listeners.delete(listener) + }, + () => getCloudOpenCover(worktreeId) + ) +} + +/** True once any terminal of the workspace has a PTY attached. */ +export function workspaceHasAttachedPty( + state: { + tabsByWorktree: Readonly> + ptyIdsByTabId: Readonly> + }, + worktreeId: string +): boolean { + return (state.tabsByWorktree[worktreeId] ?? []).some( + (tab) => (state.ptyIdsByTabId[tab.id]?.length ?? 0) > 0 + ) +} + +/** Test seam. */ +export function resetCloudOpenCovers(): void { + emit({}) +} diff --git a/src/renderer/src/lib/workspace/creation/pending-worktree-creation.ts b/src/renderer/src/lib/workspace/creation/pending-worktree-creation.ts index e0857e3bf00..5bdd5cb0571 100644 --- a/src/renderer/src/lib/workspace/creation/pending-worktree-creation.ts +++ b/src/renderer/src/lib/workspace/creation/pending-worktree-creation.ts @@ -323,6 +323,12 @@ export function getCreationProgressLabel( } if (entry.phase === 'provisioning-vm') { if (entry.environmentCheck?.status === 'failed') { + // Orca Cloud stops only on an unusable sandbox; the row says what the card says. + if (entry.request.ephemeralVmRecipe?.provider === 'orca-cloud') { + return entry.environmentCheck.sandbox === 'asleep' + ? t('auto.lib.pendingWorktreeCreation.cloudBlockedAsleep', 'Asleep') + : t('auto.lib.pendingWorktreeCreation.cloudCouldNotOpen', 'Couldn’t open') + } return t('auto.lib.pendingWorktreeCreation.vmChecksFailed', 'Environment checks failed') } // Glossary: an Orca Cloud machine is a sandbox; "VM" stays only for bring-your-own recipes. diff --git a/src/renderer/src/lib/workspace/creation/worktree-creation-completion.ts b/src/renderer/src/lib/workspace/creation/worktree-creation-completion.ts index 87579aeeca0..4fb4bf1f71f 100644 --- a/src/renderer/src/lib/workspace/creation/worktree-creation-completion.ts +++ b/src/renderer/src/lib/workspace/creation/worktree-creation-completion.ts @@ -2,6 +2,7 @@ import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-ag import { parseExecutionHostId } from '../../../../../shared/execution-host' import { runtimeEnvironmentIdOrLocalUnlessTwin } from '@/lib/workspace/ownership/worktree-runtime-owner' import { useAppStore } from '@/store/index' +import { holdCloudOpenCover } from '@/lib/orca-cloud/cloud-open-cover-store' import { ensureAgentStartupInTerminal } from '@/lib/new-workspace' import { queueWorkspaceActivationTerminalFocus } from '@/lib/workspace/activation/workspace-activation-terminal-focus' import { seedAgentTabStateAfterWorktreeCreate } from '@/lib/workspace/creation/worktree-creation-agent-seeds' @@ -23,6 +24,16 @@ export async function completeWorktreeCreation(args: { focusOnCompletion: boolean }): Promise { const { request } = args + // Orca Cloud: the start screen stays over the new workspace until its PTY attaches (JA-12). + const pending = useAppStore.getState().pendingWorktreeCreations[args.creationId] + if ( + pending && + args.focusOnCompletion && + !args.structuredLaunchAccepted && + request.ephemeralVmRecipe?.provider === 'orca-cloud' + ) { + holdCloudOpenCover(args.worktreeId, pending) + } // Why: clearing synchronously after activation lets React commit the panel-to-terminal swap in one frame. useAppStore.getState().removePendingWorktreeCreation(args.creationId, { cleanupVm: false }) // Why: an agent the host planned but did not start has no tab to seed and is not the window's to start. From af0fab19f84227fb3f0a70f6f4b981f71e4ec332 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:47:18 -0800 Subject: [PATCH 5/7] fix(cloud-routines): Run now button matches the run's status; drop redundant queued line; 'just now' --- .../settings/cloud-api/CloudRoutineRow.tsx | 32 +++++++---------- .../cloud-api/CloudRoutinesView.fixture.tsx | 35 +++++++++++++++++++ .../cloud-api/cloud-api-format.test.ts | 10 ++++++ .../settings/cloud-api/cloud-api-format.ts | 4 +++ src/renderer/src/i18n/locales/en.json | 2 -- 5 files changed, 61 insertions(+), 22 deletions(-) diff --git a/src/renderer/src/components/settings/cloud-api/CloudRoutineRow.tsx b/src/renderer/src/components/settings/cloud-api/CloudRoutineRow.tsx index af301a4084e..aad30e0e498 100644 --- a/src/renderer/src/components/settings/cloud-api/CloudRoutineRow.tsx +++ b/src/renderer/src/components/settings/cloud-api/CloudRoutineRow.tsx @@ -127,17 +127,14 @@ export function RoutineRow({ setNotice(null) const failure = await onRunNow() setRunning(false) - setNotice( - failure - ? { tone: 'error', text: failure } - : { - tone: 'ok', - text: t( - 'auto.components.settings.cloudRoutines.queued', - 'Run queued. It shows up in the history below.' - ) - } - ) + if (failure) { + setNotice({ tone: 'error', text: failure }) + return + } + // The new run's status lives in the pill and the history; open the history so it is in view. + if (!expanded) { + onToggleHistory() + } } return ( @@ -218,7 +215,7 @@ export function RoutineRow({ variant="ghost" size="xs" aria-disabled={running && !active} - aria-busy={running || active} + aria-busy={running} aria-expanded={active ? expanded : undefined} aria-controls={active ? historyId : undefined} onClick={() => void runNow()} @@ -246,14 +243,9 @@ export function RoutineRow({ : undefined } > - {running || active ? ( - - ) : ( - - )} - {active - ? t('auto.components.settings.cloudRoutines.runningNow', 'Running…') - : t('auto.components.settings.cloudRoutines.runNow', 'Run now')} + {/* Spins only while the request is in flight; the run's own status is the pill's job. */} + {running ? : } + {t('auto.components.settings.cloudRoutines.runNow', 'Run now')} diff --git a/src/renderer/src/components/settings/cloud-api/CloudRoutinesView.fixture.tsx b/src/renderer/src/components/settings/cloud-api/CloudRoutinesView.fixture.tsx index 6bb25768433..44422f66bdc 100644 --- a/src/renderer/src/components/settings/cloud-api/CloudRoutinesView.fixture.tsx +++ b/src/renderer/src/components/settings/cloud-api/CloudRoutinesView.fixture.tsx @@ -283,6 +283,41 @@ export const runHistory = defineFixture({ render: () => }) +/** Right after Run now: the pill and history say Queued; the button is back to Run now. */ +export const justQueued = defineFixture({ + width: 820, + render: () => ( + + r.id === 'rt_triage' + ? { ...r, lastRun: { id: 'run_q', status: 'queued', finishedAt: null } } + : r + ) + }} + loadRuns={async () => ({ + ok: true, + data: { + runs: [ + run({ + id: 'run_q', + status: 'queued', + trigger: 'manual', + createdAt: NOW - 3_000, + startedAt: null + }), + ...RUNS.runs.slice(1) + ], + nextBefore: null + } + })} + initial={{ historyFor: 'rt_triage' }} + /> + ) +}) + export const runHistoryEmpty = defineFixture({ width: 820, render: () => ( diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts b/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts index 38137b52967..86ef124bba5 100644 --- a/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts +++ b/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts @@ -10,6 +10,7 @@ import { describeRoutineTrigger, formatCountdown, formatKeyPrefix, + formatRelativeFromNow, formatRunDuration, presetForScopes, scopesForPreset, @@ -65,6 +66,15 @@ describe('formatting', () => { ).toMatch(/^Weekdays at 9:00.* E[SD]T$/) }) + it('says "just now" for the last minute, not "this minute"', () => { + const now = 1_000_000_000 + expect(formatRelativeFromNow(now - 3_000, now, 'en')).toBe('just now') + expect(formatRelativeFromNow(now - 59_000, now, 'en')).toBe('just now') + expect(formatRelativeFromNow(now - 5 * 60_000, now, 'en')).toBe('5 minutes ago') + // Future times (next scheduled run) keep Intl wording. + expect(formatRelativeFromNow(now + 10 * 60_000, now, 'en')).toBe('in 10 minutes') + }) + it('offers the local zone first', () => { const zones = timeZoneOptions('Asia/Tokyo') expect(zones[0]).toBe('Asia/Tokyo') diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts b/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts index daa7e17d258..15b98d6df4c 100644 --- a/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts +++ b/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts @@ -51,6 +51,10 @@ export function formatKeyPrefix(prefix: string): string { } export function formatRelativeFromNow(timestamp: number, now: number, intlLocale?: string): string { + // Under a minute ago reads "just now", like the other cloud screens (not Intl's "this minute"). + if (timestamp <= now && now - timestamp < 60_000) { + return translate('auto.components.cloudWorkspaces.justNow', 'just now') + } return formatUiRelativeTime(timestamp - now, intlLocale) } diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 3193a98dc26..48c095bcc1b 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -14599,7 +14599,6 @@ "sectionDescription": "For the Orca Cloud API, the orca CLI and MCP clients. Claude or Codex keys go in Cloud secrets." }, "cloudRoutines": { - "queued": "Run queued. It shows up in the history below.", "pausedSr": "(paused)", "createdByPerson": "by ", "lastRun": "Last run:", @@ -14608,7 +14607,6 @@ "runningShowHistory": "{{routineName}} is running. Show run history", "runNowLabel": "Run {{routineName}} now", "alreadyRunning": "A run is already in progress.", - "runningNow": "Running…", "runNow": "Run now", "more": "More actions for {{routineName}}", "hideHistory": "Hide run history", From 6d3919f4d25e697525f8889680fb800ca5eba062 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:50:52 -0800 Subject: [PATCH 6/7] test(cloud): type the cleanup mock --- src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts b/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts index f94f1ffff1e..0229515e9b3 100644 --- a/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts +++ b/src/renderer/src/lib/ephemeral-vm-worktree-creation.test.ts @@ -17,7 +17,7 @@ const { state, gate, cleanup, retry } = vi.hoisted(() => { ] }, gate: vi.fn(), - cleanup: vi.fn(async () => true), + cleanup: vi.fn(async (_request: unknown, _actions?: unknown) => true), retry: vi.fn() } }) From 35b198929156283c2038c436f5c58831ab807c3b Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:52:53 -0800 Subject: [PATCH 7/7] test(cloud): no cast in the cover store test --- src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts index 83b6cac5ee9..1cc03247cf9 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts +++ b/src/renderer/src/lib/orca-cloud/cloud-open-cover-store.test.ts @@ -23,9 +23,10 @@ describe('cloud open cover', () => { }) it('counts the workspace as open only once one of its terminals has a PTY', () => { + const noPtys: string[] = [] const state = { tabsByWorktree: { w1: [{ id: 't1' }, { id: 't2' }] }, - ptyIdsByTabId: { t1: [] as string[] } + ptyIdsByTabId: { t1: noPtys } } expect(workspaceHasAttachedPty(state, 'w1')).toBe(false) expect(