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): one participant field for New room and a chat's Configuration
raullopez-sandboxc1858601b7c5
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 a46da55f7..fb4cbafee 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@@ -12,6 +12,12 @@ import { switchServersStore } from '@renderer/features/switch-servers/switch-serimport { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { AgentAvatar } from '@renderer/lib/components/agent-avatar';import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';+import { ParticipantPicker } from '@renderer/lib/components/participant-picker';+import {+ agentParticipant,+ type Participant,+ personParticipant,+} from '@renderer/lib/components/participant-search';import { describeFailure, failureText } from '@renderer/lib/errors/describe-failure';import { rpc } from '@renderer/lib/ipc';import { useNavigate } from '@renderer/lib/layout/navigation-provider';@@ -125,7 +131,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(false);const [removing, setRemoving] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);const people = members.data ?? [];@@ -172,26 +178,15 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({</span></div>{chat.canManage && (- <div className="flex items-center gap-2">- <Button- variant="outline"- size="sm"- aria-expanded={adding === 'agent'}- onClick={() => setAdding((v) => (v === 'agent' ? null : 'agent'))}- >- <Plus className="size-3.5" />- Add agent- </Button>- <Button- variant="outline"- size="sm"- aria-expanded={adding === 'person'}- onClick={() => setAdding((v) => (v === 'person' ? null : 'person'))}- >- <Plus className="size-3.5" />- Add person- </Button>- </div>+ <Button+ variant="outline"+ size="sm"+ aria-expanded={adding}+ onClick={() => setAdding((v) => !v)}+ >+ <Plus className="size-3.5" />+ Add participant+ </Button>)}</div>@@ -212,116 +207,125 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({manage={manage}/>- {adding === 'agent' && workspaceId !== null && (- <ChatAddAgentPanel serverId={serverId} workspaceId={workspaceId} chat={chat} />- )}- {adding === 'person' && (- <ChatAddPersonPanel+ {adding && (+ <ChatAddParticipantPanelserverId={serverId}workspaceId={workspaceId}- tenantId={chatsStore.tenantId}- roomId={roomId}+ chat={chat}memberIds={new Set(people.map((person) => person.userId))}- onAdded={(next) => queryClient.setQueryData(membersKey, next)}+ onAddedPeople={(next) => queryClient.setQueryData(membersKey, next)}/>)}</section>);});-/** The workspace's agents the viewer can see, any install's; the server decides who may use which. */-const ChatAddAgentPanel = observer(function ChatAddAgentPanel({- serverId,- workspaceId,- chat,-}: {- serverId: string;- workspaceId: string;- chat: ChatSummary;-}) {- const agents = useWorkspaceAgents(workspaceId);- return (- <AddParticipantPanel- noun="agent"- footer={null}- 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}- candidates={addableAgents(agents.data ?? [], chat.agents).map((agent) => ({- id: agent.id,- name: agent.displayName ?? agent.name,- mark: (- <AgentAvatar name={agent.name} iconUrl={agent.iconUrl} serverId={serverId} size={22} />- ),- detail: knownAgentTypeDisplayName(agent.knownAgentType) ?? 'Agent',- }))}- onAdd={async (agentId) => {- try {- chatsStore.add(- serverId,- await rpc.chats.addAgent({ serverId, roomId: chat.roomId, agentId })- );- } catch (cause) {- throw new Error(chatFailure(cause).message);- }- }}- />- );-});+/** Adds a picked participant through the chats API: an agent to the chat, a person as a member. */+export async function addToChat(+ api: Pick<typeof rpc.chats, 'addAgent' | 'addMember'>,+ serverId: string,+ roomId: string,+ participant: Participant+): Promise<+ | { kind: 'agent'; chat: ChatSummary }+ | { kind: 'person'; members: Awaited<ReturnType<typeof rpc.chats.addMember>> }+> {+ if (participant.kind === 'agent')+ return {+ kind: 'agent',+ chat: await api.addAgent({ serverId, roomId, agentId: participant.id }),+ };+ return {+ kind: 'person',+ members: await api.addMember({ serverId, roomId, userId: participant.id }),+ };+}-/** The workspace's people not yet in the chat. */-function ChatAddPersonPanel({+/**+ * The New room dialog's participant field, adding each pick at once: an agent+ * the workspace shows (the server decides who may use which) or a person on+ * its roster, never someone already in the chat.+ */+const ChatAddParticipantPanel = observer(function ChatAddParticipantPanel({serverId,workspaceId,- tenantId,- roomId,+ chat,memberIds,- onAdded,+ onAddedPeople,}: {serverId: string;workspaceId: string | null;- /** The workspace the chats follow; its roster is the one offered. */- tenantId: string | null;- roomId: string;+ chat: ChatSummary;+ /** The people in the chat, the viewer included. */memberIds: Set<string>;- onAdded: (members: Awaited<ReturnType<typeof rpc.chats.addMember>>) => void;+ onAddedPeople: (members: Awaited<ReturnType<typeof rpc.chats.addMember>>) => void;}) {+ const tenantId = chatsStore.tenantId;+ const agents = useWorkspaceAgents(workspaceId);const roster = useQuery({queryKey: ['workspace-members', serverId, tenantId],queryFn: () => rpc.chats.workspaceMembers({ serverId, tenantId: tenantId as string }),enabled: tenantId !== null,});+ const [adding, setAdding] = useState<string | null>(null);+ const [error, setError] = useState<string | null>(null);+ const candidates = [+ ...addableAgents(agents.data ?? [], chat.agents).map((agent) =>+ agentParticipant(agent, knownAgentTypeDisplayName(agent.knownAgentType) ?? 'Agent')+ ),+ ...addablePeople(roster.data ?? [], memberIds).map(personParticipant),+ ];++ async function add(participant: Participant) {+ if (adding !== null) return;+ setAdding(participant.id);+ setError(null);+ try {+ const added = await addToChat(rpc.chats, serverId, chat.roomId, participant);+ if (added.kind === 'agent') chatsStore.add(serverId, added.chat);+ else onAddedPeople(added.members);+ } catch (cause) {+ setError(`${participant.name} was not added — ${chatFailure(cause).message}`);+ } finally {+ setAdding(null);+ }+ }+return (- <AddParticipantPanel- noun="person"- searchPlaceholder="Search people in this workspace…"- allInText="Everyone in this workspace is already in this chat."- loading={tenantId !== null && roster.isPending}- loadError={- tenantId === null- ? 'This workspace has no tenant to list people from.'- : roster.isError- ? 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 ?? '',- }))}- footer={<InviteHint workspaceId={workspaceId} canInvite={canInvite(serverId, workspaceId)} />}- onAdd={async (userId) => {- try {- onAdded(await rpc.chats.addMember({ serverId, roomId, userId }));- } catch (cause) {- throw new Error(chatFailure(cause).message);- }- }}- />+ <div className="flex flex-col gap-2 pt-1">+ <ParticipantPicker+ inputId="chat-add-participant"+ autoFocus+ candidates={candidates}+ picked={[]}+ onChange={(next) => {+ const picked = next.at(-1);+ if (picked) void add(picked);+ }}+ serverId={serverId}+ loading={agents.isPending || (tenantId !== null && roster.isPending)}+ />+ {error !== null && <p className="text-xs text-destructive">{error}</p>}+ {agents.isError && (+ <p className="text-xs text-destructive">+ {failureText(agents.error, 'Could not list the agents.')}+ </p>+ )}+ {tenantId === null ? (+ <p className="text-xs text-destructive">+ This workspace has no tenant to list people from.+ </p>+ ) : (+ roster.isError && (+ <p className="text-xs text-destructive">+ {failureText(roster.error, 'Could not list the people.')}+ </p>+ )+ )}+ <InviteHint workspaceId={workspaceId} canInvite={canInvite(serverId, workspaceId)} />+ </div>);-}+});/** Whether the viewer may invite people to the workspace, as the workspace menu decides it. */function canInvite(serverId: string, workspaceId: string | null): boolean {diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsxindex c2a60bb0a..953cdb586 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx@@ -11,6 +11,12 @@ import { addablePeople } from '@renderer/features/switch-rooms/room-labels';import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { agentProviderLabel } from '@renderer/lib/components/agent-mark';import { agentProviderLabelFor } from '@renderer/lib/components/agent-picker';+import { ParticipantPicker } from '@renderer/lib/components/participant-picker';+import {+ agentParticipant,+ type Participant,+ personParticipant,+} from '@renderer/lib/components/participant-search';import { failureText } from '@renderer/lib/errors/describe-failure';import { rpc } from '@renderer/lib/ipc';import { type BaseModalProps, useModalContext } from '@renderer/lib/modal/modal-provider';@@ -23,12 +29,11 @@ import {DialogHeader,DialogTitle,} from '@renderer/lib/ui/dialog';+import { Field, FieldLabel } from '@renderer/lib/ui/field';import { Input } from '@renderer/lib/ui/input';import { Textarea } from '@renderer/lib/ui/textarea';import { knownAgentTypeDisplayName } from '@shared/core/providers/agent-provider-registry';import { MessagingAppSelector, SWITCH_CONSOLE } from './messaging-app-selector';-import { ParticipantPicker } from './participant-picker';-import type { Participant } from './participant-search';import { CreateRequestIds, canCreate, roomCreateRequest } from './room-create-request';import { RoomNameInput } from './room-name-input';import { switchServersStore } from './switch-servers-store';@@ -116,22 +121,11 @@ export const CreateRoomModal = observer(function CreateRoomModal({.some((local) => local.switchAgentId === remote.id))));const candidates: Participant[] = [- ...agentCandidates.map(- (agent): Participant => ({- kind: 'agent',- id: agent.id,- name: agent.displayName ?? agent.name,- iconUrl: agent.iconUrl,- detail: `Agent · ${providerLabel(agent.id, agent.knownAgentType)}`,- })+ ...agentCandidates.map((agent) =>+ agentParticipant(agent, providerLabel(agent.id, agent.knownAgentType))),...addablePeople(selectedBridge ? [] : (rosterQuery.data ?? []), new Set([myUserId ?? ''])).map(- (person): Participant => ({- kind: 'person',- id: person.userId,- name: person.name,- detail: person.email ?? '',- })+ personParticipant),];const agentIds = picked.filter((each) => each.kind === 'agent').map((each) => each.id);@@ -221,29 +215,33 @@ export const CreateRoomModal = observer(function CreateRoomModal({</p>)}- <RoomNameInput- value={name}- onChange={(next) => {- setName(next);- setError(null);- }}- onSubmit={() => {- if (canSubmit) void handleSubmit();- }}- />- {/* What the name becomes, where it becomes it: a bridged room is a- channel of the same name in its app. */}- {trimmedName !== '' && selectedBridge && (- <span className="-mt-3 text-xs text-foreground-muted">- Created as #{trimmedName} in {selectedBridge.displayName}.- </span>- )}+ <Field>+ <FieldLabel htmlFor="new-room-name">Name</FieldLabel>+ <RoomNameInput+ id="new-room-name"+ value={name}+ onChange={(next) => {+ setName(next);+ setError(null);+ }}+ onSubmit={() => {+ if (canSubmit) void handleSubmit();+ }}+ />+ {/* What the name becomes, where it becomes it: a bridged room is a+ channel of the same name in its app. */}+ {trimmedName !== '' && selectedBridge && (+ <span className="text-xs text-foreground-muted">+ Created as #{trimmedName} in {selectedBridge.displayName}.+ </span>+ )}+ </Field>- <section className="flex flex-col gap-2">- <span className="text-xs font-semibold tracking-wide text-foreground-muted uppercase">- Participants- </span>+ <Field>+ <FieldLabel htmlFor="new-room-participants">Participants</FieldLabel><ParticipantPicker+ inputId="new-room-participants"+ autoFocus={false}candidates={candidates}picked={picked}onChange={setPicked}@@ -263,7 +261,7 @@ export const CreateRoomModal = observer(function CreateRoomModal({{failureText(rosterQuery.error, 'Could not load the people.')}</p>)}- </section>+ </Field>{/* A bridged room's own settings; a Switch Console room has none to start with. */}{selectedBridge && (diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-modal.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-modal.test.tsnew file mode 100644index 000000000..4bfb3c4ef--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-modal.test.ts@@ -0,0 +1,38 @@+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { createElement } from 'react';+import { renderToStaticMarkup } from 'react-dom/server';+import { describe, expect, it, vi } from 'vitest';+import { CreateRoomModal } from './CreateRoomModal';++vi.mock('@renderer/lib/ipc', () => ({ events: { on: vi.fn() }, rpc: {} }));+vi.mock('@renderer/features/chats/stores/chats', () => ({ chatsStore: {} }));+vi.mock('@renderer/lib/modal/modal-provider', () => ({+ useModalContext: () => ({ setCloseGuard: () => {} }),+}));++// The dialog's frame needs an open dialog around it; its contents are the subject here.+vi.mock('@renderer/lib/ui/dialog', () => {+ const pass = ({ children }: { children?: unknown }) => children;+ return {+ DialogContentArea: pass,+ DialogFooter: pass,+ DialogHeader: pass,+ DialogTitle: pass,+ };+});++describe('CreateRoomModal', () => {+ it('labels its fields as the other forms do: Name, then Participants', () => {+ const html = renderToStaticMarkup(+ createElement(+ QueryClientProvider,+ { client: new QueryClient() },+ createElement(CreateRoomModal, { onSuccess: () => {}, onClose: () => {} })+ )+ );+ expect(html).toMatch(/<label[^>]*for="new-room-name"[^>]*>Name<\/label>/);+ expect(html).toContain('placeholder="Name this room"');+ expect(html).toMatch(/<label[^>]*for="new-room-participants"[^>]*>Participants<\/label>/);+ expect(html).not.toContain('uppercase');+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/new-room-dialog.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/new-room-dialog.test.tsindex 485df3225..43a88e496 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/new-room-dialog.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/new-room-dialog.test.ts@@ -1,10 +1,10 @@import { createElement } from 'react';import { renderToStaticMarkup } from 'react-dom/server';import { describe, expect, it, vi } from 'vitest';+import { ParticipantPicker } from '@renderer/lib/components/participant-picker';+import type { Participant } from '@renderer/lib/components/participant-search';import type { RemoteBridge } from '@shared/core/switch-servers/switch-servers';import { MessagingAppSelector, messagingOptions, SWITCH_CONSOLE } from './messaging-app-selector';-import { ParticipantPicker } from './participant-picker';-import type { Participant } from './participant-search';vi.mock('@renderer/lib/stores/use-avatar-settings', () => ({useAvatarSettings: () => ({ thirdPartyAvatarsEnabled: false }),@@ -83,6 +83,8 @@ describe('ParticipantPicker', () => {onChange: () => {},serverId: 's',loading: false,+ inputId: 'participants',+ autoFocus: false,}));expect(html).toContain('aria-label="Remove helper"');diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsxindex da38d1f5e..e6815e156 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsx@@ -1,18 +1,22 @@-/** The new room's name, large as its title; Enter submits, except an Enter the IME is handling. */+import { Input } from '@renderer/lib/ui/input';++/** The new room's name; Enter submits, except an Enter the IME is handling. */export function RoomNameInput({+ id,value,onChange,onSubmit,}: {+ id: string;value: string;onChange: (value: string) => void;onSubmit: () => void;}) {return (- <input+ <Input+ id={id}autoFocus- aria-label="Room name"- placeholder="Room name"+ placeholder="Name this room"value={value}onChange={(e) => onChange(e.target.value)}onKeyDown={(e) => {@@ -20,7 +24,6 @@ export function RoomNameInput({if (e.nativeEvent.isComposing || e.keyCode === 229) return;if (e.key === 'Enter') onSubmit();}}- className="w-full border-b border-border bg-transparent pb-2 text-xl font-semibold text-foreground outline-none placeholder:font-normal placeholder:text-foreground-passive focus:border-foreground-muted"/>);}diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsx b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-picker.tsxsimilarity index 88%rename from console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsxrename to console/apps/switch-console-desktop/src/renderer/lib/components/participant-picker.tsxindex 34680f1da..0f669a914 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsx+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-picker.tsx@@ -54,14 +54,14 @@ export function ParticipantChip({return (<spanclassName={cn(- 'flex h-7 max-w-full items-center gap-1.5 rounded-full py-0.5 pr-1 pl-1 text-sm text-foreground',+ 'flex h-6 max-w-full items-center gap-1.5 rounded-full py-0.5 pr-0.5 pl-0.5 text-sm text-foreground',!accent && 'bg-[var(--fill-2)]')}style={accent ? { backgroundColor: `color-mix(in srgb, ${accent} 20%, transparent)` } : undefined}>- <Mark participant={participant} serverId={serverId} size={20} />+ <Mark participant={participant} serverId={serverId} size={18} /><span className="truncate">{participant.name}</span><buttontype="button"@@ -86,12 +86,17 @@ export function ParticipantPicker({onChange,serverId,loading,+ inputId,+ autoFocus,}: {candidates: Participant[];picked: Participant[];onChange: (next: Participant[]) => void;serverId: string | null;loading: boolean;+ /** For the field's label. */+ inputId: string;+ autoFocus: boolean;}) {const [query, setQuery] = useState('');const [open, setOpen] = useState(false);@@ -108,7 +113,8 @@ export function ParticipantPicker({return (<div><div- className="flex min-h-11 flex-wrap items-center gap-1.5 rounded-[10px] border border-border px-2 py-1.5 focus-within:border-foreground-muted"+ // The standard input's border, radius and focus ring, around chips that wrap.+ className="focus-within:ring-primary/30 dark:bg-input/30 flex min-h-8 w-full flex-wrap items-center gap-1 rounded-md border border-border bg-transparent px-1 py-0.5 transition-[color,box-shadow] focus-within:border-border-primary focus-within:ring-2 hover:border-border-1"onClick={(event) =>(event.currentTarget.querySelector('input') as HTMLInputElement | null)?.focus()}@@ -122,12 +128,14 @@ export function ParticipantPicker({/>))}<input+ id={inputId}+ autoFocus={autoFocus}role="combobox"aria-expanded={open}- aria-controls="new-room-participants"+ aria-controls={`${inputId}-results`}aria-label="Add agents or people"placeholder={picked.length === 0 ? 'Add agents or people…' : ''}- className="h-7 min-w-32 flex-1 bg-transparent px-1 text-sm outline-none placeholder:text-foreground-passive"+ className="h-6 min-w-32 flex-1 bg-transparent px-1.5 text-sm outline-none placeholder:text-foreground-passive"value={query}onChange={(event) => {setQuery(event.target.value);@@ -161,7 +169,7 @@ export function ParticipantPicker({{open && (// In the flow rather than floating: the dialog clips what overflows it, so the list grows it instead.<div- id="new-room-participants"+ id={`${inputId}-results`}role="listbox"className="mt-1 max-h-60 overflow-y-auto rounded-[10px] border border-border bg-background p-1 shadow-sm">diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.test.ts b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.test.tssimilarity index 78%rename from console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.test.tsrename to console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.test.tsindex e8fd2f475..b71d7e4ad 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.test.ts@@ -1,5 +1,11 @@import { describe, expect, it } from 'vitest';-import { type Participant, pickerKey, searchParticipants } from './participant-search';+import {+ agentParticipant,+ type Participant,+ personParticipant,+ pickerKey,+ searchParticipants,+} from './participant-search';const helper: Participant = {kind: 'agent',@@ -54,3 +60,17 @@ describe('pickerKey', () => {expect(pickerKey('Escape', { ...state, open: false })).toBeNull();});});++describe('agentParticipant / personParticipant', () => {+ it('shows an agent by its display name and provider, a person by their email', () => {+ expect(+ agentParticipant({ id: 'a1', name: 'helper', displayName: 'Helper', iconUrl: null }, 'Codex')+ ).toEqual({ kind: 'agent', id: 'a1', name: 'Helper', iconUrl: null, detail: 'Agent · Codex' });+ expect(personParticipant({ userId: 'u2', name: 'Bob', email: null })).toEqual({+ kind: 'person',+ id: 'u2',+ name: 'Bob',+ detail: '',+ });+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.ts b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.tssimilarity index 72%rename from console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.tsrename to console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.tsindex d27750f10..ab51f12fc 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-search.ts+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/participant-search.ts@@ -3,6 +3,29 @@ export type Participant =| { kind: 'agent'; id: string; name: string; iconUrl: string | null; detail: string }| { kind: 'person'; id: string; name: string; detail: string };+/** An agent the workspace lists, as a participant; `provider` names what runs it. */+export function agentParticipant(+ agent: { id: string; name: string; displayName: string | null; iconUrl: string | null },+ provider: string+): Participant {+ return {+ kind: 'agent',+ id: agent.id,+ name: agent.displayName ?? agent.name,+ iconUrl: agent.iconUrl,+ detail: `Agent · ${provider}`,+ };+}++/** A person from the workspace roster, as a participant, shown with their email. */+export function personParticipant(person: {+ userId: string;+ name: string;+ email: string | null;+}): Participant {+ return { kind: 'person', id: person.userId, name: person.name, detail: person.email ?? '' };+}+const same = (a: Participant, b: Participant) => a.kind === b.kind && a.id === b.id;/** The candidates not yet picked whose name or detail (provider, email) contains the query. */diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsxindex 31dfd1e39..83e05f489 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsx@@ -7,9 +7,9 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, describe, expect, it, vi } from 'vitest';-import { ParticipantPicker } from '@renderer/features/switch-servers/participant-picker';-import type { Participant } from '@renderer/features/switch-servers/participant-search';import { RoomNameInput } from '@renderer/features/switch-servers/room-name-input';+import { ParticipantPicker } from '@renderer/lib/components/participant-picker';+import type { Participant } from '@renderer/lib/components/participant-search';let container: HTMLDivElement | null = null;let root: Root | null = null;@@ -54,6 +54,8 @@ describe('New room IME', () => {onChange={onChange}serverId={null}loading={false}+ inputId="participants"+ autoFocus={false}/>);await act(async () => input.focus());@@ -67,7 +69,7 @@ describe('New room IME', () => {it('does not create the room on a composition Enter in the name, and does on a plain one', async () => {const onSubmit = vi.fn();const input = await render(- <RoomNameInput value="会議" onChange={() => {}} onSubmit={onSubmit} />+ <RoomNameInput id="name" value="会議" onChange={() => {}} onSubmit={onSubmit} />);await act(async () => enter(input, { isComposing: true, keyCode: 13 }));await act(async () => enter(input, { keyCode: 229 }));diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.tsindex 9160e0b09..42b2022df 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts@@ -3,6 +3,7 @@ import { createElement } from 'react';import { renderToStaticMarkup } from 'react-dom/server';import { describe, expect, it, vi } from 'vitest';import {+ addToChat,chatMembersQueryKey,InviteHint,RoomConfigurationPanel,@@ -68,8 +69,9 @@ describe('RoomConfigurationPanel for a group chat', () => {expect(html).toContain('Planning');expect(html).toContain('Helper');expect(html).toContain('1 agent · 2 people');- expect(html).toContain('Add agent');- expect(html).toContain('Add person');+ expect(html).toContain('Add participant');+ expect(html).not.toContain('Add agent');+ expect(html).not.toContain('Add person');expect(html).not.toContain('From a template');expect(html).toContain('aria-label="Remove Helper"');expect(html).toContain('aria-label="Remove Bob"');@@ -79,8 +81,7 @@ describe('RoomConfigurationPanel for a group chat', () => {it('shows the participants without controls to someone who cannot manage', () => {const html = render(false);expect(html).toContain('Bob');- expect(html).not.toContain('Add agent');- expect(html).not.toContain('Add person');+ expect(html).not.toContain('Add participant');expect(html).not.toContain('aria-label="Remove');});});@@ -127,3 +128,33 @@ describe('group chat people', () => {expect(cannot).not.toContain('<button');});});++describe('addToChat', () => {+ it('adds an agent to the chat and a person as a member', async () => {+ const api = {+ addAgent: vi.fn(async () => chat.current!),+ addMember: vi.fn(async () => [{ userId: 'u2', name: 'Bob', isOwner: false }]),+ };+ const agentPick = {+ kind: 'agent' as const,+ id: 'a1',+ name: 'helper',+ iconUrl: null,+ detail: 'Agent · Claude Code',+ };+ render(true);+ expect((await addToChat(api, 's', 'r', agentPick)).kind).toBe('agent');+ expect(api.addAgent).toHaveBeenCalledWith({ serverId: 's', roomId: 'r', agentId: 'a1' });+ const added = await addToChat(api, 's', 'r', {+ kind: 'person',+ id: 'u2',+ name: 'Bob',+ detail: '[email protected]',+ });+ expect(added).toEqual({+ kind: 'person',+ members: [{ userId: 'u2', name: 'Bob', isOwner: false }],+ });+ expect(api.addMember).toHaveBeenCalledWith({ serverId: 's', roomId: 'r', userId: 'u2' });+ });+});