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
feat(switchdash): act on updates, list every agent type, hide dead buttons (CHOO-1809)
Louis Amaudruz722ce4bbd69a
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.tsindex 01347d12f..8ca863e6e 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@@ -35,6 +35,7 @@ import {recheckSetup,recheckSetupStep,skipSetupStep,+ updateSetupStep,} from './setup/host-setup-service';import { listRemoteHosts, removeRemoteHost, upsertRemoteHost, type RemoteHost } from './store';@@ -224,6 +225,10 @@ export const remoteHostsController = createRPCController({installSetupStep: (params: { sshHost: string; stepId: string }): Promise<HostSetupPlan> =>installSetupStep(params.sshHost, params.stepId),+ /** Replace one prerequisite or agent type with its newest version, then verify. */+ updateSetupStep: (params: { sshHost: string; stepId: string }): Promise<HostSetupPlan> =>+ updateSetupStep(params.sshHost, params.stepId),+/** Move past a step the user has chosen not to fix, unblocking the rest. */skipSetupStep: (params: { sshHost: string; stepId: string }): Promise<HostSetupPlan> =>skipSetupStep(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.tsindex da309c9dc..11ab0f9ed 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@@ -44,6 +44,7 @@ function plan(steps: HostSetupStep[]): HostSetupPlan {type Harness = {checks: Record<string, StepCheckResult[]>;installs: Record<string, StepInstallResult>;+ updates?: Record<string, StepInstallResult>;canInstall?: (id: string) => boolean;reachable?: boolean;};@@ -54,6 +55,7 @@ function makeRunner(harness: Harness) {const saved: HostSetupPlan[] = [];const published: HostSetupPlan[] = [];const installOrder: string[] = [];+ const updateOrder: string[] = [];const checkOrder: string[] = [];const inFlight = { count: 0, max: 0 };@@ -75,6 +77,10 @@ function makeRunner(harness: Harness) {inFlight.count -= 1;return harness.installs[s.id] ?? { ok: true };},+ update: async (s) => {+ updateOrder.push(s.id);+ return harness.updates?.[s.id] ?? { ok: true };+ },canInstall: (s) => harness.canInstall?.(s.id) ?? true,requireReachable: () => {if (harness.reachable === false) throw new Unreachable('host down');@@ -82,7 +88,7 @@ function makeRunner(harness: Harness) {now: () => new Date('2026-02-02T00:00:00.000Z'),});- return { runner, saved, published, installOrder, checkOrder, inFlight };+ return { runner, saved, published, installOrder, updateOrder, checkOrder, inFlight };}const stateOf = (p: HostSetupPlan, id: string) => p.steps.find((s) => s.id === id)!.state;@@ -148,6 +154,7 @@ describe('installing one step', () => {throw new Error('ssh channel closed');},install: async () => ({ ok: true }),+ update: async () => ({ ok: true }),canInstall: () => true,requireReachable: () => {},now: () => new Date('2026-02-02T00:00:00.000Z'),@@ -570,3 +577,123 @@ describe('runner determinism', () => {vi.useRealTimers();});});++/**+ * Updating is not installing (CHOO-1809).+ *+ * `runStep` returns the moment it observes a satisfied step, which is right for+ * an install and useless for an update — the whole premise of an update is that+ * the thing is already there.+ */+describe('updating one step', () => {+ const installed = (patch: Partial<HostSetupStep> = {}) =>+ step('claude', {+ state: 'satisfied',+ outcome: 'satisfied',+ version: '2.1.0',+ latestVersion: '2.2.0',+ updateAvailable: true,+ ...patch,+ });++ it('runs the update and verifies it by re-probing', async () => {+ const { runner, updateOrder, checkOrder } = makeRunner({+ checks: { claude: [{ outcome: 'satisfied', version: '2.2.0' }] },+ installs: {},+ });++ const result = await runner.updateStep(plan([installed()]), 'claude');++ expect(updateOrder).toEqual(['claude']);+ expect(checkOrder).toEqual(['claude']);+ expect(stateOf(result, 'claude')).toBe('satisfied');+ expect(result.steps[0]!.version).toBe('2.2.0');+ });++ it('refuses when no update is known to be available', async () => {+ // Without a known newer version there is nothing to update *to*, and the+ // remove-then-add fallback some CLIs use would uninstall a working plugin+ // to reinstall the very same one.+ const { runner, updateOrder } = makeRunner({ checks: {}, installs: {} });++ await expect(+ runner.updateStep(+ plan([installed({ latestVersion: null, updateAvailable: false })]),+ 'claude'+ )+ ).rejects.toThrow(/no update is known/i);+ expect(updateOrder).toEqual([]);+ });++ it('reports the updater failing, and does not claim the new version', async () => {+ const { runner } = makeRunner({+ checks: { claude: [{ outcome: 'satisfied', version: '2.1.0' }] },+ installs: {},+ updates: { claude: { ok: false, error: 'network unreachable' } },+ });++ const result = await runner.updateStep(plan([installed()]), 'claude');++ expect(stateOf(result, 'claude')).toBe('failed');+ expect(result.steps[0]!.error).toBe('network unreachable');+ expect(result.steps[0]!.version).toBe('2.1.0');+ });++ it('fails when the thing is gone after updating', async () => {+ // A remove-then-add that removed and did not add leaves nothing installed.+ // An exit code saying otherwise is a claim; the probe is the observation.+ const { runner } = makeRunner({+ checks: { claude: [{ outcome: 'missing' }] },+ installs: {},+ });++ const result = await runner.updateStep(plan([installed()]), 'claude');++ expect(stateOf(result, 'claude')).toBe('failed');+ expect(result.steps[0]!.error).toMatch(/after updating/i);+ });++ it('keeps saying an update is available when the update silently no-ops', async () => {+ // The version did not move, so the fresh probe still finds one newer. The+ // row must keep offering it rather than reporting a success that never+ // happened.+ const { runner } = makeRunner({+ checks: {+ claude: [+ { outcome: 'satisfied', version: '2.1.0', latestVersion: '2.2.0', updateAvailable: true },+ ],+ },+ installs: {},+ });++ const result = await runner.updateStep(plan([installed()]), 'claude');++ expect(stateOf(result, 'claude')).toBe('satisfied');+ expect(result.steps[0]!.updateAvailable).toBe(true);+ });++ it('refuses to run while another operation holds the host', async () => {+ const { runner } = makeRunner({+ checks: { claude: [{ outcome: 'satisfied', version: '2.2.0' }] },+ installs: {},+ });+ const p = plan([installed(), step('git')]);++ const first = runner.updateStep(p, 'claude');+ await expect(runner.updateStep(p, 'claude')).rejects.toThrow(/already running/i);+ await first;+ });++ it('aborts as unreachable rather than blaming the dependency', async () => {+ const { runner, updateOrder } = makeRunner({+ checks: {},+ installs: {},+ reachable: false,+ });++ await expect(runner.updateStep(plan([installed()]), 'claude')).rejects.toBeInstanceOf(+ HostSetupAbortedError+ );+ expect(updateOrder).toEqual([]);+ });+});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.tsindex 3c3a9d8c8..eb21e45e4 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@@ -50,6 +50,8 @@ export type HostSetupRunnerDeps = {publish: (plan: HostSetupPlan) => void;check: (step: HostSetupStep) => Promise<StepCheckResult>;install: (step: HostSetupStep) => Promise<StepInstallResult>;+ /** Replace an already-installed step with the newest available version. */+ update: (step: HostSetupStep) => Promise<StepInstallResult>;/** Whether this step can be installed by switchdash at all on this host. */canInstall: (step: HostSetupStep) => boolean;/**@@ -206,6 +208,89 @@ export class HostSetupRunner {}}+ /**+ * Replace one already-installed step with the newer version — the Update+ * button (CHOO-1809).+ *+ * Deliberately not folded into `runStep`: that path exists to make an+ * unsatisfied step satisfied, and returns the moment it observes one that+ * already is. Correct for an install, useless for an update.+ *+ * The verification discipline is the same. An updater's exit code is a+ * claim, so the new version is established by a fresh probe. Note what+ * happens if the update silently no-ops: the probe records the same version+ * and `updateAvailable` stays true, so the row keeps saying "Update+ * available" rather than reporting a success that did not happen.+ */+ async updateStep(plan: HostSetupPlan, stepId: string): Promise<HostSetupPlan> {+ if (this.running) {+ throw new Error(`Another setup operation is already running for ${this.deps.sshHost}`);+ }+ this.running = true;+ try {+ try {+ this.deps.requireReachable(this.deps.sshHost);+ } catch (error) {+ throw new HostSetupAbortedError(+ `Cannot update on ${this.deps.sshHost}: the host is not reachable.`,+ error+ );+ }++ // Refuse rather than run a command whose premise we never established.+ // Without a known newer version there is nothing to update *to*, and the+ // remove-then-add fallback some CLIs use would risk uninstalling a+ // working plugin to reinstall the same one.+ const target = findStep(plan, stepId);+ if (!target.updateAvailable) {+ throw new Error(`No update is known to be available for ${target.name}.`);+ }++ let next = await this.patchStep(plan, stepId, {+ state: 'updating',+ error: null,+ output: null,+ });+ next = await this.transition(next, { currentStepId: stepId });++ const result = await this.deps.update(findStep(next, stepId));+ if (!result.ok) {+ next = await this.patchStep(next, stepId, {+ state: 'failed',+ error: result.error,+ output: result.output ?? null,+ });+ return await this.settle(next);+ }++ const verifying = await this.patchStep(next, stepId, { state: 'checking' });+ const verified = await this.observe(verifying, stepId);+ const after = findStep(verified, stepId);++ if (after.outcome === 'satisfied') return await this.settle(verified);++ return await this.settle(+ await this.patchStep(verified, stepId, {+ state: 'failed',+ error:+ after.outcome === 'unknown'+ ? `${after.name} was updated but could not be verified afterwards.`+ : `${after.name} reports "${after.outcome}" after updating.`,+ })+ );+ } finally {+ this.running = false;+ }+ }++ /** Close out an operation: recompute plan status and clear the current step. */+ private async settle(plan: HostSetupPlan): Promise<HostSetupPlan> {+ return await this.transition(plan, {+ status: isPlanComplete(plan) ? 'complete' : 'idle',+ currentStepId: null,+ });+ }+/*** Check one step, install it if that is both needed and possible, then* re-check to verify. Never marks a step satisfied on the strength of andiff --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 4a5f370b0..582dd3d33 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@@ -129,6 +129,7 @@ function runnerFor(sshHost: string, manager: HostDependencyManager): HostSetupRu},check: (step) => checkStep(sshHost, manager, step),install: (step) => installStep(sshHost, manager, step),+ update: (step) => updateStep(sshHost, manager, step),});runners.set(sshHost, runner);@@ -269,6 +270,45 @@ async function installStep(};}+/**+ * Replace one step with the newest available version.+ *+ * Exported for the same reason `checkStep` is: the routing (connector vs+ * dependency manager) is invisible from the call site and each half has its own+ * failure vocabulary.+ */+export async function updateStep(+ sshHost: string,+ manager: HostDependencyManager,+ step: HostSetupStep+): Promise<StepInstallResult> {+ if (step.kind === 'gh-auth') {+ return { ok: false, error: 'A GitHub login is not something that can be updated.' };+ }++ if (step.kind === 'agent-plugin') {+ const service = await getRemoteSwitchSetupService(sshHost);+ const result = await service.update(stepAgentId(step));+ return result.success+ ? { ok: true }+ : { ok: false, error: result.message ?? 'Could not update the Switch connector.' };+ }++ const stopProgress = streamInstallProgress(sshHost, step.id);+ let result: Awaited<ReturnType<typeof manager.update>>;+ try {+ result = await manager.update(step.id);+ } finally {+ stopProgress();+ }+ if (result.success) return { ok: true };++ const error = result.error as { message?: string; output?: string; type?: string };+ const message = error.message ?? error.type ?? 'Update failed.';+ const output = error.output ? condenseCommandOutput(error.output) : null;+ return { ok: false, error: describeInstallFailure(step.name, message, output), output };+}+/*** Observe a host without changing it — the "Re-check" button.*@@ -327,6 +367,23 @@ export async function installSetupStep(sshHost: string, stepId: string): Promise}}+/** Update one step to the newest available version — the per-row Update button. */+export async function updateSetupStep(sshHost: string, stepId: string): Promise<HostSetupPlan> {+ const plan = await ensureSetupPlan(sshHost);+ const manager = await getRemoteDependencyManager(sshHost);+ try {+ return await runnerFor(sshHost, manager).updateStep(plan, stepId);+ } catch (error) {+ log.warn('[HostSetup] step update stopped', {+ event: 'host-setup-step-update-stopped',+ sshHost,+ stepId,+ error: String((error as Error)?.message ?? error),+ });+ throw error;+ }+}+/** Move past a step the user has chosen not to fix, unblocking the rest. */export async function skipSetupStep(sshHost: string, stepId: string): Promise<HostSetupPlan> {const plan = await getSetupPlan(sshHost);diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/setup-plan-store.tsindex 870127724..8c3599d5f 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@@ -24,6 +24,7 @@ const STEP_STATES: HostSetupStepState[] = ['pending','checking','installing',+ 'updating','satisfied','failed','skipped',diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-setup/controller.ts b/dash/apps/switchdash-desktop/src/main/core/switch-setup/controller.tsindex 664dadd60..65b9eccf8 100644--- a/dash/apps/switchdash-desktop/src/main/core/switch-setup/controller.ts+++ b/dash/apps/switchdash-desktop/src/main/core/switch-setup/controller.ts@@ -1,12 +1,14 @@import { hostReachabilityService } from '@main/core/remote-hosts/production-host-reachability';import { log } from '@main/lib/logger';+import type { AgentTypeAvailability } from '@shared/core/switch-setup/agent-type-availability';import { createRPCController } from '@shared/lib/ipc/rpc';import { type LocalGhAuthStatus, probeLocalGhAuth, startLocalGhAuth } from './local-gh-auth';import { getRemoteSwitchSetupService } from './remote-switch-setup';import { switchSetupService } from './switch-setup-service';export const switchSetupController = createRPCController({- listOnboardable: () => switchSetupService.listOnboardable(),+ /** Every Switch-capable agent type on this machine, usable or not. */+ listAgentTypeAvailability: () => switchSetupService.listAgentTypeAvailability(),/** Whether this machine can fetch the MCP runtime from GitHub Packages. */getLocalGhAuth: (): Promise<LocalGhAuthStatus> => probeLocalGhAuth(),@@ -14,20 +16,39 @@ export const switchSetupController = createRPCController({/** Interactive `gh` login/refresh on this machine; returns a PTY session id. */startLocalGhAuth: (): Promise<{ sessionId: string }> => startLocalGhAuth(),/**- * Agent types installed on a remote host. An unreachable host has no- * answerable list, so return none rather than throwing: this is a query that- * paints UI, and its caller renders the host-unreachable state alongside it,- * so the degraded result is disclosed. Throwing surfaced an ordinary,- * expected condition as an unhandled handler error with a stack trace.+ * Every Switch-capable agent type on a remote host, usable or not.+ *+ * An unreachable host has no answerable list, so return none rather than+ * throwing: this is a query that paints UI, and its caller renders the+ * host-unreachable state alongside it, so the degraded result is disclosed.+ * Throwing surfaced an ordinary, expected condition as an unhandled handler+ * error with a stack trace.*/- listOnboardableRemote: async (sshHost: string) => {+ listAgentTypeAvailabilityRemote: async (sshHost: string): Promise<AgentTypeAvailability[]> => {if (hostReachabilityService.isBlocked(sshHost)) {- log.warn('switchSetup.listOnboardableRemote: host unreachable — no agent types', { sshHost });+ log.warn('switchSetup.listAgentTypeAvailabilityRemote: host unreachable — no agent types', {+ sshHost,+ });return [];}const service = await getRemoteSwitchSetupService(sshHost);const statuses = await service.listAgentTypeStatuses();- return statuses.filter((s) => s.installed).map((s) => ({ agentId: s.agentId }));+ return statuses.map((status) => {+ if (!status.supported) {+ return {+ agentId: status.agentId,+ available: false,+ blockedReason: `switchdash cannot manage this agent type on ${sshHost}.`,+ };+ }+ return status.installed+ ? { agentId: status.agentId, available: true, blockedReason: null }+ : {+ agentId: status.agentId,+ available: false,+ blockedReason: `Its Switch connector is not installed on ${sshHost}.`,+ };+ });},getStatus: (agentId: string) => switchSetupService.getStatus(agentId),checkForUpdates: (agentId: string) => switchSetupService.checkForUpdates(agentId),diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.test.ts b/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.test.tsindex 1933d2e60..1d7a61317 100644--- a/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.test.ts@@ -270,25 +270,46 @@ describe('switchSetupService.getStatus', () => {});});-describe('switchSetupService.listOnboardable', () => {- it('returns only Switch-supported agent types whose connector is installed', async () => {+describe('switchSetupService.listAgentTypeAvailability', () => {+ it('reports a Switch-supported type with its connector installed as available', async () => {mocks.listPlugins.mockReturnValue([CLI_AGENT, NONE_AGENT]);mocks.exec.mockImplementation(execImpl('0.1.0'));mocks.readFile.mockImplementation(readFileImpl('0.1.0', '0.1.0'));- const onboardable = await switchSetupService.listOnboardable();-- expect(onboardable).toEqual([{ agentId: 'claude' }]);+ expect(await switchSetupService.listAgentTypeAvailability()).toEqual([+ { agentId: 'claude', available: true, blockedReason: null },+ ]);});- it('omits supported agent types whose connector is not installed', async () => {+ /**+ * The type is still listed — that is the point of the change (CHOO-1809).+ *+ * Dropping it made "not set up here" indistinguishable from "does not exist":+ * the dropdown simply had one fewer row and the user was left to guess why the+ * agent they use every day was missing.+ */+ it('keeps a type whose connector is not installed, and says why it cannot be used', async () => {mocks.listPlugins.mockReturnValue([CLI_AGENT, NONE_AGENT]);mocks.exec.mockImplementation(execImpl(null));mocks.readFile.mockImplementation(readFileImpl('0.0.0', '0.1.0'));- const onboardable = await switchSetupService.listOnboardable();+ const availability = await switchSetupService.listAgentTypeAvailability();++ expect(availability).toHaveLength(1);+ expect(availability[0]!).toMatchObject({ agentId: 'claude', available: false });+ expect(availability[0]!.blockedReason).toBeTruthy();+ });++ it('never lists an agent type that declares no Switch setup', async () => {+ // `NONE_AGENT` cannot be onboarded at all, so it is not a thing the user+ // could fix — listing it greyed out would be noise, not information.+ mocks.listPlugins.mockReturnValue([CLI_AGENT, NONE_AGENT]);+ mocks.exec.mockImplementation(execImpl('0.1.0'));+ mocks.readFile.mockImplementation(readFileImpl('0.1.0', '0.1.0'));- expect(onboardable).toEqual([]);+ const availability = await switchSetupService.listAgentTypeAvailability();++ expect(availability.map((entry) => entry.agentId)).not.toContain(NONE_AGENT.metadata.id);});// An installed plugin still resolves its MCP server from a private registry@@ -301,7 +322,7 @@ describe('switchSetupService.listOnboardable', () => {'the token cannot read packages',{ ghInstalled: true, authenticated: true, canReadPackages: false },],- ])('offers nothing when %s, even with the connector installed', async (_label, gh) => {+ ])('makes nothing available when %s, even with the connector installed', async (_label, gh) => {mocks.listPlugins.mockReturnValue([CLI_AGENT, NONE_AGENT]);mocks.exec.mockImplementation(execImpl('0.1.0'));mocks.readFile.mockImplementation(readFileImpl('0.1.0', '0.1.0'));@@ -312,7 +333,12 @@ describe('switchSetupService.listOnboardable', () => {detail: 'nope',});- expect(await switchSetupService.listOnboardable()).toEqual([]);+ const availability = await switchSetupService.listAgentTypeAvailability();++ expect(availability.every((entry) => !entry.available)).toBe(true);+ // Blocked for a reason no per-type install would fix, so it has to name the+ // GitHub access rather than telling the user to install what they have.+ expect(availability[0]!.blockedReason).toContain('GitHub');});});diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.ts b/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.tsindex 80d7a04ae..ae81c3c6c 100644--- a/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.ts+++ b/dash/apps/switchdash-desktop/src/main/core/switch-setup/switch-setup-service.ts@@ -5,6 +5,7 @@ import semver from 'semver';import { LocalExecutionContext } from '@main/core/execution-context/local-execution-context';import { log } from '@main/lib/logger';import { READ_PACKAGES_SCOPE } from '@shared/core/npm-registry';+import type { AgentTypeAvailability } from '@shared/core/switch-setup/agent-type-availability';import { getPlugin, listPlugins } from '../providers/plugin-registry';import { probeLocalGhAuth } from './local-gh-auth';import {@@ -281,7 +282,11 @@ class SwitchSetupService {* withheld until the credential can actually fetch it, matching how a remote* host reports readiness.*/- async listOnboardable(): Promise<{ agentId: string }[]> {+ async listAgentTypeAvailability(): Promise<AgentTypeAvailability[]> {+ const types = listPlugins()+ .filter((plugin) => plugin.capabilities.switchSetup.kind === 'cli')+ .map((plugin) => plugin.metadata.id);+const gh = await probeLocalGhAuth();if (!gh.ghInstalled || !gh.authenticated || !gh.canReadPackages) {log.warn('switch-setup: no agent type is onboardable — GitHub access is not usable', {@@ -291,16 +296,30 @@ class SwitchSetupService {canReadPackages: gh.canReadPackages,envShadowed: gh.envShadowed,});- return [];+ // Blocked for every type at once, and not for a reason any per-type+ // install would fix, so say so on each rather than probing them.+ return types.map((agentId) => ({+ agentId,+ available: false,+ blockedReason:+ 'This computer cannot reach the private GitHub packages the Switch connector needs.',+ }));}- const onboardable: { agentId: string }[] = [];- for (const plugin of listPlugins()) {- if (plugin.capabilities.switchSetup.kind !== 'cli') continue;- const status = await this.getStatus(plugin.metadata.id);- if (status.installed) onboardable.push({ agentId: plugin.metadata.id });+ const availability: AgentTypeAvailability[] = [];+ for (const agentId of types) {+ const status = await this.getStatus(agentId);+ availability.push(+ status.installed+ ? { agentId, available: true, blockedReason: null }+ : {+ agentId,+ available: false,+ blockedReason: 'Its Switch connector is not installed on this computer.',+ }+ );}- return onboardable;+ return availability;}/**diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/agent-type-picker.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/agent-type-picker.tsxindex b2ef3c6dc..f1046013f 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/agent-type-picker.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/agent-type-picker.tsx@@ -3,7 +3,7 @@ import { useEffect, useMemo } from 'react';import { useLocalGhAuth } from '@renderer/features/settings/agents-page/LocalGhAuthRow';import { AgentIcon } from '@renderer/lib/components/agent-icon';import { useAgents } from '@renderer/lib/stores/use-agents';-import { useOnboardableAgentTypes } from '@renderer/lib/stores/use-switch-setup';+import { useAgentTypeAvailability } from '@renderer/lib/stores/use-switch-setup';import { Field, FieldLabel } from '@renderer/lib/ui/field';import {Select,@@ -32,81 +32,103 @@ export function AgentTypePicker({onChange: (providerId: AgentProviderId) => void;sshHost?: string;}) {- const { data: onboardable, isPending } = useOnboardableAgentTypes(sshHost);+ const { data: availability, isPending } = useAgentTypeAvailability(sshHost);const { data: agents } = useAgents();const { data: ghAuth } = useLocalGhAuth();const githubBlocked =!!ghAuth && !(ghAuth.ghInstalled && ghAuth.authenticated && ghAuth.canReadPackages);+ // Every known type, each with the agent registry's name and icon plus the+ // verdict from the machine being targeted. Types the registry does not know+ // are dropped — there is nothing to render them with.const options = useMemo(() => {const byId = new Map((agents ?? []).map((a) => [a.id, a]));- return (onboardable ?? [])- .map((o) => byId.get(o.agentId))- .filter((a): a is NonNullable<typeof a> => !!a);- }, [onboardable, agents]);+ return (availability ?? []).flatMap((entry) => {+ const agent = byId.get(entry.agentId);+ return agent ? [{ agent, ...entry }] : [];+ });+ }, [availability, agents]);+ const selectable = useMemo(() => options.filter((o) => o.available), [options]);useEffect(() => {if (value) return;- if (options.length === 1) onChange(options[0].id as AgentProviderId);- }, [value, options, onChange]);+ // Only ever auto-select something that can actually be used. Picking a+ // greyed-out type on the user's behalf would put them straight into the+ // refusal the greying exists to prevent.+ if (selectable.length === 1) onChange(selectable[0].agent.id as AgentProviderId);+ }, [value, selectable, onChange]);- if (!isPending && options.length === 0) {- return (- <div className="flex items-start gap-2 rounded-md border border-border bg-background-1 px-2 py-1.5 text-xs text-foreground-muted">- <CircleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-500" />- {/* Name the host: "no agent type is set up" reads as a global problem,+ // Nothing usable is a real dead end and still needs saying — but the list+ // below now shows *which* types exist and what each is missing, so this is+ // the pointer to where they get fixed rather than the only signal.+ const nothingUsable = !isPending && selectable.length === 0;+ const emptyNotice = nothingUsable ? (+ <div className="flex items-start gap-2 rounded-md border border-border bg-background-1 px-2 py-1.5 text-xs text-foreground-muted">+ <CircleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-500" />+ {/* Name the host: "no agent type is set up" reads as a global problem,but availability is per-host — the connector may well be installedlocally and simply missing on the machine being targeted. */}- <span>- {/* The plugin may be installed and the agent still unusable, so the+ <span>+ {/* The plugin may be installed and the agent still unusable, so theGitHub reason has to be given ahead of the install advice —otherwise it sends the user to install something they alreadyhave. */}- {!sshHost && githubBlocked ? (- <>- This computer cannot reach the private GitHub packages the Switch connector needs- {ghAuth?.detail ? ` — ${ghAuth.detail}` : '.'} Authenticate under Settings →- Agents → Switch setup, then try again.- </>- ) : sshHost ? (- <>- No agent type is set up for Switch on <span className="font-medium">{sshHost}</span>.- Install an agent's Switch connector on that host in Settings → Remote hosts- before onboarding it there.- </>- ) : (- <>- No agent type is set up for Switch on this computer. Install an agent's Switch- connector in Settings → Agents before onboarding it.- </>- )}- </span>- </div>- );- }+ {!sshHost && githubBlocked ? (+ <>+ This computer cannot reach the private GitHub packages the Switch connector needs+ {ghAuth?.detail ? ` — ${ghAuth.detail}` : '.'} Authenticate under Settings → Agents+ → Switch setup, then try again.+ </>+ ) : sshHost ? (+ <>+ No agent type is set up for Switch on <span className="font-medium">{sshHost}</span>.+ Install an agent's Switch connector on that host in Settings → Remote hosts+ before onboarding it there.+ </>+ ) : (+ <>+ No agent type is set up for Switch on this computer. Install an agent's Switch+ connector in Settings → Agents before onboarding it.+ </>+ )}+ </span>+ </div>+ ) : null;- const selected = options.find((a) => a.id === value);+ const selected = options.find((o) => o.agent.id === value);return (<Field>+ {emptyNotice}<FieldLabel>Agent type</FieldLabel><Select value={value ?? undefined} onValueChange={(v) => v && onChange(v as AgentProviderId)}><SelectTrigger><SelectValue placeholder="Select an agent type">{selected ? (<span className="flex items-center gap-2">- <AgentIcon id={selected.id} size={16} />- {selected.name}+ <AgentIcon id={selected.agent.id} size={16} />+ {selected.agent.name}</span>) : undefined}</SelectValue></SelectTrigger><SelectContent>- {options.map((agent) => (- <SelectItem key={agent.id} value={agent.id}>+ {/*+ Types that cannot be used here are listed and disabled rather than+ omitted. A missing row says nothing; a greyed one with its reason+ says what to go and fix. Availability is per-machine, so a type the+ user has locally can legitimately be absent on the host they picked.+ */}+ {options.map(({ agent, available, blockedReason }) => (+ <SelectItem key={agent.id} value={agent.id} disabled={!available}><span className="flex items-center gap-2"><AgentIcon id={agent.id} size={16} />{agent.name}+ {!available && (+ <span className="text-xs text-foreground-muted">+ — {blockedReason ?? 'Not available here.'}+ </span>+ )}</span></SelectItem>))}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.tsxindex 3169dff6c..5215b9073 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,10 +20,15 @@ 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 { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';+import {+ isStepInFlight,+ type HostSetupPlan,+ type HostSetupStep,+} from '@shared/core/remote-hosts/setup';import {agentTypeBadge,canInstall,+ canOfferAction,canSignIn,canSkip,outcomeLabel,@@ -71,7 +76,7 @@ function OutcomeTile({ step }: { step: HostSetupStep }) {</div>);}- if (step.state === 'checking' || step.state === 'installing') {+ if (isStepInFlight(step)) {return (<div className="flex size-6 items-center justify-center rounded-lg bg-background-2"><Loader2 className="size-3.5 animate-spin text-foreground-muted" />@@ -115,6 +120,8 @@ function ObservationCard({<span className="text-foreground-muted">Checking…</span>) : step.state === 'installing' ? (<span className="text-foreground-muted">Installing…</span>+ ) : step.state === 'updating' ? (+ <span className="text-foreground-muted">Updating…</span>) : (<span className="text-foreground-muted">{outcomeLabel(step.outcome)}</span>)}@@ -145,6 +152,7 @@ function StepActions({plan,onInstall,installing,+ hostBusy,onSkip,skipping,onAuthenticate,@@ -154,13 +162,18 @@ function StepActions({plan: HostSetupPlan | null;onInstall: () => void;installing: boolean;+ /** True while any operation is running on this host. */+ hostBusy: boolean;onSkip: () => void;skipping: boolean;onAuthenticate: () => void;}) {+ // The same rule the rows follow: while the host is working, the only honest+ // thing to show is what it is doing. The runner would refuse these anyway.+ if (!canOfferAction(hostBusy, installing)) return null;const signInOffered = canSignIn(step, plan);const installable = canInstall(step);- const busy = installing || step.state === 'installing' || step.state === 'checking';+ const busy = installing || isStepInFlight(step);if (!signInOffered && !installable && !canSkip(step)) return null;return (@@ -231,6 +244,7 @@ export function SetupDetailSheet({onClose,onInstall,installingStepId,+ hostBusy,onSkip,skippingStepId,onAuthenticate,@@ -246,6 +260,8 @@ export function SetupDetailSheet({onClose: () => void;onInstall: (stepId: string) => void;installingStepId: string | null;+ /** True while any operation is running on this host. */+ hostBusy: boolean;onSkip: (stepId: string) => void;skippingStepId: string | null;onAuthenticate: () => void;@@ -280,6 +296,7 @@ export function SetupDetailSheet({plan={plan}onInstall={() => onInstall(target.step.id)}installing={installingStepId === target.step.id}+ hostBusy={hostBusy}onSkip={() => onSkip(target.step.id)}skipping={skippingStepId === target.step.id}onAuthenticate={onAuthenticate}@@ -296,6 +313,7 @@ export function SetupDetailSheet({activityFor={activityFor}onInstall={onInstall}installingStepId={installingStepId}+ hostBusy={hostBusy}onSkip={onSkip}skippingStepId={skippingStepId}onAuthenticate={onAuthenticate}@@ -316,6 +334,7 @@ function AgentTypeDetail({activityFor,onInstall,installingStepId,+ hostBusy,onSkip,skippingStepId,onAuthenticate,@@ -326,6 +345,8 @@ function AgentTypeDetail({activityFor: (stepId: string) => string | null;onInstall: (stepId: string) => void;installingStepId: string | null;+ /** True while any operation is running on this host. */+ hostBusy: boolean;onSkip: (stepId: string) => void;skippingStepId: string | null;onAuthenticate: () => void;@@ -351,6 +372,7 @@ function AgentTypeDetail({plan={plan}onInstall={() => onInstall(row.cli.id)}installing={installingStepId === row.cli.id}+ hostBusy={hostBusy}onSkip={() => onSkip(row.cli.id)}skipping={skippingStepId === row.cli.id}onAuthenticate={onAuthenticate}@@ -378,6 +400,7 @@ function AgentTypeDetail({plan={plan}onInstall={() => onInstall(row.plugin!.id)}installing={installingStepId === row.plugin.id}+ hostBusy={hostBusy}onSkip={() => onSkip(row.plugin!.id)}skipping={skippingStepId === row.plugin.id}onAuthenticate={onAuthenticate}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsxindex 0e1b89276..98755a6a5 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx@@ -22,11 +22,17 @@ import { Button } from '@renderer/lib/ui/button';import { Label } from '@renderer/lib/ui/label';import { StatusBadge } from '@renderer/lib/ui/status-badge';import { cn } from '@renderer/utils/utils';-import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';+import {+ isStepInFlight,+ type HostSetupPlan,+ type HostSetupStep,+} from '@shared/core/remote-hosts/setup';import {agentTypeBadge,canInstall,+ canOfferAction,canSignIn,+ canUpdate,signInLabel,stepBadge,type AgentTypeRow,@@ -162,7 +168,7 @@ function InstallAction({onInstall: () => void;}) {if (!canInstall(step)) return null;- const busy = installing || step.state === 'installing' || step.state === 'checking';+ const busy = installing || isStepInFlight(step);return (<Buttonsize="xs"@@ -183,16 +189,52 @@ function InstallAction({);}+/**+ * The inline Update control, shown only when a newer version is known to exist.+ *+ * Separate from Install because the step is already satisfied: this replaces+ * something working, rather than supplying something absent, and the two want+ * different words and different risk.+ */+function UpdateAction({+ step,+ updating,+ onUpdate,+}: {+ step: HostSetupStep;+ updating: boolean;+ onUpdate: () => void;+}) {+ if (!canUpdate(step)) return null;+ const busy = updating || step.state === 'updating';+ return (+ <Button+ size="xs"+ variant="outline"+ disabled={busy}+ title={step.latestVersion ? `Update to ${step.latestVersion}` : 'Update'}+ onClick={(event) => {+ event.stopPropagation();+ onUpdate();+ }}+ >+ {busy ? <Loader2 className="size-3.5 animate-spin" /> : 'Update'}+ </Button>+ );+}+export function PrerequisiteRow({step,plan,isCurrent,installing,+ updating,rechecking,hostBusy,activity,authenticating,onInstall,+ onUpdate,onRecheck,onAuthenticate,onOpen,@@ -202,6 +244,8 @@ export function PrerequisiteRow({plan: HostSetupPlan | null;isCurrent: boolean;installing: boolean;+ /** True while this row's update is the operation in flight. */+ updating: boolean;rechecking: boolean;/** True while any operation is running on this host. */hostBusy: boolean;@@ -209,6 +253,7 @@ export function PrerequisiteRow({/** True while the sign-in terminal for this step is already open. */authenticating: boolean;onInstall: () => void;+ onUpdate: () => void;onRecheck: () => void;onAuthenticate: () => void;onOpen: () => void;@@ -228,24 +273,28 @@ export function PrerequisiteRow({step satisfied, so it belongs beside it rather than one click awayinside the detail sheet.*/}- {canSignIn(step, plan) ? (- <Button- size="xs"- disabled={authenticating}- onClick={(event) => {- event.stopPropagation();- onAuthenticate();- }}- >- {signInLabel(step)}- </Button>- ) : (- <InstallAction step={step} installing={installing} onInstall={onInstall} />- )}+ {canOfferAction(hostBusy, installing || updating) &&+ (canSignIn(step, plan) ? (+ <Button+ size="xs"+ disabled={authenticating}+ onClick={(event) => {+ event.stopPropagation();+ onAuthenticate();+ }}+ >+ {signInLabel(step)}+ </Button>+ ) : (+ <>+ <UpdateAction step={step} updating={updating} onUpdate={onUpdate} />+ <InstallAction step={step} installing={installing} onInstall={onInstall} />+ </>+ ))}{/* Last, so the primary action keeps the same place whether or notthere is one to take. */}<RecheckAction- rechecking={rechecking}+ rechecking={rechecking || step.state === 'checking'}disabled={hostBusy}label={step.name}onRecheck={onRecheck}@@ -261,16 +310,20 @@ export function AgentTypeRowItem({row,isCurrent,installingStepId,+ updatingStepId,rechecking,hostBusy,activityFor,onInstall,+ onUpdate,onRecheck,onOpen,}: {row: AgentTypeRow;isCurrent: boolean;installingStepId: string | null;+ /** The step whose update is in flight, if any. */+ updatingStepId: string | null;/** True while either of this row's two steps is being re-checked. */rechecking: boolean;/** True while any operation is running on this host. */@@ -278,6 +331,7 @@ export function AgentTypeRowItem({/** A row covers two steps, so it asks per step which one is talking. */activityFor: (stepId: string) => string | null;onInstall: (stepId: string) => void;+ onUpdate: (stepId: string) => void;/** Re-checks both of the row's steps — it presents them as one thing. */onRecheck: () => void;onOpen: () => void;@@ -289,6 +343,13 @@ export function AgentTypeRowItem({: row.plugin && canInstall(row.plugin)? row.plugin: null;+ // Update the CLI before its connector when both are behind: the connector is+ // installed *through* the CLI, so the newer CLI is what will fetch it.+ const stale = canUpdate(row.cli)+ ? row.cli+ : row.plugin && canUpdate(row.plugin)+ ? row.plugin+ : null;return (<Rowicon={<AgentIcon id={row.agentId} size={16} />}@@ -299,7 +360,14 @@ export function AgentTypeRowItem({highlighted={isCurrent}action={<>- {next ? (+ {stale && canOfferAction(hostBusy, updatingStepId === stale.id) ? (+ <UpdateAction+ step={stale}+ updating={updatingStepId === stale.id}+ onUpdate={() => onUpdate(stale.id)}+ />+ ) : null}+ {next && canOfferAction(hostBusy, installingStepId === next.id) ? (<InstallActionstep={next}installing={installingStepId === next.id}@@ -307,7 +375,12 @@ export function AgentTypeRowItem({/>) : null}<RecheckAction- rechecking={rechecking}+ rechecking={+ rechecking ||+ row.cli.state === 'checking' ||+ row.plugin?.state === 'checking' ||+ false+ }disabled={hostBusy}label={row.name}onRecheck={onRecheck}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.tsindex 81c3547f5..5139c0497 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,7 +4,9 @@ import {agentTypeBadge,canInstall,canSkip,+ canOfferAction,canSignIn,+ canUpdate,dependenciesMet,groupPlanSteps,outcomeLabel,@@ -294,3 +296,66 @@ describe('canSignIn — the row and the sheet must agree', () => {expect(signInLabel(ghAuth())).toBe('Sign in');});});++/**+ * An available update is information, not a defect — but it has to be+ * actionable, and only when we actually know a newer version exists.+ */+describe('canUpdate', () => {+ it('offers an update when a newer version is known', () => {+ expect(+ canUpdate(step({ state: 'satisfied', latestVersion: '2.2.0', updateAvailable: true }))+ ).toBe(true);+ });++ it('offers nothing when the latest version could not be read', () => {+ // `updateAvailable` is never inferred from a missing latest version, and+ // this must not reintroduce that inference by the back door.+ expect(+ canUpdate(step({ state: 'satisfied', latestVersion: null, updateAvailable: false }))+ ).toBe(false);+ });++ it('offers nothing on something not installed — that is an install', () => {+ expect(canUpdate(step({ state: 'pending', outcome: 'missing', updateAvailable: true }))).toBe(+ false+ );+ });++ it('never offers to update a login', () => {+ expect(canUpdate(step({ kind: 'gh-auth', state: 'satisfied', updateAvailable: true }))).toBe(+ false+ );+ });++ it('offers nothing while the update is already running', () => {+ expect(canUpdate(step({ state: 'updating', updateAvailable: true }))).toBe(false);+ });+});++/**+ * The runner takes one operation per host and refuses the rest, so a button+ * offered during someone else's operation is a button that cannot work.+ */+describe('canOfferAction', () => {+ it('offers actions on an idle host', () => {+ expect(canOfferAction(false, false)).toBe(true);+ });++ it('withdraws them while the host is working', () => {+ expect(canOfferAction(true, false)).toBe(false);+ });++ it('keeps the button on the row whose own operation is running — it is the progress', () => {+ expect(canOfferAction(true, true)).toBe(true);+ });+});++describe('stepBadge — an update in flight', () => {+ it('says Updating, not Installing, about software already present', () => {+ expect(stepBadge(step({ state: 'updating' }))).toEqual({+ tone: 'info',+ label: 'Updating…',+ });+ });+});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.tsindex c51c27ce6..5c8cd0566 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@@ -58,12 +58,31 @@ export function canSkip(step: HostSetupStep): boolean {*/export function canInstall(step: HostSetupStep): boolean {if (step.kind === 'gh-auth') return false;- if (step.state === 'satisfied' || step.state === 'checking' || step.state === 'installing') {+ if (+ step.state === 'satisfied' ||+ step.state === 'checking' ||+ step.state === 'installing' ||+ step.state === 'updating'+ ) {return false;}return true;}+/**+ * Whether to offer an update for this step.+ *+ * Gated on `updateAvailable` alone, which is only ever true when a newer+ * version is *known* to exist — never inferred from a version we could not+ * read. A login has no version to replace, and something not yet installed+ * needs Install rather than Update.+ */+export function canUpdate(step: HostSetupStep): boolean {+ if (step.kind === 'gh-auth') return false;+ if (step.state !== 'satisfied') return false;+ return step.updateAvailable;+}+/*** Whether everything this step declares a dependency on has been satisfied.*@@ -87,7 +106,31 @@ export function dependenciesMet(step: HostSetupStep, plan: HostSetupPlan | null)* real problem.*/export function canSignIn(step: HostSetupStep, plan: HostSetupPlan | null): boolean {- return step.kind === 'gh-auth' && step.state !== 'satisfied' && dependenciesMet(step, plan);+ if (step.kind !== 'gh-auth') return false;+ // Same in-flight exclusion `canInstall` makes. A check moves the step through+ // `checking` on its way back to a verdict, and "not yet satisfied" during+ // that window is not the same fact as "signed out" — without this, re-checking+ // a working login flashes a Sign in button at someone already signed in.+ if (step.state === 'satisfied' || step.state === 'checking' || step.state === 'installing') {+ return false;+ }+ return dependenciesMet(step, plan);+}++/**+ * Whether a row may offer its fix-it action right now.+ *+ * Not while the host is busy. The runner takes one operation per host at a time+ * and refuses the rest, so an Install offered during a check is an offer that+ * cannot be honoured — clicking it raises "another setup operation is already+ * running", which reads as this dependency's fault rather than as the button+ * never having been live.+ *+ * The single exception is the row whose own install is the operation in flight:+ * there the button is the progress indicator.+ */+export function canOfferAction(hostBusy: boolean, isInstallingThisRow: boolean): boolean {+ return !hostBusy || isInstallingThisRow;}/**@@ -125,6 +168,8 @@ export function stepBadge(step: HostSetupStep): BadgeSpec {return { tone: 'info', label: 'Checking…' };case 'installing':return { tone: 'info', label: 'Installing…' };+ case 'updating':+ return { tone: 'info', label: 'Updating…' };case 'failed':return { tone: 'danger', label: outcomeLabel(step.outcome) };case 'skipped':@@ -161,7 +206,8 @@ export type AgentTypeRow = {*/export function agentTypeBadge(row: AgentTypeRow): BadgeSpec {const inFlight = [row.cli, row.plugin].find(- (step) => step?.state === 'checking' || step?.state === 'installing'+ (step) =>+ step?.state === 'checking' || step?.state === 'installing' || step?.state === 'updating');if (inFlight) return stepBadge(inFlight);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.tsindex 9f94acb7d..88592166e 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@@ -115,6 +115,16 @@ export function useInstallSetupStep(sshHost: string) {});}+/** Replace one step with its newest version — the per-row Update button. */+export function useUpdateSetupStep(sshHost: string) {+ const queryClient = useQueryClient();+ return useMutation({+ mutationFn: (stepId: string) => rpc.remoteHosts.updateSetupStep({ sshHost, stepId }),+ onSuccess: (plan) => queryClient.setQueryData(setupPlanQueryKey(sshHost), plan),+ onError: (error) => log.error('Could not update a setup step', { sshHost, error }),+ });+}+export function useSkipSetupStep(sshHost: string) {const queryClient = useQueryClient();return useMutation({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 5a12a2296..b506009e5 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@@ -49,6 +49,7 @@ import {useRecheckSetup,useRecheckSetupStep,useSkipSetupStep,+ useUpdateSetupStep,} from '../setup/use-host-setup';import { REMOTE_HOSTS_QUERY_KEY } from './remote-hosts-view';@@ -72,6 +73,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {const skip = useSkipSetupStep(sshHost);const installStep = useInstallSetupStep(sshHost);const recheckStep = useRecheckSetupStep(sshHost);+ const updateStep = useUpdateSetupStep(sshHost);const [authenticatingGh, setAuthenticatingGh] = useState(false);const [sheetTarget, setSheetTarget] = useState<SheetTarget | null>(null);@@ -98,8 +100,13 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {[plan.data]);const busy =- prepare.isPending || recheck.isPending || installStep.isPending || recheckStep.isPending;+ prepare.isPending ||+ recheck.isPending ||+ installStep.isPending ||+ recheckStep.isPending ||+ updateStep.isPending;const installingStepId = installStep.isPending ? (installStep.variables ?? null) : null;+ const updatingStepId = updateStep.isPending ? (updateStep.variables ?? null) : null;const recheckingStepId = recheckStep.isPending ? (recheckStep.variables ?? null) : null;const currentStepId = plan.data?.currentStepId ?? null;@@ -186,6 +193,11 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {Could not install: {(installStep.error as Error).message}</p>)}+ {updateStep.isError && (+ <p className="text-destructive text-xs">+ Could not update: {(updateStep.error as Error).message}+ </p>+ )}{recheck.isError && (<p className="text-destructive text-xs">Could not check this host: {(recheck.error as Error).message}@@ -217,11 +229,13 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {plan={plan.data ?? null}isCurrent={step.id === currentStepId}installing={installingStepId === step.id}+ updating={updatingStepId === step.id}rechecking={recheckingStepId === step.id}hostBusy={busy}activity={activityFor(step.id)}authenticating={authenticatingGh && step.kind === 'gh-auth'}onInstall={() => installStep.mutate(step.id)}+ onUpdate={() => updateStep.mutate(step.id)}onRecheck={() => recheckStep.mutate(step.id)}onAuthenticate={() => setAuthenticatingGh(true)}onOpen={() => setSheetTarget({ kind: 'prerequisite', step })}@@ -260,6 +274,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {row.cli.id === currentStepId || row.plugin?.id === currentStepId}installingStepId={installingStepId}+ updatingStepId={updatingStepId}rechecking={recheckingStepId === row.cli.id ||(row.plugin != null && recheckingStepId === row.plugin.id)@@ -267,6 +282,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {hostBusy={busy}activityFor={activityFor}onInstall={(stepId) => installStep.mutate(stepId)}+ onUpdate={(stepId) => updateStep.mutate(stepId)}onRecheck={() => void recheckAgentType(row)}onOpen={() => setSheetTarget({ kind: 'agent-type', row })}/>@@ -290,6 +306,7 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {onClose={() => setSheetTarget(null)}onInstall={(stepId) => installStep.mutate(stepId)}installingStepId={installingStepId}+ hostBusy={busy}onSkip={(stepId) => skip.mutate(stepId)}skippingStepId={skip.isPending ? (skip.variables ?? null) : null}onAuthenticate={() => {diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/stores/use-switch-setup.ts b/dash/apps/switchdash-desktop/src/renderer/lib/stores/use-switch-setup.tsindex ebc75c2cf..87985ed1c 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/stores/use-switch-setup.ts+++ b/dash/apps/switchdash-desktop/src/renderer/lib/stores/use-switch-setup.ts@@ -8,17 +8,22 @@ function switchSetupQueryKey(agentId: string) {}/**- * Agent types that can be onboarded into Switch right now — Switch-supported AND- * with their connector plugin installed. Drives the onboarding agent-type picker.- * When `sshHost` is set the availability is resolved on that remote host (over- * SSH) rather than the local machine, so a remote agent offers the types the- * host actually has installed.+ * Every Switch-capable agent type, each carrying whether it can be onboarded+ * here and — when it cannot — why. Drives the onboarding agent-type picker,+ * which shows the whole roster and greys out what is not set up rather than+ * hiding it (CHOO-1809).+ *+ * When `sshHost` is set, availability is resolved on that remote host over SSH+ * rather than on this machine: a type installed locally and absent on the host+ * being targeted is not available *there*, which is the question being asked.*/-export function useOnboardableAgentTypes(sshHost?: string) {+export function useAgentTypeAvailability(sshHost?: string) {return useQuery({- queryKey: ['switch-setup', 'onboardable', sshHost ?? 'local'] as const,+ queryKey: ['switch-setup', 'agent-type-availability', sshHost ?? 'local'] as const,queryFn: () =>- sshHost ? rpc.switchSetup.listOnboardableRemote(sshHost) : rpc.switchSetup.listOnboardable(),+ sshHost+ ? rpc.switchSetup.listAgentTypeAvailabilityRemote(sshHost)+ : rpc.switchSetup.listAgentTypeAvailability(),staleTime: 30_000,});}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.tsxindex 7f9787515..8482da12b 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@@ -82,7 +82,13 @@ async function render(node: React.ReactNode): Promise<HTMLDivElement> {function row(auth: HostSetupStep,ghState: HostSetupStep['state'] = 'satisfied',- overrides: { hostBusy?: boolean; rechecking?: boolean; onRecheck?: () => void } = {}+ overrides: {+ hostBusy?: boolean;+ rechecking?: boolean;+ updating?: boolean;+ onRecheck?: () => void;+ onUpdate?: () => void;+ } = {}) {return (<PrerequisiteRow@@ -90,11 +96,13 @@ function row(plan={planWith(auth, ghState)}isCurrent={false}installing={false}+ updating={overrides.updating ?? false}rechecking={overrides.rechecking ?? false}hostBusy={overrides.hostBusy ?? false}activity={null}authenticating={false}onInstall={() => {}}+ onUpdate={overrides.onUpdate ?? (() => {})}onRecheck={overrides.onRecheck ?? (() => {})}onAuthenticate={() => {}}onOpen={() => {}}@@ -205,3 +213,100 @@ describe('the per-row re-check', () => {expect(recheckButton(el)!.disabled).toBe(true);});});++/**+ * While a check runs, a row offers nothing but the check (CHOO-1809).+ *+ * Two separate defects produced the same complaint. A check moves a step+ * through `checking` on its way back to a verdict, and the sign-in predicate+ * read "not satisfied" as "signed out" — so re-checking a working GitHub login+ * flashed a Sign in button at someone already signed in. Meanwhile Install+ * stayed live on every other row, even though the runner takes one operation+ * per host and would have refused it.+ */+describe('actions while the host is working', () => {+ it('offers no Sign in while this row is mid-check', async () => {+ const el = await render(row(step({ state: 'checking' })));++ expect(buttonLabels(el)).not.toContain('Sign in');+ });++ it('offers no Sign in on a satisfied login being re-checked', async () => {+ // The case Louis hit: the button appeared on a login that was fine.+ const el = await render(+ row(step({ state: 'checking', outcome: 'satisfied', version: 'amaudruz' }))+ );++ expect(buttonLabels(el)).not.toContain('Sign in');+ expect(buttonLabels(el)).not.toContain('Re-authenticate');+ });++ it('withdraws Sign in from an idle row while the host is busy elsewhere', async () => {+ const el = await render(row(step({}), 'satisfied', { hostBusy: true }));++ expect(buttonLabels(el)).not.toContain('Sign in');+ });++ it('still shows the check control, so something says work is happening', async () => {+ const el = await render(row(step({}), 'satisfied', { hostBusy: true }));++ expect(recheckButton(el)).not.toBeNull();+ });+});++/** The Update action is the one thing the "Update available" badge was missing. */+describe('the update action', () => {+ const dep = (patch: Partial<HostSetupStep> = {}) =>+ step({+ id: 'git',+ kind: 'core-dependency',+ name: 'Git',+ dependsOn: [],+ state: 'satisfied',+ outcome: 'satisfied',+ version: '2.43.0',+ ...patch,+ });++ it('is offered when a newer version is known to exist', async () => {+ const el = await render(row(dep({ latestVersion: '2.44.0', updateAvailable: true })));++ expect(buttonLabels(el)).toContain('Update');+ });++ it('is not offered when nothing newer is known', async () => {+ const el = await render(row(dep()));++ expect(buttonLabels(el)).not.toContain('Update');+ });++ it('is not offered on a version we simply could not read', async () => {+ // `latestVersion: null` means "we could not tell", which is not grounds to+ // offer an update any more than it is grounds to claim currency.+ const el = await render(row(dep({ latestVersion: null, updateAvailable: false })));++ expect(buttonLabels(el)).not.toContain('Update');+ });++ it('calls back with the row it belongs to', async () => {+ const onUpdate = vi.fn();+ const el = await render(+ row(dep({ latestVersion: '2.44.0', updateAvailable: true }), 'satisfied', { onUpdate })+ );++ const button = [...el.querySelectorAll('button')].find(+ (b) => b.textContent?.trim() === 'Update'+ );+ await act(async () => button!.click());++ expect(onUpdate).toHaveBeenCalledTimes(1);+ });++ it('is withdrawn while the host is busy with something else', async () => {+ const el = await render(+ row(dep({ latestVersion: '2.44.0', updateAvailable: true }), 'satisfied', { hostBusy: true })+ );++ expect(buttonLabels(el)).not.toContain('Update');+ });+});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.tsindex 6a1c9b602..6fe77618a 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@@ -23,7 +23,13 @@*/import { isHostBlocked, type HostReachability } from './reachability';-import { agentTypeSteps, hostLevelSteps, type HostSetupPlan, type HostSetupStep } from './setup';+import {+ agentTypeSteps,+ hostLevelSteps,+ isStepInFlight,+ type HostSetupPlan,+ type HostSetupStep,+} from './setup';export type HostStatusKind =/** SSH authentication failed — will not self-heal, the user must fix it. */@@ -143,7 +149,7 @@ function deriveFromSteps(steps: HostSetupStep[]): HostStatus {// 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 = steps.find((step) => step.state === 'checking' || step.state === 'installing');+ const inFlight = steps.find(isStepInFlight);if (inFlight) {return {kind: 'setting-up',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.tsindex e8c2f1c59..e6556ec0f 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@@ -60,6 +60,10 @@ export function isInstallableOutcome(outcome: DependencyCheckOutcome | null): bo* - `pending` — not reached yet.* - `checking` — a probe is in flight.* - `installing` — an install is in flight.+ * - `updating` — a replacement of something already present is in flight.+ * Distinct from `installing` because the thing is not absent: if the update+ * fails, what was there before is (usually) still there. Collapsing the two+ * would have the row say "Installing…" about software the host already has.* - `satisfied` — verified present after the last observation.* - `failed` — the check or install failed; carries `error` (and `output` when* a command produced any). The run halts here.@@ -69,6 +73,7 @@ export type HostSetupStepState =| 'pending'| 'checking'| 'installing'+ | 'updating'| 'satisfied'| 'failed'| 'skipped';@@ -140,16 +145,26 @@ export type HostSetupPlan = {updatedAt: string;};-/** True while any step is being checked or installed. */+/**+ * True while a command is running against this step.+ *+ * Defined once because "is something happening here?" is asked from half a+ * dozen places — badges, tiles, buttons, the host verdict. Each used to spell+ * the state list out inline, so adding `updating` to the union would have left+ * most of them quietly treating an update in progress as idle.+ */+export function isStepInFlight(step: HostSetupStep): boolean {+ return step.state === 'checking' || step.state === 'installing' || step.state === 'updating';+}++/** True while any step is being checked, installed or updated. */export function isPlanBusy(plan: HostSetupPlan): boolean {- return plan.steps.some((step) => step.state === 'checking' || step.state === 'installing');+ return plan.steps.some(isStepInFlight);}/** The step currently being worked on, if any. */export function inFlightStep(plan: HostSetupPlan): HostSetupStep | null {- return (- plan.steps.find((step) => step.state === 'checking' || step.state === 'installing') ?? null- );+ return plan.steps.find(isStepInFlight) ?? null;}/** Required steps that are not yet satisfied — what stands between here and done. */diff --git a/dash/apps/switchdash-desktop/src/shared/core/switch-setup/agent-type-availability.ts b/dash/apps/switchdash-desktop/src/shared/core/switch-setup/agent-type-availability.tsnew file mode 100644index 000000000..c7d01070f--- /dev/null+++ b/dash/apps/switchdash-desktop/src/shared/core/switch-setup/agent-type-availability.ts@@ -0,0 +1,25 @@+/**+ * Whether an agent type can be onboarded here, and if not, why (CHOO-1809).+ *+ * The picker used to be handed only the usable types. That made "this type is+ * not set up on this host" indistinguishable from "this type does not exist" —+ * the dropdown simply had fewer rows and said nothing about the difference. A+ * user with Codex installed locally and not on the host they were targeting saw+ * it silently vanish.+ *+ * Carrying the blocked types along with their reason lets the picker show the+ * whole roster, grey out what cannot be chosen, and say what would make it+ * choosable.+ */+export type AgentTypeAvailability = {+ agentId: string;+ /** True only when this type can be onboarded here right now. */+ available: boolean;+ /**+ * Why it cannot be, in words fit to show a user. Null when it can.+ *+ * Always set when `available` is false — an option greyed out for no stated+ * reason is the silence this type exists to remove.+ */+ blockedReason: string | null;+};