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: only a workspace admin puts a room in a group
Simon Flacka92e730215b2
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 c968405b4..636bc7575 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@@ -8,6 +8,7 @@ import { chatsStore } from '@renderer/features/chats/stores/chats';import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';import { isConsoleGroupChatSummary } from '@renderer/features/switch-servers/room-filters';import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';+import { administersWorkspaceById } from '@renderer/features/switch-servers/workspace-admin';import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';import { describeFailure, failureText } from '@renderer/lib/errors/describe-failure';@@ -186,7 +187,12 @@ export const RoomConfigurationPanel = observer(function RoomConfigurationPanel({room={room}readOnly={!permissions.canWrite}/>- <AccessAndGroupFields workspaceId={workspaceId} room={room} permissions={permissions} />+ <AccessAndGroupFields+ workspaceId={workspaceId}+ room={room}+ permissions={permissions}+ administersWorkspace={administersWorkspaceById(workspaceId)}+ /><RolesSection workspaceId={workspaceId} room={room} permissions={permissions} /><RoomInfoSection room={room} /><sectiondiff --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.tsxindex 9bd11655b..f1309cb4d 100644--- 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.tsx@@ -68,19 +68,37 @@ export const AccessAndGroupFields = observer(function AccessAndGroupFields({workspaceId,room,permissions,+ administersWorkspace,}: {workspaceId: string;room: RemoteRoomDetail;permissions: RoomPermissions;+ /**+ * Whether the viewer administers the room's workspace. Putting a room in a+ * group is theirs alone: a group can decide who may address an agent.+ * Taking it out needs only write access to the room.+ */+ administersWorkspace: boolean;}) {const queryClient = useQueryClient();const [accessState, setAccessState] = useState<WriteState>({ phase: 'idle' });const [groupState, setGroupState] = useState<WriteState>({ phase: 'idle' });+ const picksGroup = permissions.canWrite && administersWorkspace;const groups = useQuery({queryKey: ['room-groups', workspaceId],queryFn: () => rpc.workspaces.listRoomGroups(workspaceId),- enabled: permissions.canWrite,+ enabled: picksGroup,});+ // The server names the room's group; one it does not name is still a group.+ const groupText = room.groupName ?? (room.groupId ? 'A group not in your list' : 'No group');+ const setGroup = (groupId: string | null) =>+ void write(+ setGroupState,+ () => rpc.workspaces.setRoomGroup({ workspaceId, roomId: room.id, groupId }),+ groupId === null+ ? 'Could not take the room out of its group.'+ : 'Could not change the room’s group.'+ );const access = roomAccessOf(room.readVisibility, room.writeVisibility);async function write(@@ -148,21 +166,17 @@ export const AccessAndGroupFields = observer(function AccessAndGroupFields({<div className="flex flex-col gap-1.5"><span className="text-sm text-foreground-muted">Group</span>- {permissions.canWrite ? (+ {picksGroup ? (<Selectvalue={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.'- );+ setGroup(groupId);}}><SelectTrigger className="w-full" aria-label="Group">- <SelectValue>{room.groupName ?? 'No group'}</SelectValue>+ <SelectValue>{groupText}</SelectValue></SelectTrigger><SelectContent><SelectItem value={NO_GROUP}>No group</SelectItem>@@ -174,12 +188,26 @@ export const AccessAndGroupFields = observer(function AccessAndGroupFields({</SelectContent></Select>) : (- <span className="text-sm text-foreground">{room.groupName ?? 'No group'}</span>+ <span className="flex min-h-8 items-center gap-2 text-sm text-foreground">+ {groupText}+ {permissions.canWrite && room.groupId !== null && (+ <Button+ size="xs"+ variant="outline"+ disabled={groupState.phase === 'saving'}+ onClick={() => setGroup(null)}+ >+ Remove from group+ </Button>+ )}+ </span>)}<span className="min-h-4 text-xs text-foreground-muted">{groupState.phase === 'idle' ? (groups.isError ? (failureText(groups.error, 'Could not list the groups.')+ ) : permissions.canWrite && !administersWorkspace ? (+ 'A workspace admin puts rooms in groups, since a group can decide who may talk to an agent.') : ('Groups organise rooms and can scope who may talk to an agent.')diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-admin.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-admin.tsindex 0d7e17077..8063a04ed 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-admin.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-admin.ts@@ -20,3 +20,14 @@ export function administersWorkspaceInScope(serverId: string): boolean {const workspace = workspacesStore.onServerInScope(serverId);return workspace !== null && administersWorkspace(workspace);}++/**+ * Whether the signed-in account may manage the workspace `workspaceId` names:+ * an owner or admin of it, or the operator running its server.+ */+export function administersWorkspaceById(workspaceId: string): boolean {+ const serverId = workspacesStore.serverIdFor(workspaceId);+ if (serverId !== null && operatesServer(serverId)) return true;+ const workspace = workspacesStore.workspaces.find((each) => each.id === workspaceId) ?? null;+ return workspace !== null && administersWorkspace(workspace);+}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.tsxindex a064252a1..ebe5e90fd 100644--- 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.tsx@@ -12,6 +12,8 @@ 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 } }));+const admin = vi.hoisted(() => ({ value: true }));+const setRoomGroup = vi.hoisted(() => vi.fn());vi.hoisted(() => {window.electronAPI ??= {@@ -34,7 +36,8 @@ vi.mock('@renderer/lib/ipc', () => ({listAgents: vi.fn(() =>Promise.resolve([{ id: 'a-1', name: 'reviewer-bot', iconUrl: null, knownAgentType: null }])),- listRoomGroups: vi.fn(() => Promise.resolve([])),+ listRoomGroups: vi.fn(() => Promise.resolve([{ id: 'g-1', name: 'Design' }])),+ setRoomGroup,},agents: { getAgents: vi.fn(() => Promise.resolve([])) },},@@ -55,6 +58,12 @@ vi.mock('@renderer/features/sidebar/sidebar-tree-data', () => ({refreshSidebarRoomStateAfterOnboarding: vi.fn(),}));+vi.mock('@renderer/features/switch-servers/workspace-admin', () => ({+ administersWorkspaceById: () => admin.value,+ administersWorkspaceInScope: () => admin.value,+ operatesServer: () => false,+}));+vi.mock('@renderer/lib/hooks/useFeatureFlags', () => ({ useFeatureFlags: () => ({}) }));vi.mock('@renderer/features/managed-agents/use-managed-agents', () => ({useManagedAgents: () => ({ data: [] }),@@ -119,6 +128,11 @@ beforeEach(() => {Promise.resolve({ ...ROOM, archived: params.archived }));permissions.value = { canWrite: true, canManage: true };+ admin.value = true;+ setRoomGroup.mockReset();+ setRoomGroup.mockImplementation(() =>+ Promise.resolve({ ...ROOM, groupId: null, groupName: null })+ );});afterEach(async () => {@@ -268,6 +282,36 @@ describe('room settings for someone who may write to the room', () => {});});+describe('putting a room in a group', () => {+ it('offers the group picker to a workspace admin', async () => {+ const el = await renderPanel();+ expect(el.querySelector('[aria-label="Group"]')).not.toBeNull();+ });++ it('shows anyone else who may change the room its group, and lets them take it out', async () => {+ admin.value = false;+ permissions.value = { canWrite: true, canManage: false };+ getRoomDetail.mockResolvedValue({ ...ROOM, groupId: 'g-1', groupName: 'Design' });+ const el = await renderPanel();+ expect(el.querySelector('[aria-label="Group"]')).toBeNull();+ expect(el.textContent).toContain('Design');+ expect(el.textContent).toContain('A workspace admin puts rooms in groups');+ await click(button(el, /^Remove from group$/)!);+ expect(setRoomGroup).toHaveBeenCalledWith({+ workspaceId: 'ws-1',+ roomId: 'room-1',+ groupId: null,+ });+ });++ it('names a group the server does not, without offering to change it', async () => {+ admin.value = false;+ getRoomDetail.mockResolvedValue({ ...ROOM, groupId: 'g-9', groupName: null });+ const el = await renderPanel();+ expect(el.textContent).toContain('A group not in your list');+ });+});+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 };