mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
feat(cloud): JA-22 agent picker says which agents a cloud workspace can run as-is
Inside the open agent picker only (nothing changes on the closed button), each Orca Cloud image
agent carries a muted status: none when ready, 'Not set up' (Claude/Codex without an Orca account or
team key; Copilot/OpenCode/Gemini/Cursor with no matching Cloud secret), or 'Signs in per workspace'
(Orca-account sign-in off or paused). Accessible names read '{{agent}}, not set up'.
- lib/orca-cloud/orca-cloud-agent-picker-status.ts: pure selector over the shared Agent accounts read
(orcaCloudAgentCoverageFromAccounts) plus Cloud secret names (never values).
- The accounts store keeps the effective Cloud secret names it already fetches.
- AgentLaunchPicker / Menu / MenuRow take an optional statusLabels map; agentSurfaceRows carries it.
This commit is contained in:
@@ -174,7 +174,7 @@ function QuickTabBody({
|
||||
const [quickAgentOverride, setQuickAgentOverride] = useState<TuiAgent | null | undefined>(
|
||||
modalData.recovery?.agent
|
||||
)
|
||||
const { orcaCloud, orcaCloudModel, quickAgent, chipAgentIds, agentNotice } =
|
||||
const { orcaCloud, orcaCloudModel, quickAgent, chipAgentIds, agentNotice, statusLabels } =
|
||||
useComposerQuickAgent(cardProps, settings, quickAgentOverride, setQuickAgentOverride)
|
||||
// Why keyed by agent: a pick repaired to another agent must not carry the old one's surface.
|
||||
const [quickAgentPick, setQuickAgentPick] = useState<
|
||||
@@ -399,7 +399,8 @@ function QuickTabBody({
|
||||
selection: launchSelection,
|
||||
surface: quickAgentSurface,
|
||||
contextKey: observation.contextKey,
|
||||
onPick: handleQuickAgentChange
|
||||
onPick: handleQuickAgentChange,
|
||||
statusLabels
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export const AgentLaunchPicker = memo(
|
||||
onOpenAgentSettings,
|
||||
defaultAgent,
|
||||
onSetDefault,
|
||||
statusLabels,
|
||||
onPick
|
||||
}: {
|
||||
model: NewTabAgentMenuModel
|
||||
@@ -88,6 +89,8 @@ export const AgentLaunchPicker = memo(
|
||||
/** The saved default; with onSetDefault, right-clicking an agent row offers "Set as default". */
|
||||
defaultAgent?: AgentPickerEntry['agent'] | 'blank' | null
|
||||
onSetDefault?: (agent: AgentPickerEntry['agent'] | 'blank') => void
|
||||
/** A muted status per agent row, shown only inside the open menu (Orca Cloud: JA-22). */
|
||||
statusLabels?: ReadonlyMap<AgentPickerEntry['agent'], string>
|
||||
onPick: (
|
||||
agent: AgentPickerEntry['agent'],
|
||||
draft?: AgentPickerDraft,
|
||||
@@ -261,6 +264,7 @@ export const AgentLaunchPicker = memo(
|
||||
onSelectAgent={selectAgent}
|
||||
defaultAgent={defaultAgent}
|
||||
onSetDefault={onSetDefault}
|
||||
statusLabels={statusLabels}
|
||||
runLaunch={runLaunch}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -28,6 +28,7 @@ export function AgentLaunchPickerMenu({
|
||||
model,
|
||||
draftScope,
|
||||
shortcutLabels,
|
||||
statusLabels,
|
||||
disabled,
|
||||
setupDisabled,
|
||||
mode,
|
||||
@@ -47,6 +48,7 @@ export function AgentLaunchPickerMenu({
|
||||
model?: NewTabAgentMenuModel
|
||||
draftScope?: object
|
||||
shortcutLabels?: ReadonlyMap<AgentPickerEntry['agent'], string>
|
||||
statusLabels?: ReadonlyMap<AgentPickerEntry['agent'], string>
|
||||
disabled?: boolean
|
||||
setupDisabled?: boolean
|
||||
mode?: 'launch' | 'select'
|
||||
@@ -235,6 +237,7 @@ export function AgentLaunchPickerMenu({
|
||||
isDefault={defaultAgent === entry.agent}
|
||||
onSetDefault={onSetDefault}
|
||||
shortcut={mode !== 'select' ? shortcutLabels?.get(entry.agent) : undefined}
|
||||
status={statusLabels?.get(entry.agent)}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -56,6 +56,7 @@ export const AgentPickerMenuRow = memo(function AgentPickerMenuRow({
|
||||
terminalBlocked,
|
||||
runLaunch,
|
||||
shortcut,
|
||||
status,
|
||||
onSelectAgent,
|
||||
isDefault = false,
|
||||
onSetDefault
|
||||
@@ -85,6 +86,8 @@ export const AgentPickerMenuRow = memo(function AgentPickerMenuRow({
|
||||
terminalBlocked?: boolean
|
||||
runLaunch: AgentPickerMenuLaunch
|
||||
shortcut?: string
|
||||
/** Muted status after the label, such as "Ready" or "Set up" for Orca Cloud (JA-22). */
|
||||
status?: string
|
||||
onSelectAgent?: (agent: AgentPickerEntry['agent']) => void
|
||||
isDefault?: boolean
|
||||
/** Base agent rows only; setup rows are presets, not default-agent choices. */
|
||||
@@ -135,6 +138,12 @@ export const AgentPickerMenuRow = memo(function AgentPickerMenuRow({
|
||||
<span className="truncate text-xs text-muted-foreground">{entry.description}</span>
|
||||
) : null}
|
||||
</span>
|
||||
{status ? (
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
<span className="sr-only">, </span>
|
||||
{status}
|
||||
</span>
|
||||
) : null}
|
||||
{shortcut ? <DropdownMenuShortcut>{shortcut}</DropdownMenuShortcut> : null}
|
||||
</DropdownMenuItem>
|
||||
</AgentDefaultContextMenu>
|
||||
@@ -223,6 +232,12 @@ export const AgentPickerMenuRow = memo(function AgentPickerMenuRow({
|
||||
<AgentIcon agent={entry.agent} size={14} />
|
||||
<span className="min-w-0 flex-1 truncate text-left">{label}</span>
|
||||
{shortcut ? <DropdownMenuShortcut>{shortcut}</DropdownMenuShortcut> : null}
|
||||
{status && !launchBlocked ? (
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
<span className="sr-only">, </span>
|
||||
{status}
|
||||
</span>
|
||||
) : null}
|
||||
{launchBlocked ? (
|
||||
<span
|
||||
id={reasonId}
|
||||
|
||||
@@ -29,6 +29,8 @@ export type AgentComboboxSurfaceRows = {
|
||||
selection: ReturnType<typeof resolveAgentMenuSelection>
|
||||
contextKey?: string
|
||||
onPick: (agent: TuiAgent, surface: AgentLaunchSurface) => void
|
||||
/** A muted status per agent row inside the open menu only (Orca Cloud: JA-22). */
|
||||
statusLabels?: ReadonlyMap<TuiAgent, string>
|
||||
}
|
||||
|
||||
/** The host has not answered what the choices are; a terminal only waiting on its host does not
|
||||
|
||||
@@ -99,6 +99,7 @@ export function NewWorkspaceComposerAgentSection({
|
||||
emptyLabel={t('auto.components.agent.AgentCombobox.986f946354', 'Blank terminal')}
|
||||
defaultAgent={defaultTuiAgent}
|
||||
onSetDefault={handleSetDefaultAgent}
|
||||
statusLabels={agentSurfaceRows?.statusLabels}
|
||||
onSelectBlankTerminal={() => onQuickAgentChange(null)}
|
||||
onPick={(agent, draft, entry) => onQuickAgentChange(agent, draft?.surface, draft, entry)}
|
||||
/>
|
||||
|
||||
@@ -12,6 +12,7 @@ function Picker(props: {
|
||||
agent: TuiAgent
|
||||
disabled?: TuiAgent[]
|
||||
notice?: string
|
||||
statusLabels?: ReadonlyMap<TuiAgent, string>
|
||||
}): React.JSX.Element {
|
||||
const model = orcaCloudAgentMenuModel({
|
||||
defaultTuiAgent: 'claude',
|
||||
@@ -30,6 +31,7 @@ function Picker(props: {
|
||||
onSetDefault={noop}
|
||||
onSelectBlankTerminal={noop}
|
||||
onPick={noop}
|
||||
statusLabels={props.statusLabels}
|
||||
/>
|
||||
{props.notice ? <p className="text-xs text-muted-foreground">{props.notice}</p> : null}
|
||||
</div>
|
||||
@@ -71,3 +73,44 @@ export const fallback = defineFixture({
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
/** JA-22: each row says whether a cloud workspace can run it as-is (inside the open menu only). */
|
||||
// No status means ready (design-squad): Claude, OpenCode and Copilot carry none here.
|
||||
const STATUS: ReadonlyMap<TuiAgent, string> = new Map<TuiAgent, string>([
|
||||
['codex', 'Not set up'],
|
||||
['gemini', 'Not set up'],
|
||||
['cursor', 'Not set up']
|
||||
])
|
||||
|
||||
export const openWithStatus = defineFixture({
|
||||
width: 480,
|
||||
render: () => <Picker agent="claude" statusLabels={STATUS} />,
|
||||
interact: open
|
||||
})
|
||||
|
||||
/** Closed: nothing changes on the button (Neil). */
|
||||
export const closedWithStatus = defineFixture({
|
||||
width: 480,
|
||||
render: () => <Picker agent="claude" statusLabels={STATUS} />
|
||||
})
|
||||
|
||||
/** Orca-account sign-in off here (prod today): Claude and Codex sign in per workspace. */
|
||||
export const openPerWorkspace = defineFixture({
|
||||
width: 480,
|
||||
render: () => (
|
||||
<Picker
|
||||
agent="claude"
|
||||
statusLabels={
|
||||
new Map<TuiAgent, string>([
|
||||
['claude', 'Signs in per workspace'],
|
||||
['codex', 'Signs in per workspace'],
|
||||
['opencode', 'Not set up'],
|
||||
['gemini', 'Not set up'],
|
||||
['cursor', 'Not set up'],
|
||||
['copilot', 'Not set up']
|
||||
])
|
||||
}
|
||||
/>
|
||||
),
|
||||
interact: open
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useOrcaCloudAgentPickerStatusLabels } from '@/lib/orca-cloud/orca-cloud-agent-picker-status'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { agentChoicePending } from '@/lib/host-chat-program'
|
||||
import { useAgentsOfferedForLaunch } from '@/lib/host-chat-program-acquisition'
|
||||
@@ -82,5 +83,7 @@ export function useComposerQuickAgent(
|
||||
// Orca Cloud adds nothing to the dialog (Neil): an agent it can't run falls back silently; the
|
||||
// picker shows what will start.
|
||||
const agentNotice: string | undefined = undefined
|
||||
return { orcaCloud, orcaCloudModel, quickAgent, chipAgentIds, agentNotice }
|
||||
// JA-22: inside the open menu only, which image agents a cloud workspace can run as-is.
|
||||
const statusLabels = useOrcaCloudAgentPickerStatusLabels(orcaCloud)
|
||||
return { orcaCloud, orcaCloudModel, quickAgent, chipAgentIds, agentNotice, statusLabels }
|
||||
}
|
||||
|
||||
+6
@@ -2325,6 +2325,12 @@
|
||||
"menu": {
|
||||
"quitApp": "Quit {{appName}}"
|
||||
},
|
||||
"orcaCloudAgentPicker": {
|
||||
"status": {
|
||||
"ready": "Ready",
|
||||
"setUp": "Set up"
|
||||
}
|
||||
},
|
||||
"orcaCloudMove": {
|
||||
"confirm": {
|
||||
"changesCount_one": "{{count}} uncommitted change, plus untracked files",
|
||||
|
||||
@@ -28086,5 +28086,14 @@
|
||||
},
|
||||
"untitled": "New cloud workspace",
|
||||
"waitingBrowser": "Waiting for your browser…"
|
||||
},
|
||||
"orcaCloudAgentPicker": {
|
||||
"status": {
|
||||
"ready": "Ready",
|
||||
"setUp": "Set up",
|
||||
"perWorkspace": "Signs in per workspace",
|
||||
"notAvailable": "Not available in cloud",
|
||||
"notSetUp": "Not set up"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ export type OrcaCloudAgentAccountsState = {
|
||||
load: OrcaCloudAgentAccountsLoad
|
||||
setups: OrcaCloudAgentSetups
|
||||
keyKinds: Record<OrcaCloudAccountAgent, AgentKeyKind | null>
|
||||
/** Names (never values) of the Cloud secrets a new workspace gets; null until read (JA-22). */
|
||||
cloudSecretNames?: ReadonlySet<string> | null
|
||||
/** The build sheet's R2 Set up: agents set up in turn; `index` is the one running now. */
|
||||
queue: { agents: readonly OrcaCloudAccountAgent[]; index: number }
|
||||
}
|
||||
@@ -37,6 +39,7 @@ let state: OrcaCloudAgentAccountsState = {
|
||||
load: { kind: 'loading' },
|
||||
setups: IDLE_ORCA_CLOUD_AGENT_SETUPS,
|
||||
keyKinds: NO_KEYS,
|
||||
cloudSecretNames: null,
|
||||
queue: NO_QUEUE
|
||||
}
|
||||
// Set once the queued agent's setup has left idle, so idle afterwards means it finished.
|
||||
@@ -84,7 +87,10 @@ export async function reloadOrcaCloudAgentAccounts(): Promise<void> {
|
||||
: result.error === 'not_configured'
|
||||
? { kind: 'unavailable' }
|
||||
: { kind: 'failed', error: result.error },
|
||||
keyKinds: effective?.ok ? agentKeyKinds(effective.value.secrets) : state.keyKinds
|
||||
keyKinds: effective?.ok ? agentKeyKinds(effective.value.secrets) : state.keyKinds,
|
||||
cloudSecretNames: effective?.ok
|
||||
? new Set(effective.value.secrets.map((secret) => secret.name))
|
||||
: state.cloudSecretNames
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { OrcaCloudAgentsStatus } from '../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import type { OrcaCloudAgentAccountsRead } from './orca-cloud-agent-accounts-model'
|
||||
import {
|
||||
orcaCloudAgentPickerStatus,
|
||||
orcaCloudAgentPickerStatusLabel
|
||||
} from './orca-cloud-agent-picker-status'
|
||||
|
||||
function status(patch: Partial<OrcaCloudAgentsStatus['credentials']> = {}): OrcaCloudAgentsStatus {
|
||||
return {
|
||||
credentials: {
|
||||
claude: { state: 'none' },
|
||||
codex: { state: 'none' },
|
||||
providerEnabled: { claude: true, codex: true },
|
||||
...patch
|
||||
},
|
||||
sources: { defaults: {}, coveredByKey: { claude: false, codex: false } }
|
||||
}
|
||||
}
|
||||
|
||||
function accounts(
|
||||
load: OrcaCloudAgentAccountsRead['load'],
|
||||
names: string[] | null = []
|
||||
): OrcaCloudAgentAccountsRead & { cloudSecretNames: ReadonlySet<string> | null } {
|
||||
return {
|
||||
load,
|
||||
keyKinds: { claude: null, codex: null },
|
||||
cloudSecretNames: names ? new Set(names) : null
|
||||
}
|
||||
}
|
||||
|
||||
describe('orcaCloudAgentPickerStatus (JA-22)', () => {
|
||||
it('shows nothing until the account is read', () => {
|
||||
expect(orcaCloudAgentPickerStatus('claude', accounts({ kind: 'loading' }))).toBeNull()
|
||||
expect(orcaCloudAgentPickerStatus('gemini', accounts({ kind: 'loading' }, null))).toBeNull()
|
||||
})
|
||||
|
||||
it('reads Claude and Codex from the Orca account', () => {
|
||||
const ready = accounts({ kind: 'ready', status: status({ claude: { state: 'active' } }) })
|
||||
expect(orcaCloudAgentPickerStatus('claude', ready)).toBe('ready')
|
||||
expect(orcaCloudAgentPickerStatus('codex', ready)).toBe('setUp')
|
||||
const expired = accounts({ kind: 'ready', status: status({ claude: { state: 'expired' } }) })
|
||||
expect(orcaCloudAgentPickerStatus('claude', expired)).toBe('setUp')
|
||||
})
|
||||
|
||||
it('says a paused or never-offered provider signs in per workspace, never "Set up"', () => {
|
||||
const off = accounts({
|
||||
kind: 'ready',
|
||||
status: status({
|
||||
providerEnabled: { claude: false, codex: false },
|
||||
providerState: { claude: 'off', codex: 'disabled' }
|
||||
})
|
||||
})
|
||||
expect(orcaCloudAgentPickerStatus('claude', off)).toBe('perWorkspace')
|
||||
expect(orcaCloudAgentPickerStatus('codex', off)).toBe('perWorkspace')
|
||||
})
|
||||
|
||||
it('reads API-key agents from Cloud secret names only', () => {
|
||||
const load = { kind: 'ready', status: status() } as const
|
||||
expect(orcaCloudAgentPickerStatus('gemini', accounts(load, ['GOOGLE_API_KEY']))).toBe('ready')
|
||||
expect(orcaCloudAgentPickerStatus('cursor', accounts(load, ['GOOGLE_API_KEY']))).toBe('setUp')
|
||||
expect(orcaCloudAgentPickerStatus('copilot', accounts(load, ['COPILOT_GITHUB_TOKEN']))).toBe(
|
||||
'ready'
|
||||
)
|
||||
expect(orcaCloudAgentPickerStatus('opencode', accounts(load, ['OPENAI_API_KEY']))).toBe('ready')
|
||||
expect(orcaCloudAgentPickerStatus('opencode', accounts(load, []))).toBe('setUp')
|
||||
})
|
||||
|
||||
it('marks agents the image does not ship', () => {
|
||||
expect(orcaCloudAgentPickerStatus('aider', accounts({ kind: 'loading' }))).toBe('notAvailable')
|
||||
})
|
||||
})
|
||||
|
||||
describe('orcaCloudAgentPickerStatusLabel (JA-22)', () => {
|
||||
const t: Translate = (_key, fallback) => fallback
|
||||
it('says nothing for ready and names the state otherwise', () => {
|
||||
expect(orcaCloudAgentPickerStatusLabel('ready', t)).toBeNull()
|
||||
expect(orcaCloudAgentPickerStatusLabel('setUp', t)).toBe('Not set up')
|
||||
expect(orcaCloudAgentPickerStatusLabel('perWorkspace', t)).toBe('Signs in per workspace')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,117 @@
|
||||
// JA-22: the status suffix each agent row shows inside the open agent picker when Run on is Orca
|
||||
// Cloud. Claude and Codex read the Orca account coverage (the shared selector); the API-key agents
|
||||
// read whether a Cloud secret they use exists. Names only: no secret value ever reaches here.
|
||||
import { useMemo } from 'react'
|
||||
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
|
||||
import {
|
||||
ORCA_CLOUD_IMAGE_AGENTS,
|
||||
isOrcaCloudImageAgent
|
||||
} from '../../../../shared/hosted-sandbox/orca-cloud-image-agents'
|
||||
import {
|
||||
orcaCloudAgentCoverageFromAccounts,
|
||||
type OrcaCloudAgentAccountsRead
|
||||
} from './orca-cloud-agent-accounts-model'
|
||||
import { useTranslate, type Translate } from '@/i18n/use-translate'
|
||||
import { useOrcaCloudAgentAccounts } from './orca-cloud-agent-accounts-store'
|
||||
|
||||
export type OrcaCloudAgentPickerStatus =
|
||||
/** A new cloud workspace can run it with nothing more to do. */
|
||||
| 'ready'
|
||||
/** Not set up yet: the Orca account (Claude, Codex) or a key in Cloud secrets. */
|
||||
| 'setUp'
|
||||
/** Orca-account sign-in is off or paused here: the agent signs in inside each workspace. */
|
||||
| 'perWorkspace'
|
||||
/** The Orca Cloud image doesn't ship it. */
|
||||
| 'notAvailable'
|
||||
|
||||
/**
|
||||
* Cloud secrets that make each API-key agent work in a cloud workspace. Copilot and Cursor read
|
||||
* their own token; Gemini its Google key; OpenCode any model provider key it supports.
|
||||
*/
|
||||
const API_KEY_AGENT_NAMES: Partial<Record<TuiAgent, readonly string[]>> = {
|
||||
copilot: ['COPILOT_GITHUB_TOKEN', 'COPILOT_PROVIDER_API_KEY', 'COPILOT_PROVIDER_BEARER_TOKEN'],
|
||||
cursor: ['CURSOR_API_KEY'],
|
||||
gemini: ['GEMINI_API_KEY', 'GOOGLE_API_KEY', 'GOOGLE_GENERATIVE_AI_API_KEY'],
|
||||
opencode: [
|
||||
'ANTHROPIC_API_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'GEMINI_API_KEY',
|
||||
'GOOGLE_GENERATIVE_AI_API_KEY',
|
||||
'AI_GATEWAY_API_KEY',
|
||||
'OPENROUTER_API_KEY',
|
||||
'GROQ_API_KEY',
|
||||
'XAI_API_KEY',
|
||||
'MISTRAL_API_KEY',
|
||||
'DEEPSEEK_API_KEY'
|
||||
]
|
||||
}
|
||||
|
||||
/** Null while the account or Cloud secrets aren't read yet, so the row shows no suffix. */
|
||||
export function orcaCloudAgentPickerStatus(
|
||||
agent: TuiAgent,
|
||||
accounts: OrcaCloudAgentAccountsRead & { cloudSecretNames?: ReadonlySet<string> | null }
|
||||
): OrcaCloudAgentPickerStatus | null {
|
||||
if (!isOrcaCloudImageAgent(agent)) {
|
||||
return 'notAvailable'
|
||||
}
|
||||
if (agent === 'claude' || agent === 'codex') {
|
||||
const coverage = orcaCloudAgentCoverageFromAccounts(agent, accounts)
|
||||
switch (coverage?.kind) {
|
||||
case undefined:
|
||||
return null
|
||||
case 'account':
|
||||
case 'key':
|
||||
return 'ready'
|
||||
case 'notSetUp':
|
||||
case 'expired':
|
||||
return 'setUp'
|
||||
case 'killSwitch':
|
||||
case 'unavailable':
|
||||
return 'perWorkspace'
|
||||
}
|
||||
}
|
||||
const names = accounts.cloudSecretNames ?? null
|
||||
if (!names) {
|
||||
return null
|
||||
}
|
||||
return (API_KEY_AGENT_NAMES[agent] ?? []).some((name) => names.has(name)) ? 'ready' : 'setUp'
|
||||
}
|
||||
|
||||
/** The muted suffix; null for 'ready' (no status means ready, design-squad JA-22). */
|
||||
export function orcaCloudAgentPickerStatusLabel(
|
||||
status: OrcaCloudAgentPickerStatus,
|
||||
t: Translate
|
||||
): string | null {
|
||||
switch (status) {
|
||||
case 'ready':
|
||||
return null
|
||||
case 'setUp':
|
||||
return t('orcaCloudAgentPicker.status.notSetUp', 'Not set up')
|
||||
case 'perWorkspace':
|
||||
return t('orcaCloudAgentPicker.status.perWorkspace', 'Signs in per workspace')
|
||||
case 'notAvailable':
|
||||
return t('orcaCloudAgentPicker.status.notAvailable', 'Not available in cloud')
|
||||
}
|
||||
}
|
||||
|
||||
/** Status labels for the image agents while Run on is Orca Cloud; undefined otherwise. */
|
||||
export function useOrcaCloudAgentPickerStatusLabels(
|
||||
enabled: boolean
|
||||
): ReadonlyMap<TuiAgent, string> | undefined {
|
||||
const t = useTranslate()
|
||||
const accounts = useOrcaCloudAgentAccounts(enabled)
|
||||
return useMemo(() => {
|
||||
if (!enabled) {
|
||||
return undefined
|
||||
}
|
||||
const labels = new Map<TuiAgent, string>()
|
||||
for (const agent of ORCA_CLOUD_IMAGE_AGENTS) {
|
||||
const status = orcaCloudAgentPickerStatus(agent, accounts)
|
||||
const label = status ? orcaCloudAgentPickerStatusLabel(status, t) : null
|
||||
if (label) {
|
||||
labels.set(agent, label)
|
||||
}
|
||||
}
|
||||
return labels
|
||||
}, [enabled, accounts, t])
|
||||
}
|
||||
Reference in New Issue
Block a user