Merge pull request #293 from nwparker/cloud/agents-host-panel-hosts

feat(cloud): A16 panel on hosts with their own login (2/2, stacked on #292)
This commit is contained in:
Neil
2026-11-10 09:51:17 -08:00
committed by GitHub
13 changed files with 743 additions and 40 deletions
@@ -264,3 +264,4 @@ export const hostMenu = defineFixture({
</div>
)
})
export * from './agent-host-panel-host-fixtures'
@@ -3,7 +3,7 @@ import { cleanup, render, screen, waitFor } from '@testing-library/react'
import { afterEach, describe, expect, it } from 'vitest'
import { Sheet } from '@/components/ui/sheet'
import type { OrcaCloudAgentsStatus } from '../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
import { CloudHostPanel } from './AgentHostPanel'
import { CloudHostPanel, HostPanel } from './AgentHostPanel'
import type { ResolvedAgentHost } from './use-agent-host'
const STATUS: OrcaCloudAgentsStatus = {
@@ -100,3 +100,56 @@ describe('AgentHostPanel on Orca Cloud', () => {
expect(calls.filter((call) => !allowed.has(call))).toEqual([])
})
})
describe('AgentHostPanel on hosts with their own login', () => {
const stopped = (
kind: ResolvedAgentHost['kind'],
availability: ResolvedAgentHost['availability']
): ResolvedAgentHost => ({
hostId: 'runtime:env-2',
label: 'Ubuntu-24.04',
kind,
availability,
environmentId: 'env-2',
cloud: null
})
it.each([
['wsl', 'stopped'],
['recipe', 'suspended'],
['paired', 'unreachable'],
['sshOrcad', 'disconnected']
] as const)(
'never asks a %s host that is %s (no start, resume, wake or connect)',
async (kind, availability) => {
const calls: string[] = []
Object.defineProperty(window, 'api', { value: recordingApi(calls), configurable: true })
render(
<Sheet open>
<HostPanel host={stopped(kind, availability)} />
</Sheet>
)
await waitFor(() => expect(calls).toContain('agentApiKeys.list'))
const allowed = new Set(['agentApiKeys.list', 'ephemeralVm.forwardedEnvSummary'])
expect(calls.filter((call) => !allowed.has(call))).toEqual([])
}
)
it('shows why sign-in actions are off on a stopped distro', async () => {
const calls: string[] = []
Object.defineProperty(window, 'api', { value: recordingApi(calls), configurable: true })
render(
<Sheet open>
<HostPanel host={stopped('wsl', 'stopped')} />
</Sheet>
)
expect(
await screen.findByText(
'Ubuntu-24.04 is stopped. Opening a workspace on it starts it as usual.'
)
).toBeTruthy()
expect(
screen.getByText('Sign-ins inside the distro. Windows sign-ins don’t carry over.')
).toBeTruthy()
})
})
@@ -1,6 +1,11 @@
// The app's one "Agent accounts & secrets" sheet. Opened through openAgentHostPanel({ hostId, focus });
// it resolves the host from renderer state and never connects, wakes, starts or resumes it.
import React from 'react'
import React, { useState, useSyncExternalStore } from 'react'
import {
readHostAgentSignInReport,
subscribeHostAgentSignInReports
} from '@/runtime/provider-accounts/sign-in/host-agent-sign-in-status-client'
import { formatDate } from '../settings/agent-accounts/orca-cloud-account-row-shell'
import { Sheet } from '@/components/ui/sheet'
import { useTranslate } from '@/i18n/use-translate'
import { hostCapabilities } from './agent-host-capabilities'
@@ -11,6 +16,7 @@ import {
} from './agent-host-panel-store'
import { AgentHostPanelView } from './AgentHostPanelView'
import { useCloudHostPanelBody } from './CloudHostPanelBody'
import { useHostPanelBody } from './HostPanelBody'
import { openAgentHostSettings } from './open-agent-host-settings'
import { useResolvedAgentHost, type ResolvedAgentHost } from './use-agent-host'
@@ -41,14 +47,55 @@ export function CloudHostPanel({
)
}
const NO_ENVIRONMENT = '\u0000'
/** Every other kind: the host's own sign-ins, this computer's keys that apply, one env line. */
export function HostPanel({ host }: { host: ResolvedAgentHost }): React.JSX.Element {
const t = useTranslate()
const [generation, setGeneration] = useState(0)
const cached = useSyncExternalStore(subscribeHostAgentSignInReports, () =>
readHostAgentSignInReport(host.environmentId ?? NO_ENVIRONMENT)
)
const capabilities = hostCapabilities(
host.kind,
host.availability,
{ host: host.label, date: cached ? formatDate(cached.checkedAt) : null },
t
)
const body = useHostPanelBody(host, capabilities, generation, () =>
setGeneration((value) => value + 1)
)
return (
<AgentHostPanelView
capabilities={capabilities}
subject={host.label}
dot={
host.kind === 'recipe'
? host.availability === 'available'
? 'running'
: host.availability === 'suspended'
? 'sleeping'
: 'unknown'
: null
}
agents={body.agents}
keys={body.keys}
environment={body.environment}
onFooterLink={openAgentHostSettings}
/>
)
}
export function AgentHostPanel(): React.JSX.Element {
const request = useAgentHostPanelRequest()
const host = useResolvedAgentHost(request)
// v1: Orca Cloud hosts; the other kinds follow with their own section 1.
const cloud = host?.kind === 'cloud' ? host : null
return (
<Sheet open={cloud !== null} onOpenChange={(open) => !open && closeAgentHostPanel()}>
{cloud ? <CloudHostPanel key={cloud.hostId} host={cloud} focus={request?.focus} /> : null}
<Sheet open={host !== null} onOpenChange={(open) => !open && closeAgentHostPanel()}>
{host?.kind === 'cloud' ? (
<CloudHostPanel key={host.hostId} host={host} focus={request?.focus} />
) : host ? (
<HostPanel key={host.hostId} host={host} />
) : null}
</Sheet>
)
}
@@ -0,0 +1,167 @@
// Panel section 1 on hosts with their own login: each agent's verdict from the host, and Sign out…
// (moved here from the host ⋯ menu). Actions that need the host say why when it can't answer.
import React from 'react'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { Button } from '@/components/ui/button'
import { InlineError } from '@/components/ui/inline-error'
import { HOST_AGENT_SIGN_IN_AGENT_NAME } from '../../../../shared/host-agent-sign-in-status'
import type { HostAgentSignInAgent } from '../../../../shared/host-agent-sign-in-status'
import { SettingsDisabledControlTooltip } from '../settings/form-controls/SettingsDisabledControlTooltip'
import { LoadingRows, PanelSection } from './cloud-sections/PanelSection'
import type { HostAgentPanelRow, HostAgentPanelState } from './host-agents-panel-model'
export type HostAgentsPanelSectionProps = {
title: string
help: string
host: string
/** Null: this host kind can't report sign-ins yet (classic SSH). */
rows: readonly HostAgentPanelRow[] | null
checking: boolean
failed: boolean
/** "last checked Nov 9" while the host can't answer; null when live or never checked. */
lastChecked: string | null
signOut: boolean
actionsDisabledReason: string | null
onSignOut: (agent: HostAgentSignInAgent) => void
onCheckAgain: () => void
}
function stateLabel(state: HostAgentPanelState, t: Translate): string {
switch (state) {
case 'signedIn':
return t('agentHostPanel.host.signedIn', 'Signed in')
case 'apiKey':
return t('agentHostPanel.host.apiKey', 'Signed in with an API key')
case 'signedOut':
return t('agentHostPanel.host.signedOut', 'Signed out')
case 'notInstalled':
return t('agentHostPanel.host.notInstalled', 'Not installed')
case 'unknown':
return t('agentHostPanel.host.unknown', 'Not checked yet')
}
}
function SignOutButton({
agent,
reason,
onSignOut
}: {
agent: HostAgentSignInAgent
reason: string | null
onSignOut: (agent: HostAgentSignInAgent) => void
}): React.JSX.Element {
const t = useTranslate()
const reasonId = React.useId()
const label = t('agentSignIn.signOutOf', 'Sign out of {{agent}}…', {
agent: HOST_AGENT_SIGN_IN_AGENT_NAME[agent]
})
return (
<SettingsDisabledControlTooltip reason={reason ?? undefined}>
<Button
type="button"
variant="outline"
size="xs"
aria-label={label}
aria-disabled={reason ? 'true' : undefined}
aria-describedby={reason ? reasonId : undefined}
onClick={() => (reason ? undefined : onSignOut(agent))}
>
{t('agentHostPanel.host.signOut', 'Sign out…')}
{reason ? (
<span id={reasonId} className="sr-only">
{reason}
</span>
) : null}
</Button>
</SettingsDisabledControlTooltip>
)
}
export function HostAgentsPanelSection(props: HostAgentsPanelSectionProps): React.JSX.Element {
const t = useTranslate()
const { rows, checking, failed, lastChecked, host } = props
const announce = rows
? rows
.map((row) => `${HOST_AGENT_SIGN_IN_AGENT_NAME[row.agent]} ${stateLabel(row.state, t)}.`)
.join(' ')
: ''
return (
<PanelSection title={props.title} help={props.help}>
{rows === null ? (
<p className="text-xs text-muted-foreground">
{t(
'agentHostPanel.host.cantCheck',
'Orca can’t check sign-ins on {{host}} yet. Start an agent in a workspace there to sign in.',
{ host }
)}
</p>
) : checking && rows.every((row) => row.state === 'unknown') ? (
<LoadingRows />
) : (
<>
{failed ? (
<InlineError
tone="neutral"
density="compact"
title={t(
'agentHostPanel.host.noAnswer',
'{{host}} didn’t answer. It may run an older Orca.',
{ host }
)}
retryLabel={t('agentHostPanel.retry', 'Try again')}
onRetry={props.onCheckAgain}
/>
) : null}
<ul className="flex flex-col divide-y divide-border/60">
{rows.map((row) => {
const muted = checking
? t('agentHostPanel.host.checking', 'Checking…')
: lastChecked
? t('agentHostPanel.host.lastChecked', 'last checked {{date}}', {
date: lastChecked
})
: null
return (
<li
key={row.agent}
data-agent={row.agent}
className="grid grid-cols-[5rem_minmax(0,1fr)_auto] items-center gap-x-3 py-2.5"
>
<span className="text-sm text-foreground">
{HOST_AGENT_SIGN_IN_AGENT_NAME[row.agent]}
</span>
<div className="flex min-w-0 flex-col gap-0.5">
<span className="text-sm text-foreground">
{[stateLabel(row.state, t), muted].filter(Boolean).join(' · ')}
</span>
{row.state === 'signedOut' ? (
<span className="text-xs text-muted-foreground">
{t(
'agentHostPanel.host.signInHint',
'Start {{agent}} in a workspace on {{host}} to sign in.',
{ agent: HOST_AGENT_SIGN_IN_AGENT_NAME[row.agent], host }
)}
</span>
) : null}
</div>
{props.signOut && row.canSignOut ? (
<SignOutButton
agent={row.agent}
reason={props.actionsDisabledReason}
onSignOut={props.onSignOut}
/>
) : (
<span />
)}
</li>
)
})}
</ul>
<span role="status" className="sr-only">
{checking ? '' : announce}
</span>
</>
)}
</PanelSection>
)
}
@@ -0,0 +1,144 @@
// The panel on hosts that keep their own login. Section 1 asks the host once per open while it can
// answer; sections 2–3 read only this computer (Agent API keys, the recipe env summary).
import React, { useEffect, useState } from 'react'
import { useTranslate } from '@/i18n/use-translate'
import { Button } from '@/components/ui/button'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import type { AgentApiKeySummary } from '../../../../shared/agent-api-keys/agent-api-key-catalog'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { RecipeForwardedEnvSummary } from '../../../../shared/ephemeral-vm-recipe-forwarded-env'
import type { HostAgentSignInAgent } from '../../../../shared/host-agent-sign-in-status'
import { HostAgentSignOutDialog } from '../sidebar/worktree-list/rows/HostAgentSignOutMenuItems'
import { formatDate } from '../settings/agent-accounts/orca-cloud-account-row-shell'
import { RecipeEnvForwardingWarning } from './RecipeEnvForwardingWarning'
import type { AgentHostCapabilities } from './agent-host-capabilities'
import { HostAgentsPanelSection } from './HostAgentsPanelSection'
import { agentApiKeysForHost, hostAgentPanelRows } from './host-agents-panel-model'
import { openAgentHostSettings } from './open-agent-host-settings'
import type { ResolvedAgentHost } from './use-agent-host'
import { useHostAgentReport } from './use-host-agent-report'
function useHostKeys(hostId: ExecutionHostId): AgentApiKeySummary[] | null {
const [keys, setKeys] = useState<AgentApiKeySummary[] | null>(null)
useEffect(() => {
let cancelled = false
void (window.api.agentApiKeys?.list() ?? Promise.resolve(null))
.catch(() => null)
.then((state) => {
if (!cancelled) {
setKeys(state ? agentApiKeysForHost(state.keys, hostId) : [])
}
})
return () => {
cancelled = true
}
}, [hostId])
return keys
}
function useRecipeEnvSummary(enabled: boolean): RecipeForwardedEnvSummary | null | undefined {
const [summary, setSummary] = useState<RecipeForwardedEnvSummary | null | undefined>(null)
useEffect(() => {
if (!enabled) {
return
}
let cancelled = false
void (window.api.ephemeralVm?.forwardedEnvSummary() ?? Promise.resolve(undefined))
.catch(() => undefined)
.then((next) => !cancelled && setSummary(next))
return () => {
cancelled = true
}
}, [enabled])
return summary
}
export function HostKeysRows({ keys }: { keys: AgentApiKeySummary[] | null }): React.JSX.Element {
const t = useTranslate()
if (keys === null) {
return <span className="sr-only">{t('agentHostPanel.keys.loading', 'Loading keys…')}</span>
}
if (keys.length === 0) {
return (
<p className="text-xs text-muted-foreground">
{t('agentHostPanel.keys.noneHere', 'No keys apply to this host.')}{' '}
<Button
type="button"
variant="link"
size="xs"
onClick={() => openAgentHostSettings('agentApiKeys')}
>
{t('agentHostPanel.keys.addOne', 'Add one in Agent API keys')}
</Button>
</p>
)
}
return (
<ul className="flex flex-col divide-y divide-border/60">
{keys.map((key) => (
<li key={key.id} className="grid grid-cols-[5rem_minmax(0,1fr)] gap-x-3 py-2.5">
<span className="text-sm text-foreground">{formatAgentTypeLabel(key.agent)}</span>
<div className="flex min-w-0 flex-col gap-0.5">
<span className="truncate font-mono text-xs text-foreground">
{key.envName} ••••{key.hint}
</span>
<span className="text-xs text-muted-foreground">
{key.hostScope.kind === 'all'
? t('agentHostPanel.keys.scopeAll', 'Every host except Orca Cloud')
: t('agentHostPanel.keys.scopeHosts', 'Only the hosts you picked')}
</span>
</div>
</li>
))}
</ul>
)
}
export function useHostPanelBody(
host: ResolvedAgentHost,
capabilities: AgentHostCapabilities,
generation: number,
onCheckAgain: () => void
): { agents: React.ReactNode; keys: React.ReactNode; environment: React.ReactNode } {
const report = useHostAgentReport({
kind: host.kind,
availability: host.availability,
environmentId: host.environmentId,
generation
})
const keys = useHostKeys(host.hostId)
const recipeSummary = useRecipeEnvSummary(host.kind === 'recipe')
const [signOutAgent, setSignOutAgent] = useState<HostAgentSignInAgent | null>(null)
const unavailable = host.availability !== 'available'
const agents = (
<>
<HostAgentsPanelSection
title={capabilities.agents.title}
help={capabilities.agents.help}
host={host.label}
rows={host.kind === 'sshClassic' ? null : hostAgentPanelRows(report.report)}
checking={report.checking}
failed={report.failed}
lastChecked={unavailable && report.report ? formatDate(report.report.checkedAt) : null}
signOut={capabilities.signOut && host.environmentId !== null}
actionsDisabledReason={capabilities.actionsDisabledReason}
onSignOut={setSignOutAgent}
onCheckAgain={onCheckAgain}
/>
{host.environmentId ? (
<HostAgentSignOutDialog
environmentId={host.environmentId}
hostLabel={host.label}
agent={signOutAgent}
onClose={() => setSignOutAgent(null)}
/>
) : null}
</>
)
return {
agents,
keys: <HostKeysRows keys={keys} />,
environment:
host.kind === 'recipe' ? <RecipeEnvForwardingWarning summary={recipeSummary} /> : null
}
}
@@ -59,7 +59,7 @@ describe('hostCapabilities', () => {
)
expect(hostCapabilities('recipe', 'available', ctx, t).environmentHelp).toBeNull()
expect(hostCapabilities('cloud', 'available', ctx, t).agents.help).toBe(
'From your Orca account. Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same.'
'Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same.'
)
})
@@ -253,7 +253,7 @@ function sectionHelp(
keys: passed,
environment: t(
'agentHostPanel.help.envPaired',
'Agents on {{host}} get its own environment. Orca doesn’t add variables on paired hosts.',
'Agents on {{host}} use its own environment. Orca doesn’t add variables on paired hosts.',
{ host }
)
}
@@ -261,7 +261,7 @@ function sectionHelp(
return {
agents: t(
'agentHostPanel.help.agentsCloud',
'From your Orca account. Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same.'
'Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same.'
),
// Sections 2–3 on Cloud carry their own help (Cloud secrets).
keys: '',
@@ -0,0 +1,179 @@
// AgentHostPanel fixtures for hosts that keep their own login (spec §4 P-1…P-5). Re-exported from
// AgentHostPanel.fixture.tsx so the ids read agent-host-panel/AgentHostPanel:<name>.
import React from 'react'
import { defineFixture } from '../../component-fixtures/component-fixture'
import { Sheet } from '@/components/ui/sheet'
import { translate } from '@/i18n/i18n'
import type { AgentApiKeySummary } from '../../../../shared/agent-api-keys/agent-api-key-catalog'
import type { CloudDotState } from '@/lib/orca-cloud/orca-cloud-workspace-state'
import {
hostCapabilities,
type AgentHostAvailability,
type AgentHostKind
} from './agent-host-capabilities'
import { AgentHostPanelView } from './AgentHostPanelView'
import { HostAgentsPanelSection } from './HostAgentsPanelSection'
import { HostKeysRows } from './HostPanelBody'
import type { HostAgentPanelRow } from './host-agents-panel-model'
import { RecipeEnvForwardingWarning } from './RecipeEnvForwardingWarning'
const noop = (): void => {}
const KEYS: AgentApiKeySummary[] = [
{
id: 'k1',
agent: 'claude',
envName: 'ANTHROPIC_API_KEY',
hostScope: { kind: 'all' },
hint: 'x4Qa',
updatedAt: 0
}
]
const SIGNED_IN: HostAgentPanelRow[] = [
{ agent: 'claude', state: 'signedIn', canSignOut: true },
{ agent: 'codex', state: 'signedOut', canSignOut: false }
]
function HostFixture({
kind,
host,
availability = 'available',
rows = SIGNED_IN,
keys = KEYS,
failed = false,
lastChecked = null,
dot = null
}: {
kind: AgentHostKind
host: string
availability?: AgentHostAvailability
rows?: HostAgentPanelRow[] | null
keys?: AgentApiKeySummary[]
failed?: boolean
lastChecked?: string | null
dot?: CloudDotState | null
}): React.JSX.Element {
const capabilities = hostCapabilities(kind, availability, { host, date: lastChecked }, translate)
return (
<div className="h-[760px] bg-background">
<Sheet open modal={false}>
<AgentHostPanelView
capabilities={capabilities}
subject={host}
dot={dot}
agents={
<HostAgentsPanelSection
title={capabilities.agents.title}
help={capabilities.agents.help}
host={host}
rows={rows}
checking={false}
failed={failed}
lastChecked={availability === 'available' ? null : lastChecked}
signOut={capabilities.signOut}
actionsDisabledReason={capabilities.actionsDisabledReason}
onSignOut={noop}
onCheckAgain={noop}
/>
}
keys={<HostKeysRows keys={keys} />}
environment={
kind === 'recipe' ? (
<RecipeEnvForwardingWarning
summary={{
count: 42,
keyLike: ['AWS_SECRET_ACCESS_KEY', 'OPENAI_API_KEY'],
other: ['HOME', 'PATH']
}}
/>
) : null
}
onFooterLink={noop}
/>
</Sheet>
</div>
)
}
const NO_KEYS: AgentApiKeySummary[] = []
const LAST = 'Nov 9, 2026'
export const local = defineFixture({
width: 1000,
render: () => <HostFixture kind="local" host="MacBook Pro" />
})
export const sshOrcad = defineFixture({
width: 1000,
render: () => <HostFixture kind="sshOrcad" host="devbox" />
})
export const sshClassic = defineFixture({
width: 1000,
render: () => <HostFixture kind="sshClassic" host="build-01" rows={null} keys={NO_KEYS} />
})
export const wsl = defineFixture({
width: 1000,
render: () => <HostFixture kind="wsl" host="Ubuntu-24.04" keys={NO_KEYS} />
})
export const wslStopped = defineFixture({
width: 1000,
render: () => (
<HostFixture
kind="wsl"
host="Ubuntu-24.04"
availability="stopped"
keys={NO_KEYS}
lastChecked={LAST}
/>
)
})
export const recipe = defineFixture({
width: 1000,
render: () => <HostFixture kind="recipe" host="gpu-box" dot="running" />
})
export const recipeSuspended = defineFixture({
width: 1000,
render: () => (
<HostFixture
kind="recipe"
host="gpu-box"
availability="suspended"
lastChecked={LAST}
dot="sleeping"
/>
)
})
export const paired = defineFixture({
width: 1000,
render: () => <HostFixture kind="paired" host="mac-mini" />
})
export const pairedOffline = defineFixture({
width: 1000,
render: () => (
<HostFixture kind="paired" host="mac-mini" availability="unreachable" lastChecked={LAST} />
)
})
/** An older Orca on the host answers no sign-in status. */
export const pairedOld = defineFixture({
width: 1000,
render: () => (
<HostFixture
kind="paired"
host="mac-mini"
failed
rows={[
{ agent: 'claude', state: 'unknown', canSignOut: false },
{ agent: 'codex', state: 'unknown', canSignOut: false }
]}
/>
)
})
@@ -0,0 +1,43 @@
// Panel section 1 on hosts that keep their own login (this computer, SSH with Orca server, WSL,
// recipe VMs, paired hosts): the host's own verdicts, never tokens or CLI output.
import {
HOST_AGENT_SIGN_IN_AGENTS,
type HostAgentSignInAgent,
type HostAgentSignInReport
} from '../../../../shared/host-agent-sign-in-status'
import type { AgentApiKeySummary } from '../../../../shared/agent-api-keys/agent-api-key-catalog'
import type { ExecutionHostId } from '../../../../shared/execution-host'
export type HostAgentPanelState = 'signedIn' | 'apiKey' | 'signedOut' | 'notInstalled' | 'unknown'
export type HostAgentPanelRow = {
agent: HostAgentSignInAgent
state: HostAgentPanelState
/** A CLI login Orca can run the agent's own sign-out for (API-key logins live in the env). */
canSignOut: boolean
}
export function hostAgentPanelRows(report: HostAgentSignInReport | null): HostAgentPanelRow[] {
return HOST_AGENT_SIGN_IN_AGENTS.map((agent) => {
const entry = report?.agents.find((candidate) => candidate.agent === agent)
if (!entry) {
return { agent, state: 'unknown', canSignOut: false }
}
if (entry.state === 'signedIn') {
return entry.method === 'apiKey'
? { agent, state: 'apiKey', canSignOut: false }
: { agent, state: 'signedIn', canSignOut: true }
}
return { agent, state: entry.state, canSignOut: false }
})
}
/** Section 2 off Cloud: the desktop Agent API keys Orca sends to agents on this host. */
export function agentApiKeysForHost(
keys: readonly AgentApiKeySummary[],
hostId: ExecutionHostId
): AgentApiKeySummary[] {
return keys.filter(
(key) => key.hostScope.kind === 'all' || key.hostScope.hostIds.includes(hostId)
)
}
@@ -9,7 +9,11 @@ import {
deriveCloudDotState,
type CloudDotState
} from '@/lib/orca-cloud/orca-cloud-workspace-state'
import { getWorktreeExecutionHostId, parseExecutionHostId } from '../../../../shared/execution-host'
import {
getWorktreeExecutionHostId,
parseExecutionHostId,
type ExecutionHostId
} from '../../../../shared/execution-host'
import { cloudSecretRepoKey } from '../settings/cloud-secrets/cloud-secret-repos'
import { runtimeEnvironmentDisplayName } from '../../../../shared/remote-runtime/host-catalog/orca-cloud-environment-name'
import { selectStartableStoppedWslDistro } from '../wsl-host-stopped/use-stopped-wsl-host'
@@ -18,7 +22,7 @@ import { agentHostAvailability, agentHostKind } from './agent-host-kind'
import type { AgentHostPanelRequest } from './agent-host-panel-store'
export type ResolvedAgentHost = {
hostId: string
hostId: ExecutionHostId
label: string
kind: AgentHostKind
availability: AgentHostAvailability
@@ -0,0 +1,72 @@
// The host's sign-in verdicts for the panel. The last cached report shows at once; the host is asked
// once per open, and only while it can answer. A stopped, suspended, disconnected or unreachable host
// is never connected, started, woken or resumed to check.
import { useEffect, useState, useSyncExternalStore } from 'react'
import { callRuntimeRpc } from '@/runtime/rpc/calls/runtime-rpc-call'
import {
readHostAgentSignInReport,
refreshHostAgentSignInReport,
subscribeHostAgentSignInReports
} from '@/runtime/provider-accounts/sign-in/host-agent-sign-in-status-client'
import type { HostAgentSignInReport } from '../../../../shared/host-agent-sign-in-status'
import type { AgentHostAvailability, AgentHostKind } from './agent-host-capabilities'
export type HostAgentReport = {
report: HostAgentSignInReport | null
/** A check is running for this open. */
checking: boolean
/** The host answered nothing (older Orca, or it went away). */
failed: boolean
}
const NO_ENVIRONMENT = '\u0000'
export function useHostAgentReport(args: {
kind: AgentHostKind
availability: AgentHostAvailability
environmentId: string | null
/** Bumped by "Check again". */
generation: number
}): HostAgentReport {
const { kind, availability, environmentId, generation } = args
const remoteId = kind === 'local' || kind === 'sshClassic' ? null : environmentId
const cached = useSyncExternalStore(subscribeHostAgentSignInReports, () =>
readHostAgentSignInReport(remoteId ?? NO_ENVIRONMENT)
)
const canAsk = availability === 'available' && (kind === 'local' || remoteId !== null)
const askKey = canAsk ? `${kind}:${remoteId ?? ''}:${generation}` : null
// Set only when an answer arrives (never synchronously in the effect), keyed by what was asked.
const [answer, setAnswer] = useState<{
key: string
report: HostAgentSignInReport | null
} | null>(null)
useEffect(() => {
if (!askKey) {
return
}
let cancelled = false
const ask: Promise<HostAgentSignInReport | null> =
kind === 'local'
? callRuntimeRpc<HostAgentSignInReport>(
{ kind: 'local' },
'accounts.agentSignInStatus',
generation > 0 ? { force: true } : {}
).catch(() => null)
: refreshHostAgentSignInReport(remoteId ?? '', { force: generation > 0 })
void ask.then((report) => {
if (!cancelled) {
setAnswer({ key: askKey, report })
}
})
return () => {
cancelled = true
}
}, [askKey, kind, remoteId, generation])
const answered = answer !== null && answer.key === askKey
const checking = askKey !== null && !answered
const failed = answered && answer.report === null
const local = kind === 'local' && answer ? answer.report : null
return { report: kind === 'local' ? local : cached, checking, failed }
}
@@ -30,7 +30,6 @@ import { useTranslate, type Translate } from '@/i18n/use-translate'
import { sshConnectVerb } from '@/ssh/ssh-connect-verb'
import { parseExecutionHostId } from '../../../../../../shared/execution-host'
import { runtimePairingRepairRoute } from '../../../../../../shared/remote-runtime/host-catalog/runtime-environments'
import { isOrcaCloudRuntimeEnvironment } from '../../../../../../shared/remote-runtime/host-catalog/orca-cloud-environment-name'
import { AgentHostPanelMenuItem } from '../../../agent-host-panel/AgentHostPanelMenuItem'
import { describeRuntimeCompatBlock } from '@/lib/runtime-host-copy'
@@ -45,9 +44,7 @@ import { HostRenameDialog } from '../../HostRenameDialog'
import { HostRemoveDialog } from '../../HostRemoveDialog'
import { RuntimeRepairDialog } from '../../../runtime-access/RuntimeRepairDialog'
import { resolveHostRemoval } from '../../host-rename-remove'
import { HostAgentSignOutDialog, HostAgentSignOutMenuItems } from './HostAgentSignOutMenuItems'
import { CloudMcpSyncMenuItem } from './CloudMcpSyncMenuItem'
import type { HostAgentSignInAgent } from '../../../../../../shared/host-agent-sign-in-status'
function blockedTitle(
reason: 'client-too-old' | 'server-too-old',
@@ -83,7 +80,6 @@ export function HostSectionHeaderMenu({ row }: { row: HostHeaderRow }): React.JS
const [renameOpen, setRenameOpen] = useState(false)
const [removeOpen, setRemoveOpen] = useState(false)
const [repairOpen, setRepairOpen] = useState(false)
const [signOutAgent, setSignOutAgent] = useState<HostAgentSignInAgent | null>(null)
const mountedRef = useMountedRef()
const sshStatus = useAppStore((s) => {
const parsed = parseExecutionHostId(row.hostId)
@@ -99,11 +95,6 @@ export function HostSectionHeaderMenu({ row }: { row: HostHeaderRow }): React.JS
const environment = s.runtimeEnvironments.find((entry) => entry.id === runtimeEnvironmentId)
return environment ? runtimePairingRepairRoute(environment) : 'access-link'
})
// Orca Cloud: one "Agent accounts & secrets…" entry; there is nothing to sign out of per sandbox.
const cloudHost = useAppStore((s) => {
const environment = s.runtimeEnvironments.find((entry) => entry.id === runtimeEnvironmentId)
return environment ? isOrcaCloudRuntimeEnvironment(environment) : false
})
const repairableWithAccessLink = repairRoute === 'access-link'
const stoppedWslDistro = useAppStore((s) =>
selectStartableStoppedWslDistro(s, runtimeEnvironmentId)
@@ -308,20 +299,12 @@ export function HostSectionHeaderMenu({ row }: { row: HostHeaderRow }): React.JS
{t('auto.components.sidebar.HostSectionHeaderMenu.2d3e4f5a6b', 'Check connection')}
</DropdownMenuItem>
)}
{cloudHost ? (
{row.kind !== 'local' ? (
<AgentHostPanelMenuItem
hostId={row.hostId}
host={{ label: row.label, health: row.health }}
/>
) : null}
{runtimeEnvironmentId && !cloudHost && row.health !== 'blocked' && (
<HostAgentSignOutMenuItems
environmentId={runtimeEnvironmentId}
hostLabel={row.label}
open={open}
onSignOut={setSignOutAgent}
/>
)}
<DropdownMenuSeparator />
{runtimeEnvironmentId && (
<CloudMcpSyncMenuItem
@@ -353,14 +336,6 @@ export function HostSectionHeaderMenu({ row }: { row: HostHeaderRow }): React.JS
hostId={row.hostId}
derivedLabel={row.label}
/>
{runtimeEnvironmentId && (
<HostAgentSignOutDialog
environmentId={runtimeEnvironmentId}
hostLabel={row.label}
agent={signOutAgent}
onClose={() => setSignOutAgent(null)}
/>
)}
{runtimeEnvironmentId && (
<RuntimeRepairDialog
open={repairOpen}
+21 -3
View File
@@ -27427,7 +27427,12 @@
"edit": "Edit",
"empty": "No agent keys in Cloud secrets.",
"emptyMember": "Add your own, or ask an owner or admin for a team key.",
"manage": "Open Cloud secrets"
"manage": "Open Cloud secrets",
"loading": "Loading keys…",
"noneHere": "No keys apply to this host.",
"addOne": "Add one in Agent API keys",
"scopeAll": "Every host except Orca Cloud",
"scopeHosts": "Only the hosts you picked"
},
"unreachable": "Couldn’t reach Orca Cloud.",
"section": {
@@ -27449,8 +27454,8 @@
"envSsh": "Agents on {{host}} get its shell profile. Orca doesn’t add variables on SSH hosts.",
"agentsWsl": "Sign-ins inside the distro. Windows sign-ins don’t carry over.",
"envWsl": "Agents get the distro’s own environment. Orca doesn’t add variables in WSL.",
"envPaired": "Agents on {{host}} get its own environment. Orca doesn’t add variables on paired hosts.",
"agentsCloud": "From your Orca account. Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same."
"envPaired": "Agents on {{host}} use its own environment. Orca doesn’t add variables on paired hosts.",
"agentsCloud": "Nothing is stored in the sandbox, so new, cloned and restarted sandboxes work the same."
},
"retry": "Try again",
"asleepFooter": "Changes reach the sandbox when it wakes.",
@@ -27529,6 +27534,19 @@
"sshDisconnected": "Open a workspace on {{host}} to sign in or out.",
"unreachable": "Can’t reach {{host}}. Sign-in and sign-out need it online.",
"archived": "This workspace is archived."
},
"host": {
"signedIn": "Signed in",
"apiKey": "Signed in with an API key",
"signedOut": "Signed out",
"notInstalled": "Not installed",
"unknown": "Not checked yet",
"signOut": "Sign out…",
"cantCheck": "Orca can’t check sign-ins on {{host}} yet. Start an agent in a workspace there to sign in.",
"noAnswer": "{{host}} didn’t answer. It may run an older Orca.",
"checking": "Checking…",
"lastChecked": "last checked {{date}}",
"signInHint": "Start {{agent}} in a workspace on {{host}} to sign in."
}
},
"cloudSecretsAsk": {