feat(cloud): PC-3b composer creates with the agent; the held prompt says it waits (DS-e)

- Orca Cloud with an agent that isn't set up now creates WITH the agent: its
  launch holds on the pane's Set up once strip (#385) and never reaches /login,
  so the first prompt goes in once the agent is set up and started. The plain
  terminal fallback (onCreateWithoutAgent / noAgentRef) is gone.
- The not-set-up toast shows only away from that workspace (onlyWhenAway); in
  it, the pane strip asks.
- DS-e: the build sheet's queued prompt reads "First prompt for Claude · Sends
  when the workspace is ready", and "… · Sends once Claude is set up" while the
  agent's launch is held.
This commit is contained in:
Neil
2026-11-10 23:47:00 -08:00
parent 881992ab39
commit 1fc2526bc2
6 changed files with 108 additions and 53 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}
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"