Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
feat(console): room summary in place and quieter tool activity in chats (CHOO-3119) (#934)
raullopez-sandbox6eeabe833b6f
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/activity-join.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/activity-join.tsindex 2e36c1f0a..48543491e 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/activity-join.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/activity-join.ts@@ -4,7 +4,6 @@ import {TURN_ITEM_ID,} from '@shared/core/chats/activity';import { type ChatMessage, isSessionStartingNotice, turnEndNotice } from '@shared/core/chats/chats';-import { SWITCH_TOOL_PREFIX } from './tool-presentation';/*** Joining an agent's turns, as Switch's activity feed stores them, to the@@ -154,29 +153,29 @@ export function toolState(item: Pick<ChatActivityItem, 'status'>, turn: TurnStatreturn turn === 'interrupted' || turn === 'error' ? 'failed' : 'running';}-/**- * The tool calls a turn shows. Assistant text is left out: what the agent- * means the room to read it posts there, and the room message is the copy- * shown. Switch's own tools (connecting, reading context, posting) are split- * off — they are how the agent talks to the room, not work done for it.- */-export function turnTools(turn: TurnActivity): {- work: ChatActivityItem[];- switchActions: ChatActivityItem[];-} {- const work: ChatActivityItem[] = [];- const switchActions: ChatActivityItem[] = [];- for (const item of turn.items) {- if (item.kind !== 'tool-activity') continue;- (item.title.startsWith(SWITCH_TOOL_PREFIX) ? switchActions : work).push(item);- }- return { work, switchActions };+/** Tool calls whose only output is the room message the user already sees. */+export function isHiddenTool(item: Pick<ChatActivityItem, 'title'>): boolean {+ return (+ /^mcp__switch__post_message(\s|$)/.test(item.title) ||+ /^mcp__switch__send_targeted_message(\s|$)/.test(item.title) ||+ /^ToolSearch(\s|$)/.test(item.title)+ );+}++/** The tool calls a turn shows. Assistant text is left out: the room message is the copy shown. */+export function turnTools(turn: TurnActivity): ChatActivityItem[] {+ return turn.items.filter((item) => item.kind === 'tool-activity' && !isHiddenTool(item));}-/** Whether the turn is under way with no tool run yet. */+/** Whether the turn is running with no visible tool currently running. */export function isThinking(turn: TurnActivity): boolean {return ((turn.status === 'queued' || turn.status === 'running') &&- !turn.items.some((item) => item.kind === 'tool-activity')+ !turn.items.some(+ (item) =>+ item.kind === 'tool-activity' &&+ !isHiddenTool(item) &&+ toolState(item, turn.status) === 'running'+ ));}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsxindex f9f4df6b2..b2a6452b7 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx@@ -78,34 +78,6 @@ function ToolGroup({);}-/** Switch's own tools for the turn, folded into a count until asked for. */-function SwitchActions({- items,- turn,- activity,-}: {- items: ChatActivityItem[];- turn: TurnActivity;- activity: AgentActivity;-}) {- const [open, setOpen] = useState(false);- return (- <WorkLogRow- icon={<ToolKindIcon kind="switch" />}- label={`${items.length} Switch ${items.length === 1 ? 'action' : 'actions'}`}- tone="passive"- open={open}- onToggle={() => setOpen(!open)}- >- {open && (- <div className="ms-3 border-l border-border ps-2">- <ToolRows items={items} turn={turn} activity={activity} />- </div>- )}- </WorkLogRow>- );-}-/** How a turn ended, with the host's reason for it muted after it. */export function turnEndLabel(label: string, reason: string | null): ReactNode {if (!reason) return label;@@ -159,11 +131,10 @@ export function AgentRow({export function turnShown(activity: AgentActivity, turn: TurnActivity): boolean {const running = turn.status === 'queued' || turn.status === 'running';const reasoning = activity.reasoning.get(turn.turnId) ?? null;- const { work, switchActions } = turnTools(turn);+ const work = turnTools(turn);return (reasoningLabel(reasoning, running && reasoning !== null) !== null ||work.length > 0 ||- switchActions.length > 0 ||isThinking(turn) ||turn.status === 'interrupted' ||turn.status === 'error' ||@@ -200,8 +171,8 @@ export const ChatActivityBlock = observer(function ChatActivityBlock({const running = turn.status === 'queued' || turn.status === 'running';const reasoning = activity.reasoning.get(turn.turnId) ?? null;const label = reasoningLabel(reasoning, running && reasoning !== null);- const { work, switchActions } = turnTools(turn);- const thinking = isThinking(turn) && !label;+ const work = turnTools(turn);+ const thinking = isThinking(turn) && !(label && !reasoning?.completedAt);const ended = turn.status === 'interrupted' || turn.status === 'error';const requests = turn.requests;if (!turnShown(activity, turn)) return null;@@ -225,9 +196,6 @@ export const ChatActivityBlock = observer(function ChatActivityBlock({) : (<ToolRows items={work} turn={turn} activity={activity} />)}- {switchActions.length > 0 && (- <SwitchActions items={switchActions} turn={turn} activity={activity} />- )}{thinking && (<WorkLogRowicon={<ThinkingIcon />}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/tool-presentation.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/tool-presentation.tsindex 50e72ca84..79c6c14a9 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/tool-presentation.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/tool-presentation.ts@@ -335,7 +335,7 @@ export function shortPath(path: string): string {return parts.length > 3 ? `…/${parts.slice(-3).join('/')}` : path;}-const COUNTED: Record<ToolKind, (count: number) => string> = {+const COUNTED: Record<Exclude<ToolKind, 'switch'>, (count: number) => string> = {shell: (n) => `Ran ${n} ${n === 1 ? 'command' : 'commands'}`,read: (n) => `Read ${n} ${n === 1 ? 'file' : 'files'}`,edit: (n) => `Edited ${n} ${n === 1 ? 'file' : 'files'}`,@@ -343,7 +343,6 @@ const COUNTED: Record<ToolKind, (count: number) => string> = {web: (n) => `Searched the web ${n} ${n === 1 ? 'time' : 'times'}`,agent: (n) => `Ran ${n} ${n === 1 ? 'agent' : 'agents'}`,todo: (n) => `Updated the to-do list${n === 1 ? '' : ` ${n} times`}`,- switch: (n) => `Took ${n} Switch ${n === 1 ? 'action' : 'actions'}`,mcp: (n) => `Called ${n} ${n === 1 ? 'tool' : 'tools'}`,other: (n) => `Used ${n} ${n === 1 ? 'tool' : 'tools'}`,};@@ -354,8 +353,11 @@ const COUNTED: Record<ToolKind, (count: number) => string> = {* when every call shares it, and null when they are mixed.*/export function summarizeTools(kinds: ToolKind[]): { label: string; kind: ToolKind | null } {- const counts = new Map<ToolKind, number>();- for (const kind of kinds) counts.set(kind, (counts.get(kind) ?? 0) + 1);+ const counts = new Map<Exclude<ToolKind, 'switch'>, number>();+ for (const kind of kinds) {+ const counted = kind === 'switch' ? 'other' : kind;+ counts.set(counted, (counts.get(counted) ?? 0) + 1);+ }const parts = [...counts].map(([kind, count], index) => {const text = COUNTED[kind](count);return index === 0 ? text : text.charAt(0).toLowerCase() + text.slice(1);diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsxindex 82ce3b4f1..d6c793578 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx@@ -12,7 +12,6 @@ import {SidebarMenuAction,SidebarMenuRow,} from '@renderer/features/sidebar/sidebar-primitives';-import { openRoomView } from '@renderer/features/sidebar/sidebar-room-grouping';import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';import { useFeatureFlags } from '@renderer/lib/hooks/useFeatureFlags';import { useParams } from '@renderer/lib/layout/navigation-provider';@@ -22,7 +21,13 @@ import { EmptyState } from '@renderer/lib/ui/empty-state';import type { ChatSummary } from '@shared/core/chats/chats';import { isCloudMachine, type ManagedAgentView } from '@shared/core/managed-agents/managed-agents';import { AgentConnectionsTab, useAgentServiceGrants } from './agent-connections-tab';-import { type AgentSection, agentSections, shownAgentSection } from './agent-sections';+import { AgentRoomSummary } from './agent-room-summary';+import {+ type AgentSection,+ agentSections,+ shownAgentRoom,+ shownAgentSection,+} from './agent-sections';import { shouldAutoStartChat } from './auto-start-chat';import { ManagedAgentPage } from './managed-agent-page';import { managedAgentLabel } from './managed-agent-state';@@ -108,9 +113,19 @@ export function openAgentChat(return direct.find((chat) => chat.roomId === roomId) ?? direct[0] ?? null;}+/** The room summarised on an agent's page in place of a chat, if one is. */+export function openAgentRoom(+ agent: ManagedAgentView,+ room: string | undefined,+ section: AgentSection | null+): string | null {+ const { agentRooms, rooms } = conversationsOf(agent);+ return shownAgentRoom(room, section, agentRooms && rooms);+}+/*** An agent's page: its navigation (the agent's settings, its direct chats and- * the rooms it is in, which open in the room view) beside what is selected.+ * the rooms it is in, each summarised in place) beside what is selected.* The selection is kept in the view's params; with none chosen it is the* newest direct chat, and an agent with none gets one started once per visit.*/@@ -124,8 +139,9 @@ export const AgentChats = observer(function AgentChats({ agent }: { agent: Managconst { agentRooms, direct, rooms } = conversationsOf(agent);const roomsError = switchRoomsStore.errorFor(workspaceId, agentId);const { sections, section } = useAgentSection(serverId, agent, params.section);- const roomId = openAgentChat(agent, params.roomId)?.roomId ?? null;- const open = (id: string) => setParams({ roomId: id, section: undefined });+ const shownRoom = openAgentRoom(agent, params.room, section);+ const roomId = shownRoom ? null : (openAgentChat(agent, params.roomId)?.roomId ?? null);+ const open = (id: string) => setParams({ roomId: id, section: undefined, room: undefined });const newChat = async () => {const chat = await directChats.start(serverId, agentId);if (chat) open(chat.roomId);@@ -139,7 +155,7 @@ export const AgentChats = observer(function AgentChats({ agent }: { agent: Managlisted: ownServer && chatsStore.userId !== null,listFailed: chatsStore.listError !== null,hasDirectChats: direct.length > 0,- selected: Boolean(params.roomId) || section !== null,+ selected: Boolean(params.roomId) || section !== null || shownRoom !== null,tried: autoStartTried.current,});useEffect(() => {@@ -199,8 +215,8 @@ export const AgentChats = observer(function AgentChats({ agent }: { agent: ManagbridgeDisplayName:switchRoomsStore.roomSummaryById(room.roomId)?.bridgeDisplayName ?? null,}}- isActive={false}- onOpen={() => openRoomView(room.roomId)}+ isActive={room.roomId === shownRoom}+ onOpen={() => setParams({ room: room.roomId, section: undefined })}/>))}{!agentRooms && !roomsError && <Note>Loading…</Note>}@@ -217,6 +233,14 @@ export const AgentChats = observer(function AgentChats({ agent }: { agent: ManagagentName={managedAgentLabel(agent)}cloud={agent.machine !== null && isCloudMachine(agent.machine)}/>+ ) : shownRoom ? (+ <AgentRoomSummary+ key={shownRoom}+ roomId={shownRoom}+ fallbackName={+ rooms.find((listed) => listed.roomId === shownRoom)?.roomName ?? shownRoom+ }+ />) : roomId ? (<><ChatPanel key={`${serverId}:${roomId}`} serverId={serverId} roomId={roomId} />diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-room-summary.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-room-summary.tsxnew file mode 100644index 000000000..1f56b6407--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-room-summary.tsx@@ -0,0 +1,102 @@+import { ExternalLink, Loader2, Settings } from 'lucide-react';+import { observer } from 'mobx-react-lite';+import { openRoomView } from '@renderer/features/sidebar/sidebar-room-grouping';+import {+ ParticipantList,+ useRoomDetail,+} from '@renderer/features/switch-rooms/room-configuration-panel';+import { membershipSummary } from '@renderer/features/switch-rooms/room-labels';+import { openRoomChannel } from '@renderer/features/switch-rooms/room-links';+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';+import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';+import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';+import { failureText } from '@renderer/lib/errors/describe-failure';+import { Button } from '@renderer/lib/ui/button';++/**+ * A room the agent is in, summarised on the agent's page: what it is, where it+ * is bridged, and who is in it. What the room list already knows shows at+ * once; who is in it comes with the room's own read.+ */+export const AgentRoomSummary = observer(function AgentRoomSummary({+ roomId,+ fallbackName,+}: {+ roomId: string;+ fallbackName: string;+}) {+ const { workspaceId, query } = useRoomDetail(roomId);+ const summary = query.data ?? switchRoomsStore.roomSummaryById(roomId);+ const name = switchRoomsStore.roomNameById(roomId) ?? summary?.name ?? fallbackName;+ const bridgeType = switchRoomsStore.roomBridgeTypeById(roomId);+ const platform = bridgePlatformLabel(bridgeType);+ return (+ <div data-testid="agent-room-summary" className="h-full overflow-y-auto">+ <div className="mx-auto flex w-full max-w-[880px] flex-col gap-8 px-10 py-8">+ <div className="flex flex-col gap-1">+ <h1 className="truncate text-2xl font-semibold text-foreground">+ {name.startsWith('#') ? name : `#${name}`}+ </h1>+ <p className="text-sm text-foreground-muted">+ {summary?.bridgeDisplayName+ ? `Room bridged to ${summary.bridgeDisplayName}`+ : 'Not bridged to a messaging platform'}+ </p>+ {summary?.description && (+ <p className="pt-2 text-sm text-foreground">{summary.description}</p>+ )}+ </div>+ <div className="flex items-center gap-2">+ <Button+ variant="outline"+ size="sm"+ data-testid="agent-room-summary-configure"+ onClick={() => openRoomView(roomId)}+ >+ <Settings className="size-3.5" />+ Room configurations+ </Button>+ {switchRoomsStore.roomChannelUrl(roomId) && (+ <Button+ variant="outline"+ size="sm"+ data-testid="agent-room-summary-open-external"+ onClick={() => openRoomChannel(roomId)}+ >+ {hasBridgeIcon(bridgeType) && (+ <BridgeIcon bridgeType={bridgeType} size={14} className="size-3.5" />+ )}+ Open in {platform}+ <ExternalLink className="size-3.5" />+ </Button>+ )}+ </div>+ <section className="flex flex-col gap-3">+ <div className="flex items-baseline gap-2">+ <h2 className="text-sm font-semibold text-foreground">Participants</h2>+ {query.data && (+ <span className="text-xs text-foreground-muted">+ {membershipSummary(+ query.data.agentIds.length,+ query.data.connectedUserNames.length+ )}+ </span>+ )}+ </div>+ {query.isError ? (+ <p role="alert" className="text-sm text-foreground-destructive">+ {failureText(query.error, 'Could not read who is in this room.')}+ </p>+ ) : query.data && workspaceId ? (+ <ParticipantList workspaceId={workspaceId} room={query.data} />+ ) : (+ <p className="flex items-center gap-2 text-sm text-foreground-muted">+ <Loader2 className="size-3.5 animate-spin" />+ Loading participants…+ </p>+ )}+ </section>+ </div>+ </div>+ );+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.test.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.test.tsindex 5253cc146..dfdcb8338 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';import type { ServiceGrants } from '@shared/core/switch-servers/service-grants';-import { agentSections, isAgentSection, shownAgentSection } from './agent-sections';+import { agentSections, isAgentSection, shownAgentRoom, shownAgentSection } from './agent-sections';const GRANTS: ServiceGrants = { grants: [], addressing_open: false };@@ -34,4 +34,13 @@ describe("a managed agent's sections", () => {expect(isAgentSection('chats')).toBe(false);expect(isAgentSection(undefined)).toBe(false);});++ it('shows the chosen room unless a section is chosen or the agent has left it', () => {+ const rooms = [{ roomId: '!a' }];+ expect(shownAgentRoom('!a', null, rooms)).toBe('!a');+ expect(shownAgentRoom('!a', 'settings', rooms)).toBeNull();+ expect(shownAgentRoom('!b', null, rooms)).toBeNull();+ expect(shownAgentRoom('!b', null, undefined)).toBe('!b');+ expect(shownAgentRoom(undefined, null, rooms)).toBeNull();+ });});diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.tsindex 16fe5e08c..eb685dc24 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-sections.ts@@ -30,3 +30,17 @@ export function shownAgentSection(): AgentSection | null {return chosen !== undefined && sections.includes(chosen) ? chosen : null;}++/**+ * The room whose summary shows: the one chosen, unless a section shows instead+ * or the agent is no longer in it. While its rooms load it is taken on trust,+ * so a reopened page does not flash a chat first.+ */+export function shownAgentRoom(+ chosen: string | undefined,+ section: AgentSection | null,+ rooms: readonly { roomId: string }[] | undefined+): string | null {+ if (chosen === undefined || section !== null) return null;+ return rooms === undefined || rooms.some((room) => room.roomId === chosen) ? chosen : null;+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsxindex f5699e19e..18872bf80 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx@@ -9,8 +9,10 @@ import {ServerStatusPill,serverState,} from '@renderer/features/switch-servers/server-presentation';+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';import { AgentAvatar } from '@renderer/lib/components/agent-avatar';+import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';import { TitlebarBreadcrumb } from '@renderer/lib/components/titlebar/titlebar-breadcrumb';import { failureText } from '@renderer/lib/errors/describe-failure';@@ -25,7 +27,13 @@ import {DropdownMenuTrigger,} from '@renderer/lib/ui/dropdown-menu';import type { ManagedAgentView } from '@shared/core/managed-agents/managed-agents';-import { AgentChats, agentSectionLabel, openAgentChat, useAgentSection } from './agent-chats';+import {+ AgentChats,+ agentSectionLabel,+ openAgentChat,+ openAgentRoom,+ useAgentSection,+} from './agent-chats';import { type AgentSection, isAgentSection } from './agent-sections';import { ManagedAgentPage } from './managed-agent-page';import { managedAgentLabel } from './managed-agent-state';@@ -40,6 +48,8 @@ type ManagedAgentParams = {roomId?: string;/** Shown instead of a chat when set. */section?: AgentSection;+ /** A room the agent is in, summarised instead of a chat when set. */+ room?: string;};const ManagedAgentTitlebar = observer(function ManagedAgentTitlebar() {@@ -50,7 +60,9 @@ const ManagedAgentTitlebar = observer(function ManagedAgentTitlebar() {const label = agent ? managedAgentLabel(agent) : params.name;const chatsOn = useFeatureFlags(params.serverId).agent_chats;const { section } = useAgentSection(params.serverId, agent, params.section);- const chat = chatsOn && agent && !section ? openAgentChat(agent, params.roomId) : null;+ const room = chatsOn && agent ? openAgentRoom(agent, params.room, section) : null;+ const chat = chatsOn && agent && !section && !room ? openAgentChat(agent, params.roomId) : null;+ const roomBridge = room && switchRoomsStore.roomBridgeTypeById(room);const activities = useAgentActivities(params.serverId, chat ?? undefined);const crumb = {key: 'agent',@@ -90,8 +102,13 @@ const ManagedAgentTitlebar = observer(function ManagedAgentTitlebar() {rightClassName="min-w-0 flex-1 justify-between gap-3 pl-4 [-webkit-app-region:drag]"rightSlot={<>- <span className="truncate text-sm font-medium">- {section ? agentSectionLabel(section) : chat?.name}+ <span className="flex min-w-0 items-center gap-1.5 truncate text-sm font-medium">+ {room && hasBridgeIcon(roomBridge) && <BridgeIcon bridgeType={roomBridge} size={16} />}+ {section+ ? agentSectionLabel(section)+ : room+ ? (switchRoomsStore.roomNameById(room) ?? room)+ : chat?.name}</span><div className="flex shrink-0 items-center gap-1.5 [-webkit-app-region:no-drag]">{server &&@@ -216,7 +233,8 @@ export const managedAgentView = {typeof value.agentId !== 'string' ||typeof value.name !== 'string' ||(value.roomId !== undefined && typeof value.roomId !== 'string') ||- (value.section !== undefined && !isAgentSection(value.section))+ (value.section !== undefined && !isAgentSection(value.section)) ||+ (value.room !== undefined && typeof value.room !== 'string'))return { ok: false, redirect: 'home', discardParams: true };return { ok: true };diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsxindex ff3963ada..52d012d6a 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx@@ -36,6 +36,17 @@ function roomDetailKey(workspaceId: string, roomId: string) {return ['remote-room-detail', workspaceId, roomId] as const;}+/** One room read from its server; `workspaceId` is null until the room list has loaded. */+export function useRoomDetail(roomId: string) {+ const workspaceId = switchRoomsStore.roomWorkspaceId(roomId);+ const query = useQuery({+ queryKey: roomDetailKey(workspaceId ?? '', roomId),+ queryFn: () => rpc.workspaces.getRoomDetail({ workspaceId: workspaceId as string, roomId }),+ enabled: workspaceId !== null,+ });+ return { workspaceId, query };+}+/*** A room's settings: what it is for, what it tells agents on arrival, and who is* in it.@@ -49,12 +60,7 @@ export const RoomConfigurationPanel = observer(function RoomConfigurationPanel({}: {roomId: string;}) {- const workspaceId = switchRoomsStore.roomWorkspaceId(roomId);- const query = useQuery({- queryKey: roomDetailKey(workspaceId ?? '', roomId),- queryFn: () => rpc.workspaces.getRoomDetail({ workspaceId: workspaceId as string, roomId }),- enabled: workspaceId !== null,- });+ const { workspaceId, query } = useRoomDetail(roomId);if (workspaceId === null) {return <PanelNotice title="This room’s workspace is still loading." />;@@ -335,12 +341,6 @@ const ParticipantsSection = observer(function ParticipantsSection({const [adding, setAdding] = useState(false);const showAddAgentsToRoomModal = useShowModal('addAgentsToRoomModal');- // Names for agents belonging to other installs, which this computer has no- // local record of. Shares its key with the rest of the app, so it is usually- // already in hand.- const remoteAgents = useWorkspaceAgents(workspaceId);- const remoteById = new Map((remoteAgents.data ?? []).map((a) => [a.id, a]));-async function refresh() {await queryClient.invalidateQueries({ queryKey: roomDetailKey(workspaceId, room.id) });await switchRoomsStore.refreshRoomState();@@ -376,40 +376,54 @@ const ParticipantsSection = observer(function ParticipantsSection({</div></div>- {room.agentIds.length === 0 && room.connectedUserNames.length === 0 ? (- <p className="text-sm text-foreground-muted">Nobody is in this room yet.</p>- ) : (- <div className="grid grid-cols-2 gap-2.5">- {room.agentIds.map((agentId) => (- <ParticipantCard- key={agentId}- mark={- <AgentMark agentId={agentId} workspaceId={workspaceId} remoteById={remoteById} />- }- name={agentNameFor(agentId, workspaceId, remoteById)}- detail={agentKindFor(agentId, workspaceId, remoteById)}- />- ))}- {room.connectedUserNames.map((name) => (- <ParticipantCard- key={`user:${name}`}- mark={- <span className="flex size-7 shrink-0 items-center justify-center rounded-full bg-[var(--fill-2)] text-xs font-medium text-foreground">- {name.charAt(0).toUpperCase()}- </span>- }- name={name}- detail="person"- />- ))}- </div>- )}+ <ParticipantList workspaceId={workspaceId} room={room} />{adding && <AddAgentPanel workspaceId={workspaceId} room={room} onAdded={refresh} />}</section>);});+/** The room's members as cards, agents first. */+export const ParticipantList = observer(function ParticipantList({+ workspaceId,+ room,+}: {+ workspaceId: string;+ room: Pick<RemoteRoomDetail, 'agentIds' | 'connectedUserNames'>;+}) {+ // Names for agents belonging to other installs, which this computer has no+ // local record of. Shares its key with the rest of the app, so it is usually+ // already in hand.+ const remoteAgents = useWorkspaceAgents(workspaceId);+ const remoteById = new Map((remoteAgents.data ?? []).map((a) => [a.id, a]));+ return room.agentIds.length === 0 && room.connectedUserNames.length === 0 ? (+ <p className="text-sm text-foreground-muted">Nobody is in this room yet.</p>+ ) : (+ <div className="grid grid-cols-2 gap-2.5">+ {room.agentIds.map((agentId) => (+ <ParticipantCard+ key={agentId}+ mark={<AgentMark agentId={agentId} workspaceId={workspaceId} remoteById={remoteById} />}+ name={agentNameFor(agentId, workspaceId, remoteById)}+ detail={agentKindFor(agentId, workspaceId, remoteById)}+ />+ ))}+ {room.connectedUserNames.map((name) => (+ <ParticipantCard+ key={`user:${name}`}+ mark={+ <span className="flex size-7 shrink-0 items-center justify-center rounded-full bg-[var(--fill-2)] text-xs font-medium text-foreground">+ {name.charAt(0).toUpperCase()}+ </span>+ }+ name={name}+ detail="person"+ />+ ))}+ </div>+ );+});+function ParticipantCard({mark,name,diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.tsindex 4c5b9aa07..26d3e6b50 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts@@ -304,24 +304,56 @@ describe('bindTurns', () => {'running');expect(isThinking(turn)).toBe(true);- expect(isThinking({ ...turn, items: [row('t1', 'tool')] })).toBe(false);});- it("shows tools only, with Switch's own tools set apart", () => {+ it('thinks between tools and not while a visible tool runs', () => {+ const tool = row('t1', 'tool', { status: 'in-progress' });+ expect(isThinking(turnOf([tool], 'running'))).toBe(false);+ const done = { ...tool, status: 'completed' };+ expect(isThinking(turnOf([done], 'running'))).toBe(true);+ expect(isThinking(turnOf([done], 'completed'))).toBe(false);+ const streaming = row('t1', 'msg', { kind: 'assistant-message', status: 'in-progress' });+ expect(isThinking(turnOf([streaming], 'running'))).toBe(true);+ });++ it('is thinking when only hidden tools are running', () => {+ const postMessage = row('t1', 'post', {+ title: 'mcp__switch__post_message',+ status: 'in-progress',+ });+ expect(isThinking(turnOf([postMessage], 'running'))).toBe(true);+ const sendTargeted = row('t1', 'send', {+ title: 'mcp__switch__send_targeted_message',+ status: 'in-progress',+ });+ expect(isThinking(turnOf([sendTargeted], 'running'))).toBe(true);+ const toolSearch = row('t1', 'search', { title: 'ToolSearch', status: 'in-progress' });+ expect(isThinking(turnOf([toolSearch], 'running'))).toBe(true);+ const listBridges = row('t1', 'list', {+ title: 'mcp__switch__list_bridges',+ status: 'in-progress',+ });+ expect(isThinking(turnOf([listBridges], 'running'))).toBe(false);+ });++ it('returns only visible tools, filtering out post_message, send_targeted_message, ToolSearch and assistant text', () => {const turn = turnOf([row('t1', 'a', { title: 'mcp__switch__read_context' }),- row('t1', 'b', { title: 'ls -la' }),- row('t1', 'c', { kind: 'assistant-message', text: 'the answer' }),- row('t1', 'd', { title: 'mcp__switch__post_message' }),+ row('t1', 'b', { title: 'ToolSearch' }),+ row('t1', 'c', { title: 'ls -la' }),+ row('t1', 'd', { kind: 'assistant-message', text: 'the answer' }),+ row('t1', 'e', { title: 'mcp__switch__post_message' }),+ row('t1', 'f', { title: 'mcp__switch__send_targeted_message' }),+ row('t1', 'g', { title: 'mcp__switch__list_bridges' }),],'completed');- const { work, switchActions } = turnTools(turn);- expect(work.map((each) => each.title)).toEqual(['ls -la']);- expect(switchActions.map((each) => each.title)).toEqual([+ const work = turnTools(turn);+ expect(work.map((each) => each.title)).toEqual(['mcp__switch__read_context',- 'mcp__switch__post_message',+ 'ls -la',+ 'mcp__switch__list_bridges',]);});@@ -331,6 +363,17 @@ describe('bindTurns', () => {expect(toolState(tool, 'interrupted')).toBe('failed');expect(toolState({ ...tool, status: 'completed' }, 'running')).toBe('done');});++ it('keeps thinking when only hidden post_message is complete and assistant text is streaming', () => {+ const turn = turnOf(+ [+ row('t1', 'post', { title: 'mcp__switch__post_message', status: 'completed' }),+ row('t1', 'msg', { kind: 'assistant-message', status: 'in-progress' }),+ ],+ 'running'+ );+ expect(isThinking(turn)).toBe(true);+ });});function rpcError(code: string, message: string, data: Record<string, unknown>): RpcError {diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-tool-presentation.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-tool-presentation.test.tsindex 56a804f16..167a0abe5 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-tool-presentation.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-tool-presentation.test.ts@@ -166,6 +166,10 @@ describe('summarizeTools', () => {kind: null,});expect(summarizeTools(['read', 'read'])).toEqual({ label: 'Read 2 files', kind: 'read' });+ expect(summarizeTools(['switch', 'switch', 'shell'])).toEqual({+ label: 'Used 2 tools and ran 1 command',+ kind: null,+ });});});