chore(cloud): composer-redo lint (file size, footer type, no stale state)

This commit is contained in:
Neil
2026-11-10 18:53:31 -08:00
parent 3431639cc2
commit 0c8d142299
12 changed files with 240 additions and 181 deletions
@@ -39,9 +39,7 @@ import { getFolderWorkspacePrimaryActionLabel } from '@/components/sidebar/works
import { useAgentMenuObservation } from '@/components/tab-bar/use-new-tab-agent-menu-rows'
import { addAppKeyListener, removeAppKeyListener } from '@/lib/keyboard/app-keyboard-router'
import { useComposerCloudStart } from './new-workspace/run-on/use-composer-cloud-start'
/** How long a hidden Orca Cloud auto-start may take before the dialog shows instead. */
const CLOUD_AUTO_START_REVEAL_MS = 8_000
import { HiddenComposer, useCloudAutoStartReveal } from './new-workspace/composer-cloud-auto-start'
// Keep Add Project’s clone/SSH machinery outside the composer entry render, matching App loading.
const HostedAddRepoDialog = lazyWithRetry(
@@ -83,34 +81,18 @@ function ComposerModalBody({
onClose()
}, [onClose])
const isSubmissionCancelled = useCallback(() => submitCancelledRef.current, [])
// Orca Cloud setup finished on its page: submit with the dialog unseen. If the start can't run
// by itself (a form error, a revoked grant), the dialog appears with everything kept.
const [autoStartRevealed, setAutoStartRevealed] = useState(false)
useEffect(() => {
if (!modalData.cloudAutoStart) {
return
}
const timer = window.setTimeout(() => setAutoStartRevealed(true), CLOUD_AUTO_START_REVEAL_MS)
return () => window.clearTimeout(timer)
}, [modalData.cloudAutoStart])
if (modalData.cloudAutoStart && !autoStartRevealed) {
return (
// A closed Root still provides the title's context; nothing is portaled or shown.
<Dialog open={false}>
<div className="hidden" aria-hidden>
<QuickTabBody
modalData={modalData}
onClose={onClose}
isSubmissionCancelled={isSubmissionCancelled}
active
/>
</div>
</Dialog>
)
const visibleModalData = useCloudAutoStartReveal(modalData)
const body = (data: ComposerModalData): React.JSX.Element => (
<QuickTabBody
modalData={data}
onClose={onClose}
isSubmissionCancelled={isSubmissionCancelled}
active
/>
)
if (!visibleModalData) {
return <HiddenComposer>{body(modalData)}</HiddenComposer>
}
const visibleModalData = modalData.cloudAutoStart
? { ...modalData, cloudAutoStart: false }
: modalData
return (
<Dialog open onOpenChange={(open) => !open && handleDismiss()}>
@@ -129,12 +111,7 @@ function ComposerModalBody({
getWorkspaceComposerInitialFocusTarget(content)?.focus({ preventScroll: true })
}}
>
<QuickTabBody
modalData={visibleModalData}
onClose={onClose}
isSubmissionCancelled={isSubmissionCancelled}
active
/>
{body(visibleModalData)}
</DialogContent>
</Dialog>
)
@@ -236,75 +213,67 @@ function QuickTabBody({
// `withoutAgent`: Orca Cloud with an agent that has no account there starts a plain terminal
// instead of dropping the user into the agent's /login.
const handleCreate = useCallback(async (options?: { withoutAgent?: boolean }): Promise<void> => {
if (createDisabled) {
return
}
const agent = options?.withoutAgent ? null : quickAgent
await submitQuick(agent, {
// Blank Terminal is the setup-only create: no agent, and no extra shell beside setup.
setupOnly: agent === null,
...(agent === null ? {} : { launchChoice: launchSelection.choice }),
onLegacyPreparationFailure: (error) => {
if (isSubmissionCancelled()) {
return
}
const snapshot = {
...modalData,
prefilledName: cardProps.name,
initialRepoId: cardProps.repoId,
initialBaseBranch: cardProps.baseBranch,
initialWorkspaceTarget:
cardProps.selectedProjectId && cardProps.selectedRepoExecutionHostId
? {
projectId: cardProps.selectedProjectId,
hostId: cardProps.selectedRepoExecutionHostId,
projectHostSetupId: cardProps.selectedProjectHostSetupId ?? null
const handleCreate = useCallback(
async (options?: { withoutAgent?: boolean }): Promise<void> => {
if (createDisabled) {
return
}
const agent = options?.withoutAgent ? null : quickAgent
await submitQuick(agent, {
// Blank Terminal is the setup-only create: no agent, and no extra shell beside setup.
setupOnly: agent === null,
...(agent === null ? {} : { launchChoice: launchSelection.choice }),
onLegacyPreparationFailure: (error) => {
if (isSubmissionCancelled()) {
return
}
const snapshot = {
...modalData,
prefilledName: cardProps.name,
initialRepoId: cardProps.repoId,
initialBaseBranch: cardProps.baseBranch,
initialWorkspaceTarget:
cardProps.selectedProjectId && cardProps.selectedRepoExecutionHostId
? {
projectId: cardProps.selectedProjectId,
hostId: cardProps.selectedRepoExecutionHostId,
projectHostSetupId: cardProps.selectedProjectHostSetupId ?? null
}
: modalData.initialWorkspaceTarget,
linkedWorkItem: cardProps.linkedWorkItem,
recovery: { ...quickAgentPick, agent: quickAgent, note: cardProps.note }
}
toast.error(getWorkspaceCreateErrorToastMessage(formatWorkspaceCreateError(error)), {
action: {
label: translate('auto.lib.composerCreateHandoff.reopen', 'Reopen'),
onClick: () => {
if (!isSubmissionCancelled() && useAppStore.getState().activeModal === 'none') {
useAppStore.getState().openModal('new-workspace-composer', snapshot)
}
: modalData.initialWorkspaceTarget,
linkedWorkItem: cardProps.linkedWorkItem,
recovery: { ...quickAgentPick, agent: quickAgent, note: cardProps.note }
}
toast.error(getWorkspaceCreateErrorToastMessage(formatWorkspaceCreateError(error)), {
action: {
label: translate('auto.lib.composerCreateHandoff.reopen', 'Reopen'),
onClick: () => {
if (!isSubmissionCancelled() && useAppStore.getState().activeModal === 'none') {
useAppStore.getState().openModal('new-workspace-composer', snapshot)
}
}
}
})
},
...quickWorkspacePickerInputs(
pickerDraft,
quickAgentPick.entry,
launchSelection.choice?.executionHostId
)
})
}, [
createDisabled,
quickAgent,
launchSelection.choice,
submitQuick,
pickerDraft,
quickAgentPick,
isSubmissionCancelled,
modalData,
cardProps
])
// The composer as it is now, for Orca Cloud's setup page (Back, and the start when it's done).
const composerSnapshot = useCallback(
(): ComposerModalData => ({
...modalData,
prefilledName: cardProps.name,
initialRepoId: cardProps.repoId,
initialBaseBranch: cardProps.baseBranch,
linkedWorkItem: cardProps.linkedWorkItem,
recovery: { ...quickAgentPick, agent: quickAgent, note: cardProps.note }
}),
[cardProps, modalData, quickAgent, quickAgentPick]
})
},
...quickWorkspacePickerInputs(
pickerDraft,
quickAgentPick.entry,
launchSelection.choice?.executionHostId
)
})
},
[
createDisabled,
quickAgent,
launchSelection.choice,
submitQuick,
pickerDraft,
quickAgentPick,
isSubmissionCancelled,
modalData,
cardProps
]
)
// The composer as it is now, for Orca Cloud's setup page (Back, and the start when it's done).
const { cloudStart, primaryCreateDisabled, onPrimary } = useComposerCloudStart({
active,
modalData,
@@ -312,7 +281,7 @@ function QuickTabBody({
quickAgent,
handleCreate,
createDisabled,
composerSnapshot,
quickAgentPick,
recordCreatedRef,
onClose
})
@@ -72,11 +72,14 @@ export function NewWorkspaceComposerFooter({
onClick={() => void onCreate()}
disabled={createDisabled}
size="sm"
className="ml-auto shrink-0 text-xs"
className="ml-auto shrink-0"
>
{creating ? <LoaderCircle className="size-4 animate-spin" /> : null}
{primaryActionLabel}
<ButtonKeyHint modifierLabel={submitShortcutModifierLabel} />
{/* The footer's compact type, as before; the Button keeps its own variant styling. */}
<span className="flex items-center gap-1.5 whitespace-nowrap text-xs">
{creating ? <LoaderCircle className="size-4 animate-spin" /> : null}
{primaryActionLabel}
<ButtonKeyHint modifierLabel={submitShortcutModifierLabel} />
</span>
</Button>
</div>
</>
@@ -38,24 +38,24 @@ type NewWorkspaceComposerProjectSectionProps = Pick<
| 'orcaCloudAvailability'
| 'cloudStart'
> & {
disabled?: boolean
projectDescriptionId: string
onAddProject: () => void
focusNameInput: () => void
shouldShowRunTargetPicker: boolean
projectHostSetupOptions: NewWorkspaceComposerCardProps['projectHostSetupOptions']
ephemeralVmRecipes: EphemeralVmRecipeOption[]
handleProjectHostSetupChange: (setupId: string) => void
handleAddSshHost: () => void
handleAddRemoteServer: () => void
handleConnectRunTargetHost: (option: NeedsProjectHostOption) => Promise<void>
handleSetLocation: (option: NeedsProjectHostOption) => void
sshStatusLabel: string
connectButtonLabel: string
selectedProjectName: string
/** Fixtures pin Orca Cloud entitlement; the app reads it from billing. */
orcaCloudAccess?: OrcaCloudRunTargetAccess
}
disabled?: boolean
projectDescriptionId: string
onAddProject: () => void
focusNameInput: () => void
shouldShowRunTargetPicker: boolean
projectHostSetupOptions: NewWorkspaceComposerCardProps['projectHostSetupOptions']
ephemeralVmRecipes: EphemeralVmRecipeOption[]
handleProjectHostSetupChange: (setupId: string) => void
handleAddSshHost: () => void
handleAddRemoteServer: () => void
handleConnectRunTargetHost: (option: NeedsProjectHostOption) => Promise<void>
handleSetLocation: (option: NeedsProjectHostOption) => void
sshStatusLabel: string
connectButtonLabel: string
selectedProjectName: string
/** Fixtures pin Orca Cloud entitlement; the app reads it from billing. */
orcaCloudAccess?: OrcaCloudRunTargetAccess
}
export function NewWorkspaceComposerProjectSection({
disabled = false,
@@ -9,7 +9,6 @@ import {
type ReadyProjectHostSetupOption
} from '@/lib/project-host-setup-options'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import { ORCA_CLOUD_RECIPE_ID } from '../../../../shared/hosted-sandbox/orca-cloud-recipe-id'
import { isWithinComboboxRoot, useTypeAheadCombobox } from './use-type-ahead-combobox'
import { COMBOBOX_POPOVER_SURFACE } from './type-ahead-combobox-styles'
import {
@@ -18,9 +17,6 @@ import {
getRecipeSubmenuItemKey,
getRunTargetSubmenuItemKeys,
getRunTargetCurrentRowKey,
getOrcaCloudDetail,
ORCA_CLOUD_LABEL,
RUN_TARGET_ORCA_CLOUD_KEY,
getRunTargetOptionId,
RUN_TARGET_ADD_HOST_KEY,
RUN_TARGET_ADD_REMOTE_SERVER_ITEM,
@@ -110,13 +106,8 @@ export default function RunTargetCombobox({
// An unlisted target (e.g. a per-workspace VM) shows "Choose target", never another host's name (#38669).
null
const selectedRecipe = recipes.find((recipe) => recipe.id === recipeValue) ?? null
// Signed out, main lists no Orca Cloud recipe, yet the composer can still pick it.
const orcaCloudPicked =
selectedRecipe === null && recipeValue === ORCA_CLOUD_RECIPE_ID && Boolean(onSelectOrcaCloud)
// Opening highlights the committed row, so only one row reads as chosen.
const currentRowKey = orcaCloudPicked
? RUN_TARGET_ORCA_CLOUD_KEY
: getRunTargetCurrentRowKey(selectedRecipe, selectedHost)
const currentRowKey = getRunTargetCurrentRowKey(selectedRecipe, selectedHost)
const hasAddHost = Boolean(onAddSshHost || onAddRemoteServer)
const orcaCloudOffer = getRunTargetOrcaCloudOffer({
@@ -152,8 +143,7 @@ export default function RunTargetCombobox({
const { submenu, armedItemKey, openSubmenu, closeSubmenu, armItem, moveItemArm, armItemEdge } =
useRunTargetSubmenu(submenuItemKeys)
const armedRow = rows.find((row) => row.key === armedKey) ?? rows[0] ?? null
const committed =
query.length === 0 && (orcaCloudPicked || selectedRecipe !== null || selectedHost !== null)
const committed = query.length === 0 && (selectedRecipe !== null || selectedHost !== null)
// Closing also drops any open submenu, which the shared hook doesn't know about.
const close = useCallback((): void => {
@@ -324,9 +314,7 @@ export default function RunTargetCombobox({
const activeDescendantId = activeDescendantKey ? optionIdFor(activeDescendantKey) : undefined
const addHostOptionId = optionIdFor(RUN_TARGET_ADD_HOST_KEY)
const field = orcaCloudPicked
? { label: ORCA_CLOUD_LABEL, detail: getOrcaCloudDetail(t), recipeKind: 'orca-cloud' as const }
: getRunTargetFieldText(selectedRecipe, selectedHost, t)
const field = getRunTargetFieldText(selectedRecipe, selectedHost, t)
return (
<Popover open={open} onOpenChange={handleOpenChange}>
@@ -342,7 +330,7 @@ export default function RunTargetCombobox({
onToggle={() => setOpen(!open)}
committed={committed}
recipeKind={field.recipeKind}
hostId={orcaCloudPicked ? null : (selectedHost?.hostId ?? null)}
hostId={selectedHost?.hostId ?? null}
label={field.label}
detail={field.detail}
controlsId={submenu ? `${listId} ${listId}-${submenu}` : listId}
@@ -396,8 +384,8 @@ export default function RunTargetCombobox({
<RunTargetRowList
rows={rows}
armedKey={armedRow?.key ?? null}
selectedHost={selectedRecipe === null && !orcaCloudPicked ? selectedHost : null}
selectedRecipeId={orcaCloudPicked ? ORCA_CLOUD_RECIPE_ID : (selectedRecipe?.id ?? null)}
selectedHost={selectedRecipe === null ? selectedHost : null}
selectedRecipeId={selectedRecipe?.id ?? null}
matchedRecipes={matchedRecipes}
recipesOpen={submenu === 'recipes'}
inSubmenu={inSubmenu}
@@ -10,7 +10,6 @@ import { RunTargetOrcaCloudRow } from './RunTargetOrcaCloudRow'
import { needsSetupRowHint } from './run-target-row-hints'
import { useTranslate } from '@/i18n/use-translate'
import type { OrcaCloudRunTargetAccess } from './orca-cloud-run-target-access'
import { ORCA_CLOUD_RECIPE_ID } from '../../../../shared/hosted-sandbox/orca-cloud-recipe-id'
import type { EphemeralVmRecipeOption, RunTargetRowModel } from './run-target-options'
/** The scrolling rows of the run-target picker; "Add host" is pinned outside this list. */
@@ -100,11 +99,7 @@ export default function RunTargetRowList({
access={orcaCloudAccess}
pending={orcaCloudPending}
armed={isArmed}
current={
row.recipe !== null
? row.recipe.id === selectedRecipeId
: selectedRecipeId === ORCA_CLOUD_RECIPE_ID
}
current={row.recipe !== null && row.recipe.id === selectedRecipeId}
optionId={optionId}
onArm={() => onArm(row.key, null)}
onSelect={() => onSelectOrcaCloud(row.recipe)}
@@ -0,0 +1,61 @@
// The composer's side of the Orca Cloud setup page (composer-redo): the snapshot the page keeps for
// Back and for its auto-start, and the hidden composer that submits once setup is done.
import React, { useEffect, useState } from 'react'
import { Dialog } from '@/components/ui/dialog'
import type { ComposerModalData } from './composer-modal-data'
/** How long a hidden Orca Cloud auto-start may take before the dialog shows instead. */
const CLOUD_AUTO_START_REVEAL_MS = 8_000
/** The composer as it is now: prompt, project, base branch, linked item and agent pick. */
export function buildComposerSnapshot(
modalData: ComposerModalData,
card: {
name: string
repoId: string
baseBranch?: string
linkedWorkItem?: ComposerModalData['linkedWorkItem']
note: string
},
agentPick: Omit<NonNullable<ComposerModalData['recovery']>, 'note'>
): ComposerModalData {
return {
...modalData,
prefilledName: card.name,
initialRepoId: card.repoId,
...(card.baseBranch ? { initialBaseBranch: card.baseBranch } : {}),
linkedWorkItem: card.linkedWorkItem ?? null,
recovery: { ...agentPick, note: card.note }
}
}
/**
* Setup finished on its page: the composer submits with the dialog unseen. If the start can't run
* by itself in time (a form error, a revoked grant), the dialog appears with everything kept.
* Returns the modal data to render once visible (no second auto-start), or null while hidden.
*/
export function useCloudAutoStartReveal(modalData: ComposerModalData): ComposerModalData | null {
const [revealed, setRevealed] = useState(false)
useEffect(() => {
if (!modalData.cloudAutoStart) {
return
}
const timer = window.setTimeout(() => setRevealed(true), CLOUD_AUTO_START_REVEAL_MS)
return () => window.clearTimeout(timer)
}, [modalData.cloudAutoStart])
if (!modalData.cloudAutoStart) {
return modalData
}
return revealed ? { ...modalData, cloudAutoStart: false } : null
}
/** A closed Root still gives the title its context; nothing is portaled or shown. */
export function HiddenComposer({ children }: { children: React.ReactNode }): React.JSX.Element {
return (
<Dialog open={false}>
<div className="hidden" aria-hidden>
{children}
</div>
</Dialog>
)
}
@@ -48,9 +48,13 @@ function showAgentNotStartedToast(agent: string | null): void {
{
action: {
label: name
? translate('components.newWorkspace.cloudStart.setUpAgentOnce', 'Set up {{agent}} once', {
agent: name
})
? translate(
'components.newWorkspace.cloudStart.setUpAgentOnce',
'Set up {{agent}} once',
{
agent: name
}
)
: translate('components.newWorkspace.cloudStart.setUpAgentOnceGeneric', 'Set up once'),
onClick: openOrcaCloudAgentAccounts
}
@@ -4,6 +4,8 @@ import { useCallback, useEffect, type MutableRefObject } from 'react'
import type { ComposerModalData } from '../composer-modal-data'
import type { NewWorkspaceComposerCardProps } from '../new-workspace-composer-card-props'
import { useCloudStartComposer } from './use-cloud-start-composer'
import { buildComposerSnapshot } from '../composer-cloud-auto-start'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
type ComposerCardState = Pick<
NewWorkspaceComposerCardProps,
@@ -12,7 +14,9 @@ type ComposerCardState = Pick<
| 'onEphemeralVmRecipeChange'
| 'repoId'
| 'name'
>
| 'baseBranch'
| 'note'
> & { linkedWorkItem?: ComposerModalData['linkedWorkItem'] }
export function useComposerCloudStart({
active,
@@ -21,17 +25,18 @@ export function useComposerCloudStart({
quickAgent,
handleCreate,
createDisabled,
composerSnapshot,
quickAgentPick,
recordCreatedRef,
onClose
}: {
active: boolean
modalData: ComposerModalData
cardProps: ComposerCardState
quickAgent: string | null
quickAgent: TuiAgent | null
handleCreate: (options?: { withoutAgent?: boolean }) => Promise<void>
createDisabled: boolean
composerSnapshot: () => ComposerModalData
/** The agent pick (surface, draft) as the composer keeps it, for the setup page's snapshot. */
quickAgentPick: Omit<NonNullable<ComposerModalData['recovery']>, 'note'>
/** The composer's onCreated calls this: only a start that happened is remembered. */
recordCreatedRef: MutableRefObject<(() => void) | null>
onClose?: () => void
@@ -43,6 +48,10 @@ export function useComposerCloudStart({
() => void handleCreate({ withoutAgent: true }),
[handleCreate]
)
const composerSnapshot = useCallback(
() => buildComposerSnapshot(modalData, cardProps, { ...quickAgentPick, agent: quickAgent }),
[cardProps, modalData, quickAgent, quickAgentPick]
)
const cloudStart = useCloudStartComposer({
active,
availability: cardProps.orcaCloudAvailability ?? 'unavailable',
@@ -77,7 +77,9 @@ function SetupStepper({
)}
>
{state === 'done' ? <Check className="size-2.5" strokeWidth={3} /> : null}
{state === 'current' ? <span className="size-1.5 rounded-full bg-focus-ring" /> : null}
{state === 'current' ? (
<span className="size-1.5 rounded-full bg-focus-ring" />
) : null}
</span>
<span
className={cn(
@@ -110,7 +112,8 @@ function trialHours(step: CloudSetupStep): string | null {
function currentStepCopy(flow: CloudSetupFlow, t: Translate, agentLabel: string | null): StepCopy {
const step = flow.current
const detail = step
? (sessionDetailCopy(step, t) === undefined ? step.detail : sessionDetailCopy(step, t)) ?? null
? ((sessionDetailCopy(step, t) === undefined ? step.detail : sessionDetailCopy(step, t)) ??
null)
: null
switch (flow.action) {
case 'sign-in':
@@ -132,9 +135,13 @@ function currentStepCopy(flow: CloudSetupFlow, t: Translate, agentLabel: string
lead:
hours === null
? t('cloudSetupPage.trial.leadNoHours', 'Try Orca Cloud on your team. No card needed.')
: t('cloudSetupPage.trial.lead', '{{hours}} sandbox hours to try Orca Cloud. No card needed.', {
hours
}),
: t(
'cloudSetupPage.trial.lead',
'{{hours}} sandbox hours to try Orca Cloud. No card needed.',
{
hours
}
),
note: t('cloudSetupPage.trial.note', 'Nothing is charged until you choose a plan.')
}
}
@@ -172,7 +179,10 @@ function currentStepCopy(flow: CloudSetupFlow, t: Translate, agentLabel: string
: t('cloudSetupPage.billing.hoursTitle', 'Out of sandbox hours'),
lead:
step?.need === 'payment'
? t('cloudSetupPage.billing.paymentLead', 'The last payment failed. Update the card to keep going.')
? t(
'cloudSetupPage.billing.paymentLead',
'The last payment failed. Update the card to keep going.'
)
: step?.need === 'spend-cap'
? t('cloudSetupPage.billing.capLead', 'Raise the spend cap to start this workspace.')
: t('cloudSetupPage.billing.hoursLead', 'Turn on overage to start this workspace.')
@@ -203,7 +213,12 @@ function currentStepCopy(flow: CloudSetupFlow, t: Translate, agentLabel: string
case 'ask-owner':
return {
title: t('cloudSetupPage.owner.title', 'An owner or admin needs to fix this'),
lead: detail ?? t('cloudSetupPage.owner.lead', 'Orca Cloud needs a Team plan. Only owners and admins can choose one.')
lead:
detail ??
t(
'cloudSetupPage.owner.lead',
'Orca Cloud needs a Team plan. Only owners and admins can choose one.'
)
}
case 'agent':
return {
@@ -216,7 +231,10 @@ function currentStepCopy(flow: CloudSetupFlow, t: Translate, agentLabel: string
)
}
case 'checking':
return { title: t('cloudSetupPage.checking.title', 'Checking your Orca Cloud account…'), lead: null }
return {
title: t('cloudSetupPage.checking.title', 'Checking your Orca Cloud account…'),
lead: null
}
case 'done':
return {
title: t('cloudSetupPage.done.title', 'All set'),
@@ -287,7 +305,10 @@ function StepActions({ flow }: { flow: CloudSetupFlow }): React.JSX.Element | nu
case 'agent':
return (
<div className="flex flex-wrap items-center gap-2">
<Button type="button" onClick={flow.current?.action?.onClick ?? openOrcaCloudAgentAccounts}>
<Button
type="button"
onClick={flow.current?.action?.onClick ?? openOrcaCloudAgentAccounts}
>
{flow.current?.action?.label ?? t('cloudSetupPage.agent.setUp', 'Set up once')}
</Button>
<Button type="button" variant="ghost" onClick={flow.skipAgent}>
@@ -363,7 +384,11 @@ export function CloudSetupPage({
</div>
<div className="mt-8">
<SetupStepper steps={flow.steps} current={flow.current} allDone={starting || flow.action === 'done'} />
<SetupStepper
steps={flow.steps}
current={flow.current}
allDone={starting || flow.action === 'done'}
/>
</div>
<div className="mt-8 space-y-3">
@@ -404,8 +429,7 @@ export function CloudSetupPage({
{t('cloudSetupPage.startsAfter', 'Starts when setup is done')}
</div>
<div className="mt-1 truncate text-sm text-foreground">
{prompt.trim() ||
t('cloudSetupPage.untitled', 'New cloud workspace')}
{prompt.trim() || t('cloudSetupPage.untitled', 'New cloud workspace')}
</div>
<div className="mt-0.5 truncate text-xs text-muted-foreground">
{[projectName, agentLabel, t('cloudSetupPage.orcaCloud', 'Orca Cloud')]
@@ -37,9 +37,7 @@ describe('cloudSetupPageModel', () => {
expect(actionForStep({ id: 'plan', state: 'needed', need: 'plan', canFix: false })).toBe(
'ask-owner'
)
expect(actionForStep({ id: 'team', state: 'needed' }, { teamSwitch: true })).toBe(
'switch-team'
)
expect(actionForStep({ id: 'team', state: 'needed' }, { teamSwitch: true })).toBe('switch-team')
expect(actionForStep({ id: 'github', state: 'loading' })).toBe('checking')
})
})
@@ -101,7 +101,10 @@ export function actionForStep(
*/
export function cloudSetupPageModel(
steps: readonly CloudSetupStep[],
{ agentSkipped = false, teamSwitch = false }: { agentSkipped?: boolean; teamSwitch?: boolean } = {}
{
agentSkipped = false,
teamSwitch = false
}: { agentSkipped?: boolean; teamSwitch?: boolean } = {}
): CloudSetupPageModel {
const current = steps.find((step) => !isFinished(step, agentSkipped)) ?? null
if (!current) {
@@ -123,7 +126,10 @@ export function sessionNeedsFrom(steps: readonly CloudSetupStep[]): CloudSetupSt
*/
export function cloudSetupRequired(
steps: readonly CloudSetupStep[],
{ teamSwitch = false, agentSkipped = false }: { teamSwitch?: boolean; agentSkipped?: boolean } = {}
{
teamSwitch = false,
agentSkipped = false
}: { teamSwitch?: boolean; agentSkipped?: boolean } = {}
): boolean {
if (teamSwitch) {
return true
@@ -28,7 +28,11 @@ import {
import { reportCloudSetupProgress } from '@/lib/orca-cloud/cloud-setup-telemetry'
import type { OrcaCloudAvailability } from '../../../../shared/orca-yaml-hook-types'
import type { OrcaCloudRunTargetAccess } from '@/components/new-workspace/orca-cloud-run-target-access'
import { cloudSetupPageModel, sessionNeedsFrom, type CloudSetupPageModel } from './cloud-setup-page-model'
import {
cloudSetupPageModel,
sessionNeedsFrom,
type CloudSetupPageModel
} from './cloud-setup-page-model'
/** Billing rows re-read this often while the page waits on a browser step (focus also re-reads). */
const BILLING_POLL_MS = 4_000
@@ -96,8 +100,7 @@ export function useCloudSetupFlow(
): CloudSetupFlow {
const fetched = useOrcaCloudRunTargetAccess(!accessOverride)
const access = accessOverride ?? fetched
const [settled, setSettled] = useState(false)
const availability = useLiveAvailability(request.repoId, request.availability, !settled && !accessOverride)
const availability = useLiveAvailability(request.repoId, request.availability, !accessOverride)
const [sessionId, setSessionId] = useState<string | null>(null)
const [inBrowser, setInBrowser] = useState(false)
const [busy, setBusy] = useState(false)
@@ -106,7 +109,11 @@ export function useCloudSetupFlow(
() => (request.cloudOnlyRepo ? { id: 'github', state: 'done' } : null),
[request.cloudOnlyRepo]
)
const { steps: rowSteps, session, openInstall } = useCloudStartSteps({
const {
steps: rowSteps,
session,
openInstall
} = useCloudStartSteps({
availability,
access,
repoId: request.repoId,
@@ -117,11 +124,6 @@ export function useCloudSetupFlow(
})
const { steps, held: switchTeam } = useSwitchTeamSteps(rowSteps, !session)
const model = cloudSetupPageModel(steps, { agentSkipped, teamSwitch: switchTeam !== null })
useEffect(() => {
if (model.action === 'done') {
setSettled(true)
}
}, [model.action])
const error = useMemo(() => {
const parsed = parseCloudSetupError(session?.error)
return parsed && session?.teamName ? { ...parsed, teamName: session.teamName } : parsed