Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(console): first-run feedback batch — search, icons, install progress, rooms, updates (#220)

Louis Amaudruz7015dd92e0d0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0efcec700..0f13e2b72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -517,6 +517,48 @@ version of their own to them without also giving them a release of their own.
clicking at each other. Replacement is otherwise unchanged: an older sidecar
is still replaced whoever deployed it, and a rebuild of your own is still
picked up.
+- Search results no longer read as though agents, sessions and commands were
+ servers. Those three had no heading of their own, so they were drawn after the
+ last group on screen — usually "Servers" — and appeared to belong to it. Every
+ result now sits under a heading that names it.
+- The server running on this computer shows a laptop everywhere — the sidebar
+ and search as well as the dialog that adds it. The sidebar and search each
+ chose the icon themselves; they now share one rule, so the next change lands
+ in all three at once.
+- The local server's setup log now fills as the work happens rather than all at
+ once at the end. Every line Docker printed was applied to the screen on its
+ own, and a pull narrates faster than the UI can redraw — so the renderer spent
+ the whole install rebuilding the list instead of painting it. Lines are
+ applied in batches now. The same fix covers a remote host's setup.
+- Setting up the local server no longer looks stalled before Docker says
+ anything. The output panel appeared only once the first line arrived, so the
+ seconds Docker spends resolving the registry showed as an empty dialog; the
+ panel is now there from the start and says what it is waiting for.
+- The command palette no longer opens onto a "Notifications" list of sessions
+ and rooms. It is a search field; the first thing under it should be what you
+ searched for.
+- Creating a room offers only the agents this Switch Console registered. The
+ server answers with everyone on it, including agents belonging to another
+ install — which this app cannot show under a room or drive.
+- Creating a room switches the sidebar to its Rooms list and selects the new
+ room. It was already opened in the main panel, but the sidebar stayed on
+ Agents, which does not list rooms — so the room you had just made was nowhere
+ in it.
+- Installing a Switch connector now finishes the onboarding step it belongs to.
+ The list of agent types you can onboard is cached separately from the agent's
+ own status, and the install refreshed everything but that — so the step stayed
+ unticked, and because the checklist locks each step behind the one above it,
+ the rest of onboarding stayed greyed out with nothing explaining why.
+
+#### Changed
+- An update to an agent's own CLI is no longer reported as though something were
+ wrong. It never gated anything, but an amber badge ahead of "Installed" read
+ like a fault on an agent that worked, and it was the nearest explanation for
+ onboarding appearing stuck. A newer CLI is now mentioned only on the agent's
+ own page, in plain text with the command that installs it.
+- The Switch connector's own updates keep their badge and gain a name —
+ "Connector update" rather than "Update available". That one is worth acting
+ on, and the two used to share a badge that could not say which was behind.
### [0.23.0] - 2026-08-14
diff --git a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.test.ts b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.test.ts
new file mode 100644
index 000000000..83a29fea0
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, it, vi } from 'vitest';
+import { composeUp } from './compose';
+import type { ServerHost } from './host/types';
+
+vi.mock('@main/lib/logger', () => ({ log: { error: vi.fn(), warn: vi.fn(), info: vi.fn() } }));
+
+function hostSpy() {
+ const streamCommand = vi.fn<
+ (bin: string, args: string[], onLog: (line: string) => void) => Promise<void>
+ >(() => Promise.resolve());
+ const host = {
+ label: 'this computer',
+ dockerBin: '/usr/local/bin/docker',
+ composeProjectName: 'switch-managed',
+ streamCommand,
+ } as unknown as ServerHost;
+ return { host, streamCommand };
+}
+
+describe('composeUp', () => {
+ /**
+ * `--progress` is a flag of `docker compose`, not of `up`. Passing it after
+ * the subcommand makes compose exit with "unknown flag" and takes the whole
+ * local-server install with it, so the position is the thing worth pinning.
+ */
+ it('asks for plain progress before the subcommand, where compose accepts it', async () => {
+ const { host, streamCommand } = hostSpy();
+
+ await composeUp(host, () => {});
+
+ const args = streamCommand.mock.calls[0]![1];
+ const progressAt = args.indexOf('--progress');
+
+ expect(args[progressAt + 1]).toBe('plain');
+ expect(progressAt).toBeGreaterThan(args.indexOf('compose'));
+ expect(progressAt).toBeLessThan(args.indexOf('up'));
+ });
+
+ it('still brings the stack up detached', async () => {
+ const { host, streamCommand } = hostSpy();
+
+ await composeUp(host, () => {});
+
+ expect(streamCommand.mock.calls[0]![1]).toEqual(expect.arrayContaining(['up', '-d']));
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.ts b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.ts
index 9086662b1..7d5401432 100644
--- a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.ts
+++ b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/compose.ts
@@ -11,9 +11,10 @@ function profileArgs(): string[] {
/** Base args that scope every invocation to the managed project + env file.
* Relative file names resolve against the host working dir (the ctx root). */
-function baseArgs(host: ServerHost): string[] {
+function baseArgs(host: ServerHost, globalFlags: string[]): string[] {
return [
'compose',
+ ...globalFlags,
'-f',
COMPOSE_FILE_NAME,
'--env-file',
@@ -46,9 +47,16 @@ async function runCompose(host: ServerHost, args: string[], timeout: number): Pr
*/
export function composeUp(host: ServerHost, onLog: (line: string) => void): Promise<void> {
log.info(`local-switch-server: docker compose up (${host.label})`);
- return host.streamCommand(host.dockerBin, [...baseArgs(host), 'up', '-d'], onLog, {
- timeoutMs: COMPOSE_TIMEOUT_MS,
- });
+ // Compose already falls back to plain, line-per-event output when it is not
+ // attached to a TTY, which is how we always run it — so this pins the
+ // behaviour we depend on rather than changing it. `--progress` belongs to
+ // `compose`, not to `up`; after the subcommand it exits with "unknown flag".
+ return host.streamCommand(
+ host.dockerBin,
+ [...baseArgs(host, ['--progress', 'plain']), 'up', '-d'],
+ onLog,
+ { timeoutMs: COMPOSE_TIMEOUT_MS }
+ );
}
/** Stop and remove the stack's containers. `removeVolumes` also destroys the
@@ -57,7 +65,7 @@ export async function composeDown(host: ServerHost, removeVolumes: boolean): Pro
log.info(`local-switch-server: docker compose down${removeVolumes ? ' -v' : ''} (${host.label})`);
await runCompose(
host,
- [...baseArgs(host), 'down', ...(removeVolumes ? ['-v'] : [])],
+ [...baseArgs(host, []), 'down', ...(removeVolumes ? ['-v'] : [])],
5 * 60 * 1000
);
}
@@ -67,7 +75,7 @@ export async function runningServices(host: ServerHost): Promise<string[]> {
try {
const stdout = await runCompose(
host,
- [...baseArgs(host), 'ps', '--status', 'running', '--services'],
+ [...baseArgs(host, []), 'ps', '--status', 'running', '--services'],
60_000
);
return stdout
@@ -97,7 +105,7 @@ export async function isStackRunning(host: ServerHost): Promise<boolean> {
export async function runningImages(host: ServerHost): Promise<Map<string, string>> {
const stdout = await runCompose(
host,
- [...baseArgs(host), 'ps', '--status', 'running', '--format', 'json'],
+ [...baseArgs(host, []), 'ps', '--status', 'running', '--format', 'json'],
60_000
);
const images = new Map<string, string>();
diff --git a/console/apps/switch-console-desktop/src/renderer/features/command-palette/command-palette-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/command-palette/command-palette-modal.tsx
index 558429685..71d609835 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/command-palette/command-palette-modal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/command-palette/command-palette-modal.tsx
@@ -5,7 +5,6 @@ import {
Bot,
DoorOpen,
Globe,
- HardDrive,
type LucideIcon,
MessageSquare,
Server,
@@ -16,6 +15,7 @@ import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import { REMOTE_HOSTS_QUERY_KEY } from '@renderer/features/remote-hosts/views/remote-hosts-view';
import { getSessionStore } from '@renderer/features/sessions/stores/session-selectors';
import { agentExpandKey } from '@renderer/features/sidebar/sidebar-store';
+import { serverIcon } from '@renderer/features/switch-servers/server-icon';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
import { commandRegistry } from '@renderer/lib/commands/registry';
@@ -34,10 +34,15 @@ import { ALL_COMMAND_DEFS, type CommandDef } from '@shared/commands';
import type { SearchItem, SearchResult } from '@shared/core/search';
import { getCommandIcon } from './command-icons';
import { PALETTE_ITEM_CLASS } from './palette-item-styles';
-import { PaletteNotificationsGroup } from './palette-notifications-group';
import { PaletteSessionItem } from './palette-session-item';
import { ResourceMonitorView } from './resource-monitor-view';
-import { applyContextAffinity, matchHosts, matchRooms, matchServers } from './search-utils';
+import {
+ applyContextAffinity,
+ matchHosts,
+ matchRooms,
+ matchServers,
+ sectionResults,
+} from './search-utils';
interface CommandPaletteProps {
locationId?: string;
@@ -85,12 +90,8 @@ const PaletteKindIcon = observer(function PaletteKindIcon({ item }: { item: Sear
}
case 'server': {
const server = switchServersStore.servers.find((s) => s.id === item.id);
- if (server?.managementKind === 'remote') return <Server className={MUTED_ICON} />;
- return server?.managed ? (
- <HardDrive className={MUTED_ICON} />
- ) : (
- <Globe className={MUTED_ICON} />
- );
+ const Icon = server ? serverIcon(server) : Globe;
+ return <Icon className={MUTED_ICON} />;
}
case 'host':
return <Server className={MUTED_ICON} />;
@@ -311,6 +312,33 @@ export function CommandPaletteModal({
: null;
const sessionResults = rankedDb.filter((r): r is SearchItem => r.kind === 'session');
+ // Sectioned only when the items actually answer the query. Under any other
+ // status they are recents or nothing, and rendering them as results is what
+ // made a too-short query look like a result set.
+ const indexed = sectionResults(searchResult.status === 'ok' ? rankedDb : []);
+
+ /** Indexed commands still registered and visible, paired with the live entry
+ * that executes them. Built here so the group knows whether it has rows
+ * before it renders a heading over none. */
+ const commandItems = indexed.command.flatMap((item) => {
+ const live = commandRegistry.findById(item.id);
+ if (!live || live.enabled === false || live.hideFromPalette) return [];
+ const def = ALL_COMMAND_DEFS.find((d) => d.id === item.id) as CommandDef | undefined;
+ const display: PaletteAction = {
+ kind: 'action',
+ id: item.id,
+ title: live.label,
+ subtitle: live.description,
+ shortcut: def?.shortcutKey ? getEffectiveHotkey(def.shortcutKey) : null,
+ icon: getCommandIcon(def?.iconKey),
+ execute: () => {
+ handleClose();
+ live.execute();
+ },
+ };
+ return [{ item: display, live }];
+ });
+
const handleNavigateToSession = (item: SearchItem) => {
if (!item.locationId) return;
const locationId = item.locationId;
@@ -363,6 +391,30 @@ export function CommandPaletteModal({
if (item.kind === 'host') return handleNavigateToHost(item);
};
+ /** A session row, rendered from its live store when there is one so it carries
+ * the same status as the sidebar; otherwise as a plain result. */
+ const renderSessionResult = (item: SearchItem) => {
+ const store = item.locationId ? getSessionStore(item.locationId, item.id) : null;
+ if (!store) {
+ return (
+ <PaletteItem
+ key={`session:${item.id}`}
+ value={`session:${item.id}`}
+ item={item}
+ onSelect={() => handleSelect(item)}
+ />
+ );
+ }
+ return (
+ <PaletteSessionItem
+ key={`session:${item.id}`}
+ sessionStore={store}
+ value={`session:${item.id}`}
+ onSelect={() => handleNavigateToSession(item)}
+ />
+ );
+ };
+
const handleResourceMonitorBack = useCallback(() => {
setView('search');
}, []);
@@ -427,95 +479,56 @@ export function CommandPaletteModal({
' Rooms, servers and hosts are matched from the first character.'}
</div>
)}
+ <PaletteResultGroup
+ heading="Agents"
+ items={indexed.agent}
+ onSelect={handleNavigateToAgent}
+ />
+ {indexed.session.length > 0 && (
+ <Command.Group heading="Sessions" className={GROUP_CLASS}>
+ {indexed.session.map(renderSessionResult)}
+ </Command.Group>
+ )}
<PaletteResultGroup
heading="Rooms"
- items={roomResults}
+ items={[...roomResults, ...indexed.room]}
onSelect={handleNavigateToRoom}
/>
<PaletteResultGroup
heading="Servers"
- items={serverResults}
+ items={[...serverResults, ...indexed.server]}
onSelect={handleNavigateToServer}
/>
<PaletteResultGroup
heading="Remote hosts"
- items={hostResults}
+ items={[...hostResults, ...indexed.host]}
onSelect={handleNavigateToHost}
/>
- {matchedResourceMonitor && (
- <PaletteItem
- value={matchedResourceMonitor.id}
- item={matchedResourceMonitor}
- onSelect={matchedResourceMonitor.execute}
- />
- )}
- {/* Only when the items actually answer the query. Under any other
- status they are recents or nothing, and rendering them here is
- what made a too-short query look like a result set. */}
- {searchResult.status === 'ok' &&
- rankedDb.map((item) => {
- if (item.kind === 'command') {
- const live = commandRegistry.findById(item.id);
- if (!live || live.enabled === false || live.hideFromPalette) return null;
- const def = ALL_COMMAND_DEFS.find((d) => d.id === item.id) as
- | CommandDef
- | undefined;
- const shortcut = def?.shortcutKey ? getEffectiveHotkey(def.shortcutKey) : null;
- const displayItem: PaletteAction = {
- kind: 'action',
- id: item.id,
- title: live.label,
- subtitle: live.description,
- shortcut,
- icon: getCommandIcon(def?.iconKey),
- execute: () => {
- handleClose();
- live.execute();
- },
- };
- return (
- <PaletteItem
- key={item.id}
- value={item.id}
- item={displayItem}
- onSelect={() => {
- handleClose();
- live.execute();
- }}
- />
- );
- }
- if (item.kind === 'session' && item.locationId) {
- const store = getSessionStore(item.locationId, item.id);
- if (store) {
- return (
- <PaletteSessionItem
- key={`session:${item.id}`}
- sessionStore={store}
- value={`session:${item.id}`}
- onSelect={() => handleNavigateToSession(item)}
- />
- );
- }
- }
- return (
+ {(matchedResourceMonitor || commandItems.length > 0) && (
+ <Command.Group heading="Commands" className={GROUP_CLASS}>
+ {matchedResourceMonitor && (
+ <PaletteItem
+ value={matchedResourceMonitor.id}
+ item={matchedResourceMonitor}
+ onSelect={matchedResourceMonitor.execute}
+ />
+ )}
+ {commandItems.map(({ item, live }) => (
<PaletteItem
- key={`${item.kind}:${item.id}`}
- value={`${item.kind}:${item.id}`}
+ key={item.id}
+ value={item.id}
item={item}
- onSelect={() => handleSelect(item)}
+ onSelect={() => {
+ handleClose();
+ live.execute();
+ }}
/>
- );
- })}
+ ))}
+ </Command.Group>
+ )}
</>
) : (
<>
- <PaletteNotificationsGroup
- currentLocationId={locationId}
- currentSessionId={sessionId}
- onClose={handleClose}
- navigate={navigate}
- />
{actionResults.length > 0 && (
<Command.Group heading="Suggested Actions" className={GROUP_CLASS}>
{actionResults.map((item) => (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-notifications-group.tsx b/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-notifications-group.tsx
deleted file mode 100644
index 4fc064533..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-notifications-group.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { Command } from 'cmdk';
-import { useObserver } from 'mobx-react-lite';
-import {
- asMounted,
- getLocationManagerStore,
-} from '@renderer/features/locations/stores/location-selectors';
-import { sessionAgentRegistry } from '@renderer/features/sessions/stores/session-agent-registry';
-import { isRegistered, type SessionStore } from '@renderer/features/sessions/stores/session-store';
-import type { NavigateFnTyped } from '@renderer/lib/layout/navigation-provider';
-import { cn } from '@renderer/utils/utils';
-import { PaletteSessionItem } from './palette-session-item';
-
-type NotificationItem = { locationId: string; sessionStore: SessionStore };
-
-const GROUP_CLASS = cn(
- '[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5',
- '[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
- '[&_[cmdk-group-heading]]:text-foreground/50'
-);
-
-interface PaletteNotificationsGroupProps {
- currentLocationId: string | undefined;
- currentSessionId: string | undefined;
- onClose: () => void;
- navigate: NavigateFnTyped;
-}
-
-export function PaletteNotificationsGroup({
- currentLocationId,
- currentSessionId,
- onClose,
- navigate,
-}: PaletteNotificationsGroupProps) {
- const items = useObserver((): NotificationItem[] => {
- const result: NotificationItem[] = [];
-
- for (const locationStore of getLocationManagerStore().locations.values()) {
- const mounted = asMounted(locationStore);
- if (!mounted) continue;
- const pid = mounted.data.id;
-
- for (const [tid, sessionStore] of mounted.sessionManager.sessions) {
- if (!isRegistered(sessionStore)) continue;
- const agent = sessionAgentRegistry.get(tid);
- if (!agent) continue;
-
- const status = agent.sessionStatus;
- // Only surface awaiting-input, error, completed — not working or idle.
- if (!status || status === 'idle' || status === 'working') continue;
-
- result.push({ locationId: pid, sessionStore });
- }
- }
-
- return result;
- });
-
- if (items.length === 0) return null;
-
- return (
- <Command.Group heading="Notifications" className={GROUP_CLASS}>
- {items.map((item) => (
- <PaletteSessionItem
- key={item.sessionStore.data.id}
- sessionStore={item.sessionStore}
- value={`notif:session:${item.sessionStore.data.id}`}
- onSelect={() => {
- if (
- item.locationId !== currentLocationId ||
- item.sessionStore.data.id !== currentSessionId
- ) {
- navigate('session', {
- locationId: item.locationId,
- sessionId: item.sessionStore.data.id,
- });
- }
- onClose();
- }}
- />
- ))}
- </Command.Group>
- );
-}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/command-palette/search-utils.ts b/console/apps/switch-console-desktop/src/renderer/features/command-palette/search-utils.ts
index 17ddd52db..38a7f6804 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/command-palette/search-utils.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/command-palette/search-utils.ts
@@ -122,3 +122,28 @@ export function matchHosts(
})
);
}
+
+/**
+ * Splits results into the sections the palette shows them under.
+ *
+ * The palette used to render indexed results ungrouped, after the room/server/
+ * host groups. A cmdk heading belongs to a group, and an item outside one is a
+ * sibling appended after the last group — so agents and sessions read as though
+ * they were more servers. Every result now belongs to a section.
+ *
+ * Keyed by every kind rather than the three the index emits today, so a kind it
+ * starts emitting lands in the section that already names it instead of
+ * silently vanishing.
+ */
+export function sectionResults(items: SearchItem[]): Record<SearchItemKind, SearchItem[]> {
+ const sections: Record<SearchItemKind, SearchItem[]> = {
+ agent: [],
+ session: [],
+ command: [],
+ room: [],
+ server: [],
+ host: [],
+ };
+ for (const entry of items) sections[entry.kind].push(entry);
+ return sections;
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx
index bcd2aa976..4060f3499 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx
@@ -33,8 +33,13 @@ import { hostSetupStore } from './host-setup-store';
const ICON = 'h-3.5 w-3.5 shrink-0 text-foreground-warning';
/**
- * This agent type's steps that are installed but behind — its CLI, its Switch
- * connector, or both.
+ * This agent type's Switch connector, when it is installed but behind.
+ *
+ * The agent's own CLI is deliberately excluded. A newer release of it changes
+ * nothing about whether the agent works here, and an icon in the sidebar is a
+ * claim that something wants attention — which put a mark against hosts that
+ * were entirely fine. The connector is ours and worth chasing; the CLI is
+ * reported on the host's own page, where someone has gone to look.
*
* Only steps carrying a known newer version qualify. `updateAvailable` is never
* set off a version we could not read, and it is additionally gated on the
@@ -44,7 +49,11 @@ const ICON = 'h-3.5 w-3.5 shrink-0 text-foreground-warning';
function staleStepsFor(plan: HostSetupPlan | null, agentId: string): HostSetupStep[] {
if (!plan) return [];
return agentTypeSteps(plan, agentId).filter(
- (step) => step.state === 'satisfied' && step.updateAvailable && step.latestVersion
+ (step) =>
+ step.kind === 'agent-plugin' &&
+ step.state === 'satisfied' &&
+ step.updateAvailable &&
+ step.latestVersion
);
}
@@ -100,10 +109,10 @@ export const HostTroubleIndicator = observer(function HostTroubleIndicator({
other two icons mean "broken", a refresh glyph reads as "retrying".
Same warning tone as those, so it belongs to the same family.
*/}
- <CircleFadingArrowUp className={ICON} aria-label="Update available" />
+ <CircleFadingArrowUp className={ICON} aria-label="Connector update available" />
</TooltipTrigger>
<TooltipContent>
- {`Update available on ${sshHost}: ${stale
+ {`Connector update available on ${sshHost}: ${stale
.map((step) => `${step.name} ${step.latestVersion}`)
.join(', ')}`}
</TooltipContent>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
index b26241d37..c7ae726ac 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/setup/step-presentation.ts
@@ -206,10 +206,11 @@ export function agentTypeBadge(row: AgentTypeRow): BadgeSpec {
if (row.plugin && row.plugin.state !== 'satisfied') {
return { tone: 'warning', label: 'Switch setup required' };
}
- // Either half being out of date is worth saying, and the row states one
- // question — is this usable, and is it current?
- if (row.cli.updateAvailable || row.plugin?.updateAvailable) {
- return { tone: 'warning', label: 'Update available' };
+ // Only the connector. A newer release of the agent's own CLI changes nothing
+ // about whether the agent works here, and reporting it in place of
+ // "Installed" made a working host look like it needed attention.
+ if (row.plugin?.updateAvailable) {
+ return { tone: 'warning', label: 'Connector update' };
}
return { tone: 'success', label: 'Installed' };
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRow.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRow.tsx
index 4636c906b..c47e22ed8 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRow.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRow.tsx
@@ -1,5 +1,4 @@
import { AgentIcon } from '@renderer/lib/components/agent-icon';
-import { getAgentUpdateActionState } from '@renderer/lib/components/agent-selector/agent-install';
import type { AgentPayload } from '@shared/core/providers/agent-payload';
import { AgentRowStatus } from './AgentRowStatus';
@@ -8,16 +7,6 @@ export const AgentRow = ({ agent, onClick }: { agent: AgentPayload; onClick?: ()
const isClickable = !!onClick;
const Tag = isClickable ? 'button' : 'div';
- const updates = agent.capabilities.hostDependency.updates;
- const updateStrategyKind = updates.kind === 'supported' ? updates.update.kind : 'none';
- const updateState = getAgentUpdateActionState({
- updateAvailable: agent.updateAvailable,
- updateStrategyKind,
- version: agent.version,
- latestVersion: agent.latestVersion,
- isUpdating: false,
- });
-
return (
<Tag
className={`group flex w-full items-center gap-3 rounded-lg p-3 hover:bg-background-1${isClickable ? ' cursor-pointer text-left' : ''}`}
@@ -34,7 +23,6 @@ export const AgentRow = ({ agent, onClick }: { agent: AgentPayload; onClick?: ()
agentId={agent.id}
supportsSwitch={agent.capabilities.switchSetup.kind !== 'none'}
cliInstalled={isInstalled}
- cliUpdateAvailable={!!updateState.render}
/>
</div>
</div>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRowStatus.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRowStatus.tsx
index c614a2220..fcc1ef116 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRowStatus.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/AgentRowStatus.tsx
@@ -1,9 +1,9 @@
import { useSwitchSetup } from '@renderer/lib/stores/use-switch-setup';
import {
+ ConnectorUpdateBadge,
InstalledBadge,
SwitchSetupRequiredBadge,
UninstalledBadge,
- UpdateAvailableBadge,
} from './agent-status-badge';
/**
@@ -14,65 +14,44 @@ import {
* the connector is set up. The intermediate "Switch setup required" state makes
* clear that an installed CLI is not yet usable on its own. Agent types with no
* Switch setup keep the plain installed/not-installed status.
+ *
+ * A newer version of the agent's own CLI is deliberately not reported here. It
+ * changes nothing about whether the agent works in Switch, and shown beside the
+ * name it read as a fault on an agent that was fine — the list answers "can I
+ * use this", and an optional upgrade is not an answer to that. It stays on the
+ * agent's own page, where someone has gone looking. The connector is the
+ * exception: it is ours, and a stale one is worth acting on.
*/
export function AgentRowStatus({
agentId,
supportsSwitch,
cliInstalled,
- cliUpdateAvailable,
}: {
agentId: string;
supportsSwitch: boolean;
cliInstalled: boolean;
- cliUpdateAvailable: boolean;
}) {
if (!supportsSwitch) {
- return (
- <>
- {cliUpdateAvailable && <UpdateAvailableBadge />}
- {cliInstalled ? <InstalledBadge /> : <UninstalledBadge />}
- </>
- );
+ return cliInstalled ? <InstalledBadge /> : <UninstalledBadge />;
}
- return (
- <SwitchAwareStatus
- agentId={agentId}
- cliInstalled={cliInstalled}
- cliUpdateAvailable={cliUpdateAvailable}
- />
- );
+ return <SwitchAwareStatus agentId={agentId} cliInstalled={cliInstalled} />;
}
-function SwitchAwareStatus({
- agentId,
- cliInstalled,
- cliUpdateAvailable,
-}: {
- agentId: string;
- cliInstalled: boolean;
- cliUpdateAvailable: boolean;
-}) {
+function SwitchAwareStatus({ agentId, cliInstalled }: { agentId: string; cliInstalled: boolean }) {
const { status, isLoading } = useSwitchSetup(agentId);
- const connectorUpdateAvailable = !!status?.installed && !!status.updateAvailable;
// Not on the machine yet — nothing else matters.
if (!cliInstalled) return <UninstalledBadge />;
// CLI installed; refine by connector state. While the connector status is
// still loading (or unexpectedly unsupported), fall back to plain Installed.
- const statusBadge =
- isLoading || !status?.supported ? (
- <InstalledBadge />
- ) : status.installed ? (
- <InstalledBadge />
- ) : (
- <SwitchSetupRequiredBadge />
- );
+ if (isLoading || !status?.supported) return <InstalledBadge />;
+ if (!status.installed) return <SwitchSetupRequiredBadge />;
return (
<>
- {(cliUpdateAvailable || connectorUpdateAvailable) && <UpdateAvailableBadge />}
- {statusBadge}
+ {status.updateAvailable && <ConnectorUpdateBadge />}
+ <InstalledBadge />
</>
);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/DependencyInstallationUpdateCard.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/DependencyInstallationUpdateCard.tsx
index 449ee1735..d08c271ba 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/DependencyInstallationUpdateCard.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/DependencyInstallationUpdateCard.tsx
@@ -127,6 +127,14 @@ export function DependencyInstallationUpdateCard({
return null;
}
+/**
+ * A newer release of the agent's own CLI.
+ *
+ * Presented plainly, not as a warning. Nothing in Switch needs the newest CLI —
+ * the agent works either way — so amber here put an alarm on a healthy agent
+ * and left people updating a tool they had no reason to touch. This is an
+ * offer: here is a newer version, and the command that installs it.
+ */
function UpdateCard({
versionArrow,
children,
@@ -138,14 +146,10 @@ function UpdateCard({
<div className="space-y-2 rounded-lg border p-3">
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
- <div className="flex size-6 items-center justify-center rounded-lg bg-background-warning">
- <RefreshCw
- className="size-3.5 shrink-0 text-foreground-warning"
- absoluteStrokeWidth
- strokeWidth={3}
- />
+ <div className="flex size-6 items-center justify-center rounded-lg bg-background-1">
+ <RefreshCw className="size-3.5 shrink-0 text-foreground-muted" />
</div>
- <span>Update available</span>
+ <span className="text-foreground-muted">Newer version available</span>
</div>
{versionArrow}
</div>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/SwitchSetupCard.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/SwitchSetupCard.tsx
index 46854b215..9d03b7f3f 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/SwitchSetupCard.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/SwitchSetupCard.tsx
@@ -8,7 +8,7 @@ import {
InstalledBadge,
InstallingBadge,
UninstalledBadge,
- UpdateAvailableBadge,
+ ConnectorUpdateBadge,
UpdatingBadge,
} from './agent-status-badge';
@@ -45,7 +45,7 @@ export function SwitchSetupCard({ agentId }: { agentId: string }) {
) : !status.installed ? (
<UninstalledBadge />
) : status.updateAvailable ? (
- <UpdateAvailableBadge />
+ <ConnectorUpdateBadge />
) : (
<InstalledBadge />
);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
index 0924bffda..ec4b72383 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/agent-status-badge.tsx
@@ -13,8 +13,16 @@ export function SwitchSetupRequiredBadge() {
return <StatusBadge tone="warning">Switch setup required</StatusBadge>;
}
-export function UpdateAvailableBadge() {
- return <StatusBadge tone="warning">Update available</StatusBadge>;
+/**
+ * The Switch connector is behind the version this build ships.
+ *
+ * Named for the connector rather than "Update available": the agent's own CLI
+ * can also be out of date, and that is between the user and their CLI. This one
+ * is ours, it is what lets the agent speak to Switch at all, and it is worth
+ * acting on — so it says which thing it means.
+ */
+export function ConnectorUpdateBadge() {
+ return <StatusBadge tone="warning">Connector update</StatusBadge>;
}
export function RecommendedBadge() {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
index a38b2459f..967117b39 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
@@ -288,7 +288,10 @@ const LocalSetupStep = observer(function LocalSetupStep({
<span>{store.message}</span>
</div>
)}
- <LogTail lines={store.logs} />
+ <LogTail
+ lines={store.logs}
+ placeholder={starting ? 'Waiting for Docker to report progress…' : null}
+ />
</div>
)}
</DialogContentArea>
@@ -351,7 +354,16 @@ function DockerStatus({
return null;
}
-function LogTail({ lines }: { lines: string[] }) {
+/**
+ * The command's output so far.
+ *
+ * `placeholder` keeps the panel on screen before the first line arrives. Docker
+ * is silent for a while at the start of a pull — it is resolving the registry,
+ * not stalled — and an empty space there read as nothing happening at all. It
+ * is styled apart from the output so it cannot be mistaken for a line docker
+ * printed.
+ */
+function LogTail({ lines, placeholder }: { lines: string[]; placeholder: string | null }) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
@@ -359,13 +371,16 @@ function LogTail({ lines }: { lines: string[] }) {
if (el) el.scrollTop = el.scrollHeight;
}, [lines]);
- if (lines.length === 0) return null;
+ if (lines.length === 0 && !placeholder) return null;
return (
<div
ref={ref}
className="max-h-48 overflow-auto rounded-md border border-border bg-background-tertiary p-2 font-mono text-[11px] leading-relaxed text-foreground-muted"
>
+ {lines.length === 0 && placeholder && (
+ <div className="text-foreground-tertiary-passive italic">{placeholder}</div>
+ )}
{lines.map((line, i) => (
// Log lines have no stable id; index is fine for an append-only tail.
<div key={i} className="break-all whitespace-pre-wrap">
@@ -542,7 +557,10 @@ const RemoteHostSetupStep = observer(function RemoteHostSetupStep({
<span>{status.message}</span>
</div>
)}
- <LogTail lines={logs} />
+ <LogTail
+ lines={logs}
+ placeholder={starting ? 'Waiting for Docker to report progress…' : null}
+ />
</div>
)}
</>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx
index d781f7175..7a0c69bbf 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { ChevronDown, X } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useCallback, useState } from 'react';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import { openRoomView } from '@renderer/features/sidebar/sidebar-room-grouping';
import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';
import { rpc } from '@renderer/lib/ipc';
@@ -78,6 +79,19 @@ export const CreateRoomModal = observer(function CreateRoomModal({
enabled: !!serverId,
});
+ /**
+ * Only agents this install registered on the server.
+ *
+ * The server answers with everyone registered on it, including agents
+ * belonging to somebody else's Switch Console. Those cannot be shown under a
+ * room here or driven from here, so offering them in the picker promises
+ * something this app cannot deliver — the same rule the room views already
+ * follow.
+ */
+ const invitableAgents = (agentsQuery.data ?? []).filter((remote) =>
+ agentsStore.agentsOnServer(serverId).some((local) => local.switchAgentId === remote.id)
+ );
+
// Only a running bridge can back a new room, and creating a room here means
// creating a channel on it — a bridge withheld from that (an operator's
// switch, or a platform like Telegram that has no such call at all) is just
@@ -133,9 +147,11 @@ export const CreateRoomModal = observer(function CreateRoomModal({
// appear with nothing under it until the next reconcile.
await refreshSidebarRoomState(true);
- // Open what was just created: expanded in the tree, and shown in the main
- // panel. Creating a room and being left where you were reads as if
- // nothing happened.
+ // Open what was just created: listed in the sidebar, expanded in the
+ // tree, and shown in the main panel. Creating a room and being left where
+ // you were reads as if nothing happened — and the agent grouping does not
+ // list rooms at all, so the new room would be nowhere on screen.
+ sidebarStore.setGrouping('room');
sidebarStore.ensureRoomExpanded(result.room.id);
openRoomView(result.room.id);
@@ -257,7 +273,7 @@ export const CreateRoomModal = observer(function CreateRoomModal({
<Field>
<FieldLabel>Agents</FieldLabel>
<Combobox
- items={(agentsQuery.data ?? []).filter((a) => !agents.some((s) => s.id === a.id))}
+ items={invitableAgents.filter((a) => !agents.some((s) => s.id === a.id))}
value={null}
onValueChange={(next: RemoteAgentSummary | null) => {
if (next) setAgents((current) => [...current, next]);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
index f8552dd08..fb66f9b38 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
@@ -3,11 +3,9 @@ import {
ChevronDown,
ChevronRight,
ExternalLink,
- Globe,
- HardDrive,
+ Laptop,
Pencil,
Plus,
- Server,
Trash2,
TriangleAlert,
} from 'lucide-react';
@@ -33,6 +31,7 @@ import { SidebarMenu, SidebarMenuButton } from '../sidebar/sidebar-primitives';
import { localServerStore } from './local-server-store';
import { remoteServerStore } from './remote-server-store';
import { serverAvailability } from './server-availability';
+import { serverIcon } from './server-icon';
import { switchServersStore } from './switch-servers-store';
export const ServersSidebarSection = observer(function ServersSidebarSection() {
@@ -130,7 +129,7 @@ const LocalServerPendingEntry = observer(function LocalServerPendingEntry({
return (
<SidebarMenuButton onClick={onOpen} className="justify-between">
<span className="flex min-w-0 items-center gap-2">
- <HardDrive className="size-4 shrink-0" />
+ <Laptop className="size-4 shrink-0" />
<span className="truncate">
{failed ? 'Local server (setup failed)' : 'Local Switch server'}
</span>
@@ -187,10 +186,8 @@ function ServerDriftIndicator({ drift }: { drift: SwitchVersionDrift }) {
}
function ServerIcon({ server, isScoped }: { server: SwitchServer; isScoped: boolean }) {
- const className = cn('size-4 shrink-0', isScoped && 'text-foreground');
- if (server.managementKind === 'remote') return <Server className={className} />;
- if (server.managed) return <HardDrive className={className} />;
- return <Globe className={className} />;
+ const Icon = serverIcon(server);
+ return <Icon className={cn('size-4 shrink-0', isScoped && 'text-foreground')} />;
}
const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: string }) {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-log-batching.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-log-batching.test.ts
new file mode 100644
index 000000000..d128dccf3
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-log-batching.test.ts
@@ -0,0 +1,91 @@
+import { autorun } from 'mobx';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * `docker compose` narrates a pull faster than the UI can redraw — hundreds of
+ * lines a second, for minutes, on a first run. One observable write per line
+ * meant one render of the whole dialog per line, each rebuilding the tail and
+ * measuring it to scroll, and the renderer never got to paint: the output
+ * appeared in one lump once the command fell quiet.
+ *
+ * What matters is the number of times observers are woken, not the lines
+ * themselves — so that is what these assert.
+ */
+
+vi.mock('@renderer/lib/ipc', () => ({
+ rpc: { localSwitchServer: {} },
+ events: { on: () => () => {} },
+}));
+vi.mock('@renderer/features/locations/stores/agents-store', () => ({ agentsStore: {} }));
+vi.mock('./switch-servers-store', () => ({
+ switchServersStore: { init: () => Promise.resolve() },
+}));
+
+import { LocalServerStore } from './local-server-store';
+
+let store: LocalServerStore;
+
+beforeEach(() => {
+ vi.useFakeTimers();
+ store = new LocalServerStore();
+});
+
+afterEach(() => {
+ vi.useRealTimers();
+});
+
+/** Counts how often anything observing the tail is woken. */
+function watchTail(target: LocalServerStore) {
+ let renders = 0;
+ const stop = autorun(() => {
+ // Reading length is what an observer of the tail does; the void keeps the
+ // read without leaving a bare expression behind.
+ void target.logs.length;
+ renders += 1;
+ });
+ return { count: () => renders, stop };
+}
+
+describe('the local server log tail', () => {
+ it('wakes observers once for a burst, not once per line', () => {
+ const tail = watchTail(store);
+ const before = tail.count();
+
+ for (let i = 0; i < 200; i += 1) store.queueLine(`layer ${i} downloading`);
+
+ // Nothing yet: a burst mid-flight must not repaint 200 times.
+ expect(tail.count()).toBe(before);
+
+ vi.advanceTimersByTime(200);
+
+ expect(tail.count()).toBe(before + 1);
+ expect(store.logs).toHaveLength(200);
+ tail.stop();
+ });
+
+ it('keeps the lines, and their order, across several batches', () => {
+ store.queueLine('first');
+ vi.advanceTimersByTime(200);
+ store.queueLine('second');
+ vi.advanceTimersByTime(200);
+
+ expect(store.logs).toEqual(['first', 'second']);
+ });
+
+ it('does not strand the last lines when the output stops', () => {
+ // These are the ones that say how it went, so they cannot wait on a timer
+ // that nothing will trigger.
+ store.queueLine('Container switch-1 Started');
+ store.flushLines();
+
+ expect(store.logs).toEqual(['Container switch-1 Started']);
+ });
+
+ it('still caps the tail when a batch overflows it', () => {
+ for (let i = 0; i < 500; i += 1) store.queueLine(`line ${i}`);
+ vi.advanceTimersByTime(200);
+
+ expect(store.logs).toHaveLength(400);
+ expect(store.logs.at(-1)).toBe('line 499');
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-store.ts
index 93c552e33..7fafd8945 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/local-server-store.ts
@@ -15,6 +15,19 @@ import { switchServersStore } from './switch-servers-store';
/** Cap the retained log tail so a long pull can't grow the buffer unbounded. */
const MAX_LOG_LINES = 400;
+/**
+ * How often the tail is allowed to repaint.
+ *
+ * `docker compose` reports a pull faster than a person can read and far faster
+ * than the UI can usefully redraw — a few images' worth of layers runs to
+ * hundreds of lines a second, sustained for minutes on a first run. One store
+ * write per line means one render of the whole dialog per line, each rebuilding
+ * the tail and measuring it to scroll; the renderer stops painting and the
+ * output only lands once the command falls quiet. Lines are collected and
+ * applied in batches instead.
+ */
+const LOG_FLUSH_MS = 100;
+
/**
* Renderer store for local-server mode. Mirrors the main-process supervisor's
* status (streamed over `localServerStatusChannel`) and exposes the lifecycle
@@ -32,9 +45,13 @@ export class LocalServerStore {
private off: (() => void) | null = null;
private offLog: (() => void) | null = null;
+ /** Lines received since the last flush. Not observable: reading it would
+ * defeat the batching it exists for. */
+ /* internal */ pendingLines: string[] = [];
+ /* internal */ flushTimer: ReturnType<typeof setTimeout> | null = null;
constructor() {
- makeAutoObservable(this);
+ makeAutoObservable(this, { pendingLines: false, flushTimer: false });
}
get phase(): LocalServerStatus['phase'] {
@@ -67,14 +84,7 @@ export class LocalServerStore {
});
}
if (!this.offLog) {
- this.offLog = events.on(localServerLogChannel, ({ line }) => {
- runInAction(() => {
- this.logs.push(line);
- if (this.logs.length > MAX_LOG_LINES) {
- this.logs.splice(0, this.logs.length - MAX_LOG_LINES);
- }
- });
- });
+ this.offLog = events.on(localServerLogChannel, ({ line }) => this.queueLine(line));
}
try {
const status = await rpc.localSwitchServer.getStatus();
@@ -86,11 +96,37 @@ export class LocalServerStore {
}
}
+ /** Collects a line for the next flush. Public for the batching test. */
+ queueLine(line: string): void {
+ this.pendingLines.push(line);
+ if (this.flushTimer) return;
+ this.flushTimer = setTimeout(() => this.flushLines(), LOG_FLUSH_MS);
+ }
+
+ /** Applies the batch. Exposed for tests and for the end of a run, where the
+ * last few lines must not wait on a timer that may never fire. */
+ flushLines(): void {
+ if (this.flushTimer) {
+ clearTimeout(this.flushTimer);
+ this.flushTimer = null;
+ }
+ if (this.pendingLines.length === 0) return;
+ const batch = this.pendingLines;
+ this.pendingLines = [];
+ runInAction(() => {
+ this.logs.push(...batch);
+ if (this.logs.length > MAX_LOG_LINES) {
+ this.logs.splice(0, this.logs.length - MAX_LOG_LINES);
+ }
+ });
+ }
+
dispose(): void {
this.off?.();
this.off = null;
this.offLog?.();
this.offLog = null;
+ this.flushLines();
}
async checkDocker(): Promise<void> {
@@ -105,6 +141,11 @@ export class LocalServerStore {
}
async start(): Promise<void> {
+ this.pendingLines = [];
+ if (this.flushTimer) {
+ clearTimeout(this.flushTimer);
+ this.flushTimer = null;
+ }
runInAction(() => {
this.busy = true;
this.error = null;
@@ -131,6 +172,9 @@ export class LocalServerStore {
} catch (cause) {
this.setError(cause);
} finally {
+ // The command has finished, so nothing more will arrive to trigger a
+ // flush — the tail's last lines are the ones that say how it went.
+ this.flushLines();
runInAction(() => {
this.busy = false;
});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/remote-server-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/remote-server-store.ts
index 2e0bff08c..e4960d27e 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/remote-server-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/remote-server-store.ts
@@ -15,6 +15,10 @@ import { switchServersStore } from './switch-servers-store';
const MAX_LOG_LINES = 400;
+/** See the local store: compose reports a pull faster than the UI can redraw,
+ * so lines are applied in batches rather than one render each. */
+const LOG_FLUSH_MS = 100;
+
function defaultStatus(sshHost: string): RemoteServerStatus {
return {
sshHost,
@@ -43,9 +47,39 @@ export class RemoteServerStore {
private off: (() => void) | null = null;
private offLog: (() => void) | null = null;
+ /** Lines received since the last flush, per host. Not observable. */
+ /* internal */ pendingByHost = new Map<string, string[]>();
+ /* internal */ flushTimer: ReturnType<typeof setTimeout> | null = null;
constructor() {
- makeAutoObservable(this);
+ makeAutoObservable(this, { pendingByHost: false, flushTimer: false });
+ }
+
+ private queueLine(sshHost: string, line: string): void {
+ const pending = this.pendingByHost.get(sshHost) ?? [];
+ pending.push(line);
+ this.pendingByHost.set(sshHost, pending);
+ if (this.flushTimer) return;
+ this.flushTimer = setTimeout(() => this.flushLines(), LOG_FLUSH_MS);
+ }
+
+ /** Applies the batched lines for every host. */
+ flushLines(): void {
+ if (this.flushTimer) {
+ clearTimeout(this.flushTimer);
+ this.flushTimer = null;
+ }
+ if (this.pendingByHost.size === 0) return;
+ const batches = this.pendingByHost;
+ this.pendingByHost = new Map();
+ runInAction(() => {
+ for (const [sshHost, batch] of batches) {
+ const lines = this.logsByHost.get(sshHost) ?? [];
+ lines.push(...batch);
+ if (lines.length > MAX_LOG_LINES) lines.splice(0, lines.length - MAX_LOG_LINES);
+ this.logsByHost.set(sshHost, lines);
+ }
+ });
}
statusFor(sshHost: string): RemoteServerStatus {
@@ -96,14 +130,9 @@ export class RemoteServerStore {
});
}
if (!this.offLog) {
- this.offLog = events.on(remoteServerLogChannel, ({ sshHost, line }) => {
- runInAction(() => {
- const lines = this.logsByHost.get(sshHost) ?? [];
- lines.push(line);
- if (lines.length > MAX_LOG_LINES) lines.splice(0, lines.length - MAX_LOG_LINES);
- this.logsByHost.set(sshHost, lines);
- });
- });
+ this.offLog = events.on(remoteServerLogChannel, ({ sshHost, line }) =>
+ this.queueLine(sshHost, line)
+ );
}
try {
const statuses = await rpc.remoteSwitchServer.getStatuses();
@@ -120,6 +149,7 @@ export class RemoteServerStore {
this.off = null;
this.offLog?.();
this.offLog = null;
+ this.flushLines();
}
async checkDocker(sshHost: string): Promise<void> {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-icon.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-icon.ts
new file mode 100644
index 000000000..0663800b7
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-icon.ts
@@ -0,0 +1,15 @@
+import { Globe, type LucideIcon, Laptop, Server } from 'lucide-react';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+
+/**
+ * Which icon stands for a server, by how it is run: a laptop for the stack on
+ * this computer, a server for one on a remote host, a globe for one reached by
+ * URL.
+ *
+ * Shared so the sidebar and the command palette cannot disagree — they render
+ * the same server in two places, and the picker that creates it is a third.
+ */
+export function serverIcon(server: SwitchServer): LucideIcon {
+ if (server.managementKind === 'remote') return Server;
+ return server.managed ? Laptop : Globe;
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/stores/use-switch-setup.ts b/console/apps/switch-console-desktop/src/renderer/lib/stores/use-switch-setup.ts
index 87985ed1c..f4711ec5d 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/stores/use-switch-setup.ts
+++ b/console/apps/switch-console-desktop/src/renderer/lib/stores/use-switch-setup.ts
@@ -7,6 +7,12 @@ function switchSetupQueryKey(agentId: string) {
return ['switch-setup', agentId] as const;
}
+/** Deliberately not under `switchSetupQueryKey`: this answers for every agent
+ * type at once, so it belongs to no single one of them. */
+function agentTypeAvailabilityQueryKey(sshHost: string | undefined) {
+ return ['switch-setup', 'agent-type-availability', sshHost ?? 'local'] as const;
+}
+
/**
* Every Switch-capable agent type, each carrying whether it can be onboarded
* here and — when it cannot — why. Drives the onboarding agent-type picker,
@@ -19,7 +25,7 @@ function switchSetupQueryKey(agentId: string) {
*/
export function useAgentTypeAvailability(sshHost?: string) {
return useQuery({
- queryKey: ['switch-setup', 'agent-type-availability', sshHost ?? 'local'] as const,
+ queryKey: agentTypeAvailabilityQueryKey(sshHost),
queryFn: () =>
sshHost
? rpc.switchSetup.listAgentTypeAvailabilityRemote(sshHost)
@@ -43,7 +49,21 @@ export function useSwitchSetup(agentId: string) {
staleTime: 30_000,
});
- const invalidate = () => void qc.invalidateQueries({ queryKey });
+ /**
+ * Installing or removing a connector changes two answers: this agent type's
+ * own status, and the roster of types that can be onboarded at all.
+ *
+ * The roster is cached under its own key, so the per-agent invalidation did
+ * not reach it. The onboarding checklist reads the roster to decide whether
+ * the agent-providers step is done — and it locks every later step behind the
+ * first unfinished one. Installing a connector therefore left the step
+ * unticked and the rest of onboarding greyed out until something else
+ * happened to refetch.
+ */
+ const invalidate = () => {
+ void qc.invalidateQueries({ queryKey });
+ void qc.invalidateQueries({ queryKey: ['switch-setup', 'agent-type-availability'] });
+ };
const checkForUpdates = useMutation({
mutationFn: () => rpc.switchSetup.checkForUpdates(agentId),
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/host-trouble-indicator.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/host-trouble-indicator.test.tsx
index e3b44a708..3daa66349 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/host-trouble-indicator.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/host-trouble-indicator.test.tsx
@@ -129,7 +129,35 @@ describe('the update indicator', () => {
it('appears when this agent’s connector is behind', async () => {
stores.plans.set('dev-vm', healthyPlan({ latestVersion: '0.8.0', updateAvailable: true }));
- expect(shows(await render(indicator()), 'Update available')).toBe(true);
+ expect(shows(await render(indicator()), 'Connector update available')).toBe(true);
+ });
+
+ it('ignores the agent CLI being behind, which is not a problem here', async () => {
+ // A newer `claude` does not stop the agent working on this host, and a mark
+ // in the sidebar reads as something needing attention.
+ stores.plans.set(
+ 'dev-vm',
+ plan([
+ step({}),
+ step({
+ id: 'claude',
+ kind: 'agent-cli',
+ name: 'Claude Code',
+ version: '2.1.0',
+ latestVersion: '2.2.0',
+ updateAvailable: true,
+ }),
+ step({
+ id: 'claude:plugin',
+ kind: 'agent-plugin',
+ name: 'Switch connector',
+ version: '0.7.7',
+ dependsOn: ['claude'],
+ }),
+ ])
+ );
+
+ expect(icons(await render(indicator()))).toBe(0);
});
it('stays away when everything is current', async () => {
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/switch-setup-invalidation.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/switch-setup-invalidation.test.tsx
new file mode 100644
index 000000000..6288f8321
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/switch-setup-invalidation.test.tsx
@@ -0,0 +1,102 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * Installing a connector has to reach the onboarding checklist.
+ *
+ * The checklist decides the agent-providers step from the roster of agent types
+ * that can be onboarded, which is cached under its own key — not under the
+ * agent's. Invalidating only the agent's key left the roster stale, so a
+ * successful install did not tick the step, and the checklist locks every later
+ * step behind the first unfinished one. The whole rest of onboarding went grey
+ * with nothing on screen saying why.
+ */
+
+const install = vi.hoisted(() => vi.fn(() => Promise.resolve({ success: true })));
+const getStatus = vi.hoisted(() =>
+ vi.fn(() =>
+ Promise.resolve({
+ agentId: 'claude',
+ supported: true,
+ installed: false,
+ installedVersion: null,
+ latestVersion: null,
+ updateAvailable: false,
+ refreshError: null,
+ })
+ )
+);
+
+vi.mock('@renderer/lib/ipc', () => ({
+ rpc: {
+ switchSetup: {
+ getStatus,
+ install,
+ update: vi.fn(),
+ uninstall: vi.fn(),
+ checkForUpdates: vi.fn(),
+ listAgentTypeAvailability: vi.fn(() => Promise.resolve([])),
+ listAgentTypeAvailabilityRemote: vi.fn(() => Promise.resolve([])),
+ },
+ },
+}));
+vi.mock('@renderer/lib/hooks/use-toast', () => ({ toast: vi.fn() }));
+
+import { useSwitchSetup } from '@renderer/lib/stores/use-switch-setup';
+
+const AVAILABILITY_KEY = ['switch-setup', 'agent-type-availability', 'local'];
+
+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;
+});
+
+/** Renders the hook and hands back its `install`, plus the shared client. */
+async function mountSwitchSetup() {
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ // Seeded as fresh so nothing refetches it except an invalidation.
+ queryClient.setQueryData(AVAILABILITY_KEY, []);
+
+ let installConnector: () => void = () => {};
+ function Probe() {
+ installConnector = useSwitchSetup('claude').install;
+ return null;
+ }
+
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ await act(async () =>
+ root!.render(
+ <QueryClientProvider client={queryClient}>
+ <Probe />
+ </QueryClientProvider>
+ )
+ );
+
+ return { queryClient, installConnector: () => installConnector() };
+}
+
+describe('installing a Switch connector', () => {
+ it('marks the onboardable agent types stale, so the checklist re-reads them', async () => {
+ const { queryClient, installConnector } = await mountSwitchSetup();
+
+ expect(queryClient.getQueryState(AVAILABILITY_KEY)?.isInvalidated).toBe(false);
+
+ await act(async () => {
+ installConnector();
+ await vi.waitFor(() =>
+ expect(queryClient.getQueryState(AVAILABILITY_KEY)?.isInvalidated).toBe(true)
+ );
+ });
+
+ expect(install).toHaveBeenCalled();
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/palette-search-utils.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/palette-search-utils.test.ts
index 4df845232..10fb96ec3 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/palette-search-utils.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/tests/palette-search-utils.test.ts
@@ -4,6 +4,7 @@ import {
matchHosts,
matchRooms,
matchServers,
+ sectionResults,
} from '@renderer/features/command-palette/search-utils';
import type { SearchItem } from '@shared/core/search';
import type { RemoteRoomSummary, SwitchServer } from '@shared/core/switch-servers/switch-servers';
@@ -206,3 +207,46 @@ describe('applyContextAffinity', () => {
expect(items.map((i) => i.id)).toEqual(['b', 'a']);
});
});
+
+/**
+ * Every result must land in a section. The palette renders sections as cmdk
+ * groups, and a row outside one is appended after the last group — which is how
+ * agents and sessions came to sit under the "Servers" heading.
+ */
+describe('sectionResults', () => {
+ const item = (kind: SearchItem['kind'], id: string): SearchItem => ({
+ kind,
+ id,
+ locationId: null,
+ sessionId: null,
+ title: id,
+ subtitle: '',
+ score: 0,
+ });
+
+ it('splits the kinds the index emits into their own sections', () => {
+ const sections = sectionResults([
+ item('agent', 'a1'),
+ item('session', 's1'),
+ item('command', 'c1'),
+ item('agent', 'a2'),
+ ]);
+
+ expect(sections.agent.map((i) => i.id)).toEqual(['a1', 'a2']);
+ expect(sections.session.map((i) => i.id)).toEqual(['s1']);
+ expect(sections.command.map((i) => i.id)).toEqual(['c1']);
+ });
+
+ it('keeps a section for every kind, so none can go unrendered', () => {
+ const kinds: SearchItem['kind'][] = ['agent', 'session', 'command', 'room', 'server', 'host'];
+ const sections = sectionResults(kinds.map((kind) => item(kind, kind)));
+
+ for (const kind of kinds) expect(sections[kind].map((i) => i.id)).toEqual([kind]);
+ });
+
+ it('preserves the ranked order within a section', () => {
+ const sections = sectionResults([item('agent', 'first'), item('agent', 'second')]);
+
+ expect(sections.agent.map((i) => i.id)).toEqual(['first', 'second']);
+ });
+});