diff --git a/src/renderer/src/components/NewWorkspaceComposerModal.tsx b/src/renderer/src/components/NewWorkspaceComposerModal.tsx index 5e5f9c61cba..af9cd3fba86 100644 --- a/src/renderer/src/components/NewWorkspaceComposerModal.tsx +++ b/src/renderer/src/components/NewWorkspaceComposerModal.tsx @@ -174,7 +174,7 @@ function QuickTabBody({ const [quickAgentOverride, setQuickAgentOverride] = useState( 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 } diff --git a/src/renderer/src/components/agent/AgentLaunchPicker.tsx b/src/renderer/src/components/agent/AgentLaunchPicker.tsx index 4c28231b0b6..56e65ef80d3 100644 --- a/src/renderer/src/components/agent/AgentLaunchPicker.tsx +++ b/src/renderer/src/components/agent/AgentLaunchPicker.tsx @@ -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 onPick: ( agent: AgentPickerEntry['agent'], draft?: AgentPickerDraft, @@ -261,6 +264,7 @@ export const AgentLaunchPicker = memo( onSelectAgent={selectAgent} defaultAgent={defaultAgent} onSetDefault={onSetDefault} + statusLabels={statusLabels} runLaunch={runLaunch} /> ) : ( diff --git a/src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx b/src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx index e384ca0b4ad..5d1de091110 100644 --- a/src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx +++ b/src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx @@ -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 + statusLabels?: ReadonlyMap 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)} /> ) })} diff --git a/src/renderer/src/components/agent/AgentLaunchPickerMenuRow.tsx b/src/renderer/src/components/agent/AgentLaunchPickerMenuRow.tsx index ce63771d05c..cb3b571a93f 100644 --- a/src/renderer/src/components/agent/AgentLaunchPickerMenuRow.tsx +++ b/src/renderer/src/components/agent/AgentLaunchPickerMenuRow.tsx @@ -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({ {entry.description} ) : null} + {status ? ( + + , + {status} + + ) : null} {shortcut ? {shortcut} : null} @@ -223,6 +232,12 @@ export const AgentPickerMenuRow = memo(function AgentPickerMenuRow({ {label} {shortcut ? {shortcut} : null} + {status && !launchBlocked ? ( + + , + {status} + + ) : null} {launchBlocked ? ( 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 } /** The host has not answered what the choices are; a terminal only waiting on its host does not diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerAgentSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerAgentSection.tsx index f31b3565d47..deb8c51046d 100644 --- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerAgentSection.tsx +++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerAgentSection.tsx @@ -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)} /> diff --git a/src/renderer/src/components/new-workspace/OrcaCloudAgentPicker.fixture.tsx b/src/renderer/src/components/new-workspace/OrcaCloudAgentPicker.fixture.tsx index db0fe70c7ba..47078078e9d 100644 --- a/src/renderer/src/components/new-workspace/OrcaCloudAgentPicker.fixture.tsx +++ b/src/renderer/src/components/new-workspace/OrcaCloudAgentPicker.fixture.tsx @@ -12,6 +12,7 @@ function Picker(props: { agent: TuiAgent disabled?: TuiAgent[] notice?: string + statusLabels?: ReadonlyMap }): 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 ?

{props.notice}

: null} @@ -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 = new Map([ + ['codex', 'Not set up'], + ['gemini', 'Not set up'], + ['cursor', 'Not set up'] +]) + +export const openWithStatus = defineFixture({ + width: 480, + render: () => , + interact: open +}) + +/** Closed: nothing changes on the button (Neil). */ +export const closedWithStatus = defineFixture({ + width: 480, + render: () => +}) + +/** Orca-account sign-in off here (prod today): Claude and Codex sign in per workspace. */ +export const openPerWorkspace = defineFixture({ + width: 480, + render: () => ( + ([ + ['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 +}) diff --git a/src/renderer/src/components/new-workspace/use-composer-quick-agent.ts b/src/renderer/src/components/new-workspace/use-composer-quick-agent.ts index e8d235303eb..90e0bacc709 100644 --- a/src/renderer/src/components/new-workspace/use-composer-quick-agent.ts +++ b/src/renderer/src/components/new-workspace/use-composer-quick-agent.ts @@ -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 } } diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index 5a71a0907a4..3c0a5fcb2a9 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -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", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index ec448c98c22..9b54c89ddbe 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -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" + } } } diff --git a/src/renderer/src/lib/orca-cloud/orca-cloud-agent-accounts-store.ts b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-accounts-store.ts index 3da5ad97a35..e1b513c1132 100644 --- a/src/renderer/src/lib/orca-cloud/orca-cloud-agent-accounts-store.ts +++ b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-accounts-store.ts @@ -25,6 +25,8 @@ export type OrcaCloudAgentAccountsState = { load: OrcaCloudAgentAccountsLoad setups: OrcaCloudAgentSetups keyKinds: Record + /** Names (never values) of the Cloud secrets a new workspace gets; null until read (JA-22). */ + cloudSecretNames?: ReadonlySet | 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 { : 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 }) } diff --git a/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.test.ts b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.test.ts new file mode 100644 index 00000000000..cbc466e9207 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.test.ts @@ -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 { + 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 | 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') + }) +}) diff --git a/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.ts b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.ts new file mode 100644 index 00000000000..d6c8a43726a --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/orca-cloud-agent-picker-status.ts @@ -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> = { + 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 | 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 | undefined { + const t = useTranslate() + const accounts = useOrcaCloudAgentAccounts(enabled) + return useMemo(() => { + if (!enabled) { + return undefined + } + const labels = new Map() + 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]) +}