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): surface available updates on a remote host (CHOO-1809)

Louis Amaudruz262a9f5897e0
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 fad5a2a06..da309c9dc 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
@@ -19,6 +19,8 @@ function step(id: string, patch: Partial<HostSetupStep> = {}): HostSetupStep {
state: 'pending',
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
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 2d0217e9b..3c3a9d8c8 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
@@ -30,6 +30,10 @@ import {
export type StepCheckResult = {
outcome: DependencyCheckOutcome;
version?: string | null;
+ /** Version available to install, when it could be determined. Null = unknown. */
+ latestVersion?: string | null;
+ /** True only when a newer version is known to exist. */
+ updateAvailable?: boolean;
/** Set when the outcome is `unknown` — why we could not tell. */
error?: string;
};
@@ -273,6 +277,8 @@ export class HostSetupRunner {
return await this.patchStep(plan, stepId, {
outcome: result.outcome,
version: result.version ?? null,
+ latestVersion: result.latestVersion ?? null,
+ updateAvailable: result.updateAvailable ?? false,
state: result.outcome === 'satisfied' ? 'satisfied' : 'checking',
error: result.error ?? null,
});
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.ts
index e75f764c4..3e5070be9 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
@@ -2,20 +2,27 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
const mocks = vi.hoisted(() => ({
getStatus: vi.fn(),
+ checkForUpdates: vi.fn(),
listAgentTypeStatuses: vi.fn(),
probe: vi.fn(),
remoteDependencyDescriptor: vi.fn(),
probeGhAuthStatus: vi.fn(),
+ getUpdateInfo: vi.fn(),
}));
vi.mock('@main/core/switch-setup/remote-switch-setup', () => ({
getRemoteSwitchSetupService: () =>
Promise.resolve({
getStatus: mocks.getStatus,
+ checkForUpdates: mocks.checkForUpdates,
listAgentTypeStatuses: mocks.listAgentTypeStatuses,
}),
}));
+vi.mock('@main/core/dependencies/agent-update-service', () => ({
+ agentUpdateService: { getUpdateInfo: mocks.getUpdateInfo },
+}));
+
vi.mock('@main/core/dependencies/remote-dependency-manager', () => ({
getRemoteDependencyManager: vi.fn(),
remoteDependencyDescriptor: mocks.remoteDependencyDescriptor,
@@ -64,6 +71,8 @@ function step(patch: Partial<HostSetupStep>): HostSetupStep {
state: 'pending',
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
@@ -75,9 +84,24 @@ function step(patch: Partial<HostSetupStep>): HostSetupStep {
const manager = { probe: mocks.probe } as unknown as HostDependencyManager;
+/** A full connector status, the shape the service always returns. */
+function status(patch: Record<string, unknown> = {}) {
+ return {
+ agentId: 'claude',
+ supported: true,
+ installed: true,
+ installedVersion: '0.7.7',
+ latestVersion: null,
+ updateAvailable: false,
+ refreshError: null,
+ ...patch,
+ };
+}
+
beforeEach(() => {
vi.clearAllMocks();
mocks.remoteDependencyDescriptor.mockReturnValue({ name: 'Claude Code' });
+ mocks.getUpdateInfo.mockReturnValue({ latestVersion: null, updateAvailable: false });
});
/**
@@ -91,23 +115,15 @@ beforeEach(() => {
*/
describe('checking an agent-plugin step', () => {
it('asks about its own agent type only', async () => {
- mocks.getStatus.mockResolvedValue({
- supported: true,
- installed: true,
- installedVersion: '1.0',
- });
+ mocks.checkForUpdates.mockResolvedValue(status());
await checkStep(SSH_HOST, manager, step({}));
- expect(mocks.getStatus).toHaveBeenCalledExactlyOnceWith('claude');
+ expect(mocks.checkForUpdates).toHaveBeenCalledExactlyOnceWith('claude');
});
it('never enumerates the other agent types', async () => {
- mocks.getStatus.mockResolvedValue({
- supported: true,
- installed: true,
- installedVersion: '1.0',
- });
+ mocks.checkForUpdates.mockResolvedValue(status());
await checkStep(SSH_HOST, manager, step({}));
@@ -115,35 +131,33 @@ describe('checking an agent-plugin step', () => {
});
it('strips the plugin suffix to get the agent id', async () => {
- mocks.getStatus.mockResolvedValue({ supported: true, installed: false });
+ mocks.checkForUpdates.mockResolvedValue(status({ installed: false }));
await checkStep(SSH_HOST, manager, step({ id: 'codex:plugin' }));
- expect(mocks.getStatus).toHaveBeenCalledWith('codex');
+ expect(mocks.checkForUpdates).toHaveBeenCalledWith('codex');
});
it('reports an installed connector as satisfied, carrying its version', async () => {
- mocks.getStatus.mockResolvedValue({
- supported: true,
- installed: true,
- installedVersion: '0.7.7',
- });
+ mocks.checkForUpdates.mockResolvedValue(status({ installedVersion: '0.7.7' }));
expect(await checkStep(SSH_HOST, manager, step({}))).toEqual({
outcome: 'satisfied',
version: '0.7.7',
+ latestVersion: null,
+ updateAvailable: false,
});
});
it('reports an absent connector as missing', async () => {
- mocks.getStatus.mockResolvedValue({ supported: true, installed: false });
+ mocks.checkForUpdates.mockResolvedValue(status({ installed: false }));
expect(await checkStep(SSH_HOST, manager, step({}))).toEqual({ outcome: 'missing' });
});
it('reports unknown — not missing — for a type switchdash cannot drive', async () => {
// "We cannot answer this" is not "it is not installed".
- mocks.getStatus.mockResolvedValue({ supported: false, installed: false });
+ mocks.checkForUpdates.mockResolvedValue(status({ supported: false, installed: false }));
const result = await checkStep(SSH_HOST, manager, step({}));
@@ -152,6 +166,62 @@ describe('checking an agent-plugin step', () => {
});
});
+/**
+ * A check that cannot see an update is a check that will report a stale
+ * connector as fine forever.
+ */
+describe('update detection', () => {
+ it('refreshes the catalog rather than reading what the host last fetched', async () => {
+ // `getStatus` reads the host's cached marketplace snapshot, which can be
+ // arbitrarily old; only `checkForUpdates` refreshes it first. Reading the
+ // cache would let a published update go unreported indefinitely.
+ mocks.checkForUpdates.mockResolvedValue(status());
+
+ await checkStep(SSH_HOST, manager, step({}));
+
+ expect(mocks.getStatus).not.toHaveBeenCalled();
+ });
+
+ it('carries an available connector update through', async () => {
+ mocks.checkForUpdates.mockResolvedValue(
+ status({ installedVersion: '0.7.6', latestVersion: '0.7.7', updateAvailable: true })
+ );
+
+ expect(await checkStep(SSH_HOST, manager, step({}))).toMatchObject({
+ outcome: 'satisfied',
+ latestVersion: '0.7.7',
+ updateAvailable: true,
+ });
+ });
+
+ it('does not claim an update when the latest version is unknowable', async () => {
+ // Null latest means "we could not tell", which is not "there is one" and
+ // not "you are current" either.
+ mocks.checkForUpdates.mockResolvedValue(status({ latestVersion: null }));
+
+ expect(await checkStep(SSH_HOST, manager, step({}))).toMatchObject({
+ latestVersion: null,
+ updateAvailable: false,
+ });
+ });
+
+ it('reports an agent CLI update from the shared coordinator', async () => {
+ // Latest-version data is host-agnostic, so the same service that answers
+ // for local agents answers here — no extra SSH to find it out.
+ mocks.probe.mockResolvedValue({ id: 'claude', status: 'installed', version: '2.1.0' });
+ mocks.getUpdateInfo.mockReturnValue({ latestVersion: '2.2.0', updateAvailable: true });
+
+ const result = await checkStep(
+ SSH_HOST,
+ manager,
+ step({ id: 'claude', kind: 'agent-cli', name: 'Claude Code' })
+ );
+
+ expect(mocks.getUpdateInfo).toHaveBeenCalledWith('claude', '2.1.0');
+ expect(result).toMatchObject({ latestVersion: '2.2.0', updateAvailable: true });
+ });
+});
+
describe('checking a core-dependency step', () => {
it('goes to the dependency manager, not the plugin CLIs', async () => {
mocks.probe.mockResolvedValue({ id: 'git', status: 'installed', version: '2.43.0' });
@@ -159,6 +229,6 @@ describe('checking a core-dependency step', () => {
await checkStep(SSH_HOST, manager, step({ id: 'git', kind: 'core-dependency', name: 'Git' }));
expect(mocks.probe).toHaveBeenCalledExactlyOnceWith('git');
- expect(mocks.getStatus).not.toHaveBeenCalled();
+ expect(mocks.checkForUpdates).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.ts
index 35a507be1..4a5f370b0 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,7 +7,8 @@
* per-host lifecycle (build, resume, run, skip, discard).
*/
-import type { HostDependencyManager } from '@switchdash/core/deps/runtime';
+import type { DependencyId, HostDependencyManager } from '@switchdash/core/deps/runtime';
+import { agentUpdateService } from '@main/core/dependencies/agent-update-service';
import { CORE_DEPENDENCIES } from '@main/core/dependencies/core-dependencies';
import { installOutput } from '@main/core/dependencies/install-output';
import {
@@ -158,7 +159,14 @@ export async function checkStep(
// discarding all but one ran each other type's CLI over SSH as a side
// effect, so checking one row reported failures for a different row's
// absent CLI — and cost two extra round trips per type to do it.
- const status = await service.getStatus(agentId);
+ //
+ // `checkForUpdates` rather than `getStatus`: it refreshes the host's
+ // marketplace catalog first. `getStatus` reads whatever that host last
+ // fetched, which can be arbitrarily old, so an update could exist and go
+ // unreported indefinitely. A failed refresh does not throw — it returns the
+ // cached versions with `refreshError` set, and an update we could not
+ // confirm is simply not claimed.
+ const status = await service.checkForUpdates(agentId);
if (!status.supported) {
return {
outcome: 'unknown',
@@ -166,12 +174,32 @@ export async function checkStep(
};
}
return status.installed
- ? { outcome: 'satisfied', version: status.installedVersion ?? null }
- : { outcome: 'missing' };
+ ? {
+ outcome: 'satisfied',
+ version: status.installedVersion ?? null,
+ latestVersion: status.latestVersion,
+ updateAvailable: status.updateAvailable,
+ }
+ : // Nothing installed, so there is nothing to be out of date. What the
+ // marketplace advertises is install-time detail, not an update.
+ { outcome: 'missing' };
}
const state = await manager.probe(step.id);
- return outcomeForDependency(state, Boolean(remoteDependencyDescriptor(step.id)?.minVersion));
+ const result = outcomeForDependency(
+ state,
+ Boolean(remoteDependencyDescriptor(step.id)?.minVersion)
+ );
+
+ // Latest-version data is host-agnostic — it comes from the release source,
+ // not the machine — so the same coordinator that answers for local agents
+ // answers here, given this host's own installed version. No extra SSH.
+ const update = agentUpdateService.getUpdateInfo(step.id as DependencyId, result.version ?? null);
+ return {
+ ...result,
+ latestVersion: update.latestVersion,
+ updateAvailable: update.updateAvailable,
+ };
}
/**
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 80f715cff..fd37e5483 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
@@ -100,6 +100,8 @@ describe('buildSetupPlan — rebuilding onto an existing plan', () => {
state: 'pending',
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
@@ -174,6 +176,8 @@ describe('reconcileInterruptedPlan', () => {
state: 'satisfied',
outcome: 'satisfied',
version: '2.43.0',
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
@@ -187,6 +191,8 @@ describe('reconcileInterruptedPlan', () => {
state,
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
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 82862c32b..e3e464fa9 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
@@ -65,6 +65,8 @@ function blankStep(
state: 'pending',
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: options.optional ?? false,
@@ -139,6 +141,8 @@ function mergeSteps(fresh: HostSetupStep[], previous: HostSetupStep[]): HostSetu
state: prior.state,
outcome: prior.outcome,
version: prior.version,
+ latestVersion: prior.latestVersion,
+ updateAvailable: prior.updateAvailable,
error: prior.error,
output: prior.output,
updatedAt: prior.updatedAt,
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 c54aaf5b9..870127724 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
@@ -90,6 +90,10 @@ function toStep(raw: unknown, sshHost: string): HostSetupStep {
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),
+ // Absent in plans written before update-awareness. Unknown latest and no
+ // known update is the honest reading of a row that predates the concept.
+ latestVersion: nullableString(value.latestVersion),
+ updateAvailable: value.updateAvailable === true,
error: nullableString(value.error),
output: nullableString(value.output),
optional: value.optional === true,
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts
index 996fe558e..e6449b80e 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/host-readiness.test.ts
@@ -37,6 +37,8 @@ function step(
state,
outcome: state === 'satisfied' ? 'satisfied' : 'missing',
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
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 fabe424bf..81c3547f5 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
@@ -20,6 +20,8 @@ function step(patch: Partial<HostSetupStep> = {}): HostSetupStep {
state: 'pending',
outcome: null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: 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 8983d073b..c51c27ce6 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
@@ -111,7 +111,16 @@ export type BadgeSpec = { tone: StatusTone; label: string };
export function stepBadge(step: HostSetupStep): BadgeSpec {
switch (step.state) {
case 'satisfied':
- return { tone: 'success', label: 'Installed' };
+ // An available update does not make a step unsatisfied — what is
+ // installed still works — but it is the one thing about a healthy row
+ // worth surfacing, so it takes the badge.
+ //
+ // Note the absence of an "Up to date" badge. `updateAvailable: false`
+ // means either "nothing newer" or "we could not tell", and only one of
+ // those earns the claim; "Installed" is true in both cases.
+ return step.updateAvailable
+ ? { tone: 'warning', label: 'Update available' }
+ : { tone: 'success', label: 'Installed' };
case 'checking':
return { tone: 'info', label: 'Checking…' };
case 'installing':
@@ -163,6 +172,11 @@ export function agentTypeBadge(row: AgentTypeRow): BadgeSpec {
if (row.plugin && row.plugin.state !== 'satisfied') {
return { tone: 'warning', label: 'Switch setup required' };
}
+ // Either half being out of date is worth saying, and the row states one
+ // question — is this usable, and is it current?
+ if (row.cli.updateAvailable || row.plugin?.updateAvailable) {
+ return { tone: 'warning', label: 'Update available' };
+ }
return { tone: 'success', label: 'Installed' };
}
diff --git a/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-prerequisite-row.test.tsx b/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-prerequisite-row.test.tsx
index e38d04e78..7f9787515 100644
--- a/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-prerequisite-row.test.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-prerequisite-row.test.tsx
@@ -42,6 +42,8 @@ function step(patch: Partial<HostSetupStep>): HostSetupStep {
state: 'pending',
outcome: 'missing',
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional: false,
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 4ad499258..4232ef45e 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
@@ -29,6 +29,8 @@ function step(
state,
outcome: state === 'satisfied' ? 'satisfied' : null,
version: null,
+ latestVersion: null,
+ updateAvailable: false,
error: null,
output: null,
optional,
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 420756006..e8c2f1c59 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
@@ -87,6 +87,22 @@ export type HostSetupStep = {
outcome: DependencyCheckOutcome | null;
/** Detected version, when the probe found one. */
version: string | null;
+ /**
+ * Version available to install, when that could be determined.
+ *
+ * Null means *unknown*, not "none newer" — the two are different and only one
+ * of them justifies telling someone they are up to date.
+ */
+ latestVersion: string | null;
+ /**
+ * True only when a newer version is known to exist. Never inferred from a
+ * missing `latestVersion`: not knowing is not evidence of currency.
+ *
+ * Deliberately does not make a step unsatisfied. An out-of-date connector
+ * still works, so an available update is information, not a blocker — a host
+ * is not "setup required" because something on it could be newer.
+ */
+ updateAvailable: boolean;
/** Why this step failed. Null unless `state === 'failed'`. */
error: string | null;
/** Raw command output from a failed install — the detail users need. */