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): put Sign in on the row and open its terminal there (CHOO-1809)

switch-worker-louis-remotee649762e9aca
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-detail-sheet.tsx
index b2fc263b7..3169dff6c 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
@@ -24,9 +24,10 @@ import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/set
import {
agentTypeBadge,
canInstall,
+ canSignIn,
canSkip,
- dependenciesMet,
outcomeLabel,
+ signInLabel,
stepBadge,
type AgentTypeRow,
} from './step-presentation';
@@ -141,7 +142,7 @@ function ObservationCard({
function StepActions({
step,
- dependenciesSatisfied,
+ plan,
onInstall,
installing,
onSkip,
@@ -149,27 +150,24 @@ function StepActions({
onAuthenticate,
}: {
step: HostSetupStep;
- /** False while something this step depends on is still outstanding. */
- dependenciesSatisfied: boolean;
+ /** Needed to tell whether this step's own prerequisites are in place. */
+ plan: HostSetupPlan | null;
onInstall: () => void;
installing: boolean;
onSkip: () => void;
skipping: boolean;
onAuthenticate: () => void;
}) {
- // Only offer the GitHub sign-in once gh itself is there — the device flow
- // runs `gh` on the host, so offering it before the CLI exists sends the user
- // into a failure that says nothing about the real problem.
- const canSignIn = step.kind === 'gh-auth' && step.state !== 'satisfied' && dependenciesSatisfied;
+ const signInOffered = canSignIn(step, plan);
const installable = canInstall(step);
const busy = installing || step.state === 'installing' || step.state === 'checking';
- if (!canSignIn && !installable && !canSkip(step)) return null;
+ if (!signInOffered && !installable && !canSkip(step)) return null;
return (
<div className="flex shrink-0 items-center gap-1.5">
- {canSignIn && (
+ {signInOffered && (
<Button size="xs" onClick={onAuthenticate}>
- {step.error?.includes('read:packages') ? 'Re-authenticate' : 'Sign in'}
+ {signInLabel(step)}
</Button>
)}
{installable && (
@@ -279,7 +277,7 @@ export function SetupDetailSheet({
actions={
<StepActions
step={target.step}
- dependenciesSatisfied={dependenciesMet(target.step, plan)}
+ plan={plan}
onInstall={() => onInstall(target.step.id)}
installing={installingStepId === target.step.id}
onSkip={() => onSkip(target.step.id)}
@@ -350,7 +348,7 @@ function AgentTypeDetail({
actions={
<StepActions
step={row.cli}
- dependenciesSatisfied={dependenciesMet(row.cli, plan)}
+ plan={plan}
onInstall={() => onInstall(row.cli.id)}
installing={installingStepId === row.cli.id}
onSkip={() => onSkip(row.cli.id)}
@@ -377,7 +375,7 @@ function AgentTypeDetail({
</div>
<StepActions
step={row.plugin}
- dependenciesSatisfied={dependenciesMet(row.plugin, plan)}
+ plan={plan}
onInstall={() => onInstall(row.plugin!.id)}
installing={installingStepId === row.plugin.id}
onSkip={() => onSkip(row.plugin!.id)}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/setup/setup-rows.tsx
index 3b9862125..0f7378e71 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
@@ -14,10 +14,12 @@ 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 { HostSetupStep } from '@shared/core/remote-hosts/setup';
+import type { HostSetupPlan, HostSetupStep } from '@shared/core/remote-hosts/setup';
import {
agentTypeBadge,
canInstall,
+ canSignIn,
+ signInLabel,
stepBadge,
type AgentTypeRow,
type BadgeSpec,
@@ -138,17 +140,25 @@ function InstallAction({
export function PrerequisiteRow({
step,
+ plan,
isCurrent,
installing,
activity,
+ authenticating,
onInstall,
+ onAuthenticate,
onOpen,
}: {
step: HostSetupStep;
+ /** Needed to tell whether this step's own prerequisites are in place. */
+ plan: HostSetupPlan | null;
isCurrent: boolean;
installing: boolean;
activity: string | null;
+ /** True while the sign-in terminal for this step is already open. */
+ authenticating: boolean;
onInstall: () => void;
+ onAuthenticate: () => void;
onOpen: () => void;
}) {
return (
@@ -159,7 +169,25 @@ export function PrerequisiteRow({
progress={activity}
badge={stepBadge(step)}
highlighted={isCurrent}
- action={<InstallAction step={step} installing={installing} onInstall={onInstall} />}
+ action={
+ // Signing in is this row's install: it is the one action that makes the
+ // step satisfied, so it belongs beside it rather than one click away
+ // inside 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} />
+ )
+ }
onClick={onOpen}
/>
);
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 861b321bd..fabe424bf 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,9 +4,11 @@ import {
agentTypeBadge,
canInstall,
canSkip,
+ canSignIn,
dependenciesMet,
groupPlanSteps,
outcomeLabel,
+ signInLabel,
stepBadge,
} from './step-presentation';
@@ -243,3 +245,50 @@ describe('dependenciesMet — do not offer an action that cannot work', () => {
expect(dependenciesMet(ghAuth(), null)).toBe(false);
});
});
+
+describe('canSignIn — the row and the sheet must agree', () => {
+ // Both surfaces offer this button, so the rule lives in one place: two copies
+ // of it is how the sheet once hid Sign in in exactly the state that needs it.
+ const ghAuth = (patch: Partial<HostSetupStep> = {}) =>
+ step({ id: 'gh:auth', kind: 'gh-auth', name: 'GitHub CLI login', dependsOn: ['gh'], ...patch });
+ const withGh = (auth: HostSetupStep) =>
+ plan([step({ id: 'gh', name: 'GitHub CLI', state: 'satisfied', outcome: 'satisfied' }), auth]);
+
+ it('is offered for an outstanding login once gh is installed', () => {
+ const p = withGh(ghAuth({ outcome: 'missing' }));
+
+ expect(canSignIn(p.steps[1]!, p)).toBe(true);
+ });
+
+ it('is offered after a re-check leaves the step pending', () => {
+ // The state a host actually sits in when the user wants this button.
+ const p = withGh(ghAuth({ state: 'pending', outcome: 'missing' }));
+
+ expect(canSignIn(p.steps[1]!, p)).toBe(true);
+ });
+
+ it('is not offered once the login is good', () => {
+ const p = withGh(ghAuth({ state: 'satisfied', outcome: 'satisfied' }));
+
+ expect(canSignIn(p.steps[1]!, p)).toBe(false);
+ });
+
+ it('is not offered while gh itself is missing', () => {
+ const p = plan([step({ id: 'gh', name: 'GitHub CLI', outcome: 'missing' }), ghAuth()]);
+
+ expect(canSignIn(p.steps[1]!, p)).toBe(false);
+ });
+
+ it('is never offered for something that is not a login', () => {
+ expect(canSignIn(step({ id: 'git', outcome: 'missing' }), null)).toBe(false);
+ });
+
+ it('says re-authenticate when the login exists but lacks the scope', () => {
+ // "Sign in" reads as wrong advice to someone already signed in, even though
+ // re-running the flow is the fix.
+ expect(signInLabel(ghAuth({ error: 'gh is missing the read:packages scope' }))).toBe(
+ 'Re-authenticate'
+ );
+ expect(signInLabel(ghAuth())).toBe('Sign in');
+ });
+});
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 79737fc89..e2b88984d 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
@@ -77,6 +77,26 @@ export function dependenciesMet(step: HostSetupStep, plan: HostSetupPlan | null)
);
}
+/**
+ * Whether to offer the GitHub sign-in for this step.
+ *
+ * Only once `gh` itself is installed: the device flow runs `gh` on the host, so
+ * offering it earlier sends the user into a failure that says nothing about the
+ * real problem.
+ */
+export function canSignIn(step: HostSetupStep, plan: HostSetupPlan | null): boolean {
+ return step.kind === 'gh-auth' && step.state !== 'satisfied' && dependenciesMet(step, plan);
+}
+
+/**
+ * A login that exists but lacks a scope is not signed out, and telling someone
+ * already signed in to "sign in" reads as wrong advice — even though re-running
+ * the flow is in fact the fix.
+ */
+export function signInLabel(step: HostSetupStep): string {
+ return step.error?.includes('read:packages') ? 'Re-authenticate' : 'Sign in';
+}
+
export type BadgeSpec = { tone: StatusTone; label: string };
/**
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/remote-hosts/views/remote-host-view.tsx
index 630139b34..0c81131e7 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
@@ -192,12 +192,33 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
<div key={step.id} className="w-full py-0.5">
<PrerequisiteRow
step={step}
+ plan={plan.data ?? null}
isCurrent={step.id === currentStepId}
installing={installingStepId === step.id}
activity={activityFor(step.id)}
+ authenticating={authenticatingGh && step.kind === 'gh-auth'}
onInstall={() => installStep.mutate(step.id)}
+ onAuthenticate={() => setAuthenticatingGh(true)}
onOpen={() => setSheetTarget({ kind: 'prerequisite', step })}
/>
+ {/*
+ Opens against the row it belongs to rather than at the
+ foot of the page: the terminal is the continuation of
+ that one row's Sign in, and appending it below
+ everything else meant scrolling away from the thing you
+ just clicked to find it.
+ */}
+ {authenticatingGh && step.kind === 'gh-auth' && (
+ <div className="px-3 pt-2 pb-1">
+ <GhAuthPanel
+ sshHost={sshHost}
+ onDone={() => {
+ setAuthenticatingGh(false);
+ recheck.mutate();
+ }}
+ />
+ </div>
+ )}
</div>
))}
</section>
@@ -223,22 +244,6 @@ export const RemoteHostMainPanel = observer(function RemoteHostMainPanel() {
</div>
)}
- {/*
- The GitHub device flow needs a real terminal the user types into, so
- it runs inline rather than in a dialog — switchdash disables terminal
- input while a dialog is open. Re-check on close so the step reflects
- what actually happened rather than assuming it worked.
- */}
- {authenticatingGh && (
- <GhAuthPanel
- sshHost={sshHost}
- onDone={() => {
- setAuthenticatingGh(false);
- recheck.mutate();
- }}
- />
- )}
-
<SetupDetailSheet
target={liveTarget}
sshHost={sshHost}
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
new file mode 100644
index 000000000..9f2d5f701
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/tests/browser/remote-host-prerequisite-row.test.tsx
@@ -0,0 +1,138 @@
+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;
+});
+
+/**
+ * The action a prerequisite row offers has to be on the row (CHOO-1809).
+ *
+ * The GitHub login is the case that went wrong: it was the only prerequisite
+ * whose fix lived exclusively in the detail sheet, so the row showed "Not
+ * installed" and no way to do anything about it — you had to know to click
+ * through. Every other row had its Install button in plain sight.
+ */
+import { PrerequisiteRow } from '@renderer/features/remote-hosts/setup/setup-rows';
+import type { HostSetupPlan, 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: 'gh:auth',
+ kind: 'gh-auth',
+ name: 'GitHub CLI login',
+ state: 'pending',
+ outcome: 'missing',
+ version: null,
+ error: null,
+ output: null,
+ optional: false,
+ dependsOn: ['gh'],
+ updatedAt: '2026-02-02T00:00:00.000Z',
+ ...patch,
+ };
+}
+
+function planWith(auth: HostSetupStep, ghState: HostSetupStep['state']): HostSetupPlan {
+ return {
+ sshHost: 'dev-vm',
+ status: 'idle',
+ steps: [
+ {
+ ...step({ id: 'gh', kind: 'core-dependency', name: 'GitHub CLI', dependsOn: [] }),
+ state: ghState,
+ outcome: ghState === 'satisfied' ? 'satisfied' : 'missing',
+ },
+ auth,
+ ],
+ currentStepId: null,
+ createdAt: '2026-02-02T00:00:00.000Z',
+ updatedAt: '2026-02-02T00:00:00.000Z',
+ };
+}
+
+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;
+}
+
+function row(auth: HostSetupStep, ghState: HostSetupStep['state'] = 'satisfied') {
+ return (
+ <PrerequisiteRow
+ step={auth}
+ plan={planWith(auth, ghState)}
+ isCurrent={false}
+ installing={false}
+ activity={null}
+ authenticating={false}
+ onInstall={() => {}}
+ onAuthenticate={() => {}}
+ onOpen={() => {}}
+ />
+ );
+}
+
+function buttonLabels(el: HTMLElement): string[] {
+ return [...el.querySelectorAll('button')].map((b) => b.textContent?.trim() ?? '');
+}
+
+describe('the GitHub login row', () => {
+ it('offers Sign in on the row itself, not only inside the sheet', async () => {
+ const el = await render(row(step({})));
+
+ expect(buttonLabels(el)).toContain('Sign in');
+ });
+
+ it('says Re-authenticate when the login exists but lacks read:packages', async () => {
+ const el = await render(row(step({ error: 'gh is missing the read:packages scope' })));
+
+ expect(buttonLabels(el)).toContain('Re-authenticate');
+ });
+
+ it('offers nothing while gh itself is still missing', async () => {
+ // The device flow runs `gh` on the host. A Sign in button here would only
+ // produce a failure that says nothing about the real problem.
+ const el = await render(row(step({}), 'pending'));
+
+ expect(buttonLabels(el)).not.toContain('Sign in');
+ });
+
+ it('offers no action once the login is good', async () => {
+ // The row itself is a button (it opens the detail sheet), so this asks that
+ // no *action* is offered rather than that no button exists.
+ const el = await render(
+ row(step({ state: 'satisfied', outcome: 'satisfied', version: 'amaudruz' }))
+ );
+
+ expect(buttonLabels(el)).not.toContain('Sign in');
+ expect(buttonLabels(el)).not.toContain('Re-authenticate');
+ expect(buttonLabels(el)).not.toContain('Install');
+ });
+
+ it('never offers Install for a login — it is a device flow, not a package', async () => {
+ const el = await render(row(step({})));
+
+ expect(buttonLabels(el)).not.toContain('Install');
+ });
+});
diff --git a/dash/apps/switchdash-desktop/vitest.config.ts b/dash/apps/switchdash-desktop/vitest.config.ts
index b3ee12eab..c89c77496 100644
--- a/dash/apps/switchdash-desktop/vitest.config.ts
+++ b/dash/apps/switchdash-desktop/vitest.config.ts
@@ -1,4 +1,5 @@
import { resolve } from 'node:path';
+import tailwindcss from '@tailwindcss/vite';
import { playwright } from '@vitest/browser-playwright';
import { defineConfig } from 'vitest/config';
@@ -81,9 +82,15 @@ export default defineConfig({
},
},
{
- // Renderer terminal tests that need a real browser environment
- // (real CSS layout, ResizeObserver, requestAnimationFrame, WebGL).
+ // Renderer tests that need a real browser environment (real CSS
+ // layout, ResizeObserver, requestAnimationFrame, WebGL).
extends: true,
+ // Tailwind runs here for the same reason it runs in the app build:
+ // without it every utility class resolves to nothing, so anything
+ // rendered in these tests is unstyled and no test can say a word about
+ // how it looks. `electron.vite.config.ts` is the app's build and does
+ // not apply to Vitest.
+ plugins: [tailwindcss()],
test: {
name: 'browser',
browser: {