Merge pull request #390 from nwparker/cloud/pc3b-composer

Cloud: create with the agent behind the PC-3b hold; held first prompt copy (PC-3b composer, DS-e)
This commit is contained in:
Neil
2026-11-11 01:46:10 -08:00
committed by GitHub
9 changed files with 231 additions and 54 deletions
@@ -212,11 +212,8 @@ function QuickTabBody({
[observation.contextKey, orcaCloud]
)
// Orca Cloud with an agent that has no account there starts a plain terminal, never the agent's
// /login: the cloud hook sets this around one create (read before the first await).
const noAgentRef = useRef(false)
const handleCreate = useCallback(async (): Promise<void> => {
const agent = noAgentRef.current ? null : quickAgent
const agent = quickAgent
if (createDisabled) {
return
}
@@ -280,7 +277,6 @@ function QuickTabBody({
handleCreate,
createDisabled,
quickAgentPick,
noAgentRef,
recordCreatedRef,
onClose
})
@@ -32,10 +32,13 @@ import { isOrcaCloudAccountAgent } from '../../../../../shared/orca-cloud-agents
export type { CloudStartView } from './cloud-start-view'
/** The workspace started without its agent: the one prompt to set it up (design-squad journey). */
/**
* The agent isn't set up: its pane holds on the "Set up once" strip (PC-3b), so the toast only
* names the workspace once the user has moved to another one (design-squad journey).
*/
function showAgentNotStartedToast(agent: string | null, workspaceName: string): void {
if (isOrcaCloudAccountAgent(agent)) {
showCloudAgentNotStartedToast(agent, workspaceName)
showCloudAgentNotStartedToast(agent, workspaceName, { onlyWhenAway: true })
}
}
@@ -52,7 +55,6 @@ export function useCloudStartComposer({
createReady = true,
composerSnapshot,
onCreate: createWorkspace,
onCreateWithoutAgent,
onClose,
accessOverride
}: {
@@ -75,8 +77,6 @@ export function useCloudStartComposer({
/** The composer as it is now, for the setup page's Back and its auto-start. */
composerSnapshot: () => ComposerModalData
onCreate: () => void
/** The same create with no agent launched (the agent has no Orca Cloud account yet). */
onCreateWithoutAgent?: () => void
/** Closes the composer (setup moves to its page; a cloud-only repository started, D4). */
onClose?: () => void
/** Fixtures pin the account's access. */
@@ -110,31 +110,25 @@ export function useCloudStartComposer({
})
const { steps, held: switchTeam } = useSwitchTeamSteps(rowSteps, cloudSelected)
const setupNeeded = cloudSetupRequired(steps, { teamSwitch: switchTeam !== null })
// The agent has no Orca Cloud account (the user skipped setting it up): never launch it into its
// /login. Start a plain terminal and say how to set the agent up once.
// The agent has no Orca Cloud account (the user skipped setting it up). It is still created with
// the workspace: its launch holds on the pane's "Set up once" strip and never reaches the agent's
// own /login (PC-3b, #385), and its first prompt waits for it.
const agentUnset =
cloudSelected && steps.some((step) => step.id === 'agent' && step.state === 'optional')
const onCreateRaw = useCloudOnlyCreate({
cloudOnly,
createWorkspace,
prompt,
agent: agentUnset ? null : agent,
agent,
profileId,
onClose
})
const onCreate = useCallback(() => {
if (!agentUnset) {
onCreateRaw()
return
onCreateRaw()
if (agentUnset) {
showAgentNotStartedToast(agent, prompt)
}
// A GitHub-only start already leaves the agent out (above); a local project's create skips it.
if (cloudOnly.picked || !onCreateWithoutAgent) {
onCreateRaw()
} else {
onCreateWithoutAgent()
}
showAgentNotStartedToast(agent, prompt)
}, [agent, agentUnset, cloudOnly.picked, onCreateRaw, onCreateWithoutAgent, prompt])
}, [agent, agentUnset, onCreateRaw, prompt])
const { markTouched } = useRunOnDefault({
active,
@@ -26,7 +26,6 @@ export function useComposerCloudStart({
handleCreate,
createDisabled,
quickAgentPick,
noAgentRef,
recordCreatedRef,
onClose
}: {
@@ -35,8 +34,6 @@ export function useComposerCloudStart({
cardProps: ComposerCardState
quickAgent: TuiAgent | null
handleCreate: () => Promise<void>
/** Set right before a create to start it with no agent. */
noAgentRef: MutableRefObject<boolean>
createDisabled: boolean
/** The agent pick (surface, draft) as the composer keeps it, for the setup page's snapshot. */
quickAgentPick: Omit<NonNullable<ComposerModalData['recovery']>, 'note'>
@@ -47,10 +44,6 @@ export function useComposerCloudStart({
// The latest handleCreate, never a ref copied after render: a submit right after an edit must
// see that edit.
const runCreate = useCallback(() => void handleCreate(), [handleCreate])
const runCreateWithoutAgent = useCallback(() => {
noAgentRef.current = true
void handleCreate()
}, [handleCreate, noAgentRef])
const composerSnapshot = useCallback(
() => buildComposerSnapshot(modalData, cardProps, { ...quickAgentPick, agent: quickAgent }),
[cardProps, modalData, quickAgent, quickAgentPick]
@@ -70,7 +63,6 @@ export function useComposerCloudStart({
createReady: !createDisabled,
composerSnapshot,
onCreate: runCreate,
onCreateWithoutAgent: runCreateWithoutAgent,
onClose
})
useEffect(() => {
@@ -0,0 +1,44 @@
// @vitest-environment happy-dom
import { cleanup, render } from '@testing-library/react'
import { afterEach, describe, expect, it } from 'vitest'
import { OrcaCloudQueuedPromptView } from './OrcaCloudQueuedPrompt'
afterEach(() => {
cleanup()
})
function heading(props: { held?: boolean; editable: boolean; draft?: boolean }): string {
const { container } = render(
<OrcaCloudQueuedPromptView
agentName="Claude"
prompt="Fix the typo"
onQueue={() => {}}
{...props}
/>
)
return container.querySelector('[data-orca-cloud-queued-prompt="queued"] p')?.textContent ?? ''
}
describe('OrcaCloudQueuedPromptView heading (DS-e)', () => {
it('says the first prompt sends when the workspace is ready', () => {
expect(heading({ editable: true })).toBe(
'First prompt for Claude · Sends when the workspace is ready'
)
})
it('says it waits for the agent while the agent isn’t set up (PC-3b hold)', () => {
expect(heading({ editable: true, held: true })).toBe(
'First prompt for Claude · Sends once Claude is set up'
)
// Past provisioning it still waits: never "Sending to Claude next" while held.
expect(heading({ editable: false, held: true })).toBe(
'First prompt for Claude · Sends once Claude is set up'
)
})
it('keeps the draft and hand-off wording', () => {
expect(heading({ editable: true, draft: true })).toBe('Draft for Claude, typed in when ready')
expect(heading({ editable: false })).toBe('Sending to Claude next')
})
})
@@ -11,6 +11,9 @@ import {
vmCreationPromptIsDraft
} from '@/lib/workspace/creation/vm-creation-queued-prompt'
import { tuiAgentDisplayName } from '../../../../shared/agent-launch/catalog/tui-agent-display-names'
import { isOrcaCloudAccountAgent } from '../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
import { cloudAgentHoldReason } from '@/lib/orca-cloud/cloud-agent-launch-hold'
import { useOrcaCloudAgentAccounts } from '@/lib/orca-cloud/orca-cloud-agent-accounts-store'
export type OrcaCloudQueuedPromptViewProps = {
agentName: string
@@ -20,15 +23,53 @@ export type OrcaCloudQueuedPromptViewProps = {
editable: boolean
/** The prompt is typed into the agent unsent rather than sent. */
draft?: boolean
/** The agent isn't set up for Orca Cloud: its launch, and so this prompt, wait for that (PC-3b). */
held?: boolean
onQueue: (text: string) => void
}
type Translate = ReturnType<typeof useTranslate>
/** The queued prompt's heading: when, and whether, it goes to the agent. */
function queuedTitle(
t: Translate,
agent: string,
{ held, editable, draft }: { held: boolean; editable: boolean; draft: boolean }
): string {
if (held) {
return t(
'auto.components.orcaCloud.QueuedPrompt.held',
'First prompt for {{agent}} · Sends once {{agent}} is set up',
{ agent }
)
}
if (editable) {
return draft
? t(
'auto.components.orcaCloud.QueuedPrompt.draftQueued',
'Draft for {{agent}}, typed in when ready',
{ agent }
)
: t(
'auto.components.orcaCloud.QueuedPrompt.queuedUntilReady',
'First prompt for {{agent}} · Sends when the workspace is ready',
{ agent }
)
}
return draft
? t('auto.components.orcaCloud.QueuedPrompt.drafting', 'Ready as a draft in {{agent}}', {
agent
})
: t('auto.components.orcaCloud.QueuedPrompt.sending', 'Sending to {{agent}} next', { agent })
}
/** Queue the agent's first prompt while the workspace builds; it starts with it once ready. */
export function OrcaCloudQueuedPromptView({
agentName,
prompt,
editable,
draft: isDraftDelivery = false,
held = false,
onQueue
}: OrcaCloudQueuedPromptViewProps): React.JSX.Element | null {
const t = useTranslate()
@@ -141,25 +182,7 @@ export function OrcaCloudQueuedPromptView({
<Clock3 className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
<div className="min-w-0 flex-1">
<p className="text-xs font-medium text-foreground">
{editable && isDraftDelivery
? t(
'auto.components.orcaCloud.QueuedPrompt.draftQueued',
'Draft for {{agent}}, typed in when ready',
{ agent: agentName }
)
: editable
? t('auto.components.orcaCloud.QueuedPrompt.queued', 'Queued for {{agent}}', {
agent: agentName
})
: isDraftDelivery
? t(
'auto.components.orcaCloud.QueuedPrompt.drafting',
'Ready as a draft in {{agent}}',
{ agent: agentName }
)
: t('auto.components.orcaCloud.QueuedPrompt.sending', 'Sending to {{agent}} next', {
agent: agentName
})}
{queuedTitle(t, agentName, { held, editable, draft: isDraftDelivery })}
</p>
<p className="mt-0.5 line-clamp-3 text-xs whitespace-pre-wrap break-words text-muted-foreground">
{prompt}
@@ -186,15 +209,20 @@ export function OrcaCloudQueuedPrompt({
creationId: string
}): React.JSX.Element | null {
const entry = useAppStore((state) => state.pendingWorktreeCreations[creationId])
if (!entry?.request.ephemeralVmRecipe || entry.request.agent === null) {
const agent = entry?.request.agent ?? null
const accountAgent = isOrcaCloudAccountAgent(agent) ? agent : null
const accounts = useOrcaCloudAgentAccounts(accountAgent !== null)
if (!entry?.request.ephemeralVmRecipe || agent === null) {
return null
}
const held = accountAgent !== null && cloudAgentHoldReason(accountAgent, accounts) === 'notSetUp'
return (
<OrcaCloudQueuedPromptView
key={creationId}
agentName={tuiAgentDisplayName(entry.request.agent) ?? entry.request.agent}
agentName={tuiAgentDisplayName(agent) ?? agent}
prompt={vmCreationFirstPrompt(entry)}
draft={vmCreationPromptIsDraft(entry)}
held={held}
editable={canQueueVmCreationPrompt(entry)}
onQueue={(text) => queueVmCreationPrompt(creationId, text)}
/>
+2 -1
View File
@@ -21118,7 +21118,8 @@
"lateEdit": "Too late to change: {{agent}} is starting with the queued prompt. Send your edit once the workspace opens:",
"lateQueue": "Too late to queue: {{agent}} is already starting. Send this once the workspace opens:",
"draftQueued": "Draft for {{agent}}, typed in when ready",
"queued": "Queued for {{agent}}",
"queuedUntilReady": "First prompt for {{agent}} · Sends when the workspace is ready",
"held": "First prompt for {{agent}} · Sends once {{agent}} is set up",
"drafting": "Ready as a draft in {{agent}}",
"sending": "Sending to {{agent}} next",
"edit": "Edit queued prompt"
@@ -0,0 +1,93 @@
import { beforeEach, describe, expect, it } from 'vitest'
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
import { resolveBackendDraftStartup } from '@/lib/workspace/creation/worktree-draft-startup-view-mode'
import type { OrcaCloudAgentsStatus } from '../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
import {
setOrcaCloudAgentAccountsStateForTest,
type OrcaCloudAgentAccountsState
} from './orca-cloud-agent-accounts-store'
import { withholdsCloudAgentBackendStartup } from './cloud-create-agent-startup'
function accounts(
claude: OrcaCloudAgentsStatus['credentials']['claude'] | 'loading'
): OrcaCloudAgentAccountsState {
return {
load:
claude === 'loading'
? { kind: 'loading' }
: {
kind: 'ready',
status: {
credentials: {
claude,
codex: { state: 'none' },
providerEnabled: { claude: true, codex: true }
},
sources: { defaults: {}, coveredByKey: { claude: false, codex: false } }
}
},
setups: { claude: { phase: 'idle' }, codex: { phase: 'idle' } },
keyKinds: { claude: null, codex: null },
queue: { agents: [], index: 0 }
}
}
const STARTUP = { command: "claude 'fix the typo'" }
function request(
overrides: Partial<Pick<WorktreeCreationRequest, 'agent' | 'ephemeralVmRecipe'>> = {}
): WorktreeCreationRequest {
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the startup path reads only these fields
return {
agent: 'claude',
startup: STARTUP,
ephemeralVmRecipe: {
sourceRepoId: 'repo',
recipeId: 'cloud',
projectId: 'project',
provider: 'orca-cloud'
},
...overrides
} as WorktreeCreationRequest
}
describe('Orca Cloud create: no host draft startup while the agent is held (PC-3b)', () => {
beforeEach(() => {
setOrcaCloudAgentAccountsStateForTest(accounts({ state: 'none' }))
})
it('withholds the startup (and its prompt) when Claude is not set up', () => {
expect(withholdsCloudAgentBackendStartup(request())).toBe(true)
expect(resolveBackendDraftStartup(request())).toBeUndefined()
})
it('withholds while the first account read is loading (the pane gate waits for it)', () => {
setOrcaCloudAgentAccountsStateForTest(accounts('loading'))
expect(resolveBackendDraftStartup(request())).toBeUndefined()
})
it('withholds for an expired account too', () => {
setOrcaCloudAgentAccountsStateForTest(accounts({ state: 'expired' }))
expect(resolveBackendDraftStartup(request())).toBeUndefined()
})
it('keeps the host startup once Claude is signed in', () => {
setOrcaCloudAgentAccountsStateForTest(accounts({ state: 'active' }))
expect(resolveBackendDraftStartup(request())).toEqual(STARTUP)
})
it('never touches local or custom-environment creates', () => {
expect(resolveBackendDraftStartup(request({ ephemeralVmRecipe: undefined }))).toEqual(STARTUP)
expect(
resolveBackendDraftStartup(
request({
ephemeralVmRecipe: { sourceRepoId: 'repo', recipeId: 'devbox', projectId: 'project' }
})
)
).toEqual(STARTUP)
})
it('leaves agents without an Orca Cloud account alone', () => {
expect(resolveBackendDraftStartup(request({ agent: 'opencode' }))).toEqual(STARTUP)
})
})
@@ -0,0 +1,24 @@
// PC-3b on the create path: an Orca Cloud create whose agent isn't set up (or whose account read is
// still loading) must not hand the host a draft startup. The host would start the agent with the
// queued prompt straight into its /login. Withheld, the create opens the workspace and the launch is
// planned in the pane, where the cloud credential gate holds it behind the "Set up once" strip; on
// Start it runs the same startup, prompt included, exactly once.
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
import { isOrcaCloudAccountAgent } from '../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
import { ORCA_CLOUD_RECIPE_ID } from '../../../../shared/hosted-sandbox/orca-cloud-recipe-id'
import { cloudAgentLaunchHoldReason } from './cloud-agent-launch-hold'
export function withholdsCloudAgentBackendStartup(
request: Pick<WorktreeCreationRequest, 'agent' | 'ephemeralVmRecipe'>
): boolean {
const recipe = request.ephemeralVmRecipe
if (recipe?.provider !== 'orca-cloud' && recipe?.recipeId !== ORCA_CLOUD_RECIPE_ID) {
return false
}
const agent = request.agent
if (!isOrcaCloudAccountAgent(agent)) {
return false
}
// 'unknown' (first account read loading) withholds too: the pane gate waits for the read.
return cloudAgentLaunchHoldReason(agent) !== null
}
@@ -1,8 +1,13 @@
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
import { withholdsCloudAgentBackendStartup } from '@/lib/orca-cloud/cloud-create-agent-startup'
export function resolveBackendDraftStartup(
request: WorktreeCreationRequest
): WorktreeCreationRequest['startup'] {
// Orca Cloud agent not set up: the pane plans the launch behind its hold, never the host (PC-3b).
if (withholdsCloudAgentBackendStartup(request)) {
return undefined
}
if (!request.startup || !request.agent || !request.launchDraftPrompt) {
return request.startup
}