Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Give the room page a side panel, and settings a page of their own

Simon Flack6110bfe17acb
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.test.ts
new file mode 100644
index 000000000..ba8dc10ed
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, it } from 'vitest';
+import { roomAgentPresence } from './room-agent-presence';
+
+describe('roomAgentPresence', () => {
+ it('names each presence the server reports', () => {
+ expect(roomAgentPresence('live')).toEqual({ label: 'Here now', tone: 'live' });
+ expect(roomAgentPresence('awaiting_manual_poll')).toEqual({ label: 'Idle', tone: 'idle' });
+ expect(roomAgentPresence('disconnected')).toEqual({ label: 'Disconnected', tone: 'off' });
+ expect(roomAgentPresence('no_session')).toEqual({ label: 'No session', tone: 'off' });
+ });
+
+ it('does not guess at a presence it does not know', () => {
+ expect(roomAgentPresence(undefined)).toEqual({ label: 'Status unknown', tone: 'off' });
+ expect(roomAgentPresence('something_new')).toEqual({ label: 'Status unknown', tone: 'off' });
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.ts
new file mode 100644
index 000000000..da451ba40
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-agent-presence.ts
@@ -0,0 +1,18 @@
+/** How an agent's presence in a room reads, and the colour of its dot. */
+export function roomAgentPresence(status: string | undefined): {
+ label: string;
+ tone: 'live' | 'idle' | 'off';
+} {
+ switch (status) {
+ case 'live':
+ return { label: 'Here now', tone: 'live' };
+ case 'awaiting_manual_poll':
+ return { label: 'Idle', tone: 'idle' };
+ case 'disconnected':
+ return { label: 'Disconnected', tone: 'off' };
+ case 'no_session':
+ return { label: 'No session', tone: 'off' };
+ default:
+ return { label: 'Status unknown', tone: 'off' };
+ }
+}
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.tsx
index 3cdf2a5fb..be3771938 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
@@ -56,7 +56,7 @@ import { openRoomChannel } from './room-links';
/** Query key for one room's own settings — shared so a save can write the
* server's answer straight back into what the page is reading. */
-function roomDetailKey(workspaceId: string, roomId: string) {
+export function roomDetailKey(workspaceId: string, roomId: string) {
return ['remote-room-detail', workspaceId, roomId] as const;
}
@@ -939,7 +939,7 @@ const ParticipantList = observer(function ParticipantList({
});
/** A person's initials disc: people have no picture in Switch. */
-function PersonMark({ name, size }: { name: string; size: 'sm' | 'md' }) {
+export function PersonMark({ name, size }: { name: string; size: 'sm' | 'md' }) {
return (
<span
className={cn(
@@ -1183,7 +1183,7 @@ function PanelNotice({
}
/** An agent's own picture, beside the human participants' initials discs. */
-function AgentMark({
+export function AgentMark({
agentId,
workspaceId,
remoteById,
@@ -1215,7 +1215,7 @@ function localAgentFor(switchAgentId: string, workspaceId: string | null) {
);
}
-function agentNameFor(
+export function agentNameFor(
switchAgentId: string,
workspaceId: string | null,
remoteById: Map<string, RemoteAgentSummary>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-layer.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-layer.tsx
index 5c0f7f04b..64f4b99a0 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-layer.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-layer.tsx
@@ -234,8 +234,10 @@ export const RoomEmbedLayer = observer(function RoomEmbedLayer() {
(slot ? slotBox !== null : isRoomView) &&
activeRoomId !== null &&
!consoleChat &&
- roomTabStore.tabFor(activeRoomId, slot ? embeddedRoomFallbackTab(activeRoomId) : 'chat') ===
- 'chat';
+ roomTabStore.tabFor(
+ activeRoomId,
+ slot ? (slot.fallback ?? embeddedRoomFallbackTab(activeRoomId)) : 'chat'
+ ) === 'chat';
const active = activeState;
return (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-slot.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-slot.ts
index 28cebb018..f5b740c9e 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-slot.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-embed-slot.ts
@@ -1,7 +1,13 @@
import { makeAutoObservable, observable } from 'mobx';
+import type { RoomTab } from './room-tab-store';
-/** A box on a page other than the room view where a room's conversation is drawn. */
-export type RoomEmbedSlot = { roomId: string; element: HTMLElement };
+/**
+ * A box where a room's conversation is drawn: on a page other than the room
+ * view, or the part of the room view beside its side panel. `fallback` is the
+ * tab the box's page opens on until one is picked; without it, the box opens on
+ * the conversation only when its platform can be drawn inline.
+ */
+export type RoomEmbedSlot = { roomId: string; element: HTMLElement; fallback?: RoomTab };
/**
* Where `RoomEmbedLayer` draws a room when a page shows one inside itself, as
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-side-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-side-panel.tsx
new file mode 100644
index 000000000..55e1786d2
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-side-panel.tsx
@@ -0,0 +1,223 @@
+import { useQuery } from '@tanstack/react-query';
+import { ChevronDown, ChevronRight, Settings } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { type ReactNode, useState } from 'react';
+import { chatMembersQueryKey } from '@renderer/features/chats/chat-people';
+import { opensAsConsoleChat } from '@renderer/features/chats/console-chat-redirect';
+import { chatsStore } from '@renderer/features/chats/stores/chats';
+import { useManagedAgents } from '@renderer/features/managed-agents/use-managed-agents';
+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
+import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';
+import { rpc } from '@renderer/lib/ipc';
+import { useNavigate } from '@renderer/lib/layout/navigation-provider';
+import { useWorkspaceAgents } from '@renderer/lib/stores/use-workspace-agents';
+import { Button } from '@renderer/lib/ui/button';
+import { cn } from '@renderer/utils/utils';
+import { chatAgentLabel } from '@shared/core/chats/chats';
+import { roomAgentPresence } from './room-agent-presence';
+import { AgentMark, agentNameFor, PersonMark, roomDetailKey } from './room-configuration-panel';
+import { roomTabStore } from './room-tab-store';
+
+const TONE_CLASS = {
+ live: 'bg-foreground-success',
+ idle: 'bg-foreground-warning',
+ off: 'bg-[var(--fg-passive)]',
+} as const;
+
+/**
+ * The room's own column, beside its conversation: a way into its settings, and
+ * what is in the room that the conversation does not already show — who the
+ * agents are and what each is doing here, and who the people are.
+ *
+ * Nothing here is a setting. Settings live behind the button, on a page of their
+ * own, so the column never repeats them; the room's name and description are in
+ * the title bar above, so it does not repeat those either.
+ */
+export const RoomSidePanel = observer(function RoomSidePanel({ roomId }: { roomId: string }) {
+ const chat = chatsStore.chat(roomId);
+ const consoleChat = opensAsConsoleChat(roomId);
+ const workspaceId =
+ switchRoomsStore.roomWorkspaceId(roomId) ?? (chat ? workspacesStore.activeId : null);
+ const serverId =
+ switchRoomsStore.roomServerId(roomId) ?? (chat ? chatsStore.serverId : null) ?? null;
+ // Anyone taking part may read the room, so this answers for a chat's members too.
+ const detail = useQuery({
+ queryKey: roomDetailKey(workspaceId ?? '', roomId),
+ queryFn: () => rpc.workspaces.getRoomDetail({ workspaceId: workspaceId as string, roomId }),
+ enabled: workspaceId !== null,
+ });
+ const members = useQuery({
+ queryKey: chat && serverId ? chatMembersQueryKey(serverId, chat) : ['no-chat-members'],
+ queryFn: () => rpc.chats.members(serverId as string, roomId),
+ enabled: consoleChat && chat !== null && serverId !== null,
+ });
+
+ const room = detail.data ?? null;
+ const agentIds = chat ? chat.agents.map((agent) => agent.id) : (room?.agentIds ?? []);
+ const chatNames = new Map((chat?.agents ?? []).map((agent) => [agent.id, chatAgentLabel(agent)]));
+ const people = consoleChat
+ ? (members.data ?? []).map((member) => ({
+ key: member.userId,
+ name: member.name,
+ detail: member.isOwner ? 'owner' : null,
+ }))
+ : (room?.connectedUserNames ?? []).map((name) => ({ key: name, name, detail: null }));
+
+ return (
+ <aside
+ aria-label="Room"
+ className="flex w-[260px] shrink-0 flex-col gap-3 overflow-y-auto border-r border-border p-2"
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ className="w-full justify-center"
+ onClick={() => roomTabStore.setTab(roomId, 'configuration')}
+ >
+ <Settings className="size-3.5" />
+ Room settings
+ </Button>
+
+ <Fold title="Agents" count={agentIds.length}>
+ {agentIds.length === 0 ? (
+ <Note>No agents in this room yet.</Note>
+ ) : (
+ agentIds.map((agentId) => (
+ <AgentRow
+ key={agentId}
+ agentId={agentId}
+ roomId={roomId}
+ workspaceId={workspaceId}
+ serverId={serverId}
+ name={chatNames.get(agentId) ?? null}
+ status={room?.agentStatuses[agentId]}
+ roles={room?.roles ?? []}
+ />
+ ))
+ )}
+ </Fold>
+
+ <Fold title={consoleChat ? 'People' : 'People seen here'} count={people.length}>
+ {people.length === 0 ? (
+ <Note>{consoleChat ? 'Nobody else is here yet.' : 'Nobody has been seen here yet.'}</Note>
+ ) : (
+ people.map((person) => (
+ <div key={person.key} className="flex items-center gap-2 rounded-md px-2 py-1">
+ <PersonMark name={person.name} size="sm" />
+ <span className="min-w-0 flex-1 truncate text-[13px] text-foreground">
+ {person.name}
+ </span>
+ {person.detail && (
+ <span className="shrink-0 text-xs text-foreground-muted">{person.detail}</span>
+ )}
+ </div>
+ ))
+ )}
+ {!consoleChat && (
+ // Switch only knows the people who posted here or were added through it.
+ <Note>
+ People who posted here or were added through Switch. The channel may have more.
+ </Note>
+ )}
+ </Fold>
+ </aside>
+ );
+});
+
+/**
+ * One agent in the room: its name, what it is doing here and the role it holds.
+ * The viewer's own agents open their seat in this room on the agent's page;
+ * anyone else's are listed only.
+ */
+const AgentRow = observer(function AgentRow({
+ agentId,
+ roomId,
+ workspaceId,
+ serverId,
+ name,
+ status,
+ roles,
+}: {
+ agentId: string;
+ roomId: string;
+ workspaceId: string | null;
+ serverId: string | null;
+ name: string | null;
+ status: string | undefined;
+ /** The room's roles; the one this agent holds is shown beside its status. */
+ roles: { name: string; heldBy: string[] }[];
+}) {
+ const { navigate } = useNavigate();
+ const remoteAgents = useWorkspaceAgents(workspaceId);
+ const remoteById = new Map((remoteAgents.data ?? []).map((agent) => [agent.id, agent]));
+ const managed = useManagedAgents(serverId);
+ const own = (managed.data ?? []).find((agent) => agent.agentId === agentId) ?? null;
+ const label = name ?? agentNameFor(agentId, workspaceId, remoteById);
+ // Roles name their holders by agent name, which is how the server reports them.
+ const role = roles.find((each) => each.heldBy.includes(label));
+ const presence = roomAgentPresence(status);
+ const detail = [status === undefined ? null : presence.label, role?.name ?? null]
+ .filter(Boolean)
+ .join(' · ');
+
+ const body = (
+ <>
+ <span className="relative flex shrink-0">
+ <AgentMark agentId={agentId} workspaceId={workspaceId} remoteById={remoteById} />
+ {status !== undefined && (
+ <span
+ aria-hidden
+ className={cn(
+ 'absolute -right-0.5 -bottom-0.5 size-2 rounded-full ring-2 ring-background',
+ TONE_CLASS[presence.tone]
+ )}
+ />
+ )}
+ </span>
+ <span className="flex min-w-0 flex-1 flex-col">
+ <span className="truncate text-[13px] text-foreground">{label}</span>
+ {detail && <span className="truncate text-xs text-foreground-muted">{detail}</span>}
+ </span>
+ </>
+ );
+
+ if (own && serverId) {
+ return (
+ <button
+ type="button"
+ title={`Open ${label}’s session in this room`}
+ className="flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-[var(--sel-soft)]"
+ onClick={() =>
+ navigate('managedAgent', { serverId, agentId, name: own.name, room: roomId })
+ }
+ >
+ {body}
+ </button>
+ );
+ }
+ return <div className="flex items-center gap-2 rounded-md px-2 py-1">{body}</div>;
+});
+
+function Fold({ title, count, children }: { title: string; count: number; children: ReactNode }) {
+ const [open, setOpen] = useState(true);
+ const Chevron = open ? ChevronDown : ChevronRight;
+ return (
+ <section aria-label={title} className="flex flex-col gap-[2px]">
+ <button
+ type="button"
+ aria-expanded={open}
+ onClick={() => setOpen(!open)}
+ className="flex items-center gap-1 px-1 pb-1 text-xs font-medium text-foreground-muted hover:text-foreground"
+ >
+ <Chevron className="size-3.5" />
+ <span className="flex-1 text-left">{title}</span>
+ <span className="text-[var(--fg-passive)] tabular-nums">{count}</span>
+ </button>
+ {open && children}
+ </section>
+ );
+}
+
+const Note = ({ children }: { children: ReactNode }) => (
+ <p className="px-2 py-1 text-xs text-foreground-muted">{children}</p>
+);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
index 5751213a7..b0fee3d1a 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
@@ -1,4 +1,4 @@
-import { DoorOpen, ExternalLink } from 'lucide-react';
+import { ArrowLeft, DoorOpen, ExternalLink } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useLayoutEffect, useRef } from 'react';
import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
@@ -20,6 +20,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/toolti
import { RoomConfigurationPanel } from './room-configuration-panel';
import { roomEmbedSlotStore } from './room-embed-slot';
import { openRoomChannel } from './room-links';
+import { RoomSidePanel } from './room-side-panel';
import { embeddedRoomTab, type RoomTab, roomTabStore } from './room-tab-store';
/**
@@ -95,15 +96,19 @@ export const RoomTabs = observer(function RoomTabs({
* agent in it, and picking one of those to stand in front of it would be a
* claim about how you got here rather than about where you are.
*
- * The two sides of a room sit next to its name rather than in a sidebar or a
- * menu: there are only two, and which one you are on is the first thing you
- * need to know about the page under it.
+ * Beside the name: where the room lives (its messaging app, or a group chat
+ * here) and what it is for. Its settings are a page of their own, reached from
+ * the room's side panel, and the title bar says when that page is showing.
*/
const RoomTitlebar = observer(function RoomTitlebar() {
const { params } = useParams('room');
- const name =
- switchRoomsStore.roomNameById(params.roomId) ?? chatsStore.chat(params.roomId)?.name ?? null;
- const bridgeType = switchRoomsStore.roomBridgeTypeById(params.roomId);
+ const roomId = params.roomId;
+ const summary = switchRoomsStore.roomSummaryById(roomId);
+ const name = switchRoomsStore.roomNameById(roomId) ?? chatsStore.chat(roomId)?.name ?? null;
+ const bridgeType = switchRoomsStore.roomBridgeTypeById(roomId);
+ const settings = roomTabStore.tabFor(roomId, 'chat') === 'configuration';
+ const where = summary?.bridgeDisplayName ?? (opensAsConsoleChat(roomId) ? 'Group chat' : null);
+ const description = summary?.description.trim() || null;
return (
<Titlebar
@@ -119,15 +124,26 @@ const RoomTitlebar = observer(function RoomTitlebar() {
<DoorOpen className="size-3.5 shrink-0" />
),
label: name ?? 'Room',
+ onClick: settings ? () => roomTabStore.setTab(roomId, 'chat') : undefined,
},
+ ...(settings ? [{ key: 'settings', label: 'Room settings' }] : []),
]}
/>
- <RoomTabs roomId={params.roomId} fallback="chat" />
+ {!settings && where && (
+ <span className="shrink-0 rounded-full bg-background-tertiary px-2 py-0.5 text-[11px] text-foreground-muted">
+ {where}
+ </span>
+ )}
+ {!settings && description && (
+ <span className="min-w-0 truncate text-sm text-foreground-muted" title={description}>
+ {description}
+ </span>
+ )}
</div>
}
rightSlot={
<div className="mr-2 flex items-center gap-1">
- <OpenInMessagingApp roomId={params.roomId} />
+ <OpenInMessagingApp roomId={roomId} />
</div>
}
/>
@@ -141,23 +157,61 @@ const ConsoleChat = observer(function ConsoleChat({ roomId }: { roomId: string }
return <ChatPanel key={`${serverId}:${roomId}`} serverId={serverId} roomId={roomId} />;
});
-/** Settings when the room is showing them; otherwise a Console chat's
- * conversation, or nothing, and the conversation drawn by `RoomEmbedLayer`
- * above shows through. */
+/**
+ * The room's page: its side panel and its conversation, or — once Room
+ * settings is picked — its settings across the whole page, with a way back.
+ * Settings replace the page rather than sit beside the panel, so there is only
+ * ever one column of the room's own beside the app's sidebar.
+ */
const RoomMainPanel = observer(function RoomMainPanel(): React.JSX.Element {
const { params } = useParams('room');
+ const roomId = params.roomId;
return (
<>
- <ConsoleChatRedirect roomId={params.roomId} />
- {roomTabStore.tabFor(params.roomId, 'chat') === 'configuration' ? (
- <RoomConfigurationPanel roomId={params.roomId} />
+ <ConsoleChatRedirect roomId={roomId} />
+ {roomTabStore.tabFor(roomId, 'chat') === 'configuration' ? (
+ <div className="flex h-full min-h-0 flex-col">
+ <div className="px-6 pt-3">
+ <Button variant="outline" size="sm" onClick={() => roomTabStore.setTab(roomId, 'chat')}>
+ <ArrowLeft className="size-3.5" />
+ Back to room
+ </Button>
+ </div>
+ <div className="min-h-0 flex-1">
+ <RoomConfigurationPanel roomId={roomId} />
+ </div>
+ </div>
) : (
- <ConsoleChat roomId={params.roomId} />
+ <div className="flex h-full min-h-0">
+ <RoomSidePanel roomId={roomId} />
+ <RoomConversation roomId={roomId} />
+ </div>
)}
</>
);
});
+/**
+ * The room's conversation beside its side panel: a Console chat drawn here, or
+ * a box that `RoomEmbedLayer` lays the messaging app's conversation over —
+ * the app itself where it can be drawn inline, otherwise its way out to it.
+ */
+const RoomConversation = observer(function RoomConversation({ roomId }: { roomId: string }) {
+ const ref = useRef<HTMLDivElement>(null);
+ const consoleChat = opensAsConsoleChat(roomId);
+ useLayoutEffect(() => {
+ const element = ref.current;
+ if (!element || consoleChat) return;
+ roomEmbedSlotStore.claim({ roomId, element, fallback: 'chat' });
+ return () => roomEmbedSlotStore.release(element);
+ }, [roomId, consoleChat]);
+ return (
+ <div ref={ref} data-testid="room-conversation" className="flex min-w-0 flex-1 flex-col">
+ {consoleChat && <ConsoleChat roomId={roomId} />}
+ </div>
+ );
+});
+
/** The side a room shown inside another page opens on, until one is picked. */
export function embeddedRoomFallbackTab(roomId: string): RoomTab {
return embeddedRoomTab(switchRoomsStore.roomBridgeTypeById(roomId));