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): rebuild the remote-host pages on the agents-page pattern (CHOO-1809)

switch-worker-louis-remote761a79d985c8
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 95b5e9668..aa06d9e4f 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
@@ -30,6 +30,7 @@ import {
discardSetupPlan,
ensureSetupPlan,
readSetupPlan,
+ recheckSetup,
runSetup,
skipSetupStep,
} from './setup/host-setup-service';
@@ -203,9 +204,13 @@ export const remoteHostsController = createRPCController({
/**
* Build or refresh the plan without running it — what the host page loads on
* open. Merges onto any persisted progress rather than discarding it.
+ * Structural only: it lists what to check, it does not check it.
*/
prepareSetup: (sshHost: string): Promise<HostSetupPlan> => ensureSetupPlan(sshHost),
+ /** Probe every step and install nothing — the "Re-check" button. */
+ recheckSetup: (sshHost: string): Promise<HostSetupPlan> => recheckSetup(sshHost),
+
/**
* Run (or resume) setup. Steps are checked and installed one at a time and
* the run halts at the first required failure, holding its position so it can
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.test.ts
index 6f3a0982d..c84d9307a 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.test.ts
@@ -381,6 +381,84 @@ describe('plan helpers', () => {
});
});
+describe('checkAll — looking without touching', () => {
+ it('installs nothing, whatever it finds', async () => {
+ const { runner, installOrder } = makeRunner({
+ checks: { git: [{ outcome: 'satisfied' }], node: [{ outcome: 'missing' }] },
+ installs: {},
+ });
+
+ await runner.checkAll(plan([step('git'), step('node')]));
+
+ expect(installOrder).toEqual([]);
+ });
+
+ it('records what it saw on steps it leaves pending', async () => {
+ // The distinction the UI depends on: "not checked" vs "checked, and absent".
+ const { runner } = makeRunner({
+ checks: { node: [{ outcome: 'missing' }] },
+ installs: {},
+ });
+
+ const result = await runner.checkAll(plan([step('node')]));
+
+ expect(stateOf(result, 'node')).toBe('pending');
+ expect(result.steps[0]!.outcome).toBe('missing');
+ });
+
+ it('marks what is genuinely there as satisfied', async () => {
+ const { runner } = makeRunner({
+ checks: { git: [{ outcome: 'satisfied', version: '2.43.0' }] },
+ installs: {},
+ });
+
+ const result = await runner.checkAll(plan([step('git')]));
+
+ expect(stateOf(result, 'git')).toBe('satisfied');
+ expect(result.status).toBe('complete');
+ });
+
+ it('checks every step rather than stopping at the first problem', async () => {
+ // Unlike a run, there is nothing to halt for — the point is a full picture.
+ const { runner } = makeRunner({
+ checks: {
+ git: [{ outcome: 'missing' }],
+ node: [{ outcome: 'missing' }],
+ tmux: [{ outcome: 'satisfied' }],
+ },
+ installs: {},
+ });
+
+ const result = await runner.checkAll(plan([step('git'), step('node'), step('tmux')]));
+
+ expect(result.steps.map((s) => s.outcome)).toEqual(['missing', 'missing', 'satisfied']);
+ expect(stateOf(result, 'tmux')).toBe('satisfied');
+ });
+
+ it('supersedes a previous failure rather than leaving its error behind', async () => {
+ const { runner } = makeRunner({
+ checks: { node: [{ outcome: 'satisfied', version: '22.0.0' }] },
+ installs: {},
+ });
+
+ const result = await runner.checkAll(
+ plan([step('node', { state: 'failed', error: 'apt-get failed', output: 'E: broken' })])
+ );
+
+ expect(stateOf(result, 'node')).toBe('satisfied');
+ expect(result.steps[0]!.error).toBeNull();
+ expect(result.steps[0]!.output).toBeNull();
+ });
+
+ it('aborts as unreachable rather than reporting everything missing', async () => {
+ const { runner } = makeRunner({ checks: {}, installs: {}, reachable: false });
+
+ await expect(runner.checkAll(plan([step('git')]))).rejects.toBeInstanceOf(
+ HostSetupAbortedError
+ );
+ });
+});
+
describe('gh-auth steps', () => {
const ghStep = (patch: Partial<HostSetupStep> = {}) =>
step('gh:auth', { kind: 'gh-auth', name: 'GitHub CLI login', optional: true, ...patch });
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.ts
index d7d69ef54..0fe1ff723 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-runner.ts
@@ -130,6 +130,58 @@ export class HostSetupRunner {
});
}
+ /**
+ * Observe every step, installing nothing — what "Re-check" means.
+ *
+ * Without this the only way to learn a host's state was to press "Run setup",
+ * which also installs; a user who just wanted to know where a host stood had
+ * to risk changing it. A pass here records what is actually there and leaves
+ * unsatisfied steps `pending` — they carry their observed `outcome`, so the
+ * UI can say "not installed" rather than "not checked", without claiming an
+ * attempt was made.
+ *
+ * A previous failure's error and command output are cleared deliberately: a
+ * fresh observation supersedes the story of an older install attempt.
+ */
+ async checkAll(plan: HostSetupPlan): Promise<HostSetupPlan> {
+ if (this.running) {
+ throw new Error(`A setup run is already in progress for ${this.deps.sshHost}`);
+ }
+ this.running = true;
+ try {
+ let next = plan;
+ for (const step of plan.steps) {
+ try {
+ this.deps.requireReachable(this.deps.sshHost);
+ } catch (error) {
+ next = await this.transition(next, { status: 'halted', currentStepId: null });
+ throw new HostSetupAbortedError(
+ `Could not check ${this.deps.sshHost}: the host became unreachable.`,
+ error
+ );
+ }
+
+ next = await this.patchStep(next, step.id, {
+ state: 'checking',
+ error: null,
+ output: null,
+ });
+ next = await this.observe(next, step.id);
+
+ if (findStep(next, step.id).state !== 'satisfied') {
+ next = await this.patchStep(next, step.id, { state: 'pending' });
+ }
+ }
+
+ return await this.transition(next, {
+ status: isPlanComplete(next) ? 'complete' : 'idle',
+ currentStepId: null,
+ });
+ } finally {
+ this.running = false;
+ }
+ }
+
/**
* Check one step, install it if that is both needed and possible, then
* re-check to verify. Never marks a step satisfied on the strength of an
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 863862721..62d04d119 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
@@ -175,6 +175,27 @@ export async function runSetup(sshHost: string): Promise<HostSetupPlan> {
}
}
+/**
+ * Observe a host without changing it — the "Re-check" button.
+ *
+ * Rebuilds the plan first so newly-known dependencies are included, then probes
+ * every step and installs nothing.
+ */
+export async function recheckSetup(sshHost: string): Promise<HostSetupPlan> {
+ const plan = await ensureSetupPlan(sshHost);
+ const manager = await getRemoteDependencyManager(sshHost);
+ try {
+ return await runnerFor(sshHost, manager).checkAll(plan);
+ } catch (error) {
+ log.warn('[HostSetup] re-check stopped', {
+ event: 'host-setup-recheck-stopped',
+ sshHost,
+ error: String((error as Error)?.message ?? error),
+ });
+ throw error;
+ }
+}
+
/** Move past a step the user has chosen not to fix, unblocking the rest. */
export async function skipSetupStep(sshHost: string, stepId: string): Promise<HostSetupPlan> {
const plan = await getSetupPlan(sshHost);
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
new file mode 100644
index 000000000..a208ca524
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
@@ -0,0 +1,205 @@
+/**
+ * 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.
+ */
+
+import { ChevronRight } from 'lucide-react';
+import { useState } from 'react';
+import { Button } from '@renderer/lib/ui/button';
+import { Sheet, SheetContent, SheetHeader } from '@renderer/lib/ui/sheet';
+import { StatusBadge } from '@renderer/lib/ui/status-badge';
+import { cn } from '@renderer/utils/utils';
+import type { HostSetupStep } from '@shared/core/remote-hosts/setup';
+import {
+ agentTypeBadge,
+ canSkip,
+ outcomeLabel,
+ stepBadge,
+ type AgentTypeRow,
+} from './step-presentation';
+
+/**
+ * A failed step's raw command output, collapsed by default. Hidden behind a
+ * disclosure rather than dropped: it is usually the only thing that explains
+ * *why* an install failed, but it is long enough to bury everything else.
+ */
+function FailureOutput({ output }: { output: string }) {
+ const [open, setOpen] = useState(false);
+ return (
+ <div className="flex flex-col gap-1">
+ <button
+ type="button"
+ className="flex w-fit items-center gap-1 text-xs text-foreground-muted hover:text-foreground"
+ onClick={() => setOpen((prev) => !prev)}
+ >
+ <ChevronRight className={cn('size-3 transition-transform', open && 'rotate-90')} />
+ {open ? 'Hide output' : 'Show output'}
+ </button>
+ {open && (
+ <pre className="bg-background-subtle max-h-64 overflow-auto rounded-md p-2 text-xs whitespace-pre-wrap">
+ {output}
+ </pre>
+ )}
+ </div>
+ );
+}
+
+/** What one step observed, plus its failure detail. */
+function StepDetail({
+ step,
+ onSkip,
+ skipping,
+ onAuthenticate,
+}: {
+ step: HostSetupStep;
+ onSkip: () => void;
+ 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);
+
+ 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>
+ )}
+ {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>
+ )}
+ </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';
+}
+
+export type SheetTarget =
+ | { kind: 'prerequisite'; step: HostSetupStep }
+ | { kind: 'agent-type'; row: AgentTypeRow };
+
+export function SetupDetailSheet({
+ target,
+ onClose,
+ onSkip,
+ skippingStepId,
+ onAuthenticate,
+}: {
+ target: SheetTarget | null;
+ onClose: () => void;
+ onSkip: (stepId: string) => void;
+ skippingStepId: string | null;
+ onAuthenticate: () => void;
+}) {
+ return (
+ <Sheet open={target !== null} onOpenChange={(open) => !open && onClose()}>
+ <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">
+ {target.kind === 'prerequisite' ? (
+ <StepDetail
+ step={target.step}
+ onSkip={() => onSkip(target.step.id)}
+ skipping={skippingStepId === target.step.id}
+ onAuthenticate={onAuthenticate}
+ />
+ ) : (
+ <AgentTypeDetail
+ row={target.row}
+ onSkip={onSkip}
+ skippingStepId={skippingStepId}
+ onAuthenticate={onAuthenticate}
+ />
+ )}
+ </div>
+ </>
+ )}
+ </SheetContent>
+ </Sheet>
+ );
+}
+
+function AgentTypeDetail({
+ row,
+ onSkip,
+ skippingStepId,
+ onAuthenticate,
+}: {
+ row: AgentTypeRow;
+ onSkip: (stepId: string) => void;
+ skippingStepId: string | null;
+ onAuthenticate: () => void;
+}) {
+ 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}
+ />
+ {row.plugin && (
+ <StepDetail
+ step={row.plugin}
+ onSkip={() => onSkip(row.plugin!.id)}
+ skipping={skippingStepId === row.plugin.id}
+ onAuthenticate={onAuthenticate}
+ />
+ )}
+ </>
+ );
+}
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
new file mode 100644
index 000000000..54b46b02b
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx
@@ -0,0 +1,124 @@
+/**
+ * A host's contents as rows (CHOO-1809).
+ *
+ * The first cut of this page was a flat checklist of every step, which read as
+ * a wall of text and buried the one line that mattered. This is the same
+ * language the agents settings page uses — icon tile, name, status pill, click
+ * for detail — so a host reads like the rest of the product.
+ */
+
+import { GitBranch, Github, KeyRound, Package, Server, SquareTerminal } from 'lucide-react';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { Label } from '@renderer/lib/ui/label';
+import { StatusBadge } from '@renderer/lib/ui/status-badge';
+import { cn } from '@renderer/utils/utils';
+import type { HostSetupStep } from '@shared/core/remote-hosts/setup';
+import { agentTypeBadge, stepBadge, type AgentTypeRow, type BadgeSpec } from './step-presentation';
+
+/** Lucide icons for the host tools. Agent types use their own brand icon. */
+const PREREQUISITE_ICON: Record<string, React.ComponentType<{ className?: string }>> = {
+ git: GitBranch,
+ tmux: SquareTerminal,
+ node: Package,
+ gh: Github,
+};
+
+function PrerequisiteIcon({ step }: { step: HostSetupStep }) {
+ const Icon = step.kind === 'gh-auth' ? KeyRound : (PREREQUISITE_ICON[step.id] ?? Server);
+ return <Icon className="size-4 text-foreground-muted" />;
+}
+
+export function SectionLabel({ children, count }: { children: React.ReactNode; count: number }) {
+ return (
+ <div className="px-3 py-2">
+ <Label>
+ {children}
+ {` (${count})`}
+ </Label>
+ </div>
+ );
+}
+
+/**
+ * One row. Deliberately the same shape as the agents page's `AgentRow`: a
+ * tile, a name, a subtitle, and the status on the right.
+ */
+function Row({
+ icon,
+ name,
+ subtitle,
+ badge,
+ highlighted,
+ onClick,
+}: {
+ icon: React.ReactNode;
+ name: string;
+ subtitle?: string | null;
+ badge: BadgeSpec;
+ highlighted?: boolean;
+ onClick: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ className={cn(
+ 'group flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-left hover:bg-background-1',
+ highlighted && 'bg-background-1 ring-1 ring-amber-500/40'
+ )}
+ >
+ <div className="flex size-6 shrink-0 items-center justify-center rounded-lg bg-background-1 p-1.5 group-hover:bg-background-2">
+ {icon}
+ </div>
+ <div className="flex w-full min-w-0 items-center justify-between gap-2">
+ <span className="flex min-w-0 flex-col">
+ <span className="truncate text-sm text-foreground">{name}</span>
+ {subtitle && <span className="truncate text-xs text-foreground-muted">{subtitle}</span>}
+ </span>
+ <StatusBadge tone={badge.tone}>{badge.label}</StatusBadge>
+ </div>
+ </button>
+ );
+}
+
+export function PrerequisiteRow({
+ step,
+ isCurrent,
+ onOpen,
+}: {
+ step: HostSetupStep;
+ isCurrent: boolean;
+ onOpen: () => void;
+}) {
+ return (
+ <Row
+ icon={<PrerequisiteIcon step={step} />}
+ name={step.name}
+ subtitle={step.state === 'satisfied' ? step.version : null}
+ badge={stepBadge(step)}
+ highlighted={isCurrent}
+ onClick={onOpen}
+ />
+ );
+}
+
+export function AgentTypeRowItem({
+ row,
+ isCurrent,
+ onOpen,
+}: {
+ row: AgentTypeRow;
+ isCurrent: boolean;
+ onOpen: () => void;
+}) {
+ return (
+ <Row
+ icon={<AgentIcon id={row.agentId} size={16} />}
+ name={row.name}
+ subtitle={row.cli.state === 'satisfied' ? row.cli.version : null}
+ badge={agentTypeBadge(row)}
+ highlighted={isCurrent}
+ onClick={onOpen}
+ />
+ );
+}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-steps.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-steps.tsx
deleted file mode 100644
index 704db565b..000000000
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-steps.tsx
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * The visible setup sequence for one host (CHOO-1809).
- *
- * Every step renders its own state, its own error and its own command output.
- * The previous page showed a bare "Install failed" — and, when the failure came
- * back as a Result rather than a thrown error, showed nothing at all.
- */
-
-import { CheckCircle2, ChevronRight, Circle, Loader2, MinusCircle, XCircle } from 'lucide-react';
-import { useState } from 'react';
-import { Button } from '@renderer/lib/ui/button';
-import { cn } from '@renderer/utils/utils';
-import type { HostSetupStep } from '@shared/core/remote-hosts/setup';
-import { canSkip, stepStatusLabel, stepTone, type StepTone } from './step-presentation';
-
-const TONE_TEXT: Record<StepTone, string> = {
- done: 'text-green-500',
- busy: 'text-amber-500',
- failed: 'text-destructive',
- skipped: 'text-foreground-muted',
- waiting: 'text-foreground-muted',
- idle: 'text-foreground-muted',
-};
-
-function StepIcon({ tone }: { tone: StepTone }) {
- const className = cn('size-4 shrink-0', TONE_TEXT[tone]);
- switch (tone) {
- case 'done':
- return <CheckCircle2 className={className} />;
- case 'busy':
- return <Loader2 className={cn(className, 'animate-spin')} />;
- case 'failed':
- return <XCircle className={className} />;
- case 'skipped':
- return <MinusCircle className={className} />;
- case 'waiting':
- return <Circle className={className} />;
- case 'idle':
- return <Circle className={className} />;
- }
-}
-
-/**
- * A failed step's raw command output, collapsed by default. Hidden behind a
- * disclosure rather than dropped: it is usually the only thing that explains
- * *why* an install failed, but it is long enough to bury the rest of the page.
- */
-function FailureOutput({ output }: { output: string }) {
- const [open, setOpen] = useState(false);
- return (
- <div className="flex flex-col gap-1">
- <button
- type="button"
- className="flex w-fit items-center gap-1 text-xs text-foreground-muted hover:text-foreground"
- onClick={() => setOpen((prev) => !prev)}
- >
- <ChevronRight className={cn('size-3 transition-transform', open && 'rotate-90')} />
- {open ? 'Hide output' : 'Show output'}
- </button>
- {open && (
- <pre className="bg-background-subtle max-h-48 overflow-auto rounded-md p-2 text-xs whitespace-pre-wrap">
- {output}
- </pre>
- )}
- </div>
- );
-}
-
-export function SetupStepRow({
- step,
- isCurrent,
- onSkip,
- skipping,
- onAuthenticate,
-}: {
- step: HostSetupStep;
- isCurrent: boolean;
- onSkip: () => void;
- skipping: boolean;
- /** Starts the interactive GitHub sign-in. Only meaningful for the gh-auth step. */
- onAuthenticate: () => void;
-}) {
- const tone = stepTone(step);
-
- return (
- <li
- className={cn(
- 'flex flex-col gap-2 rounded-md border px-3 py-2',
- isCurrent ? 'border-amber-500/50' : 'border-border',
- tone === 'failed' && 'border-destructive/50'
- )}
- >
- <div className="flex items-start justify-between gap-3">
- <div className="flex min-w-0 items-start gap-2">
- <span className="pt-0.5">
- <StepIcon tone={tone} />
- </span>
- <span className="flex min-w-0 flex-col">
- <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={cn('text-xs', TONE_TEXT[tone])}>{stepStatusLabel(step)}</span>
- </span>
- </div>
- <div className="flex shrink-0 items-center gap-1">
- {step.kind === 'gh-auth' && step.state !== 'satisfied' && (
- <Button size="sm" onClick={onAuthenticate}>
- Sign in
- </Button>
- )}
- {canSkip(step) && (
- <Button size="sm" variant="ghost" disabled={skipping} onClick={onSkip}>
- {skipping ? 'Skipping…' : 'Skip'}
- </Button>
- )}
- </div>
- </div>
-
- {step.state === 'failed' && step.error && (
- <p className="text-destructive pl-6 text-xs">{step.error}</p>
- )}
- {step.state === 'failed' && step.output && (
- <div className="pl-6">
- <FailureOutput output={step.output} />
- </div>
- )}
- </li>
- );
-}
-
-export function SetupStepList({
- steps,
- currentStepId,
- onSkip,
- skippingStepId,
- onAuthenticate,
-}: {
- steps: HostSetupStep[];
- currentStepId: string | null;
- onSkip: (stepId: string) => void;
- skippingStepId: string | null;
- onAuthenticate: () => void;
-}) {
- if (steps.length === 0) {
- return (
- <p className="text-sm text-foreground-muted">
- No setup steps yet — prepare the host to work out what it needs.
- </p>
- );
- }
-
- return (
- <ol className="flex flex-col gap-2">
- {steps.map((step) => (
- <SetupStepRow
- key={step.id}
- step={step}
- isCurrent={step.id === currentStepId}
- onSkip={() => onSkip(step.id)}
- skipping={skippingStepId === step.id}
- onAuthenticate={onAuthenticate}
- />
- ))}
- </ol>
- );
-}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
index 03d4eb72d..c62dd743b 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
@@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest';
import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';
import {
+ agentTypeBadge,
+ canSkip,
+ groupPlanSteps,
outcomeLabel,
- showsAsComplete,
- stepStatusLabel,
- stepTone,
- summarisePlan,
+ stepBadge,
} from './step-presentation';
function step(patch: Partial<HostSetupStep> = {}): HostSetupStep {
@@ -37,157 +37,151 @@ function plan(steps: HostSetupStep[], patch: Partial<HostSetupPlan> = {}): HostS
};
}
-describe('showsAsComplete — the green tick must be earned', () => {
- it('is true only for a satisfied step', () => {
- expect(showsAsComplete(step({ state: 'satisfied' }))).toBe(true);
+describe('stepBadge — green must be earned', () => {
+ it('is success only for a satisfied step', () => {
+ expect(stepBadge(step({ state: 'satisfied' }))).toEqual({
+ tone: 'success',
+ label: 'Installed',
+ });
});
it.each(['pending', 'checking', 'installing', 'failed', 'skipped', 'blocked'] as const)(
- 'is false for %s',
+ 'is never success for %s',
(state) => {
- expect(showsAsComplete(step({ state }))).toBe(false);
+ expect(stepBadge(step({ state })).tone).not.toBe('success');
}
);
- it('is false for a skipped step even though the run moved past it', () => {
- expect(showsAsComplete(step({ state: 'skipped' }))).toBe(false);
- });
-
- it('is false when the check could not determine anything', () => {
- expect(showsAsComplete(step({ state: 'failed', outcome: 'unknown' }))).toBe(false);
- });
-});
-
-describe('stepTone', () => {
- it('maps each state to a distinct tone', () => {
- expect(stepTone(step({ state: 'satisfied' }))).toBe('done');
- expect(stepTone(step({ state: 'checking' }))).toBe('busy');
- expect(stepTone(step({ state: 'installing' }))).toBe('busy');
- expect(stepTone(step({ state: 'failed' }))).toBe('failed');
- expect(stepTone(step({ state: 'skipped' }))).toBe('skipped');
- expect(stepTone(step({ state: 'blocked' }))).toBe('waiting');
- expect(stepTone(step({ state: 'pending' }))).toBe('idle');
- });
-
- it('never gives a non-satisfied step the done tone', () => {
- const states = ['pending', 'checking', 'installing', 'failed', 'skipped', 'blocked'] as const;
- for (const state of states) {
- expect(stepTone(step({ state }))).not.toBe('done');
- }
+ it('does not show a skipped step as done even though the run moved past it', () => {
+ expect(stepBadge(step({ state: 'skipped' }))).toEqual({ tone: 'neutral', label: 'Skipped' });
+ });
+
+ describe('"not checked" and "checked, and absent" are different facts', () => {
+ it('says not checked when nothing has been observed', () => {
+ expect(stepBadge(step({ state: 'pending', outcome: null }))).toEqual({
+ tone: 'neutral',
+ label: 'Not checked',
+ });
+ });
+
+ it('reports what a probe-only pass observed, without claiming an attempt', () => {
+ // Re-check leaves steps pending but records the outcome. Showing that as
+ // "Not checked" would throw away the only thing the user asked for.
+ expect(stepBadge(step({ state: 'pending', outcome: 'missing' }))).toEqual({
+ tone: 'warning',
+ label: 'Not installed',
+ });
+ });
+
+ it('does not dress an undetermined probe up as a definite answer', () => {
+ expect(stepBadge(step({ state: 'pending', outcome: 'unknown' })).label).toBe(
+ 'Could not be checked'
+ );
+ });
});
});
-describe('labels', () => {
- it('distinguishes "could not check" from "not installed"', () => {
- expect(outcomeLabel('unknown')).toBe('Could not be checked');
- expect(outcomeLabel('missing')).toBe('Not installed');
- expect(outcomeLabel('unknown')).not.toBe(outcomeLabel('missing'));
- });
-
- it('names the installed-but-unusable states specifically', () => {
- expect(outcomeLabel('not-running')).toBe('Installed but not running');
- expect(outcomeLabel('wrong-version')).toBe('Installed but too old');
- });
-
- it('says a pending step has not been checked, rather than implying a result', () => {
- expect(stepStatusLabel(step({ state: 'pending' }))).toBe('Not checked yet');
- expect(outcomeLabel(null)).toBe('Not checked yet');
- });
-
- it('shows the detected version on a ready step', () => {
- expect(stepStatusLabel(step({ state: 'satisfied', version: '22.0.0' }))).toBe('Ready · 22.0.0');
- });
-
- it('explains that a blocked step is waiting on something upstream', () => {
- expect(stepStatusLabel(step({ state: 'blocked' }))).toBe('Waiting on an earlier step');
- });
-
- it('reports the observed outcome for a failed step', () => {
- expect(stepStatusLabel(step({ state: 'failed', outcome: 'not-running' }))).toBe(
- 'Installed but not running'
+describe('agentTypeBadge — a CLI alone is not usable', () => {
+ const cli = (patch: Partial<HostSetupStep> = {}) =>
+ step({ id: 'claude-code', kind: 'agent-cli', name: 'Claude Code', ...patch });
+ const plugin = (patch: Partial<HostSetupStep> = {}) =>
+ step({
+ id: 'claude-code:plugin',
+ kind: 'agent-plugin',
+ name: 'Claude Code · Switch connector',
+ ...patch,
+ });
+ const row = (c: HostSetupStep, p: HostSetupStep | null) => ({
+ agentId: 'claude-code',
+ name: 'Claude Code',
+ cli: c,
+ plugin: p,
+ });
+
+ it('is installed only when both the CLI and the connector are satisfied', () => {
+ expect(
+ agentTypeBadge(row(cli({ state: 'satisfied' }), plugin({ state: 'satisfied' })))
+ ).toEqual({ tone: 'success', label: 'Installed' });
+ });
+
+ it('calls out the connector when the CLI is there but the connector is not', () => {
+ // Without the connector the agent starts and has no Switch tools — rounding
+ // this up to "Installed" is what makes that failure invisible.
+ expect(agentTypeBadge(row(cli({ state: 'satisfied' }), plugin({ state: 'pending' })))).toEqual({
+ tone: 'warning',
+ label: 'Switch setup required',
+ });
+ });
+
+ it('reports the CLI state when the CLI itself is missing', () => {
+ expect(agentTypeBadge(row(cli({ state: 'pending', outcome: 'missing' }), plugin())).label).toBe(
+ 'Not installed'
);
});
-});
-describe('summarisePlan', () => {
- it('treats a host with no plan as unstarted, not ready', () => {
- const summary = summarisePlan(null);
- expect(summary.ready).toBe(false);
- expect(summary.tone).toBe('unstarted');
+ it('surfaces a failure from either half', () => {
+ expect(
+ agentTypeBadge(
+ row(cli({ state: 'satisfied' }), plugin({ state: 'failed', outcome: 'missing' }))
+ ).tone
+ ).toBe('danger');
});
- it('is ready only when every required step is satisfied', () => {
- const summary = summarisePlan(
- plan([step({ id: 'git', state: 'satisfied' }), step({ id: 'node', state: 'satisfied' })])
- );
- expect(summary.ready).toBe(true);
- expect(summary.headline).toBe('Ready');
+ it('shows work in flight ahead of the resting state', () => {
+ expect(
+ agentTypeBadge(row(cli({ state: 'satisfied' }), plugin({ state: 'installing' }))).label
+ ).toBe('Installing…');
});
+});
- it('ignores optional steps when deciding readiness', () => {
- const summary = summarisePlan(
+describe('groupPlanSteps', () => {
+ it('splits prerequisites from agent types and pairs each CLI with its connector', () => {
+ const grouped = groupPlanSteps(
plan([
- step({ id: 'node', state: 'satisfied' }),
- step({ id: 'gh', state: 'failed', optional: true }),
+ step({ id: 'git', name: 'Git' }),
+ step({ id: 'gh:auth', kind: 'gh-auth', name: 'GitHub CLI login' }),
+ step({ id: 'claude-code', kind: 'agent-cli', name: 'Claude Code' }),
+ step({
+ id: 'claude-code:plugin',
+ kind: 'agent-plugin',
+ name: 'Claude Code · Switch connector',
+ }),
])
);
- expect(summary.ready).toBe(true);
- });
- it('is not ready when a required step was skipped', () => {
- const summary = summarisePlan(
- plan([step({ id: 'node', state: 'skipped' }), step({ id: 'git', state: 'satisfied' })])
- );
- expect(summary.ready).toBe(false);
+ expect(grouped.prerequisites.map((s) => s.id)).toEqual(['git', 'gh:auth']);
+ expect(grouped.agentTypes).toHaveLength(1);
+ expect(grouped.agentTypes[0]!.agentId).toBe('claude-code');
+ expect(grouped.agentTypes[0]!.plugin?.id).toBe('claude-code:plugin');
});
- it('names the step a halted run stopped at', () => {
- const summary = summarisePlan(
- plan([
- step({ id: 'git', state: 'satisfied' }),
- step({ id: 'node', state: 'failed' }),
- step({ id: 'tmux', state: 'blocked' }),
- ])
- );
- expect(summary.tone).toBe('blocked');
- expect(summary.headline).toBe('Stopped at Node.js');
+ it('keeps an agent type whose connector step is absent', () => {
+ const grouped = groupPlanSteps(plan([step({ id: 'codex', kind: 'agent-cli', name: 'Codex' })]));
+
+ expect(grouped.agentTypes[0]!.plugin).toBeNull();
});
- it('does not report an optional failure as blocking', () => {
- const summary = summarisePlan(
- plan([
- step({ id: 'node', state: 'satisfied' }),
- step({ id: 'gh', state: 'failed', optional: true, name: 'GitHub CLI' }),
- ])
- );
- expect(summary.tone).not.toBe('blocked');
+ it('is empty for a host with no plan', () => {
+ expect(groupPlanSteps(null)).toEqual({ prerequisites: [], agentTypes: [] });
});
+});
- it('names the step currently running', () => {
- const summary = summarisePlan(
- plan([step({ id: 'node', state: 'installing' })], {
- status: 'running',
- currentStepId: 'node',
- })
- );
- expect(summary.headline).toBe('Setting up Node.js…');
+describe('outcomeLabel', () => {
+ it('says plainly when a check could not determine anything', () => {
+ expect(outcomeLabel('unknown')).toBe('Could not be checked');
+ expect(outcomeLabel(null)).toBe('Not checked yet');
});
- it('counts only required steps in the progress fraction', () => {
- const summary = summarisePlan(
- plan([
- step({ id: 'git', state: 'satisfied' }),
- step({ id: 'node', state: 'pending' }),
- step({ id: 'gh', state: 'pending', optional: true }),
- ])
- );
- expect(summary).toMatchObject({ done: 1, total: 2 });
+ it('distinguishes a stopped service from a missing one', () => {
+ expect(outcomeLabel('not-running')).toBe('Installed but not running');
+ expect(outcomeLabel('missing')).toBe('Not installed');
});
+});
- it('reports partial progress once something is done', () => {
- const summary = summarisePlan(
- plan([step({ id: 'git', state: 'satisfied' }), step({ id: 'node', state: 'pending' })])
- );
- expect(summary.headline).toBe('1 of 2 steps done');
+describe('canSkip', () => {
+ it('offers a skip only once a step has actually failed', () => {
+ expect(canSkip(step({ state: 'failed' }))).toBe(true);
+ expect(canSkip(step({ state: 'pending' }))).toBe(false);
+ expect(canSkip(step({ state: 'satisfied' }))).toBe(false);
});
});
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.ts
index aed7aa9c6..8ec4d0d41 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
@@ -8,53 +8,13 @@
* identical to "we checked and it's fine".
*/
+import type { StatusTone } from '@renderer/lib/ui/status-badge';
import type {
DependencyCheckOutcome,
HostSetupPlan,
HostSetupStep,
} from '@shared/core/remote-hosts/setup';
-/** Visual tone for a step row. `done` is green and is deliberately hard to earn. */
-export type StepTone = 'done' | 'busy' | 'failed' | 'skipped' | 'waiting' | 'idle';
-
-export function stepTone(step: HostSetupStep): StepTone {
- switch (step.state) {
- case 'satisfied':
- return 'done';
- case 'checking':
- case 'installing':
- return 'busy';
- case 'failed':
- return 'failed';
- case 'skipped':
- return 'skipped';
- case 'blocked':
- return 'waiting';
- case 'pending':
- return 'idle';
- }
-}
-
-/** Short status label for a step row. */
-export function stepStatusLabel(step: HostSetupStep): string {
- switch (step.state) {
- case 'pending':
- return 'Not checked yet';
- case 'checking':
- return 'Checking…';
- case 'installing':
- return 'Installing…';
- case 'satisfied':
- return step.version ? `Ready · ${step.version}` : 'Ready';
- case 'failed':
- return outcomeLabel(step.outcome);
- case 'skipped':
- return 'Skipped';
- case 'blocked':
- return 'Waiting on an earlier step';
- }
-}
-
/**
* What a check observed, in words. `unknown` says so plainly rather than
* borrowing the language of a definite answer.
@@ -76,75 +36,103 @@ export function outcomeLabel(outcome: DependencyCheckOutcome | null): string {
}
}
-/**
- * Whether a step may show a "done" affordance. Only a fresh `satisfied`
- * observation qualifies — a skipped step is explicitly not done, and neither is
- * one we failed to verify.
- */
-export function showsAsComplete(step: HostSetupStep): boolean {
- return step.state === 'satisfied';
-}
-
/** Steps whose failure the user can act on directly, rather than only retrying. */
export function canSkip(step: HostSetupStep): boolean {
return step.state === 'failed';
}
-export type PlanSummary = {
- /** Steps satisfied out of the required total. */
- done: number;
- total: number;
- /** True only when every required step is satisfied. */
- ready: boolean;
- /** One-line description of where the host stands. */
- headline: string;
- tone: 'ready' | 'blocked' | 'in-progress' | 'unstarted';
-};
+export type BadgeSpec = { tone: StatusTone; label: string };
/**
- * Summarise a plan for the host list. Deliberately conservative: a host is only
- * described as ready when every required step is satisfied, and skipped or
- * unverifiable steps hold it back rather than rounding up.
+ * The pill shown on a step row.
+ *
+ * `satisfied` is the only state that earns green, and `pending` says "not
+ * checked" rather than borrowing the language of a negative result — we have
+ * not looked, which is not the same as having looked and found nothing.
*/
-export function summarisePlan(plan: HostSetupPlan | null): PlanSummary {
- if (!plan || plan.steps.length === 0) {
- return { done: 0, total: 0, ready: false, headline: 'Setup not started', tone: 'unstarted' };
+export function stepBadge(step: HostSetupStep): BadgeSpec {
+ switch (step.state) {
+ case 'satisfied':
+ return { tone: 'success', label: 'Installed' };
+ case 'checking':
+ return { tone: 'info', label: 'Checking…' };
+ case 'installing':
+ return { tone: 'info', label: 'Installing…' };
+ case 'failed':
+ return { tone: 'danger', label: outcomeLabel(step.outcome) };
+ case 'skipped':
+ return { tone: 'neutral', label: 'Skipped' };
+ case 'blocked':
+ return { tone: 'neutral', label: 'Waiting' };
+ case 'pending':
+ // A re-check leaves steps pending but records what it saw. "Not checked"
+ // and "checked, and it isn't there" are different facts and must not
+ // share a label.
+ return step.outcome === null
+ ? { tone: 'neutral', label: 'Not checked' }
+ : { tone: 'warning', label: outcomeLabel(step.outcome) };
}
+}
+
+/**
+ * An agent type as one row: its CLI and its Switch connector are two steps, but
+ * a user thinks of them as one thing being usable or not. Mirrors how the
+ * agents settings page presents a local agent.
+ */
+export type AgentTypeRow = {
+ agentId: string;
+ name: string;
+ cli: HostSetupStep;
+ /** Null only if the plan predates connector steps. */
+ plugin: HostSetupStep | null;
+};
- const required = plan.steps.filter((step) => !step.optional);
- const done = required.filter((step) => step.state === 'satisfied').length;
- const total = required.length;
- const ready = done === total;
+/**
+ * Combined status for an agent type.
+ *
+ * An installed CLI is not usable on its own — without the Switch connector the
+ * agent starts and has no Switch tools. That intermediate state gets its own
+ * label rather than being rounded up to "installed".
+ */
+export function agentTypeBadge(row: AgentTypeRow): BadgeSpec {
+ const inFlight = [row.cli, row.plugin].find(
+ (step) => step?.state === 'checking' || step?.state === 'installing'
+ );
+ if (inFlight) return stepBadge(inFlight);
- if (ready) {
- return { done, total, ready, headline: 'Ready', tone: 'ready' };
- }
+ const failed = [row.cli, row.plugin].find((step) => step?.state === 'failed');
+ if (failed) return { tone: 'danger', label: outcomeLabel(failed.outcome) };
- const failed = plan.steps.find((step) => step.state === 'failed' && !step.optional);
- if (failed) {
- return {
- done,
- total,
- ready,
- headline: `Stopped at ${failed.name}`,
- tone: 'blocked',
- };
+ if (row.cli.state !== 'satisfied') return stepBadge(row.cli);
+ if (row.plugin && row.plugin.state !== 'satisfied') {
+ return { tone: 'warning', label: 'Switch setup required' };
}
+ return { tone: 'success', label: 'Installed' };
+}
- if (plan.status === 'running') {
- const current = plan.steps.find((step) => step.id === plan.currentStepId);
- return {
- done,
- total,
- ready,
- headline: current ? `Setting up ${current.name}…` : 'Setting up…',
- tone: 'in-progress',
- };
- }
+export type GroupedPlan = {
+ /** Host tools and the GitHub login — everything an agent needs before itself. */
+ prerequisites: HostSetupStep[];
+ agentTypes: AgentTypeRow[];
+};
- if (done === 0) {
- return { done, total, ready, headline: 'Setup not started', tone: 'unstarted' };
- }
+/** Split a plan into the two things a host page is actually about. */
+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'
+ );
+
+ const agentTypes = plan.steps
+ .filter((step) => step.kind === 'agent-cli')
+ .map((cli) => ({
+ agentId: cli.id,
+ name: cli.name,
+ cli,
+ plugin:
+ plan.steps.find((s) => s.kind === 'agent-plugin' && s.id === `${cli.id}:plugin`) ?? null,
+ }));
- return { done, total, ready, headline: `${done} of ${total} steps done`, tone: 'in-progress' };
+ return { prerequisites, agentTypes };
}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
index 4f5d78a3b..a5f7e6a78 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
@@ -77,6 +77,19 @@ export function usePrepareSetup(sshHost: string) {
});
}
+/**
+ * Probe every step without installing anything. `prepareSetup` only rebuilds
+ * the list of steps — this is the one that actually looks at the host.
+ */
+export function useRecheckSetup(sshHost: string) {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: () => rpc.remoteHosts.recheckSetup(sshHost),
+ onSuccess: (plan) => queryClient.setQueryData(setupPlanQueryKey(sshHost), plan),
+ onError: (error) => log.error('Could not re-check remote host', { sshHost, error }),
+ });
+}
+
/**
* Run or resume setup. The run halts at the first required failure; the
* rejection carries the reason (an unreachable host, most often), which the
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 ba67f419b..4158e01af 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
@@ -6,31 +6,40 @@
* agent types running on it. It gets its own route so that lifecycle has
* somewhere to live and somewhere to grow.
*
- * The page does no probing of its own. Reachability comes from the central
- * model (CHOO-1682/1780) and the setup plan is pushed from the main process, so
- * opening this page costs nothing and cannot disagree with the rest of the app.
+ * Presented as a catalogue of what is on the host rather than a checklist of
+ * steps: prerequisites and agent types, each a row with its status, each
+ * opening a sheet with the detail and the actions. The same language the
+ * agents settings page uses, so a host reads like the rest of the product.
+ *
+ * The page does no probing of its own on open. Reachability comes from the
+ * central model (CHOO-1682/1780) and the setup plan is pushed from the main
+ * process, so opening this page costs nothing and cannot disagree with the
+ * rest of the app.
*/
import { useQuery } from '@tanstack/react-query';
-import { ArrowLeft, Play, RefreshCw, RotateCcw } from 'lucide-react';
+import { ArrowLeft, Play, RefreshCw, RotateCcw, Server } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
import { PageHeader } from '@renderer/lib/components/page-header';
import { rpc } from '@renderer/lib/ipc';
import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
import { Button } from '@renderer/lib/ui/button';
import { Spinner } from '@renderer/lib/ui/spinner';
+import { StatusBadge } from '@renderer/lib/ui/status-badge';
+import { deriveHostStatus } from '@shared/core/remote-hosts/host-status';
import { isHostBlocked } from '@shared/core/remote-hosts/reachability';
-import { isPlanComplete } from '@shared/core/remote-hosts/setup';
import { GhAuthPanel } from '../gh-auth-panel';
import { hostReachabilityStore } from '../host-reachability-store';
import { HostUnreachablePanel } from '../host-unreachable-panel';
-import { SetupStepList } from '../setup/setup-steps';
-import { summarisePlan } from '../setup/step-presentation';
+import { SetupDetailSheet, type SheetTarget } from '../setup/setup-detail-sheet';
+import { AgentTypeRowItem, PrerequisiteRow, SectionLabel } from '../setup/setup-rows';
+import { groupPlanSteps } from '../setup/step-presentation';
import {
useHostSetupPlan,
usePrepareSetup,
+ useRecheckSetup,
useRunSetup,
useSkipSetupStep,
} from '../setup/use-host-setup';
@@ -52,10 +61,12 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
const plan = useHostSetupPlan(sshHost);
const prepare = usePrepareSetup(sshHost);
+ const recheck = useRecheckSetup(sshHost);
const run = useRunSetup(sshHost);
const skip = useSkipSetupStep(sshHost);
const [authenticatingGh, setAuthenticatingGh] = useState(false);
+ const [sheetTarget, setSheetTarget] = useState<SheetTarget | null>(null);
const reachability = hostReachabilityStore.get(sshHost);
const blocked = isHostBlocked(reachability);
@@ -73,12 +84,29 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
startPrepare();
}, [blocked, plan.isLoading, hasPlan, startPrepare]);
- const summary = summarisePlan(plan.data ?? null);
- const busy = run.isPending || prepare.isPending;
- const complete = plan.data ? isPlanComplete(plan.data) : false;
+ const status = deriveHostStatus(reachability, plan.data ?? null);
+ const { prerequisites, agentTypes } = useMemo(
+ () => groupPlanSteps(plan.data ?? null),
+ [plan.data]
+ );
+ const busy = run.isPending || prepare.isPending || recheck.isPending;
+ const currentStepId = plan.data?.currentStepId ?? null;
+
+ // Keep an open sheet in step with pushed plan updates, so a row's detail
+ // advances while a run is in flight instead of freezing at the state it had
+ // when it was opened.
+ const liveTarget = useMemo((): SheetTarget | null => {
+ if (!sheetTarget) return null;
+ if (sheetTarget.kind === 'prerequisite') {
+ const step = prerequisites.find((s) => s.id === sheetTarget.step.id);
+ return step ? { kind: 'prerequisite', step } : null;
+ }
+ const row = agentTypes.find((r) => r.agentId === sheetTarget.row.agentId);
+ return row ? { kind: 'agent-type', row } : null;
+ }, [sheetTarget, prerequisites, agentTypes]);
return (
- <div className="space-y-8 px-8 pb-10">
+ <div className="space-y-6 px-8 pb-10">
<PageHeader
sticky
title={host?.name ?? sshHost}
@@ -88,34 +116,19 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
<Button size="sm" variant="ghost" onClick={() => navigate('remoteHosts')}>
<ArrowLeft className="size-4" /> All hosts
</Button>
- </div>
- </PageHeader>
-
- {blocked ? (
- <HostUnreachablePanel reachability={reachability} />
- ) : (
- <section className="flex flex-col gap-4">
- <div className="flex items-start justify-between gap-3">
- <div className="flex flex-col gap-1">
- <h3 className="text-sm font-medium">Setup</h3>
- <p className="text-xs text-foreground-muted">
- {summary.total > 0
- ? `${summary.done} of ${summary.total} required steps done · ${summary.headline}`
- : summary.headline}
- </p>
- </div>
- <div className="flex items-center gap-2">
+ {!blocked && (
+ <>
<Button
size="sm"
variant="outline"
disabled={busy}
- onClick={() => prepare.mutate()}
+ onClick={() => recheck.mutate()}
aria-label="Re-check this host"
>
- <RefreshCw className={`size-3.5 ${prepare.isPending ? 'animate-spin' : ''}`} />
+ <RefreshCw className={`size-3.5 ${recheck.isPending ? 'animate-spin' : ''}`} />
Re-check
</Button>
- {!complete && (
+ {status.kind !== 'ready' && (
<Button size="sm" disabled={busy} onClick={() => run.mutate()}>
{plan.data?.status === 'halted' ? (
<>
@@ -128,8 +141,31 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
)}
</Button>
)}
+ </>
+ )}
+ </div>
+ </PageHeader>
+
+ {blocked ? (
+ <HostUnreachablePanel reachability={reachability} />
+ ) : (
+ <>
+ <section 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">
+ <Server className="size-6 text-foreground-muted" />
</div>
- </div>
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="truncate text-lg text-foreground">{host?.name ?? sshHost}</span>
+ <StatusBadge tone={status.tone}>{status.label}</StatusBadge>
+ </div>
+ <span className="text-xs text-foreground-muted">
+ {status.readinessKnown && status.total > 0
+ ? `${status.done} of ${status.total} required · ${sshHost}`
+ : sshHost}
+ </span>
+ </div>
+ </section>
{/*
A run that stops because the host went away is reported as exactly
@@ -138,6 +174,11 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
{run.isError && (
<p className="text-destructive text-xs">{(run.error as Error).message}</p>
)}
+ {recheck.isError && (
+ <p className="text-destructive text-xs">
+ Could not check this host: {(recheck.error as Error).message}
+ </p>
+ )}
{prepare.isError && (
<p className="text-destructive text-xs">
Could not work out what this host needs: {(prepare.error as Error).message}
@@ -146,16 +187,44 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
{plan.isLoading ? (
<div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner /> Loading setup…
+ <Spinner /> Loading…
</div>
+ ) : prerequisites.length === 0 && agentTypes.length === 0 ? (
+ <p className="text-sm text-foreground-muted">
+ Nothing known about this host yet. Re-check to see what it has.
+ </p>
) : (
- <SetupStepList
- steps={plan.data?.steps ?? []}
- currentStepId={plan.data?.currentStepId ?? null}
- onSkip={(stepId) => skip.mutate(stepId)}
- skippingStepId={skip.isPending ? (skip.variables ?? null) : null}
- onAuthenticate={() => setAuthenticatingGh(true)}
- />
+ <div className="flex flex-col">
+ {prerequisites.length > 0 && (
+ <section>
+ <SectionLabel count={prerequisites.length}>Prerequisites</SectionLabel>
+ {prerequisites.map((step) => (
+ <div key={step.id} className="w-full py-0.5">
+ <PrerequisiteRow
+ step={step}
+ isCurrent={step.id === currentStepId}
+ onOpen={() => setSheetTarget({ kind: 'prerequisite', step })}
+ />
+ </div>
+ ))}
+ </section>
+ )}
+
+ {agentTypes.length > 0 && (
+ <section className="pt-2">
+ <SectionLabel count={agentTypes.length}>Agent types</SectionLabel>
+ {agentTypes.map((row) => (
+ <div key={row.agentId} className="w-full py-0.5">
+ <AgentTypeRowItem
+ row={row}
+ isCurrent={row.cli.id === currentStepId || row.plugin?.id === currentStepId}
+ onOpen={() => setSheetTarget({ kind: 'agent-type', row })}
+ />
+ </div>
+ ))}
+ </section>
+ )}
+ </div>
)}
{/*
@@ -169,13 +238,22 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
sshHost={sshHost}
onDone={() => {
setAuthenticatingGh(false);
- prepare.mutate();
+ recheck.mutate();
}}
/>
)}
- {complete && <p className="text-xs text-green-500">This host is ready to run agents.</p>}
- </section>
+ <SetupDetailSheet
+ target={liveTarget}
+ onClose={() => setSheetTarget(null)}
+ onSkip={(stepId) => skip.mutate(stepId)}
+ skippingStepId={skip.isPending ? (skip.variables ?? null) : null}
+ onAuthenticate={() => {
+ setSheetTarget(null);
+ setAuthenticatingGh(true);
+ }}
+ />
+ </>
)}
</div>
);
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 f9247ae60..41dc76566 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
@@ -1,15 +1,18 @@
/**
* The remote-hosts list (CHOO-1809).
*
- * Rendering this page costs nothing. Each row shows reachability read from the
- * central model and a setup summary read from the host's persisted plan — no
- * SSH round trips, no probing on mount. The previous version fired a full
- * dependency sweep per row the instant the page opened, which is what made it
- * slow and unreliable with more than one host onboarded.
+ * Rendering this page costs nothing. Each row shows a status derived from the
+ * central reachability model and the host's persisted plan — no SSH round
+ * trips, no probing on mount. The previous version fired a full dependency
+ * sweep per row the instant the page opened, which is what made it slow and
+ * unreliable with more than one host onboarded.
+ *
+ * Rows use the same language as the agents settings page — icon tile, name,
+ * status pill — so hosts and agents read as one product.
*/
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import { CheckCircle2, ChevronRight, Circle, Loader2, Plus, Server, Trash2 } from 'lucide-react';
+import { ChevronRight, Plus, Server, Trash2 } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useMemo, useState } from 'react';
import type { ViewDefinition } from '@renderer/app/view-registry';
@@ -27,64 +30,80 @@ import {
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';
import { log } from '@renderer/utils/logger';
-import { cn } from '@renderer/utils/utils';
-import { isHostBlocked } from '@shared/core/remote-hosts/reachability';
+import { deriveHostStatus, type HostStatus } from '@shared/core/remote-hosts/host-status';
import type { HostSetupPlan } from '@shared/core/remote-hosts/setup';
import { hostReachabilityStore } from '../host-reachability-store';
-import { summarisePlan } from '../setup/step-presentation';
import { useAllHostSetupPlans } from '../setup/use-host-setup';
export const REMOTE_HOSTS_QUERY_KEY = ['remote-hosts'];
-const SUMMARY_TONE = {
- ready: 'text-green-500',
- blocked: 'text-destructive',
- 'in-progress': 'text-amber-500',
- unstarted: 'text-foreground-muted',
-} as const;
+type HostFilter = 'all' | 'ready' | 'attention';
+
+type RemoteHost = { sshHost: string; name: string };
+
+function SectionLabel({ children, count }: { children: React.ReactNode; count: number }) {
+ return (
+ <div className="px-3 py-2">
+ <Label>
+ {children}
+ {` (${count})`}
+ </Label>
+ </div>
+ );
+}
/**
- * A host row's status. Reachability wins over setup state: a host we cannot
- * reach is reported as unreachable, never as "dependency missing" — that
- * conflation is exactly what CHOO-1682/1780 set out to end.
+ * One host row.
+ *
+ * Reachability wins over setup state: a host we cannot reach is reported as
+ * unreachable, never as "dependency missing" — that conflation is exactly what
+ * CHOO-1682/1780 set out to end. The derivation lives in `deriveHostStatus`, so
+ * this row and the host's own page cannot disagree.
*/
-const HostStatus = observer(function HostStatus({
- sshHost,
+const HostRow = observer(function HostRow({
+ host,
plan,
+ onOpen,
+ onRemoved,
}: {
- sshHost: string;
+ host: RemoteHost;
plan: HostSetupPlan | null;
+ onOpen: () => void;
+ onRemoved: () => void;
}) {
- const reachability = hostReachabilityStore.get(sshHost);
+ const status = deriveHostStatus(hostReachabilityStore.get(host.sshHost), plan);
- if (isHostBlocked(reachability)) {
- return (
- <span className="text-destructive flex items-center gap-1 text-xs">
- <Circle className="size-3.5" />
- {reachability.status === 'suspended' ? 'SSH auth failed' : 'Unreachable'}
- </span>
- );
- }
-
- const summary = summarisePlan(plan);
return (
- <span className={cn('flex items-center gap-1 text-xs', SUMMARY_TONE[summary.tone])}>
- {summary.tone === 'ready' ? (
- <CheckCircle2 className="size-3.5" />
- ) : summary.tone === 'in-progress' ? (
- <Loader2 className={cn('size-3.5', plan?.status === 'running' && 'animate-spin')} />
- ) : (
- <Circle className="size-3.5" />
- )}
- {summary.headline}
- </span>
+ <div className="group flex w-full items-center gap-3 rounded-lg p-3 hover:bg-background-1">
+ <button
+ type="button"
+ onClick={onOpen}
+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-3 text-left"
+ >
+ <div className="flex size-6 shrink-0 items-center justify-center rounded-lg bg-background-1 p-1.5 group-hover:bg-background-2">
+ <Server className="size-4 text-foreground-muted" />
+ </div>
+ <span className="flex min-w-0 flex-col">
+ <span className="truncate text-sm text-foreground">{host.name}</span>
+ <span className="truncate text-xs text-foreground-muted">{host.sshHost}</span>
+ </span>
+ </button>
+ <div className="flex shrink-0 items-center gap-2">
+ <StatusBadge tone={status.tone}>{status.label}</StatusBadge>
+ <RemoveHostButton sshHost={host.sshHost} name={host.name} onRemoved={onRemoved} />
+ <ChevronRight className="size-4 text-foreground-muted" />
+ </div>
+ </div>
);
});
export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
const queryClient = useQueryClient();
const { navigate } = useNavigate();
+ const [filter, setFilter] = useState<HostFilter>('all');
const { data: hosts, isLoading } = useQuery({
queryKey: REMOTE_HOSTS_QUERY_KEY,
@@ -99,20 +118,73 @@ export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
void hostReachabilityStore.hydrate();
}, []);
+ const statuses = useMemo(() => {
+ const byHost = new Map<string, HostStatus>();
+ for (const host of list) {
+ byHost.set(
+ host.sshHost,
+ deriveHostStatus(
+ hostReachabilityStore.get(host.sshHost),
+ plans.data?.[host.sshHost] ?? null
+ )
+ );
+ }
+ return byHost;
+ }, [list, plans.data]);
+
+ const ready = useMemo(
+ () => list.filter((host) => statuses.get(host.sshHost)?.kind === 'ready'),
+ [list, statuses]
+ );
+ const attention = useMemo(
+ () => list.filter((host) => statuses.get(host.sshHost)?.kind !== 'ready'),
+ [list, statuses]
+ );
+
+ const openHost = (sshHost: string) => navigate('remoteHost', { sshHost });
+ const invalidate = () => {
+ void queryClient.invalidateQueries({ queryKey: REMOTE_HOSTS_QUERY_KEY });
+ };
+
+ const renderRows = (rows: RemoteHost[]) =>
+ rows.map((host) => (
+ <div key={host.sshHost} className="w-full py-0.5">
+ <HostRow
+ host={host}
+ plan={plans.data?.[host.sshHost] ?? null}
+ onOpen={() => openHost(host.sshHost)}
+ onRemoved={invalidate}
+ />
+ </div>
+ ));
+
return (
- <div className="space-y-8 px-8 pb-10">
+ <div className="space-y-4 px-8 pb-10">
<PageHeader
sticky
title="Remote hosts"
description="SSH hosts that can run agents. Each host has its own page for setup and for the agent types installed on it."
>
- <OnboardHostForm
- onboarded={sshHosts}
- onOnboarded={(sshHost) => {
- void queryClient.invalidateQueries({ queryKey: REMOTE_HOSTS_QUERY_KEY });
- navigate('remoteHost', { sshHost });
- }}
- />
+ <div className="flex items-center justify-between gap-2">
+ <ToggleGroup
+ multiple={false}
+ value={[filter]}
+ onValueChange={([value]) => {
+ if (value) setFilter(value as HostFilter);
+ }}
+ >
+ <ToggleGroupItem value="all">All</ToggleGroupItem>
+ <ToggleGroupItem value="ready">Ready</ToggleGroupItem>
+ <ToggleGroupItem value="attention">Needs setup</ToggleGroupItem>
+ </ToggleGroup>
+ <OnboardHostForm
+ onboarded={sshHosts}
+ onOnboarded={(sshHost) => {
+ invalidate();
+ openHost(sshHost);
+ }}
+ />
+ </div>
</PageHeader>
{isLoading ? (
@@ -123,35 +195,38 @@ export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
<p className="text-sm text-foreground-muted">
No remote hosts yet. Add one above to get started.
</p>
+ ) : filter === 'ready' ? (
+ ready.length > 0 ? (
+ <div>
+ <SectionLabel count={ready.length}>Ready</SectionLabel>
+ {renderRows(ready)}
+ </div>
+ ) : (
+ <p className="text-sm text-foreground-muted">No host is ready yet.</p>
+ )
+ ) : filter === 'attention' ? (
+ attention.length > 0 ? (
+ <div>
+ <SectionLabel count={attention.length}>Needs setup</SectionLabel>
+ {renderRows(attention)}
+ </div>
+ ) : (
+ <p className="text-sm text-foreground-muted">Every host is ready.</p>
+ )
) : (
- <div className="flex flex-col gap-2">
- {list.map((host) => (
- <div
- key={host.sshHost}
- className="flex items-center justify-between gap-3 rounded-lg border border-border p-3"
- >
- <button
- type="button"
- className="flex min-w-0 flex-1 items-center gap-2 text-left"
- onClick={() => navigate('remoteHost', { sshHost: host.sshHost })}
- >
- <Server className="size-4 shrink-0 text-foreground-muted" />
- <span className="flex min-w-0 flex-col">
- <span className="truncate text-sm">{host.name}</span>
- <span className="truncate text-xs text-foreground-muted">{host.sshHost}</span>
- </span>
- </button>
- <HostStatus sshHost={host.sshHost} plan={plans.data?.[host.sshHost] ?? null} />
- <RemoveHostButton
- sshHost={host.sshHost}
- name={host.name}
- onRemoved={() => {
- void queryClient.invalidateQueries({ queryKey: REMOTE_HOSTS_QUERY_KEY });
- }}
- />
- <ChevronRight className="size-4 shrink-0 text-foreground-muted" />
- </div>
- ))}
+ <div className="flex flex-col">
+ {attention.length > 0 && (
+ <section>
+ <SectionLabel count={attention.length}>Needs setup</SectionLabel>
+ {renderRows(attention)}
+ </section>
+ )}
+ {ready.length > 0 && (
+ <section className="pt-2">
+ <SectionLabel count={ready.length}>Ready</SectionLabel>
+ {renderRows(ready)}
+ </section>
+ )}
</div>
)}
</div>
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
index db6609ad0..0924bffda 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
@@ -1,64 +1,42 @@
+import { StatusBadge } from '@renderer/lib/ui/status-badge';
+
export function InstalledBadge() {
- return (
- <span className="rounded-md bg-background-success px-1.5 py-0.5 text-xs text-foreground-success">
- Installed
- </span>
- );
+ return <StatusBadge tone="success">Installed</StatusBadge>;
}
export function UninstalledBadge() {
- return (
- <span className="rounded-md bg-background-2 px-1.5 py-0.5 text-xs text-foreground-passive">
- Not installed
- </span>
- );
+ return <StatusBadge tone="neutral">Not installed</StatusBadge>;
}
/** Agent CLI is on the machine, but the Switch connector still needs setup. */
export function SwitchSetupRequiredBadge() {
- return (
- <span className="rounded-md bg-background-warning px-1.5 py-0.5 text-xs text-foreground-warning">
- Switch setup required
- </span>
- );
+ return <StatusBadge tone="warning">Switch setup required</StatusBadge>;
}
export function UpdateAvailableBadge() {
- return (
- <span className="rounded-md bg-background-warning px-1.5 py-0.5 text-xs text-foreground-warning">
- Update available
- </span>
- );
+ return <StatusBadge tone="warning">Update available</StatusBadge>;
}
export function RecommendedBadge() {
return (
- <span className="rounded-md bg-background-2 px-1.5 py-0.5 text-[10px] text-foreground-passive">
+ <StatusBadge tone="neutral" className="text-[10px]">
Recommended
- </span>
+ </StatusBadge>
);
}
export function UsedBadge() {
return (
- <span className="rounded-md bg-background-info px-1.5 py-0.5 text-[10px] text-foreground-info">
+ <StatusBadge tone="info" className="text-[10px]">
Used
- </span>
+ </StatusBadge>
);
}
export function InstallingBadge() {
- return (
- <span className="rounded-md bg-background-info px-1.5 py-0.5 text-xs text-foreground-info">
- Installing…
- </span>
- );
+ return <StatusBadge tone="info">Installing…</StatusBadge>;
}
export function UpdatingBadge() {
- return (
- <span className="rounded-md bg-background-info px-1.5 py-0.5 text-xs text-foreground-info">
- Updating…
- </span>
- );
+ return <StatusBadge tone="info">Updating…</StatusBadge>;
}
diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/ui/status-badge.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/ui/status-badge.tsx
new file mode 100644
index 000000000..95aed8ae2
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/lib/ui/status-badge.tsx
@@ -0,0 +1,35 @@
+import { cn } from '@renderer/utils/utils';
+
+/**
+ * The small status pill used to say what state a thing is in.
+ *
+ * One component rather than a set of hand-rolled spans so the agents page, the
+ * remote-hosts list and a host's own page read as the same product. Tone is
+ * semantic, not a colour: callers say what they mean and the palette stays in
+ * one place.
+ */
+export type StatusTone = 'success' | 'warning' | 'info' | 'danger' | 'neutral';
+
+const TONE_CLASS: Record<StatusTone, string> = {
+ success: 'bg-background-success text-foreground-success',
+ warning: 'bg-background-warning text-foreground-warning',
+ info: 'bg-background-info text-foreground-info',
+ danger: 'bg-background-error text-foreground-error',
+ neutral: 'bg-background-2 text-foreground-passive',
+};
+
+export function StatusBadge({
+ tone,
+ children,
+ className,
+}: {
+ tone: StatusTone;
+ children: React.ReactNode;
+ className?: string;
+}) {
+ return (
+ <span className={cn('rounded-md px-1.5 py-0.5 text-xs', TONE_CLASS[tone], className)}>
+ {children}
+ </span>
+ );
+}
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.ts
new file mode 100644
index 000000000..5d0cfe408
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts
@@ -0,0 +1,163 @@
+import { describe, expect, it } from 'vitest';
+import { deriveHostStatus, isHostUsable } from './host-status';
+import type { HostReachability, HostReachabilityStatus } from './reachability';
+import type { HostSetupPlan, HostSetupStep, HostSetupStepState } from './setup';
+
+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, optional = false): HostSetupStep {
+ return {
+ id,
+ kind: 'core-dependency',
+ name: id,
+ state,
+ outcome: state === 'satisfied' ? 'satisfied' : null,
+ version: null,
+ error: null,
+ output: null,
+ optional,
+ dependsOn: [],
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ };
+}
+
+function plan(steps: HostSetupStep[], patch: Partial<HostSetupPlan> = {}): HostSetupPlan {
+ return {
+ sshHost: 'dev-vm',
+ status: 'idle',
+ steps,
+ currentStepId: null,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ ...patch,
+ };
+}
+
+describe('deriveHostStatus', () => {
+ it('reports a fully satisfied reachable host as ready', () => {
+ const status = deriveHostStatus(
+ reachability('reachable'),
+ plan([step('git', 'satisfied'), step('node', 'satisfied')])
+ );
+
+ expect(status.kind).toBe('ready');
+ expect(status.done).toBe(2);
+ expect(isHostUsable(status)).toBe(true);
+ });
+
+ it('does not count optional steps against readiness', () => {
+ const status = deriveHostStatus(
+ reachability('reachable'),
+ plan([step('git', 'satisfied'), step('gh', 'pending', true)])
+ );
+
+ expect(status.kind).toBe('ready');
+ expect(status.total).toBe(1);
+ });
+
+ describe('readiness is withheld when the host cannot be reached', () => {
+ // The whole point of CHOO-1780: a network problem must not be reported as
+ // a missing dependency, however good or bad the last setup run looked.
+ it('reports unreachable, not setup-required, even with a failed plan', () => {
+ const status = deriveHostStatus(
+ reachability('unreachable'),
+ plan([step('git', 'failed'), step('node', 'pending')])
+ );
+
+ expect(status.kind).toBe('unreachable');
+ expect(status.readinessKnown).toBe(false);
+ expect(isHostUsable(status)).toBe(false);
+ });
+
+ it('reports unreachable, not ready, even with a fully satisfied plan', () => {
+ const status = deriveHostStatus(
+ reachability('unreachable'),
+ plan([step('git', 'satisfied')])
+ );
+
+ expect(status.kind).toBe('unreachable');
+ expect(status.readinessKnown).toBe(false);
+ expect(isHostUsable(status)).toBe(false);
+ });
+
+ it('distinguishes an auth failure, which never self-heals', () => {
+ const status = deriveHostStatus(reachability('suspended'), null);
+
+ expect(status.kind).toBe('auth-failed');
+ expect(status.label).toBe('SSH auth failed');
+ });
+ });
+
+ describe('not knowing is its own answer', () => {
+ it('reports a host with no plan as unchecked, not as not-ready', () => {
+ const status = deriveHostStatus(reachability('reachable'), null);
+
+ expect(status.kind).toBe('unchecked');
+ expect(status.readinessKnown).toBe(false);
+ });
+
+ it('reports a built-but-never-observed plan as unchecked', () => {
+ // Building the plan lists what to check; it observes nothing. Calling
+ // that "setup required" claims knowledge we do not have.
+ const status = deriveHostStatus(
+ reachability('reachable'),
+ plan([step('git', 'pending'), step('node', 'pending')])
+ );
+
+ expect(status.kind).toBe('unchecked');
+ expect(status.readinessKnown).toBe(false);
+ });
+
+ it('reports setup-required once something has actually been observed', () => {
+ const status = deriveHostStatus(
+ reachability('reachable'),
+ plan([step('git', 'satisfied'), step('node', 'pending')])
+ );
+
+ expect(status.kind).toBe('setup-required');
+ expect(status.readinessKnown).toBe(true);
+ expect(status.done).toBe(1);
+ expect(status.total).toBe(2);
+ });
+
+ it('treats an unknown-reachability host as checkable rather than blocked', () => {
+ // `unknown` is deliberately not blocking elsewhere in the app; readiness
+ // should follow the same convention.
+ const status = deriveHostStatus(reachability('unknown'), plan([step('git', 'satisfied')]));
+
+ expect(status.kind).toBe('ready');
+ });
+ });
+
+ it('names the step in flight while a run is going', () => {
+ const status = deriveHostStatus(
+ reachability('reachable'),
+ plan([step('git', 'satisfied'), step('node', 'installing')], {
+ status: 'running',
+ currentStepId: 'node',
+ })
+ );
+
+ expect(status.kind).toBe('setting-up');
+ expect(status.label).toBe('Setting up node…');
+ });
+
+ it('reports a skipped required step as still not ready', () => {
+ // Skipping is the user moving past a problem, not the problem going away.
+ const status = deriveHostStatus(reachability('reachable'), plan([step('git', 'skipped')]));
+
+ expect(status.kind).toBe('setup-required');
+ expect(isHostUsable(status)).toBe(false);
+ });
+});
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.ts
new file mode 100644
index 000000000..1abd27f62
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts
@@ -0,0 +1,138 @@
+/**
+ * A remote host's status, as one value (CHOO-1809).
+ *
+ * There is no "host" object in the app: an agent points at a location, a
+ * location carries an SSH alias, and three separate stores are keyed by that
+ * alias — the host row, its reachability, and its setup plan. Nothing could
+ * answer "how is this host doing?" in one place, so every screen answered it
+ * again and slightly differently.
+ *
+ * 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).
+ */
+
+import { isHostBlocked, type HostReachability } from './reachability';
+import { outstandingRequiredSteps, type HostSetupPlan } from './setup';
+
+export type HostStatusKind =
+ /** SSH authentication failed — will not self-heal, the user must fix it. */
+ | 'auth-failed'
+ /** We cannot reach the host, so we cannot say anything about readiness. */
+ | 'unreachable'
+ /** Reachable, but nothing has ever been observed about it. */
+ | 'unchecked'
+ /** A setup run is in flight. */
+ | 'setting-up'
+ /** Reachable and every required step was observed satisfied. */
+ | 'ready'
+ /** Reachable, and something required is missing or failed. */
+ | 'setup-required';
+
+/** Same vocabulary as the renderer's StatusBadge tones, without importing it. */
+export type HostStatusTone = 'success' | 'warning' | 'info' | 'danger' | 'neutral';
+
+export type HostStatus = {
+ kind: HostStatusKind;
+ /** Short label for a badge. */
+ label: string;
+ tone: HostStatusTone;
+ /**
+ * Whether readiness is actually known. False when the host is unreachable —
+ * the setup state we hold may be stale and must not be presented as current.
+ */
+ readinessKnown: boolean;
+ /** Required steps satisfied / total, when readiness is known. */
+ done: number;
+ total: number;
+};
+
+/**
+ * Whether a host is usable for running agents *right now*.
+ *
+ * Deliberately not "is the plan complete": an unreachable host is not usable
+ * however good its last setup run looked.
+ */
+export function isHostUsable(status: HostStatus): boolean {
+ return status.kind === 'ready';
+}
+
+export function deriveHostStatus(
+ reachability: HostReachability,
+ plan: HostSetupPlan | null
+): HostStatus {
+ if (isHostBlocked(reachability)) {
+ const authFailed = reachability.status === 'suspended';
+ return {
+ kind: authFailed ? 'auth-failed' : 'unreachable',
+ label: authFailed ? 'SSH auth failed' : 'Unreachable',
+ tone: 'danger',
+ readinessKnown: false,
+ done: 0,
+ total: 0,
+ };
+ }
+
+ if (!plan || plan.steps.length === 0) {
+ return {
+ kind: 'unchecked',
+ label: 'Not checked',
+ tone: 'neutral',
+ readinessKnown: false,
+ done: 0,
+ total: 0,
+ };
+ }
+
+ const required = plan.steps.filter((step) => !step.optional);
+ const total = required.length;
+ const done = required.filter((step) => step.state === 'satisfied').length;
+
+ if (plan.status === 'running') {
+ const current = plan.steps.find((step) => step.id === plan.currentStepId);
+ return {
+ kind: 'setting-up',
+ label: current ? `Setting up ${current.name}…` : 'Setting up…',
+ tone: 'info',
+ readinessKnown: true,
+ done,
+ total,
+ };
+ }
+
+ if (outstandingRequiredSteps(plan).length === 0) {
+ return { kind: 'ready', label: 'Ready', tone: 'success', readinessKnown: true, done, total };
+ }
+
+ // Nothing observed yet is materially different from "we looked and it's
+ // missing" — saying "setup required" of a host nobody has checked overstates
+ // what we know.
+ //
+ // "Untouched" means both: no observation recorded (a re-check leaves steps
+ // 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');
+ if (untouched) {
+ return {
+ kind: 'unchecked',
+ label: 'Not checked',
+ tone: 'neutral',
+ readinessKnown: false,
+ done,
+ total,
+ };
+ }
+
+ return {
+ kind: 'setup-required',
+ label: 'Setup required',
+ tone: 'warning',
+ readinessKnown: true,
+ done,
+ total,
+ };
+}