Skip to content

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

Bug fix/console bug roundup 2 (#267)

Louis Amaudruz1ff9f684c591
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 b07f8c820..231f44be6 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
@@ -1,17 +1,8 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { Command } from 'cmdk';
-import {
- Activity,
- Bot,
- DoorOpen,
- Globe,
- type LucideIcon,
- MessageSquare,
- Server,
-} from 'lucide-react';
+import { Activity, DoorOpen, Globe, type LucideIcon, MessageSquare, Server } from 'lucide-react';
import { observer, useObserver } from 'mobx-react-lite';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
-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';
@@ -20,7 +11,6 @@ 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';
-import { AgentIcon } from '@renderer/lib/components/agent-icon';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
import { useDebounce } from '@renderer/lib/hooks/useDebounce';
import { getEffectiveHotkey } from '@renderer/lib/hooks/useKeyboardShortcuts';
@@ -34,6 +24,7 @@ import { cn } from '@renderer/utils/utils';
import { ALL_COMMAND_DEFS, type CommandDef } from '@shared/commands';
import type { SearchItem, SearchResult } from '@shared/core/search';
import { getCommandIcon } from './command-icons';
+import { PaletteAgentItem } from './palette-agent-item';
import { PALETTE_ITEM_CLASS } from './palette-item-styles';
import { PaletteSessionItem } from './palette-session-item';
import { ResourceMonitorView } from './resource-monitor-view';
@@ -66,21 +57,16 @@ const MUTED_ICON = 'size-3.5 shrink-0 text-foreground/40';
* The icon a result carries in the left sidebar.
*
* Deliberately not a static kind→glyph map: the sidebar's icons are conditional
- * — an agent shows its provider's mark, a room its bridge platform, a server its
- * management kind — so a flat map can only ever approximate them. Resolving from
- * the same stores the sidebar reads keeps the two in step instead of leaving a
- * second set of lookalikes to drift.
+ * — a room shows its bridge platform, a server its management kind — so a flat
+ * map can only ever approximate them. Resolving from the same stores the sidebar
+ * reads keeps the two in step instead of leaving a second set of lookalikes to
+ * drift.
+ *
+ * Agents are not here: they wear their own picture, which needs a query, so
+ * `PaletteAgentItem` draws the whole row.
*/
const PaletteKindIcon = observer(function PaletteKindIcon({ item }: { item: SearchItem }) {
switch (item.kind) {
- case 'agent': {
- const providerId = agentsStore.agentById(item.id)?.providerId;
- return providerId ? (
- <AgentIcon id={providerId} size={14} className="shrink-0" />
- ) : (
- <Bot className={MUTED_ICON} />
- );
- }
case 'room': {
const bridgeType = switchRoomsStore.roomBridgeTypeById(item.id);
return hasBridgeIcon(bridgeType) ? (
@@ -133,6 +119,9 @@ function PaletteItem({
item: SearchItem | PaletteAction;
onSelect: () => void;
}) {
+ if (item.kind === 'agent') {
+ return <PaletteAgentItem item={item as SearchItem} value={value} onSelect={onSelect} />;
+ }
const action = item.kind === 'action' ? (item as PaletteAction) : null;
const ActionIcon = action?.icon;
const iconNode = ActionIcon ? (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-agent-item.tsx b/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-agent-item.tsx
new file mode 100644
index 000000000..a8e7ab034
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/command-palette/palette-agent-item.tsx
@@ -0,0 +1,57 @@
+import { Command } from 'cmdk';
+import { Bot } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { AgentAvatar } from '@renderer/lib/components/agent-avatar';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { sidebarStore } from '@renderer/lib/stores/app-state';
+import { useAgentIconUrl } from '@renderer/lib/stores/use-remote-agents';
+import type { SearchItem } from '@shared/core/search';
+import { PALETTE_ITEM_CLASS } from './palette-item-styles';
+
+/**
+ * An agent row, laid out like the sidebar's (`sidebar/agent-item.tsx`): the
+ * agent's own face leads, and what it runs on follows its name as a small mark.
+ *
+ * A row of its own rather than a branch of `PaletteKindIcon`, because the
+ * chosen icon comes from a query keyed by server and a hook cannot be called
+ * from inside a switch. An agent this app does not hold — a hit whose local row
+ * has gone — still gets the bot drawn from its name, which is the same face the
+ * Switch bridges show.
+ */
+export const PaletteAgentItem = observer(function PaletteAgentItem({
+ item,
+ value,
+ onSelect,
+}: {
+ item: SearchItem;
+ value: string;
+ onSelect: () => void;
+}) {
+ const agent = agentsStore.agentById(item.id);
+ const iconUrl = useAgentIconUrl(agent?.serverId ?? null, agent?.switchAgentId ?? null);
+
+ return (
+ <Command.Item value={value} onSelect={onSelect} className={PALETTE_ITEM_CLASS}>
+ {/* 16px inside a 14px slot, so the circle carries the same weight as the
+ glyphs on the other rows without widening the icon column. */}
+ <span className="flex size-3.5 shrink-0 items-center justify-center">
+ <AgentAvatar
+ name={item.title}
+ iconUrl={iconUrl}
+ size={16}
+ className="-mx-px bg-transparent"
+ />
+ </span>
+ <span className="flex min-w-0 flex-1 items-center gap-1.5">
+ <span className="truncate">{item.title}</span>
+ {!sidebarStore.hideProviderMark &&
+ (agent?.providerId ? (
+ <AgentIcon id={agent.providerId} size={12} className="h-3 w-3 shrink-0" />
+ ) : (
+ <Bot className="h-3 w-3 shrink-0 text-foreground-muted" />
+ ))}
+ </span>
+ </Command.Item>
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-instructions-section.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-instructions-section.tsx
index 34da36601..b14fbcd65 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-instructions-section.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-instructions-section.tsx
@@ -1,5 +1,5 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import { useCallback, useEffect, useId, useState } from 'react';
+import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
import { describeFailure } from '@renderer/lib/errors/describe-failure';
import { toast } from '@renderer/lib/hooks/use-toast';
import { rpc } from '@renderer/lib/ipc';
@@ -38,6 +38,22 @@ export function AgentInstructionsSection({
const savedValue = saved ?? '';
const [value, setValue] = useState('');
+ const [expanded, setExpanded] = useState(false);
+ const boxRef = useRef<HTMLTextAreaElement>(null);
+ const [clipped, setClipped] = useState(false);
+
+ // Whether the box is actually holding more than it can show. Measured rather
+ // than guessed from the text's length: how much fits depends on how the lines
+ // wrap, so it changes with the width of the page as well as with the text.
+ useLayoutEffect(() => {
+ const box = boxRef.current;
+ if (!box) return;
+ const measure = () => setClipped(box.scrollHeight > box.clientHeight + 1);
+ measure();
+ const observer = new ResizeObserver(measure);
+ observer.observe(box);
+ return () => observer.disconnect();
+ }, [value, expanded]);
// Re-seed when the stored value changes — after a save, and when the page
// swaps to a different agent without remounting. No refetch fires while
@@ -85,15 +101,32 @@ export function AgentInstructionsSection({
return (
<Field>
- <FieldLabel htmlFor={fieldId}>
- Agent instructions <span className="text-foreground-muted">(optional)</span>
- </FieldLabel>
+ <div className="flex items-center justify-between gap-2">
+ <FieldLabel htmlFor={fieldId}>
+ Agent instructions <span className="text-foreground-muted">(optional)</span>
+ </FieldLabel>
+ {/* Offered only once there is something being withheld, so a two-line
+ instruction does not carry a control that would do nothing. */}
+ {(clipped || expanded) && (
+ <button
+ type="button"
+ aria-expanded={expanded}
+ aria-controls={fieldId}
+ onClick={() => setExpanded((open) => !open)}
+ className="cursor-pointer text-sm text-foreground-muted hover:text-foreground"
+ >
+ {expanded ? 'Collapse' : 'Expand'}
+ </button>
+ )}
+ </div>
<Textarea
+ ref={boxRef}
id={fieldId}
rows={4}
placeholder="How this agent should work"
value={value}
onChange={(event) => setValue(event.target.value)}
+ className={expanded ? 'max-h-none' : undefined}
/>
</Field>
);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts b/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
index 8c42ef35f..42a27c5bd 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
@@ -54,9 +54,9 @@ export class AgentsStore {
});
}
- /** One agent by id, across every location — the palette resolves an agent's
- * provider from a search hit this way, so it can show the same provider mark
- * the sidebar does. */
+ /** One agent by id, across every location — the palette resolves a search
+ * hit's agent this way, so it can wear the same face and provider mark the
+ * sidebar gives it. */
agentById(agentId: string): Agent | null {
for (const agents of this.byLocation.values()) {
const found = agents.find((a) => a.id === agentId);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-store.ts b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-store.ts
index d5f2ee8c3..8a5725397 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-store.ts
@@ -190,9 +190,11 @@ export class SidebarStore implements Snapshottable<SidebarSnapshot> {
/** Whether the first-run setup checklist is collapsed to its header row. */
onboardingChecklistCollapsed = false;
- /** Whether to hide the provider mark beside a sidebar agent's name. Stated
- * as "hide" so the default — showing it — is the falsy one, and a reader who
- * never opens the menu keeps seeing what an agent runs on. */
+ /** Whether to hide the provider mark beside an agent's name, in the sidebar
+ * and in search alike — a reader who does not want to be told what an agent
+ * runs on does not want it in one list and not the other. Stated as "hide" so
+ * the default — showing it — is the falsy one, and a reader who never opens
+ * the menu keeps seeing what an agent runs on. */
hideProviderMark = false;
constructor(private readonly locationManager: LocationManagerStore) {
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/textarea.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/textarea.tsx
index 60d3781c6..210cab5b2 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/textarea.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/textarea.tsx
@@ -1,12 +1,21 @@
import * as React from 'react';
import { cn } from '@renderer/utils/utils';
+/**
+ * A multi-line field that grows with what it holds, up to a ceiling.
+ *
+ * The ceiling is the load-bearing half. `field-sizing-content` alone has no
+ * upper bound, so a box given a whole agent prompt or a room's instructions
+ * becomes as tall as the text and pushes the rest of the page out of sight
+ * (CHOO-2203). Roughly a dozen lines, after which it scrolls inside itself.
+ * A field that genuinely needs to open further overrides `max-h-*`.
+ */
function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
return (
<textarea
data-slot="textarea"
className={cn(
- 'flex field-sizing-content min-h-16 w-full rounded-md border border-border bg-transparent px-2.5 py-2 text-sm transition-[color,box-shadow] outline-none placeholder:text-foreground-passive hover:border-border-1 focus-visible:border focus-visible:border-border-primary focus-visible:ring-2 focus-visible:ring-primary/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
+ 'flex field-sizing-content max-h-64 min-h-16 w-full rounded-md border border-border bg-transparent px-2.5 py-2 text-sm transition-[color,box-shadow] outline-none placeholder:text-foreground-passive hover:border-border-1 focus-visible:border focus-visible:border-border-primary focus-visible:ring-2 focus-visible:ring-primary/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
className
)}
{...props}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-instructions-height.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-instructions-height.test.tsx
new file mode 100644
index 000000000..eab2fe109
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-instructions-height.test.tsx
@@ -0,0 +1,132 @@
+/**
+ * How much of the page an agent's instructions are allowed to take (CHOO-2203).
+ *
+ * The box grows with its content, and nothing capped it — so an agent carrying
+ * a real prompt turned its page into one long textarea with the settings below
+ * pushed out of sight. These pin the ceiling and the way out of it, both of
+ * which are invisible to the save tests next door: a box of the wrong height
+ * still holds the right text.
+ */
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+// Heights are the whole subject here, so the real utility classes have to be
+// present — without this the box renders at the browser's own default size.
+import '@renderer/index.css';
+
+const readInstructions = vi.hoisted(() => vi.fn());
+const updateInstructions = vi.hoisted(() => vi.fn());
+
+vi.hoisted(() => {
+ window.electronAPI ??= {
+ invoke: () => Promise.resolve(undefined),
+ eventOn: () => () => {},
+ eventSend: () => {},
+ } as unknown as typeof window.electronAPI;
+});
+
+vi.mock('@renderer/lib/ipc', () => ({
+ events: { on: vi.fn() },
+ rpc: {
+ agents: { readInstructions, updateInstructions },
+ },
+}));
+
+import { AgentEditsProvider } from '@renderer/features/locations/components/main-panel/agent-edits';
+import { AgentInstructionsSection } from '@renderer/features/locations/components/main-panel/agent-instructions-section';
+
+const SHORT = 'Answer in French.';
+/** A prompt of the size that provoked the report — far past any ceiling. */
+const LONG = Array.from({ length: 120 }, (_, i) => `Instruction line ${i + 1}.`).join('\n');
+
+let container: HTMLDivElement | null = null;
+let root: Root | null = null;
+
+beforeEach(() => {
+ readInstructions.mockReset();
+ updateInstructions.mockReset();
+ updateInstructions.mockResolvedValue(undefined);
+});
+
+afterEach(async () => {
+ if (root) await act(async () => root!.unmount());
+ container?.remove();
+ container = null;
+ root = null;
+});
+
+async function renderSection(stored: string): Promise<HTMLDivElement> {
+ readInstructions.mockResolvedValue(stored);
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0 } } });
+ await act(async () =>
+ root!.render(
+ <QueryClientProvider client={client}>
+ <AgentEditsProvider>
+ <AgentInstructionsSection locationId="loc-1" agentId="agent-1" />
+ </AgentEditsProvider>
+ </QueryClientProvider>
+ )
+ );
+ for (let i = 0; i < 5; i++) await act(async () => await Promise.resolve());
+ return container;
+}
+
+function field(el: HTMLElement): HTMLTextAreaElement {
+ return el.querySelector<HTMLTextAreaElement>('textarea')!;
+}
+
+function toggle(el: HTMLElement): HTMLButtonElement | undefined {
+ return [...el.querySelectorAll<HTMLButtonElement>('button')].find((b) =>
+ /^(Expand|Collapse)$/.test(b.textContent?.trim() ?? '')
+ );
+}
+
+describe('an agent’s instructions box', () => {
+ it('stops growing well before it fills a page', async () => {
+ const el = await renderSection(LONG);
+ const box = field(el);
+
+ // The ceiling itself, not the exact number: what matters is that a
+ // 120-line prompt cannot push the sections below it off the screen.
+ expect(box.clientHeight).toBeLessThan(320);
+ expect(box.scrollHeight).toBeGreaterThan(box.clientHeight);
+ });
+
+ it('offers a way to open it when it is holding back text', async () => {
+ const el = await renderSection(LONG);
+
+ expect(toggle(el)?.textContent?.trim()).toBe('Expand');
+ });
+
+ it('offers nothing to open when everything already fits', async () => {
+ const el = await renderSection(SHORT);
+
+ expect(toggle(el)).toBeUndefined();
+ });
+
+ it('shows the whole prompt once expanded, and offers the way back', async () => {
+ const el = await renderSection(LONG);
+ const capped = field(el).clientHeight;
+
+ await act(async () => toggle(el)!.click());
+
+ const box = field(el);
+ expect(box.clientHeight).toBeGreaterThan(capped);
+ expect(box.scrollHeight).toBeLessThanOrEqual(box.clientHeight + 1);
+ expect(toggle(el)?.textContent?.trim()).toBe('Collapse');
+ });
+
+ it('puts the ceiling back when collapsed again', async () => {
+ const el = await renderSection(LONG);
+ await act(async () => toggle(el)!.click());
+
+ await act(async () => toggle(el)!.click());
+
+ expect(field(el).clientHeight).toBeLessThan(320);
+ expect(toggle(el)?.textContent?.trim()).toBe('Expand');
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/palette-agent-icon.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/palette-agent-icon.test.tsx
new file mode 100644
index 000000000..aaa114c2d
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/palette-agent-icon.test.tsx
@@ -0,0 +1,150 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { Command } from 'cmdk';
+import { runInAction } from 'mobx';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it } from 'vitest';
+/**
+ * The face an agent wears in search (CHOO-2203).
+ *
+ * Search was the one surface the custom-agent-icon work never reached: it drew
+ * the agent's *provider* logo, so every Claude Code agent was the same picture
+ * and none of them was its own. Pinned here because the wrong icon is still an
+ * icon — nothing else in the suite can tell the two apart.
+ */
+import { PaletteAgentItem } from '@renderer/features/command-palette/palette-agent-item';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { ThemeContext } from '@renderer/lib/providers/theme-provider';
+import { AGENTS_METADATA_QUERY_KEY } from '@renderer/lib/stores/use-agents';
+import { remoteAgentsQueryKey } from '@renderer/lib/stores/use-remote-agents';
+import type { Agent } from '@shared/core/agents/agents';
+import type { SearchItem } from '@shared/core/search';
+import type { RemoteAgentSummary } from '@shared/core/switch-servers/switch-servers';
+
+const LOCATION_ID = 'loc-1';
+const SERVER_ID = 'server-1';
+const SWITCH_AGENT_ID = 'switch-agent-1';
+const AGENT_NAME = 'reviewer';
+
+const AGENT: Agent = {
+ id: 'agent-row-1',
+ locationId: LOCATION_ID,
+ name: AGENT_NAME,
+ providerId: 'claude',
+ switchAgentId: SWITCH_AGENT_ID,
+ apiEndpoint: 'https://switch.example',
+ serverId: SERVER_ID,
+ status: null,
+ autoApprove: false,
+ providerConfig: null,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:00.000Z',
+};
+
+const HIT: SearchItem = {
+ kind: 'agent',
+ id: AGENT.id,
+ locationId: LOCATION_ID,
+ sessionId: null,
+ title: AGENT_NAME,
+ subtitle: '',
+ score: 1,
+};
+
+function remoteAgent(iconUrl: string | null): RemoteAgentSummary {
+ return {
+ id: SWITCH_AGENT_ID,
+ name: AGENT_NAME,
+ description: '',
+ connectorType: 'agent',
+ ownerId: null,
+ ownerName: null,
+ knownAgentType: 'claude-code',
+ addressingPolicy: null,
+ iconUrl,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ };
+}
+
+const THEME = {
+ theme: 'emlight' as const,
+ setTheme: () => {},
+ toggleTheme: () => {},
+ effectiveTheme: 'emlight' as const,
+};
+
+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;
+ runInAction(() => agentsStore.byLocation.clear());
+});
+
+/** The `src` of the picture the search row draws for the agent. */
+async function rowAvatarSrc(options: {
+ /** Seed the local agent row, as a hit on a known agent would find it. */
+ known: boolean;
+ /** The icon the server holds for it, or null for none. */
+ iconUrl: string | null;
+}): Promise<string> {
+ if (options.known) {
+ runInAction(() => agentsStore.byLocation.set(LOCATION_ID, [AGENT]));
+ }
+
+ const client = new QueryClient({
+ // staleTime keeps the seeded list from being refetched over IPC, which the
+ // test has no main process to answer.
+ defaultOptions: { queries: { retry: false, gcTime: 0, staleTime: Infinity } },
+ });
+ client.setQueryData(remoteAgentsQueryKey(SERVER_ID), [remoteAgent(options.iconUrl)]);
+ // The provider mark beside the name reads its artwork from here. Seeded empty
+ // so it resolves to nothing rather than reaching for a main process the test
+ // does not have; the mark itself is the sidebar's, already covered there.
+ client.setQueryData(AGENTS_METADATA_QUERY_KEY, []);
+
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ await act(async () =>
+ root!.render(
+ <QueryClientProvider client={client}>
+ <ThemeContext.Provider value={THEME}>
+ <Command>
+ <Command.List>
+ <PaletteAgentItem item={HIT} value="agent:1" onSelect={() => {}} />
+ </Command.List>
+ </Command>
+ </ThemeContext.Provider>
+ </QueryClientProvider>
+ )
+ );
+
+ // `alt=""` is the avatar's; the provider mark carries its provider's name.
+ const img = container.querySelector('img[alt=""]');
+ if (!img) throw new Error('the search row drew no picture at all');
+ return img.getAttribute('src') ?? '';
+}
+
+describe('an agent in search', () => {
+ it('wears its own chosen icon', async () => {
+ const src = await rowAvatarSrc({ known: true, iconUrl: 'https://icons.example/reviewer.png' });
+ expect(src).toBe('https://icons.example/reviewer.png');
+ });
+
+ it('falls back to the bot drawn from its name, not its provider logo', async () => {
+ const src = await rowAvatarSrc({ known: true, iconUrl: null });
+ expect(src).toContain('/bottts/png?');
+ expect(src).toContain(AGENT_NAME);
+ });
+
+ it('still draws a face when the app holds no local row for the hit', async () => {
+ // The lookup that used to supply the provider id can miss — a stale index
+ // entry, an agent removed since. A miss must not leave the row blank.
+ const src = await rowAvatarSrc({ known: false, iconUrl: null });
+ expect(src).toContain('/bottts/png?');
+ });
+});