Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(switchdash): rebuild stale plans, explain 127 installs, move the back link (CHOO-1809)
Louis Amaudruz273c95de2bb3
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.test.tsindex 3e5070be9..9c0ef9b81 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.test.ts@@ -58,8 +58,9 @@ vi.mock('@main/core/dependencies/install-output', () => ({}));import type { HostDependencyManager } from '@switchdash/core/deps/runtime';-import type { HostSetupStep } from '@shared/core/remote-hosts/setup';-import { checkStep } from './host-setup-service';+import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';+import { checkStep, readAllSetupPlans } from './host-setup-service';+import { listSetupPlans, saveSetupPlan } from './setup-plan-store';const SSH_HOST = 'dev-vm';@@ -232,3 +233,73 @@ describe('checking a core-dependency step', () => {expect(mocks.checkForUpdates).not.toHaveBeenCalled();});});++/**+ * A persisted plan is a record of progress, not a fixed roster (CHOO-1809).+ *+ * Reported from a real host: Codex was absent from one host's page and present+ * on another. The plan had been built before Codex shipped, and nothing ever+ * rebuilt it — the page only built a plan when none existed at all. Worse than+ * the missing row: a *missing* step reads as no objection, so the readiness+ * verdict called that host fine for an agent type it had never looked for.+ */+describe('readAllSetupPlans', () => {+ function persisted(steps: HostSetupStep[]): HostSetupPlan {+ return {+ sshHost: 'dev-vm',+ status: 'idle',+ steps,+ currentStepId: null,+ createdAt: '2026-01-01T00:00:00.000Z',+ updatedAt: '2026-01-01T00:00:00.000Z',+ };+ }++ const claudeCli = step({+ id: 'claude',+ kind: 'agent-cli',+ name: 'Claude Code',+ state: 'satisfied',+ outcome: 'satisfied',+ version: '2.1.221',+ dependsOn: ['node'],+ });++ it('adds a step for an agent type that shipped after the plan was built', async () => {+ vi.mocked(listSetupPlans).mockResolvedValue([persisted([claudeCli])]);++ const [plan] = await readAllSetupPlans();++ expect(plan!.steps.some((s) => s.id === 'codex')).toBe(true);+ });++ it('keeps what was already known about the steps that survive', async () => {+ vi.mocked(listSetupPlans).mockResolvedValue([persisted([claudeCli])]);++ const [plan] = await readAllSetupPlans();+ const claude = plan!.steps.find((s) => s.id === 'claude');++ expect(claude).toMatchObject({ state: 'satisfied', version: '2.1.221' });+ });++ it('persists the new shape, so the next read is not a rebuild again', async () => {+ vi.mocked(listSetupPlans).mockResolvedValue([persisted([claudeCli])]);++ await readAllSetupPlans();++ expect(saveSetupPlan).toHaveBeenCalledTimes(1);+ });++ it('writes nothing when the step set is already current', async () => {+ // The common case. Rebuilding costs no SSH, but it must not turn every read+ // into a write and a push to the renderer.+ vi.mocked(listSetupPlans).mockResolvedValue([persisted([claudeCli])]);+ const [rebuilt] = await readAllSetupPlans();+ vi.mocked(saveSetupPlan).mockClear();+ vi.mocked(listSetupPlans).mockResolvedValue([rebuilt!]);++ await readAllSetupPlans();++ expect(saveSetupPlan).not.toHaveBeenCalled();+ });+});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.tsindex 582dd3d33..9a688f9dc 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@@ -93,12 +93,56 @@ export async function ensureSetupPlan(sshHost: string): Promise<HostSetupPlan> {}/**- * Every host's persisted plan. Feeds the renderer store that the sidebar and- * the agent-creation gate read — both need readiness for hosts whose page- * nobody has opened.+ * Every host's plan, with its step *set* brought up to date first.+ *+ * Feeds the renderer store that the sidebar and the agent-creation gate read —+ * both need readiness for hosts whose page nobody has opened.+ *+ * Which steps a plan has is derived from the local plugin registry and costs no+ * SSH, so it can be recomputed freely; only the states are the host's business,+ * and those merge forward. Reading the persisted plan verbatim meant a host+ * onboarded before an agent type shipped had no step for it — and a *missing*+ * step reads as no objection, so the sidebar called that host ready for an+ * agent type it had never once looked for.+ *+ * Only writes when the set of steps actually changed, so the common case is a+ * plain read.*/export async function readAllSetupPlans(): Promise<HostSetupPlan[]> {- return await listSetupPlans();+ const persisted = await listSetupPlans();+ const now = new Date().toISOString();+ const coreDependencies = CORE_DEPENDENCIES.map((dep) => ({ id: dep.id, name: dep.name }));+ const agentTypes = plannableAgentTypes();++ const plans: HostSetupPlan[] = [];+ for (const existing of persisted) {+ const rebuilt = buildSetupPlan({+ sshHost: existing.sshHost,+ coreDependencies,+ agentTypes,+ existing,+ now,+ });+ if (sameStepIds(existing, rebuilt)) {+ plans.push(existing);+ continue;+ }+ log.info('[HostSetup] plan gained or lost steps; persisting the new shape', {+ event: 'host-setup-plan-reshaped',+ sshHost: existing.sshHost,+ before: existing.steps.length,+ after: rebuilt.steps.length,+ });+ await saveSetupPlan(rebuilt);+ events.emit(hostSetupPlanEventChannel, rebuilt);+ plans.push(rebuilt);+ }+ return plans;+}++function sameStepIds(a: HostSetupPlan, b: HostSetupPlan): boolean {+ if (a.steps.length !== b.steps.length) return false;+ return a.steps.every((step, index) => step.id === b.steps[index]!.id);}/** The persisted plan, without rebuilding it. Null when the host has never run setup. */diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.tsindex e3e464fa9..ea3e30d21 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts@@ -18,6 +18,7 @@import {agentPluginStepId,+ isStepInFlight,type HostSetupPlan,type HostSetupStep,type HostSetupStepKind,@@ -152,20 +153,18 @@ function mergeSteps(fresh: HostSetupStep[], previous: HostSetupStep[]): HostSetu/*** Reset a plan's transient states so the next look re-observes rather than- * trusting what a previous process was mid-way through. Anything left- * `checking` or `installing` when the app died is of unknown truth — the one- * thing it must not become is `satisfied`.+ * trusting what a previous process was mid-way through. Anything left in flight+ * when the app died is of unknown truth — the one thing it must not become is+ * `satisfied`.*/export function reconcileInterruptedPlan(plan: HostSetupPlan, now: string): HostSetupPlan {- const interrupted = plan.steps.some(- (step) => step.state === 'checking' || step.state === 'installing'- );+ const interrupted = plan.steps.some(isStepInFlight);if (!interrupted) return plan;return {...plan,steps: plan.steps.map((step) =>- step.state === 'checking' || step.state === 'installing'+ isStepInFlight(step)? {...step,state: 'pending',diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.tsindex fa8231f23..ffb7cd981 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts@@ -162,3 +162,69 @@ describe('condenseCommandOutput', () => {expect(condenseCommandOutput('line one\nline two')).toBe('line one\nline two');});});++/**+ * An install that never ran because its own toolchain is absent (CHOO-1809).+ *+ * The report that prompted this: installing Codex on a host printed the host's+ * login banner in ASCII art followed by `npm: command not found`, and that whole+ * blob was the error. Nothing in it says the host is missing npm, and nothing+ * distinguishes it from Codex itself being broken.+ */+describe('describeInstallFailure — the install command could not run', () => {+ const banner = [+ ' ____ _ ',+ ' / ___| __ _ _ __ | |',+ 'alg-bench-debian-12-v260624',+ '/bin/bash: line 1: npm: command not found',+ ].join('\n');++ it('names the missing tool rather than echoing the transcript', () => {+ const message = describeInstallFailure('Codex', 'Install command failed.', banner);++ expect(message).toContain('npm');+ expect(message).toContain('was not found on the host');+ });++ it('says the host was left alone, because it was', () => {+ const message = describeInstallFailure('Codex', 'Install command failed.', banner);++ expect(message).toContain('Nothing was changed');+ });++ it('explains where npm comes from, since a working node implies it', () => {+ // The confusing part of this failure is that Node.js reads "Installed" on+ // the same page. Saying only "npm is missing" invites the reply "but Node+ // is right there".+ const message = describeInstallFailure('Codex', 'Install command failed.', banner);++ expect(message).toContain('Node.js');+ });++ it('handles a tool other than npm without inventing advice for it', () => {+ const message = describeInstallFailure(+ 'Something',+ 'Install command failed.',+ '/bin/sh: 1: curl: command not found'+ );++ expect(message).toContain('curl');+ expect(message).not.toContain('Node.js');+ });++ it('leaves an ordinary failure message alone', () => {+ expect(describeInstallFailure('Git', 'Disk full.', 'no space left on device')).toBe(+ 'Disk full.'+ );+ });++ it('still prefers the lock diagnosis when both could match', () => {+ const message = describeInstallFailure(+ 'Git',+ 'Install command failed.',+ 'E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4242\nfoo: command not found'+ );++ expect(message).toContain('package manager lock');+ });+});diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.tsindex 4c317aa74..42330f903 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts@@ -65,6 +65,20 @@ const PACKAGE_MANAGER_BUSY =/** The pid apt names as the lock holder, when it names one. */const LOCK_HOLDER_PID = /held by process (\d+)/i;+/**+ * A shell reporting that the install command's own tool does not exist.+ *+ * Matches the shell's wording rather than the exit code: 127 is also what some+ * installers return for their own reasons, and the message is the thing that+ * identifies *which* tool is missing.+ */+const COMMAND_NOT_FOUND = /(?:^|[\n:])\s*([\w.+-]+): command not found/im;++/** Tools we can say something useful about beyond "it is missing". */+const TOOLCHAIN_HINTS: Record<string, string> = {+ npm: 'npm ships with Node.js — a Node install that reports a version but has no npm is usually a partial one (on Debian/Ubuntu the distro splits `nodejs` and `npm` into separate packages). Re-installing Node.js from the Node.js step generally fixes it.',+};+/*** Explain why an install failed, in terms the user can act on.*@@ -89,6 +103,19 @@ export function describeInstallFailure(const holder = pid ? ` (pid ${pid})` : '';return `Could not install ${name}: another process${holder} on the host holds the package manager lock. That is usually the system's own automatic updates, which clear within a few minutes — but it can also be an earlier install left stuck, which will not clear on its own. If retrying keeps failing with the same pid, check that process on the host.`;}++ // The install never started: the tool that runs it is not there. Left raw,+ // this reaches the user as a screen of login banner ending in+ // "npm: command not found", which reads as the agent being broken rather+ // than as a gap in the host's toolchain.+ const missing = COMMAND_NOT_FOUND.exec(output ?? '')?.[1] ?? COMMAND_NOT_FOUND.exec(message)?.[1];+ if (missing) {+ const hint = TOOLCHAIN_HINTS[missing];+ return `Could not install ${name}: \`${missing}\` was not found on the host, so the install command could not run.${+ hint ? ` ${hint}` : ''+ } Nothing was changed on the host.`;+ }+return message;}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsxindex b506009e5..77de73042 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@@ -84,15 +84,22 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {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.+ // Rebuild the plan whenever the page opens, not only when none exists.+ //+ // Which steps a plan *has* comes from the local plugin registry and costs no+ // SSH at all; only their states come from the host, and those are merged+ // forward. Building only when the plan was absent meant a host onboarded+ // before an agent type shipped never grew a row for it — Codex was simply+ // missing from that host's page for good, while appearing on hosts added+ // later. Rebuilding is free, so there is no reason to skip it.+ //+ // Still gated on reachability: 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;+ if (blocked || plan.isLoading) return;startPrepare();- }, [blocked, plan.isLoading, hasPlan, startPrepare]);+ }, [blocked, plan.isLoading, startPrepare]);const status = deriveHostStatus(reachability, plan.data ?? null);const { prerequisites, agentTypes } = useMemo(@@ -150,6 +157,16 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {stickytitle={host?.name ?? sshHost}description={`Remote host · ${sshHost}. Auth uses your SSH agent — switchdash stores no credentials.`}+ back={+ <Button+ size="sm"+ variant="ghost"+ className="-ml-2"+ onClick={() => navigate('remoteHosts')}+ >+ <ArrowLeft className="size-4" /> All hosts+ </Button>+ }><div className="flex items-center gap-2">{!blocked && (@@ -162,9 +179,6 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {)}</span>)}- <Button size="sm" variant="ghost" onClick={() => navigate('remoteHosts')}>- <ArrowLeft className="size-4" /> All hosts- </Button>{!blocked && (<Buttonsize="sm"diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/components/page-header.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/components/page-header.tsxindex c89d806d4..c894566a7 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/components/page-header.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/lib/components/page-header.tsx@@ -4,16 +4,26 @@ export function PageHeader({title,description,children,+ back,sticky = false,}: {title: string;description?: string;children?: React.ReactNode;+ /**+ * Navigation out of this page, rendered above the title at the top left.+ *+ * Kept out of `children`: those are the page's *actions*, and a way back is+ * not one — sitting it among them put "All hosts" in the middle of a row of+ * buttons that act on the host you are looking at.+ */+ back?: React.ReactNode;sticky?: boolean;}) {const body = (<div className="flex flex-col gap-6"><div className="flex flex-col gap-1 [-webkit-app-region:drag]">+ {back && <div className="mb-1 flex [-webkit-app-region:no-drag]">{back}</div>}<h2 className="text-xl">{title}</h2><p className="text-sm text-foreground-muted">{description}</p></div>