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
New room: the channel as cards, always shown; More options says what it holds
Simon Flack86f2693cea2f
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 32ed6e424..aa2192b42 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@@ -34,8 +34,9 @@ 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 { CreateRoomOptions } from './create-room-options';+import { CreateRoomOptions, RoomChannelField } from './create-room-options';import { MessagingAppSelector, SWITCH_CONSOLE } from './messaging-app-selector';+import { optionsForBridge } from './room-channel-choices';import {CreateRequestIds,canCreate,@@ -167,6 +168,9 @@ export const CreateRoomModal = observer(function CreateRoomModal({if (dropsStartingAgent(startChip, next)) setStartDropped(true);setPicked(next);};+ // A choice the chosen app does not offer (a private channel on Teams, say)+ // falls back to a new public channel rather than being sent and refused.+ const roomOptions = optionsForBridge(options, selectedBridge);const agentIds = shownPicked.filter((each) => each.kind === 'agent').map((each) => each.id);const memberUserIds = shownPicked.filter((each) => each.kind === 'person').map((each) => each.id);@@ -189,7 +193,7 @@ export const CreateRoomModal = observer(function CreateRoomModal({startingAgentState !== 'pending' &&!nowhere &&canCreate({ name }) &&- (selectedBridge === null || roomOptionsReady(options)) &&+ (selectedBridge === null || roomOptionsReady(roomOptions)) &&!isSubmitting;async function handleSubmit() {@@ -210,7 +214,7 @@ export const CreateRoomModal = observer(function CreateRoomModal({agentIds,memberUserIds,requestId: requestIds.for({ bridgeId, name, agentIds, memberUserIds }),- options,+ options: roomOptions,});if (request.kind === 'chat') {const chat = await rpc.chats.create(request.params);@@ -286,9 +290,9 @@ export const CreateRoomModal = observer(function CreateRoomModal({/>{/* What the name becomes, where it becomes it: a bridged room is achannel of the same name in its app. */}- {trimmedName !== '' && selectedBridge && options.channel.kind === 'new' && (+ {trimmedName !== '' && selectedBridge && roomOptions.channel.kind === 'new' && (<span className="text-xs text-foreground-muted">- {`Created as ${options.channel.private ? 'private ' : ''}#${trimmedName} in ${selectedBridge.displayName}.`}+ {`Created as ${roomOptions.channel.private ? 'private ' : ''}#${trimmedName} in ${selectedBridge.displayName}.`}</span>)}</Field>@@ -325,6 +329,18 @@ export const CreateRoomModal = observer(function CreateRoomModal({)}</Field>+ {/* Where a bridged room lives is decided now: Console cannot move it later. */}+ {selectedBridge && (+ <RoomChannelField+ bridge={selectedBridge}+ value={roomOptions}+ onChange={(next) => {+ setOptions(next);+ setError(null);+ }}+ />+ )}+{/* A bridged room's own settings; a Switch Console room has none to start with. */}{selectedBridge && (<>@@ -352,8 +368,7 @@ export const CreateRoomModal = observer(function CreateRoomModal({</Field><CreateRoomOptionsworkspaceId={workspaceId}- bridge={selectedBridge}- value={options}+ value={roomOptions}onChange={(next) => {setOptions(next);setError(null);diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-options.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-options.tsxindex 980d9abc4..abb2f324e 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-options.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/create-room-options.tsx@@ -6,7 +6,6 @@ import { rpc } from '@renderer/lib/ipc';import { DisclosureRow } from '@renderer/lib/ui/disclosure-row';import { Field, FieldLabel } from '@renderer/lib/ui/field';import { Input } from '@renderer/lib/ui/input';-import { SegmentedControl } from '@renderer/lib/ui/segmented-control';import {Select,SelectContent,@@ -14,11 +13,11 @@ import {SelectTrigger,SelectValue,} from '@renderer/lib/ui/select';+import { cn } from '@renderer/utils/utils';import type { RemoteBridge, RoomAccess } from '@shared/core/switch-servers/switch-servers';+import { type ChannelChoice, channelChoiceCards } from './room-channel-choices';import type { RoomCreateOptions } from './room-create-request';-type ChannelChoice = 'public' | 'private' | 'existing';-const NO_GROUP = '__none__';const ACCESS_ORDER: RoomAccess[] = ['public', 'read_only', 'private'];@@ -29,23 +28,89 @@ function channelChoiceOf(options: RoomCreateOptions): ChannelChoice {}/**- * What a room on a messaging app can be made with beyond its name: its- * channel, its group and who may see and change it. Shut until opened, so the- * plain path stays short; each choice starts where the server would leave it- * — a new public channel, no group, open to the workspace.- *- * Channel type and access stay separate: one is the platform's, the other- * Switch's, and choosing a private channel does not change who may see the- * room in Switch.+ * Where a room on a messaging app lives: a new public channel (the default),+ * a new private one, or a channel already there. Always shown, as cards each+ * saying what the choice means on this platform, because Console cannot move+ * a room to another channel afterwards.+ */+export function RoomChannelField({+ bridge,+ value,+ onChange,+}: {+ bridge: RemoteBridge;+ value: RoomCreateOptions;+ onChange: (next: RoomCreateOptions) => void;+}) {+ const cards = channelChoiceCards(bridge);+ const choice = channelChoiceOf(value);+ return (+ <Field>+ <FieldLabel>Channel in {bridge.displayName}</FieldLabel>+ <div+ role="radiogroup"+ aria-label={`Channel in ${bridge.displayName}`}+ className={cn('grid gap-2', cards.length === 3 ? 'grid-cols-3' : 'grid-cols-2')}+ >+ {cards.map((card) => (+ <button+ key={card.value}+ type="button"+ role="radio"+ aria-checked={choice === card.value}+ onClick={() =>+ onChange({+ ...value,+ channel:+ card.value === 'existing'+ ? { kind: 'existing', externalChannelId: '' }+ : { kind: 'new', private: card.value === 'private' },+ })+ }+ className={cn(+ 'space-y-0.5 rounded-md border p-2.5 text-left',+ choice === card.value+ ? 'border-primary bg-background-tertiary-2'+ : 'border-border hover:bg-background-tertiary-2'+ )}+ >+ <span className="block text-sm font-medium text-foreground">{card.title}</span>+ <span className="block text-xs text-foreground-muted">{card.detail}</span>+ </button>+ ))}+ </div>+ {value.channel.kind === 'existing' && (+ <Input+ aria-label="Channel id"+ placeholder="The channel’s id"+ value={value.channel.externalChannelId}+ onChange={(event) =>+ onChange({+ ...value,+ channel: { kind: 'existing', externalChannelId: event.target.value },+ })+ }+ />+ )}+ <span className="text-xs text-foreground-muted">+ Console can’t move a room to another channel later.+ </span>+ </Field>+ );+}++/**+ * What a room can be made with that is easy to change afterwards, in its+ * Configuration tab: its group and who may see and change it. Shut until+ * opened, its row saying what each is set to so the defaults are never a+ * surprise — no group, open to the workspace.*/export function CreateRoomOptions({workspaceId,- bridge,value,onChange,}: {workspaceId: string | null;- bridge: RemoteBridge;value: RoomCreateOptions;onChange: (next: RoomCreateOptions) => void;}) {@@ -53,67 +118,21 @@ export function CreateRoomOptions({const groups = useQuery({queryKey: ['room-groups', workspaceId],queryFn: () => rpc.workspaces.listRoomGroups(workspaceId as string),- enabled: workspaceId !== null && open,+ enabled: workspaceId !== null,});- // A connection shared between organisations cannot be pointed at a channel- // by its id: the app says how to add one instead.- const existingOffered = bridge.channelIdsRefused === null;- const choice = channelChoiceOf(value);const groupName = (groups.data ?? []).find((group) => group.id === value.groupId)?.name;-- const channelOptions = [- { value: 'public' as const, label: 'New public' },- { value: 'private' as const, label: 'New private' },- ...(existingOffered ? [{ value: 'existing' as const, label: 'Existing' }] : []),- ];+ const access = value.access ?? 'public';return (<div className="flex flex-col gap-4">- <DisclosureRow open={open} title="More options" onToggle={() => setOpen(!open)} />+ <DisclosureRow+ open={open}+ title="More options"+ summary={`Group: ${groupName ?? 'none'} · ${ACCESS_LABELS[access]}`}+ onToggle={() => setOpen(!open)}+ />{open && (<>- <Field>- <FieldLabel>Channel in {bridge.displayName}</FieldLabel>- <SegmentedControl- ariaLabel={`Channel in ${bridge.displayName}`}- value={choice}- options={channelOptions}- onChange={(next) =>- onChange({- ...value,- channel:- next === 'existing'- ? { kind: 'existing', externalChannelId: '' }- : { kind: 'new', private: next === 'private' },- })- }- />- {value.channel.kind === 'existing' ? (- <>- <Input- aria-label="Channel id"- placeholder="The channel’s id"- value={value.channel.externalChannelId}- onChange={(event) =>- onChange({- ...value,- channel: { kind: 'existing', externalChannelId: event.target.value },- })- }- />- <span className="text-xs text-foreground-muted">- The room uses this channel instead of making a new one.- </span>- </>- ) : (- <span className="text-xs text-foreground-muted">- {choice === 'private'- ? `A private channel in ${bridge.displayName}: only people added to it can see it.`- : `A public channel in ${bridge.displayName}: anyone there can find and join it.`}- </span>- )}- </Field>-<Field><FieldLabel>Group</FieldLabel><Select@@ -144,23 +163,24 @@ export function CreateRoomOptions({<Field><FieldLabel>Who can see and change it</FieldLabel><Select- value={value.access ?? 'public'}+ value={access}onValueChange={(next) => onChange({ ...value, access: next as RoomAccess })}><SelectTrigger className="w-full" aria-label="Who can see and change it">- <SelectValue>{ACCESS_LABELS[value.access ?? 'public']}</SelectValue>+ <SelectValue>{ACCESS_LABELS[access]}</SelectValue></SelectTrigger><SelectContent>- {ACCESS_ORDER.map((access) => (- <SelectItem key={access} value={access}>- {ACCESS_LABELS[access]}+ {ACCESS_ORDER.map((each) => (+ <SelectItem key={each} value={each}>+ {ACCESS_LABELS[each]}</SelectItem>))}</SelectContent></Select><span className="text-xs text-foreground-muted">Who can see the room in Switch and change its settings, members and resources. It does- not decide who can read or post in the channel.+ not decide who can read or post in the channel. Both can be changed later in the+ room’s Configuration.</span></Field></>diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.test.tsnew file mode 100644index 000000000..e4ed3473d--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.test.ts@@ -0,0 +1,62 @@+import { describe, expect, it } from 'vitest';+import { channelChoiceCards, optionsForBridge } from './room-channel-choices';+import { DEFAULT_ROOM_OPTIONS } from './room-create-request';++const bridge = (type: string, channelIdsRefused: string | null = null) => ({+ type,+ displayName: `Acme ${type}`,+ channelIdsRefused,+});++describe('the channel choices for a new room', () => {+ it('offers a public, a private and an existing channel, saying what each is on Slack', () => {+ const cards = channelChoiceCards(bridge('slack'));+ expect(cards.map((card) => card.value)).toEqual(['public', 'private', 'existing']);+ expect(cards[0]!.detail).toBe('Anyone in the Slack workspace can find and join it.');+ expect(cards[1]!.detail).toBe('Only people invited to it can see it.');+ expect(cards[2]!.detail).toBe('Use a channel already in Acme slack, by its id.');+ });++ it('says a Discord channel is read without joining, and a private one still shows to its admins', () => {+ const [publicCard, privateCard] = channelChoiceCards(bridge('discord'));+ expect(publicCard!.detail).toBe('Everyone in the server can see and read it.');+ expect(privateCard!.detail).toContain('the server’s admins');+ });++ it('leaves out a private channel on Teams, which Switch cannot make there', () => {+ expect(channelChoiceCards(bridge('teams')).map((card) => card.value)).toEqual([+ 'public',+ 'existing',+ ]);+ });++ it('leaves out an existing channel where the app cannot be pointed at one by id', () => {+ expect(+ channelChoiceCards(bridge('slack', 'Add the app to the channel.')).map((card) => card.value)+ ).toEqual(['public', 'private']);+ });++ it('promises nothing about a platform it does not know', () => {+ expect(channelChoiceCards(bridge('carrier-pigeon'))[0]!.detail).toBe(+ 'A public channel on this messaging app.'+ );+ });+});++describe('keeping the channel choice to what the app offers', () => {+ const privateChoice = {+ ...DEFAULT_ROOM_OPTIONS,+ channel: { kind: 'new' as const, private: true },+ };++ it('keeps a choice the app offers', () => {+ expect(optionsForBridge(privateChoice, bridge('slack'))).toBe(privateChoice);+ });++ it('falls back to a new public channel when the app does not offer the choice', () => {+ expect(optionsForBridge(privateChoice, bridge('teams')).channel).toEqual({+ kind: 'new',+ private: false,+ });+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.tsnew file mode 100644index 000000000..8ebab9bdc--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-channel-choices.ts@@ -0,0 +1,84 @@+import type { RemoteBridge } from '@shared/core/switch-servers/switch-servers';+import type { RoomCreateOptions } from './room-create-request';++export type ChannelChoice = 'public' | 'private' | 'existing';++export type ChannelChoiceCard = { value: ChannelChoice; title: string; detail: string };++/**+ * What a new public and a new private channel are on each platform, as its+ * adapter makes them. Worded per platform because they differ: a Discord+ * channel is read without joining it, and a private one there is hidden by+ * permission rather than by membership, so its server's admins still see it.+ *+ * `private` is null where Switch cannot make a private channel. On Teams an+ * app must name an owner when it creates one, and Switch does not, so the+ * choice is left out rather than offered and refused.+ */+const NEW_CHANNEL: Record<string, { public: string; private: string | null }> = {+ slack: {+ public: 'Anyone in the Slack workspace can find and join it.',+ private: 'Only people invited to it can see it.',+ },+ mattermost: {+ public: 'Anyone in the team can find and join it.',+ private: 'Only people added to it can see it.',+ },+ discord: {+ public: 'Everyone in the server can see and read it.',+ private: 'Hidden from everyone but the people given access and the server’s admins.',+ },+ teams: {+ public: 'A standard channel: everyone in the team can see it.',+ private: null,+ },+};++/** Any other platform: said without promising what its channels do. */+const OTHER = {+ public: 'A public channel on this messaging app.',+ private: 'A private channel on this messaging app.',+};++/**+ * The channel choices for a new room on `bridge`, each saying what it means+ * there: a new public channel first (the server's default), a new private one+ * where the platform has one Switch can make, and an existing channel where+ * the app lets a channel be named by its id.+ */+export function channelChoiceCards(+ bridge: Pick<RemoteBridge, 'type' | 'displayName' | 'channelIdsRefused'>+): ChannelChoiceCard[] {+ const known = NEW_CHANNEL[bridge.type] ?? OTHER;+ return [+ { value: 'public', title: 'New public channel', detail: known.public },+ ...(known.private !== null+ ? [{ value: 'private' as const, title: 'New private channel', detail: known.private }]+ : []),+ ...(bridge.channelIdsRefused === null+ ? [+ {+ value: 'existing' as const,+ title: 'Existing channel',+ detail: `Use a channel already in ${bridge.displayName}, by its id.`,+ },+ ]+ : []),+ ];+}++/** `options` with its channel choice kept only if `bridge` offers it. */+export function optionsForBridge(+ options: RoomCreateOptions,+ bridge: Pick<RemoteBridge, 'type' | 'displayName' | 'channelIdsRefused'> | null+): RoomCreateOptions {+ if (bridge === null) return options;+ const offered = new Set(channelChoiceCards(bridge).map((card) => card.value));+ const choice =+ options.channel.kind === 'existing'+ ? 'existing'+ : options.channel.private+ ? 'private'+ : 'public';+ return offered.has(choice) ? options : { ...options, channel: { kind: 'new', private: false } };+}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/create-room-options.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/create-room-options.test.tsxindex 972adfc2e..f4572132c 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/create-room-options.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/create-room-options.test.tsx@@ -1,7 +1,7 @@/**- * The New room dialog's More options for a room on a messaging app: shut at- * first, each choice starting where the server would leave it, and binding an- * existing channel only where the app allows it.+ * The New room dialog for a room on a messaging app: the channel choice, always+ * shown as cards, and More options for what is easy to change later — shut at+ * first, its row saying what each is set to.*/import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { act, useState } from 'react';@@ -22,13 +22,21 @@ vi.mock('@renderer/lib/ipc', () => ({rpc: { workspaces: { listRoomGroups: vi.fn(async () => [{ id: 'g1', name: 'Design' }]) } },}));-import { CreateRoomOptions } from '@renderer/features/switch-servers/create-room-options';+import {+ CreateRoomOptions,+ RoomChannelField,+} from '@renderer/features/switch-servers/create-room-options';import {DEFAULT_ROOM_OPTIONS,type RoomCreateOptions,} from '@renderer/features/switch-servers/room-create-request';-const BRIDGE = { id: 'b1', displayName: 'Acme Slack', channelIdsRefused: null } as RemoteBridge;+const BRIDGE = {+ id: 'b1',+ type: 'slack',+ displayName: 'Acme Slack',+ channelIdsRefused: null,+} as RemoteBridge;let container: HTMLDivElement | null = null;let root: Root | null = null;@@ -44,16 +52,15 @@ afterEach(async () => {function Harness({ bridge }: { bridge: RemoteBridge }) {const [value, setValue] = useState<RoomCreateOptions>(DEFAULT_ROOM_OPTIONS);+ const onChange = (next: RoomCreateOptions) => {+ latest = next;+ setValue(next);+ };return (- <CreateRoomOptions- workspaceId="ws-1"- bridge={bridge}- value={value}- onChange={(next) => {- latest = next;- setValue(next);- }}- />+ <>+ <RoomChannelField bridge={bridge} value={value} onChange={onChange} />+ <CreateRoomOptions workspaceId="ws-1" value={value} onChange={onChange} />+ </>);}@@ -72,47 +79,56 @@ async function render(bridge: RemoteBridge = BRIDGE): Promise<HTMLDivElement> {return container;}-function button(el: HTMLElement, text: string): HTMLButtonElement | undefined {- return [...el.querySelectorAll<HTMLButtonElement>('button')].find(- (b) => b.textContent?.trim() === text- );-}-async function click(target: HTMLElement) {await act(async () => target.click());for (let i = 0; i < 4; i++) await act(async () => await Promise.resolve());}-describe('More options when creating a room on a messaging app', () => {- it('starts shut, and opens on a new public channel open to the workspace', async () => {+function radio(el: HTMLElement, title: string): HTMLButtonElement | undefined {+ return [...el.querySelectorAll<HTMLButtonElement>('[role="radio"]')].find((b) =>+ b.textContent?.startsWith(title)+ );+}++describe('creating a room on a messaging app', () => {+ it('shows the channel choice as cards, a new public channel picked', async () => {const el = await render();- expect(el.textContent).not.toContain('Channel in Acme Slack');- await click(button(el, 'More options')!);- expect(el.textContent).toContain('Channel in Acme Slack');- expect(el.textContent).toContain('A public channel in Acme Slack');- expect(el.textContent).toContain('Everyone in the workspace can see and change it');+ expect(radio(el, 'New public channel')!.getAttribute('aria-checked')).toBe('true');+ expect(el.textContent).toContain('Anyone in the Slack workspace can find and join it.');+ expect(el.textContent).toContain('Console can’t move a room to another channel later.');});- it('asks for a private channel without changing who can see the room in Switch', async () => {+ it('says what More options holds while shut: no group, open to the workspace', async () => {const el = await render();- await click(button(el, 'More options')!);- await click(button(el, 'New private')!);+ expect(el.textContent).toContain(+ 'Group: none · Everyone in the workspace can see and change it'+ );+ expect(el.querySelector('[aria-label="Group"]')).toBeNull();+ });++ it('picks a private channel without changing who can see the room in Switch', async () => {+ const el = await render();+ await click(radio(el, 'New private channel')!);expect(latest.channel).toEqual({ kind: 'new', private: true });expect(latest.access).toBeNull();- expect(el.textContent).toContain('only people added to it can see it');});it('takes an existing channel by its id', async () => {const el = await render();- await click(button(el, 'More options')!);- await click(button(el, 'Existing')!);+ await click(radio(el, 'Existing channel')!);expect(el.querySelector('input[aria-label="Channel id"]')).not.toBeNull();expect(latest.channel).toEqual({ kind: 'existing', externalChannelId: '' });});it('offers no existing channel where the app cannot be pointed at one by id', async () => {const el = await render({ ...BRIDGE, channelIdsRefused: 'Add the app to the channel.' });- await click(button(el, 'More options')!);- expect(button(el, 'Existing')).toBeUndefined();+ expect(radio(el, 'Existing channel')).toBeUndefined();+ });++ it('opens More options on the group and access', async () => {+ const el = await render();+ await click(el.querySelector<HTMLButtonElement>('button[aria-expanded]')!);+ expect(el.querySelector('[aria-label="Group"]')).not.toBeNull();+ expect(el.querySelector('[aria-label="Who can see and change it"]')).not.toBeNull();});});