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
Room settings: access, group, presence, join notifications, roles, info, archive
Simon Flack27dbf3429ad6
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 be3771938..f155ec43d 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,5 +1,15 @@import { useQuery, useQueryClient } from '@tanstack/react-query';-import { ExternalLink, FileText, Loader2, Plus, RefreshCw, Search, X } from 'lucide-react';+import {+ Archive,+ ExternalLink,+ FileText,+ Loader2,+ Lock,+ Plus,+ RefreshCw,+ Search,+ X,+} from 'lucide-react';import { observer } from 'mobx-react-lite';import { useState } from 'react';import { chatMembersQueryKey, workspaceRosterQuery } from '@renderer/features/chats/chat-people';@@ -10,6 +20,7 @@ import { chatsStore } from '@renderer/features/chats/stores/chats';import { agentsStore } from '@renderer/features/locations/stores/agents-store';import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';import { isConsoleGroupChatSummary } from '@renderer/features/switch-servers/room-filters';+import type { RoomPermissions } from '@renderer/features/switch-servers/room-permissions';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';@@ -36,6 +47,7 @@ import {InputGroupButton,InputGroupInput,} from '@renderer/lib/ui/input-group';+import { Switch } from '@renderer/lib/ui/switch';import { Textarea } from '@renderer/lib/ui/textarea';import { cn } from '@renderer/utils/utils';import { agentInitials } from '@shared/core/agents/agent-avatar';@@ -50,9 +62,16 @@ import type {RemoteRoomDetail,} from '@shared/core/switch-servers/switch-servers';import { administersWorkspace } from '@shared/core/workspaces/workspaces';+import { roomAgentPresence } from './room-agent-presence';import { channelOnDeleteSummary } from './room-delete-wording';import { addableAgents, addablePeople, membershipSummary, roomTitle } from './room-labels';import { openRoomChannel } from './room-links';+import {+ AccessAndGroupFields,+ ArchiveRoomSection,+ RolesSection,+ RoomInfoSection,+} from './room-settings-sections';/** 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. */@@ -106,6 +125,16 @@ const ChatConfiguration = observer(function ChatConfiguration({</p>)}<ChatParticipantsSection serverId={serverId} workspaceId={workspaceId} chat={chat} />+ {workspaceId !== null && detail.data && (+ <>+ <RolesSection+ workspaceId={workspaceId}+ room={detail.data}+ permissions={{ canWrite: chat.canManage, canManage: chat.canManage }}+ />+ <RoomInfoSection room={detail.data} />+ </>+ )}<section className="border-t border-border pt-6"><div className="flex items-center justify-between gap-3"><div className="space-y-0.5">@@ -495,21 +524,90 @@ export const RoomConfigurationPanel = observer(function RoomConfigurationPanel({}const room = query.data;+ const permissions = switchRoomsStore.roomPermissions(workspaceId, room);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} />- {/* Keyed on the room so the drafts below belong to the room on screen:- switching rooms starts a fresh form rather than carrying half-typed- text across. */}- <GeneralSection key={room.id} workspaceId={workspaceId} room={room} />- <ParticipantsSection workspaceId={workspaceId} room={room} />- <DeleteRoomSection workspaceId={workspaceId} room={room} />+ <div className="mx-auto flex w-full max-w-[1080px] gap-10 px-10 py-8">+ <SettingsIndex />+ <div className="flex min-w-0 flex-1 flex-col gap-8">+ <RoomHeading serverId={switchRoomsStore.roomServerId(roomId)} room={room} />+ {room.archived && (+ <Notice icon={<Archive className="size-3.5" />}>+ This room is archived. It is out of the room lists and agents cannot join it.+ </Notice>+ )}+ {!permissions.canWrite && (+ <Notice icon={<Lock className="size-3.5" />}>+ Only {room.ownerName ?? 'the room’s owner'} or a workspace admin can change this+ room’s settings.+ </Notice>+ )}+ {/* Keyed on the room so the drafts below belong to the room on screen:+ switching rooms starts a fresh form rather than carrying half-typed+ text across. */}+ <GeneralSection+ key={room.id}+ workspaceId={workspaceId}+ room={room}+ readOnly={!permissions.canWrite}+ />+ <AccessAndGroupFields workspaceId={workspaceId} room={room} permissions={permissions} />+ <ParticipantsSection workspaceId={workspaceId} room={room} permissions={permissions} />+ <RolesSection workspaceId={workspaceId} room={room} permissions={permissions} />+ <RoomInfoSection room={room} />+ <section+ id="room-settings-archive"+ className="flex flex-col gap-5 border-t border-border pt-6"+ >+ <ArchiveRoomSection workspaceId={workspaceId} room={room} permissions={permissions} />+ <DeleteRoomSection workspaceId={workspaceId} room={room} />+ </section>+ </div></div></div>);});+const SETTINGS_SECTIONS = [+ ['room-settings-general', 'General'],+ ['room-settings-participants', 'Participants'],+ ['room-settings-roles', 'Roles'],+ ['room-settings-info', 'Room info'],+ ['room-settings-archive', 'Archive & delete'],+] as const;++/** The page's sections, to jump between; it stays put while the page scrolls. */+function SettingsIndex() {+ return (+ <nav+ aria-label="Room settings sections"+ className="sticky top-0 hidden w-[150px] shrink-0 self-start pt-1 lg:block"+ >+ {SETTINGS_SECTIONS.map(([id, label]) => (+ <button+ key={id}+ type="button"+ className="block w-full cursor-pointer rounded-md px-2.5 py-1.5 text-left text-sm text-foreground-muted hover:bg-background-1 hover:text-foreground"+ onClick={() =>+ document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' })+ }+ >+ {label}+ </button>+ ))}+ </nav>+ );+}++function Notice({ icon, children }: { icon: React.ReactNode; children: React.ReactNode }) {+ return (+ <div className="flex items-center gap-2 rounded-md bg-background-secondary px-3 py-2 text-xs text-foreground-muted">+ {icon}+ <span>{children}</span>+ </div>+ );+}+/*** Deleting the room, last on its page and below a rule.*@@ -619,7 +717,16 @@ type SaveState = { phase: 'idle' | 'saving' | 'saved' } | { phase: 'failed'; mes** 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,+ readOnly = false,+}: {+ workspaceId: string;+ room: RemoteRoomDetail;+ /** For someone who may read the room but not change it: the fields show, and do not take edits. */+ readOnly?: boolean;+}) {const queryClient = useQueryClient();const savedName = room.name;const savedDescription = room.description;@@ -656,13 +763,14 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo}return (- <section className="flex flex-col gap-4">+ <section id="room-settings-general" className="flex flex-col gap-4"><h2 className="text-sm font-semibold text-foreground">General</h2><Field label="Name" hint="What everyone in the room sees it called."><InputclassName="h-9"aria-label="Name"+ disabled={readOnly}value={name}onChange={(e) => {setName(e.target.value);@@ -683,6 +791,7 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo<InputclassName="h-9"placeholder="What this room is for"+ disabled={readOnly}value={description}onChange={(e) => {setDescription(e.target.value);@@ -695,6 +804,7 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo<Textarearows={4}placeholder="Optional guidance shown to agents when they enter the room"+ disabled={readOnly}value={instructions}onChange={(e) => {setInstructions(e.target.value);@@ -705,7 +815,7 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo{/* The status sits beside the button rather than under a field: onerequest covers both, so there is one answer to report. */}- <div className="flex items-center justify-end gap-3">+ <div className={cn('flex items-center justify-end gap-3', readOnly && 'hidden')}><SaveStatus state={state} dirty={dirty} /><Buttontype="button"@@ -813,30 +923,50 @@ function Field({}/**- * Who is in the room, and the one way to change it from here.- *- * Agents and people are drawn as the same kind of card because they are the same- * kind of fact — membership — and separating them into two lists implied a- * hierarchy the room does not have.+ * Who is in the room: each agent with what it is doing here, whether it is told+ * when someone joins, and a way to take it out; then the people. Someone who may+ * write to the room adds agents — any agent on the server, as the gateway+ * offers — and invites people from the messaging app.*/const ParticipantsSection = observer(function ParticipantsSection({workspaceId,room,+ permissions,}: {workspaceId: string;room: RemoteRoomDetail;+ permissions: RoomPermissions;}) {const queryClient = useQueryClient();- const [adding, setAdding] = useState(false);+ const [panel, setPanel] = useState<'agent' | 'people' | null>(null);+ const [busy, setBusy] = useState<string | null>(null);+ const [error, setError] = useState<string | null>(null);const showAddAgentsToRoomModal = useShowModal('addAgentsToRoomModal');+ const remoteAgents = useWorkspaceAgents(workspaceId);+ const remoteById = new Map((remoteAgents.data ?? []).map((agent) => [agent.id, agent]));+ const detailQueryKey = roomDetailKey(workspaceId, room.id);+ const canWrite = permissions.canWrite;+ const canInvitePeople = canWrite && room.bridgeId !== null;async function refresh() {- await queryClient.invalidateQueries({ queryKey: roomDetailKey(workspaceId, room.id) });+ await queryClient.invalidateQueries({ queryKey: detailQueryKey });await switchRoomsStore.refreshRoomState();}+ async function act(key: string, action: () => Promise<void>, fallback: string) {+ setBusy(key);+ setError(null);+ try {+ await action();+ } catch (cause) {+ setError(failureText(cause, fallback));+ } finally {+ setBusy(null);+ }+ }+return (- <section className="flex flex-col gap-3">+ <section id="room-settings-participants" 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>@@ -844,44 +974,208 @@ const ParticipantsSection = observer(function ParticipantsSection({{membershipSummary(room.agentIds.length, room.connectedUserNames.length)}</span></div>- <div className="flex items-center gap-2">- <Button- variant="outline"- size="sm"- onClick={() => showAddAgentsToRoomModal({ roomId: room.id })}- >- <FileText className="size-3.5" />- From a template- </Button>- <Button- variant="outline"- size="sm"- aria-expanded={adding}- onClick={() => setAdding((v) => !v)}- >- <Plus className="size-3.5" />- Add agent- </Button>- </div>+ {canWrite && (+ <div className="flex items-center gap-2">+ <Button+ variant="outline"+ size="sm"+ onClick={() => showAddAgentsToRoomModal({ roomId: room.id })}+ >+ <FileText className="size-3.5" />+ From a template+ </Button>+ <Button+ variant="outline"+ size="sm"+ aria-expanded={panel === 'agent'}+ onClick={() => setPanel(panel === 'agent' ? null : 'agent')}+ >+ <Plus className="size-3.5" />+ Add agent+ </Button>+ {canInvitePeople && (+ <Button+ variant="outline"+ size="sm"+ aria-expanded={panel === 'people'}+ onClick={() => setPanel(panel === 'people' ? null : 'people')}+ >+ <Plus className="size-3.5" />+ Add people+ </Button>+ )}+ </div>+ )}</div>- <ParticipantList- workspaceId={workspaceId}- agentIds={room.agentIds}- agentNames={new Map()}- people={room.connectedUserNames.map((name) => ({- id: `user:${name}`,- name,- detail: 'person',- }))}- manage={null}- />+ {panel === 'agent' && (+ <AddAgentPanel workspaceId={workspaceId} room={room} onAdded={refresh} />+ )}+ {panel === 'people' && room.bridgeId !== null && (+ <AddPeoplePanel workspaceId={workspaceId} room={room} bridgeId={room.bridgeId} />+ )}+ {error !== null && <p className="text-xs text-destructive">{error}</p>}- {adding && <AddAgentPanel workspaceId={workspaceId} room={room} onAdded={refresh} />}+ {room.agentIds.length === 0 && room.connectedUserNames.length === 0 ? (+ <p className="text-sm text-foreground-muted">Nobody is in this room yet.</p>+ ) : (+ <div className="divide-y divide-border overflow-hidden rounded-[10px] border border-border">+ {room.agentIds.map((agentId) => {+ const name = agentNameFor(agentId, workspaceId, remoteById);+ const presence = roomAgentPresence(room.agentStatuses[agentId]);+ const role = room.roles.find((each) => each.heldBy.includes(name));+ const listening = room.joinEventListeners.includes(agentId);+ return (+ <div key={agentId} className="flex items-center gap-3 px-3.5 py-2.5">+ <AgentMark agentId={agentId} workspaceId={workspaceId} remoteById={remoteById} />+ <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-xs text-foreground-muted">+ {[+ agentKindFor(agentId, workspaceId, remoteById),+ room.agentStatuses[agentId] === undefined ? null : presence.label,+ role ? `role: ${role.name}` : null,+ ]+ .filter(Boolean)+ .join(' · ')}+ </span>+ </div>+ <label+ className="flex shrink-0 items-center gap-2 text-xs text-foreground-muted"+ title="Tell this agent when someone joins the room"+ >+ Notify on join+ <Switch+ size="sm"+ checked={listening}+ disabled={!canWrite || busy === `join:${agentId}`}+ aria-label={`Tell ${name} when someone joins`}+ onCheckedChange={(next) =>+ void act(+ `join:${agentId}`,+ async () => {+ queryClient.setQueryData(+ detailQueryKey,+ await rpc.workspaces.setRoomAgentJoinEvents({+ workspaceId,+ roomId: room.id,+ agentId,+ receivesJoinEvents: next,+ })+ );+ },+ 'Could not change the join notification.'+ )+ }+ />+ </label>+ {canWrite && (+ <Button+ variant="ghost"+ size="icon-xs"+ aria-label={`Remove ${name}`}+ title={`Remove ${name}`}+ disabled={busy === `remove:${agentId}`}+ onClick={() =>+ void act(+ `remove:${agentId}`,+ async () => {+ await rpc.workspaces.removeRoomAgent({+ workspaceId,+ roomId: room.id,+ agentId,+ });+ await refresh();+ },+ `Could not remove ${name}.`+ )+ }+ >+ {busy === `remove:${agentId}` ? <Loader2 className="animate-spin" /> : <X />}+ </Button>+ )}+ </div>+ );+ })}+ {room.connectedUserNames.map((person) => (+ <div key={`user:${person}`} className="flex items-center gap-3 px-3.5 py-2.5">+ <PersonMark name={person} size="md" />+ <span className="min-w-0 flex-1 truncate text-sm text-foreground">{person}</span>+ <span className="shrink-0 text-xs text-foreground-muted">person</span>+ </div>+ ))}+ </div>+ )}+ {room.bridgeId !== null && room.connectedUserNames.length > 0 && (+ <p className="text-xs text-foreground-muted">+ People are those Switch has seen in the channel or added to it. The channel may have more.+ </p>+ )}</section>);});+/**+ * Invite people to a bridged room from the messaging app's users Switch knows.+ * The server does not say who it could not add, so the names asked for are+ * compared with the room's people afterwards and any missing are named.+ */+const AddPeoplePanel = observer(function AddPeoplePanel({+ workspaceId,+ room,+ bridgeId,+}: {+ workspaceId: string;+ room: RemoteRoomDetail;+ bridgeId: string;+}) {+ const queryClient = useQueryClient();+ const [notAdded, setNotAdded] = useState<string | null>(null);+ const users = useQuery({+ queryKey: ['bridge-user-names', workspaceId, bridgeId],+ queryFn: () => rpc.workspaces.listBridgeUserNames({ workspaceId, bridgeId }),+ });+ const present = new Set(room.connectedUserNames);+ return (+ <>+ <AddParticipantPanel+ noun="person"+ searchPlaceholder={`Search people on ${room.bridgeDisplayName ?? 'the messaging app'}…`}+ allInText="Everyone Switch knows on this messaging app is already in the room."+ loading={users.isPending}+ loadError={users.isError ? failureText(users.error, 'Could not list the people.') : null}+ candidates={(users.data ?? [])+ .filter((name) => !present.has(name))+ .map((name) => ({+ id: name,+ name,+ mark: <PersonMark name={name} size="sm" />,+ detail: 'person',+ }))}+ footer={+ <p className="px-1 text-xs text-foreground-muted">+ Only people Switch has seen on this messaging app are listed.+ </p>+ }+ onAdd={async (name) => {+ setNotAdded(null);+ const updated = await rpc.workspaces.addRoomUsers({+ workspaceId,+ roomId: room.id,+ userNames: [name],+ });+ queryClient.setQueryData(roomDetailKey(workspaceId, room.id), updated);+ if (!updated.connectedUserNames.includes(name))+ setNotAdded(+ `${name} was not added. The messaging app may not have let Switch invite them.`+ );+ }}+ />+ {notAdded !== null && <p className="text-xs text-destructive">{notAdded}</p>}+ </>+ );+});+type Person = { id: string; name: string; detail: string };/** Removal from the cards, for someone who may manage the members; `removePerson` is null for one who cannot be removed. */@@ -1103,11 +1397,9 @@ function AddParticipantPanel({}/**- * Search this computer's agents and put one in the room.- *- * Scoped to agents this install owns, like every other add-an-agent surface:- * adding somebody else's agent from here would put a room in front of an agent- * whose owner never agreed to it.+ * Search the server's agents and put one in the room — any agent the viewer can+ * see, as the gateway offers. Whether an agent then answers anyone in the room+ * is still up to its own addressing rules.*/const AddAgentPanel = observer(function AddAgentPanel({workspaceId,@@ -1119,40 +1411,42 @@ const AddAgentPanel = observer(function AddAgentPanel({onAdded: () => Promise<void>;}) {const members = new Set(room.agentIds);- const { data: remoteAgents } = useWorkspaceAgents(workspaceId);- const remoteById = new Map((remoteAgents ?? []).map((agent) => [agent.id, agent]));+ const remoteAgents = useWorkspaceAgents(workspaceId);+ const serverId = workspacesStore.serverIdFor(workspaceId);return (<AddParticipantPanelnoun="agent"footer={null}- searchPlaceholder="Search agents on this computer…"- allInText="Every agent on this computer is already in this room."- loading={false}- loadError={null}- candidates={agentsStore- .agentsInWorkspace(workspaceId)- .filter((agent) => agent.switchAgentId !== null && !members.has(agent.switchAgentId))- .map((agent) => {- const switchAgentId = agent.switchAgentId as string;- return {- id: switchAgentId,- name: agent.name,- mark: (- <AgentAvatar- name={agent.name}- iconUrl={remoteById.get(switchAgentId)?.iconUrl ?? null}- serverId={agent.serverId}- size={22}- />- ),- detail: providerDisplayName(agent.providerId) ?? 'Agent',- };- })}- onAdd={async (switchAgentId) => {+ searchPlaceholder="Search agents…"+ allInText="Every agent on this server is already in this room."+ loading={remoteAgents.isPending}+ loadError={+ remoteAgents.isError ? failureText(remoteAgents.error, 'Could not list the agents.') : null+ }+ candidates={(remoteAgents.data ?? [])+ .filter((agent) => !members.has(agent.id))+ .map((agent) => ({+ id: agent.id,+ name: agent.name,+ mark: (+ <AgentAvatar name={agent.name} iconUrl={agent.iconUrl} serverId={serverId} size={22} />+ ),+ detail: [+ localAgentFor(agent.id, workspaceId)+ ? 'yours'+ : agent.ownerName+ ? `${agent.ownerName}’s`+ : null,+ agentKindFor(agent.id, workspaceId, new Map([[agent.id, agent]])),+ ]+ .filter(Boolean)+ .join(' · '),+ }))}+ onAdd={async (agentId) => {await rpc.workspaces.addRoomAgents({workspaceId,roomId: room.id,- agentIds: [switchAgentId],+ agentIds: [agentId],direction: 'agents_to_room',});await onAdded();diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-settings-sections.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-settings-sections.tsxnew file mode 100644index 000000000..c8b91a99c--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-settings-sections.tsx@@ -0,0 +1,558 @@+import { useQuery, useQueryClient } from '@tanstack/react-query';+import { Archive, ArchiveRestore, Loader2, Pencil, Plus, Trash2 } from 'lucide-react';+import { observer } from 'mobx-react-lite';+import { useState } from 'react';+import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';+import type { RoomPermissions } from '@renderer/features/switch-servers/room-permissions';+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';+import { failureText } from '@renderer/lib/errors/describe-failure';+import { rpc } from '@renderer/lib/ipc';+import { AbsoluteTime } from '@renderer/lib/ui/absolute-time';+import { Button } from '@renderer/lib/ui/button';+import { Checkbox } from '@renderer/lib/ui/checkbox';+import { Input } from '@renderer/lib/ui/input';+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@renderer/lib/ui/select';+import { Textarea } from '@renderer/lib/ui/textarea';+import {+ type RemoteRoomDetail,+ type RemoteRoomRole,+ type RoomAccess,+ roomAccessOf,+ visibilityForAccess,+} from '@shared/core/switch-servers/switch-servers';++/** The query key the room page reads one room under; shared with `room-configuration-panel`. */+function detailKey(workspaceId: string, roomId: string) {+ return ['remote-room-detail', workspaceId, roomId] as const;+}++export const ACCESS_LABELS: Record<RoomAccess, string> = {+ public: 'Everyone in the workspace can see and post',+ read_only: 'Everyone can see it; only the owner and admins post',+ private: 'Only the owner and admins',+};++const ACCESS_ORDER: RoomAccess[] = ['public', 'read_only', 'private'];+const NO_GROUP = '__none__';++/** One write's progress, for a control that saves the moment it changes. */+type WriteState = { phase: 'idle' | 'saving' | 'saved' } | { phase: 'failed'; message: string };++function WriteStatus({ state }: { state: WriteState }) {+ if (state.phase === 'saving')+ return <span className="text-xs text-foreground-muted">Saving…</span>;+ if (state.phase === 'saved') return <span className="text-xs text-foreground-muted">Saved.</span>;+ if (state.phase === 'failed')+ return <span className="text-xs text-destructive">Not saved — {state.message}</span>;+ return null;+}++/**+ * Who may see and post in the room, and the group it is filed under. Each+ * saves as soon as it is picked: a choice from a list is already a decision,+ * unlike half-typed text, so there is nothing to confirm.+ *+ * Access is the owner's and the admins' to change, so for anyone else it is+ * shown as words rather than a control they would only be refused at.+ */+export const AccessAndGroupFields = observer(function AccessAndGroupFields({+ workspaceId,+ room,+ permissions,+}: {+ workspaceId: string;+ room: RemoteRoomDetail;+ permissions: RoomPermissions;+}) {+ const queryClient = useQueryClient();+ const [accessState, setAccessState] = useState<WriteState>({ phase: 'idle' });+ const [groupState, setGroupState] = useState<WriteState>({ phase: 'idle' });+ const groups = useQuery({+ queryKey: ['room-groups', workspaceId],+ queryFn: () => rpc.workspaces.listRoomGroups(workspaceId),+ enabled: permissions.canWrite,+ });+ const access = roomAccessOf(room.readVisibility, room.writeVisibility);++ async function write(+ setState: (state: WriteState) => void,+ action: () => Promise<RemoteRoomDetail>,+ fallback: string+ ) {+ setState({ phase: 'saving' });+ try {+ queryClient.setQueryData(detailKey(workspaceId, room.id), await action());+ setState({ phase: 'saved' });+ void refreshSidebarRoomState(true);+ } catch (cause) {+ setState({ phase: 'failed', message: failureText(cause, fallback) });+ }+ }++ return (+ <div className="grid grid-cols-2 gap-4">+ <div className="flex flex-col gap-1.5">+ <span className="text-sm text-foreground-muted">Who can see and post</span>+ {permissions.canManage ? (+ <Select+ value={access}+ onValueChange={(next) =>+ next !== access &&+ void write(+ setAccessState,+ () =>+ rpc.workspaces.updateRoom({+ workspaceId,+ roomId: room.id,+ ...visibilityForAccess(next as RoomAccess),+ }),+ 'Could not change who can see this room.'+ )+ }+ >+ <SelectTrigger className="w-full" aria-label="Who can see and post">+ <SelectValue>{ACCESS_LABELS[access]}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {ACCESS_ORDER.map((option) => (+ <SelectItem key={option} value={option}>+ {ACCESS_LABELS[option]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ ) : (+ <span className="text-sm text-foreground">{ACCESS_LABELS[access]}</span>+ )}+ <span className="min-h-4 text-xs text-foreground-muted">+ {accessState.phase === 'idle' ? (+ permissions.canManage ? (+ 'Only the room’s owner and workspace admins change this.'+ ) : (+ 'The room’s owner or a workspace admin can change this.'+ )+ ) : (+ <WriteStatus state={accessState} />+ )}+ </span>+ </div>++ <div className="flex flex-col gap-1.5">+ <span className="text-sm text-foreground-muted">Group</span>+ {permissions.canWrite ? (+ <Select+ value={room.groupId ?? NO_GROUP}+ onValueChange={(next) => {+ const groupId = next === NO_GROUP ? null : (next as string);+ if (groupId === room.groupId) return;+ void write(+ setGroupState,+ () => rpc.workspaces.setRoomGroup({ workspaceId, roomId: room.id, groupId }),+ 'Could not change the room’s group.'+ );+ }}+ >+ <SelectTrigger className="w-full" aria-label="Group">+ <SelectValue>{room.groupName ?? 'No group'}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={NO_GROUP}>No group</SelectItem>+ {(groups.data ?? []).map((group) => (+ <SelectItem key={group.id} value={group.id}>+ {group.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ ) : (+ <span className="text-sm text-foreground">{room.groupName ?? 'No group'}</span>+ )}+ <span className="min-h-4 text-xs text-foreground-muted">+ {groupState.phase === 'idle' ? (+ groups.isError ? (+ failureText(groups.error, 'Could not list the groups.')+ ) : (+ 'Groups organise rooms and can scope who may talk to an agent.'+ )+ ) : (+ <WriteStatus state={groupState} />+ )}+ </span>+ </div>+ </div>+ );+});++/**+ * The room's roles: hats an agent can put on here, each with the instructions+ * it hands whoever takes it. Addressing `@role` reaches whoever holds it.+ */+export const RolesSection = observer(function RolesSection({+ workspaceId,+ room,+ permissions,+}: {+ workspaceId: string;+ room: RemoteRoomDetail;+ permissions: RoomPermissions;+}) {+ const queryClient = useQueryClient();+ const [adding, setAdding] = useState(false);+ const [editing, setEditing] = useState<string | null>(null);+ const [error, setError] = useState<string | null>(null);++ function storeRoles(roles: RemoteRoomRole[]) {+ queryClient.setQueryData<RemoteRoomDetail>(detailKey(workspaceId, room.id), (current) =>+ current ? { ...current, roles } : current+ );+ }++ async function remove(name: string) {+ setError(null);+ try {+ storeRoles(await rpc.workspaces.deleteRoomRole({ workspaceId, roomId: room.id, name }));+ } catch (cause) {+ setError(`Not deleted — ${failureText(cause, 'Could not delete the role.')}`);+ }+ }++ return (+ <section id="room-settings-roles" 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">Roles</h2>+ <span className="text-xs text-foreground-muted">{room.roles.length}</span>+ </div>+ {permissions.canWrite && !adding && (+ <Button variant="outline" size="sm" onClick={() => setAdding(true)}>+ <Plus className="size-3.5" />+ Add role+ </Button>+ )}+ </div>+ <p className="-mt-1 text-xs text-foreground-muted">+ Hats an agent can put on in this room. Mentioning a role reaches whoever holds it.+ </p>++ {adding && (+ <RoleForm+ existing={null}+ takenNames={room.roles.map((role) => role.name)}+ onCancel={() => setAdding(false)}+ onSave={async (input) => {+ storeRoles(+ await rpc.workspaces.createRoomRole({ workspaceId, roomId: room.id, role: input })+ );+ setAdding(false);+ }}+ />+ )}+ {error !== null && <p className="text-xs text-destructive">{error}</p>}++ {room.roles.length === 0 && !adding ? (+ <p className="text-sm text-foreground-muted">No roles in this room.</p>+ ) : (+ <div className="divide-y divide-border overflow-hidden rounded-[10px] border border-border">+ {room.roles.map((role) =>+ editing === role.name ? (+ <div key={role.name} className="p-3">+ <RoleForm+ existing={role}+ takenNames={[]}+ onCancel={() => setEditing(null)}+ onSave={async (input) => {+ storeRoles(+ await rpc.workspaces.updateRoomRole({+ workspaceId,+ roomId: room.id,+ name: role.name,+ instructions: input.instructions,+ exclusive: input.exclusive,+ })+ );+ setEditing(null);+ }}+ />+ </div>+ ) : (+ <div key={role.name} className="flex items-start gap-3 px-3.5 py-2.5">+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <div className="flex items-center gap-2">+ <span className="text-sm font-medium text-foreground">{role.name}</span>+ <span className="rounded-full bg-background-tertiary px-2 text-[11px] text-foreground-muted">+ {role.exclusive ? 'one at a time' : 'shared'}+ </span>+ </div>+ <span className="truncate text-xs text-foreground-muted">+ {role.heldBy.length > 0+ ? `Held by ${role.heldBy.join(', ')}`+ : 'Nobody holds it right now'}+ </span>+ {role.instructions && (+ <span className="line-clamp-2 text-xs text-foreground-muted">+ {role.instructions}+ </span>+ )}+ </div>+ {permissions.canWrite && (+ <div className="flex shrink-0 items-center gap-1">+ <Button+ variant="ghost"+ size="icon-xs"+ aria-label={`Edit ${role.name}`}+ title="Edit"+ onClick={() => setEditing(role.name)}+ >+ <Pencil />+ </Button>+ <ConfirmIconButton+ label={`Delete ${role.name}`}+ onConfirm={() => remove(role.name)}+ />+ </div>+ )}+ </div>+ )+ )}+ </div>+ )}+ </section>+ );+});++/** A role's fields, for adding one or editing one; the name is fixed once the role exists. */+function RoleForm({+ existing,+ takenNames,+ onCancel,+ onSave,+}: {+ existing: RemoteRoomRole | null;+ takenNames: string[];+ onCancel: () => void;+ onSave: (input: { name: string; instructions: string; exclusive: boolean }) => Promise<void>;+}) {+ const [name, setName] = useState(existing?.name ?? '');+ const [instructions, setInstructions] = useState(existing?.instructions ?? '');+ const [exclusive, setExclusive] = useState(existing?.exclusive ?? false);+ const [saving, setSaving] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const trimmed = name.trim();+ const clash = existing === null && takenNames.includes(trimmed);++ async function save() {+ setSaving(true);+ setError(null);+ try {+ await onSave({ name: trimmed, instructions, exclusive });+ } catch (cause) {+ setError(failureText(cause, 'Could not save the role.'));+ setSaving(false);+ }+ }++ return (+ <div className="flex flex-col gap-2.5 rounded-[10px] border border-border p-3">+ {existing === null && (+ <Input+ className="h-9"+ aria-label="Role name"+ placeholder="Role name, e.g. reviewer"+ value={name}+ onChange={(e) => setName(e.target.value)}+ />+ )}+ <Textarea+ rows={3}+ aria-label="Role instructions"+ placeholder="What an agent holding this role should do"+ value={instructions}+ onChange={(e) => setInstructions(e.target.value)}+ />+ <label className="flex items-center gap-2 text-sm text-foreground">+ <Checkbox checked={exclusive} onCheckedChange={(next) => setExclusive(next === true)} />+ Only one agent can hold it at a time+ </label>+ {existing !== null && (+ <p className="text-xs text-foreground-muted">+ An agent already holding this role keeps the instructions it was given until it takes the+ role again.+ </p>+ )}+ {clash && (+ <p className="text-xs text-destructive">This room already has a role called that.</p>+ )}+ {error !== null && <p className="text-xs text-destructive">Not saved — {error}</p>}+ <div className="flex justify-end gap-2">+ <Button variant="ghost" size="sm" onClick={onCancel} disabled={saving}>+ Cancel+ </Button>+ <Button size="sm" disabled={saving || trimmed === '' || clash} onClick={() => void save()}>+ {saving ? 'Saving…' : existing === null ? 'Add role' : 'Save'}+ </Button>+ </div>+ </div>+ );+}++/** A delete that asks once more before it acts: the first click arms it, the second deletes. */+function ConfirmIconButton({+ label,+ onConfirm,+}: {+ label: string;+ onConfirm: () => Promise<void>;+}) {+ const [armed, setArmed] = useState(false);+ const [busy, setBusy] = useState(false);+ if (armed) {+ return (+ <Button+ variant="outline"+ size="xs"+ className="border-red-500/40 text-red-500 hover:bg-red-500/10 hover:text-red-500"+ disabled={busy}+ onBlur={() => !busy && setArmed(false)}+ onClick={async () => {+ setBusy(true);+ await onConfirm();+ setBusy(false);+ setArmed(false);+ }}+ >+ {busy ? <Loader2 className="size-3 animate-spin" /> : 'Delete'}+ </Button>+ );+ }+ return (+ <Button+ variant="ghost"+ size="icon-xs"+ aria-label={label}+ title="Delete"+ onClick={() => setArmed(true)}+ >+ <Trash2 />+ </Button>+ );+}++/** Facts about the room that nobody edits here, for finding it elsewhere. */+export function RoomInfoSection({ room }: { room: RemoteRoomDetail }) {+ const rows: [string, React.ReactNode][] = [+ [+ 'Created',+ room.createdAt ? <AbsoluteTime key="created" value={room.createdAt} includeYear /> : '—',+ ],+ ['Owner', room.ownerName ?? '—'],+ [+ 'Messaging app',+ room.bridgeDisplayName ?? (room.isConsoleChat ? 'Group chat in Switch Console' : 'None'),+ ],+ ];+ if (room.linkedChannelName) rows.push(['Channel', `#${room.linkedChannelName}`]);+ if (room.externalChannelId)+ rows.push(['Channel id', <Mono key="c">{room.externalChannelId}</Mono>]);+ if (room.transportRoomId)+ rows.push(['Switch room id', <Mono key="t">{room.transportRoomId}</Mono>]);+ return (+ <section id="room-settings-info" className="flex flex-col gap-3">+ <h2 className="text-sm font-semibold text-foreground">Room info</h2>+ <dl className="grid grid-cols-[140px_1fr] gap-x-4 gap-y-2 text-sm">+ {rows.map(([label, value]) => (+ <div key={label} className="contents">+ <dt className="text-foreground-muted">{label}</dt>+ <dd className="min-w-0 truncate text-foreground">{value}</dd>+ </div>+ ))}+ </dl>+ </section>+ );+}++function Mono({ children }: { children: React.ReactNode }) {+ return <span className="font-mono text-xs select-all">{children}</span>;+}++/**+ * Archiving the room, beside deleting it. Archiving keeps everything and is+ * undone here; while archived, the room drops out of the room lists and its+ * page says so.+ */+export const ArchiveRoomSection = observer(function ArchiveRoomSection({+ workspaceId,+ room,+ permissions,+}: {+ workspaceId: string;+ room: RemoteRoomDetail;+ permissions: RoomPermissions;+}) {+ const queryClient = useQueryClient();+ const [busy, setBusy] = useState(false);+ const [error, setError] = useState<string | null>(null);+ if (!permissions.canWrite) return null;++ async function toggle() {+ setBusy(true);+ setError(null);+ try {+ const updated = await rpc.workspaces.setRoomArchived({+ workspaceId,+ roomId: room.id,+ archived: !room.archived,+ });+ queryClient.setQueryData(detailKey(workspaceId, room.id), updated);+ await switchRoomsStore.refreshRoomState();+ void refreshSidebarRoomState(true);+ void queryClient.invalidateQueries({ queryKey: ['archived-rooms', workspaceId] });+ } catch (cause) {+ setError(+ failureText(+ cause,+ room.archived ? 'Could not unarchive the room.' : 'Could not archive the room.'+ )+ );+ } finally {+ setBusy(false);+ }+ }++ return (+ <div className="flex items-center justify-between gap-3">+ <div className="space-y-0.5">+ <h3 className="text-sm font-medium text-foreground">+ {room.archived ? 'Unarchive room' : 'Archive room'}+ </h3>+ <p className="text-xs text-foreground-muted">+ {room.archived+ ? 'Puts the room back in the room lists, with everything in it.'+ : 'Takes the room out of the room lists and stops agents joining it. Nothing in it is deleted, and you can unarchive it from Your Rooms.'}+ </p>+ {error !== null && <p className="text-xs text-destructive">{error}</p>}+ </div>+ <Button+ variant="outline"+ size="sm"+ className="shrink-0"+ disabled={busy}+ onClick={() => void toggle()}+ >+ {room.archived ? <ArchiveRestore className="size-3.5" /> : <Archive className="size-3.5" />}+ {busy+ ? room.archived+ ? 'Unarchiving…'+ : 'Archiving…'+ : room.archived+ ? 'Unarchive'+ : 'Archive'}+ </Button>+ </div>+ );+});diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsxindex b638d31a1..0a155f4d1 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx@@ -34,6 +34,7 @@ vi.mock('@renderer/lib/ipc', () => ({getRoomDetail,syncRoomName,listAgents: vi.fn(() => Promise.resolve([])),+ listRoomGroups: vi.fn(() => Promise.resolve([])),},agents: { getAgents: vi.fn(() => Promise.resolve([])) },},@@ -44,6 +45,7 @@ vi.mock('@renderer/features/switch-servers/switch-rooms-store', () => ({roomWorkspaceId: () => 'ws-1',roomServerId: () => 'server-1',canDeleteRoom: () => manages.value,+ roomPermissions: () => ({ canWrite: true, canManage: manages.value }),},}));@@ -66,6 +68,20 @@ const ROOM = {externalChannelUrl: null,agentIds: [],connectedUserNames: [],+ readVisibility: 'public',+ writeVisibility: 'public',+ groupId: null,+ groupName: null,+ ownerName: 'Ada',+ bridgeId: null,+ agentStatuses: {},+ roles: [],+ joinEventListeners: [],+ externalChannelId: null,+ transportRoomId: null,+ archived: false,+ archivedAt: null,+ createdAt: '2026-10-01T09:00:00+00:00',};let container: HTMLDivElement | null = null;diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-settings-sections.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-settings-sections.test.tsxnew file mode 100644index 000000000..a50bf9ce4--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-settings-sections.test.tsx@@ -0,0 +1,230 @@+/**+ * A bridged room's settings page: what someone who may write to the room can+ * change, and what someone who may not is shown instead.+ */+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++const getRoomDetail = vi.hoisted(() => vi.fn());+const setRoomAgentJoinEvents = vi.hoisted(() => vi.fn());+const createRoomRole = vi.hoisted(() => vi.fn());+const setRoomArchived = vi.hoisted(() => vi.fn());+const permissions = vi.hoisted(() => ({ value: { canWrite: true, canManage: true } }));++vi.hoisted(() => {+ window.electronAPI ??= {+ invoke: () => Promise.resolve(undefined),+ eventOn: () => () => {},+ eventSend: () => {},+ } as unknown as typeof window.electronAPI;+});++vi.mock('@renderer/lib/ipc', () => ({+ events: { on: vi.fn() },+ rpc: {+ workspaces: {+ getRoomDetail,+ setRoomAgentJoinEvents,+ createRoomRole,+ setRoomArchived,+ updateRoom: vi.fn(),+ syncRoomName: vi.fn(),+ listAgents: vi.fn(() =>+ Promise.resolve([{ id: 'a-1', name: 'reviewer-bot', iconUrl: null, knownAgentType: null }])+ ),+ listRoomGroups: vi.fn(() => Promise.resolve([])),+ },+ agents: { getAgents: vi.fn(() => Promise.resolve([])) },+ },+}));++vi.mock('@renderer/features/switch-servers/switch-rooms-store', () => ({+ switchRoomsStore: {+ roomWorkspaceId: () => 'ws-1',+ roomServerId: () => 'server-1',+ canDeleteRoom: () => permissions.value.canManage,+ roomPermissions: () => permissions.value,+ refreshRoomState: vi.fn(async () => {}),+ },+}));++vi.mock('@renderer/features/sidebar/sidebar-tree-data', () => ({+ refreshSidebarRoomState: vi.fn(async () => {}),+ refreshSidebarRoomStateAfterOnboarding: vi.fn(),+}));++import { RoomConfigurationPanel } from '@renderer/features/switch-rooms/room-configuration-panel';++const ROOM = {+ id: 'room-1',+ name: 'design-review',+ description: 'Where we review designs',+ instructions: '',+ channelType: 'channel_public',+ agentCount: 1,+ bridgeType: 'mattermost',+ bridgeDisplayName: 'Mattermost',+ externalChannelUrl: null,+ ownerId: 'u-1',+ viewerIsMember: true,+ isConsoleChat: false,+ createdAt: '2026-10-01T09:00:00+00:00',+ agentIds: ['a-1'],+ connectedUserNames: ['ada'],+ linkedChannelName: null,+ readVisibility: 'public',+ writeVisibility: 'private',+ groupId: null,+ groupName: null,+ ownerName: 'Ada',+ bridgeId: 'bridge-1',+ agentStatuses: { 'a-1': 'live' },+ roles: [],+ joinEventListeners: [],+ externalChannelId: 'C123',+ transportRoomId: '!abc:switch.local',+ archived: false,+ archivedAt: null,+};++let container: HTMLDivElement | null = null;+let root: Root | null = null;++beforeEach(() => {+ getRoomDetail.mockReset();+ getRoomDetail.mockResolvedValue(ROOM);+ setRoomAgentJoinEvents.mockReset();+ setRoomAgentJoinEvents.mockImplementation(+ (params: { receivesJoinEvents: boolean; agentId: string }) =>+ Promise.resolve({+ ...ROOM,+ joinEventListeners: params.receivesJoinEvents ? [params.agentId] : [],+ })+ );+ createRoomRole.mockReset();+ createRoomRole.mockImplementation(+ (params: { role: { name: string; instructions: string; exclusive: boolean } }) =>+ Promise.resolve([{ ...params.role, heldBy: [] }])+ );+ setRoomArchived.mockReset();+ setRoomArchived.mockImplementation((params: { archived: boolean }) =>+ Promise.resolve({ ...ROOM, archived: params.archived })+ );+ permissions.value = { canWrite: true, canManage: true };+});++afterEach(async () => {+ if (root) await act(async () => root!.unmount());+ container?.remove();+ container = null;+ root = null;+});++async function renderPanel(): Promise<HTMLDivElement> {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+ const client = new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0 } } });+ await act(async () =>+ root!.render(+ <QueryClientProvider client={client}>+ <RoomConfigurationPanel roomId="room-1" />+ </QueryClientProvider>+ )+ );+ for (let i = 0; i < 6; i++) await act(async () => await Promise.resolve());+ return container;+}++function button(el: HTMLElement, text: RegExp): HTMLButtonElement | undefined {+ return [...el.querySelectorAll<HTMLButtonElement>('button')].find((b) =>+ text.test(b.textContent?.trim() ?? '')+ );+}++async function click(target: HTMLElement) {+ await act(async () => target.click());+ for (let i = 0; i < 4; i++) await act(async () => await Promise.resolve());+}++async function type(field: HTMLInputElement | HTMLTextAreaElement, value: string) {+ const proto =+ field instanceof HTMLTextAreaElement+ ? HTMLTextAreaElement.prototype+ : HTMLInputElement.prototype;+ await act(async () => {+ Object.getOwnPropertyDescriptor(proto, 'value')!.set!.call(field, value);+ field.dispatchEvent(new Event('input', { bubbles: true }));+ });+}++describe('room settings for someone who may write to the room', () => {+ it('shows each agent’s presence, and access as a control for its manager', async () => {+ const el = await renderPanel();+ expect(el.textContent).toContain('reviewer-bot');+ expect(el.textContent).toContain('Here now');+ expect(el.querySelector('[aria-label="Who can see and post"]')).not.toBeNull();+ expect(el.textContent).toContain('C123');+ });++ it('turns an agent’s join notification on', async () => {+ const el = await renderPanel();+ const toggle = el.querySelector<HTMLElement>(+ '[aria-label="Tell reviewer-bot when someone joins"]'+ )!;+ await click(toggle);+ expect(setRoomAgentJoinEvents).toHaveBeenCalledWith({+ workspaceId: 'ws-1',+ roomId: 'room-1',+ agentId: 'a-1',+ receivesJoinEvents: true,+ });+ });++ it('adds a role and lists it', async () => {+ const el = await renderPanel();+ await click(button(el, /^Add role$/)!);+ await type(el.querySelector<HTMLInputElement>('input[aria-label="Role name"]')!, 'reviewer');+ await type(+ el.querySelector<HTMLTextAreaElement>('textarea[aria-label="Role instructions"]')!,+ 'Review every change'+ );+ const add = [...el.querySelectorAll<HTMLButtonElement>('button')].filter(+ (b) => b.textContent?.trim() === 'Add role'+ );+ await click(add.at(-1)!);+ expect(createRoomRole).toHaveBeenCalledWith({+ workspaceId: 'ws-1',+ roomId: 'room-1',+ role: { name: 'reviewer', instructions: 'Review every change', exclusive: false },+ });+ expect(el.textContent).toContain('Nobody holds it right now');+ });++ it('archives the room', async () => {+ const el = await renderPanel();+ await click(button(el, /^Archive$/)!);+ expect(setRoomArchived).toHaveBeenCalledWith({+ workspaceId: 'ws-1',+ roomId: 'room-1',+ archived: true,+ });+ expect(el.textContent).toContain('This room is archived');+ });+});++describe('room settings for someone who may only read the room', () => {+ it('says who can change it, and offers no changes', async () => {+ permissions.value = { canWrite: false, canManage: false };+ const el = await renderPanel();+ expect(el.textContent).toContain(+ 'Only Ada or a workspace admin can change this room’s settings.'+ );+ expect(el.querySelector('[aria-label="Who can see and post"]')).toBeNull();+ expect(button(el, /^Add agent$/)).toBeUndefined();+ expect(button(el, /^Archive$/)).toBeUndefined();+ expect(el.querySelector<HTMLInputElement>('input[aria-label="Name"]')!.disabled).toBe(true);+ });+});