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): split an agent type into CLI and connector rows (CHOO-1809)
Louis Amaudruz28890502ae65
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 98755a6a5..e2ebf953b 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@@ -12,6 +12,7 @@ import {Github,KeyRound,Package,+ Puzzle,RefreshCw,Server,SquareTerminal,@@ -28,7 +29,6 @@ import {type HostSetupStep,} from '@shared/core/remote-hosts/setup';import {- agentTypeBadge,canInstall,canOfferAction,canSignIn,@@ -306,12 +306,72 @@ export function PrerequisiteRow({);}+/**+ * The three controls a step row offers, in a fixed order.+ *+ * Order is deliberate and shared: Update, Install, then Re-check. The re-check+ * sits last so the primary action keeps the same place whether or not there is+ * one to take.+ */+function StepControls({+ step,+ installing,+ updating,+ rechecking,+ hostBusy,+ label,+ onInstall,+ onUpdate,+ onRecheck,+}: {+ step: HostSetupStep;+ installing: boolean;+ updating: boolean;+ rechecking: boolean;+ hostBusy: boolean;+ label: string;+ onInstall: () => void;+ onUpdate: () => void;+ onRecheck: () => void;+}) {+ return (+ <>+ {canOfferAction(hostBusy, installing || updating) && (+ <>+ <UpdateAction step={step} updating={updating} onUpdate={onUpdate} />+ <InstallAction step={step} installing={installing} onInstall={onInstall} />+ </>+ )}+ <RecheckAction+ rechecking={rechecking || step.state === 'checking'}+ disabled={hostBusy}+ label={label}+ onRecheck={onRecheck}+ />+ </>+ );+}++/**+ * An agent type: its CLI, and its Switch connector indented beneath it.+ *+ * The two were one row with one badge and one button, on the theory that a user+ * thinks of an agent type as a single thing. That hid which half needed work and+ * gave the connector no controls of its own — you could not update it, and its+ * "Switch setup required" state named no action.+ *+ * They are now separate rows, with the connector indented under the CLI to show+ * what it hangs off. That relationship is real, not decorative: the connector is+ * installed *by* the CLI, so with the CLI absent there is nothing to install it+ * with — the sub-row says what it is waiting for instead of offering a button+ * that would fail.+ */export function AgentTypeRowItem({row,- isCurrent,+ currentStepId,installingStepId,updatingStepId,- rechecking,+ recheckingStepId,hostBusy,activityFor,onInstall,@@ -320,74 +380,87 @@ export function AgentTypeRowItem({onOpen,}: {row: AgentTypeRow;- isCurrent: boolean;+ /** The step the plan says is in flight — highlights that row, not both. */+ currentStepId: string | null;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;+ /** The step being re-checked, if any. */+ recheckingStepId: string | null;/** True while any operation is running on this host. */hostBusy: boolean;/** 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;+ onRecheck: (stepId: string) => void;onOpen: () => void;}) {- // Fix whichever half is outstanding: the CLI first, then its connector. One- // button, because the row states one question — is this usable?- const next = canInstall(row.cli)- ? row.cli- : 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;+ const plugin = row.plugin;+ // The connector is installed through the agent's own CLI. Until that exists,+ // an Install button here is an offer we cannot honour.+ const cliReady = row.cli.state === 'satisfied';return (- <Row- icon={<AgentIcon id={row.agentId} size={16} />}- name={row.name}- subtitle={row.cli.state === 'satisfied' ? row.cli.version : null}- progress={activityFor(row.cli.id) ?? (row.plugin ? activityFor(row.plugin.id) : null)}- badge={agentTypeBadge(row)}- highlighted={isCurrent}- action={- <>- {stale && canOfferAction(hostBusy, updatingStepId === stale.id) ? (- <UpdateAction- step={stale}- updating={updatingStepId === stale.id}- onUpdate={() => onUpdate(stale.id)}- />- ) : null}- {next && canOfferAction(hostBusy, installingStepId === next.id) ? (- <InstallAction- step={next}- installing={installingStepId === next.id}- onInstall={() => onInstall(next.id)}- />- ) : null}- <RecheckAction- rechecking={- rechecking ||- row.cli.state === 'checking' ||- row.plugin?.state === 'checking' ||- false- }- disabled={hostBusy}+ <>+ <Row+ icon={<AgentIcon id={row.agentId} size={16} />}+ name={row.name}+ subtitle={row.cli.state === 'satisfied' ? row.cli.version : null}+ progress={activityFor(row.cli.id)}+ badge={stepBadge(row.cli)}+ highlighted={currentStepId === row.cli.id}+ action={+ <StepControls+ step={row.cli}+ installing={installingStepId === row.cli.id}+ updating={updatingStepId === row.cli.id}+ rechecking={recheckingStepId === row.cli.id}+ hostBusy={hostBusy}label={row.name}- onRecheck={onRecheck}+ onInstall={() => onInstall(row.cli.id)}+ onUpdate={() => onUpdate(row.cli.id)}+ onRecheck={() => onRecheck(row.cli.id)}/>- </>- }- onClick={onOpen}- />+ }+ onClick={onOpen}+ />++ {plugin && (+ // Indented and rule-marked, so the connector reads as belonging to the+ // CLI above rather than as a seventh thing on the host.+ <div className="ml-6 border-l border-border pl-3">+ <Row+ icon={<Puzzle className="size-4 text-foreground-muted" />}+ name="Switch connector"+ subtitle={+ cliReady+ ? plugin.state === 'satisfied'+ ? plugin.version+ : null+ : `Needs ${row.name} first`+ }+ progress={activityFor(plugin.id)}+ badge={stepBadge(plugin)}+ highlighted={currentStepId === plugin.id}+ action={+ cliReady ? (+ <StepControls+ step={plugin}+ installing={installingStepId === plugin.id}+ updating={updatingStepId === plugin.id}+ rechecking={recheckingStepId === plugin.id}+ hostBusy={hostBusy}+ label={`the ${row.name} Switch connector`}+ onInstall={() => onInstall(plugin.id)}+ onUpdate={() => onUpdate(plugin.id)}+ onRecheck={() => onRecheck(plugin.id)}+ />+ ) : null+ }+ onClick={onOpen}+ />+ </div>+ )}+ </>);}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 77de73042..48067adf5 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@@ -41,7 +41,7 @@ import {PrerequisiteRow,SectionLabel,} from '../setup/setup-rows';-import { groupPlanSteps, type AgentTypeRow } from '../setup/step-presentation';+import { groupPlanSteps } from '../setup/step-presentation';import {useHostSetupPlan,useInstallSetupStep,@@ -117,18 +117,6 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {const recheckingStepId = recheckStep.isPending ? (recheckStep.variables ?? null) : null;const currentStepId = plan.data?.currentStepId ?? null;- // An agent type is presented as one thing, so its re-check covers both of its- // steps. Sequential because the runner takes one operation per host at a time- // — firing them together would only make the second fail.- const recheckAgentType = async (row: AgentTypeRow) => {- try {- await recheckStep.mutateAsync(row.cli.id);- if (row.plugin) await recheckStep.mutateAsync(row.plugin.id);- } catch {- // The mutation's onError already reports it; this only stops the second- // step running after the first failed.- }- };// Read inside render so mobx tracks it: the line changes several times a// second while an install runs, and nothing else re-renders on that.const activityFor = (stepId: string) => hostSetupStore.activityFor(sshHost, stepId);@@ -284,20 +272,15 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {<div key={row.agentId} className="w-full py-0.5"><AgentTypeRowItemrow={row}- isCurrent={- row.cli.id === currentStepId || row.plugin?.id === currentStepId- }+ currentStepId={currentStepId}installingStepId={installingStepId}updatingStepId={updatingStepId}- rechecking={- recheckingStepId === row.cli.id ||- (row.plugin != null && recheckingStepId === row.plugin.id)- }+ recheckingStepId={recheckingStepId}hostBusy={busy}activityFor={activityFor}onInstall={(stepId) => installStep.mutate(stepId)}onUpdate={(stepId) => updateStep.mutate(stepId)}- onRecheck={() => void recheckAgentType(row)}+ onRecheck={(stepId) => recheckStep.mutate(stepId)}onOpen={() => setSheetTarget({ kind: 'agent-type', row })}/></div>diff --git a/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-agent-type-row.test.tsx b/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-agent-type-row.test.tsxnew file mode 100644index 000000000..fde4dd6b8--- /dev/null+++ b/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-agent-type-row.test.tsx@@ -0,0 +1,252 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';++// The row's sibling components reach the renderer IPC bridge at import time,+// which only exists inside Electron. Hoisted so it is in place before those+// modules are evaluated. Nothing under test calls through it.+vi.hoisted(() => {+ window.electronAPI ??= {+ invoke: () => Promise.resolve(undefined),+ eventOn: () => () => {},+ eventSend: () => {},+ } as unknown as typeof window.electronAPI;+});++/**+ * An agent type is two things, and the page has to admit it (CHOO-1809).+ *+ * The CLI and its Switch connector were one row with one badge and one button.+ * That hid which half needed work, and left the connector with no controls of+ * its own — there was no way to update it, and "Switch setup required" named no+ * action you could take.+ */+vi.mock('@renderer/lib/components/agent-icon', () => ({+ AgentIcon: () => null,+}));++import { AgentTypeRowItem } from '@renderer/features/remote-hosts/setup/setup-rows';+import type { AgentTypeRow } from '@renderer/features/remote-hosts/setup/step-presentation';+import type { HostSetupStep } from '@shared/core/remote-hosts/setup';++let container: HTMLDivElement | null = null;+let root: Root | null = null;++afterEach(async () => {+ if (root) await act(async () => root!.unmount());+ container?.remove();+ container = null;+ root = null;+});++function step(patch: Partial<HostSetupStep>): HostSetupStep {+ return {+ id: 'claude',+ kind: 'agent-cli',+ name: 'Claude Code',+ state: 'pending',+ outcome: 'missing',+ version: null,+ latestVersion: null,+ updateAvailable: false,+ error: null,+ output: null,+ optional: false,+ dependsOn: ['node'],+ updatedAt: '2026-02-02T00:00:00.000Z',+ ...patch,+ };+}++function agentRow(+ cli: Partial<HostSetupStep>,+ plugin: Partial<HostSetupStep> | null+): AgentTypeRow {+ return {+ agentId: 'claude',+ name: 'Claude Code',+ cli: step(cli),+ plugin: plugin+ ? step({+ id: 'claude:plugin',+ kind: 'agent-plugin',+ name: 'Claude Code · Switch connector',+ dependsOn: ['claude'],+ ...plugin,+ })+ : null,+ };+}++async function render(node: React.ReactNode): Promise<HTMLDivElement> {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+ await act(async () => root!.render(node));+ return container;+}++type Overrides = {+ hostBusy?: boolean;+ installingStepId?: string | null;+ updatingStepId?: string | null;+ recheckingStepId?: string | null;+ onInstall?: (stepId: string) => void;+ onUpdate?: (stepId: string) => void;+ onRecheck?: (stepId: string) => void;+};++function view(row: AgentTypeRow, overrides: Overrides = {}) {+ return (+ <AgentTypeRowItem+ row={row}+ currentStepId={null}+ installingStepId={overrides.installingStepId ?? null}+ updatingStepId={overrides.updatingStepId ?? null}+ recheckingStepId={overrides.recheckingStepId ?? null}+ hostBusy={overrides.hostBusy ?? false}+ activityFor={() => null}+ onInstall={overrides.onInstall ?? (() => {})}+ onUpdate={overrides.onUpdate ?? (() => {})}+ onRecheck={overrides.onRecheck ?? (() => {})}+ onOpen={() => {}}+ />+ );+}++const text = (el: HTMLElement) => el.textContent ?? '';+const buttons = (el: HTMLElement) => [...el.querySelectorAll('button')];+const labels = (el: HTMLElement) => buttons(el).map((b) => b.textContent?.trim() ?? '');+const recheckButtons = (el: HTMLElement) => [+ ...el.querySelectorAll<HTMLButtonElement>('button[aria-label^="Re-check"]'),+];++describe('the connector as its own row', () => {+ it('shows the connector beneath the CLI', async () => {+ const el = await render(view(agentRow({ state: 'satisfied' }, { state: 'satisfied' })));++ expect(text(el)).toContain('Claude Code');+ expect(text(el)).toContain('Switch connector');+ });++ it('gives each half its own re-check', async () => {+ const el = await render(view(agentRow({ state: 'satisfied' }, { state: 'satisfied' })));++ expect(recheckButtons(el)).toHaveLength(2);+ });++ it('re-checks only the step whose button was clicked', async () => {+ const onRecheck = vi.fn();+ const el = await render(+ view(agentRow({ state: 'satisfied' }, { state: 'satisfied' }), { onRecheck })+ );++ await act(async () => recheckButtons(el)[1]!.click());++ expect(onRecheck).toHaveBeenCalledExactlyOnceWith('claude:plugin');+ });++ it('installs the connector, not the CLI, from the connector row', async () => {+ const onInstall = vi.fn();+ const el = await render(+ view(agentRow({ state: 'satisfied' }, { state: 'pending', outcome: 'missing' }), {+ onInstall,+ })+ );++ const install = buttons(el).find((b) => b.textContent?.trim() === 'Install');+ await act(async () => install!.click());++ expect(onInstall).toHaveBeenCalledExactlyOnceWith('claude:plugin');+ });++ it('offers the connector its own update', async () => {+ const onUpdate = vi.fn();+ const el = await render(+ view(+ agentRow(+ { state: 'satisfied', version: '2.1.0' },+ { state: 'satisfied', version: '0.7.6', latestVersion: '0.7.7', updateAvailable: true }+ ),+ { onUpdate }+ )+ );++ const update = buttons(el).find((b) => b.textContent?.trim() === 'Update');+ await act(async () => update!.click());++ expect(onUpdate).toHaveBeenCalledExactlyOnceWith('claude:plugin');+ });++ it('can update one half while the other is current', async () => {+ // Two rows, two verdicts: an out-of-date CLI and an out-of-date connector+ // are different facts and each gets its own button.+ const el = await render(+ view(+ agentRow(+ { state: 'satisfied', version: '2.1.0', latestVersion: '2.2.0', updateAvailable: true },+ { state: 'satisfied', version: '0.7.7' }+ )+ )+ );++ expect(labels(el).filter((l) => l === 'Update')).toHaveLength(1);+ });+});++/**+ * The connector is installed *by* the agent's own CLI, so with the CLI absent+ * there is nothing to install it with. Offering the button anyway produced a+ * failure that named the connector rather than the missing CLI.+ */+describe('the connector depends on the CLI', () => {+ const cliMissing = agentRow(+ { state: 'pending', outcome: 'missing' },+ { state: 'pending', outcome: 'missing' }+ );++ it('offers no install for the connector while the CLI is missing', async () => {+ const el = await render(view(cliMissing));++ // The CLI's own Install is still offered — exactly one, not two.+ expect(labels(el).filter((l) => l === 'Install')).toHaveLength(1);+ });++ it('says what it is waiting for instead', async () => {+ const el = await render(view(cliMissing));++ expect(text(el)).toContain('Needs Claude Code first');+ });++ it('offers the connector its actions once the CLI is there', async () => {+ const el = await render(+ view(agentRow({ state: 'satisfied' }, { state: 'pending', outcome: 'missing' }))+ );++ expect(labels(el).filter((l) => l === 'Install')).toHaveLength(1);+ expect(recheckButtons(el)).toHaveLength(2);+ });+});++describe('a plan with no connector step', () => {+ it('renders the CLI alone rather than an empty sub-row', async () => {+ // Plans persisted before connector steps existed have no plugin half.+ const el = await render(view(agentRow({ state: 'satisfied' }, null)));++ expect(text(el)).not.toContain('Switch connector');+ expect(recheckButtons(el)).toHaveLength(1);+ });+});++describe('actions while the host is working', () => {+ it('withdraws both rows’ actions, keeping only the checks', async () => {+ const el = await render(+ view(agentRow({ state: 'satisfied' }, { state: 'pending', outcome: 'missing' }), {+ hostBusy: true,+ })+ );++ expect(labels(el)).not.toContain('Install');+ expect(recheckButtons(el)).toHaveLength(2);+ });+});