From 27c702dbbc9c8fd829825caf0c2f07b2ff61047a Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 09:45:17 -0800 Subject: [PATCH 1/3] feat(cloud): A16 panel on hosts with their own login (part 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Section 1 for this computer, SSH with an Orca server, WSL, recipe VMs and paired hosts: each agent's verdict from accounts.agentSignInStatus (cached report first, asked once per open and only while the host can answer; stopped, suspended, disconnected and unreachable hosts are never started, resumed or connected), 'Sign out…' moved here from the host ⋯ menu (HostAgentSignOutDialog stacks above the sheet), disabled with its reason via aria-disabled + tooltip. Classic SSH says it can't check yet. Section 2: this computer's Agent API keys that apply to the host. Section 3: the spec's one line, or the recipe env-forwarding warning. The host ⋯ menu's single 'Agent accounts & secrets…' now shows for every remote host. Fixtures for all kinds; tests assert no host call while it can't answer. --- .../AgentHostPanel.fixture.tsx | 1 + .../agent-host-panel/AgentHostPanel.test.tsx | 55 +++++- .../agent-host-panel/AgentHostPanel.tsx | 57 +++++- .../HostAgentsPanelSection.tsx | 167 ++++++++++++++++ .../agent-host-panel/HostPanelBody.tsx | 144 ++++++++++++++ .../agent-host-panel-host-fixtures.tsx | 179 ++++++++++++++++++ .../host-agents-panel-model.ts | 43 +++++ .../agent-host-panel/use-agent-host.ts | 8 +- .../agent-host-panel/use-host-agent-report.ts | 72 +++++++ .../rows/HostSectionHeaderMenu.tsx | 27 +-- src/renderer/src/i18n/locales/en.json | 20 +- 11 files changed, 738 insertions(+), 35 deletions(-) create mode 100644 src/renderer/src/components/agent-host-panel/HostAgentsPanelSection.tsx create mode 100644 src/renderer/src/components/agent-host-panel/HostPanelBody.tsx create mode 100644 src/renderer/src/components/agent-host-panel/agent-host-panel-host-fixtures.tsx create mode 100644 src/renderer/src/components/agent-host-panel/host-agents-panel-model.ts create mode 100644 src/renderer/src/components/agent-host-panel/use-host-agent-report.ts diff --git a/src/renderer/src/components/agent-host-panel/AgentHostPanel.fixture.tsx b/src/renderer/src/components/agent-host-panel/AgentHostPanel.fixture.tsx index c6ddc429b15..4603fae8ded 100644 --- a/src/renderer/src/components/agent-host-panel/AgentHostPanel.fixture.tsx +++ b/src/renderer/src/components/agent-host-panel/AgentHostPanel.fixture.tsx @@ -264,3 +264,4 @@ export const hostMenu = defineFixture({ ) }) +export * from './agent-host-panel-host-fixtures' diff --git a/src/renderer/src/components/agent-host-panel/AgentHostPanel.test.tsx b/src/renderer/src/components/agent-host-panel/AgentHostPanel.test.tsx index 49a433ebfda..99917b88094 100644 --- a/src/renderer/src/components/agent-host-panel/AgentHostPanel.test.tsx +++ b/src/renderer/src/components/agent-host-panel/AgentHostPanel.test.tsx @@ -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( + + + + ) + 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( + + + + ) + 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() + }) +}) diff --git a/src/renderer/src/components/agent-host-panel/AgentHostPanel.tsx b/src/renderer/src/components/agent-host-panel/AgentHostPanel.tsx index 5da49fd23b0..e5c878be358 100644 --- a/src/renderer/src/components/agent-host-panel/AgentHostPanel.tsx +++ b/src/renderer/src/components/agent-host-panel/AgentHostPanel.tsx @@ -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 ( + + ) +} + 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 ( - !open && closeAgentHostPanel()}> - {cloud ? : null} + !open && closeAgentHostPanel()}> + {host?.kind === 'cloud' ? ( + + ) : host ? ( + + ) : null} ) } diff --git a/src/renderer/src/components/agent-host-panel/HostAgentsPanelSection.tsx b/src/renderer/src/components/agent-host-panel/HostAgentsPanelSection.tsx new file mode 100644 index 00000000000..374af8f0c4b --- /dev/null +++ b/src/renderer/src/components/agent-host-panel/HostAgentsPanelSection.tsx @@ -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 ( + + + + ) +} + +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 ( + + {rows === null ? ( +

+ {t( + 'agentHostPanel.host.cantCheck', + 'Orca can’t check sign-ins on {{host}} yet. Start an agent in a workspace there to sign in.', + { host } + )} +

+ ) : checking && rows.every((row) => row.state === 'unknown') ? ( + + ) : ( + <> + {failed ? ( + + ) : null} +
    + {rows.map((row) => { + const muted = checking + ? t('agentHostPanel.host.checking', 'Checking…') + : lastChecked + ? t('agentHostPanel.host.lastChecked', 'last checked {{date}}', { + date: lastChecked + }) + : null + return ( +
  • + + {HOST_AGENT_SIGN_IN_AGENT_NAME[row.agent]} + +
    + + {[stateLabel(row.state, t), muted].filter(Boolean).join(' · ')} + + {row.state === 'signedOut' ? ( + + {t( + 'agentHostPanel.host.signInHint', + 'Start {{agent}} in a workspace on {{host}} to sign in.', + { agent: HOST_AGENT_SIGN_IN_AGENT_NAME[row.agent], host } + )} + + ) : null} +
    + {props.signOut && row.canSignOut ? ( + + ) : ( + + )} +
  • + ) + })} +
+ + {checking ? '' : announce} + + + )} +
+ ) +} diff --git a/src/renderer/src/components/agent-host-panel/HostPanelBody.tsx b/src/renderer/src/components/agent-host-panel/HostPanelBody.tsx new file mode 100644 index 00000000000..5bca6b480e3 --- /dev/null +++ b/src/renderer/src/components/agent-host-panel/HostPanelBody.tsx @@ -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(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(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 {t('agentHostPanel.keys.loading', 'Loading keys…')} + } + if (keys.length === 0) { + return ( +

+ {t('agentHostPanel.keys.noneHere', 'No keys apply to this host.')}{' '} + +

+ ) + } + return ( +
    + {keys.map((key) => ( +
  • + {formatAgentTypeLabel(key.agent)} +
    + + {key.envName} ••••{key.hint} + + + {key.hostScope.kind === 'all' + ? t('agentHostPanel.keys.scopeAll', 'Every host except Orca Cloud') + : t('agentHostPanel.keys.scopeHosts', 'Only the hosts you picked')} + +
    +
  • + ))} +
+ ) +} + +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(null) + const unavailable = host.availability !== 'available' + const agents = ( + <> + + {host.environmentId ? ( + setSignOutAgent(null)} + /> + ) : null} + + ) + return { + agents, + keys: , + environment: + host.kind === 'recipe' ? : null + } +} diff --git a/src/renderer/src/components/agent-host-panel/agent-host-panel-host-fixtures.tsx b/src/renderer/src/components/agent-host-panel/agent-host-panel-host-fixtures.tsx new file mode 100644 index 00000000000..6221169faa9 --- /dev/null +++ b/src/renderer/src/components/agent-host-panel/agent-host-panel-host-fixtures.tsx @@ -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:. +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 ( +
+ + + } + keys={} + environment={ + kind === 'recipe' ? ( + + ) : null + } + onFooterLink={noop} + /> + +
+ ) +} + +const NO_KEYS: AgentApiKeySummary[] = [] +const LAST = 'Nov 9, 2026' + +export const local = defineFixture({ + width: 1000, + render: () => +}) + +export const sshOrcad = defineFixture({ + width: 1000, + render: () => +}) + +export const sshClassic = defineFixture({ + width: 1000, + render: () => +}) + +export const wsl = defineFixture({ + width: 1000, + render: () => +}) + +export const wslStopped = defineFixture({ + width: 1000, + render: () => ( + + ) +}) + +export const recipe = defineFixture({ + width: 1000, + render: () => +}) + +export const recipeSuspended = defineFixture({ + width: 1000, + render: () => ( + + ) +}) + +export const paired = defineFixture({ + width: 1000, + render: () => +}) + +export const pairedOffline = defineFixture({ + width: 1000, + render: () => ( + + ) +}) + +/** An older Orca on the host answers no sign-in status. */ +export const pairedOld = defineFixture({ + width: 1000, + render: () => ( + + ) +}) diff --git a/src/renderer/src/components/agent-host-panel/host-agents-panel-model.ts b/src/renderer/src/components/agent-host-panel/host-agents-panel-model.ts new file mode 100644 index 00000000000..6c8f5f2407c --- /dev/null +++ b/src/renderer/src/components/agent-host-panel/host-agents-panel-model.ts @@ -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) + ) +} diff --git a/src/renderer/src/components/agent-host-panel/use-agent-host.ts b/src/renderer/src/components/agent-host-panel/use-agent-host.ts index aaf90a4d47d..5e115316093 100644 --- a/src/renderer/src/components/agent-host-panel/use-agent-host.ts +++ b/src/renderer/src/components/agent-host-panel/use-agent-host.ts @@ -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 diff --git a/src/renderer/src/components/agent-host-panel/use-host-agent-report.ts b/src/renderer/src/components/agent-host-panel/use-host-agent-report.ts new file mode 100644 index 00000000000..929fffb393f --- /dev/null +++ b/src/renderer/src/components/agent-host-panel/use-host-agent-report.ts @@ -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 = + kind === 'local' + ? callRuntimeRpc( + { 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 } +} diff --git a/src/renderer/src/components/sidebar/worktree-list/rows/HostSectionHeaderMenu.tsx b/src/renderer/src/components/sidebar/worktree-list/rows/HostSectionHeaderMenu.tsx index defea6c829c..21f18c926aa 100644 --- a/src/renderer/src/components/sidebar/worktree-list/rows/HostSectionHeaderMenu.tsx +++ b/src/renderer/src/components/sidebar/worktree-list/rows/HostSectionHeaderMenu.tsx @@ -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(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')} )} - {cloudHost ? ( + {row.kind !== 'local' ? ( ) : null} - {runtimeEnvironmentId && !cloudHost && row.health !== 'blocked' && ( - - )} {runtimeEnvironmentId && ( - {runtimeEnvironmentId && ( - setSignOutAgent(null)} - /> - )} {runtimeEnvironmentId && ( Date: Tue, 10 Nov 2026 09:48:31 -0800 Subject: [PATCH 2/3] fix(cloud): paired-host environment line reads 'use its own environment' (design-squad nit) --- .../src/components/agent-host-panel/agent-host-capabilities.ts | 2 +- src/renderer/src/i18n/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts index ad6dd116f3d..6ff5638a875 100644 --- a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts +++ b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts @@ -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 } ) } diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 7102d5a290b..f3a3434f6db 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -27454,7 +27454,7 @@ "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.", + "envPaired": "Agents on {{host}} use 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." }, "retry": "Try again", From a4276afe994f19b5a05de050f833758724e6c1a3 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 09:49:30 -0800 Subject: [PATCH 3/3] fix(cloud): Cloud Agents section intro is source-neutral (design-squad P3) --- .../components/agent-host-panel/agent-host-capabilities.test.ts | 2 +- .../src/components/agent-host-panel/agent-host-capabilities.ts | 2 +- src/renderer/src/i18n/locales/en.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.test.ts b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.test.ts index 9b654252be8..fbc8da997e0 100644 --- a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.test.ts +++ b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.test.ts @@ -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.' ) }) diff --git a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts index 6ff5638a875..14f244a1d92 100644 --- a/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts +++ b/src/renderer/src/components/agent-host-panel/agent-host-capabilities.ts @@ -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: '', diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index f3a3434f6db..cd1ec073bd6 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -27455,7 +27455,7 @@ "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}} use 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." + "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.",