Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(switchdash): judge host readiness and agent-type readiness separately (CHOO-1809)
Louis Amaudruz378f53dbf492
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.tsindex 2f5993d88..80f715cff 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts@@ -1,4 +1,8 @@import { describe, expect, it } from 'vitest';+import { CORE_DEPENDENCIES } from '@main/core/dependencies/core-dependencies';+import { listPlugins } from '@main/core/providers/plugin-registry';+import { deriveHostStatus } from '@shared/core/remote-hosts/host-status';+import type { HostReachability } from '@shared/core/remote-hosts/reachability';import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';import {agentPluginStepId,@@ -221,3 +225,76 @@ describe('reconcileInterruptedPlan', () => {expect(reconcileInterruptedPlan(plan, NOW)).toBe(plan);});});++/**+ * Every other test here builds from fixtures, which is exactly why the Codex+ * regression got through: making Codex Switch-supported added two required+ * steps to every real plan, and nothing built from the real registry to notice.+ * These tests use the shipped dependency list and plugin registry, so adding an+ * agent type that quietly changes what a provisioned host reports fails here.+ */+describe('buildSetupPlan — against the real registry', () => {+ const reachable: HostReachability = {+ sshHost: 'dev-vm',+ status: 'reachable',+ lastError: null,+ lastCheckedAt: null,+ lastReachableAt: null,+ consecutiveFailures: 0,+ nextProbeAt: null,+ probing: false,+ };++ /** The same filter `plannableAgentTypes` applies before building a plan. */+ const switchSupported = () =>+ listPlugins()+ .filter((plugin) => plugin.capabilities.switchSetup.kind === 'cli')+ .map((plugin) => ({ agentId: plugin.metadata.id, name: plugin.metadata.id }));++ const realPlan = () =>+ buildSetupPlan({+ sshHost: 'dev-vm',+ coreDependencies: CORE_DEPENDENCIES.map((dep) => ({ id: dep.id, name: dep.name })),+ agentTypes: switchSupported(),+ existing: null,+ now: NOW,+ });++ function satisfy(plan: HostSetupPlan, predicate: (step: HostSetupStep) => boolean) {+ return {+ ...plan,+ steps: plan.steps.map((step) =>+ predicate(step)+ ? { ...step, state: 'satisfied' as const, outcome: 'satisfied' as const }+ : step+ ),+ };+ }++ it('offers more than one Switch-supported agent type', () => {+ // Guards the premise of the test below: with a single type, host-wide and+ // per-type verdicts coincide and the regression is invisible.+ expect(switchSupported().length).toBeGreaterThan(1);+ });++ it('reports a host with every prerequisite installed as ready, whatever agent types ship', () => {+ // The reported bug: all prerequisites present, one agent CLI absent, and the+ // host badge read "Setup required".+ const plan = satisfy(+ realPlan(),+ (step) => step.kind === 'core-dependency' || step.kind === 'gh-auth'+ );++ expect(deriveHostStatus(reachable, plan).kind).toBe('ready');+ });++ it('still reports a host missing a prerequisite as not ready', () => {+ // The inverse, so the test above cannot pass by never blocking anything.+ const plan = satisfy(+ realPlan(),+ (step) => (step.kind === 'core-dependency' || step.kind === 'gh-auth') && step.id !== 'node'+ );++ expect(deriveHostStatus(reachable, plan).kind).toBe('setup-required');+ });+});diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.tsindex 6e10219ab..82862c32b 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts@@ -17,11 +17,14 @@*/import {+ agentPluginStepId,type HostSetupPlan,type HostSetupStep,type HostSetupStepKind,} from '@shared/core/remote-hosts/setup';+export { agentPluginStepId };+/** A dependency switchdash knows how to check on the host. */export type PlannableDependency = {id: string;@@ -45,11 +48,6 @@ export type BuildPlanInput = {now: string;};-/** Step id for an agent type's Switch connector plugin. */-export function agentPluginStepId(agentId: string): string {- return `${agentId}:plugin`;-}-/** Step id for the interactive `gh auth login`. */export const GH_AUTH_STEP_ID = 'gh:auth';diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsxindex 44d0ed4b7..b52a0b871 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx@@ -300,9 +300,21 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc// produce an agent that cannot start. Refuse, rather than letting the failure// surface later as a mystery (CHOO-1809). An unchecked host is probed first// and only then judged — `checking` withholds the verdict, it is not one.- const hostReadiness = useRemoteHostReadiness(isRemoteRun ? runHost : null);+ const hostReadiness = useRemoteHostReadiness(+ isRemoteRun ? runHost : null,+ pickState.providerId ?? null+ );const runHostReady = !isRemoteRun || (!hostReadiness.blocked && !hostReadiness.checking);+ // Where the block stops the flow. A host missing its own prerequisites cannot+ // run anything, so nothing below the location picker is worth filling in —+ // the same rule reachability already follows. A host that is fine but lacks+ // one agent CLI blocks only the parts that commit to that type, so the type+ // picker stays live and you can pick one the host already has.+ const hostLevelBlocked = isRemoteRun && hostReadiness.blocked && hostReadiness.scope === 'host';+ const canChooseAgentType = runHostReachable && !hostLevelBlocked;+ const canConfigureAgent = canChooseAgentType && runHostReady;+const canSubmitDetected = isRemoteRun? !!pickState.providerId &&trimmedRemoteDir.length > 0 &&@@ -525,7 +537,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc* directory — importing those already registered on the gateway and minting a* fresh identity for plain provider definitions. */const handleOnboard = async () => {- if (!pickState.serverId || !pickState.providerId || selectedNames.size === 0) return;+ if (!canOnboard || !pickState.providerId || !pickState.serverId) return;setSubmitState('creating');setCloseGuard(true);try {@@ -559,8 +571,16 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc}};+ // Adopting agents that already exist in the directory still puts them on this+ // host, so it answers to the same gates as creating one. Omitting them here+ // let you onboard onto a host that was unreachable or missing prerequisites.const canOnboard =- hasOnboardable && selectedNames.size > 0 && !!pickState.serverId && submitState === 'idle';+ hasOnboardable &&+ selectedNames.size > 0 &&+ !!pickState.serverId &&+ runHostReachable &&+ runHostReady &&+ submitState === 'idle';const submitLabel = submitState === 'creating' ? 'Adding...' : 'Add Agent';return (@@ -649,7 +669,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoconNavigateAway={onClose}/>)}- {isRemoteRun && runHostReachable && (+ {isRemoteRun && canChooseAgentType && (<div className="flex items-center gap-2"><Inputvalue={remoteRepoDirDraft}@@ -673,23 +693,26 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc</div>)}</Field>- {/* The host is the first gate: with it unreachable we cannot know which- agent types it has, so offering a type picker (or a directory to scan)- would be guessing. Everything below waits for a usable host. */}- {runHostReachable && (+ {/* The host is the first gate: with it unreachable, or missing its own+ prerequisites, we cannot know which agent types it has, so offering a+ type picker (or a directory to scan) would be guessing. Everything+ below waits for a usable host — and everything past the picker waits+ for a type that host can actually run, rather than letting you fill+ in a name and a config only to be refused at the last button. */}+ {canChooseAgentType && (<AgentTypePickervalue={pickState.providerId}onChange={pickState.setProviderId}sshHost={isRemoteRun ? runHost : undefined}/>)}- {runHostReachable && !isRemoteRun && (+ {canConfigureAgent && !isRemoteRun && (<PickExistingPanel state={pickState} showName={!isMissingSwitchAgent} />)}{isChecking && (<p className="text-sm text-foreground-muted">Scanning directory for agents…</p>)}- {hasOnboardable && !createMode && (+ {canConfigureAgent && hasOnboardable && !createMode && (<><OnboardExistingPanelagents={onboardableAgents}@@ -717,7 +740,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc← Back to existing agents</Button>)}- {isMissingRemoteAgent && showCreate && (+ {canConfigureAgent && isMissingRemoteAgent && showCreate && (<><ConfigureAgentPanelform={remoteConfigureForm}@@ -761,7 +784,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc)}</>)}- {isMissingSwitchAgent && showCreate && (+ {canConfigureAgent && isMissingSwitchAgent && showCreate && (<><ConfigureAgentPanelform={configureForm}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness-notice.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness-notice.tsxindex 5cf6ed194..cbc40b70f 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness-notice.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness-notice.tsx@@ -20,7 +20,7 @@ import { useNavigate } from '@renderer/lib/layout/navigation-provider';import { Button } from '@renderer/lib/ui/button';import { Spinner } from '@renderer/lib/ui/spinner';import { log } from '@renderer/utils/logger';-import { deriveHostStatus } from '@shared/core/remote-hosts/host-status';+import { deriveAgentTypeStatus } from '@shared/core/remote-hosts/host-status';import { hostReachabilityStore } from './host-reachability-store';import { resolveReadiness, type HostReadiness } from './host-readiness';import { hostSetupStore } from './host-setup-store';@@ -34,7 +34,11 @@ export { resolveReadiness, type HostReadiness };* Reachability is deliberately not treated as "blocked" here — the modal* already gates on it separately and says something more useful about it.*/-export function useRemoteHostReadiness(sshHost: string | null): HostReadiness {+export function useRemoteHostReadiness(+ sshHost: string | null,+ /** The agent type being created, so the gate judges that type and not all of them. */+ agentId: string | null+): HostReadiness {const [checking, setChecking] = useState(false);// Probe at most once per host per mount: this costs an SSH round trip, and// re-running it on every render of a modal would hammer the host.@@ -46,7 +50,8 @@ export function useRemoteHostReadiness(sshHost: string | null): HostReadiness {const reachability = sshHost ? hostReachabilityStore.get(sshHost) : null;const plan = hostSetupStore.get(sshHost);- const status = sshHost && reachability ? deriveHostStatus(reachability, plan) : null;+ const status =+ sshHost && reachability ? deriveAgentTypeStatus(reachability, plan, agentId) : null;const needsProbe = status?.kind === 'unchecked';useEffect(() => {@@ -64,7 +69,7 @@ export function useRemoteHostReadiness(sshHost: string | null): HostReadiness {.finally(() => setChecking(false));}, [sshHost, needsProbe]);- return resolveReadiness(status, plan, checking || needsProbe);+ return resolveReadiness(status, plan, agentId, checking || needsProbe);}/** Explains a blocked host, and sends the user to the page that fixes it. */@@ -95,7 +100,10 @@ export const HostReadinessNotice = observer(function HostReadinessNotice({<CircleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-500" /><div className="flex min-w-0 flex-col gap-1.5"><span>- <span className="font-medium">{sshHost}</span> is not set up to run agents+ <span className="font-medium">{sshHost}</span>{' '}+ {readiness.scope === 'agent-type'+ ? 'is ready, but is not set up for this agent type'+ : 'is not set up to run agents'}{readiness.missing.length > 0 ? `: ${readiness.missing.join(', ')} ` : ' '}{readiness.missing.length === 1 ? 'is missing.' : 'are missing.'} An agent created herewould fail to start.diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.tsindex 9859faa4e..996fe558e 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest';-import { deriveHostStatus, type HostStatus } from '@shared/core/remote-hosts/host-status';+import { deriveAgentTypeStatus, type HostStatus } from '@shared/core/remote-hosts/host-status';import type {HostReachability,HostReachabilityStatus,@@ -7,6 +7,7 @@ import type {import type {HostSetupPlan,HostSetupStep,+ HostSetupStepKind,HostSetupStepState,} from '@shared/core/remote-hosts/setup';import { resolveReadiness } from './host-readiness';@@ -24,10 +25,14 @@ function reachability(status: HostReachabilityStatus): HostReachability {};}-function step(id: string, state: HostSetupStepState): HostSetupStep {+function step(+ id: string,+ state: HostSetupStepState,+ kind: HostSetupStepKind = 'core-dependency'+): HostSetupStep {return {id,- kind: 'core-dependency',+ kind,name: id,state,outcome: state === 'satisfied' ? 'satisfied' : 'missing',@@ -51,30 +56,34 @@ function plan(steps: HostSetupStep[]): HostSetupPlan {};}-const statusFor = (p: HostSetupPlan | null, r: HostReachabilityStatus = 'reachable'): HostStatus =>- deriveHostStatus(reachability(r), p);+const statusFor = (+ p: HostSetupPlan | null,+ agentId: string | null = null,+ r: HostReachabilityStatus = 'reachable'+): HostStatus => deriveAgentTypeStatus(reachability(r), p, agentId);describe('resolveReadiness — the agent-creation gate', () => {it('blocks a host known to be missing something, and names it', () => {const p = plan([step('git', 'pending'), step('node', 'satisfied')]);- const readiness = resolveReadiness(statusFor(p), p, false);+ const readiness = resolveReadiness(statusFor(p), p, null, false);expect(readiness.blocked).toBe(true);expect(readiness.missing).toEqual(['git']);+ expect(readiness.scope).toBe('host');});it('allows a ready host', () => {const p = plan([step('git', 'satisfied')]);- expect(resolveReadiness(statusFor(p), p, false).blocked).toBe(false);+ expect(resolveReadiness(statusFor(p), p, null, false).blocked).toBe(false);});describe('never block on ignorance', () => {it('does not block while a probe is in flight — checking is not a verdict', () => {const p = plan([step('git', 'pending'), step('node', 'satisfied')]);- const readiness = resolveReadiness(statusFor(p), p, true);+ const readiness = resolveReadiness(statusFor(p), p, null, true);expect(readiness.blocked).toBe(false);expect(readiness.checking).toBe(true);@@ -82,11 +91,11 @@ describe('resolveReadiness — the agent-creation gate', () => {it('does not block a host nobody has ever checked', () => {// Refusing here would be the false green inverted: a verdict we did not earn.- expect(resolveReadiness(statusFor(null), null, false).blocked).toBe(false);+ expect(resolveReadiness(statusFor(null), null, null, false).blocked).toBe(false);});it('does not block a local run, which has no host', () => {- expect(resolveReadiness(null, null, false).blocked).toBe(false);+ expect(resolveReadiness(null, null, null, false).blocked).toBe(false);});});@@ -96,7 +105,7 @@ describe('resolveReadiness — the agent-creation gate', () => {// prerequisites for a network problem.const p = plan([step('git', 'pending')]);- const readiness = resolveReadiness(statusFor(p, 'unreachable'), p, false);+ const readiness = resolveReadiness(statusFor(p, null, 'unreachable'), p, null, false);expect(readiness.blocked).toBe(false);});@@ -104,6 +113,82 @@ describe('resolveReadiness — the agent-creation gate', () => {it('counts a skipped required step as still missing', () => {const p = plan([step('git', 'skipped')]);- expect(resolveReadiness(statusFor(p), p, false).blocked).toBe(true);+ expect(resolveReadiness(statusFor(p), p, null, false).blocked).toBe(true);+ });++ /**+ * The regression this split exists for: main made Codex a Switch-supported+ * type, which added two required steps to every host, and the single verdict+ * meant a host without Codex refused to create a Claude Code agent that was+ * perfectly well installed.+ */+ describe('the gate judges the agent type being created, not all of them', () => {+ const twoAgentTypes = () =>+ plan([+ step('git', 'satisfied'),+ step('node', 'satisfied'),+ step('claude', 'satisfied', 'agent-cli'),+ step('claude:plugin', 'satisfied', 'agent-plugin'),+ step('codex', 'pending', 'agent-cli'),+ step('codex:plugin', 'pending', 'agent-plugin'),+ ]);++ it('allows creating an agent of an installed type while another type is missing', () => {+ const p = twoAgentTypes();++ const readiness = resolveReadiness(statusFor(p, 'claude'), p, 'claude', false);++ expect(readiness.blocked).toBe(false);+ });++ it('blocks the type that is actually missing, and names only its steps', () => {+ const p = twoAgentTypes();++ const readiness = resolveReadiness(statusFor(p, 'codex'), p, 'codex', false);++ expect(readiness.blocked).toBe(true);+ expect(readiness.scope).toBe('agent-type');+ expect(readiness.missing).toEqual(['codex', 'codex:plugin']);+ });++ it('reports an installed CLI with a missing connector as still not ready', () => {+ // The agent would start and have no Switch tools, which is the stale-green+ // this rewrite exists to remove.+ const p = plan([+ step('git', 'satisfied'),+ step('claude', 'satisfied', 'agent-cli'),+ step('claude:plugin', 'pending', 'agent-plugin'),+ ]);++ const readiness = resolveReadiness(statusFor(p, 'claude'), p, 'claude', false);++ expect(readiness.blocked).toBe(true);+ expect(readiness.scope).toBe('agent-type');+ expect(readiness.missing).toEqual(['claude:plugin']);+ });++ it('blames the host, not the agent type, when a prerequisite is missing', () => {+ // A host with no node cannot install any CLI, so every type inherits that+ // verdict rather than each reporting its own CLI as the problem.+ const p = plan([+ step('git', 'satisfied'),+ step('node', 'pending'),+ step('claude', 'pending', 'agent-cli'),+ ]);++ const readiness = resolveReadiness(statusFor(p, 'claude'), p, 'claude', false);++ expect(readiness.blocked).toBe(true);+ expect(readiness.scope).toBe('host');+ expect(readiness.missing).toEqual(['node']);+ });++ it('does not hold an unmanaged agent type against a ready host', () => {+ // A type whose connector switchdash does not manage has no steps; there is+ // nothing type-specific to satisfy, so the host's verdict stands.+ const p = plan([step('git', 'satisfied')]);++ expect(resolveReadiness(statusFor(p, 'mistral'), p, 'mistral', false).blocked).toBe(false);+ });});});diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.tsindex bcec917fc..eabfbb02a 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.ts@@ -7,22 +7,43 @@*/import type { HostStatus } from '@shared/core/remote-hosts/host-status';-import { outstandingRequiredSteps, type HostSetupPlan } from '@shared/core/remote-hosts/setup';+import {+ outstandingRequiredHostSteps,+ outstandingRequiredStepsFor,+ type HostSetupPlan,+} from '@shared/core/remote-hosts/setup';++/**+ * Whether the block is the machine or just the agent type asked for.+ *+ * The two lead to different places: a host-level block stops every agent and is+ * fixed on the host page, while an agent-type block can also be sidestepped by+ * choosing a type the host already has.+ */+export type ReadinessScope = 'host' | 'agent-type';export type HostReadiness = {- /** True when we know the host is missing something an agent needs. */+ /** True when we know the host is missing something the chosen agent needs. */blocked: boolean;/** True while a probe is in flight — not a verdict, just "ask again shortly". */checking: boolean;/** Required steps not yet satisfied. Empty unless `blocked`. */missing: string[];+ /** What the block is about. Null unless `blocked`. */+ scope: ReadinessScope | null;};-const READY: HostReadiness = { blocked: false, checking: false, missing: [] };+const READY: HostReadiness = { blocked: false, checking: false, missing: [], scope: null };/*** The gate's decision, as a pure function.*+ * `status` is the agent-type-aware verdict, so passing the status for the type+ * being created is what makes this gate answer "is this host ready for *this*+ * agent?" rather than "is it ready for every type it could ever run?" — the+ * question it used to ask, which let a missing Codex block creating a Claude+ * Code agent.+ ** `probing` withholds a verdict rather than being one: while we are looking, the* honest answer is "ask again shortly", not "no". And a host we could not* determine anything about is NOT blocked — refusing on ignorance is the same@@ -31,14 +52,19 @@ const READY: HostReadiness = { blocked: false, checking: false, missing: [] };export function resolveReadiness(status: HostStatus | null,plan: HostSetupPlan | null,+ agentId: string | null,probing: boolean): HostReadiness {if (!status) return READY;- if (probing) return { blocked: false, checking: true, missing: [] };+ if (probing) return { blocked: false, checking: true, missing: [], scope: null };if (status.kind !== 'setup-required') return READY;+ if (!plan) return { blocked: true, checking: false, missing: [], scope: 'host' };++ const hostOutstanding = outstandingRequiredHostSteps(plan);return {blocked: true,checking: false,- missing: plan ? outstandingRequiredSteps(plan).map((step) => step.name) : [],+ missing: outstandingRequiredStepsFor(plan, agentId).map((step) => step.name),+ scope: hostOutstanding.length > 0 ? 'host' : 'agent-type',};}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsxindex 31ac98d1a..060cd5974 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx@@ -8,14 +8,22 @@* sidebar trees cannot disagree with each other or with the host page: a host* that is down says *unreachable* and says nothing about its dependencies,* because we cannot see them from here.+ *+ * Readiness is judged for *this agent's own type*. A host missing a prerequisite+ * flags every agent on it; a host that is fine but lacks one agent CLI flags+ * only the agents of that type, rather than marking a working Claude Code agent+ * as broken because Codex is absent.*/import { PlugZap, Wrench } from 'lucide-react';import { observer } from 'mobx-react-lite';import { useEffect } from 'react';import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';-import { deriveHostStatus } from '@shared/core/remote-hosts/host-status';-import { outstandingRequiredSteps } from '@shared/core/remote-hosts/setup';+import { deriveAgentTypeStatus } from '@shared/core/remote-hosts/host-status';+import {+ outstandingRequiredHostSteps,+ outstandingRequiredStepsFor,+} from '@shared/core/remote-hosts/setup';import { hostReachabilityStore } from './host-reachability-store';import { hostSetupStore } from './host-setup-store';@@ -23,9 +31,12 @@ const ICON = 'h-3.5 w-3.5 shrink-0 text-foreground-warning';export const HostTroubleIndicator = observer(function HostTroubleIndicator({sshHost,+ agentId,}: {/** Null for a local agent, which has no host to be in trouble. */sshHost: string | null;+ /** This agent's type, so its host's other agent types are not held against it. */+ agentId: string | null;}) {useEffect(() => {void hostSetupStore.hydrate();@@ -35,7 +46,7 @@ export const HostTroubleIndicator = observer(function HostTroubleIndicator({const reachability = hostReachabilityStore.get(sshHost);const plan = hostSetupStore.get(sshHost);- const status = deriveHostStatus(reachability, plan);+ const status = deriveAgentTypeStatus(reachability, plan, agentId);// The host being down is why this agent is idle, so say so on the row itself// — previously you had to select the agent to discover its host was failing@@ -58,14 +69,17 @@ export const HostTroubleIndicator = observer(function HostTroubleIndicator({if (status.kind !== 'setup-required') return null;- const missing = plan ? outstandingRequiredSteps(plan).map((step) => step.name) : [];+ const missing = plan ? outstandingRequiredStepsFor(plan, agentId).map((step) => step.name) : [];+ const hostItself = !plan || outstandingRequiredHostSteps(plan).length > 0;return (<Tooltip><TooltipTrigger><Wrench className={ICON} /></TooltipTrigger><TooltipContent>- {`${sshHost} is missing something this agent needs`}+ {hostItself+ ? `${sshHost} is missing something this agent needs`+ : `${sshHost} is ready, but this agent's type is not set up on it`}{missing.length > 0 ? `: ${missing.join(', ')}` : ''}</TooltipContent></Tooltip>diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.tsindex e2b88984d..8983d073b 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts@@ -9,10 +9,12 @@*/import type { StatusTone } from '@renderer/lib/ui/status-badge';-import type {- DependencyCheckOutcome,- HostSetupPlan,- HostSetupStep,+import {+ agentPluginStepId,+ hostLevelSteps,+ type DependencyCheckOutcome,+ type HostSetupPlan,+ type HostSetupStep,} from '@shared/core/remote-hosts/setup';/**@@ -174,9 +176,9 @@ export type GroupedPlan = {export function groupPlanSteps(plan: HostSetupPlan | null): GroupedPlan {if (!plan) return { prerequisites: [], agentTypes: [] };- const prerequisites = plan.steps.filter(- (step) => step.kind === 'core-dependency' || step.kind === 'gh-auth'- );+ // Same partition the host verdict uses, so the section a step is listed under+ // cannot disagree with the badge that judges it.+ const prerequisites = hostLevelSteps(plan);const agentTypes = plan.steps.filter((step) => step.kind === 'agent-cli')@@ -185,7 +187,8 @@ export function groupPlanSteps(plan: HostSetupPlan | null): GroupedPlan {name: cli.name,cli,plugin:- plan.steps.find((s) => s.kind === 'agent-plugin' && s.id === `${cli.id}:plugin`) ?? null,+ plan.steps.find((s) => s.kind === 'agent-plugin' && s.id === agentPluginStepId(cli.id)) ??+ null,}));return { prerequisites, agentTypes };diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsxindex 0c81131e7..a0f89d4d7 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx@@ -128,7 +128,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {<StatusBadge tone={status.tone}>{status.label}</StatusBadge>{status.readinessKnown && status.total > 0 && (<span className="text-xs text-foreground-muted">- {status.done} of {status.total} required+ {status.done} of {status.total} prerequisites</span>)}</span>diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsxindex 32a9e5dcb..63d8af0f5 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx@@ -172,7 +172,7 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({{/* Unreachable host, or one missing something this agent needs.Shared with the room-grouped rows so the two trees cannotdisagree about the same agent (CHOO-1682/1809). */}- <HostTroubleIndicator sshHost={sshHost} />+ <HostTroubleIndicator sshHost={sshHost} agentId={agent.providerId ?? null} />{locationViewKind(location) === 'ready' && hasSessionError(agent.locationId) && (<Tooltip><TooltipTrigger>diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsxindex f3c1a8098..b17b538d5 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx@@ -142,7 +142,10 @@ export const RoomAgentRow = observer(function RoomAgentRow({{/* Same agent, same host problem — this row used to shownothing, so whether you saw it depended on which groupingthe sidebar happened to be in. */}- <HostTroubleIndicator sshHost={location.data?.sshHost ?? null} />+ <HostTroubleIndicator+ sshHost={location.data?.sshHost ?? null}+ agentId={agent.providerId ?? null}+ /></span></SidebarMenuAction></div>diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.tsindex a8699d70f..4ad499258 100644--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from 'vitest';-import { deriveHostStatus, isHostUsable } from './host-status';+import { deriveAgentTypeStatus, deriveHostStatus, isHostUsable } from './host-status';import type { HostReachability, HostReachabilityStatus } from './reachability';-import type { HostSetupPlan, HostSetupStep, HostSetupStepState } from './setup';+import type { HostSetupPlan, HostSetupStep, HostSetupStepKind, HostSetupStepState } from './setup';function reachability(status: HostReachabilityStatus): HostReachability {return {@@ -16,10 +16,15 @@ function reachability(status: HostReachabilityStatus): HostReachability {};}-function step(id: string, state: HostSetupStepState, optional = false): HostSetupStep {+function step(+ id: string,+ state: HostSetupStepState,+ optional = false,+ kind: HostSetupStepKind = 'core-dependency'+): HostSetupStep {return {id,- kind: 'core-dependency',+ kind,name: id,state,outcome: state === 'satisfied' ? 'satisfied' : null,@@ -168,4 +173,133 @@ describe('deriveHostStatus', () => {expect(status.kind).toBe('setup-required');expect(isHostUsable(status)).toBe(false);});++ describe('the host is judged on its own prerequisites, not its agent types', () => {+ // A host with every prerequisite installed is ready. One of several agent+ // CLIs being absent is that type's problem, not the machine's — conflating+ // the two is what made a fully-provisioned host read "Setup required".+ const hostReadyCodexMissing = () =>+ plan([+ step('git', 'satisfied'),+ step('node', 'satisfied'),+ step('claude', 'satisfied', false, 'agent-cli'),+ step('claude:plugin', 'satisfied', false, 'agent-plugin'),+ step('codex', 'pending', false, 'agent-cli'),+ step('codex:plugin', 'pending', false, 'agent-plugin'),+ ]);++ it('reports ready when only an agent CLI is missing', () => {+ const status = deriveHostStatus(reachability('reachable'), hostReadyCodexMissing());++ expect(status.kind).toBe('ready');+ expect(isHostUsable(status)).toBe(true);+ });++ it('counts only the host prerequisites, so the tally matches that section', () => {+ const status = deriveHostStatus(reachability('reachable'), hostReadyCodexMissing());++ expect(status.done).toBe(2);+ expect(status.total).toBe(2);+ });++ it('is not distracted by an agent CLI installing elsewhere on the host', () => {+ const status = deriveHostStatus(+ reachability('reachable'),+ plan([step('git', 'satisfied'), step('codex', 'installing', false, 'agent-cli')])+ );++ expect(status.kind).toBe('ready');+ });+ });+});++describe('deriveAgentTypeStatus', () => {+ /** A step we have actually looked at and found absent. */+ function observedMissing(id: string, kind: HostSetupStepKind): HostSetupStep {+ return { ...step(id, 'pending', false, kind), outcome: 'missing' };+ }++ const twoAgentTypes = () =>+ plan([+ step('git', 'satisfied'),+ step('claude', 'satisfied', false, 'agent-cli'),+ step('claude:plugin', 'satisfied', false, 'agent-plugin'),+ observedMissing('codex', 'agent-cli'),+ observedMissing('codex:plugin', 'agent-plugin'),+ ]);++ it('reports an installed type as ready', () => {+ const status = deriveAgentTypeStatus(reachability('reachable'), twoAgentTypes(), 'claude');++ expect(status.kind).toBe('ready');+ });++ it('reports a missing type as setup-required', () => {+ const status = deriveAgentTypeStatus(reachability('reachable'), twoAgentTypes(), 'codex');++ expect(status.kind).toBe('setup-required');+ expect(status.done).toBe(0);+ expect(status.total).toBe(2);+ });++ it('reports a type nobody has looked at as unchecked, not missing', () => {+ // Per type, the same rule the host verdict follows: a plan lists what to+ // check and observes nothing, so calling an unobserved type "setup+ // required" claims knowledge we have not earned.+ const status = deriveAgentTypeStatus(+ reachability('reachable'),+ plan([+ step('git', 'satisfied'),+ step('codex', 'pending', false, 'agent-cli'),+ step('codex:plugin', 'pending', false, 'agent-plugin'),+ ]),+ 'codex'+ );++ expect(status.kind).toBe('unchecked');+ expect(status.readinessKnown).toBe(false);+ });++ it('inherits the host verdict when the host itself is not ready', () => {+ // Every type is blocked by a missing prerequisite, and saying "Codex is+ // missing" of a host with no node would name the wrong cause.+ const status = deriveAgentTypeStatus(+ reachability('reachable'),+ plan([step('node', 'pending'), step('git', 'satisfied')]),+ 'codex'+ );++ expect(status.kind).toBe('setup-required');+ expect(status.total).toBe(2);+ });++ it('withholds a verdict for an unreachable host rather than blaming the type', () => {+ const status = deriveAgentTypeStatus(reachability('unreachable'), twoAgentTypes(), 'codex');++ expect(status.kind).toBe('unreachable');+ expect(status.readinessKnown).toBe(false);+ });++ it('falls back to the host verdict for a type with no steps in the plan', () => {+ const status = deriveAgentTypeStatus(reachability('reachable'), twoAgentTypes(), 'mistral');++ expect(status.kind).toBe('ready');+ });++ it('falls back to the host verdict when no type has been chosen', () => {+ const status = deriveAgentTypeStatus(reachability('reachable'), twoAgentTypes(), null);++ expect(status.kind).toBe('ready');+ });++ it('names the agent step in flight while its install runs', () => {+ const status = deriveAgentTypeStatus(+ reachability('reachable'),+ plan([step('git', 'satisfied'), step('codex', 'installing', false, 'agent-cli')]),+ 'codex'+ );++ expect(status.kind).toBe('setting-up');+ expect(status.label).toBe('Setting up codex…');+ });});diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.tsindex 1f26287e8..6a1c9b602 100644--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts@@ -9,14 +9,21 @@** This is that answer, derived once and read everywhere.*- * The ordering rule is the important part: **readiness is conditional on- * reachability.** A host we cannot reach reports *unreachable* with its- * readiness withheld — never "not ready", which would blame the prerequisites- * for a network problem (the conflation CHOO-1780 removed).+ * Two ordering rules matter here:+ *+ * 1. **Readiness is conditional on reachability.** A host we cannot reach+ * reports *unreachable* with its readiness withheld — never "not ready",+ * which would blame the prerequisites for a network problem (the conflation+ * CHOO-1780 removed).+ * 2. **The host and its agent types are separate verdicts.** `deriveHostStatus`+ * answers "can this machine run agents at all?" from its prerequisites+ * alone; `deriveAgentTypeStatus` answers "can it run *this* type?". A host+ * with every prerequisite installed is ready even if one of several agent+ * CLIs is absent — that absence blocks its own type, nothing else.*/import { isHostBlocked, type HostReachability } from './reachability';-import { inFlightStep, outstandingRequiredSteps, type HostSetupPlan } from './setup';+import { agentTypeSteps, hostLevelSteps, type HostSetupPlan, type HostSetupStep } from './setup';export type HostStatusKind =/** SSH authentication failed — will not self-heal, the user must fix it. */@@ -46,7 +53,8 @@ export type HostStatus = {*/readinessKnown: boolean;/**- * Steps satisfied / total, counting everything the page lists.+ * Steps satisfied / total, counting everything in the group this verdict is+ * about — the host's prerequisites, or one agent type's steps.** Deliberately not "required only": a count that silently excludes optional* steps cannot be reconciled with the list beside it, which is how a host@@ -83,23 +91,59 @@ export function deriveHostStatus(};}- if (!plan || plan.steps.length === 0) {- return {- kind: 'unchecked',- label: 'Not checked',- tone: 'neutral',- readinessKnown: false,- done: 0,- total: 0,- };- }+ if (!plan) return UNCHECKED;+ return deriveFromSteps(hostLevelSteps(plan));+}++/**+ * The same verdict, narrowed to "can this host run an agent of *this* type?".+ *+ * The host's own state comes first and dominates: a host missing git cannot run+ * anything, so every agent type inherits that verdict rather than each reporting+ * its own CLI as the problem. Only once the host itself is ready does the+ * question become type-specific.+ *+ * A type with no steps in the plan — one whose connector switchdash does not+ * manage — is not held against the host: there is nothing type-specific to+ * satisfy, so the host's verdict stands.+ */+export function deriveAgentTypeStatus(+ reachability: HostReachability,+ plan: HostSetupPlan | null,+ agentId: string | null+): HostStatus {+ const host = deriveHostStatus(reachability, plan);+ if (host.kind !== 'ready' || !plan || !agentId) return host;++ const steps = agentTypeSteps(plan, agentId);+ if (steps.length === 0) return host;+ return deriveFromSteps(steps);+}++const UNCHECKED: HostStatus = {+ kind: 'unchecked',+ label: 'Not checked',+ tone: 'neutral',+ readinessKnown: false,+ done: 0,+ total: 0,+};++/**+ * The verdict for one group of steps, host-level or agent-type.+ *+ * Shared so the two cannot drift into judging the same evidence differently —+ * the only thing that varies between them is which steps they are handed.+ */+function deriveFromSteps(steps: HostSetupStep[]): HostStatus {+ if (steps.length === 0) return UNCHECKED;- const total = plan.steps.length;- const done = plan.steps.filter((step) => step.state === 'satisfied').length;+ const total = steps.length;+ const done = steps.filter((step) => step.state === 'satisfied').length;// Work in flight lives on the step, not the plan: there is no automated run// to be "running", only whatever the user asked for a moment ago.- const inFlight = inFlightStep(plan);+ const inFlight = steps.find((step) => step.state === 'checking' || step.state === 'installing');if (inFlight) {return {kind: 'setting-up',@@ -111,7 +155,7 @@ export function deriveHostStatus(};}- if (outstandingRequiredSteps(plan).length === 0) {+ if (steps.every((step) => step.optional || step.state === 'satisfied')) {return { kind: 'ready', label: 'Ready', tone: 'success', readinessKnown: true, done, total };}@@ -123,7 +167,7 @@ export function deriveHostStatus(// pending but stores what it saw) and no step moved off pending (skipping one// is a decision the user made, and reporting that host as unchecked would// hide it).- const untouched = plan.steps.every((step) => step.outcome === null && step.state === 'pending');+ const untouched = steps.every((step) => step.outcome === null && step.state === 'pending');if (untouched) {return {kind: 'unchecked',diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.tsindex 16c401e8c..420756006 100644--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts@@ -141,6 +141,79 @@ export function outstandingRequiredSteps(plan: HostSetupPlan): HostSetupStep[] {return plan.steps.filter((step) => !step.optional && step.state !== 'satisfied');}+const AGENT_PLUGIN_STEP_SUFFIX = ':plugin';++/** Step id for an agent type's Switch connector plugin. */+export function agentPluginStepId(agentId: string): string {+ return `${agentId}${AGENT_PLUGIN_STEP_SUFFIX}`;+}++/**+ * Whether a step describes the host itself rather than one agent type.+ *+ * This split is the difference between "this machine cannot run agents" and+ * "this machine cannot run *Codex*". Collapsing the two is what made a host with+ * every prerequisite installed report "Setup required" because one agent CLI of+ * several was absent, and then refused to create an agent of a type that was+ * perfectly well installed.+ */+export function isHostLevelStep(step: HostSetupStep): boolean {+ return step.kind === 'core-dependency' || step.kind === 'gh-auth';+}++/** The agent type a step belongs to, or null when the step is host-level. */+export function agentIdForStep(step: HostSetupStep): string | null {+ if (step.kind === 'agent-cli') return step.id;+ if (step.kind === 'agent-plugin') {+ return step.id.endsWith(AGENT_PLUGIN_STEP_SUFFIX)+ ? step.id.slice(0, -AGENT_PLUGIN_STEP_SUFFIX.length)+ : step.id;+ }+ return null;+}++/** The host's own prerequisites — every agent type needs all of these. */+export function hostLevelSteps(plan: HostSetupPlan): HostSetupStep[] {+ return plan.steps.filter(isHostLevelStep);+}++/** One agent type's steps: its CLI and its Switch connector. */+export function agentTypeSteps(plan: HostSetupPlan, agentId: string): HostSetupStep[] {+ return plan.steps.filter((step) => agentIdForStep(step) === agentId);+}++/** Host prerequisites still outstanding — these block every agent type. */+export function outstandingRequiredHostSteps(plan: HostSetupPlan): HostSetupStep[] {+ return hostLevelSteps(plan).filter((step) => !step.optional && step.state !== 'satisfied');+}++/** One agent type's outstanding steps — these block only that type. */+export function outstandingRequiredAgentTypeSteps(+ plan: HostSetupPlan,+ agentId: string+): HostSetupStep[] {+ return agentTypeSteps(plan, agentId).filter(+ (step) => !step.optional && step.state !== 'satisfied'+ );+}++/**+ * What stands between this host and running an agent of `agentId`, in the order+ * the user must deal with it: the host's own prerequisites first, because until+ * they are met the agent type's steps cannot even be attempted.+ *+ * Mirrors the precedence in `deriveAgentTypeStatus` so a verdict and the reasons+ * given for it cannot disagree.+ */+export function outstandingRequiredStepsFor(+ plan: HostSetupPlan,+ agentId: string | null+): HostSetupStep[] {+ const host = outstandingRequiredHostSteps(plan);+ if (host.length > 0 || !agentId) return host;+ return outstandingRequiredAgentTypeSteps(plan, agentId);+}+/*** Whether the host is usable for running agents. Optional steps and skipped* steps do not count against it; a step we could not verify does.