Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(switchdash): gate agent creation on host readiness, and surface it (CHOO-1809)

switch-worker-louis-remote7c20bf0da390
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/controller.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/controller.ts
index aa06d9e4f..20480e878 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/controller.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/controller.ts
@@ -29,6 +29,7 @@ import { deletePersistedReachability } from './reachability-store';
import {
discardSetupPlan,
ensureSetupPlan,
+ readAllSetupPlans,
readSetupPlan,
recheckSetup,
runSetup,
@@ -201,6 +202,9 @@ export const remoteHostsController = createRPCController({
/** The host's persisted setup plan, or null if setup has never been run. */
getSetupPlan: (sshHost: string): Promise<HostSetupPlan | null> => readSetupPlan(sshHost),
+ /** Every host's plan, for the initial hydrate of the renderer's readiness store. */
+ listSetupPlans: (): Promise<HostSetupPlan[]> => readAllSetupPlans(),
+
/**
* Build or refresh the plan without running it — what the host page loads on
* open. Merges onto any persisted progress rather than discarding it.
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts
index 62d04d119..1ed642c5a 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts
@@ -30,7 +30,7 @@ import {
GH_AUTH_STEP_ID,
reconcileInterruptedPlan,
} from './plan-builder';
-import { deleteSetupPlan, getSetupPlan, saveSetupPlan } from './setup-plan-store';
+import { deleteSetupPlan, getSetupPlan, listSetupPlans, saveSetupPlan } from './setup-plan-store';
import { outcomeForDependency, outcomeForGhAuth } from './step-outcomes';
/** Runners are per-host so two hosts can be set up at once, but a host only once. */
@@ -70,6 +70,15 @@ export async function ensureSetupPlan(sshHost: string): Promise<HostSetupPlan> {
return plan;
}
+/**
+ * Every host's persisted plan. Feeds the renderer store that the sidebar and
+ * the agent-creation gate read — both need readiness for hosts whose page
+ * nobody has opened.
+ */
+export async function readAllSetupPlans(): Promise<HostSetupPlan[]> {
+ return await listSetupPlans();
+}
+
/** The persisted plan, without rebuilding it. Null when the host has never run setup. */
export async function readSetupPlan(sshHost: string): Promise<HostSetupPlan | null> {
return await getSetupPlan(sshHost);
diff --git a/dash/apps/switchdash-desktop/src/renderer/app/modal-registry.ts b/dash/apps/switchdash-desktop/src/renderer/app/modal-registry.ts
index efdd033e1..9abd40f1c 100644
--- a/dash/apps/switchdash-desktop/src/renderer/app/modal-registry.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/app/modal-registry.ts
@@ -2,6 +2,7 @@ import { CommandPaletteModal } from '@renderer/features/command-palette/command-
import { AddAgentModal } from '@renderer/features/locations/components/add-agent-modal/add-agent-modal';
import { DeleteAgentModal } from '@renderer/features/locations/components/delete-agent-modal';
import { ResetAgentModal } from '@renderer/features/locations/components/reset-agent-modal';
+import { AddHostModal } from '@renderer/features/remote-hosts/add-host-modal';
import { CreateSessionModal } from '@renderer/features/sessions/create-session-modal/create-session-modal';
import { DeleteSessionModal } from '@renderer/features/sessions/delete-session-modal';
import { RenameSessionModal } from '@renderer/features/sessions/rename-session-modal';
@@ -56,6 +57,7 @@ export const modalRegistry = {
}),
deleteSessionModal: createModal(DeleteSessionModal, { size: 'sm' }),
addServerModal: createModal(AddServerModal, { size: 'md', dismissOnOutsideClick: false }),
+ addHostModal: createModal(AddHostModal, { size: 'md', dismissOnOutsideClick: false }),
assignServerModal: createModal(AssignServerModal, { size: 'sm', dismissOnOutsideClick: false }),
renameServerModal: createModal(RenameServerModal, {
size: 'xs',
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.tsx
index 8be0de954..6f25da7c7 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
@@ -11,6 +11,10 @@ import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import { getLocationManagerStore } from '@renderer/features/locations/stores/location-selectors';
import { HostReachabilityNotice } from '@renderer/features/remote-hosts/host-reachability-notice';
import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reachability-store';
+import {
+ HostReadinessNotice,
+ useRemoteHostReadiness,
+} from '@renderer/features/remote-hosts/host-readiness-notice';
import { policyHasDeadRule } from '@renderer/features/switch-servers/addressing-policy-editor';
import type { ServerVerifyState } from '@renderer/features/switch-servers/agent-server-picker';
import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
@@ -279,6 +283,13 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
// into the failing state this ticket exists to surface (CHOO-1676).
const runHostReachable = !isRemoteRun || !hostReachabilityStore.isBlocked(runHost);
+ // A reachable host that is missing git (or node, or the connector) will
+ // 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 runHostReady = !isRemoteRun || (!hostReadiness.blocked && !hostReadiness.checking);
+
const canSubmitDetected = isRemoteRun
? !!pickState.providerId &&
trimmedRemoteDir.length > 0 &&
@@ -286,6 +297,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
!!switchAgent &&
verifyState === 'found' &&
runHostReachable &&
+ runHostReady &&
submitState === 'idle'
: pickState.isValid &&
!isChecking &&
@@ -301,6 +313,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
!!pickState.providerId &&
remoteRunValid &&
runHostReachable &&
+ runHostReady &&
submitState === 'idle';
// Remote configure gate: no agent in the remote dir yet — a valid remote
@@ -316,6 +329,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
!!pickState.providerId &&
trimmedRemoteDir.length > 0 &&
runHostReachable &&
+ runHostReady &&
submitState === 'idle';
const reportCreationError = (error: AgentOnboardingError) => {
@@ -613,6 +627,13 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
</p>
)}
{isRemoteRun && <HostReachabilityNotice sshHost={runHost} />}
+ {isRemoteRun && runHostReachable && (
+ <HostReadinessNotice
+ sshHost={runHost}
+ readiness={hostReadiness}
+ onNavigateAway={onClose}
+ />
+ )}
{isRemoteRun && runHostReachable && (
<div className="flex items-center gap-2">
<Input
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/add-host-modal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/add-host-modal.tsx
new file mode 100644
index 000000000..ef8d57320
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/add-host-modal.tsx
@@ -0,0 +1,168 @@
+/**
+ * Adding a remote host (CHOO-1809).
+ *
+ * This was an inline form living in the page header's action slot — a slot
+ * sized for a button — so it rendered as a cramped box wedged beside the filter
+ * tabs. It is a data-entry step like adding a server or an agent, and it now
+ * looks like one.
+ */
+
+import { useMutation, useQuery } from '@tanstack/react-query';
+import { Plus } from 'lucide-react';
+import { useMemo, useState } from 'react';
+import { rpc } from '@renderer/lib/ipc';
+import { type BaseModalProps } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
+import {
+ DialogContentArea,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@renderer/lib/ui/dialog';
+import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';
+import { Input } from '@renderer/lib/ui/input';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@renderer/lib/ui/select';
+import { Spinner } from '@renderer/lib/ui/spinner';
+import { log } from '@renderer/utils/logger';
+
+export type AddHostModalProps = BaseModalProps<void> & {
+ /** Aliases already onboarded, so the picker does not offer duplicates. */
+ onboarded: string[];
+ onAdded: (sshHost: string) => void;
+};
+
+/** Suggest a display name from the alias, so the second field is rarely work. */
+function suggestName(alias: string): string {
+ return alias
+ .split(/[-_.]/)
+ .filter(Boolean)
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
+ .join(' ');
+}
+
+export function AddHostModal({ onboarded, onAdded, onClose }: AddHostModalProps) {
+ const [sshHost, setSshHost] = useState('');
+ const [name, setName] = useState('');
+ const [nameEdited, setNameEdited] = useState(false);
+
+ const configHosts = useQuery({
+ queryKey: ['ssh-config-hosts'],
+ queryFn: () => rpc.remoteHosts.listSshConfigHosts(),
+ });
+
+ const available = useMemo(
+ () => (configHosts.data ?? []).filter((alias) => !onboarded.includes(alias)),
+ [configHosts.data, onboarded]
+ );
+
+ const chooseHost = (alias: string) => {
+ setSshHost(alias);
+ if (!nameEdited) setName(suggestName(alias));
+ };
+
+ const mutation = useMutation({
+ mutationFn: () => rpc.remoteHosts.onboardHost({ sshHost: sshHost.trim(), name: name.trim() }),
+ onError: (error) => log.error('Failed to onboard remote host', { sshHost, error }),
+ onSuccess: (host) => {
+ onAdded(host.sshHost);
+ onClose();
+ },
+ });
+
+ const canSubmit = sshHost.trim().length > 0 && name.trim().length > 0 && !mutation.isPending;
+
+ return (
+ <>
+ <DialogHeader>
+ <DialogTitle>Add a remote host</DialogTitle>
+ </DialogHeader>
+
+ <DialogContentArea>
+ <FieldGroup>
+ <Field>
+ <FieldLabel>SSH host</FieldLabel>
+ <p className="text-xs text-foreground-muted">
+ A Host alias from your <code>~/.ssh/config</code>. Auth uses your SSH agent —
+ switchdash stores no credentials.
+ </p>
+ {/*
+ Wait for the alias list before choosing which control to show.
+ Swapping a text input for a select once the query resolves used to
+ discard whatever the user had already typed.
+ */}
+ {configHosts.isLoading ? (
+ <div className="flex items-center gap-2 text-xs text-foreground-muted">
+ <Spinner /> Reading ~/.ssh/config…
+ </div>
+ ) : available.length > 0 ? (
+ <Select value={sshHost} onValueChange={(value) => chooseHost(value ?? '')}>
+ <SelectTrigger>
+ <SelectValue placeholder="Select a host alias" />
+ </SelectTrigger>
+ <SelectContent>
+ {available.map((alias) => (
+ <SelectItem key={alias} value={alias}>
+ {alias}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ ) : (
+ <>
+ <Input
+ value={sshHost}
+ placeholder="dev-vm"
+ onChange={(event) => chooseHost(event.target.value)}
+ />
+ <p className="text-xs text-foreground-muted">
+ {(configHosts.data ?? []).length === 0
+ ? 'No aliases found in ~/.ssh/config — type one to add it anyway.'
+ : 'Every alias in ~/.ssh/config is already onboarded.'}
+ </p>
+ </>
+ )}
+ </Field>
+
+ <Field>
+ <FieldLabel>Display name</FieldLabel>
+ <Input
+ value={name}
+ placeholder="Dev VM"
+ onChange={(event) => {
+ setNameEdited(true);
+ setName(event.target.value);
+ }}
+ />
+ </Field>
+
+ {mutation.isError && (
+ <p className="text-destructive text-xs">{(mutation.error as Error).message}</p>
+ )}
+ </FieldGroup>
+ </DialogContentArea>
+
+ <DialogFooter>
+ <Button variant="ghost" onClick={onClose} disabled={mutation.isPending}>
+ Cancel
+ </Button>
+ <Button onClick={() => mutation.mutate()} disabled={!canSubmit}>
+ {mutation.isPending ? (
+ <>
+ <Spinner /> Verifying…
+ </>
+ ) : (
+ <>
+ <Plus className="size-4" /> Add host
+ </>
+ )}
+ </Button>
+ </DialogFooter>
+ </>
+ );
+}
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.tsx
new file mode 100644
index 000000000..5cf6ed194
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness-notice.tsx
@@ -0,0 +1,117 @@
+/**
+ * The readiness gate on creating an agent (CHOO-1809).
+ *
+ * A host missing what an agent needs used to change nothing outside its own
+ * page: you could create an agent on a host with no git and find out when the
+ * session failed. This refuses, names what is missing, and offers one click to
+ * the place that fixes it.
+ *
+ * The rule that matters is what happens when we *do not know*. A host nobody
+ * has checked is not blocked — it is checked, now, and then judged. Refusing on
+ * ignorance is the same mistake as the false green, only inverted, and it would
+ * contradict how `unknown` reachability already behaves everywhere else.
+ */
+
+import { CircleAlert } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect, useRef, useState } from 'react';
+import { rpc } from '@renderer/lib/ipc';
+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 { hostReachabilityStore } from './host-reachability-store';
+import { resolveReadiness, type HostReadiness } from './host-readiness';
+import { hostSetupStore } from './host-setup-store';
+
+export { resolveReadiness, type HostReadiness };
+
+/**
+ * Readiness for the host an agent is about to be created on, probing once if
+ * nothing has ever been observed.
+ *
+ * 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 {
+ 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.
+ const probed = useRef(new Set<string>());
+
+ useEffect(() => {
+ void hostSetupStore.hydrate();
+ }, []);
+
+ const reachability = sshHost ? hostReachabilityStore.get(sshHost) : null;
+ const plan = hostSetupStore.get(sshHost);
+ const status = sshHost && reachability ? deriveHostStatus(reachability, plan) : null;
+ const needsProbe = status?.kind === 'unchecked';
+
+ useEffect(() => {
+ if (!sshHost || !needsProbe || probed.current.has(sshHost)) return;
+ probed.current.add(sshHost);
+ setChecking(true);
+ rpc.remoteHosts
+ .recheckSetup(sshHost)
+ .catch((error: unknown) => {
+ // A probe we could not run tells us nothing. Leaving the gate open is
+ // the honest outcome — the alternative blocks the user over our own
+ // failure to look.
+ log.warn('Could not check host readiness before creating an agent', { sshHost, error });
+ })
+ .finally(() => setChecking(false));
+ }, [sshHost, needsProbe]);
+
+ return resolveReadiness(status, plan, checking || needsProbe);
+}
+
+/** Explains a blocked host, and sends the user to the page that fixes it. */
+export const HostReadinessNotice = observer(function HostReadinessNotice({
+ sshHost,
+ readiness,
+ onNavigateAway,
+}: {
+ sshHost: string;
+ readiness: HostReadiness;
+ /** Called before navigating, so a host modal can close itself first. */
+ onNavigateAway?: () => void;
+}) {
+ const { navigate } = useNavigate();
+
+ if (readiness.checking) {
+ return (
+ <div className="flex items-center gap-2 text-xs text-foreground-muted">
+ <Spinner /> Checking what {sshHost} has installed…
+ </div>
+ );
+ }
+
+ if (!readiness.blocked) return null;
+
+ return (
+ <div className="flex items-start gap-2 rounded-md border border-border bg-background-1 px-2 py-1.5 text-xs text-foreground-muted">
+ <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
+ {readiness.missing.length > 0 ? `: ${readiness.missing.join(', ')} ` : ' '}
+ {readiness.missing.length === 1 ? 'is missing.' : 'are missing.'} An agent created here
+ would fail to start.
+ </span>
+ <Button
+ size="sm"
+ variant="outline"
+ className="w-fit"
+ onClick={() => {
+ onNavigateAway?.();
+ navigate('remoteHost', { sshHost });
+ }}
+ >
+ Set up {sshHost}
+ </Button>
+ </div>
+ </div>
+ );
+});
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.ts
new file mode 100644
index 000000000..9859faa4e
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts
@@ -0,0 +1,109 @@
+import { describe, expect, it } from 'vitest';
+import { deriveHostStatus, type HostStatus } from '@shared/core/remote-hosts/host-status';
+import type {
+ HostReachability,
+ HostReachabilityStatus,
+} from '@shared/core/remote-hosts/reachability';
+import type {
+ HostSetupPlan,
+ HostSetupStep,
+ HostSetupStepState,
+} from '@shared/core/remote-hosts/setup';
+import { resolveReadiness } from './host-readiness';
+
+function reachability(status: HostReachabilityStatus): HostReachability {
+ return {
+ sshHost: 'dev-vm',
+ status,
+ lastError: null,
+ lastCheckedAt: null,
+ lastReachableAt: null,
+ consecutiveFailures: 0,
+ nextProbeAt: null,
+ probing: false,
+ };
+}
+
+function step(id: string, state: HostSetupStepState): HostSetupStep {
+ return {
+ id,
+ kind: 'core-dependency',
+ name: id,
+ state,
+ outcome: state === 'satisfied' ? 'satisfied' : 'missing',
+ version: null,
+ error: null,
+ output: null,
+ optional: false,
+ dependsOn: [],
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ };
+}
+
+function plan(steps: HostSetupStep[]): HostSetupPlan {
+ return {
+ sshHost: 'dev-vm',
+ status: 'idle',
+ steps,
+ currentStepId: null,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ };
+}
+
+const statusFor = (p: HostSetupPlan | null, r: HostReachabilityStatus = 'reachable'): HostStatus =>
+ deriveHostStatus(reachability(r), p);
+
+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);
+
+ expect(readiness.blocked).toBe(true);
+ expect(readiness.missing).toEqual(['git']);
+ });
+
+ it('allows a ready host', () => {
+ const p = plan([step('git', 'satisfied')]);
+
+ expect(resolveReadiness(statusFor(p), p, 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);
+
+ expect(readiness.blocked).toBe(false);
+ expect(readiness.checking).toBe(true);
+ });
+
+ 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);
+ });
+
+ it('does not block a local run, which has no host', () => {
+ expect(resolveReadiness(null, null, false).blocked).toBe(false);
+ });
+ });
+
+ it('leaves an unreachable host to the reachability gate rather than calling it not-ready', () => {
+ // The modal already refuses unreachable hosts and says something more
+ // useful about them; reporting "missing dependencies" here would blame the
+ // prerequisites for a network problem.
+ const p = plan([step('git', 'pending')]);
+
+ const readiness = resolveReadiness(statusFor(p, 'unreachable'), p, false);
+
+ expect(readiness.blocked).toBe(false);
+ });
+
+ it('counts a skipped required step as still missing', () => {
+ const p = plan([step('git', 'skipped')]);
+
+ expect(resolveReadiness(statusFor(p), p, false).blocked).toBe(true);
+ });
+});
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.ts
new file mode 100644
index 000000000..bcec917fc
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.ts
@@ -0,0 +1,44 @@
+/**
+ * The agent-creation readiness gate's decision (CHOO-1809).
+ *
+ * Split from the component so the rule can be tested without dragging in the
+ * renderer's electron bridge — and because this rule is the whole point of the
+ * gate, not an implementation detail of a notice.
+ */
+
+import type { HostStatus } from '@shared/core/remote-hosts/host-status';
+import { outstandingRequiredSteps, type HostSetupPlan } from '@shared/core/remote-hosts/setup';
+
+export type HostReadiness = {
+ /** True when we know the host is missing something an 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[];
+};
+
+const READY: HostReadiness = { blocked: false, checking: false, missing: [] };
+
+/**
+ * The gate's decision, as a pure function.
+ *
+ * `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
+ * mistake as the false green, inverted.
+ */
+export function resolveReadiness(
+ status: HostStatus | null,
+ plan: HostSetupPlan | null,
+ probing: boolean
+): HostReadiness {
+ if (!status) return READY;
+ if (probing) return { blocked: false, checking: true, missing: [] };
+ if (status.kind !== 'setup-required') return READY;
+ return {
+ blocked: true,
+ checking: false,
+ missing: plan ? outstandingRequiredSteps(plan).map((step) => step.name) : [],
+ };
+}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-setup-store.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-setup-store.ts
new file mode 100644
index 000000000..ffd37a21b
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-setup-store.ts
@@ -0,0 +1,67 @@
+/**
+ * Every host's readiness, app-wide (CHOO-1809).
+ *
+ * Readiness used to live only in the host page's react-query cache, so nothing
+ * else could see it: uninstalling git from a host made that page honest and
+ * changed nothing anywhere else — the sidebar said nothing and agents could
+ * still be created there.
+ *
+ * This puts it on the same footing as reachability: one store, hydrated once,
+ * kept current by the pushed plan events, readable from any component. Pair it
+ * with `hostReachabilityStore` through `deriveHostStatus` — never read one
+ * without the other, or an unreachable host reads as "missing dependencies".
+ */
+
+import { makeAutoObservable, runInAction } from 'mobx';
+import { events, rpc } from '@renderer/lib/ipc';
+import { log } from '@renderer/utils/logger';
+import { hostSetupPlanEventChannel, type HostSetupPlan } from '@shared/core/remote-hosts/setup';
+
+class HostSetupStore {
+ private plans = new Map<string, HostSetupPlan>();
+ private hydrated = false;
+ private hydrating: Promise<void> | null = null;
+
+ constructor() {
+ makeAutoObservable<this, 'plans' | 'hydrating'>(this, {
+ plans: true,
+ hydrating: false,
+ });
+
+ events.on(hostSetupPlanEventChannel, (plan) => {
+ runInAction(() => {
+ this.plans.set(plan.sshHost, plan);
+ });
+ });
+ }
+
+ /** Load once. Idempotent and safe to call from every component that needs it. */
+ hydrate(): Promise<void> {
+ if (this.hydrated) return Promise.resolve();
+ this.hydrating ??= rpc.remoteHosts
+ .listSetupPlans()
+ .then((plans) => {
+ runInAction(() => {
+ for (const plan of plans) this.plans.set(plan.sshHost, plan);
+ this.hydrated = true;
+ });
+ })
+ .catch((error: unknown) => {
+ // Leave `hydrated` false so a later caller retries rather than the app
+ // quietly treating "we failed to load" as "no host needs anything".
+ log.error('Could not load remote host setup plans', { error });
+ })
+ .finally(() => {
+ this.hydrating = null;
+ });
+ return this.hydrating;
+ }
+
+ /** Null when the host has no persisted plan — which is not the same as ready. */
+ get(sshHost: string | null): HostSetupPlan | null {
+ if (!sshHost) return null;
+ return this.plans.get(sshHost) ?? null;
+ }
+}
+
+export const hostSetupStore = new HostSetupStore();
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.tsx
new file mode 100644
index 000000000..31ac98d1a
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx
@@ -0,0 +1,73 @@
+/**
+ * Why an agent's host is a problem, on the agent's own row (CHOO-1809).
+ *
+ * Surfaces deviation only — a healthy host adds nothing, because a green tick
+ * on every row is noise that trains people to stop reading the column.
+ *
+ * Both reachability and readiness are handled here, in that order, so the two
+ * 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.
+ */
+
+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 { hostReachabilityStore } from './host-reachability-store';
+import { hostSetupStore } from './host-setup-store';
+
+const ICON = 'h-3.5 w-3.5 shrink-0 text-foreground-warning';
+
+export const HostTroubleIndicator = observer(function HostTroubleIndicator({
+ sshHost,
+}: {
+ /** Null for a local agent, which has no host to be in trouble. */
+ sshHost: string | null;
+}) {
+ useEffect(() => {
+ void hostSetupStore.hydrate();
+ }, []);
+
+ if (!sshHost) return null;
+
+ const reachability = hostReachabilityStore.get(sshHost);
+ const plan = hostSetupStore.get(sshHost);
+ const status = deriveHostStatus(reachability, plan);
+
+ // 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
+ // to connect (CHOO-1682).
+ if (status.kind === 'unreachable' || status.kind === 'auth-failed') {
+ return (
+ <Tooltip>
+ <TooltipTrigger>
+ <PlugZap className={ICON} />
+ </TooltipTrigger>
+ <TooltipContent>
+ {status.kind === 'auth-failed'
+ ? `SSH authentication to ${sshHost} failed — work is paused until you retry`
+ : `Host ${sshHost} is unreachable — work is paused`}
+ {reachability.lastError ? ` · ${reachability.lastError}` : ''}
+ </TooltipContent>
+ </Tooltip>
+ );
+ }
+
+ if (status.kind !== 'setup-required') return null;
+
+ const missing = plan ? outstandingRequiredSteps(plan).map((step) => step.name) : [];
+ return (
+ <Tooltip>
+ <TooltipTrigger>
+ <Wrench className={ICON} />
+ </TooltipTrigger>
+ <TooltipContent>
+ {`${sshHost} is missing something this agent needs`}
+ {missing.length > 0 ? `: ${missing.join(', ')}` : ''}
+ </TooltipContent>
+ </Tooltip>
+ );
+});
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
index a208ca524..54f575de0 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
@@ -1,14 +1,22 @@
/**
* One thing on a host, in detail (CHOO-1809).
*
- * The row says what state something is in; this says what we actually observed
- * and what you can do about it. Mirrors the agents settings page, where a row
- * opens a sheet carrying the install detail rather than expanding the list.
+ * Deliberately the same shape as the agents settings sheet: an identity header,
+ * an **Installation** section with the found/not-found card, and — for an agent
+ * type — a **Switch setup** section for its connector. Setting up Claude Code
+ * on a remote host should not look like a different product from setting it up
+ * locally.
+ *
+ * The row says what state something is in; this says what was actually
+ * observed and what you can do about it.
*/
-import { ChevronRight } from 'lucide-react';
+import { Check, ChevronRight, Loader2, X } from 'lucide-react';
import { useState } from 'react';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
import { Button } from '@renderer/lib/ui/button';
+import { Field } from '@renderer/lib/ui/field';
+import { Label } from '@renderer/lib/ui/label';
import { Sheet, SheetContent, SheetHeader } from '@renderer/lib/ui/sheet';
import { StatusBadge } from '@renderer/lib/ui/status-badge';
import { cn } from '@renderer/utils/utils';
@@ -47,8 +55,75 @@ function FailureOutput({ output }: { output: string }) {
);
}
-/** What one step observed, plus its failure detail. */
-function StepDetail({
+/** The tick / spinner / cross tile the agents page uses for install status. */
+function OutcomeTile({ step }: { step: HostSetupStep }) {
+ if (step.state === 'satisfied') {
+ return (
+ <div className="flex size-6 items-center justify-center rounded-lg bg-background-success">
+ <Check
+ className="size-3.5 shrink-0 text-foreground-success"
+ absoluteStrokeWidth
+ strokeWidth={3}
+ />
+ </div>
+ );
+ }
+ if (step.state === 'checking' || step.state === 'installing') {
+ return (
+ <div className="flex size-6 items-center justify-center rounded-lg bg-background-2">
+ <Loader2 className="size-3.5 animate-spin text-foreground-muted" />
+ </div>
+ );
+ }
+ return (
+ <div className="flex size-6 items-center justify-center rounded-lg bg-background-2">
+ <X className="size-3.5 shrink-0 text-foreground-passive" strokeWidth={2.5} />
+ </div>
+ );
+}
+
+/** What a step observed, in the agents page's "Found `v…`" card. */
+function ObservationCard({ step, actions }: { step: HostSetupStep; actions?: React.ReactNode }) {
+ return (
+ <div className="flex flex-col gap-1.5">
+ <div className="flex items-center gap-2 rounded-lg border p-3">
+ <OutcomeTile step={step} />
+ <div className="min-w-0 flex-1 truncate text-sm">
+ {step.state === 'satisfied' ? (
+ <>
+ <span>Found</span>
+ {step.version && (
+ <span className="ml-1 rounded-md bg-background-quaternary-2 px-1 py-0.5 font-mono text-xs text-foreground-muted">
+ {step.version}
+ </span>
+ )}
+ <span className="ml-1">on this host</span>
+ </>
+ ) : step.state === 'checking' ? (
+ <span className="text-foreground-muted">Checking…</span>
+ ) : step.state === 'installing' ? (
+ <span className="text-foreground-muted">Installing…</span>
+ ) : (
+ <span className="text-foreground-muted">{outcomeLabel(step.outcome)}</span>
+ )}
+ </div>
+ {actions}
+ </div>
+
+ {step.state === 'failed' && step.error && (
+ <p className="text-destructive text-xs">{step.error}</p>
+ )}
+ {step.state === 'failed' && step.output && <FailureOutput output={step.output} />}
+ </div>
+ );
+}
+
+/** A gh-auth step whose own dependency has not been satisfied yet. */
+function isBlockedByDep(step: HostSetupStep): boolean {
+ return step.state === 'blocked' || step.state === 'pending';
+}
+
+function StepActions({
step,
onSkip,
skipping,
@@ -59,61 +134,54 @@ function StepDetail({
skipping: boolean;
onAuthenticate: () => void;
}) {
- const badge = stepBadge(step);
// Only offer the GitHub sign-in once gh itself is there — the device flow
// runs `gh` on the host, so offering it before the CLI exists sends the user
// into a failure that says nothing about the real problem.
const canSignIn = step.kind === 'gh-auth' && step.state !== 'satisfied' && !isBlockedByDep(step);
+ if (!canSignIn && !canSkip(step)) return null;
return (
- <div className="flex flex-col gap-2 rounded-lg border border-border p-3">
- <div className="flex items-start justify-between gap-3">
- <div className="flex min-w-0 flex-col gap-0.5">
- <span className="flex items-center gap-2 text-sm">
- {step.name}
- {step.optional && (
- <span className="rounded-sm border border-border px-1 text-[10px] text-foreground-muted">
- optional
- </span>
- )}
- </span>
- <span className="text-xs text-foreground-muted">
- {step.state === 'satisfied' && step.version
- ? `Found ${step.version}`
- : outcomeLabel(step.outcome)}
- </span>
- </div>
- <StatusBadge tone={badge.tone}>{badge.label}</StatusBadge>
- </div>
-
- {step.state === 'failed' && step.error && (
- <p className="text-destructive text-xs">{step.error}</p>
+ <div className="flex shrink-0 items-center gap-1.5">
+ {canSignIn && (
+ <Button size="xs" onClick={onAuthenticate}>
+ {step.error?.includes('read:packages') ? 'Re-authenticate' : 'Sign in'}
+ </Button>
)}
- {step.state === 'failed' && step.output && <FailureOutput output={step.output} />}
-
- {(canSignIn || canSkip(step)) && (
- <div className="flex items-center gap-2 pt-1">
- {canSignIn && (
- <Button size="sm" onClick={onAuthenticate}>
- {step.state === 'failed' && step.error?.includes('read:packages')
- ? 'Re-authenticate'
- : 'Sign in'}
- </Button>
- )}
- {canSkip(step) && (
- <Button size="sm" variant="ghost" disabled={skipping} onClick={onSkip}>
- {skipping ? 'Skipping…' : 'Skip this step'}
- </Button>
- )}
- </div>
+ {canSkip(step) && (
+ <Button size="xs" variant="ghost" disabled={skipping} onClick={onSkip}>
+ {skipping ? 'Skipping…' : 'Skip'}
+ </Button>
)}
</div>
);
}
-/** A gh-auth step whose own dependency has not been satisfied yet. */
-function isBlockedByDep(step: HostSetupStep): boolean {
- return step.state === 'blocked' || step.state === 'pending';
+/** Identity header, mirroring the agents sheet. */
+function ItemHeader({
+ icon,
+ name,
+ subtitle,
+ badge,
+}: {
+ icon: React.ReactNode;
+ name: string;
+ subtitle: string;
+ badge: React.ReactNode;
+}) {
+ return (
+ <div className="flex items-center gap-3">
+ <div className="flex size-12 shrink-0 items-center justify-center rounded-lg bg-background-quaternary-1 p-1.5">
+ {icon}
+ </div>
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <div className="flex items-center gap-2">
+ <span className="truncate text-lg text-foreground">{name}</span>
+ {badge}
+ </div>
+ <span className="text-xs text-foreground-muted">{subtitle}</span>
+ </div>
+ </div>
+ );
}
export type SheetTarget =
@@ -122,12 +190,17 @@ export type SheetTarget =
export function SetupDetailSheet({
target,
+ sshHost,
+ icon,
onClose,
onSkip,
skippingStepId,
onAuthenticate,
}: {
target: SheetTarget | null;
+ sshHost: string;
+ /** Icon for the prerequisite being shown; agent types use their own. */
+ icon: React.ReactNode;
onClose: () => void;
onSkip: (stepId: string) => void;
skippingStepId: string | null;
@@ -138,20 +211,39 @@ export function SetupDetailSheet({
<SheetContent side="right" className="flex flex-col gap-0 p-0">
{target && (
<>
- <SheetHeader
- label={target.kind === 'agent-type' ? target.row.name : target.step.name}
- />
- <div className="flex flex-col gap-4 overflow-y-auto px-4 pb-6">
+ <SheetHeader label={target.kind === 'agent-type' ? 'Agent type' : 'Prerequisite'} />
+ <div className="space-y-6 overflow-y-auto px-4 pb-6">
{target.kind === 'prerequisite' ? (
- <StepDetail
- step={target.step}
- onSkip={() => onSkip(target.step.id)}
- skipping={skippingStepId === target.step.id}
- onAuthenticate={onAuthenticate}
- />
+ <>
+ <ItemHeader
+ icon={icon}
+ name={target.step.name}
+ subtitle={`On ${sshHost}`}
+ badge={
+ <StatusBadge tone={stepBadge(target.step).tone}>
+ {stepBadge(target.step).label}
+ </StatusBadge>
+ }
+ />
+ <Field>
+ <Label>Installation</Label>
+ <ObservationCard
+ step={target.step}
+ actions={
+ <StepActions
+ step={target.step}
+ onSkip={() => onSkip(target.step.id)}
+ skipping={skippingStepId === target.step.id}
+ onAuthenticate={onAuthenticate}
+ />
+ }
+ />
+ </Field>
+ </>
) : (
<AgentTypeDetail
row={target.row}
+ sshHost={sshHost}
onSkip={onSkip}
skippingStepId={skippingStepId}
onAuthenticate={onAuthenticate}
@@ -167,11 +259,13 @@ export function SetupDetailSheet({
function AgentTypeDetail({
row,
+ sshHost,
onSkip,
skippingStepId,
onAuthenticate,
}: {
row: AgentTypeRow;
+ sshHost: string;
onSkip: (stepId: string) => void;
skippingStepId: string | null;
onAuthenticate: () => void;
@@ -179,26 +273,61 @@ function AgentTypeDetail({
const badge = agentTypeBadge(row);
return (
<>
- <div className="flex items-center justify-between gap-2">
- <p className="text-xs text-foreground-muted">
- An agent type is usable once its CLI is installed <em>and</em> its Switch connector is set
- up. Without the connector it starts with no Switch tools.
- </p>
- <StatusBadge tone={badge.tone}>{badge.label}</StatusBadge>
- </div>
- <StepDetail
- step={row.cli}
- onSkip={() => onSkip(row.cli.id)}
- skipping={skippingStepId === row.cli.id}
- onAuthenticate={onAuthenticate}
+ <ItemHeader
+ icon={<AgentIcon id={row.agentId} size={24} />}
+ name={row.name}
+ subtitle={`On ${sshHost}`}
+ badge={<StatusBadge tone={badge.tone}>{badge.label}</StatusBadge>}
/>
- {row.plugin && (
- <StepDetail
- step={row.plugin}
- onSkip={() => onSkip(row.plugin!.id)}
- skipping={skippingStepId === row.plugin.id}
- onAuthenticate={onAuthenticate}
+
+ <Field>
+ <Label>Installation</Label>
+ <ObservationCard
+ step={row.cli}
+ actions={
+ <StepActions
+ step={row.cli}
+ onSkip={() => onSkip(row.cli.id)}
+ skipping={skippingStepId === row.cli.id}
+ onAuthenticate={onAuthenticate}
+ />
+ }
/>
+ </Field>
+
+ {row.plugin && (
+ <Field>
+ <Label>Switch setup</Label>
+ <div className="space-y-2 rounded-lg border p-3">
+ <div className="flex items-center justify-between gap-2">
+ <div className="flex min-w-0 items-center gap-2">
+ <span className="text-sm text-foreground">switch-connector</span>
+ <StatusBadge tone={stepBadge(row.plugin).tone}>
+ {stepBadge(row.plugin).label}
+ </StatusBadge>
+ {row.plugin.version && (
+ <span className="text-xs text-foreground-muted">v{row.plugin.version}</span>
+ )}
+ </div>
+ <StepActions
+ step={row.plugin}
+ onSkip={() => onSkip(row.plugin!.id)}
+ skipping={skippingStepId === row.plugin.id}
+ onAuthenticate={onAuthenticate}
+ />
+ </div>
+ {row.plugin.state === 'failed' && row.plugin.error && (
+ <p className="text-destructive text-xs">{row.plugin.error}</p>
+ )}
+ {row.plugin.state === 'failed' && row.plugin.output && (
+ <FailureOutput output={row.plugin.output} />
+ )}
+ <p className="text-xs text-foreground-muted">
+ Connects this agent to a Switch instance. Without it the agent starts on this host
+ with no Switch tools.
+ </p>
+ </div>
+ </Field>
)}
</>
);
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx
index 54b46b02b..cb9b26579 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx
@@ -23,9 +23,9 @@ const PREREQUISITE_ICON: Record<string, React.ComponentType<{ className?: string
gh: Github,
};
-function PrerequisiteIcon({ step }: { step: HostSetupStep }) {
+export function PrerequisiteIcon({ step, size = 16 }: { step: HostSetupStep; size?: 16 | 24 }) {
const Icon = step.kind === 'gh-auth' ? KeyRound : (PREREQUISITE_ICON[step.id] ?? Server);
- return <Icon className="size-4 text-foreground-muted" />;
+ return <Icon className={cn('text-foreground-muted', size === 24 ? 'size-6' : 'size-4')} />;
}
export function SectionLabel({ children, count }: { children: React.ReactNode; count: number }) {
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.tsx
index 4158e01af..a7c293fc5 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
@@ -34,7 +34,12 @@ import { GhAuthPanel } from '../gh-auth-panel';
import { hostReachabilityStore } from '../host-reachability-store';
import { HostUnreachablePanel } from '../host-unreachable-panel';
import { SetupDetailSheet, type SheetTarget } from '../setup/setup-detail-sheet';
-import { AgentTypeRowItem, PrerequisiteRow, SectionLabel } from '../setup/setup-rows';
+import {
+ AgentTypeRowItem,
+ PrerequisiteIcon,
+ PrerequisiteRow,
+ SectionLabel,
+} from '../setup/setup-rows';
import { groupPlanSteps } from '../setup/step-presentation';
import {
useHostSetupPlan,
@@ -245,6 +250,12 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
<SetupDetailSheet
target={liveTarget}
+ sshHost={sshHost}
+ icon={
+ liveTarget?.kind === 'prerequisite' ? (
+ <PrerequisiteIcon step={liveTarget.step} size={24} />
+ ) : null
+ }
onClose={() => setSheetTarget(null)}
onSkip={(stepId) => skip.mutate(stepId)}
skippingStepId={skip.isPending ? (skip.variables ?? null) : null}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-hosts-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-hosts-view.tsx
index 41dc76566..cdb1ad98c 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-hosts-view.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-hosts-view.tsx
@@ -19,16 +19,9 @@ import type { ViewDefinition } from '@renderer/app/view-registry';
import { PageHeader } from '@renderer/lib/components/page-header';
import { rpc } from '@renderer/lib/ipc';
import { useNavigate } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
import { Button } from '@renderer/lib/ui/button';
-import { Input } from '@renderer/lib/ui/input';
import { Label } from '@renderer/lib/ui/label';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '@renderer/lib/ui/select';
import { Spinner } from '@renderer/lib/ui/spinner';
import { StatusBadge } from '@renderer/lib/ui/status-badge';
import { ToggleGroup, ToggleGroupItem } from '@renderer/lib/ui/toggle-group';
@@ -104,6 +97,7 @@ export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
const queryClient = useQueryClient();
const { navigate } = useNavigate();
const [filter, setFilter] = useState<HostFilter>('all');
+ const showAddHost = useShowModal('addHostModal');
const { data: hosts, isLoading } = useQuery({
queryKey: REMOTE_HOSTS_QUERY_KEY,
@@ -177,13 +171,21 @@ export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
<ToggleGroupItem value="ready">Ready</ToggleGroupItem>
<ToggleGroupItem value="attention">Needs setup</ToggleGroupItem>
</ToggleGroup>
- <OnboardHostForm
- onboarded={sshHosts}
- onOnboarded={(sshHost) => {
- invalidate();
- openHost(sshHost);
- }}
- />
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() =>
+ void showAddHost({
+ onboarded: sshHosts,
+ onAdded: (sshHost) => {
+ invalidate();
+ openHost(sshHost);
+ },
+ })
+ }
+ >
+ <Plus className="size-4" /> Add host
+ </Button>
</div>
</PageHeader>
@@ -233,124 +235,6 @@ export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
);
});
-function OnboardHostForm({
- onboarded,
- onOnboarded,
-}: {
- onboarded: string[];
- onOnboarded: (sshHost: string) => void;
-}) {
- const [open, setOpen] = useState(false);
- const [sshHost, setSshHost] = useState('');
- const [name, setName] = useState('');
-
- const configHosts = useQuery({
- queryKey: ['ssh-config-hosts'],
- queryFn: () => rpc.remoteHosts.listSshConfigHosts(),
- enabled: open,
- });
-
- const available = useMemo(
- () => (configHosts.data ?? []).filter((alias) => !onboarded.includes(alias)),
- [configHosts.data, onboarded]
- );
-
- const mutation = useMutation({
- mutationFn: () => rpc.remoteHosts.onboardHost({ sshHost: sshHost.trim(), name: name.trim() }),
- onError: (error) => log.error('Failed to onboard remote host', { sshHost, error }),
- onSuccess: (host) => {
- setOpen(false);
- setSshHost('');
- setName('');
- onOnboarded(host.sshHost);
- },
- });
-
- if (!open) {
- return (
- <div>
- <Button size="sm" variant="outline" onClick={() => setOpen(true)}>
- <Plus className="size-4" /> Add host
- </Button>
- </div>
- );
- }
-
- const canSubmit = sshHost.trim().length > 0 && name.trim().length > 0 && !mutation.isPending;
-
- return (
- <div className="flex flex-col gap-3 rounded-lg border border-border p-3">
- <div className="flex flex-col gap-1">
- <Label className="text-xs">SSH host</Label>
- <p className="text-xs text-foreground-muted">
- A Host alias from your ~/.ssh/config. Auth uses your SSH agent — switchdash stores no
- credentials.
- </p>
- {/*
- Wait for the alias list before choosing which control to show. Swapping
- a text input for a select once the query resolves used to discard
- whatever the user had already typed.
- */}
- {configHosts.isLoading ? (
- <div className="flex items-center gap-2 text-xs text-foreground-muted">
- <Spinner /> Reading ~/.ssh/config…
- </div>
- ) : available.length > 0 ? (
- <Select value={sshHost} onValueChange={(value) => setSshHost(value ?? '')}>
- <SelectTrigger>
- <SelectValue placeholder="Select a host alias" />
- </SelectTrigger>
- <SelectContent>
- {available.map((alias) => (
- <SelectItem key={alias} value={alias}>
- {alias}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- ) : (
- <>
- <Input
- value={sshHost}
- placeholder="dev-vm"
- onChange={(event) => setSshHost(event.target.value)}
- />
- <p className="text-xs text-foreground-muted">
- {(configHosts.data ?? []).length === 0
- ? 'No aliases found in ~/.ssh/config — type one to add it anyway.'
- : 'Every alias in ~/.ssh/config is already onboarded.'}
- </p>
- </>
- )}
- </div>
- <div className="flex flex-col gap-1">
- <Label className="text-xs">Display name</Label>
- <Input
- value={name}
- placeholder="Dev VM"
- onChange={(event) => setName(event.target.value)}
- />
- </div>
- {mutation.isError && (
- <p className="text-destructive text-xs">{(mutation.error as Error).message}</p>
- )}
- <div className="flex items-center justify-end gap-2">
- <Button
- size="sm"
- variant="ghost"
- onClick={() => setOpen(false)}
- disabled={mutation.isPending}
- >
- Cancel
- </Button>
- <Button size="sm" onClick={() => mutation.mutate()} disabled={!canSubmit}>
- {mutation.isPending ? 'Verifying…' : 'Add host'}
- </Button>
- </div>
- </div>
- );
-}
-
/**
* Removing a host drops its setup progress as well as the row, so it asks
* first. The previous version deleted on a single click of a trash icon.
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.tsx
index ced907eae..32a9e5dcb 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
@@ -3,7 +3,6 @@ import {
Bot,
ChevronRight,
ExternalLink,
- PlugZap,
Plus,
RotateCcw,
Server,
@@ -17,6 +16,7 @@ import {
locationViewKind,
} from '@renderer/features/locations/stores/location-selectors';
import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reachability-store';
+import { HostTroubleIndicator } from '@renderer/features/remote-hosts/host-trouble-indicator';
import { hasSessionError } from '@renderer/features/sessions/stores/session-selectors';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { AgentIcon } from '@renderer/lib/components/agent-icon';
@@ -103,7 +103,6 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
if (!location) return null;
const sshHost = location.data?.sshHost ?? null;
- const hostReachability = sshHost ? hostReachabilityStore.get(sshHost) : null;
const hostUnreachable = hostReachabilityStore.isBlocked(sshHost);
const iconClass =
@@ -170,22 +169,10 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
</TooltipContent>
</Tooltip>
)}
- {/* 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 to connect (CHOO-1682). */}
- {hostUnreachable && hostReachability && (
- <Tooltip>
- <TooltipTrigger>
- <PlugZap className="h-3.5 w-3.5 shrink-0 text-foreground-warning" />
- </TooltipTrigger>
- <TooltipContent>
- {hostReachability.status === 'suspended'
- ? `SSH authentication to ${hostReachability.sshHost} failed — work is paused until you retry`
- : `Host ${hostReachability.sshHost} is unreachable — work is paused`}
- {hostReachability.lastError ? ` · ${hostReachability.lastError}` : ''}
- </TooltipContent>
- </Tooltip>
- )}
+ {/* Unreachable host, or one missing something this agent needs.
+ Shared with the room-grouped rows so the two trees cannot
+ disagree about the same agent (CHOO-1682/1809). */}
+ <HostTroubleIndicator sshHost={sshHost} />
{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.tsx
index 578c6c707..f3c1a8098 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
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { Bot, ChevronRight, DoorOpen, Plus } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { getLocationStore } from '@renderer/features/locations/stores/location-selectors';
+import { HostTroubleIndicator } from '@renderer/features/remote-hosts/host-trouble-indicator';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { AgentIcon } from '@renderer/lib/components/agent-icon';
import { useToast } from '@renderer/lib/hooks/use-toast';
@@ -136,7 +137,13 @@ export const RoomAgentRow = observer(function RoomAgentRow({
/>
</SidebarItemMiniButton>
<SidebarMenuAction aria-label={`Open agent ${label}`} className="truncate select-none">
- <span className="truncate">{label}</span>
+ <span className="flex min-w-0 items-center gap-1.5">
+ <span className="truncate">{label}</span>
+ {/* Same agent, same host problem — this row used to show
+ nothing, so whether you saw it depended on which grouping
+ the sidebar happened to be in. */}
+ <HostTroubleIndicator sshHost={location.data?.sshHost ?? null} />
+ </span>
</SidebarMenuAction>
</div>
<Tooltip>