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): remove the whole-plan run; setup is one click per thing (CHOO-1809)

switch-worker-louis-remote380bb2e72713
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 5a1912bd0..033e58cb3 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
@@ -33,7 +33,6 @@ import {
readAllSetupPlans,
readSetupPlan,
recheckSetup,
- runSetup,
skipSetupStep,
} from './setup/host-setup-service';
import { listRemoteHosts, removeRemoteHost, upsertRemoteHost, type RemoteHost } from './store';
@@ -216,13 +215,6 @@ export const remoteHostsController = createRPCController({
/** Probe every step and install nothing — the "Re-check" button. */
recheckSetup: (sshHost: string): Promise<HostSetupPlan> => recheckSetup(sshHost),
- /**
- * Run (or resume) setup. Steps are checked and installed one at a time and
- * the run halts at the first required failure, holding its position so it can
- * be resumed rather than restarted.
- */
- runSetup: (sshHost: string): Promise<HostSetupPlan> => runSetup(sshHost),
-
/** Install one prerequisite or agent type on its own, then verify it. */
installSetupStep: (params: { sshHost: string; stepId: string }): Promise<HostSetupPlan> =>
installSetupStep(params.sshHost, params.stepId),
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 85e7d5992..64b527f93 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
@@ -1,5 +1,9 @@
import { describe, expect, it, vi } from 'vitest';
-import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';
+import {
+ isPlanComplete,
+ type HostSetupPlan,
+ type HostSetupStep,
+} from '@shared/core/remote-hosts/setup';
import {
HostSetupAbortedError,
HostSetupRunner,
@@ -79,121 +83,57 @@ function makeRunner(harness: Harness) {
const stateOf = (p: HostSetupPlan, id: string) => p.steps.find((s) => s.id === id)!.state;
-describe('HostSetupRunner', () => {
- it('marks already-satisfied steps satisfied without installing', async () => {
+describe('installing one step', () => {
+ it('does not install something already there', async () => {
const { runner, installOrder } = makeRunner({
checks: { git: [{ outcome: 'satisfied', version: '2.43.0' }] },
installs: {},
});
- const result = await runner.run(plan([step('git')]));
+ const result = await runner.runSingleStep(plan([step('git')]), 'git');
- expect(result.status).toBe('complete');
expect(stateOf(result, 'git')).toBe('satisfied');
expect(installOrder).toEqual([]);
});
- it('installs a missing dependency and verifies it afterwards', async () => {
+ it('installs, then verifies by re-probing', async () => {
const { runner, installOrder } = makeRunner({
checks: { node: [{ outcome: 'missing' }, { outcome: 'satisfied', version: '22.0.0' }] },
installs: { node: { ok: true } },
});
- const result = await runner.run(plan([step('node')]));
+ const result = await runner.runSingleStep(plan([step('node')]), 'node');
expect(installOrder).toEqual(['node']);
expect(stateOf(result, 'node')).toBe('satisfied');
expect(result.steps[0]!.version).toBe('22.0.0');
- expect(result.status).toBe('complete');
});
- it('fails the step when an install reports success but verification disagrees', async () => {
+ it('fails when an install reports success but verification disagrees', async () => {
// The installer's exit code is a claim; only the re-check is evidence.
const { runner } = makeRunner({
checks: { node: [{ outcome: 'missing' }, { outcome: 'missing' }] },
installs: { node: { ok: true } },
});
- const result = await runner.run(plan([step('node')]));
+ const result = await runner.runSingleStep(plan([step('node')]), 'node');
expect(stateOf(result, 'node')).toBe('failed');
expect(result.steps[0]!.error).toContain('still reports "missing" after installing');
- expect(result.status).toBe('halted');
});
- it('installs strictly one at a time, in plan order', async () => {
- const { runner, installOrder, inFlight } = makeRunner({
- checks: {
- git: [{ outcome: 'missing' }, { outcome: 'satisfied' }],
- node: [{ outcome: 'missing' }, { outcome: 'satisfied' }],
- tmux: [{ outcome: 'missing' }, { outcome: 'satisfied' }],
- },
- installs: {},
- });
-
- await runner.run(plan([step('git'), step('node'), step('tmux')]));
-
- expect(installOrder).toEqual(['git', 'node', 'tmux']);
- expect(inFlight.max).toBe(1);
- });
-
- it('halts on failure, keeps earlier progress, and blocks later steps', async () => {
- const { runner, installOrder } = makeRunner({
- checks: {
- git: [{ outcome: 'satisfied' }],
- node: [{ outcome: 'missing' }],
- tmux: [{ outcome: 'missing' }],
- },
- installs: { node: { ok: false, error: 'apt-get failed', output: 'E: Unable to locate' } },
- });
-
- const result = await runner.run(plan([step('git'), step('node'), step('tmux')]));
-
- expect(result.status).toBe('halted');
- expect(stateOf(result, 'git')).toBe('satisfied'); // step 1 is not discarded
- expect(stateOf(result, 'node')).toBe('failed');
- expect(stateOf(result, 'tmux')).toBe('blocked'); // never attempted, and says so
- expect(installOrder).toEqual(['node']); // stopped; tmux was not installed
- expect(result.currentStepId).toBe('node');
- });
-
- it('preserves the failing step error and command output', async () => {
+ it("preserves the installer's own error and command output", async () => {
const { runner } = makeRunner({
checks: { node: [{ outcome: 'missing' }] },
installs: { node: { ok: false, error: 'permission denied', output: 'sudo: no tty' } },
});
- const result = await runner.run(plan([step('node')]));
+ const result = await runner.runSingleStep(plan([step('node')]), 'node');
expect(result.steps[0]!.error).toBe('permission denied');
expect(result.steps[0]!.output).toBe('sudo: no tty');
});
- it('resumes from the failed step without redoing satisfied ones', async () => {
- // Each runner gets its own check queues — sharing them would let the first
- // run consume the second's answers and hide whether resume really re-probes.
- const first = makeRunner({
- checks: { git: [{ outcome: 'satisfied' }], node: [{ outcome: 'missing' }] },
- installs: { node: { ok: false, error: 'transient' } },
- });
- const halted = await first.runner.run(plan([step('git'), step('node')]));
- expect(halted.status).toBe('halted');
-
- // Resume with the persisted plan, exactly as a restart would. node is still
- // missing, so it must be re-attempted; git is satisfied and must not be.
- const second = makeRunner({
- checks: {
- git: [{ outcome: 'satisfied' }],
- node: [{ outcome: 'missing' }, { outcome: 'satisfied' }],
- },
- installs: { node: { ok: true } },
- });
- const resumed = await second.runner.run(halted);
-
- expect(resumed.status).toBe('complete');
- expect(second.installOrder).toEqual(['node']); // git was not re-installed
- });
-
it('records unknown — never missing — when a probe throws', async () => {
const runner = new HostSetupRunner({
sshHost: 'dev-vm',
@@ -209,156 +149,123 @@ describe('HostSetupRunner', () => {
now: () => new Date('2026-02-02T00:00:00.000Z'),
});
- const result = await runner.run(plan([step('docker')]));
+ const result = await runner.runSingleStep(plan([step('docker')]), 'docker');
expect(result.steps[0]!.outcome).toBe('unknown');
- expect(result.steps[0]!.state).toBe('failed');
- expect(result.steps[0]!.error).toContain('ssh channel closed');
+ expect(stateOf(result, 'docker')).toBe('failed');
});
- it('never reports an unverifiable step as satisfied', async () => {
- const { runner } = makeRunner({
- checks: { docker: [{ outcome: 'unknown', error: 'could not tell' }] },
- installs: {},
- });
-
- const result = await runner.run(plan([step('docker')]));
-
- expect(stateOf(result, 'docker')).not.toBe('satisfied');
- expect(result.status).toBe('halted');
- });
-
- it('does not try to install a dependency that is installed but not running', async () => {
+ it('does not run an installer over a service that is merely stopped', async () => {
const { runner, installOrder } = makeRunner({
checks: { docker: [{ outcome: 'not-running' }] },
installs: {},
});
- const result = await runner.run(plan([step('docker')]));
+ const result = await runner.runSingleStep(plan([step('docker')]), 'docker');
expect(installOrder).toEqual([]);
expect(result.steps[0]!.error).toContain('not running');
});
- it('reports "no install command" rather than silently stalling', async () => {
+ it('says there is no install command rather than silently stalling', async () => {
const { runner } = makeRunner({
- checks: { docker: [{ outcome: 'missing' }] },
+ checks: { tmux: [{ outcome: 'missing' }] },
installs: {},
canInstall: () => false,
});
- const result = await runner.run(plan([step('docker')]));
+ const result = await runner.runSingleStep(plan([step('tmux')]), 'tmux');
- expect(result.steps[0]!.state).toBe('failed');
+ expect(stateOf(result, 'tmux')).toBe('failed');
expect(result.steps[0]!.error).toContain('no install command');
});
- it('continues past a failed optional step', async () => {
+ it('clears a previous error when the step is retried', async () => {
const { runner } = makeRunner({
- checks: { gh: [{ outcome: 'missing' }], node: [{ outcome: 'satisfied' }] },
- installs: { gh: { ok: false, error: 'nope' } },
+ checks: { node: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
+ installs: { node: { ok: true } },
});
- const result = await runner.run(plan([step('gh', { optional: true }), step('node')]));
+ const result = await runner.runSingleStep(
+ plan([step('node', { state: 'failed', error: 'apt-get failed', output: 'E: broken' })]),
+ 'node'
+ );
- expect(stateOf(result, 'gh')).toBe('failed');
expect(stateOf(result, 'node')).toBe('satisfied');
- expect(result.status).toBe('complete'); // optional failure does not block the host
+ expect(result.steps[0]!.error).toBeNull();
+ expect(result.steps[0]!.output).toBeNull();
});
- it('skipping unblocks the rest of the plan but is not satisfied', async () => {
+ it('leaves every other step untouched', async () => {
const { runner } = makeRunner({
- checks: { node: [{ outcome: 'missing' }], tmux: [{ outcome: 'satisfied' }] },
- installs: { node: { ok: false, error: 'nope' } },
+ checks: { git: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
+ installs: { git: { ok: true } },
});
- const halted = await runner.run(plan([step('node'), step('tmux')]));
- expect(stateOf(halted, 'tmux')).toBe('blocked');
-
- const skipped = await runner.skip(halted, 'node');
+ const result = await runner.runSingleStep(
+ plan([step('git'), step('node'), step('tmux', { state: 'satisfied' })]),
+ 'git'
+ );
- expect(stateOf(skipped, 'node')).toBe('skipped');
- expect(stateOf(skipped, 'tmux')).toBe('pending'); // unblocked
- expect(skipped.steps.find((s) => s.id === 'node')!.outcome).not.toBe('satisfied');
+ expect(stateOf(result, 'node')).toBe('pending');
+ expect(stateOf(result, 'tmux')).toBe('satisfied');
});
- it('aborts as unreachable instead of blaming a dependency', async () => {
- const { runner, installOrder } = makeRunner({
- checks: { node: [{ outcome: 'missing' }] },
- installs: {},
- reachable: false,
+ it('refuses to interleave with another operation on the same host', async () => {
+ const { runner } = makeRunner({
+ checks: { git: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
+ installs: { git: { ok: true } },
});
+ const p = plan([step('git')]);
- await expect(runner.run(plan([step('node')]))).rejects.toBeInstanceOf(HostSetupAbortedError);
- expect(installOrder).toEqual([]);
+ const [first, second] = await Promise.allSettled([
+ runner.runSingleStep(p, 'git'),
+ runner.runSingleStep(p, 'git'),
+ ]);
+
+ expect([first!.status, second!.status].sort()).toEqual(['fulfilled', 'rejected']);
});
it('persists and publishes every transition', async () => {
const { runner, saved, published } = makeRunner({
- checks: { node: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
- installs: { node: { ok: true } },
+ checks: { git: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
+ installs: { git: { ok: true } },
});
- await runner.run(plan([step('node')]));
+ await runner.runSingleStep(plan([step('git')]), 'git');
- // running → checking → observed → installing → checking → satisfied → complete
- expect(saved.length).toBeGreaterThanOrEqual(6);
+ expect(saved.length).toBeGreaterThan(1);
expect(published.length).toBe(saved.length);
- expect(saved.at(-1)!.status).toBe('complete');
});
- it('refuses a second concurrent run for the same host', async () => {
- const { runner } = makeRunner({
- checks: { node: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
- installs: { node: { ok: true } },
- });
- const p = plan([step('node')]);
+ it('aborts as unreachable instead of blaming a dependency', async () => {
+ const { runner } = makeRunner({ checks: {}, installs: {}, reachable: false });
- const first = runner.run(p);
- await expect(runner.run(p)).rejects.toThrow('already in progress');
- await first;
+ await expect(runner.runSingleStep(plan([step('git')]), 'git')).rejects.toBeInstanceOf(
+ HostSetupAbortedError
+ );
});
+});
- it('stops mid-run when the host drops', async () => {
- const harness: Harness = {
- checks: { git: [{ outcome: 'satisfied' }], node: [{ outcome: 'missing' }] },
- installs: {},
- };
- const reachable = { value: true };
- const runner = new HostSetupRunner({
- sshHost: 'dev-vm',
- load: async () => null,
- save: async () => {},
- publish: () => {},
- check: async (s) => harness.checks[s.id]![0]!,
- install: async () => ({ ok: true }),
- canInstall: () => true,
- requireReachable: () => {
- if (!reachable.value) throw new Unreachable('dropped');
- reachable.value = false; // drops after the first step
- },
- now: () => new Date('2026-02-02T00:00:00.000Z'),
- });
+describe('skipping', () => {
+ it('is never reported as satisfied', async () => {
+ const { runner } = makeRunner({ checks: {}, installs: {} });
- await expect(runner.run(plan([step('git'), step('node')]))).rejects.toBeInstanceOf(
- HostSetupAbortedError
- );
+ const result = await runner.skip(plan([step('gh'), step('node')]), 'gh');
+
+ expect(stateOf(result, 'gh')).toBe('skipped');
+ expect(isPlanComplete(result)).toBe(false);
});
- it('clears a previous error when a step is retried', async () => {
- const { runner } = makeRunner({
- checks: { node: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
- installs: { node: { ok: true } },
- });
- const failed = plan([
- step('node', { state: 'failed', error: 'old failure', output: 'old output' }),
- ]);
+ it('completes the plan when the last outstanding step is optional and skipped', async () => {
+ const { runner } = makeRunner({ checks: {}, installs: {} });
- const result = await runner.run(failed);
+ const result = await runner.skip(
+ plan([step('node', { state: 'satisfied' }), step('gh', { optional: true })]),
+ 'gh'
+ );
- expect(stateOf(result, 'node')).toBe('satisfied');
- expect(result.steps[0]!.error).toBeNull();
- expect(result.steps[0]!.output).toBeNull();
+ expect(result.status).toBe('complete');
});
});
@@ -459,40 +366,10 @@ describe('checkAll — looking without touching', () => {
});
});
-describe('runSingleStep — installing one thing on its own', () => {
- it('installs and verifies just that step, leaving the rest alone', async () => {
- const { runner, installOrder } = makeRunner({
- checks: {
- git: [{ outcome: 'missing' }, { outcome: 'satisfied', version: '2.43.0' }],
- node: [{ outcome: 'missing' }],
- },
- installs: { git: { ok: true } },
- });
-
- const result = await runner.runSingleStep(plan([step('git'), step('node')]), 'git');
-
- expect(installOrder).toEqual(['git']);
- expect(stateOf(result, 'git')).toBe('satisfied');
- expect(stateOf(result, 'node')).toBe('pending');
- });
-
- it('does not mark it satisfied when the install cannot be verified', async () => {
- const { runner } = makeRunner({
- checks: { git: [{ outcome: 'missing' }, { outcome: 'missing' }] },
- installs: { git: { ok: true } },
- });
-
- const result = await runner.runSingleStep(plan([step('git')]), 'git');
-
- expect(stateOf(result, 'git')).toBe('failed');
- });
-
+describe('plan completion', () => {
it('reports the plan complete once the last outstanding step is installed', async () => {
const { runner } = makeRunner({
- checks: {
- git: [{ outcome: 'missing' }, { outcome: 'satisfied' }],
- node: [{ outcome: 'satisfied' }],
- },
+ checks: { git: [{ outcome: 'missing' }, { outcome: 'satisfied' }] },
installs: { git: { ok: true } },
});
@@ -503,14 +380,6 @@ describe('runSingleStep — installing one thing on its own', () => {
expect(result.status).toBe('complete');
});
-
- it('refuses on an unreachable host rather than reporting an install failure', async () => {
- const { runner } = makeRunner({ checks: {}, installs: {}, reachable: false });
-
- await expect(runner.runSingleStep(plan([step('git')]), 'git')).rejects.toBeInstanceOf(
- HostSetupAbortedError
- );
- });
});
describe('gh-auth steps', () => {
@@ -524,7 +393,7 @@ describe('gh-auth steps', () => {
canInstall: () => false,
});
- const result = await runner.run(plan([ghStep()]));
+ const result = await runner.runSingleStep(plan([ghStep()]), 'gh:auth');
expect(installOrder).toEqual([]);
expect(result.steps[0]!.error).toMatch(/Use Sign in to start it/);
@@ -544,7 +413,7 @@ describe('gh-auth steps', () => {
canInstall: () => false,
});
- const result = await runner.run(plan([ghStep()]));
+ const result = await runner.runSingleStep(plan([ghStep()]), 'gh:auth');
expect(result.steps[0]!.state).toBe('failed');
expect(result.steps[0]!.error).toMatch(
@@ -559,7 +428,7 @@ describe('runner determinism', () => {
const original = plan([step('git')]);
const snapshot = structuredClone(original);
- await runner.run(original);
+ await runner.runSingleStep(original, 'git');
expect(original).toEqual(snapshot);
});
@@ -568,7 +437,7 @@ describe('runner determinism', () => {
const { runner } = makeRunner({ checks: { git: [{ outcome: 'satisfied' }] }, installs: {} });
vi.useFakeTimers();
- const result = await runner.run(plan([step('git')]));
+ const result = await runner.runSingleStep(plan([step('git')]), 'git');
expect(result.steps[0]!.updatedAt).toBe('2026-02-02T00:00:00.000Z');
vi.useRealTimers();
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 03109e7f2..a011f1067 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
@@ -1,24 +1,21 @@
/**
- * Sequential, resumable setup runner for a remote host (CHOO-1809).
+ * Setup operations for a remote host (CHOO-1809).
*
- * Runs a host's setup plan one step at a time, persisting after every
- * transition so a run survives the app closing mid-install. Three rules drive
- * the design:
+ * Every operation here is one the user asked for explicitly: check everything,
+ * install this one thing, skip this one thing. There is deliberately no
+ * run-the-whole-plan loop — the ordering in a plan is guidance for a person,
+ * not a script. Three rules drive the design:
*
- * 1. **One step in flight.** Dependencies install one after another, in order,
- * never concurrently — the old page fired every probe and install
- * independently and left the user to guess the sequence.
- * 2. **Halt on failure, hold position.** A failed required step stops the run.
- * Steps already satisfied stay satisfied, the failure keeps its error and
- * command output, and untried steps become `blocked` rather than being
- * discarded. Resuming re-attempts the failure; it does not start over.
+ * 1. **One thing at a time.** Nothing runs concurrently against a host; a
+ * second request while one is in flight is refused rather than interleaved.
+ * The old page fired every probe and install independently and left the user
+ * to guess the sequence.
+ * 2. **Verification is explicit.** After an install we re-check rather than
+ * assuming the installer worked. A step is only `satisfied` on the strength
+ * of a fresh observation — an exit code is a claim.
* 3. **Reachability is not a dependency verdict.** The reachability gate is
- * consulted before any probing, and an unreachable host aborts the run as
+ * consulted before any probing, and an unreachable host aborts as
* *unreachable* instead of reporting every prerequisite as missing.
- *
- * Verification is explicit: after an install we re-check rather than assuming
- * the installer worked. A step is only `satisfied` on the strength of a fresh
- * observation.
*/
import {
@@ -27,7 +24,6 @@ import {
type DependencyCheckOutcome,
type HostSetupPlan,
type HostSetupStep,
- type HostSetupStepState,
} from '@shared/core/remote-hosts/setup';
/** What a probe observed for one step. */
@@ -80,62 +76,11 @@ export class HostSetupRunner {
return (this.deps.now?.() ?? new Date()).toISOString();
}
- /**
- * Run (or resume) the plan. Returns as soon as the plan completes or halts.
- * Concurrent calls are rejected rather than interleaved — two runs against
- * one host would break the one-at-a-time guarantee.
- */
- async run(plan: HostSetupPlan): Promise<HostSetupPlan> {
- if (this.running) {
- throw new Error(`A setup run is already in progress for ${this.deps.sshHost}`);
- }
- this.running = true;
- try {
- return await this.drive(plan);
- } finally {
- this.running = false;
- }
- }
-
- private async drive(initial: HostSetupPlan): Promise<HostSetupPlan> {
- let plan = await this.transition(initial, { status: 'running' });
-
- for (const step of plan.steps) {
- if (step.state === 'satisfied' || step.state === 'skipped') continue;
-
- // Gate on reachability before every step, not just at the start: a host
- // can drop mid-run, and continuing would attribute the loss of the
- // transport to whichever dependency happened to be next in line.
- try {
- this.deps.requireReachable(this.deps.sshHost);
- } catch (error) {
- plan = await this.transition(plan, { status: 'halted' });
- throw new HostSetupAbortedError(
- `Setup for ${this.deps.sshHost} stopped: the host became unreachable.`,
- error
- );
- }
-
- plan = await this.runStep(plan, step.id);
- const current = findStep(plan, step.id);
-
- if (current.state === 'failed' && !current.optional) {
- return await this.haltAfter(plan, step.id);
- }
- }
-
- return await this.transition(plan, {
- status: isPlanComplete(plan) ? 'complete' : 'halted',
- currentStepId: null,
- });
- }
-
/**
* Observe every step, installing nothing — what "Re-check" means.
*
- * Without this the only way to learn a host's state was to press "Run setup",
- * which also installs; a user who just wanted to know where a host stood had
- * to risk changing it. A pass here records what is actually there and leaves
+ * A user who wants to know where a host stands should not have to change it
+ * to find out. A pass here records what is actually there and leaves
* unsatisfied steps `pending` — they carry their observed `outcome`, so the
* UI can say "not installed" rather than "not checked", without claiming an
* attempt was made.
@@ -145,7 +90,7 @@ export class HostSetupRunner {
*/
async checkAll(plan: HostSetupPlan): Promise<HostSetupPlan> {
if (this.running) {
- throw new Error(`A setup run is already in progress for ${this.deps.sshHost}`);
+ throw new Error(`Another setup operation is already running for ${this.deps.sshHost}`);
}
this.running = true;
try {
@@ -154,7 +99,7 @@ export class HostSetupRunner {
try {
this.deps.requireReachable(this.deps.sshHost);
} catch (error) {
- next = await this.transition(next, { status: 'halted', currentStepId: null });
+ next = await this.transition(next, { status: 'idle', currentStepId: null });
throw new HostSetupAbortedError(
`Could not check ${this.deps.sshHost}: the host became unreachable.`,
error
@@ -185,14 +130,13 @@ export class HostSetupRunner {
/**
* Install ONE step on its own — the per-item Install button.
*
- * The ordered run is the right default, but it is not the only thing a user
- * wants: seeing that git is missing and being offered only "run the whole
- * plan" is why this existed as a gap. Same discipline as a step inside a run
- * — reachability first, verify after — just without the rest of the plan.
+ * This is how setup happens: the user sees what a host is missing and fixes
+ * one thing. Reachability is checked first and the install is verified after,
+ * the same discipline the whole-plan run used to apply.
*/
async runSingleStep(plan: HostSetupPlan, stepId: string): Promise<HostSetupPlan> {
if (this.running) {
- throw new Error(`A setup run is already in progress for ${this.deps.sshHost}`);
+ throw new Error(`Another setup operation is already running for ${this.deps.sshHost}`);
}
this.running = true;
try {
@@ -290,25 +234,10 @@ export class HostSetupRunner {
});
}
- /** Mark the plan halted and block everything downstream of the failure. */
- private async haltAfter(plan: HostSetupPlan, failedStepId: string): Promise<HostSetupPlan> {
- const failedIndex = plan.steps.findIndex((s) => s.id === failedStepId);
- const steps = plan.steps.map((step, index) =>
- index > failedIndex && (step.state === 'pending' || step.state === 'blocked')
- ? { ...step, state: 'blocked' as HostSetupStepState, updatedAt: this.now() }
- : step
- );
- return await this.commit({
- ...plan,
- steps,
- status: 'halted',
- currentStepId: failedStepId,
- });
- }
-
/**
- * Move past a step the user has chosen not to fix. Unblocks the rest of the
- * plan so the run can continue, but is never reported as satisfied.
+ * Move past a step the user has chosen not to fix. Never reported as
+ * satisfied — skipping is a decision to live without something, not evidence
+ * that it is there.
*/
async skip(plan: HostSetupPlan, stepId: string): Promise<HostSetupPlan> {
const skipped = await this.patchStep(plan, stepId, {
@@ -316,10 +245,10 @@ export class HostSetupRunner {
error: null,
output: null,
});
- const steps = skipped.steps.map((step) =>
- step.state === 'blocked' ? { ...step, state: 'pending' as HostSetupStepState } : step
- );
- return await this.commit({ ...skipped, steps, status: 'idle' });
+ return await this.commit({
+ ...skipped,
+ status: isPlanComplete(skipped) ? 'complete' : 'idle',
+ });
}
private async patchStep(
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 9ea16c3dd..b83776d09 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
@@ -168,22 +168,6 @@ async function installStep(
};
}
-/** Run (or resume) a host's setup. Returns the plan as it stands when the run stops. */
-export async function runSetup(sshHost: string): Promise<HostSetupPlan> {
- const plan = await ensureSetupPlan(sshHost);
- const manager = await getRemoteDependencyManager(sshHost);
- try {
- return await runnerFor(sshHost, manager).run(plan);
- } catch (error) {
- log.warn('[HostSetup] run stopped', {
- event: 'host-setup-run-stopped',
- sshHost,
- error: String((error as Error)?.message ?? error),
- });
- throw error;
- }
-}
-
/**
* Observe a host without changing it — the "Re-check" button.
*
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts
index 0db8057bd..a5408ed3f 100644
--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts
@@ -83,7 +83,7 @@ describe('buildSetupPlan — rebuilding onto an existing plan', () => {
function existingPlan(steps: Partial<HostSetupStep>[]): HostSetupPlan {
return {
sshHost: 'dev-vm',
- status: 'halted',
+ status: 'idle',
currentStepId: 'node',
createdAt: '2026-01-01T00:00:00.000Z',
updatedAt: '2026-01-01T00:00:00.000Z',
@@ -137,7 +137,7 @@ describe('buildSetupPlan — rebuilding onto an existing plan', () => {
it('keeps the original creation time and the halted status', () => {
const plan = build(existingPlan([{ id: 'git', state: 'satisfied' }]));
expect(plan.createdAt).toBe('2026-01-01T00:00:00.000Z');
- expect(plan.status).toBe('halted');
+ expect(plan.status).toBe('idle');
expect(plan.currentStepId).toBe('node');
});
@@ -192,30 +192,30 @@ describe('reconcileInterruptedPlan', () => {
}
it('resets a step the app died mid-install on — never to satisfied', () => {
- const reconciled = reconcileInterruptedPlan(planWith('installing', 'running'), NOW);
+ const reconciled = reconcileInterruptedPlan(planWith('installing', 'idle'), NOW);
const node = reconciled.steps.find((s) => s.id === 'node')!;
expect(node.state).toBe('pending');
expect(node.outcome).toBeNull();
});
it('resets a step interrupted mid-check', () => {
- const reconciled = reconcileInterruptedPlan(planWith('checking', 'running'), NOW);
+ const reconciled = reconcileInterruptedPlan(planWith('checking', 'idle'), NOW);
expect(reconciled.steps.find((s) => s.id === 'node')!.state).toBe('pending');
});
it('clears a stale running status so the plan is startable again', () => {
- expect(reconcileInterruptedPlan(planWith('installing', 'running'), NOW).status).toBe('idle');
+ expect(reconcileInterruptedPlan(planWith('installing', 'idle'), NOW).status).toBe('idle');
});
it('leaves genuinely finished work alone', () => {
- const reconciled = reconcileInterruptedPlan(planWith('installing', 'running'), NOW);
+ const reconciled = reconcileInterruptedPlan(planWith('installing', 'idle'), NOW);
const git = reconciled.steps.find((s) => s.id === 'git')!;
expect(git.state).toBe('satisfied');
expect(git.version).toBe('2.43.0');
});
it('is a no-op for a cleanly halted plan', () => {
- const plan = planWith('failed', 'halted');
+ const plan = planWith('failed', 'idle');
expect(reconcileInterruptedPlan(plan, NOW)).toBe(plan);
});
});
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.ts
index 548dbd117..8d10832f2 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
@@ -148,7 +148,7 @@ function mergeSteps(fresh: HostSetupStep[], previous: HostSetupStep[]): HostSetu
}
/**
- * Reset a plan's transient states so a resumed run re-observes rather than
+ * 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`.
@@ -157,11 +157,10 @@ export function reconcileInterruptedPlan(plan: HostSetupPlan, now: string): Host
const interrupted = plan.steps.some(
(step) => step.state === 'checking' || step.state === 'installing'
);
- if (!interrupted && plan.status !== 'running') return plan;
+ if (!interrupted) return plan;
return {
...plan,
- status: plan.status === 'running' ? 'idle' : plan.status,
steps: plan.steps.map((step) =>
step.state === 'checking' || step.state === 'installing'
? {
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.db.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.db.test.ts
new file mode 100644
index 000000000..042ba9241
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.db.test.ts
@@ -0,0 +1,95 @@
+import { openFixture } from '@tooling/utils/db';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import type { AppDb } from '@main/db/client';
+import { remoteHostSetupPlans } from '@main/db/schema';
+
+const mocks = vi.hoisted(() => ({
+ db: undefined as AppDb | undefined,
+}));
+
+vi.mock('@main/db/client', () => ({
+ get db() {
+ if (!mocks.db) throw new Error('Test database not initialized');
+ return mocks.db;
+ },
+}));
+
+const { getSetupPlan } = await import('./setup-plan-store');
+
+/**
+ * Plans written by a build that still had the automated run.
+ *
+ * These rows are on real machines. If the parser refused them, upgrading would
+ * look like a corrupt database — so the removed states are mapped to their
+ * nearest live meaning instead.
+ */
+describe('reading a plan written before the automated run was removed', () => {
+ let close: (() => void) | undefined;
+
+ beforeEach(async () => {
+ const fixture = await openFixture('empty');
+ mocks.db = fixture.db;
+ close = fixture.close;
+ });
+
+ afterEach(() => {
+ close?.();
+ mocks.db = undefined;
+ });
+
+ async function insertLegacyPlan(status: string, stepState: string) {
+ await mocks.db!.insert(remoteHostSetupPlans).values({
+ sshHost: 'dev-vm',
+ status,
+ steps: JSON.stringify([
+ {
+ id: 'node',
+ kind: 'core-dependency',
+ name: 'Node.js',
+ state: stepState,
+ outcome: 'missing',
+ version: null,
+ error: null,
+ output: null,
+ optional: false,
+ dependsOn: [],
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ },
+ ]),
+ currentStepId: null,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:00.000Z',
+ });
+ }
+
+ it('reads a halted plan as idle rather than refusing to load it', async () => {
+ await insertLegacyPlan('halted', 'failed');
+
+ const plan = await getSetupPlan('dev-vm');
+
+ expect(plan?.status).toBe('idle');
+ expect(plan?.steps[0]!.state).toBe('failed');
+ });
+
+ it('reads a running plan as idle', async () => {
+ await insertLegacyPlan('running', 'pending');
+
+ expect((await getSetupPlan('dev-vm'))?.status).toBe('idle');
+ });
+
+ it('reads a blocked step as pending — "not unless upstream is fixed" is just "not yet" now', async () => {
+ await insertLegacyPlan('halted', 'blocked');
+
+ const plan = await getSetupPlan('dev-vm');
+
+ expect(plan?.steps[0]!.state).toBe('pending');
+ // The observation itself is still good; only the state vocabulary changed.
+ expect(plan?.steps[0]!.outcome).toBe('missing');
+ });
+
+ it('still refuses a value that was never valid', async () => {
+ await insertLegacyPlan('nonsense', 'pending');
+
+ await expect(getSetupPlan('dev-vm')).rejects.toThrow(/Invalid plan status/);
+ });
+});
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 5ac3e7015..c54aaf5b9 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
@@ -19,7 +19,7 @@ import type {
HostSetupStepState,
} from '@shared/core/remote-hosts/setup';
-const PLAN_STATUSES: HostSetupPlanStatus[] = ['idle', 'running', 'halted', 'complete'];
+const PLAN_STATUSES: HostSetupPlanStatus[] = ['idle', 'complete'];
const STEP_STATES: HostSetupStepState[] = [
'pending',
'checking',
@@ -27,8 +27,24 @@ const STEP_STATES: HostSetupStepState[] = [
'satisfied',
'failed',
'skipped',
- 'blocked',
];
+
+/**
+ * Values written before the automated run was removed.
+ *
+ * A plan persisted by an older build can still say `running`, `halted` or
+ * `blocked`; those concepts no longer exist, but the row does. Map them to
+ * their nearest live meaning rather than refusing to load — a strict parser
+ * would make an upgrade look like a corrupt database.
+ */
+const LEGACY_PLAN_STATUSES: Record<string, HostSetupPlanStatus> = {
+ running: 'idle',
+ halted: 'idle',
+};
+const LEGACY_STEP_STATES: Record<string, HostSetupStepState> = {
+ // "never attempted because something upstream failed" is just "not yet".
+ blocked: 'pending',
+};
const STEP_KINDS: HostSetupStepKind[] = ['core-dependency', 'agent-cli', 'agent-plugin', 'gh-auth'];
const OUTCOMES: DependencyCheckOutcome[] = [
'satisfied',
@@ -38,7 +54,14 @@ const OUTCOMES: DependencyCheckOutcome[] = [
'unknown',
];
-function oneOf<T extends string>(allowed: T[], raw: unknown, field: string, sshHost: string): T {
+function oneOf<T extends string>(
+ allowed: T[],
+ raw: unknown,
+ field: string,
+ sshHost: string,
+ legacy: Record<string, T> = {}
+): T {
+ if (typeof raw === 'string' && legacy[raw]) return legacy[raw];
const match = allowed.find((value) => value === raw);
if (!match) {
throw new Error(
@@ -64,7 +87,7 @@ function toStep(raw: unknown, sshHost: string): HostSetupStep {
id: value.id,
kind: oneOf(STEP_KINDS, value.kind, 'step kind', sshHost),
name: typeof value.name === 'string' ? value.name : value.id,
- state: oneOf(STEP_STATES, value.state, 'step state', sshHost),
+ state: oneOf(STEP_STATES, value.state, 'step state', sshHost, LEGACY_STEP_STATES),
outcome: value.outcome == null ? null : oneOf(OUTCOMES, value.outcome, 'outcome', sshHost),
version: nullableString(value.version),
error: nullableString(value.error),
@@ -94,7 +117,7 @@ function toPlan(row: RemoteHostSetupPlanRow): HostSetupPlan {
return {
sshHost: row.sshHost,
- status: oneOf(PLAN_STATUSES, row.status, 'plan status', row.sshHost),
+ status: oneOf(PLAN_STATUSES, row.status, 'plan status', row.sshHost, LEGACY_PLAN_STATUSES),
steps: parsed.map((step) => toStep(step, row.sshHost)),
currentStepId: row.currentStepId,
createdAt: row.createdAt,
diff --git a/dash/apps/switchdash-desktop/src/main/db/schema.ts b/dash/apps/switchdash-desktop/src/main/db/schema.ts
index 0cd0f4dcb..c00a29a7d 100644
--- a/dash/apps/switchdash-desktop/src/main/db/schema.ts
+++ b/dash/apps/switchdash-desktop/src/main/db/schema.ts
@@ -239,7 +239,11 @@ export const remoteHostReachability = sqliteTable('remote_host_reachability', {
export const remoteHostSetupPlans = sqliteTable('remote_host_setup_plans', {
/** The `~/.ssh/config` Host alias. One plan per host. */
sshHost: text('ssh_host').primaryKey(),
- /** One of HostSetupPlanStatus — 'idle' | 'running' | 'halted' | 'complete'. */
+ /**
+ * One of HostSetupPlanStatus — 'idle' | 'complete'. Rows written before the
+ * automated run was removed may still say 'running' or 'halted'; the plan
+ * store maps those on read.
+ */
status: text('status').notNull().default('idle'),
/** JSON-encoded HostSetupStep[]. */
steps: text('steps').notNull(),
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
index 6c7bc4d23..f2d7b46f3 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
@@ -20,11 +20,12 @@ import { Label } from '@renderer/lib/ui/label';
import { Sheet, SheetContent, SheetHeader } from '@renderer/lib/ui/sheet';
import { StatusBadge } from '@renderer/lib/ui/status-badge';
import { cn } from '@renderer/utils/utils';
-import type { HostSetupStep } from '@shared/core/remote-hosts/setup';
+import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';
import {
agentTypeBadge,
canInstall,
canSkip,
+ dependenciesMet,
outcomeLabel,
stepBadge,
type AgentTypeRow,
@@ -119,13 +120,9 @@ function ObservationCard({ step, actions }: { step: HostSetupStep; actions?: Rea
);
}
-/** A gh-auth step whose own dependency has not been satisfied yet. */
-function isBlockedByDep(step: HostSetupStep): boolean {
- return step.state === 'blocked' || step.state === 'pending';
-}
-
function StepActions({
step,
+ dependenciesSatisfied,
onInstall,
installing,
onSkip,
@@ -133,6 +130,8 @@ function StepActions({
onAuthenticate,
}: {
step: HostSetupStep;
+ /** False while something this step depends on is still outstanding. */
+ dependenciesSatisfied: boolean;
onInstall: () => void;
installing: boolean;
onSkip: () => void;
@@ -142,7 +141,7 @@ function StepActions({
// Only offer the GitHub sign-in once gh itself is there — the device flow
// runs `gh` on the host, so offering it before the CLI exists sends the user
// into a failure that says nothing about the real problem.
- const canSignIn = step.kind === 'gh-auth' && step.state !== 'satisfied' && !isBlockedByDep(step);
+ const canSignIn = step.kind === 'gh-auth' && step.state !== 'satisfied' && dependenciesSatisfied;
const installable = canInstall(step);
const busy = installing || step.state === 'installing' || step.state === 'checking';
if (!canSignIn && !installable && !canSkip(step)) return null;
@@ -209,6 +208,7 @@ export type SheetTarget =
export function SetupDetailSheet({
target,
sshHost,
+ plan,
icon,
onClose,
onInstall,
@@ -219,6 +219,8 @@ export function SetupDetailSheet({
}: {
target: SheetTarget | null;
sshHost: string;
+ /** Needed to tell whether a step's own prerequisites are in place. */
+ plan: HostSetupPlan | null;
/** Icon for the prerequisite being shown; agent types use their own. */
icon: React.ReactNode;
onClose: () => void;
@@ -254,6 +256,7 @@ export function SetupDetailSheet({
actions={
<StepActions
step={target.step}
+ dependenciesSatisfied={dependenciesMet(target.step, plan)}
onInstall={() => onInstall(target.step.id)}
installing={installingStepId === target.step.id}
onSkip={() => onSkip(target.step.id)}
@@ -268,6 +271,7 @@ export function SetupDetailSheet({
<AgentTypeDetail
row={target.row}
sshHost={sshHost}
+ plan={plan}
onInstall={onInstall}
installingStepId={installingStepId}
onSkip={onSkip}
@@ -286,6 +290,7 @@ export function SetupDetailSheet({
function AgentTypeDetail({
row,
sshHost,
+ plan,
onInstall,
installingStepId,
onSkip,
@@ -294,6 +299,7 @@ function AgentTypeDetail({
}: {
row: AgentTypeRow;
sshHost: string;
+ plan: HostSetupPlan | null;
onInstall: (stepId: string) => void;
installingStepId: string | null;
onSkip: (stepId: string) => void;
@@ -317,6 +323,7 @@ function AgentTypeDetail({
actions={
<StepActions
step={row.cli}
+ dependenciesSatisfied={dependenciesMet(row.cli, plan)}
onInstall={() => onInstall(row.cli.id)}
installing={installingStepId === row.cli.id}
onSkip={() => onSkip(row.cli.id)}
@@ -343,6 +350,7 @@ function AgentTypeDetail({
</div>
<StepActions
step={row.plugin}
+ dependenciesSatisfied={dependenciesMet(row.plugin, plan)}
onInstall={() => onInstall(row.plugin!.id)}
installing={installingStepId === row.plugin.id}
onSkip={() => onSkip(row.plugin!.id)}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
index 342de1dc9..861b321bd 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.test.ts
@@ -4,6 +4,7 @@ import {
agentTypeBadge,
canInstall,
canSkip,
+ dependenciesMet,
groupPlanSteps,
outcomeLabel,
stepBadge,
@@ -46,7 +47,7 @@ describe('stepBadge — green must be earned', () => {
});
});
- it.each(['pending', 'checking', 'installing', 'failed', 'skipped', 'blocked'] as const)(
+ it.each(['pending', 'checking', 'installing', 'failed', 'skipped'] as const)(
'is never success for %s',
(state) => {
expect(stepBadge(step({ state })).tone).not.toBe('success');
@@ -200,7 +201,6 @@ describe('canInstall', () => {
it('offers an install for anything outstanding', () => {
expect(canInstall(step({ state: 'pending', outcome: 'missing' }))).toBe(true);
expect(canInstall(step({ state: 'failed', outcome: 'missing' }))).toBe(true);
- expect(canInstall(step({ state: 'blocked' }))).toBe(true);
});
it('does not offer an install for something already there or in flight', () => {
@@ -213,3 +213,33 @@ describe('canInstall', () => {
expect(canInstall(step({ kind: 'gh-auth', state: 'pending', outcome: 'missing' }))).toBe(false);
});
});
+
+describe('dependenciesMet — do not offer an action that cannot work', () => {
+ const ghAuth = (patch: Partial<HostSetupStep> = {}) =>
+ step({ id: 'gh:auth', kind: 'gh-auth', name: 'GitHub CLI login', dependsOn: ['gh'], ...patch });
+
+ it('is false while the CLI the flow needs is still missing', () => {
+ // The device flow runs `gh` on the host; offering Sign in before gh exists
+ // sends the user into a failure that says nothing about the real problem.
+ const p = plan([step({ id: 'gh', name: 'GitHub CLI', outcome: 'missing' }), ghAuth()]);
+
+ expect(dependenciesMet(p.steps[1]!, p)).toBe(false);
+ });
+
+ it('is true once the CLI is there', () => {
+ const p = plan([
+ step({ id: 'gh', name: 'GitHub CLI', state: 'satisfied', outcome: 'satisfied' }),
+ ghAuth(),
+ ]);
+
+ expect(dependenciesMet(p.steps[1]!, p)).toBe(true);
+ });
+
+ it('is true for a step that depends on nothing', () => {
+ expect(dependenciesMet(step({ id: 'git' }), plan([step({ id: 'git' })]))).toBe(true);
+ });
+
+ it('is false when there is no plan to check against', () => {
+ expect(dependenciesMet(ghAuth(), null)).toBe(false);
+ });
+});
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
index a061b666f..79737fc89 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
@@ -62,6 +62,21 @@ export function canInstall(step: HostSetupStep): boolean {
return true;
}
+/**
+ * Whether everything this step declares a dependency on has been satisfied.
+ *
+ * The GitHub login is the case that matters: its device flow runs `gh` on the
+ * host, so offering it before `gh` exists sends the user into a failure that
+ * says nothing about the real problem.
+ */
+export function dependenciesMet(step: HostSetupStep, plan: HostSetupPlan | null): boolean {
+ if (step.dependsOn.length === 0) return true;
+ if (!plan) return false;
+ return step.dependsOn.every(
+ (id) => plan.steps.find((candidate) => candidate.id === id)?.state === 'satisfied'
+ );
+}
+
export type BadgeSpec = { tone: StatusTone; label: string };
/**
@@ -83,8 +98,6 @@ export function stepBadge(step: HostSetupStep): BadgeSpec {
return { tone: 'danger', label: outcomeLabel(step.outcome) };
case 'skipped':
return { tone: 'neutral', label: 'Skipped' };
- case 'blocked':
- return { tone: 'neutral', label: 'Waiting' };
case 'pending':
// A re-check leaves steps pending but records what it saw. "Not checked"
// and "checked, and it isn't there" are different facts and must not
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
index 542636841..90dea4697 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/use-host-setup.ts
@@ -90,20 +90,6 @@ export function useRecheckSetup(sshHost: string) {
});
}
-/**
- * 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 }),
- });
-}
-
/** Install one step on its own — the per-row Install button. */
export function useInstallSetupStep(sshHost: string) {
const queryClient = useQueryClient();
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx
index d66ee575d..b9ea31698 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
@@ -18,7 +18,7 @@
*/
import { useQuery } from '@tanstack/react-query';
-import { ArrowLeft, Play, RefreshCw, RotateCcw, Server } from 'lucide-react';
+import { ArrowLeft, RefreshCw } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useMemo, useState } from 'react';
import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
@@ -46,7 +46,6 @@ import {
useInstallSetupStep,
usePrepareSetup,
useRecheckSetup,
- useRunSetup,
useSkipSetupStep,
} from '../setup/use-host-setup';
import { REMOTE_HOSTS_QUERY_KEY } from './remote-hosts-view';
@@ -68,7 +67,6 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
const plan = useHostSetupPlan(sshHost);
const prepare = usePrepareSetup(sshHost);
const recheck = useRecheckSetup(sshHost);
- const run = useRunSetup(sshHost);
const skip = useSkipSetupStep(sshHost);
const installStep = useInstallSetupStep(sshHost);
@@ -96,7 +94,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
() => groupPlanSteps(plan.data ?? null),
[plan.data]
);
- const busy = run.isPending || prepare.isPending || recheck.isPending || installStep.isPending;
+ const busy = prepare.isPending || recheck.isPending || installStep.isPending;
const installingStepId = installStep.isPending ? (installStep.variables ?? null) : null;
const currentStepId = plan.data?.currentStepId ?? null;
@@ -121,35 +119,30 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
description={`Remote host · ${sshHost}. Auth uses your SSH agent — switchdash stores no credentials.`}
>
<div className="flex items-center gap-2">
+ {!blocked && (
+ <span className="flex items-center gap-2">
+ <StatusBadge tone={status.tone}>{status.label}</StatusBadge>
+ {status.readinessKnown && status.total > 0 && (
+ <span className="text-xs text-foreground-muted">
+ {status.done} of {status.total} required
+ </span>
+ )}
+ </span>
+ )}
<Button size="sm" variant="ghost" onClick={() => navigate('remoteHosts')}>
<ArrowLeft className="size-4" /> All hosts
</Button>
{!blocked && (
- <>
- <Button
- size="sm"
- variant="outline"
- disabled={busy}
- onClick={() => recheck.mutate()}
- aria-label="Re-check this host"
- >
- <RefreshCw className={`size-3.5 ${recheck.isPending ? 'animate-spin' : ''}`} />
- Re-check
- </Button>
- {status.kind !== 'ready' && (
- <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>
- )}
- </>
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={busy}
+ onClick={() => recheck.mutate()}
+ aria-label="Re-check this host"
+ >
+ <RefreshCw className={`size-3.5 ${recheck.isPending ? 'animate-spin' : ''}`} />
+ Re-check
+ </Button>
)}
</div>
</PageHeader>
@@ -158,30 +151,10 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
<HostUnreachablePanel reachability={reachability} />
) : (
<>
- <section className="flex items-center gap-3">
- <div className="flex size-12 shrink-0 items-center justify-center rounded-lg bg-background-quaternary-1 p-1.5">
- <Server className="size-6 text-foreground-muted" />
- </div>
- <div className="flex min-w-0 flex-1 flex-col gap-1">
- <div className="flex items-center gap-2">
- <span className="truncate text-lg text-foreground">{host?.name ?? sshHost}</span>
- <StatusBadge tone={status.tone}>{status.label}</StatusBadge>
- </div>
- <span className="text-xs text-foreground-muted">
- {status.readinessKnown && status.total > 0
- ? `${status.done} of ${status.total} required · ${sshHost}`
- : sshHost}
- </span>
- </div>
- </section>
-
{/*
- A run that stops because the host went away is reported as exactly
- that, rather than being attributed to whichever step was next.
+ An operation that stops because the host went away is reported as
+ exactly that, rather than being blamed on whichever step it touched.
*/}
- {run.isError && (
- <p className="text-destructive text-xs">{(run.error as Error).message}</p>
- )}
{installStep.isError && (
<p className="text-destructive text-xs">
Could not install: {(installStep.error as Error).message}
@@ -263,6 +236,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
<SetupDetailSheet
target={liveTarget}
sshHost={sshHost}
+ plan={plan.data ?? null}
icon={
liveTarget?.kind === 'prerequisite' ? (
<PrerequisiteIcon step={liveTarget.step} size={24} />
diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts
index 5d0cfe408..766063f70 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts
@@ -140,13 +140,10 @@ describe('deriveHostStatus', () => {
});
});
- it('names the step in flight while a run is going', () => {
+ it('names the step in flight while an install is going', () => {
const status = deriveHostStatus(
reachability('reachable'),
- plan([step('git', 'satisfied'), step('node', 'installing')], {
- status: 'running',
- currentStepId: 'node',
- })
+ plan([step('git', 'satisfied'), step('node', 'installing')])
);
expect(status.kind).toBe('setting-up');
diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts
index 1abd27f62..9858d6ae9 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts
@@ -16,7 +16,7 @@
*/
import { isHostBlocked, type HostReachability } from './reachability';
-import { outstandingRequiredSteps, type HostSetupPlan } from './setup';
+import { inFlightStep, outstandingRequiredSteps, type HostSetupPlan } from './setup';
export type HostStatusKind =
/** SSH authentication failed — will not self-heal, the user must fix it. */
@@ -25,7 +25,7 @@ export type HostStatusKind =
| 'unreachable'
/** Reachable, but nothing has ever been observed about it. */
| 'unchecked'
- /** A setup run is in flight. */
+ /** A check or install is in flight on one of its steps. */
| 'setting-up'
/** Reachable and every required step was observed satisfied. */
| 'ready'
@@ -91,11 +91,13 @@ export function deriveHostStatus(
const total = required.length;
const done = required.filter((step) => step.state === 'satisfied').length;
- if (plan.status === 'running') {
- const current = plan.steps.find((step) => step.id === plan.currentStepId);
+ // Work in flight lives on the step, not the plan: there is no automated run
+ // to be "running", only whatever the user asked for a moment ago.
+ const inFlight = inFlightStep(plan);
+ if (inFlight) {
return {
kind: 'setting-up',
- label: current ? `Setting up ${current.name}…` : 'Setting up…',
+ label: `Setting up ${inFlight.name}…`,
tone: 'info',
readinessKnown: true,
done,
diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts
index 9edb8d1d4..b70e1b3a0 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/setup.ts
@@ -8,8 +8,12 @@
* record beyond whatever the UI happened to be holding in memory.
*
* A setup plan is that missing object: an ordered list of steps, persisted per
- * host, advanced one at a time. It is the single answer to "what still needs to
- * happen on this host, and what went wrong last time we tried?".
+ * host. It is the single answer to "what still needs to happen on this host,
+ * and what went wrong last time we tried?".
+ *
+ * Nothing advances the plan on its own. Each step is installed when the user
+ * asks for that step — there is no run-everything button, deliberately: the
+ * ordering is guidance, not automation.
*/
import { defineEvent } from '@shared/lib/ipc/events';
@@ -60,9 +64,6 @@ export function isInstallableOutcome(outcome: DependencyCheckOutcome | null): bo
* - `failed` — the check or install failed; carries `error` (and `output` when
* a command produced any). The run halts here.
* - `skipped` — the user chose to move past it. Never rendered as satisfied.
- * - `blocked` — an earlier required step failed, so this one was never
- * attempted. Distinct from `pending`: pending means "not yet", blocked means
- * "not unless something upstream is fixed".
*/
export type HostSetupStepState =
| 'pending'
@@ -70,8 +71,7 @@ export type HostSetupStepState =
| 'installing'
| 'satisfied'
| 'failed'
- | 'skipped'
- | 'blocked';
+ | 'skipped';
/** What kind of thing a step manages, for rendering and for install routing. */
export type HostSetupStepKind = 'core-dependency' | 'agent-cli' | 'agent-plugin' | 'gh-auth';
@@ -106,14 +106,13 @@ export type HostSetupStep = {
/**
* Plan-level status.
*
- * - `idle` — built (or resumed) and waiting for the user to start.
- * - `running` — a step is in flight.
- * - `halted` — a required step failed. **Position is held**: satisfied steps
- * stay satisfied, the failure keeps its error, and untried steps are blocked.
- * Resuming re-attempts from the failure rather than starting over.
+ * - `idle` — something required is still outstanding.
* - `complete` — every required step is satisfied or skipped.
+ *
+ * Deliberately not a lifecycle: with no automated run there is nothing to be
+ * "running" or "halted". Work in flight lives on the individual step.
*/
-export type HostSetupPlanStatus = 'idle' | 'running' | 'halted' | 'complete';
+export type HostSetupPlanStatus = 'idle' | 'complete';
export type HostSetupPlan = {
sshHost: string;
@@ -125,12 +124,15 @@ export type HostSetupPlan = {
updatedAt: string;
};
-/** The first step that still needs work, in plan order. Null when nothing is left. */
-export function nextActionableStep(plan: HostSetupPlan): HostSetupStep | null {
+/** True while any step is being checked or installed. */
+export function isPlanBusy(plan: HostSetupPlan): boolean {
+ return plan.steps.some((step) => step.state === 'checking' || step.state === 'installing');
+}
+
+/** The step currently being worked on, if any. */
+export function inFlightStep(plan: HostSetupPlan): HostSetupStep | null {
return (
- plan.steps.find(
- (step) => step.state === 'pending' || step.state === 'blocked' || step.state === 'failed'
- ) ?? null
+ plan.steps.find((step) => step.state === 'checking' || step.state === 'installing') ?? null
);
}