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
style: restore console formatting
raullopez-sandbox5ca899c2c179
diff --git a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.tsindex e56d7c221..2936eb880 100644--- a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts@@ -1,6 +1,6 @@-import { describe, expect, it, vi } from "vitest";-import { gatewayFetch } from "@main/core/switch-servers/gateway-client";-import type { SwitchServer } from "@shared/core/switch-servers/switch-servers";+import { describe, expect, it, vi } from 'vitest';+import { gatewayFetch } from '@main/core/switch-servers/gateway-client';+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';import {addChatAgent,addChatMember,@@ -11,11 +11,11 @@ import {removeChatAgent,sendChatMessage,warmChatAgent,-} from "./gateway";+} from './gateway';const warn = vi.hoisted(() => vi.fn());-vi.mock("@main/lib/logger", () => ({ log: { warn } }));-vi.mock("@main/core/switch-servers/gateway-client", () => ({+vi.mock('@main/lib/logger', () => ({ log: { warn } }));+vi.mock('@main/core/switch-servers/gateway-client', () => ({GatewayError: class extends Error {},gatewayFetch: vi.fn(),}));@@ -36,229 +36,183 @@ function row(roomId: string, channelType: string) {};}-describe("parseChatRows", () => {- it("accepts every channel type the server sends", () => {- const types = [- "lobby",- "channel_public",- "channel_private",- "group",- "direct",- ];- expect(- parseChatRows(types.map((type) => row(type, type))).map((c) => c.roomId),- ).toEqual(types);+describe('parseChatRows', () => {+ it('accepts every channel type the server sends', () => {+ const types = ['lobby', 'channel_public', 'channel_private', 'group', 'direct'];+ expect(parseChatRows(types.map((type) => row(type, type))).map((c) => c.roomId)).toEqual(types);});- it("skips a row that fails the contract with a warning and keeps the rest", () => {- const chats = parseChatRows([- row("room-a", "direct"),- row("room-bad", "unknown"),- ]);- expect(chats.map((chat) => chat.roomId)).toEqual(["room-a"]);+ it('skips a row that fails the contract with a warning and keeps the rest', () => {+ const chats = parseChatRows([row('room-a', 'direct'), row('room-bad', 'unknown')]);+ expect(chats.map((chat) => chat.roomId)).toEqual(['room-a']);expect(warn).toHaveBeenCalledWith(expect.any(String),- expect.objectContaining({ roomId: "room-bad" }),+ expect.objectContaining({ roomId: 'room-bad' }));});});-describe("warmChatAgent", () => {- it("posts the agent to the room’s warm route", async () => {- const server = { id: "server-1" } as SwitchServer;- vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(null, { status: 202 }),- );- await warmChatAgent(server, "room/a", "agent-1");- expect(gatewayFetch).toHaveBeenCalledWith(server, "/chats/room%2Fa/warm", {+describe('warmChatAgent', () => {+ it('posts the agent to the room’s warm route', async () => {+ const server = { id: 'server-1' } as SwitchServer;+ vi.mocked(gatewayFetch).mockResolvedValueOnce(new Response(null, { status: 202 }));+ await warmChatAgent(server, 'room/a', 'agent-1');+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room%2Fa/warm', {authenticated: true,- method: "POST",- body: { agentId: "agent-1" },+ method: 'POST',+ body: { agentId: 'agent-1' },});});});-describe("createChat", () => {- it("creates chat with zero agents and memberUserIds", async () => {- const server = { id: "server-1" } as SwitchServer;+describe('createChat', () => {+ it('creates chat with zero agents and memberUserIds', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(JSON.stringify({ chat: row("room-new", "group") }), {- status: 200,- }),+ new Response(JSON.stringify({ chat: row('room-new', 'group') }), { status: 200 }));await createChat(server, {agentIds: [],- memberUserIds: ["user-1", "user-2"],- name: "Test Group",- requestId: "req-1",+ memberUserIds: ['user-1', 'user-2'],+ name: 'Test Group',+ requestId: 'req-1',greeting: null,});- expect(gatewayFetch).toHaveBeenCalledWith(server, "/chats", {+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats', {authenticated: true,- method: "POST",+ method: 'POST',body: {- requestId: "req-1",+ requestId: 'req-1',agentIds: [],- memberUserIds: ["user-1", "user-2"],- name: "Test Group",+ memberUserIds: ['user-1', 'user-2'],+ name: 'Test Group',},});});- it("creates chat with one agent using agentId field", async () => {- const server = { id: "server-1" } as SwitchServer;+ it('creates chat with one agent using agentId field', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(JSON.stringify({ chat: row("room-new", "direct") }), {- status: 200,- }),+ new Response(JSON.stringify({ chat: row('room-new', 'direct') }), { status: 200 }));await createChat(server, {- agentIds: ["agent-1"],+ agentIds: ['agent-1'],name: null,- requestId: "req-1",+ requestId: 'req-1',greeting: null,});- expect(gatewayFetch).toHaveBeenCalledWith(server, "/chats", {+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats', {authenticated: true,- method: "POST",- body: { requestId: "req-1", agentId: "agent-1" },+ method: 'POST',+ body: { requestId: 'req-1', agentId: 'agent-1' },});});});-describe("addChatAgent", () => {- it("posts agent to the chat agents route", async () => {- const server = { id: "server-1" } as SwitchServer;+describe('addChatAgent', () => {+ it('posts agent to the chat agents route', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(JSON.stringify({ chat: row("room-1", "group") }), {- status: 200,- }),+ new Response(JSON.stringify({ chat: row('room-1', 'group') }), { status: 200 }));- await addChatAgent(server, "room-1", "agent-2");- expect(gatewayFetch).toHaveBeenCalledWith(server, "/chats/room-1/agents", {+ await addChatAgent(server, 'room-1', 'agent-2');+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room-1/agents', {authenticated: true,- method: "POST",- body: { agentId: "agent-2" },+ method: 'POST',+ body: { agentId: 'agent-2' },});});});-describe("removeChatAgent", () => {- it("deletes agent from the chat", async () => {- const server = { id: "server-1" } as SwitchServer;- vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(null, { status: 204 }),- );- await removeChatAgent(server, "room-1", "agent-2");- expect(gatewayFetch).toHaveBeenCalledWith(- server,- "/chats/room-1/agents/agent-2",- {- authenticated: true,- method: "DELETE",- },- );+describe('removeChatAgent', () => {+ it('deletes agent from the chat', async () => {+ const server = { id: 'server-1' } as SwitchServer;+ vi.mocked(gatewayFetch).mockResolvedValueOnce(new Response(null, { status: 204 }));+ await removeChatAgent(server, 'room-1', 'agent-2');+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room-1/agents/agent-2', {+ authenticated: true,+ method: 'DELETE',+ });});});-describe("chat members", () => {- it("adds a person and answers with the members", async () => {- const server = { id: "server-1" } as SwitchServer;+describe('chat members', () => {+ it('adds a person and answers with the members', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(- JSON.stringify({- members: [{ userId: "u2", name: "Bob", isOwner: false }],- }),- {- status: 200,- },- ),+ new Response(JSON.stringify({ members: [{ userId: 'u2', name: 'Bob', isOwner: false }] }), {+ status: 200,+ }));- expect(await addChatMember(server, "room-1", "u2")).toEqual([- { userId: "u2", name: "Bob", isOwner: false },+ expect(await addChatMember(server, 'room-1', 'u2')).toEqual([+ { userId: 'u2', name: 'Bob', isOwner: false },]);- expect(gatewayFetch).toHaveBeenCalledWith(server, "/chats/room-1/members", {+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room-1/members', {authenticated: true,- method: "POST",- body: { userId: "u2" },+ method: 'POST',+ body: { userId: 'u2' },});});- it("reads the workspace roster in its snake_case shape", async () => {- const server = { id: "server-1" } as SwitchServer;+ it('reads the workspace roster in its snake_case shape', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(new Response(JSON.stringify([- { user_id: "u2", name: "Bob", email: null, role: "member" },- {- user_id: "u3",- name: "Bot",- email: null,- role: "member",- service_account: true,- },+ { user_id: 'u2', name: 'Bob', email: null, role: 'member' },+ { user_id: 'u3', name: 'Bot', email: null, role: 'member', service_account: true },]),- { status: 200 },- ),+ { status: 200 }+ ));- expect(await listWorkspaceMembers(server, "t-1")).toEqual([- { userId: "u2", name: "Bob", email: null, serviceAccount: false },- { userId: "u3", name: "Bot", email: null, serviceAccount: true },+ expect(await listWorkspaceMembers(server, 't-1')).toEqual([+ { userId: 'u2', name: 'Bob', email: null, serviceAccount: false },+ { userId: 'u3', name: 'Bot', email: null, serviceAccount: true },]);- expect(gatewayFetch).toHaveBeenCalledWith(server, "/tenants/t-1/members", {+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/tenants/t-1/members', {authenticated: true,});});});-describe("sendChatMessage", () => {- it("sends message with mentionAgentIds", async () => {- const server = { id: "server-1" } as SwitchServer;+describe('sendChatMessage', () => {+ it('sends message with mentionAgentIds', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(JSON.stringify({ messages: [] }), { status: 200 }),+ new Response(JSON.stringify({ messages: [] }), { status: 200 }));- await sendChatMessage(server, "room-1", {- requestId: "req-1",- body: "Test message",+ await sendChatMessage(server, 'room-1', {+ requestId: 'req-1',+ body: 'Test message',threadRootId: null,uploadIds: [],- mentionAgentIds: ["agent-1", "agent-2"],+ mentionAgentIds: ['agent-1', 'agent-2'],});- expect(gatewayFetch).toHaveBeenCalledWith(- server,- "/chats/room-1/messages",- {- authenticated: true,- method: "POST",- body: {- requestId: "req-1",- body: "Test message",- threadRootId: null,- uploadIds: [],- mentionAgentIds: ["agent-1", "agent-2"],- },+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room-1/messages', {+ authenticated: true,+ method: 'POST',+ body: {+ requestId: 'req-1',+ body: 'Test message',+ threadRootId: null,+ uploadIds: [],+ mentionAgentIds: ['agent-1', 'agent-2'],},- );+ });});});-describe("fetchThreadMessages", () => {- it("fetches thread messages with pagination", async () => {- const server = { id: "server-1" } as SwitchServer;+describe('fetchThreadMessages', () => {+ it('fetches thread messages with pagination', async () => {+ const server = { id: 'server-1' } as SwitchServer;vi.mocked(gatewayFetch).mockResolvedValueOnce(- new Response(- JSON.stringify({ messages: [], headSeq: 100, hasMore: false }),- { status: 200 },- ),+ new Response(JSON.stringify({ messages: [], headSeq: 100, hasMore: false }), { status: 200 }));- await fetchThreadMessages(server, "room-1", "msg-root", {- beforeSeq: 50,- limit: 20,- });+ await fetchThreadMessages(server, 'room-1', 'msg-root', { beforeSeq: 50, limit: 20 });expect(gatewayFetch).toHaveBeenCalledWith(server,- "/chats/room-1/threads/msg-root/messages?limit=20&beforeSeq=50",- { authenticated: true },+ '/chats/room-1/threads/msg-root/messages?limit=20&beforeSeq=50',+ { authenticated: 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 363097362..0e5ad4008 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@@ -1,72 +1,57 @@-import { useQuery, useQueryClient } from "@tanstack/react-query";-import {- ExternalLink,- FileText,- Loader2,- Plus,- RefreshCw,- Search,- X,-} from "lucide-react";-import { observer } from "mobx-react-lite";-import { useState } from "react";-import { opensAsConsoleChat } from "@renderer/features/chats/console-chat-redirect";-import { chatFailure } from "@renderer/features/chats/stores/chat-errors";-import { chatsStore } from "@renderer/features/chats/stores/chats";-import { agentsStore } from "@renderer/features/locations/stores/agents-store";-import { isConsoleGroupChatSummary } from "@renderer/features/switch-servers/room-filters";-import { switchRoomsStore } from "@renderer/features/switch-servers/switch-rooms-store";-import { switchServersStore } from "@renderer/features/switch-servers/switch-servers-store";-import { workspacesStore } from "@renderer/features/workspaces/workspaces-store";-import { AgentAvatar } from "@renderer/lib/components/agent-avatar";-import { bridgePlatformLabel } from "@renderer/lib/components/bridge-platform";-import {- describeFailure,- failureText,-} from "@renderer/lib/errors/describe-failure";-import { rpc } from "@renderer/lib/ipc";-import { useNavigate } from "@renderer/lib/layout/navigation-provider";-import { useShowModal } from "@renderer/lib/modal/modal-provider";-import { useWorkspaceAgents } from "@renderer/lib/stores/use-workspace-agents";-import { Button } from "@renderer/lib/ui/button";-import { Input } from "@renderer/lib/ui/input";+import { useQuery, useQueryClient } from '@tanstack/react-query';+import { ExternalLink, FileText, Loader2, Plus, RefreshCw, Search, X } from 'lucide-react';+import { observer } from 'mobx-react-lite';+import { useState } from 'react';+import { opensAsConsoleChat } from '@renderer/features/chats/console-chat-redirect';+import { chatFailure } from '@renderer/features/chats/stores/chat-errors';+import { chatsStore } from '@renderer/features/chats/stores/chats';+import { agentsStore } from '@renderer/features/locations/stores/agents-store';+import { isConsoleGroupChatSummary } from '@renderer/features/switch-servers/room-filters';+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';+import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';+import { AgentAvatar } from '@renderer/lib/components/agent-avatar';+import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';+import { describeFailure, failureText } from '@renderer/lib/errors/describe-failure';+import { rpc } from '@renderer/lib/ipc';+import { useNavigate } from '@renderer/lib/layout/navigation-provider';+import { useShowModal } from '@renderer/lib/modal/modal-provider';+import { useWorkspaceAgents } from '@renderer/lib/stores/use-workspace-agents';+import { Button } from '@renderer/lib/ui/button';+import { Input } from '@renderer/lib/ui/input';import {InputGroup,InputGroupAddon,InputGroupButton,InputGroupInput,-} from "@renderer/lib/ui/input-group";-import { Textarea } from "@renderer/lib/ui/textarea";-import { cn } from "@renderer/utils/utils";-import { agentInitials } from "@shared/core/agents/agent-avatar";-import { type ChatSummary, chatAgentLabel } from "@shared/core/chats/chats";-import { providerDisplayName } from "@shared/core/providers/agent-provider-registry";-import { runsOnThisComputer } from "@shared/core/switch-servers/switch-servers";+} from '@renderer/lib/ui/input-group';+import { Textarea } from '@renderer/lib/ui/textarea';+import { cn } from '@renderer/utils/utils';+import { agentInitials } from '@shared/core/agents/agent-avatar';+import { type ChatSummary, chatAgentLabel } from '@shared/core/chats/chats';+import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';+import { runsOnThisComputer } from '@shared/core/switch-servers/switch-servers';import type {RemoteAgentSummary,RemoteRoomDetail,-} from "@shared/core/switch-servers/switch-servers";-import { administersWorkspace } from "@shared/core/workspaces/workspaces";-import { channelOnDeleteSummary } from "./room-delete-wording";-import { addablePeople, membershipSummary, roomTitle } from "./room-labels";-import { openRoomChannel } from "./room-links";+} from '@shared/core/switch-servers/switch-servers';+import { administersWorkspace } from '@shared/core/workspaces/workspaces';+import { channelOnDeleteSummary } from './room-delete-wording';+import { addablePeople, membershipSummary, roomTitle } from './room-labels';+import { openRoomChannel } from './room-links';/** Query key for one room's own settings — shared so a save can write the* server's answer straight back into what the page is reading. */function roomDetailKey(workspaceId: string, roomId: string) {- return ["remote-room-detail", workspaceId, roomId] as const;+ return ['remote-room-detail', workspaceId, roomId] as const;}/** One room read from its server; `workspaceId` is null until the room list has loaded. */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,- }),+ queryKey: roomDetailKey(workspaceId ?? '', roomId),+ queryFn: () => rpc.workspaces.getRoomDetail({ workspaceId: workspaceId as string, roomId }),enabled: workspaceId !== null && !opensAsConsoleChat(roomId),});return { workspaceId, query };@@ -84,48 +69,29 @@ const ChatConfiguration = observer(function ChatConfiguration({serverId: string;chat: ChatSummary;}) {- const workspaceId =- switchRoomsStore.roomWorkspaceId(chat.roomId) ?? workspacesStore.activeId;+ const workspaceId = switchRoomsStore.roomWorkspaceId(chat.roomId) ?? workspacesStore.activeId;const detail = useQuery({- queryKey: roomDetailKey(workspaceId ?? "", chat.roomId),+ queryKey: roomDetailKey(workspaceId ?? '', chat.roomId),queryFn: () =>- rpc.workspaces.getRoomDetail({- workspaceId: workspaceId as string,- roomId: chat.roomId,- }),+ rpc.workspaces.getRoomDetail({ workspaceId: workspaceId as string, roomId: chat.roomId }),enabled: workspaceId !== null && chat.canManage,});return (<div 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 min-w-0 flex-col gap-1">- <h1 className="truncate text-2xl font-semibold text-foreground">- {chat.name}- </h1>- <p className="text-sm text-foreground-muted">- Group chat in Switch Console- </p>+ <h1 className="truncate text-2xl font-semibold text-foreground">{chat.name}</h1>+ <p className="text-sm text-foreground-muted">Group chat in Switch Console</p></div>{workspaceId !== null && detail.data && (- <GeneralSection- key={chat.roomId}- workspaceId={workspaceId}- room={detail.data}- />+ <GeneralSection key={chat.roomId} workspaceId={workspaceId} room={detail.data} />)}{detail.isError && (<p className="text-xs text-foreground-muted">- {failureText(- detail.error,- "Could not read this chat’s description and instructions.",- )}+ {failureText(detail.error, 'Could not read this chat’s description and instructions.')}</p>)}- <ChatParticipantsSection- serverId={serverId}- workspaceId={workspaceId}- chat={chat}- />+ <ChatParticipantsSection serverId={serverId} workspaceId={workspaceId} chat={chat} /></div></div>);@@ -136,12 +102,7 @@ const ChatConfiguration = observer(function ChatConfiguration({* so an add, a removal or a swap by anyone reads the list again.*/export function chatMembersQueryKey(serverId: string, chat: ChatSummary) {- return [- "chat-members",- serverId,- chat.roomId,- chat.memberUserIds.join(","),- ] as const;+ return ['chat-members', serverId, chat.roomId, chat.memberUserIds.join(',')] as const;}/** Who is in a group chat; a manager adds and removes agents and people through the chat. */@@ -161,7 +122,7 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({queryKey: membersKey,queryFn: () => rpc.chats.members(serverId, roomId),});- const [adding, setAdding] = useState<"agent" | "person" | null>(null);+ const [adding, setAdding] = useState<'agent' | 'person' | null>(null);const [removing, setRemoving] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);const people = members.data ?? [];@@ -202,9 +163,7 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({<section className="flex flex-col gap-3"><div className="flex items-center justify-between gap-3"><div className="flex items-baseline gap-2">- <h2 className="text-sm font-semibold text-foreground">- Participants- </h2>+ <h2 className="text-sm font-semibold text-foreground">Participants</h2><span className="text-xs text-foreground-muted">{membershipSummary(agentIds.length, people.length)}</span>@@ -214,8 +173,8 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({<Buttonvariant="outline"size="sm"- aria-expanded={adding === "agent"}- onClick={() => setAdding((v) => (v === "agent" ? null : "agent"))}+ aria-expanded={adding === 'agent'}+ onClick={() => setAdding((v) => (v === 'agent' ? null : 'agent'))}><Plus className="size-3.5" />Add agent@@ -223,10 +182,8 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({<Buttonvariant="outline"size="sm"- aria-expanded={adding === "person"}- onClick={() =>- setAdding((v) => (v === "person" ? null : "person"))- }+ aria-expanded={adding === 'person'}+ onClick={() => setAdding((v) => (v === 'person' ? null : 'person'))}><Plus className="size-3.5" />Add person@@ -236,34 +193,26 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({</div>{members.isError && (- <p className="text-xs text-destructive">- {chatFailure(members.error).message}- </p>+ <p className="text-xs text-destructive">{chatFailure(members.error).message}</p>)}{error !== null && <p className="text-xs text-destructive">{error}</p>}<ParticipantListworkspaceId={workspaceId}agentIds={agentIds}- agentNames={- new Map(chat.agents.map((agent) => [agent.id, chatAgentLabel(agent)]))- }+ agentNames={new Map(chat.agents.map((agent) => [agent.id, chatAgentLabel(agent)]))}people={people.map((person) => ({id: person.userId,name: person.name,- detail: person.isOwner ? "owner" : "member",+ detail: person.isOwner ? 'owner' : 'member',}))}manage={manage}/>- {adding === "agent" && workspaceId !== null && (- <ChatAddAgentPanel- serverId={serverId}- workspaceId={workspaceId}- chat={chat}- />+ {adding === 'agent' && workspaceId !== null && (+ <ChatAddAgentPanel serverId={serverId} workspaceId={workspaceId} chat={chat} />)}- {adding === "person" && (+ {adding === 'person' && (<ChatAddPersonPanelserverId={serverId}workspaceId={workspaceId}@@ -296,35 +245,22 @@ const ChatAddAgentPanel = observer(function ChatAddAgentPanel({searchPlaceholder="Search agents in this workspace…"allInText="Every agent in this workspace is already in this chat."loading={agents.isPending}- loadError={- agents.isError- ? failureText(agents.error, "Could not list the agents.")- : null- }+ loadError={agents.isError ? failureText(agents.error, 'Could not list the agents.') : null}candidates={(agents.data ?? []).filter((agent) => !inChat.has(agent.id)).map((agent) => ({id: agent.id,name: agent.displayName ?? agent.name,mark: (- <AgentAvatar- name={agent.name}- iconUrl={agent.iconUrl}- serverId={serverId}- size={22}- />+ <AgentAvatar name={agent.name} iconUrl={agent.iconUrl} serverId={serverId} size={22} />),- detail: providerDisplayName(agent.knownAgentType) ?? "Agent",+ detail: providerDisplayName(agent.knownAgentType) ?? 'Agent',}))}onAdd={async (agentId) => {try {chatsStore.add(serverId,- await rpc.chats.addAgent({- serverId,- roomId: chat.roomId,- agentId,- }),+ await rpc.chats.addAgent({ serverId, roomId: chat.roomId, agentId }));} catch (cause) {throw new Error(chatFailure(cause).message);@@ -352,9 +288,8 @@ function ChatAddPersonPanel({onAdded: (members: Awaited<ReturnType<typeof rpc.chats.addMember>>) => void;}) {const roster = useQuery({- queryKey: ["workspace-members", serverId, tenantId],- queryFn: () =>- rpc.chats.workspaceMembers({ serverId, tenantId: tenantId as string }),+ queryKey: ['workspace-members', serverId, tenantId],+ queryFn: () => rpc.chats.workspaceMembers({ serverId, tenantId: tenantId as string }),enabled: tenantId !== null,});return (@@ -365,23 +300,18 @@ function ChatAddPersonPanel({loading={tenantId !== null && roster.isPending}loadError={tenantId === null- ? "This workspace has no tenant to list people from."+ ? 'This workspace has no tenant to list people from.': roster.isError- ? failureText(roster.error, "Could not list the people.")+ ? failureText(roster.error, 'Could not list the people.'): null}candidates={addablePeople(roster.data ?? [], memberIds).map((person) => ({id: person.userId,name: person.name,mark: <PersonMark name={person.name} size="sm" />,- detail: person.email ?? "",+ detail: person.email ?? '',}))}- footer={- <InviteHint- workspaceId={workspaceId}- canInvite={canInvite(serverId, workspaceId)}- />- }+ footer={<InviteHint workspaceId={workspaceId} canInvite={canInvite(serverId, workspaceId)} />}onAdd={async (userId) => {try {onAdded(await rpc.chats.addMember({ serverId, roomId, userId }));@@ -395,10 +325,8 @@ function ChatAddPersonPanel({/** Whether the viewer may invite people to the workspace, as the workspace menu decides it. */function canInvite(serverId: string, workspaceId: string | null): boolean {- const workspace =- workspacesStore.workspaces.find((each) => each.id === workspaceId) ?? null;- const server =- switchServersStore.servers.find((each) => each.id === serverId) ?? null;+ const workspace = workspacesStore.workspaces.find((each) => each.id === workspaceId) ?? null;+ const server = switchServersStore.servers.find((each) => each.id === serverId) ?? null;return (workspace !== null &&server !== null &&@@ -415,10 +343,10 @@ export function InviteHint({workspaceId: string | null;canInvite: boolean;}) {- const showInvitePeopleModal = useShowModal("invitePeopleModal");+ const showInvitePeopleModal = useShowModal('invitePeopleModal');return (<p className="px-1 text-xs text-foreground-muted">- Don't see someone?{" "}+ Don't see someone?{' '}{canInvite && workspaceId !== null ? (<buttontype="button"@@ -428,7 +356,7 @@ export function InviteHint({Invite them to the workspace</button>) : (- "Ask a workspace admin to invite them."+ 'Ask a workspace admin to invite them.')}</p>);@@ -473,18 +401,14 @@ export const RoomConfigurationPanel = observer(function RoomConfigurationPanel({if (query.isError) {const settingsReadFailure = describeFailure(query.error,- "Could not read this room’s settings.",+ 'Could not read this room’s settings.');return (<PanelNoticetitle={settingsReadFailure.headline}detail={settingsReadFailure.detail ?? undefined}action={- <Button- variant="outline"- size="sm"- onClick={() => void query.refetch()}- >+ <Button variant="outline" size="sm" onClick={() => void query.refetch()}><RefreshCw className="size-3" />Retry</Button>@@ -497,10 +421,7 @@ export const RoomConfigurationPanel = observer(function RoomConfigurationPanel({return (<div className="h-full overflow-y-auto"><div className="mx-auto flex w-full max-w-[880px] flex-col gap-8 px-10 py-8">- <RoomHeading- serverId={switchRoomsStore.roomServerId(roomId)}- room={room}- />+ <RoomHeading serverId={switchRoomsStore.roomServerId(roomId)} room={room} />{/* Keyed on the room so the drafts below belong to the room on screen:switching rooms starts a fresh form rather than carrying half-typedtext across. */}@@ -526,7 +447,7 @@ const DeleteRoomSection = observer(function DeleteRoomSection({workspaceId: string;room: RemoteRoomDetail;}) {- const showDeleteRoomModal = useShowModal("deleteRoomModal");+ const showDeleteRoomModal = useShowModal('deleteRoomModal');const { navigate } = useNavigate();if (!switchRoomsStore.canDeleteRoom(workspaceId, room)) return null;@@ -539,8 +460,8 @@ const DeleteRoomSection = observer(function DeleteRoomSection({<p className="text-xs text-foreground-muted">Removes the room and its conversation for everyone in it.{room.bridgeType- ? ` ${channelOnDeleteSummary(bridgePlatformLabel(room.bridgeType), room.channelOnDelete) ?? ""}`- : ""}+ ? ` ${channelOnDeleteSummary(bridgePlatformLabel(room.bridgeType), room.channelOnDelete) ?? ''}`+ : ''}</p></div><Button@@ -554,7 +475,7 @@ const DeleteRoomSection = observer(function DeleteRoomSection({roomName: roomTitle(room),// The page this is on is the deleted room's own, so staying would// leave a settings form for something that no longer exists.- onSuccess: () => navigate("home"),+ onSuccess: () => navigate('home'),})}>@@ -565,25 +486,17 @@ const DeleteRoomSection = observer(function DeleteRoomSection({);});-function RoomHeading({- serverId,- room,-}: {- serverId: string | null;- room: RemoteRoomDetail;-}) {+function RoomHeading({ serverId, room }: { serverId: string | null; room: RemoteRoomDetail }) {const platform = bridgePlatformLabel(room.bridgeType);const { navigate } = useNavigate();return (<div className="flex items-start justify-between gap-4"><div className="flex min-w-0 flex-col gap-1">- <h1 className="truncate text-2xl font-semibold text-foreground">- {roomTitle(room)}- </h1>+ <h1 className="truncate text-2xl font-semibold text-foreground">{roomTitle(room)}</h1><p className="text-sm text-foreground-muted">{room.bridgeDisplayName? `Room bridged to ${room.bridgeDisplayName}`- : "Room with no messaging app"}+ : 'Room with no messaging app'}</p></div><div className="flex shrink-0 items-center gap-2">@@ -591,9 +504,7 @@ function RoomHeading({<Buttonvariant="outline"size="sm"- onClick={() =>- navigate("templateCapture", { serverId, roomId: room.id })- }+ onClick={() => navigate('templateCapture', { serverId, roomId: room.id })}><FileText className="size-3.5" />Capture as template@@ -606,11 +517,7 @@ function RoomHeading({{room.bridgeDisplayName}</span>)}- <Button- variant="outline"- size="sm"- onClick={() => openRoomChannel(room.id)}- >+ <Button variant="outline" size="sm" onClick={() => openRoomChannel(room.id)}><ExternalLink className="size-3.5" />Open in {platform}</Button>@@ -622,8 +529,7 @@ function RoomHeading({}/** What the section is doing, once the user has stopped typing in it. */-type SaveState =- { phase: "idle" | "saving" | "saved" } | { phase: "failed"; message: string };+type SaveState = { phase: 'idle' | 'saving' | 'saved' } | { phase: 'failed'; message: string };/*** Description and instructions, written when Save is pressed.@@ -636,25 +542,18 @@ type SaveState =** One request carries both fields, so the pair is stored together or not at all.*/-function GeneralSection({- workspaceId,- room,-}: {- workspaceId: string;- room: RemoteRoomDetail;-}) {+function GeneralSection({ workspaceId, room }: { workspaceId: string; room: RemoteRoomDetail }) {const queryClient = useQueryClient();const savedDescription = room.description;- const savedInstructions = room.instructions ?? "";+ const savedInstructions = room.instructions ?? '';const [description, setDescription] = useState(savedDescription);const [instructions, setInstructions] = useState(savedInstructions);- const [state, setState] = useState<SaveState>({ phase: "idle" });+ const [state, setState] = useState<SaveState>({ phase: 'idle' });- const dirty =- description !== savedDescription || instructions !== savedInstructions;+ const dirty = description !== savedDescription || instructions !== savedInstructions;async function save() {- setState({ phase: "saving" });+ setState({ phase: 'saving' });try {const updated = await rpc.workspaces.updateRoom({workspaceId,@@ -663,12 +562,9 @@ function GeneralSection({instructions,});queryClient.setQueryData(roomDetailKey(workspaceId, room.id), updated);- setState({ phase: "saved" });+ setState({ phase: 'saved' });} catch (cause) {- setState({- phase: "failed",- message: failureText(cause, "Could not save the change."),- });+ setState({ phase: 'failed', message: failureText(cause, 'Could not save the change.') });}}@@ -686,22 +582,19 @@ function GeneralSection({value={description}onChange={(e) => {setDescription(e.target.value);- setState({ phase: "idle" });+ setState({ phase: 'idle' });}}/></Field>- <Field- label="Instructions"- hint="Sent to every agent as it joins the room."- >+ <Field label="Instructions" hint="Sent to every agent as it joins the room."><Textarearows={4}placeholder="Optional guidance shown to agents when they enter the room"value={instructions}onChange={(e) => {setInstructions(e.target.value);- setState({ phase: "idle" });+ setState({ phase: 'idle' });}}/></Field>@@ -713,10 +606,10 @@ function GeneralSection({<Buttontype="button"size="sm"- disabled={!dirty || state.phase === "saving"}+ disabled={!dirty || state.phase === 'saving'}onClick={() => void save()}>- {state.phase === "saving" ? "Saving…" : "Save"}+ {state.phase === 'saving' ? 'Saving…' : 'Save'}</Button></div></section>@@ -725,20 +618,14 @@ function GeneralSection({/** Says where the edits stand, so an unsaved change is never silent. */function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {- if (state.phase === "failed") {- return (- <span className="text-xs text-destructive">- Not saved — {state.message}- </span>- );+ if (state.phase === 'failed') {+ return <span className="text-xs text-destructive">Not saved — {state.message}</span>;}- if (state.phase === "saved" && !dirty) {+ if (state.phase === 'saved' && !dirty) {return <span className="text-xs text-foreground-muted">Saved.</span>;}if (dirty) {- return (- <span className="text-xs text-foreground-muted">Unsaved changes.</span>- );+ return <span className="text-xs text-foreground-muted">Unsaved changes.</span>;}return null;}@@ -777,12 +664,10 @@ const ParticipantsSection = observer(function ParticipantsSection({}) {const queryClient = useQueryClient();const [adding, setAdding] = useState(false);- const showAddAgentsToRoomModal = useShowModal("addAgentsToRoomModal");+ const showAddAgentsToRoomModal = useShowModal('addAgentsToRoomModal');async function refresh() {- await queryClient.invalidateQueries({- queryKey: roomDetailKey(workspaceId, room.id),- });+ await queryClient.invalidateQueries({ queryKey: roomDetailKey(workspaceId, room.id) });await switchRoomsStore.refreshRoomState();}@@ -790,14 +675,9 @@ const ParticipantsSection = observer(function ParticipantsSection({<section className="flex flex-col gap-3"><div className="flex items-center justify-between gap-3"><div className="flex items-baseline gap-2">- <h2 className="text-sm font-semibold text-foreground">- Participants- </h2>+ <h2 className="text-sm font-semibold text-foreground">Participants</h2><span className="text-xs text-foreground-muted">- {membershipSummary(- room.agentIds.length,- room.connectedUserNames.length,- )}+ {membershipSummary(room.agentIds.length, room.connectedUserNames.length)}</span></div><div className="flex items-center gap-2">@@ -828,18 +708,12 @@ const ParticipantsSection = observer(function ParticipantsSection({people={room.connectedUserNames.map((name) => ({id: `user:${name}`,name,- detail: "person",+ detail: 'person',}))}manage={null}/>- {adding && (- <AddAgentPanel- workspaceId={workspaceId}- room={room}- onAdded={refresh}- />- )}+ {adding && <AddAgentPanel workspaceId={workspaceId} room={room} onAdded={refresh} />}</section>);});@@ -879,17 +753,8 @@ const ParticipantList = observer(function ParticipantList({{agentIds.map((agentId) => (<ParticipantCardkey={agentId}- mark={- <AgentMark- agentId={agentId}- workspaceId={workspaceId}- remoteById={remoteById}- />- }- name={- agentNames.get(agentId) ??- agentNameFor(agentId, workspaceId, remoteById)- }+ mark={<AgentMark agentId={agentId} workspaceId={workspaceId} remoteById={remoteById} />}+ name={agentNames.get(agentId) ?? agentNameFor(agentId, workspaceId, remoteById)}detail={agentKindFor(agentId, workspaceId, remoteById)}removing={manage?.removing === agentId}onRemove={manage && (() => manage.removeAgent(agentId))}@@ -910,12 +775,12 @@ const ParticipantList = observer(function ParticipantList({});/** A person's initials disc: people have no picture in Switch. */-function PersonMark({ name, size }: { name: string; size: "sm" | "md" }) {+function PersonMark({ name, size }: { name: string; size: 'sm' | 'md' }) {return (<spanclassName={cn(- "flex shrink-0 items-center justify-center rounded-full bg-[var(--fill-2)] font-medium text-foreground",- size === "md" ? "size-7 text-xs" : "size-[22px] text-[10px]",+ 'flex shrink-0 items-center justify-center rounded-full bg-[var(--fill-2)] font-medium text-foreground',+ size === 'md' ? 'size-7 text-xs' : 'size-[22px] text-[10px]')}>{agentInitials(name)}@@ -940,9 +805,7 @@ function ParticipantCard({<div className="flex items-center gap-3 rounded-[10px] border border-border bg-[var(--surface-2)] px-3.5 py-3">{mark}<div className="flex min-w-0 flex-1 flex-col">- <span className="truncate text-sm font-medium text-foreground">- {name}- </span>+ <span className="truncate text-sm font-medium text-foreground">{name}</span><span className="truncate text-xs text-foreground-muted">{detail}</span></div>{onRemove && (@@ -961,12 +824,7 @@ function ParticipantCard({);}-type Candidate = {- id: string;- name: string;- mark: React.ReactNode;- detail: string;-};+type Candidate = { id: string; name: string; mark: React.ReactNode; detail: string };/*** A searchable list of who could join, each row adding one. A refusal is shown@@ -992,14 +850,13 @@ function AddParticipantPanel({footer: React.ReactNode;onAdd: (id: string) => Promise<void>;}) {- const [filter, setFilter] = useState("");+ const [filter, setFilter] = useState('');const [busyId, setBusyId] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);const query = filter.trim().toLowerCase();const shown = candidates.filter((candidate) =>- query === "" ||- `${candidate.name}\n${candidate.detail}`.toLowerCase().includes(query),+ query === '' || `${candidate.name}\n${candidate.detail}`.toLowerCase().includes(query));async function add(id: string) {@@ -1027,12 +884,12 @@ function AddParticipantPanel({value={filter}onChange={(e) => setFilter(e.target.value)}/>- {filter !== "" && (+ {filter !== '' && (<InputGroupAddon align="inline-end"><InputGroupButtonsize="icon-xs"aria-label="Clear the search"- onClick={() => setFilter("")}+ onClick={() => setFilter('')}><X className="size-3.5" /></InputGroupButton>@@ -1040,21 +897,15 @@ function AddParticipantPanel({)}</InputGroup>- {error !== null && (- <p className="text-xs text-destructive">Not added — {error}</p>- )}- {loadError !== null && (- <p className="text-xs text-destructive">{loadError}</p>- )}+ {error !== null && <p className="text-xs text-destructive">Not added — {error}</p>}+ {loadError !== null && <p className="text-xs text-destructive">{loadError}</p>}{loading ? (<p className="px-1 py-2 text-sm text-foreground-muted">Loading…</p>) : shown.length === 0 ? (loadError === null && (<p className="px-1 py-2 text-sm text-foreground-muted">- {query === ""- ? allInText- : `No ${noun} here matches “${filter.trim()}”.`}+ {query === '' ? allInText : `No ${noun} here matches “${filter.trim()}”.`}</p>)) : (@@ -1066,19 +917,17 @@ function AddParticipantPanel({disabled={busyId !== null}onClick={() => void add(candidate.id)}className={cn(- "flex w-full cursor-pointer items-center gap-3 bg-background px-3.5 py-2.5 text-left transition-colors hover:bg-[var(--fill)]",- busyId !== null && "cursor-wait",+ 'flex w-full cursor-pointer items-center gap-3 bg-background px-3.5 py-2.5 text-left transition-colors hover:bg-[var(--fill)]',+ busyId !== null && 'cursor-wait')}>{candidate.mark}<span className="min-w-0 flex-1 truncate text-sm text-foreground">{candidate.name}</span>- <span className="shrink-0 text-xs text-foreground-muted">- {candidate.detail}- </span>+ <span className="shrink-0 text-xs text-foreground-muted">{candidate.detail}</span><span className="shrink-0 text-xs font-medium text-foreground">- {busyId === candidate.id ? "Adding…" : "Add"}+ {busyId === candidate.id ? 'Adding…' : 'Add'}</span></button>))}@@ -1107,9 +956,7 @@ const AddAgentPanel = observer(function AddAgentPanel({}) {const members = new Set(room.agentIds);const { data: remoteAgents } = useWorkspaceAgents(workspaceId);- const remoteById = new Map(- (remoteAgents ?? []).map((agent) => [agent.id, agent]),- );+ const remoteById = new Map((remoteAgents ?? []).map((agent) => [agent.id, agent]));return (<AddParticipantPanelnoun="agent"@@ -1120,10 +967,7 @@ const AddAgentPanel = observer(function AddAgentPanel({loadError={null}candidates={agentsStore.agentsInWorkspace(workspaceId)- .filter(- (agent) =>- agent.switchAgentId !== null && !members.has(agent.switchAgentId),- )+ .filter((agent) => agent.switchAgentId !== null && !members.has(agent.switchAgentId)).map((agent) => {const switchAgentId = agent.switchAgentId as string;return {@@ -1137,7 +981,7 @@ const AddAgentPanel = observer(function AddAgentPanel({size={22}/>),- detail: providerDisplayName(agent.providerId) ?? "Agent",+ detail: providerDisplayName(agent.providerId) ?? 'Agent',};})}onAdd={async (switchAgentId) => {@@ -1145,7 +989,7 @@ const AddAgentPanel = observer(function AddAgentPanel({workspaceId,roomId: room.id,agentIds: [switchAgentId],- direction: "agents_to_room",+ direction: 'agents_to_room',});await onAdded();}}@@ -1168,9 +1012,7 @@ function PanelNotice({<div className="flex h-full flex-col items-center justify-center gap-3 p-8 text-center">{icon && <div className="text-foreground-passive">{icon}</div>}<p className="text-sm font-medium text-foreground">{title}</p>- {detail && (- <p className="max-w-md text-xs text-foreground-muted">{detail}</p>- )}+ {detail && <p className="max-w-md text-xs text-foreground-muted">{detail}</p>}{action}</div>);@@ -1204,21 +1046,20 @@ function AgentMark({function localAgentFor(switchAgentId: string, workspaceId: string | null) {if (workspaceId === null) return null;return (- agentsStore- .agentsInWorkspace(workspaceId)- .find((a) => a.switchAgentId === switchAgentId) ?? null+ agentsStore.agentsInWorkspace(workspaceId).find((a) => a.switchAgentId === switchAgentId) ??+ null);}function agentNameFor(switchAgentId: string,workspaceId: string | null,- remoteById: Map<string, RemoteAgentSummary>,+ remoteById: Map<string, RemoteAgentSummary>): string {return (localAgentFor(switchAgentId, workspaceId)?.name ??remoteById.get(switchAgentId)?.name ??- "Agent"+ 'Agent');}@@ -1227,12 +1068,9 @@ function agentNameFor(function agentKindFor(switchAgentId: string,workspaceId: string | null,- remoteById: Map<string, RemoteAgentSummary>,+ remoteById: Map<string, RemoteAgentSummary>): string {- const providerId =- localAgentFor(switchAgentId, workspaceId)?.providerId ?? null;+ const providerId = localAgentFor(switchAgentId, workspaceId)?.providerId ?? null;const knownType = remoteById.get(switchAgentId)?.knownAgentType ?? null;- return (- providerDisplayName(providerId) ?? providerDisplayName(knownType) ?? "agent"- );+ return providerDisplayName(providerId) ?? providerDisplayName(knownType) ?? 'agent';}diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.test.tsindex 9bfade3d7..416571840 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.test.ts@@ -1,50 +1,42 @@-import { describe, expect, it } from "vitest";-import { addablePeople, membershipSummary, roomTitle } from "./room-labels";+import { describe, expect, it } from 'vitest';+import { addablePeople, membershipSummary, roomTitle } from './room-labels';-describe("roomTitle", () => {- it("marks a bridged room as the channel it is", () => {- expect(roomTitle({ name: "louis-dev", bridgeType: "mattermost" })).toBe(- "#louis-dev",- );+describe('roomTitle', () => {+ it('marks a bridged room as the channel it is', () => {+ expect(roomTitle({ name: 'louis-dev', bridgeType: 'mattermost' })).toBe('#louis-dev');});- it("leaves a room in no messaging app alone — there is no channel to name", () => {- expect(roomTitle({ name: "louis-dev", bridgeType: null })).toBe(- "louis-dev",- );+ it('leaves a room in no messaging app alone — there is no channel to name', () => {+ expect(roomTitle({ name: 'louis-dev', bridgeType: null })).toBe('louis-dev');});- it("does not double the sigil on a name that already carries one", () => {- expect(roomTitle({ name: "#general", bridgeType: "slack" })).toBe(- "#general",- );+ it('does not double the sigil on a name that already carries one', () => {+ expect(roomTitle({ name: '#general', bridgeType: 'slack' })).toBe('#general');});});-describe("membershipSummary", () => {- it("counts agents and people separately", () => {- expect(membershipSummary(1, 1)).toBe("1 agent · 1 person");- expect(membershipSummary(3, 2)).toBe("3 agents · 2 people");+describe('membershipSummary', () => {+ it('counts agents and people separately', () => {+ expect(membershipSummary(1, 1)).toBe('1 agent · 1 person');+ expect(membershipSummary(3, 2)).toBe('3 agents · 2 people');});- it("omits people rather than reporting none", () => {- expect(membershipSummary(2, 0)).toBe("2 agents");+ it('omits people rather than reporting none', () => {+ expect(membershipSummary(2, 0)).toBe('2 agents');});- it("says an empty room has no agents rather than saying nothing", () => {- expect(membershipSummary(0, 0)).toBe("0 agents");+ it('says an empty room has no agents rather than saying nothing', () => {+ expect(membershipSummary(0, 0)).toBe('0 agents');});});-describe("addablePeople", () => {- it("skips a service account by its flag and anyone already in, not by name", () => {+describe('addablePeople', () => {+ it('skips a service account by its flag and anyone already in, not by name', () => {const roster = [- { userId: "u1", name: "Agent Bootstrap", serviceAccount: true },- { userId: "u2", name: "Agent Bootstrap", serviceAccount: false },- { userId: "u3", name: "alice", serviceAccount: false },+ { userId: 'u1', name: 'Agent Bootstrap', serviceAccount: true },+ { userId: 'u2', name: 'Agent Bootstrap', serviceAccount: false },+ { userId: 'u3', name: 'alice', serviceAccount: false },];- expect(- addablePeople(roster, new Set(["u3"])).map((person) => person.userId),- ).toEqual(["u2"]);+ expect(addablePeople(roster, new Set(['u3'])).map((person) => person.userId)).toEqual(['u2']);});});diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.tsindex 12d3780cc..7b0b6ef48 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-labels.ts@@ -6,11 +6,8 @@* the name does not already carry one, and never to a room in no app at all,* where there is no channel for it to name.*/-export function roomTitle(room: {- name: string;- bridgeType: string | null;-}): string {- if (!room.bridgeType || room.name.startsWith("#")) return room.name;+export function roomTitle(room: { name: string; bridgeType: string | null }): string {+ if (!room.bridgeType || room.name.startsWith('#')) return room.name;return `#${room.name}`;}@@ -21,13 +18,10 @@ export function roomTitle(room: {* People are left out rather than shown as zero: an unbridged room has no way* for anyone to be in it, and "0 people" reads as a room nobody came to.*/-export function membershipSummary(- agentCount: number,- personCount: number,-): string {- const agents = `${agentCount} ${agentCount === 1 ? "agent" : "agents"}`;+export function membershipSummary(agentCount: number, personCount: number): string {+ const agents = `${agentCount} ${agentCount === 1 ? 'agent' : 'agents'}`;if (personCount === 0) return agents;- return `${agents} · ${personCount} ${personCount === 1 ? "person" : "people"}`;+ return `${agents} · ${personCount} ${personCount === 1 ? 'person' : 'people'}`;}/**@@ -35,10 +29,9 @@ export function membershipSummary(* not a service account (the agent-registration bootstrap owner), which the* server marks rather than anything its name says.*/-export function addablePeople<- T extends { userId: string; serviceAccount: boolean },->(roster: T[], memberIds: Set<string>): T[] {- return roster.filter(- (person) => !person.serviceAccount && !memberIds.has(person.userId),- );+export function addablePeople<T extends { userId: string; serviceAccount: boolean }>(+ roster: T[],+ memberIds: Set<string>+): T[] {+ return roster.filter((person) => !person.serviceAccount && !memberIds.has(person.userId));}diff --git a/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts b/console/apps/switch-console-desktop/src/shared/core/chats/chats.tsindex 7e8b9476f..b9149c0cf 100644--- a/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts+++ b/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts@@ -1,4 +1,4 @@-import { z } from "zod";+import { z } from 'zod';/*** A chat is a Switch room the signed-in person is a member of and that has at@@ -22,13 +22,7 @@ export type ChatAgent = z.infer<typeof chatAgentSchema>;export const chatSummarySchema = z.object({roomId: z.string(),name: z.string(),- channelType: z.enum([- "lobby",- "channel_public",- "channel_private",- "group",- "direct",- ]),+ channelType: z.enum(['lobby', 'channel_public', 'channel_private', 'group', 'direct']),bridgeType: z.string().nullable(),channelName: z.string().nullable(),agents: z.array(chatAgentSchema),@@ -52,7 +46,7 @@ export type ChatSummary = z.infer<typeof chatSummarySchema>;export const chatSenderSchema = z.object({clientId: z.string(),name: z.string(),- kind: z.enum(["human", "agent", "system"]),+ kind: z.enum(['human', 'agent', 'system']),agentId: z.string().nullable(),userId: z.string().nullable(),});@@ -98,12 +92,8 @@ export const chatThreadMessagesPageSchema = z.object({headSeq: z.number().int(),hasMore: z.boolean(),});-export type ChatThreadMessagesPage = z.infer<- typeof chatThreadMessagesPageSchema->;-export const chatSentSchema = z.object({- messages: z.array(chatMessageSchema),-});+export type ChatThreadMessagesPage = z.infer<typeof chatThreadMessagesPageSchema>;+export const chatSentSchema = z.object({ messages: z.array(chatMessageSchema) });export const chatAgentAddedSchema = z.object({ chat: chatSummarySchema });export const chatMemberSchema = z.object({userId: z.string(),@@ -111,9 +101,7 @@ export const chatMemberSchema = z.object({isOwner: z.boolean(),});export type ChatMember = z.infer<typeof chatMemberSchema>;-export const chatMemberListSchema = z.object({- members: z.array(chatMemberSchema),-});+export const chatMemberListSchema = z.object({ members: z.array(chatMemberSchema) });/** A person in the workspace, from its roster, who could be added to a chat. */export const workspaceMemberSchema = z.object({@@ -142,7 +130,7 @@ export type ChatUpload = z.infer<typeof chatUploadSchema>;* `access`: the person lost the room (membership, workspace role, archive).* `unlisted`: still a member, but the room no longer qualifies for the list.*/-export const chatRemovalReasonSchema = z.enum(["access", "unlisted"]);+export const chatRemovalReasonSchema = z.enum(['access', 'unlisted']);export type ChatRemovalReason = z.infer<typeof chatRemovalReasonSchema>;export const chatRemovedSchema = z.object({roomId: z.string(),@@ -158,7 +146,7 @@ export const chatErrorBodySchema = z.object({* The live feed's state. `live` is only reached after the server's `ready`,* which it sends once every member room has been caught up from its cursor.*/-export type ChatStreamState = "connecting" | "catching-up" | "live" | "offline";+export type ChatStreamState = 'connecting' | 'catching-up' | 'live' | 'offline';export type ChatSendInput = {serverId: string;@@ -181,28 +169,22 @@ export type ChatUploadInput = {};/** The display name the room and the platforms show for an agent. */-export function chatAgentLabel(- agent: Pick<ChatAgent, "name" | "displayName">,-): string {+export function chatAgentLabel(agent: Pick<ChatAgent, 'name' | 'displayName'>): string {return agent.displayName ?? agent.name;}/** The `clientTxn` a Console send's parts carry: `{requestId}:{index}`. */export function requestIdOfClientTxn(clientTxn: string | null): string | null {if (clientTxn === null) return null;- const at = clientTxn.lastIndexOf(":");+ const at = clientTxn.lastIndexOf(':');return at > 0 ? clientTxn.slice(0, at) : null;}/** The notice an agent posts to a room while a session starts to answer it. */-export const SESSION_STARTING_MESSAGE =- "Starting a session to handle this — one moment.";+export const SESSION_STARTING_MESSAGE = 'Starting a session to handle this — one moment.';export function isSessionStartingNotice(message: ChatMessage): boolean {- return (- message.sender.kind === "agent" &&- message.body.trim() === SESSION_STARTING_MESSAGE- );+ return message.sender.kind === 'agent' && message.body.trim() === SESSION_STARTING_MESSAGE;}/**@@ -212,63 +194,52 @@ export function isSessionStartingNotice(message: ChatMessage): boolean {*/export function liveSessionStartingNotices(messages: readonly ChatMessage[],- turnAgents: ReadonlyMap<string, ReadonlySet<string>>,+ turnAgents: ReadonlyMap<string, ReadonlySet<string>>): Set<string> {const live = new Set<string>();const seen = new Set<string>();for (let at = messages.length - 1; at >= 0; at--) {const message = messages[at];- if (message.sender.kind !== "agent" || seen.has(message.sender.clientId))- continue;+ if (message.sender.kind !== 'agent' || seen.has(message.sender.clientId)) continue;seen.add(message.sender.clientId);if (!isSessionStartingNotice(message)) continue;let from = at;- while (from > 0 && messages[from].sender.kind !== "human") from--;+ while (from > 0 && messages[from].sender.kind !== 'human') from--;const agentId = message.sender.agentId;const working = messages.slice(from)- .some(- (each) =>- agentId !== null && turnAgents.get(each.messageId)?.has(agentId),- );+ .some((each) => agentId !== null && turnAgents.get(each.messageId)?.has(agentId));if (!working) live.add(message.messageId);}return live;}/** What the host posts for a turn that ended without the agent posting, then why it ended. */-export const UNPOSTED_REPLY_MESSAGE = "I finished without replying.";-export const TURN_FAILED_PHRASE = "The turn failed";-export const TURN_INTERRUPTED_PHRASE = "The turn was interrupted";+export const UNPOSTED_REPLY_MESSAGE = 'I finished without replying.';+export const TURN_FAILED_PHRASE = 'The turn failed';+export const TURN_INTERRUPTED_PHRASE = 'The turn was interrupted';export type TurnEndNotice = {- outcome: "completed" | "failed" | "interrupted";+ outcome: 'completed' | 'failed' | 'interrupted';reason: string | null;};/** The host's notice of a turn that ended without a reply, or null for any other message. */export function turnEndNotice(message: ChatMessage): TurnEndNotice | null {const body = message.body.trim();- if (- message.sender.kind !== "agent" ||- !body.startsWith(UNPOSTED_REPLY_MESSAGE)- )- return null;+ if (message.sender.kind !== 'agent' || !body.startsWith(UNPOSTED_REPLY_MESSAGE)) return null;const rest = body.slice(UNPOSTED_REPLY_MESSAGE.length).trim();- if (!rest) return { outcome: "completed", reason: null };+ if (!rest) return { outcome: 'completed', reason: null };for (const [phrase, outcome] of [- [TURN_FAILED_PHRASE, "failed"],- [TURN_INTERRUPTED_PHRASE, "interrupted"],+ [TURN_FAILED_PHRASE, 'failed'],+ [TURN_INTERRUPTED_PHRASE, 'interrupted'],] as const) {if (rest === `${phrase}.`) return { outcome, reason: null };// An interrupt is the person's Stop; the provider's raw reason for it says nothing more.if (rest.startsWith(`${phrase}: `))return {outcome,- reason:- outcome === "interrupted"- ? null- : rest.slice(phrase.length + 2).trim(),+ reason: outcome === 'interrupted' ? null : rest.slice(phrase.length + 2).trim(),};}return null;