mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
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
This commit is contained in:
@@ -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: {
|
||||
</Suspense>
|
||||
</div>
|
||||
<CloudSetupPageLayer />
|
||||
<CloudOpenCoverLayer
|
||||
reserveCollapsedSidebarHeaderSpace={layout.leftTitlebarChromeLayout.isFloating}
|
||||
/>
|
||||
{floatingWorkspace.showToggleButton && !capturingPluginShot ? (
|
||||
<MemoFloatingTerminalToggleButton
|
||||
open={floatingWorkspace.open}
|
||||
|
||||
@@ -185,6 +185,18 @@ export function CloudSetupNotices({
|
||||
)
|
||||
}
|
||||
|
||||
/** Bottom right, above the floating-terminal button: top right would cover the prompt's first row. */
|
||||
export function CloudSetupNoticesDock({ workspaceId }: { workspaceId: string }): React.JSX.Element {
|
||||
return (
|
||||
<div
|
||||
data-cloud-surface=""
|
||||
className="pointer-events-none absolute right-3 bottom-14 z-30 flex flex-col items-end gap-2"
|
||||
>
|
||||
<CloudSetupNotices workspaceId={workspaceId} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
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"
|
||||
>
|
||||
<h2 id={labelId} className="sr-only">
|
||||
{t('orcaCloud.setupNotices.label', 'Workspace setup')}
|
||||
|
||||
@@ -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(<CloudSetupNotices key="setup" workspaceId={workspaceId} />)
|
||||
}
|
||||
// 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(
|
||||
<CloudWorkspaceNotice
|
||||
@@ -439,6 +437,7 @@ function CloudSurface({ workspaceId }: { workspaceId: string }): React.JSX.Eleme
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{showSetupNotices ? <CloudSetupNoticesDock workspaceId={workspaceId} /> : null}
|
||||
{notices.length > 0 ? (
|
||||
<div
|
||||
data-cloud-surface=""
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useCloudRecoveryContext } from '@/lib/orca-cloud/use-cloud-recovery-context'
|
||||
import { useIsCloudWorkspace } from '@/lib/orca-cloud/orca-cloud-workspace-store'
|
||||
import { useCloudSetupPageRequest } from '@/lib/orca-cloud/cloud-setup-page-store'
|
||||
import { selectWorktreeCreationSurfaceShown } from '@/lib/workspace/creation/worktree-creation-surface'
|
||||
import { toast } from 'sonner'
|
||||
import { useAppStore } from '@/store'
|
||||
import { track } from '@/lib/telemetry'
|
||||
@@ -71,9 +74,18 @@ function SetupScriptPromptCard(): React.JSX.Element | null {
|
||||
// An asleep Orca Cloud workspace can't be inspected: wait until it's awake instead of showing
|
||||
// "Couldn't verify this repo's setup script" with Retry (RA-12).
|
||||
const asleepCloud = useCloudRecoveryContext(activeWorktreeId)?.asleep === true
|
||||
// Orca Cloud never shows this nudge: a cloud workspace reports a setup script that hasn't run in
|
||||
// its own notice, and while a create is setting up, starting or stopped on a check the card would
|
||||
// flip between states under the start screen (JA-12, PC-7).
|
||||
const cloudWorkspace = useIsCloudWorkspace(activeWorktreeId)
|
||||
const creationShown = useAppStore(selectWorktreeCreationSurfaceShown)
|
||||
const cloudSetupOpen = useCloudSetupPageRequest() !== null
|
||||
const isDismissed =
|
||||
provisionedByEnvironmentBuild ||
|
||||
asleepCloud ||
|
||||
cloudWorkspace ||
|
||||
creationShown ||
|
||||
cloudSetupOpen ||
|
||||
(activeRepoHostIdentity
|
||||
? isSetupScriptPromptDismissed(activeRepoHostIdentity, dismissedRepoIds)
|
||||
: false)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react'
|
||||
import type { CloudOpenCover } from '@/lib/orca-cloud/cloud-open-cover-store'
|
||||
import WorktreeCreationTabStrip from './WorktreeCreationTabStrip'
|
||||
import { VmBuildSheet } from './VmBuildSheet'
|
||||
|
||||
const noop = (): void => {}
|
||||
|
||||
/** 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 (
|
||||
<div data-cloud-open-cover="" className="absolute inset-0 z-20 flex flex-col bg-background">
|
||||
<WorktreeCreationTabStrip
|
||||
title={entry.request.displayName || entry.request.name}
|
||||
isError={false}
|
||||
reserveCollapsedSidebarHeaderSpace={reserveCollapsedSidebarHeaderSpace}
|
||||
onCancel={noop}
|
||||
/>
|
||||
{/* A picture of the last frame: nothing in it is interactive. */}
|
||||
<div className="min-h-0 flex-1 p-3" inert>
|
||||
<VmBuildSheet
|
||||
creationId={entry.creationId}
|
||||
entry={entry}
|
||||
now={now}
|
||||
elapsedLabel=""
|
||||
error={null}
|
||||
onCancel={noop}
|
||||
onRetry={noop}
|
||||
onDismiss={noop}
|
||||
onReturnToComposer={noop}
|
||||
onEditRecipe={noop}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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<void> | null = null
|
||||
const bodyListeners = new Set<() => void>()
|
||||
|
||||
export function preloadCloudOpenCover(): Promise<void> {
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -187,51 +187,54 @@ export function VmBuildSheet({
|
||||
return (
|
||||
<div data-vm-build-sheet className="flex min-h-full justify-center pt-12">
|
||||
<div className="flex w-full max-w-2xl flex-col gap-4">
|
||||
<div className="flex min-h-7 items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="grid size-4 shrink-0 place-items-center">
|
||||
{building ? (
|
||||
<Loader2 aria-hidden className="size-4 text-muted-foreground animate-spin" />
|
||||
) : state === 'ready' ? (
|
||||
<CircleCheck aria-hidden className="size-4 text-foreground" />
|
||||
) : gated ? (
|
||||
<CircleAlert aria-hidden className="size-4 text-muted-foreground" />
|
||||
) : (
|
||||
<AlertTriangle
|
||||
aria-hidden
|
||||
// Failed checks leave a running sandbox that needs a decision, not a broken start.
|
||||
className={cn(
|
||||
'size-4 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-90 motion-safe:duration-200',
|
||||
failure?.kind === 'checks' && !cloud
|
||||
? 'text-status-warning-text'
|
||||
: 'text-destructive'
|
||||
)}
|
||||
/>
|
||||
{/* JA-24: on Orca Cloud a failure card carries the one title; no page title above it. */}
|
||||
{cloud && failure ? null : (
|
||||
<div className="flex min-h-7 items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="grid size-4 shrink-0 place-items-center">
|
||||
{building ? (
|
||||
<Loader2 aria-hidden className="size-4 text-muted-foreground animate-spin" />
|
||||
) : state === 'ready' ? (
|
||||
<CircleCheck aria-hidden className="size-4 text-foreground" />
|
||||
) : gated ? (
|
||||
<CircleAlert aria-hidden className="size-4 text-muted-foreground" />
|
||||
) : (
|
||||
<AlertTriangle
|
||||
aria-hidden
|
||||
// Failed checks leave a running sandbox that needs a decision, not a broken start.
|
||||
className={cn(
|
||||
'size-4 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-90 motion-safe:duration-200',
|
||||
failure?.kind === 'checks' && !cloud
|
||||
? 'text-status-warning-text'
|
||||
: 'text-destructive'
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
{/* Retry lands focus here once the failure card collapses. The card announces failures. */}
|
||||
<h2
|
||||
data-vm-build-heading
|
||||
tabIndex={-1}
|
||||
aria-live={failure ? 'off' : 'polite'}
|
||||
className="text-sm font-medium text-foreground outline-none"
|
||||
>
|
||||
{headerTitle(state, cloud, t, failure?.kind === 'create')}
|
||||
</h2>
|
||||
{/* Orca Cloud: each step carries its own timer, so the header has none. */}
|
||||
{gated || cloud ? null : (
|
||||
<span className="text-xs tabular-nums text-muted-foreground">{elapsedLabel}</span>
|
||||
)}
|
||||
</span>
|
||||
{/* Retry lands focus here once the failure card collapses. The card announces failures. */}
|
||||
<h2
|
||||
data-vm-build-heading
|
||||
tabIndex={-1}
|
||||
aria-live={failure ? 'off' : 'polite'}
|
||||
className="text-sm font-medium text-foreground outline-none"
|
||||
>
|
||||
{headerTitle(state, cloud, t, failure?.kind === 'create')}
|
||||
</h2>
|
||||
{/* Orca Cloud: each step carries its own timer, so the header has none. */}
|
||||
{gated || cloud ? null : (
|
||||
<span className="text-xs tabular-nums text-muted-foreground">{elapsedLabel}</span>
|
||||
)}
|
||||
</div>
|
||||
{building ? (
|
||||
<Button type="button" variant="ghost" size="xs" onClick={onCancel}>
|
||||
{t(
|
||||
'auto.components.worktree.creation.WorktreeCreationPanel.cancelProvisioning',
|
||||
'Cancel'
|
||||
)}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{building ? (
|
||||
<Button type="button" variant="ghost" size="xs" onClick={onCancel}>
|
||||
{t(
|
||||
'auto.components.worktree.creation.WorktreeCreationPanel.cancelProvisioning',
|
||||
'Cancel'
|
||||
)}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
{/* An account refusal happens before anything starts, so there are no steps to show. */}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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<string, Record<string, unknown>> = {}
|
||||
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<string, unknown>) => {
|
||||
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])
|
||||
})
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
@@ -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<Record<string, CloudOpenCover>> = {}
|
||||
const listeners = new Set<() => void>()
|
||||
|
||||
function emit(next: Readonly<Record<string, CloudOpenCover>>): 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<Record<string, readonly { id: string }[] | undefined>>
|
||||
ptyIdsByTabId: Readonly<Record<string, readonly string[] | undefined>>
|
||||
},
|
||||
worktreeId: string
|
||||
): boolean {
|
||||
return (state.tabsByWorktree[worktreeId] ?? []).some(
|
||||
(tab) => (state.ptyIdsByTabId[tab.id]?.length ?? 0) > 0
|
||||
)
|
||||
}
|
||||
|
||||
/** Test seam. */
|
||||
export function resetCloudOpenCovers(): void {
|
||||
emit({})
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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<void> {
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user