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): rewrite remote-host onboarding as per-host pages with a staged flow (CHOO-1809)

switch-worker-louis-remote4d7c30a55ada
diff --git a/dash/apps/switchdash-desktop/drizzle/meta/0045_snapshot.json b/dash/apps/switchdash-desktop/drizzle/meta/0045_snapshot.json
index 91e0aa525..16866e76d 100644
--- a/dash/apps/switchdash-desktop/drizzle/meta/0045_snapshot.json
+++ b/dash/apps/switchdash-desktop/drizzle/meta/0045_snapshot.json
@@ -91,16 +91,12 @@
"indexes": {
"idx_agents_location_id": {
"name": "idx_agents_location_id",
- "columns": [
- "location_id"
- ],
+ "columns": ["location_id"],
"isUnique": false
},
"idx_agents_server_id": {
"name": "idx_agents_server_id",
- "columns": [
- "server_id"
- ],
+ "columns": ["server_id"],
"isUnique": false
}
},
@@ -109,12 +105,8 @@
"name": "agents_location_id_locations_id_fk",
"tableFrom": "agents",
"tableTo": "locations",
- "columnsFrom": [
- "location_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@@ -122,12 +114,8 @@
"name": "agents_server_id_switch_servers_id_fk",
"tableFrom": "agents",
"tableTo": "switch_servers",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["server_id"],
+ "columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
@@ -157,9 +145,7 @@
"indexes": {
"idx_app_secrets_key": {
"name": "idx_app_secrets_key",
- "columns": [
- "key"
- ],
+ "columns": ["key"],
"isUnique": true
}
},
@@ -197,9 +183,7 @@
"indexes": {
"idx_app_settings_key": {
"name": "idx_app_settings_key",
- "columns": [
- "key"
- ],
+ "columns": ["key"],
"isUnique": true
}
},
@@ -237,9 +221,7 @@
"indexes": {
"idx_kv_key": {
"name": "idx_kv_key",
- "columns": [
- "key"
- ],
+ "columns": ["key"],
"isUnique": true
}
},
@@ -304,12 +286,8 @@
"name": "location_settings_location_id_locations_id_fk",
"tableFrom": "location_settings",
"tableTo": "locations",
- "columnsFrom": [
- "location_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
@@ -370,10 +348,7 @@
"indexes": {
"idx_locations_host_dir": {
"name": "idx_locations_host_dir",
- "columns": [
- "ssh_host",
- "dir"
- ],
+ "columns": ["ssh_host", "dir"],
"isUnique": true
}
},
@@ -432,16 +407,12 @@
"indexes": {
"idx_messages_session_id": {
"name": "idx_messages_session_id",
- "columns": [
- "session_id"
- ],
+ "columns": ["session_id"],
"isUnique": false
},
"idx_messages_timestamp": {
"name": "idx_messages_timestamp",
- "columns": [
- "timestamp"
- ],
+ "columns": ["timestamp"],
"isUnique": false
}
},
@@ -450,12 +421,8 @@
"name": "messages_session_id_sessions_id_fk",
"tableFrom": "messages",
"tableTo": "sessions",
- "columnsFrom": [
- "session_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
@@ -667,12 +634,8 @@
"name": "session_room_connections_session_id_sessions_id_fk",
"tableFrom": "session_room_connections",
"tableTo": "sessions",
- "columnsFrom": [
- "session_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
@@ -806,9 +769,7 @@
"indexes": {
"idx_sessions_agent_id": {
"name": "idx_sessions_agent_id",
- "columns": [
- "agent_id"
- ],
+ "columns": ["agent_id"],
"isUnique": false
}
},
@@ -817,12 +778,8 @@
"name": "sessions_agent_id_agents_id_fk",
"tableFrom": "sessions",
"tableTo": "agents",
- "columnsFrom": [
- "agent_id"
- ],
- "columnsTo": [
- "id"
- ],
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
@@ -904,9 +861,7 @@
"indexes": {
"idx_switch_servers_gateway_url": {
"name": "idx_switch_servers_gateway_url",
- "columns": [
- "gateway_url"
- ],
+ "columns": ["gateway_url"],
"isUnique": true
}
},
@@ -926,4 +881,4 @@
"internal": {
"indexes": {}
}
-}
\ No newline at end of file
+}
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 3ded2787b..5eded504b 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
@@ -6,29 +6,22 @@ import type {
DependencyUninstallResult,
DependencyUpdateResult,
} from '@switchdash/core/deps/runtime';
-import { isTransportFailure } from '@switchdash/core/exec';
import { detectSwitchAgentRemote } from '@main/core/agents/detect-remote';
import {
evictRemoteDependencyManager,
getRemoteDependencyManager,
remoteDependencyDescriptor,
} from '@main/core/dependencies/remote-dependency-manager';
-import { SshExecutionContext } from '@main/core/execution-context/ssh-execution-context';
import { sshConnectionIdForHost } from '@main/core/locations/location-transport';
import { ptySessionRegistry } from '@main/core/pty/pty-session-registry';
import { openSsh2Pty } from '@main/core/pty/ssh2-pty';
-import { ensureSshConnected, forceSshReconnect } from '@main/core/ssh/connect/connect-agent-ssh';
-import { sshConnectionManager } from '@main/core/ssh/lifecycle/production-ssh-connection-manager';
+import { ensureSshConnected } from '@main/core/ssh/connect/connect-agent-ssh';
import { buildRemoteShellCommand } from '@main/core/ssh/lifecycle/remote-shell-profile';
-import {
- getRemoteSwitchSetupService,
- type RemoteSwitchSetupService,
-} from '@main/core/switch-setup/remote-switch-setup';
+import { getRemoteSwitchSetupService } from '@main/core/switch-setup/remote-switch-setup';
import { hostBlockedReason, type HostReachability } from '@shared/core/remote-hosts/reachability';
-import type { ConnectionState, SshHealthState } from '@shared/core/ssh/ssh';
+import type { HostSetupPlan } from '@shared/core/remote-hosts/setup';
import { createRPCController } from '@shared/lib/ipc/rpc';
import type { SwitchAgentConfig } from '@shared/switch-agents';
-import type { HostSetupPlan } from '@shared/core/remote-hosts/setup';
import { probeGhAuthStatus, type GhAuthStatus } from './gh-auth';
import { listSshConfigHosts } from './list-ssh-config-hosts';
import { hostReachabilityService } from './production-host-reachability';
@@ -66,20 +59,6 @@ export type RemoteDependencyView = {
export type TestConnectionResult = { ok: true } | { ok: false; message: string };
-/** Live status of a host's pooled SSH connection, for the connection badge. */
-export type HostConnectionStatus = {
- state: ConnectionState;
- health: SshHealthState;
-};
-
-function hostConnectionStatus(sshHost: string): HostConnectionStatus {
- const connectionId = sshConnectionIdForHost(sshHost);
- return {
- state: sshConnectionManager.getConnectionState(connectionId),
- health: sshConnectionManager.getAllHealthStates()[connectionId] ?? { status: 'ok' },
- };
-}
-
/**
* Ad-hoc reachability check. Routed through the reachability service rather
* than connecting directly, so a manual "Test connection" and the background
@@ -120,74 +99,6 @@ async function probeDeps(sshHost: string): Promise<RemoteDependencyView[]> {
return views;
}
-/**
- * Whether a remote host is set up enough to run Switch agents, and which agent
- * types are actually usable on it. A host is `ready` when its core tooling is in
- * place (git, tmux, node installed and gh authenticated) AND at least one agent
- * type has BOTH its CLI and the Switch connector plugin installed.
- */
-export type HostSetupStatus = {
- sshHost: string;
- reachable: boolean;
- coreReady: boolean;
- /** Agent-type ids with both CLI and Switch plugin installed on this host. */
- availableAgentIds: string[];
- ready: boolean;
- /** Human-readable outstanding items, for surfacing why a host isn't ready. */
- issues: string[];
-};
-
-async function getHostSetup(sshHost: string): Promise<HostSetupStatus> {
- let views: RemoteDependencyView[];
- let plugins: Awaited<ReturnType<RemoteSwitchSetupService['listAgentTypeStatuses']>>;
- try {
- views = await probeDeps(sshHost);
- const service = await getRemoteSwitchSetupService(sshHost);
- plugins = await service.listAgentTypeStatuses();
- } catch (error) {
- return {
- sshHost,
- reachable: false,
- coreReady: false,
- availableAgentIds: [],
- ready: false,
- issues: [error instanceof Error ? error.message : 'Host unreachable'],
- };
- }
-
- const issues: string[] = [];
- for (const dep of views.filter((v) => v.category === 'core')) {
- if (dep.id === 'gh') {
- if (dep.status !== 'available') issues.push('GitHub CLI not installed');
- else if (dep.ghAuth && !dep.ghAuth.authenticated) issues.push('GitHub CLI not authenticated');
- } else if (dep.status !== 'available') {
- issues.push(`${dep.name} not installed`);
- }
- }
- const coreReady = issues.length === 0;
-
- // An agent is usable only with BOTH its CLI and the Switch plugin present.
- const cliInstalled = new Set(
- views.filter((v) => v.category === 'agent' && v.status === 'available').map((v) => v.id)
- );
- const availableAgentIds = plugins
- .filter((p) => p.supported && p.installed && cliInstalled.has(p.agentId))
- .map((p) => p.agentId);
-
- if (availableAgentIds.length === 0) {
- issues.push('No agent type has both its CLI and the Switch plugin installed');
- }
-
- return {
- sshHost,
- reachable: true,
- coreReady,
- availableAgentIds,
- ready: coreReady && availableAgentIds.length > 0,
- issues,
- };
-}
-
/**
* Start an interactive `gh auth login` device-flow session on a remote host over
* SSH. Runs in a PTY registered with the shared PtySessionRegistry so the renderer
@@ -229,10 +140,6 @@ export const remoteHostsController = createRPCController({
testConnection: (sshHost: string): Promise<TestConnectionResult> => testConnection(sshHost),
- /** Live state + health of the host's pooled SSH connection. */
- getConnectionStatus: (sshHost: string): Promise<HostConnectionStatus> =>
- Promise.resolve(hostConnectionStatus(sshHost)),
-
/** Modeled reachability for one host — the state the UI gates its display on. */
getReachability: (sshHost: string): Promise<HostReachability> =>
Promise.resolve(hostReachabilityService.get(sshHost)),
@@ -250,22 +157,6 @@ export const remoteHostsController = createRPCController({
retryHost: (sshHost: string): Promise<HostReachability> =>
hostReachabilityService.checkNow(sshHost),
- /**
- * Force a full transport rebuild for the host's pooled connection — the
- * manual recovery path for a wedged or given-up connection. Returns the
- * post-rebuild status.
- */
- reconnectHost: async (sshHost: string): Promise<HostConnectionStatus> => {
- try {
- await forceSshReconnect(sshConnectionIdForHost(sshHost), sshHost);
- } catch (error) {
- hostReachabilityService.reportFailure(sshHost, error);
- throw error;
- }
- hostReachabilityService.reportSuccess(sshHost);
- return hostConnectionStatus(sshHost);
- },
-
/** Verify reachability, then onboard (or rename) the host. */
onboardHost: async (params: { sshHost: string; name: string }): Promise<RemoteHost> => {
const test = await testConnection(params.sshHost);
@@ -321,9 +212,6 @@ export const remoteHostsController = createRPCController({
probeDeps: (sshHost: string): Promise<RemoteDependencyView[]> => probeDeps(sshHost),
- /** Whether a host is set up to run agents, and which agent types are usable on it. */
- getHostSetup: (sshHost: string): Promise<HostSetupStatus> => getHostSetup(sshHost),
-
/** Begin an interactive `gh auth login` PTY session on the host; returns its pty session id. */
startGhAuth: (params: { sshHost: string }): Promise<{ sessionId: string }> =>
startGhAuth(params.sshHost),
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 7cf676398..c2505f90f 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
@@ -372,7 +372,10 @@ describe('plan helpers', () => {
const { isPlanComplete } = await import('@shared/core/remote-hosts/setup');
expect(
isPlanComplete(
- plan([step('node', { state: 'satisfied' }), step('gh', { optional: true, state: 'failed' })])
+ plan([
+ step('node', { state: 'satisfied' }),
+ step('gh', { optional: true, state: 'failed' }),
+ ])
)
).toBe(true);
});
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 a4eb95845..7bd70395f 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
@@ -39,9 +39,7 @@ export type StepCheckResult = {
};
/** Outcome of installing one step. */
-export type StepInstallResult =
- | { ok: true }
- | { ok: false; error: string; output?: string | null };
+export type StepInstallResult = { ok: true } | { ok: false; error: string; output?: string | null };
export type HostSetupRunnerDeps = {
sshHost: string;
@@ -275,6 +273,13 @@ function findStep(plan: HostSetupPlan, stepId: string): HostSetupStep {
/** Why a step cannot be advanced automatically — stated in terms of what we saw. */
function describeUnactionable(step: HostSetupStep): string {
+ // Not a failure of ours to fix: signing in to GitHub is a device flow the
+ // user drives in a terminal. Say what they need to do rather than reporting
+ // it as a missing install command.
+ if (step.kind === 'gh-auth') {
+ return 'Signing in to GitHub needs a one-time code you enter yourself. Use Sign in to start it.';
+ }
+
switch (step.outcome) {
case 'not-running':
return `${step.name} is installed but not running. Start it on the host, then retry.`;
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 f55794c65..2e289edb4 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
@@ -7,13 +7,14 @@
* per-host lifecycle (build, resume, run, skip, discard).
*/
-import { HostDependencyManager } from '@switchdash/core/deps/runtime';
+import type { HostDependencyManager } from '@switchdash/core/deps/runtime';
+import { CORE_DEPENDENCIES } from '@main/core/dependencies/core-dependencies';
import {
getRemoteDependencyManager,
remoteDependencyDescriptor,
} from '@main/core/dependencies/remote-dependency-manager';
-import { CORE_DEPENDENCIES } from '@main/core/dependencies/core-dependencies';
import { getRemoteSwitchSetupService } from '@main/core/switch-setup/remote-switch-setup';
+import { events } from '@main/lib/events';
import { log } from '@main/lib/logger';
import {
hostSetupPlanEventChannel,
@@ -21,9 +22,8 @@ import {
type HostSetupPlan,
type HostSetupStep,
} from '@shared/core/remote-hosts/setup';
-import { events } from '@main/lib/events';
-import { hostReachabilityService } from '../production-host-reachability';
import { probeGhAuthStatus } from '../gh-auth';
+import { hostReachabilityService } from '../production-host-reachability';
import { HostSetupRunner, type StepCheckResult, type StepInstallResult } from './host-setup-runner';
import {
agentPluginStepId,
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.ts
index bece11ec8..5ac3e7015 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.ts
@@ -29,12 +29,7 @@ const STEP_STATES: HostSetupStepState[] = [
'skipped',
'blocked',
];
-const STEP_KINDS: HostSetupStepKind[] = [
- 'core-dependency',
- 'agent-cli',
- 'agent-plugin',
- 'gh-auth',
-];
+const STEP_KINDS: HostSetupStepKind[] = ['core-dependency', 'agent-cli', 'agent-plugin', 'gh-auth'];
const OUTCOMES: DependencyCheckOutcome[] = [
'satisfied',
'missing',
@@ -78,8 +73,7 @@ function toStep(raw: unknown, sshHost: string): HostSetupStep {
dependsOn: Array.isArray(value.dependsOn)
? value.dependsOn.filter((id): id is string => typeof id === 'string')
: [],
- updatedAt:
- typeof value.updatedAt === 'string' ? value.updatedAt : new Date(0).toISOString(),
+ updatedAt: typeof value.updatedAt === 'string' ? value.updatedAt : new Date(0).toISOString(),
};
}
diff --git a/dash/apps/switchdash-desktop/src/main/db/tests/migrations/0045-remote-host-setup-plans.test.ts b/dash/apps/switchdash-desktop/src/main/db/tests/migrations/0045-remote-host-setup-plans.test.ts
index 2775cf45b..99116bcfc 100644
--- a/dash/apps/switchdash-desktop/src/main/db/tests/migrations/0045-remote-host-setup-plans.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/db/tests/migrations/0045-remote-host-setup-plans.test.ts
@@ -37,9 +37,7 @@ describe('migration 0045: remote host setup plans', () => {
it('defaults a new plan to idle', async () => {
fixture = await openFixture('empty');
- await fixture.db
- .insert(remoteHostSetupPlans)
- .values({ sshHost: 'dev-vm', steps: '[]' });
+ await fixture.db.insert(remoteHostSetupPlans).values({ sshHost: 'dev-vm', steps: '[]' });
const [row] = await fixture.db
.select()
diff --git a/dash/apps/switchdash-desktop/src/renderer/app/view-registry.ts b/dash/apps/switchdash-desktop/src/renderer/app/view-registry.ts
index e930ababa..4b02504c1 100644
--- a/dash/apps/switchdash-desktop/src/renderer/app/view-registry.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/app/view-registry.ts
@@ -1,6 +1,8 @@
import type { ComponentType, ReactNode } from 'react';
import { homeView } from '@renderer/app/home-view';
import { locationView } from '@renderer/features/locations/view';
+import { remoteHostView } from '@renderer/features/remote-hosts/views/remote-host-view';
+import { remoteHostsView } from '@renderer/features/remote-hosts/views/remote-hosts-view';
import { sessionView } from '@renderer/features/sessions/view';
import { settingsView } from '@renderer/features/settings/settings-view';
import { roomView } from '@renderer/features/switch-rooms/view';
@@ -18,6 +20,8 @@ export const views = {
room: roomView,
settings: settingsView,
server: serverView,
+ remoteHosts: remoteHostsView,
+ remoteHost: remoteHostView,
// oxlint-disable-next-line typescript/no-explicit-any
} satisfies Record<string, ViewDefinition<any>>;
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/RemoteHostsSettingsPage.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/RemoteHostsSettingsPage.tsx
deleted file mode 100644
index 1693efa72..000000000
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/RemoteHostsSettingsPage.tsx
+++ /dev/null
@@ -1,261 +0,0 @@
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import { AlertTriangle, CheckCircle2, ChevronRight, Plus, Server, Trash2 } from 'lucide-react';
-import { useMemo, useState } from 'react';
-import { PageHeader } from '@renderer/lib/components/page-header';
-import { rpc } from '@renderer/lib/ipc';
-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 { log } from '@renderer/utils/logger';
-import { hostSetupQueryKey } from './query-keys';
-import { RemoteHostDetail } from './remote-host-detail';
-
-export const REMOTE_HOSTS_QUERY_KEY = ['remote-hosts'];
-
-/** Compact readiness badge for a host row, backed by getHostSetup. */
-function HostSetupBadge({ sshHost }: { sshHost: string }) {
- const { data, isLoading, isError } = useQuery({
- queryKey: hostSetupQueryKey(sshHost),
- queryFn: () => rpc.remoteHosts.getHostSetup(sshHost),
- staleTime: 30_000,
- });
-
- if (isLoading) {
- return (
- <span className="flex items-center gap-1 text-xs text-foreground-muted">
- <Spinner /> Checking…
- </span>
- );
- }
- if (isError || !data?.reachable) {
- return (
- <span className="flex items-center gap-1 text-xs text-foreground-muted">
- <AlertTriangle className="size-3.5 text-amber-500" /> Unreachable
- </span>
- );
- }
- if (data.ready) {
- return (
- <span className="flex items-center gap-1 text-xs text-green-500">
- <CheckCircle2 className="size-3.5" /> Ready
- </span>
- );
- }
- return (
- <span className="flex items-center gap-1 text-xs text-amber-500" title={data.issues.join('; ')}>
- <AlertTriangle className="size-3.5" /> Setup needed
- </span>
- );
-}
-
-/**
- * Host-level management surface (switchdash remote host connection management).
- * Lists onboarded SSH hosts; selecting one opens its detail — host tool
- * dependencies and per-agent-type Switch connector plugin status, each with
- * install/update actions. Onboarding picks a `~/.ssh/config` alias; switchdash
- * stores no credentials.
- */
-export function RemoteHostsSettingsPage() {
- const queryClient = useQueryClient();
- const [selectedHost, setSelectedHost] = useState<string | null>(null);
-
- const { data: hosts, isLoading } = useQuery({
- queryKey: REMOTE_HOSTS_QUERY_KEY,
- queryFn: () => rpc.remoteHosts.listHosts(),
- });
-
- const list = hosts ?? [];
-
- return (
- <div className="space-y-8 pb-10">
- <PageHeader
- sticky
- title="Remote hosts"
- description="Onboard SSH hosts to run agents remotely. Manage each host's tool dependencies and the Switch connector plugin for every agent type."
- >
- <OnboardHostForm
- onboarded={list.map((h) => h.sshHost)}
- onOnboarded={(sshHost) => {
- void queryClient.invalidateQueries({ queryKey: REMOTE_HOSTS_QUERY_KEY });
- setSelectedHost(sshHost);
- }}
- />
- </PageHeader>
-
- {isLoading ? (
- <div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner /> Loading hosts…
- </div>
- ) : list.length === 0 ? (
- <p className="text-sm text-foreground-muted">
- No remote hosts onboarded yet. Add one above to get started.
- </p>
- ) : (
- <div className="flex flex-col gap-2">
- {list.map((host) => (
- <div
- key={host.sshHost}
- className="flex flex-col gap-3 rounded-lg border border-border p-3"
- >
- <div className="flex items-center justify-between gap-3">
- <button
- type="button"
- className="flex min-w-0 flex-1 items-center gap-2 text-left"
- onClick={() =>
- setSelectedHost((cur) => (cur === host.sshHost ? null : host.sshHost))
- }
- >
- <ChevronRight
- className={`size-4 shrink-0 text-foreground-muted transition-transform ${
- selectedHost === host.sshHost ? 'rotate-90' : ''
- }`}
- />
- <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>
- <HostSetupBadge sshHost={host.sshHost} />
- <RemoveHostButton
- sshHost={host.sshHost}
- onRemoved={() => {
- if (selectedHost === host.sshHost) setSelectedHost(null);
- void queryClient.invalidateQueries({ queryKey: REMOTE_HOSTS_QUERY_KEY });
- }}
- />
- </div>
- {selectedHost === host.sshHost && <RemoteHostDetail sshHost={host.sshHost} />}
- </div>
- ))}
- </div>
- )}
- </div>
- );
-}
-
-function OnboardHostForm({
- onboarded,
- onOnboarded,
-}: {
- onboarded: string[];
- onOnboarded: (sshHost: string) => void;
-}) {
- const [open, setOpen] = useState(false);
- const [sshHost, setSshHost] = useState('');
- const [name, setName] = useState('');
-
- const { data: configHosts } = useQuery({
- queryKey: ['ssh-config-hosts'],
- queryFn: () => rpc.remoteHosts.listSshConfigHosts(),
- enabled: open,
- });
-
- const available = useMemo(
- () => (configHosts ?? []).filter((h) => !onboarded.includes(h)),
- [configHosts, 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>
- {available.length > 0 ? (
- <Select value={sshHost} onValueChange={(v) => setSshHost(v ?? '')}>
- <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={(e) => setSshHost(e.target.value)}
- />
- )}
- </div>
- <div className="flex flex-col gap-1">
- <Label className="text-xs">Display name</Label>
- <Input value={name} placeholder="Dev VM" onChange={(e) => setName(e.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>
- );
-}
-
-function RemoveHostButton({ sshHost, onRemoved }: { sshHost: string; onRemoved: () => void }) {
- const mutation = useMutation({
- mutationFn: () => rpc.remoteHosts.removeHost(sshHost),
- onError: (error) => log.error('Failed to remove remote host', { sshHost, error }),
- onSuccess: onRemoved,
- });
-
- return (
- <Button
- size="icon-sm"
- variant="ghost"
- aria-label={`Remove ${sshHost}`}
- disabled={mutation.isPending}
- onClick={() => mutation.mutate()}
- >
- <Trash2 className="size-4" />
- </Button>
- );
-}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/query-keys.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/query-keys.ts
deleted file mode 100644
index 0ea23204c..000000000
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/query-keys.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/** React-query keys shared across the remote-hosts feature. */
-
-export function hostSetupQueryKey(sshHost: string) {
- return ['remote-host-setup', sshHost];
-}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/remote-host-detail.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/remote-host-detail.tsx
deleted file mode 100644
index 0deee5c38..000000000
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/remote-host-detail.tsx
+++ /dev/null
@@ -1,578 +0,0 @@
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import {
- AlertTriangle,
- CheckCircle2,
- ChevronRight,
- Circle,
- Loader2,
- Plug,
- RefreshCw,
- XCircle,
-} from 'lucide-react';
-import { useEffect, useRef, useState } from 'react';
-import { events, rpc } from '@renderer/lib/ipc';
-import { Button } from '@renderer/lib/ui/button';
-import { Spinner } from '@renderer/lib/ui/spinner';
-import { log } from '@renderer/utils/logger';
-import { cn } from '@renderer/utils/utils';
-import { sshConnectionEventChannel } from '@shared/core/ssh/sshEvents';
-import { GhAuthPanel } from './gh-auth-panel';
-import { hostSetupQueryKey } from './query-keys';
-
-type RemoteDep = Awaited<ReturnType<typeof rpc.remoteHosts.probeDeps>>[number];
-type AgentPluginStatus = Awaited<ReturnType<typeof rpc.remoteHosts.listAgentTypePlugins>>[number];
-type InstallResult = Awaited<ReturnType<typeof rpc.remoteHosts.installDep>>;
-
-/** Human-readable message from a failed installDep Result (surface, don't swallow). */
-function describeInstallError(result: Extract<InstallResult, { success: false }>): string {
- const e = result.error as { type?: string; message?: string; output?: string };
- return e.message || e.output || e.type || 'Install failed.';
-}
-
-function depsQueryKey(sshHost: string) {
- return ['remote-host-deps', sshHost];
-}
-function pluginsQueryKey(sshHost: string) {
- return ['remote-host-plugins', sshHost];
-}
-function connectionQueryKey(sshHost: string) {
- return ['remote-host-connection', sshHost];
-}
-
-type HostConnectionStatus = Awaited<ReturnType<typeof rpc.remoteHosts.getConnectionStatus>>;
-
-/** Compact live badge for the host's pooled SSH connection. */
-function ConnectionBadge({ status }: { status: HostConnectionStatus | undefined }) {
- if (!status) return null;
- if (status.state === 'connected' && status.health.status === 'degraded') {
- return (
- <span className="flex items-center gap-1 text-xs text-amber-500">
- <AlertTriangle className="size-3.5" /> Connection degraded
- </span>
- );
- }
- switch (status.state) {
- case 'connected':
- return (
- <span className="flex items-center gap-1 text-xs text-green-500">
- <CheckCircle2 className="size-3.5" /> Connected
- </span>
- );
- case 'connecting':
- case 'reconnecting':
- return (
- <span className="flex items-center gap-1 text-xs text-foreground-muted">
- <Loader2 className="size-3.5 animate-spin" />
- {status.state === 'connecting' ? 'Connecting…' : 'Reconnecting…'}
- </span>
- );
- case 'error':
- return (
- <span className="text-destructive flex items-center gap-1 text-xs">
- <XCircle className="size-3.5" /> Connection failed
- </span>
- );
- case 'disconnected':
- return (
- <span className="flex items-center gap-1 text-xs text-foreground-muted">
- <Circle className="size-3.5" /> Not connected
- </span>
- );
- }
-}
-
-/**
- * Whether a row is fully usable, not just "the binary exists". `partial` means a
- * required follow-up step is outstanding (gh installed but not authenticated; agent
- * CLI installed but the Switch plugin isn't) — green is reserved for `ready`.
- */
-type Readiness = 'ready' | 'partial' | 'missing' | 'error';
-
-function StatusIcon({ readiness }: { readiness: Readiness }) {
- if (readiness === 'ready') return <CheckCircle2 className="size-4 text-green-500" />;
- if (readiness === 'partial') return <AlertTriangle className="size-4 text-amber-500" />;
- if (readiness === 'error') return <AlertTriangle className="size-4 text-amber-500" />;
- return <XCircle className="size-4 text-foreground-muted" />;
-}
-
-type StepState = 'done' | 'current' | 'pending' | 'busy';
-
-type Step = { label: string; state: StepState };
-
-/**
- * Compact horizontal progress for a multi-step row (e.g. gh: Installed →
- * Authenticated; agent type: CLI → Plugin). Done steps are green, the next
- * actionable step is amber, later steps are muted, and an in-flight step spins.
- */
-function StepList({ steps }: { steps: Step[] }) {
- return (
- <div className="flex flex-wrap items-center gap-x-2 gap-y-1 pl-6">
- {steps.map((step, i) => (
- <div key={step.label} className="flex items-center gap-2">
- {i > 0 && <ChevronRight className="size-3 text-foreground-muted" />}
- <span
- className={cn(
- 'inline-flex items-center gap-1 text-xs',
- step.state === 'pending' ? 'text-foreground-muted' : 'text-foreground'
- )}
- >
- {step.state === 'done' ? (
- <CheckCircle2 className="size-3.5 text-green-500" />
- ) : step.state === 'busy' ? (
- <Loader2 className="size-3.5 animate-spin text-amber-500" />
- ) : step.state === 'current' ? (
- <Circle className="size-3.5 fill-amber-500 text-amber-500" />
- ) : (
- <Circle className="size-3.5 text-foreground-muted" />
- )}
- {step.label}
- </span>
- </div>
- ))}
- </div>
- );
-}
-
-/**
- * Detail for one onboarded remote host, gated on the SSH connection: opening it
- * first establishes (or rebuilds) the pooled connection, and only once
- * connected shows the dependency + plugin sections, whose Refresh re-probes
- * them. Probing over a connection that is known to be down would only mislabel
- * every dependency as missing, so the disconnected view offers Connect instead.
- */
-export function RemoteHostDetail({ sshHost }: { sshHost: string }) {
- const queryClient = useQueryClient();
- const [authenticatingGh, setAuthenticatingGh] = useState(false);
-
- const connection = useQuery({
- queryKey: connectionQueryKey(sshHost),
- queryFn: () => rpc.remoteHosts.getConnectionStatus(sshHost),
- });
- const isConnected = connection.data?.state === 'connected';
-
- // Probing is an SSH round-trip, so cache it: re-expanding a host reuses the
- // last result instead of re-probing. Refresh and post-install invalidation
- // force a re-fetch when the data actually needs to change. Enabled only
- // while connected — the connect step below runs first.
- const deps = useQuery({
- queryKey: depsQueryKey(sshHost),
- queryFn: () => rpc.remoteHosts.probeDeps(sshHost),
- staleTime: Infinity,
- gcTime: Infinity,
- enabled: isConnected,
- });
- const plugins = useQuery({
- queryKey: pluginsQueryKey(sshHost),
- queryFn: () => rpc.remoteHosts.listAgentTypePlugins(sshHost),
- staleTime: Infinity,
- gcTime: Infinity,
- enabled: isConnected,
- });
-
- // Live-update the badge: the main process broadcasts every connection
- // transition (connected/reconnecting/health-changed/…), so refetch on any
- // event for this host's pooled connection (id shape: `agent-ssh:<host>`).
- useEffect(() => {
- return events.on(sshConnectionEventChannel, (event) => {
- if (!event.connectionId.endsWith(`:${sshHost}`)) return;
- void queryClient.invalidateQueries({ queryKey: connectionQueryKey(sshHost) });
- });
- }, [sshHost, queryClient]);
-
- const connect = useMutation({
- mutationFn: () => rpc.remoteHosts.reconnectHost(sshHost),
- onError: (error) => log.error('Remote host connect failed', { sshHost, error }),
- onSettled: () => {
- void queryClient.invalidateQueries({ queryKey: connectionQueryKey(sshHost) });
- void queryClient.invalidateQueries({ queryKey: hostSetupQueryKey(sshHost) });
- },
- });
-
- // Connect-on-open: the page's first step is establishing the connection.
- // One automatic attempt per mount; after a failure the user retries via the
- // Connect button.
- const { mutate: startConnect, isPending: connectPending, isError: connectFailed } = connect;
- const autoConnectAttempted = useRef(false);
- const connectionState = connection.data?.state;
- useEffect(() => {
- if (connectionState === undefined || autoConnectAttempted.current) return;
- if (connectionState === 'connected' || connectionState === 'connecting') return;
- if (connectionState === 'reconnecting') return; // the manager is already on it
- autoConnectAttempted.current = true;
- startConnect();
- }, [connectionState, startConnect]);
-
- const coreDeps = (deps.data ?? []).filter((d) => d.category === 'core');
- // Only agent types that support the Switch connector plugin can be set up to
- // run in Switch, so those are the only ones offered here.
- const supportedAgentIds = new Set(
- (plugins.data ?? []).filter((p) => p.supported).map((p) => p.agentId)
- );
- const agentDeps = (deps.data ?? []).filter(
- (d) => d.category === 'agent' && supportedAgentIds.has(d.id)
- );
-
- const refreshing = deps.isFetching || plugins.isFetching;
- const establishing =
- connectPending ||
- connection.isLoading ||
- connectionState === 'connecting' ||
- connectionState === 'reconnecting';
-
- // Step 1: not connected yet — show the connection state and a Connect
- // action; the deps sections only exist once the connection is up.
- if (!isConnected) {
- return (
- <div className="flex flex-col gap-3 border-t border-border pt-3">
- <div className="flex items-center justify-between">
- <div className="flex min-w-0 items-center gap-2">
- {establishing ? (
- <span className="flex items-center gap-1 text-xs text-foreground-muted">
- <Loader2 className="size-3.5 animate-spin" /> Connecting…
- </span>
- ) : (
- <ConnectionBadge status={connection.data} />
- )}
- {connectFailed && !connectPending && (
- <span className="text-destructive truncate text-xs">
- {(connect.error as Error).message}
- </span>
- )}
- </div>
- <Button
- size="sm"
- variant="outline"
- disabled={establishing}
- onClick={() => connect.mutate()}
- >
- <Plug className="size-3.5" /> {establishing ? 'Connecting…' : 'Connect'}
- </Button>
- </div>
- </div>
- );
- }
-
- // Step 2: connected — the deps page, refreshable.
- return (
- <div className="flex flex-col gap-5 border-t border-border pt-3">
- <div className="flex items-center justify-between">
- <ConnectionBadge status={connection.data} />
- <Button
- size="sm"
- variant="outline"
- disabled={refreshing}
- onClick={() => {
- void deps.refetch();
- void plugins.refetch();
- }}
- >
- <RefreshCw className={`size-3.5 ${refreshing ? 'animate-spin' : ''}`} /> Refresh
- </Button>
- </div>
-
- <section className="flex flex-col gap-2">
- <h4 className="text-sm font-medium">Dependencies</h4>
- {deps.isLoading ? (
- <div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner /> Checking host…
- </div>
- ) : deps.isError ? (
- <p className="text-destructive text-xs">
- Could not reach host: {(deps.error as Error).message}
- </p>
- ) : coreDeps.length === 0 ? (
- <p className="text-xs text-foreground-muted">No tool dependencies to report.</p>
- ) : (
- coreDeps.map((dep) => (
- <DepRow
- key={dep.id}
- sshHost={sshHost}
- dep={dep}
- onAuthenticate={() => setAuthenticatingGh(true)}
- />
- ))
- )}
- {authenticatingGh && (
- <GhAuthPanel
- sshHost={sshHost}
- onDone={() => {
- setAuthenticatingGh(false);
- void queryClient.invalidateQueries({ queryKey: depsQueryKey(sshHost) });
- }}
- />
- )}
- </section>
-
- <section className="flex flex-col gap-2">
- <h4 className="text-sm font-medium">Agent types & Switch plugin</h4>
- {deps.isLoading || plugins.isLoading ? (
- <div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner /> Checking agent types…
- </div>
- ) : agentDeps.length === 0 ? (
- <p className="text-xs text-foreground-muted">No agent types to report.</p>
- ) : (
- agentDeps.map((dep) => (
- <AgentTypeRow
- key={dep.id}
- sshHost={sshHost}
- dep={dep}
- plugin={(plugins.data ?? []).find((p) => p.agentId === dep.id)}
- />
- ))
- )}
- </section>
- </div>
- );
-}
-
-function DepRow({
- sshHost,
- dep,
- onAuthenticate,
-}: {
- sshHost: string;
- dep: RemoteDep;
- onAuthenticate: () => void;
-}) {
- const queryClient = useQueryClient();
- const invalidate = () => {
- void queryClient.invalidateQueries({ queryKey: depsQueryKey(sshHost) });
- void queryClient.invalidateQueries({ queryKey: hostSetupQueryKey(sshHost) });
- };
-
- // gh is a two-step row (install → authenticate); other core deps are single-step.
- const isGh = dep.ghAuth !== undefined;
-
- const install = useMutation({
- mutationFn: () => rpc.remoteHosts.installDep({ sshHost, id: dep.id }),
- onSuccess: (result) => {
- // Auto-advance: once gh is installed it still needs auth, so go straight
- // to the auth step instead of making the user click a second time.
- if (result.success && isGh) onAuthenticate();
- },
- onError: (error) => log.error('Remote dep install failed', { sshHost, id: dep.id, error }),
- onSettled: invalidate,
- });
-
- const installed = dep.status === 'available';
- // gh reports auth separately: installed but not authenticated is still unusable.
- const needsGhAuth = isGh && !dep.ghAuth!.authenticated;
- const authed = isGh && dep.ghAuth!.authenticated;
-
- const readiness: Readiness =
- dep.status === 'error' ? 'error' : !installed ? 'missing' : needsGhAuth ? 'partial' : 'ready';
-
- const steps: Step[] = isGh
- ? [
- {
- label: 'Installed',
- state: installed ? 'done' : install.isPending ? 'busy' : 'current',
- },
- {
- label: authed ? `Authenticated as ${dep.ghAuth!.account ?? 'you'}` : 'Authenticate',
- state: !installed ? 'pending' : authed ? 'done' : 'current',
- },
- ]
- : [];
-
- return (
- <div className="flex items-center justify-between gap-2 rounded-md border border-border px-3 py-2">
- <div className="flex min-w-0 flex-col gap-1">
- <div className="flex items-center gap-2">
- <StatusIcon readiness={readiness} />
- <span className="text-sm">{dep.name}</span>
- {dep.version && <span className="text-xs text-foreground-muted">{dep.version}</span>}
- </div>
- {dep.status === 'error' && dep.error && (
- <span className="text-xs text-amber-500">{dep.error}</span>
- )}
- {isGh && <StepList steps={steps} />}
- </div>
- <div className="flex items-center gap-2">
- {install.isError && <span className="text-destructive text-xs">Install failed</span>}
- {!installed && dep.canInstall && (
- <Button size="sm" disabled={install.isPending} onClick={() => install.mutate()}>
- {install.isPending ? 'Installing…' : 'Install'}
- </Button>
- )}
- {installed && needsGhAuth && (
- <Button size="sm" onClick={onAuthenticate}>
- Authenticate
- </Button>
- )}
- </div>
- </div>
- );
-}
-
-function AgentTypeRow({
- sshHost,
- dep,
- plugin,
-}: {
- sshHost: string;
- dep: RemoteDep;
- plugin: AgentPluginStatus | undefined;
-}) {
- const queryClient = useQueryClient();
- const [actionError, setActionError] = useState<string | null>(null);
- const invalidateAll = () => {
- void queryClient.invalidateQueries({ queryKey: depsQueryKey(sshHost) });
- void queryClient.invalidateQueries({ queryKey: pluginsQueryKey(sshHost) });
- void queryClient.invalidateQueries({ queryKey: hostSetupQueryKey(sshHost) });
- };
-
- const installPlugin = useMutation({
- mutationFn: () => rpc.remoteHosts.installAgentPlugin({ sshHost, agentId: dep.id }),
- onSuccess: (result) =>
- setActionError(result.success ? null : (result.message ?? 'Plugin install failed.')),
- onError: (error) => {
- log.error('Remote plugin install failed', { sshHost, id: dep.id, error });
- setActionError(error instanceof Error ? error.message : 'Plugin install failed.');
- },
- onSettled: invalidateAll,
- });
-
- const installCli = useMutation({
- mutationFn: () => rpc.remoteHosts.installDep({ sshHost, id: dep.id }),
- onSuccess: (result) => {
- if (!result.success) {
- setActionError(describeInstallError(result));
- return;
- }
- setActionError(null);
- // Auto-advance: the CLI alone can't participate in Switch — once it's in,
- // install the Switch plugin without a second click.
- if (plugin?.supported && !plugin.installed) installPlugin.mutate();
- },
- onError: (error) => {
- log.error('Remote agent CLI install failed', { sshHost, id: dep.id, error });
- setActionError(error instanceof Error ? error.message : 'CLI install failed.');
- },
- onSettled: invalidateAll,
- });
-
- const updatePlugin = useMutation({
- mutationFn: () => rpc.remoteHosts.updateAgentPlugin({ sshHost, agentId: dep.id }),
- onSuccess: (result) =>
- setActionError(result.success ? null : (result.message ?? 'Plugin update failed.')),
- onError: (error) => {
- log.error('Remote plugin update failed', { sshHost, id: dep.id, error });
- setActionError(error instanceof Error ? error.message : 'Plugin update failed.');
- },
- onSettled: invalidateAll,
- });
-
- const checkUpdates = useMutation({
- mutationFn: () => rpc.remoteHosts.checkAgentPluginUpdates({ sshHost, agentId: dep.id }),
- onSuccess: (status) => {
- setActionError(
- status.refreshError
- ? `Could not refresh the plugin marketplace — showing cached status. ${status.refreshError}`
- : null
- );
- queryClient.setQueryData(pluginsQueryKey(sshHost), (prev: AgentPluginStatus[] | undefined) =>
- prev?.map((p) => (p.agentId === status.agentId ? status : p))
- );
- },
- onError: (error) => {
- log.error('Remote plugin update check failed', { sshHost, id: dep.id, error });
- setActionError(error instanceof Error ? error.message : 'Update check failed.');
- },
- });
-
- const cliInstalled = dep.status === 'available';
- const pending =
- installCli.isPending ||
- installPlugin.isPending ||
- updatePlugin.isPending ||
- checkUpdates.isPending;
-
- // Green only when the agent type is fully usable: CLI present AND (the Switch
- // plugin is installed, or this agent type has no plugin). CLI-without-plugin is
- // a partial (amber) state.
- const pluginNeeded = plugin?.supported === true && !plugin.installed;
- const readiness: Readiness =
- dep.status === 'error'
- ? 'error'
- : !cliInstalled
- ? 'missing'
- : pluginNeeded
- ? 'partial'
- : 'ready';
-
- const pluginStepLabel =
- plugin?.installed && plugin.updateAvailable
- ? 'Plugin · update available'
- : plugin?.installed
- ? `Plugin ${plugin.installedVersion ?? ''}`.trim()
- : 'Switch plugin';
-
- const steps: Step[] = [
- {
- label: cliInstalled ? `CLI ${dep.version ?? ''}`.trim() : 'Install CLI',
- state: cliInstalled ? 'done' : installCli.isPending ? 'busy' : 'current',
- },
- {
- label: pluginStepLabel,
- state: !cliInstalled
- ? 'pending'
- : plugin?.installed
- ? 'done'
- : installPlugin.isPending
- ? 'busy'
- : 'current',
- },
- ];
-
- return (
- <div className="flex items-center justify-between gap-2 rounded-md border border-border px-3 py-2">
- <div className="flex min-w-0 flex-col gap-1">
- <div className="flex items-center gap-2">
- <StatusIcon readiness={readiness} />
- <span className="text-sm">{dep.name}</span>
- </div>
- <StepList steps={steps} />
- {actionError && <span className="text-destructive pl-6 text-xs">{actionError}</span>}
- </div>
- <div className="flex items-center gap-2">
- {!cliInstalled && dep.canInstall && (
- <Button
- size="sm"
- variant="outline"
- disabled={pending}
- onClick={() => installCli.mutate()}
- >
- {installCli.isPending ? 'Installing…' : 'Install CLI'}
- </Button>
- )}
- {cliInstalled && plugin?.supported && !plugin.installed && (
- <Button size="sm" disabled={pending} onClick={() => installPlugin.mutate()}>
- {installPlugin.isPending ? 'Installing…' : 'Install plugin'}
- </Button>
- )}
- {cliInstalled && plugin?.installed && !plugin.updateAvailable && (
- <Button
- size="sm"
- variant="outline"
- disabled={pending}
- onClick={() => checkUpdates.mutate()}
- >
- {checkUpdates.isPending ? 'Checking…' : 'Check for updates'}
- </Button>
- )}
- {cliInstalled && plugin?.installed && plugin.updateAvailable && (
- <Button
- size="sm"
- variant="outline"
- disabled={pending}
- onClick={() => updatePlugin.mutate()}
- >
- {updatePlugin.isPending ? 'Updating…' : 'Update plugin'}
- </Button>
- )}
- </div>
- </div>
- );
-}
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
new file mode 100644
index 000000000..328d036b2
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-steps.tsx
@@ -0,0 +1,178 @@
+/**
+ * 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
new file mode 100644
index 000000000..03d4eb72d
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
@@ -0,0 +1,193 @@
+import { describe, expect, it } from 'vitest';
+import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';
+import {
+ outcomeLabel,
+ showsAsComplete,
+ stepStatusLabel,
+ stepTone,
+ summarisePlan,
+} from './step-presentation';
+
+function step(patch: Partial<HostSetupStep> = {}): HostSetupStep {
+ return {
+ id: 'node',
+ kind: 'core-dependency',
+ name: 'Node.js',
+ state: 'pending',
+ outcome: null,
+ version: null,
+ error: null,
+ output: null,
+ optional: false,
+ dependsOn: [],
+ updatedAt: '2026-02-02T00:00:00.000Z',
+ ...patch,
+ };
+}
+
+function plan(steps: HostSetupStep[], patch: Partial<HostSetupPlan> = {}): HostSetupPlan {
+ return {
+ sshHost: 'dev-vm',
+ status: 'idle',
+ steps,
+ currentStepId: null,
+ createdAt: '2026-02-02T00:00:00.000Z',
+ updatedAt: '2026-02-02T00:00:00.000Z',
+ ...patch,
+ };
+}
+
+describe('showsAsComplete — the green tick must be earned', () => {
+ it('is true only for a satisfied step', () => {
+ expect(showsAsComplete(step({ state: 'satisfied' }))).toBe(true);
+ });
+
+ it.each(['pending', 'checking', 'installing', 'failed', 'skipped', 'blocked'] as const)(
+ 'is false for %s',
+ (state) => {
+ expect(showsAsComplete(step({ state }))).toBe(false);
+ }
+ );
+
+ 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');
+ }
+ });
+});
+
+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('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('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('ignores optional steps when deciding readiness', () => {
+ const summary = summarisePlan(
+ plan([
+ step({ id: 'node', state: 'satisfied' }),
+ step({ id: 'gh', state: 'failed', optional: true }),
+ ])
+ );
+ 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);
+ });
+
+ 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('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('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…');
+ });
+
+ 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('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');
+ });
+});
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
new file mode 100644
index 000000000..aed7aa9c6
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
@@ -0,0 +1,150 @@
+/**
+ * How a setup step is rendered (CHOO-1809).
+ *
+ * Kept as pure functions rather than inline JSX conditionals so the rules that
+ * matter can be tested directly — above all: **nothing that was not observed to
+ * be present is ever shown as done**. The previous page decided tone with
+ * chained ternaries over booleans, which is how "we didn't check" came to look
+ * identical to "we checked and it's fine".
+ */
+
+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.
+ */
+export function outcomeLabel(outcome: DependencyCheckOutcome | null): string {
+ switch (outcome) {
+ case 'satisfied':
+ return 'Ready';
+ case 'missing':
+ return 'Not installed';
+ case 'not-running':
+ return 'Installed but not running';
+ case 'wrong-version':
+ return 'Installed but too old';
+ case 'unknown':
+ return 'Could not be checked';
+ case null:
+ return 'Not checked yet';
+ }
+}
+
+/**
+ * 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';
+};
+
+/**
+ * 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.
+ */
+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' };
+ }
+
+ 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;
+
+ if (ready) {
+ return { done, total, ready, headline: 'Ready', tone: 'ready' };
+ }
+
+ 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 (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',
+ };
+ }
+
+ if (done === 0) {
+ return { done, total, ready, headline: 'Setup not started', tone: 'unstarted' };
+ }
+
+ return { done, total, ready, headline: `${done} of ${total} steps done`, tone: 'in-progress' };
+}
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
new file mode 100644
index 000000000..4f5d78a3b
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
@@ -0,0 +1,101 @@
+/**
+ * Renderer access to a host's setup plan (CHOO-1809).
+ *
+ * The plan is **pushed**, not polled. The old page re-probed the host on every
+ * mount — an SSH round trip per row, fired during render — which is what made
+ * opening the page so expensive and so noisy. Here the main process owns the
+ * plan and emits it on every transition; this hook just mirrors it.
+ */
+
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { useEffect } from 'react';
+import { events, rpc } from '@renderer/lib/ipc';
+import { log } from '@renderer/utils/logger';
+import { hostSetupPlanEventChannel, type HostSetupPlan } from '@shared/core/remote-hosts/setup';
+
+export function setupPlanQueryKey(sshHost: string) {
+ return ['remote-host-setup-plan', sshHost];
+}
+
+/** Live plan for one host, kept current by pushed events. */
+export function useHostSetupPlan(sshHost: string) {
+ const queryClient = useQueryClient();
+
+ const query = useQuery({
+ queryKey: setupPlanQueryKey(sshHost),
+ queryFn: () => rpc.remoteHosts.getSetupPlan(sshHost),
+ });
+
+ useEffect(() => {
+ return events.on(hostSetupPlanEventChannel, (plan) => {
+ if (plan.sshHost !== sshHost) return;
+ queryClient.setQueryData(setupPlanQueryKey(sshHost), plan);
+ });
+ }, [sshHost, queryClient]);
+
+ return query;
+}
+
+/** Every host's plan at once, for the list page. Also kept current by events. */
+export function useAllHostSetupPlans(sshHosts: string[]) {
+ const queryClient = useQueryClient();
+
+ const query = useQuery({
+ queryKey: ['remote-host-setup-plans', [...sshHosts].sort().join(',')],
+ queryFn: async () => {
+ const plans = await Promise.all(
+ sshHosts.map((sshHost) => rpc.remoteHosts.getSetupPlan(sshHost))
+ );
+ return Object.fromEntries(
+ plans
+ .filter((plan): plan is HostSetupPlan => plan !== null)
+ .map((plan) => [plan.sshHost, plan])
+ );
+ },
+ enabled: sshHosts.length > 0,
+ });
+
+ useEffect(() => {
+ return events.on(hostSetupPlanEventChannel, (plan) => {
+ queryClient.setQueryData(
+ ['remote-host-setup-plans', [...sshHosts].sort().join(',')],
+ (prev: Record<string, HostSetupPlan> | undefined) => ({ ...prev, [plan.sshHost]: plan })
+ );
+ });
+ }, [sshHosts, queryClient]);
+
+ return query;
+}
+
+/** Build or refresh the plan without running it — what the host page does on open. */
+export function usePrepareSetup(sshHost: string) {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: () => rpc.remoteHosts.prepareSetup(sshHost),
+ onSuccess: (plan) => queryClient.setQueryData(setupPlanQueryKey(sshHost), plan),
+ onError: (error) => log.error('Could not prepare remote host setup', { 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
+ * caller surfaces rather than swallowing.
+ */
+export function useRunSetup(sshHost: string) {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: () => rpc.remoteHosts.runSetup(sshHost),
+ onSuccess: (plan) => queryClient.setQueryData(setupPlanQueryKey(sshHost), plan),
+ onError: (error) => log.error('Remote host setup run failed', { sshHost, error }),
+ });
+}
+
+export function useSkipSetupStep(sshHost: string) {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: (stepId: string) => rpc.remoteHosts.skipSetupStep({ sshHost, stepId }),
+ onSuccess: (plan) => queryClient.setQueryData(setupPlanQueryKey(sshHost), plan),
+ onError: (error) => log.error('Could not skip a setup step', { sshHost, error }),
+ });
+}
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
new file mode 100644
index 000000000..ba67f419b
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx
@@ -0,0 +1,205 @@
+/**
+ * A single remote host's page (CHOO-1809).
+ *
+ * A host is not a settings row — it has an ongoing lifecycle: reach it, work
+ * out what it needs, install those things one at a time, and later manage the
+ * 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.
+ */
+
+import { useQuery } from '@tanstack/react-query';
+import { ArrowLeft, Play, RefreshCw, RotateCcw } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect, 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 { 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 {
+ useHostSetupPlan,
+ usePrepareSetup,
+ useRunSetup,
+ useSkipSetupStep,
+} from '../setup/use-host-setup';
+import { REMOTE_HOSTS_QUERY_KEY } from './remote-hosts-view';
+
+function useSshHost(): string {
+ return useParams('remoteHost').params.sshHost;
+}
+
+export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
+ const sshHost = useSshHost();
+ const { navigate } = useNavigate();
+
+ const hosts = useQuery({
+ queryKey: REMOTE_HOSTS_QUERY_KEY,
+ queryFn: () => rpc.remoteHosts.listHosts(),
+ });
+ const host = hosts.data?.find((candidate) => candidate.sshHost === sshHost);
+
+ const plan = useHostSetupPlan(sshHost);
+ const prepare = usePrepareSetup(sshHost);
+ const run = useRunSetup(sshHost);
+ const skip = useSkipSetupStep(sshHost);
+
+ const [authenticatingGh, setAuthenticatingGh] = useState(false);
+ const reachability = hostReachabilityStore.get(sshHost);
+ const blocked = isHostBlocked(reachability);
+
+ useEffect(() => {
+ void hostReachabilityStore.hydrate();
+ }, []);
+
+ // Build the plan once the host is known to be reachable. Deliberately not on
+ // mount: probing a host the model already knows is down would only mislabel
+ // every prerequisite as missing.
+ const { mutate: startPrepare } = prepare;
+ const hasPlan = plan.data != null;
+ useEffect(() => {
+ if (blocked || plan.isLoading || hasPlan) return;
+ 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;
+
+ return (
+ <div className="space-y-8 px-8 pb-10">
+ <PageHeader
+ sticky
+ title={host?.name ?? sshHost}
+ description={`Remote host · ${sshHost}. Auth uses your SSH agent — switchdash stores no credentials.`}
+ >
+ <div className="flex items-center gap-2">
+ <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">
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={busy}
+ onClick={() => prepare.mutate()}
+ aria-label="Re-check this host"
+ >
+ <RefreshCw className={`size-3.5 ${prepare.isPending ? 'animate-spin' : ''}`} />
+ Re-check
+ </Button>
+ {!complete && (
+ <Button size="sm" disabled={busy} onClick={() => run.mutate()}>
+ {plan.data?.status === 'halted' ? (
+ <>
+ <RotateCcw className="size-3.5" /> {run.isPending ? 'Resuming…' : 'Resume'}
+ </>
+ ) : (
+ <>
+ <Play className="size-3.5" /> {run.isPending ? 'Running…' : 'Run setup'}
+ </>
+ )}
+ </Button>
+ )}
+ </div>
+ </div>
+
+ {/*
+ A run that stops because the host went away is reported as exactly
+ that, rather than being attributed to whichever step was next.
+ */}
+ {run.isError && (
+ <p className="text-destructive text-xs">{(run.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}
+ </p>
+ )}
+
+ {plan.isLoading ? (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner /> Loading setup…
+ </div>
+ ) : (
+ <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)}
+ />
+ )}
+
+ {/*
+ The GitHub device flow needs a real terminal the user types into, so
+ it runs inline rather than in a dialog — switchdash disables terminal
+ input while a dialog is open. Re-check on close so the step reflects
+ what actually happened rather than assuming it worked.
+ */}
+ {authenticatingGh && (
+ <GhAuthPanel
+ sshHost={sshHost}
+ onDone={() => {
+ setAuthenticatingGh(false);
+ prepare.mutate();
+ }}
+ />
+ )}
+
+ {complete && <p className="text-xs text-green-500">This host is ready to run agents.</p>}
+ </section>
+ )}
+ </div>
+ );
+});
+
+function RemoteHostTitlebar() {
+ const sshHost = useSshHost();
+ return <span className="text-sm text-foreground-muted">{sshHost}</span>;
+}
+
+export const remoteHostView = {
+ WrapView: ({ children }: { children: React.ReactNode; sshHost: string }) => <>{children}</>,
+ TitlebarSlot: RemoteHostTitlebar,
+ MainPanel: RemoteHostMainPanel,
+ canActivate: (params: unknown): GuardResult => {
+ // Params can come from a snapshot written by an older build, so validate
+ // rather than trust: a view with no host to show has nothing to render.
+ const sshHost =
+ typeof params === 'object' && params !== null
+ ? (params as { sshHost?: unknown }).sshHost
+ : undefined;
+ if (typeof sshHost !== 'string' || sshHost.length === 0) {
+ return { ok: false, redirect: 'remoteHosts' };
+ }
+ return { ok: true };
+ },
+} satisfies ViewDefinition<{ sshHost: string }>;
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
new file mode 100644
index 000000000..f9247ae60
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-hosts-view.tsx
@@ -0,0 +1,341 @@
+/**
+ * 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.
+ */
+
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { CheckCircle2, ChevronRight, Circle, Loader2, 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';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { rpc } from '@renderer/lib/ipc';
+import { useNavigate } from '@renderer/lib/layout/navigation-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 { log } from '@renderer/utils/logger';
+import { cn } from '@renderer/utils/utils';
+import { isHostBlocked } from '@shared/core/remote-hosts/reachability';
+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;
+
+/**
+ * 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.
+ */
+const HostStatus = observer(function HostStatus({
+ sshHost,
+ plan,
+}: {
+ sshHost: string;
+ plan: HostSetupPlan | null;
+}) {
+ const reachability = hostReachabilityStore.get(sshHost);
+
+ 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>
+ );
+});
+
+export const RemoteHostsMainPanel = observer(function RemoteHostsMainPanel() {
+ const queryClient = useQueryClient();
+ const { navigate } = useNavigate();
+
+ const { data: hosts, isLoading } = useQuery({
+ queryKey: REMOTE_HOSTS_QUERY_KEY,
+ queryFn: () => rpc.remoteHosts.listHosts(),
+ });
+ const list = useMemo(() => hosts ?? [], [hosts]);
+
+ const sshHosts = useMemo(() => list.map((host) => host.sshHost), [list]);
+ const plans = useAllHostSetupPlans(sshHosts);
+
+ useEffect(() => {
+ void hostReachabilityStore.hydrate();
+ }, []);
+
+ return (
+ <div className="space-y-8 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 });
+ }}
+ />
+ </PageHeader>
+
+ {isLoading ? (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner /> Loading hosts…
+ </div>
+ ) : list.length === 0 ? (
+ <p className="text-sm text-foreground-muted">
+ No remote hosts yet. Add one above to get started.
+ </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>
+ )}
+ </div>
+ );
+});
+
+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.
+ */
+function RemoveHostButton({
+ sshHost,
+ name,
+ onRemoved,
+}: {
+ sshHost: string;
+ name: string;
+ onRemoved: () => void;
+}) {
+ const [confirming, setConfirming] = useState(false);
+
+ const mutation = useMutation({
+ mutationFn: () => rpc.remoteHosts.removeHost(sshHost),
+ onError: (error) => log.error('Failed to remove remote host', { sshHost, error }),
+ onSuccess: () => {
+ setConfirming(false);
+ onRemoved();
+ },
+ });
+
+ if (!confirming) {
+ return (
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ aria-label={`Remove ${name}`}
+ onClick={() => setConfirming(true)}
+ >
+ <Trash2 className="size-4" />
+ </Button>
+ );
+ }
+
+ return (
+ <span className="flex items-center gap-1">
+ <span className="text-xs text-foreground-muted">Remove?</span>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={mutation.isPending}
+ onClick={() => setConfirming(false)}
+ >
+ No
+ </Button>
+ <Button
+ size="sm"
+ variant="destructive"
+ disabled={mutation.isPending}
+ onClick={() => mutation.mutate()}
+ >
+ {mutation.isPending ? 'Removing…' : 'Remove'}
+ </Button>
+ </span>
+ );
+}
+
+export const remoteHostsView = {
+ MainPanel: RemoteHostsMainPanel,
+} satisfies ViewDefinition;
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx
index d712ae002..4787302de 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx
@@ -2,7 +2,6 @@ import React, { useCallback } from 'react';
import { PageHeader } from '@renderer/lib/components/page-header';
import { PageContent, PageLayout, PageSidebarMenu } from '@renderer/lib/components/page-layout';
import { rpc } from '@renderer/lib/ipc';
-import { RemoteHostsSettingsPage } from '../../remote-hosts/RemoteHostsSettingsPage';
import { AgentsSettingsPage } from '../agents-page/AgentsSettingsPage';
import HiddenToolsSettingsCard from './HiddenToolsSettingsCard';
import InterfaceSettingsCard from './InterfaceSettingsCard';
@@ -27,7 +26,6 @@ export type SettingsPageTab =
| 'clis-models'
| 'integrations'
| 'connections'
- | 'remote-hosts'
| 'browser'
| 'interface'
| 'docs';
@@ -104,7 +102,6 @@ export function SettingsPage({
// switchdash v0 hides Account, Integrations, Connections (SSH), and Browser tabs.
{ id: 'general', label: 'General' },
{ id: 'clis-models', label: 'Agents' },
- { id: 'remote-hosts', label: 'Remote hosts' },
{ id: 'interface', label: 'Interface' },
{ id: 'docs', label: 'Docs', isExternal: true },
];
@@ -112,7 +109,6 @@ export function SettingsPage({
const tabContent: Record<string, React.ReactNode> = {
general: <GeneralSettingsPage />,
'clis-models': <AgentsSettingsPage />,
- 'remote-hosts': <RemoteHostsSettingsPage />,
interface: <InterfaceSettingsPage />,
};
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/settings-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/settings-view.tsx
index 15fb5ab41..fbd88250c 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/settings-view.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/settings/settings-view.tsx
@@ -1,4 +1,5 @@
import { createContext, useCallback, useContext, type ReactNode } from 'react';
+import type { GuardResult } from '@renderer/app/view-registry';
import {
SettingsPage,
type SettingsPageTab,
@@ -64,4 +65,15 @@ export function SettingsMainPanel() {
export const settingsView = {
WrapView: SettingsViewWrapper,
MainPanel: SettingsMainPanel,
+ /**
+ * Remote hosts moved out of Settings to their own view (CHOO-1809). A
+ * persisted snapshot from an older build can still name that tab, which would
+ * otherwise render Settings with nothing selected — send it to the new view.
+ */
+ canActivate: (params: unknown): GuardResult => {
+ const tab =
+ typeof params === 'object' && params !== null ? (params as { tab?: unknown }).tab : undefined;
+ if (tab === 'remote-hosts') return { ok: false, redirect: 'remoteHosts' };
+ return { ok: true };
+ },
};
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/left-sidebar.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/left-sidebar.tsx
index 03a3a5998..c13768392 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/left-sidebar.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/left-sidebar.tsx
@@ -1,4 +1,4 @@
-import { FolderInput, Settings } from 'lucide-react';
+import { FolderInput, Server, Settings } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import React from 'react';
import {
@@ -66,6 +66,20 @@ export const LeftSidebar: React.FC = observer(function LeftSidebar() {
<SidebarFooter>
<SidebarMenu>
<SidebarSearchTrigger />
+ <SidebarMenuButton
+ isActive={
+ isCurrentView(currentView, 'remoteHosts') ||
+ isCurrentView(currentView, 'remoteHost')
+ }
+ onClick={() => navigate('remoteHosts')}
+ aria-label="Remote hosts"
+ className="w-full justify-between"
+ >
+ <span className="flex items-center gap-2">
+ <Server className="h-5 w-5 sm:h-4 sm:w-4" />
+ Remote hosts
+ </span>
+ </SidebarMenuButton>
<SidebarMenuButton
isActive={isCurrentView(currentView, 'settings')}
onClick={() => navigate('settings')}