Skip to content

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

Rooms: one table, Mine or All rooms; list pages share a filter row

Simon Flack45ccc3608459
diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts
index b9de8d48f..d138db720 100644
--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts
+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts
@@ -3310,6 +3310,11 @@ type RoomSummaryJson = {
can_write?: boolean;
can_manage?: boolean;
can_unlink?: boolean;
+ group_id?: string | null;
+ group_name?: string | null;
+ owner_name?: string | null;
+ read_visibility?: string;
+ connected_user_count?: number;
};
function mapRoomSummary(r: RoomSummaryJson): RemoteRoomSummary {
@@ -3329,6 +3334,10 @@ function mapRoomSummary(r: RoomSummaryJson): RemoteRoomSummary {
createdAt: r.created_at,
// The same reading as a room's detail, so the list and the room page offer the same changes.
writeVisibility: visibilityOf(r.write_visibility),
+ ...(r.read_visibility !== undefined ? { readVisibility: visibilityOf(r.read_visibility) } : {}),
+ ...(r.group_id !== undefined ? { groupId: r.group_id, groupName: r.group_name ?? null } : {}),
+ ...(r.owner_name !== undefined ? { ownerName: r.owner_name } : {}),
+ ...(r.connected_user_count !== undefined ? { connectedUserCount: r.connected_user_count } : {}),
...(r.can_write !== undefined && r.can_manage !== undefined
? {
serverPermissions: {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/connectors/connectors-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/connectors/connectors-view.tsx
index e02521a40..b793cd784 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/connectors/connectors-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/connectors/connectors-view.tsx
@@ -10,6 +10,7 @@ import {
operatesServer,
} from '@renderer/features/switch-servers/workspace-admin';
import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';
+import { LIST_PAGE_WIDTH, ListToolbar } from '@renderer/lib/components/list-toolbar';
import { failureText } from '@renderer/lib/errors/describe-failure';
import { toast } from '@renderer/lib/hooks/use-toast';
import { rpc } from '@renderer/lib/ipc';
@@ -78,7 +79,7 @@ const ConnectorsPanel = observer(function ConnectorsPanel() {
if (access !== 'shown' || workspaceId === null)
return (
- <ServerPage width={880} title="Connectors" description={DESCRIPTION}>
+ <ServerPage width={LIST_PAGE_WIDTH} title="Connectors" description={DESCRIPTION}>
<Spinner />
</ServerPage>
);
@@ -186,7 +187,7 @@ function Connectors({
return (
<ServerPage
- width={880}
+ width={LIST_PAGE_WIDTH}
title="Connectors"
description={DESCRIPTION}
action={
@@ -206,16 +207,20 @@ function Connectors({
>
{/* Which tab opens depends on the catalog, so the tabs wait for it rather than flick over. */}
{catalog.data && (
- <div className="flex items-center gap-3">
- <SegmentedControl ariaLabel="Connectors" value={tab} onChange={setTab} options={tabs} />
- <SearchInput
- containerClassName="flex-1"
- aria-label="Search connectors"
- placeholder="Search by name, category or description"
- value={query}
- onChange={(event) => setQuery(event.target.value)}
- />
- </div>
+ <ListToolbar
+ scope={
+ <SegmentedControl ariaLabel="Connectors" value={tab} onChange={setTab} options={tabs} />
+ }
+ search={
+ <SearchInput
+ containerClassName="w-full"
+ aria-label="Search connectors"
+ placeholder="Search by name, category or description"
+ value={query}
+ onChange={(event) => setQuery(event.target.value)}
+ />
+ }
+ />
)}
{catalog.isError ? (
<CatalogError error={catalog.error} onRetry={() => void catalog.refetch()} />
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
index 548358e42..95032e48b 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
@@ -55,7 +55,7 @@ export const WorkspaceNav = observer(function WorkspaceNav() {
> = {
server: { icon: House, label: 'Home', params: homeParams },
serverAgents: { icon: Bot, label: 'Your Agents', params: agentsParams },
- serverRooms: { icon: DoorOpen, label: 'Your Rooms', params: roomsParams },
+ serverRooms: { icon: DoorOpen, label: 'Rooms', params: roomsParams },
templates: { icon: FileText, label: 'Templates', params: templatesParams },
connectors: { icon: Plug, label: 'Connectors', params: connectorsParams },
admin: { icon: ShieldCheck, label: 'Admin', params: adminParams },
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.tsx
index bdd11ed02..567b74f14 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
@@ -569,7 +569,7 @@ export const ArchiveRoomSection = observer(function ArchiveRoomSection({
<p className="text-xs text-foreground-muted">
{room.archived
? 'Puts the room back in the room lists.'
- : 'Hides the room from room lists, yours and its agents’. Everything else stays as it is: who is in it, its history and its channel. You can unarchive it from Your Rooms.'}
+ : 'Hides the room from room lists, yours and its agents’. Everything else stays as it is: who is in it, its history and its channel. You can unarchive it from Rooms.'}
</p>
{error !== null && <p className="text-xs text-destructive">{error}</p>}
</div>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.test.ts
deleted file mode 100644
index 2db3554c2..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.test.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import type { RemoteRoomSummary } from '@shared/core/switch-servers/switch-servers';
-import { groupByMessagingApp } from './rooms-by-messaging-app';
-
-const room = (id: string, bridgeType: string | null): RemoteRoomSummary => ({
- id,
- name: id,
- description: '',
- channelType: 'channel_private',
- agentCount: 0,
- bridgeDisplayName: bridgeType ? 'Acme Slack' : null,
- bridgeType,
- externalChannelUrl: null,
- ownerId: null,
- viewerIsMember: false,
- isConsoleChat: false,
- archived: false,
- createdAt: '',
-});
-
-describe('groupByMessagingApp', () => {
- it('heads the rooms in no messaging app as Switch Console, after the apps', () => {
- expect(
- groupByMessagingApp([room('a', null), room('b', 'slack')]).map((group) => group.label)
- ).toEqual(['Acme Slack', 'Switch Console']);
- });
-});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.ts
deleted file mode 100644
index 5db290f3d..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-by-messaging-app.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
-import type { RemoteRoomSummary } from '@shared/core/switch-servers/switch-servers';
-
-/** Group key for a room with no messaging app behind it. */
-const UNBRIDGED = '';
-
-export type RoomGroup = {
- key: string;
- label: string;
- bridgeType: string | null;
- rooms: RemoteRoomSummary[];
-};
-
-/**
- * Rooms under the messaging app they are reachable in.
- *
- * Which app a room is in is the thing people scan this page for — it decides
- * where a conversation actually happens — so it is the heading rather than a
- * column. Grouped by the bridge's own display name, because a server can have
- * two of the same platform (two Slack workspaces) and calling both "Slack"
- * would merge two different places into one list. Rooms in no app, which
- * live in Switch Console, sort last: they are the exception, and leading with
- * them buries the rest.
- */
-export function groupByMessagingApp(rooms: RemoteRoomSummary[]): RoomGroup[] {
- const groups = new Map<string, RoomGroup>();
- for (const room of rooms) {
- const key = room.bridgeType ? (room.bridgeDisplayName ?? room.bridgeType) : UNBRIDGED;
- const existing = groups.get(key);
- if (existing) {
- existing.rooms.push(room);
- continue;
- }
- groups.set(key, {
- key,
- label: room.bridgeType
- ? (room.bridgeDisplayName ?? bridgePlatformLabel(room.bridgeType))
- : 'Switch Console',
- bridgeType: room.bridgeType ?? null,
- rooms: [room],
- });
- }
- for (const group of groups.values()) {
- group.rooms.sort((a, b) => a.name.localeCompare(b.name));
- }
- return [...groups.values()].sort((a, b) => {
- if (a.key === UNBRIDGED) return 1;
- if (b.key === UNBRIDGED) return -1;
- return a.label.localeCompare(b.label);
- });
-}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.test.ts
new file mode 100644
index 000000000..065f1bb26
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.test.ts
@@ -0,0 +1,103 @@
+import { describe, expect, it } from 'vitest';
+import type { RemoteRoomSummary } from '@shared/core/switch-servers/switch-servers';
+import { appOptions, filterRoomRows, groupOptions, NO_FILTER, roomRow } from './rooms-table';
+
+function room(extra: Partial<RemoteRoomSummary>): RemoteRoomSummary {
+ return {
+ id: 'r',
+ name: 'room',
+ description: '',
+ channelType: 'channel_public',
+ agentCount: 1,
+ bridgeDisplayName: 'Acme Slack',
+ bridgeType: 'slack',
+ externalChannelUrl: null,
+ ownerId: 'u-2',
+ viewerIsMember: false,
+ isConsoleChat: false,
+ archived: false,
+ createdAt: '2026-10-01T09:00:00Z',
+ ...extra,
+ };
+}
+
+describe('a room as the Rooms table shows it', () => {
+ it('names its app, group, owner and access, and counts its agents and people', () => {
+ expect(
+ roomRow(
+ room({
+ groupId: 'g1',
+ groupName: 'Design',
+ ownerName: 'Max Tam',
+ readVisibility: 'public',
+ writeVisibility: 'private',
+ connectedUserCount: 6,
+ }),
+ 'u-1'
+ )
+ ).toMatchObject({
+ appLabel: 'Acme Slack',
+ groupName: 'Design',
+ ownerLabel: 'Max Tam',
+ access: 'read_only',
+ agentCount: 1,
+ peopleCount: 6,
+ privateChannel: false,
+ });
+ });
+
+ it('calls your own rooms yours, and a private channel private', () => {
+ const row = roomRow(room({ ownerId: 'u-1', channelType: 'channel_private' }), 'u-1');
+ expect(row.ownerLabel).toBe('You');
+ expect(row.privateChannel).toBe(true);
+ });
+
+ it('puts a Console chat in Switch Console, private to its members', () => {
+ const row = roomRow(
+ room({ bridgeType: null, bridgeDisplayName: null, isConsoleChat: true }),
+ null
+ );
+ expect(row).toMatchObject({ appLabel: 'Switch Console', access: 'private' });
+ });
+
+ it('says nothing about access a server does not report', () => {
+ expect(roomRow(room({}), null).access).toBeNull();
+ });
+});
+
+describe('filtering the Rooms table', () => {
+ const rows = [
+ roomRow(room({ id: 'b', name: 'beta', groupId: 'g1', groupName: 'Design' }), null),
+ roomRow(room({ id: 'a', name: 'Alpha', bridgeType: null, bridgeDisplayName: null }), null),
+ roomRow(
+ room({
+ id: 'c',
+ name: 'gamma',
+ bridgeDisplayName: 'Ops Mattermost',
+ bridgeType: 'mattermost',
+ }),
+ null
+ ),
+ ];
+
+ it('sorts by name and matches the search in any case', () => {
+ expect(filterRoomRows(rows, NO_FILTER).map((row) => row.id)).toEqual(['a', 'b', 'c']);
+ expect(filterRoomRows(rows, { ...NO_FILTER, query: ' ALP ' }).map((row) => row.id)).toEqual([
+ 'a',
+ ]);
+ });
+
+ it('narrows to one app and one group', () => {
+ expect(filterRoomRows(rows, { ...NO_FILTER, app: 'Acme Slack' }).map((row) => row.id)).toEqual([
+ 'b',
+ ]);
+ expect(filterRoomRows(rows, { ...NO_FILTER, groupId: 'g1' }).map((row) => row.id)).toEqual([
+ 'b',
+ ]);
+ });
+
+ it('offers the apps and groups the rows have, Switch Console last', () => {
+ expect(appOptions(rows)).toEqual(['Acme Slack', 'Ops Mattermost', 'Switch Console']);
+ expect(groupOptions(rows)).toEqual([{ id: 'g1', name: 'Design' }]);
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.ts
new file mode 100644
index 000000000..3799598ce
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/rooms-table.ts
@@ -0,0 +1,105 @@
+import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
+import {
+ type RemoteRoomSummary,
+ type RoomAccess,
+ roomAccessOf,
+} from '@shared/core/switch-servers/switch-servers';
+
+/** One room as the Rooms table shows it. */
+export type RoomRow = {
+ id: string;
+ name: string;
+ /** The messaging app it lives in, by its own name ("Acme Slack"), or Switch Console. */
+ appLabel: string;
+ bridgeType: string | null;
+ /** A private channel on its app, or a Console chat, which only its members reach. */
+ privateChannel: boolean;
+ isConsoleChat: boolean;
+ groupId: string | null;
+ groupName: string | null;
+ /** "You" for your own rooms; null when the server names no owner. */
+ ownerLabel: string | null;
+ /** Null when the server does not say. */
+ access: RoomAccess | null;
+ agentCount: number;
+ /** Null when the server does not say. */
+ peopleCount: number | null;
+ createdAt: string;
+ /** You own it, take part in it, or have an agent in it. */
+ mine: boolean;
+ archived: boolean;
+};
+
+/** The short word the table shows for a room's access; the full sentence is its tooltip. */
+export const ACCESS_SHORT: Record<RoomAccess, string> = {
+ public: 'Open',
+ read_only: 'Read-only',
+ private: 'Private',
+};
+
+export const CONSOLE_APP_LABEL = 'Switch Console';
+
+export function roomRow(room: RemoteRoomSummary, viewerId: string | null): RoomRow {
+ const isConsoleChat = room.isConsoleChat;
+ return {
+ id: room.id,
+ name: room.name,
+ appLabel: room.bridgeType
+ ? (room.bridgeDisplayName ?? bridgePlatformLabel(room.bridgeType))
+ : CONSOLE_APP_LABEL,
+ bridgeType: room.bridgeType,
+ privateChannel: isConsoleChat || room.channelType === 'channel_private',
+ isConsoleChat,
+ groupId: room.groupId ?? null,
+ groupName: room.groupName ?? null,
+ ownerLabel: viewerId !== null && room.ownerId === viewerId ? 'You' : (room.ownerName ?? null),
+ // A Console chat is made readable only by its members.
+ access: isConsoleChat
+ ? 'private'
+ : room.readVisibility && room.writeVisibility
+ ? roomAccessOf(room.readVisibility, room.writeVisibility)
+ : null,
+ agentCount: room.agentCount,
+ peopleCount: room.connectedUserCount ?? null,
+ createdAt: room.createdAt,
+ mine: room.viewerIsMember,
+ archived: room.archived,
+ };
+}
+
+export type RoomsFilter = {
+ query: string;
+ /** An app label, or null for any. */
+ app: string | null;
+ /** A group id, or null for any. */
+ groupId: string | null;
+};
+
+export const NO_FILTER: RoomsFilter = { query: '', app: null, groupId: null };
+
+/** The rows that match the search and the app and group picked, in name order. */
+export function filterRoomRows(rows: readonly RoomRow[], filter: RoomsFilter): RoomRow[] {
+ const query = filter.query.trim().toLowerCase();
+ return rows
+ .filter((row) => query === '' || row.name.toLowerCase().includes(query))
+ .filter((row) => filter.app === null || row.appLabel === filter.app)
+ .filter((row) => filter.groupId === null || row.groupId === filter.groupId)
+ .sort((a, b) => a.name.localeCompare(b.name));
+}
+
+/** The apps the rows live in, each once, in name order, Switch Console last. */
+export function appOptions(rows: readonly RoomRow[]): string[] {
+ const labels = [...new Set(rows.map((row) => row.appLabel))];
+ return labels.sort((a, b) =>
+ a === CONSOLE_APP_LABEL ? 1 : b === CONSOLE_APP_LABEL ? -1 : a.localeCompare(b)
+ );
+}
+
+/** The groups the rows are filed under, each once, in name order. */
+export function groupOptions(rows: readonly RoomRow[]): { id: string; name: string }[] {
+ const byId = new Map<string, string>();
+ for (const row of rows) {
+ if (row.groupId !== null) byId.set(row.groupId, row.groupName ?? 'Unnamed group');
+ }
+ return [...byId].map(([id, name]) => ({ id, name })).sort((a, b) => a.name.localeCompare(b.name));
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx
index d49de6e58..4e5ff9863 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx
@@ -1,32 +1,45 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
-import { ChevronDown, DoorOpen, MessagesSquare, Plus } from 'lucide-react';
+import { DoorOpen, Lock, MessagesSquare, Plus } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useState } from 'react';
import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
-import { ArchivedFold } from '@renderer/features/chats/components/archived-fold';
import { UnreadBadge } from '@renderer/features/chats/components/unread-badge';
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 { openRoom } from '@renderer/features/switch-rooms/open-room';
-import { roomTitle } from '@renderer/features/switch-rooms/room-labels';
+import { ACCESS_LABELS } from '@renderer/features/switch-rooms/room-settings-sections';
import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';
-import { AgentAvatar } from '@renderer/lib/components/agent-avatar';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
+import { LIST_PAGE_WIDTH, ListToolbar } from '@renderer/lib/components/list-toolbar';
import { failureText } from '@renderer/lib/errors/describe-failure';
import { toast } from '@renderer/lib/hooks/use-toast';
import { rpc } from '@renderer/lib/ipc';
import { useParams } from '@renderer/lib/layout/navigation-provider';
import { useShowModal } from '@renderer/lib/modal/modal-provider';
-import { useWorkspaceAgents } from '@renderer/lib/stores/use-workspace-agents';
import { Button } from '@renderer/lib/ui/button';
import { SearchInput } from '@renderer/lib/ui/search-input';
-import { ToggleGroup, ToggleGroupItem } from '@renderer/lib/ui/toggle-group';
+import { SegmentedControl } from '@renderer/lib/ui/segmented-control';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@renderer/lib/ui/select';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
import { cn } from '@renderer/utils/utils';
import type { RemoteRoomSummary } from '@shared/core/switch-servers/switch-servers';
-import { allReadableRooms, isConsoleGroupChatSummary } from './room-filters';
-import { groupByMessagingApp, type RoomGroup } from './rooms-by-messaging-app';
+import { allReadableRooms, isConsoleGroupChatSummary, withConsoleGroupChats } from './room-filters';
+import {
+ ACCESS_SHORT,
+ appOptions,
+ filterRoomRows,
+ groupOptions,
+ NO_FILTER,
+ type RoomRow,
+ type RoomsFilter,
+ roomRow,
+} from './rooms-table';
import { ServerPage, ServerTableEmpty } from './server-page';
import { ServerSectionTitlebar } from './server-section-titlebar';
import { switchRoomsStore } from './switch-rooms-store';
@@ -38,41 +51,52 @@ function useServerId(): string {
}
const ServerRoomsTitlebar = observer(function ServerRoomsTitlebar() {
- return <ServerSectionTitlebar serverId={useServerId()} icon={DoorOpen} label="Your Rooms" />;
+ return <ServerSectionTitlebar serverId={useServerId()} icon={DoorOpen} label="Rooms" />;
});
+type Scope = 'mine' | 'all';
+type State = 'active' | 'archived';
+
+const SCOPES = [
+ { value: 'mine', label: 'Mine' },
+ { value: 'all', label: 'All rooms' },
+] as const satisfies readonly { value: Scope; label: string }[];
+
+const STATES = [
+ { value: 'active', label: 'Active' },
+ { value: 'archived', label: 'Archived' },
+] as const satisfies readonly { value: State; label: string }[];
+
+const ANY = '__any__';
+
+/**
+ * The workspace's rooms as one table: yours by default, every room you can
+ * read at a switch, and the archived ones at another. The same row whichever
+ * slice you look at, so moving between them never changes what a column
+ * means.
+ */
const ServerRoomsPanel = observer(function ServerRoomsPanel() {
const serverId = useServerId();
const server = switchServersStore.servers.find((s) => s.id === serverId);
const showCreateRoomModal = useShowModal('createRoomModal');
- const [filter, setFilter] = useState('');
+ const queryClient = useQueryClient();
+ const [scope, setScope] = useState<Scope>('mine');
+ const [state, setState] = useState<State>('active');
+ const [filter, setFilter] = useState<RoomsFilter>(NO_FILTER);
useEffect(() => {
void refreshSidebarRoomState(false);
}, [serverId]);
const workspaceId = workspacesStore.idOnServerInScope(serverId);
+ const viewerId = switchServersStore.statusFor(serverId)?.user?.id ?? null;
const yours = useListedRoomsInWorkspace(workspaceId);
const all = allReadableRooms(yours, useReadableRoomsInWorkspace(workspaceId));
- // Only someone who can read more than their own (an admin, or public rooms) gets the choice.
- const [showAll, setShowAll] = useState(false);
- const canShowAll = all.length > yours.length;
- const rooms = showAll && canShowAll ? all : yours;
const signedOut = switchRoomsStore.workspacesNotSignedIn.some((w) => w.id === workspaceId);
const failed = switchRoomsStore.workspacesThatFailedToLoad.some((w) => w.id === workspaceId);
- const query = filter.trim().toLowerCase();
- const matching = query === '' ? rooms : rooms.filter((r) => r.name.toLowerCase().includes(query));
- const groups = groupByMessagingApp(matching);
- const archived =
- chatsStore.serverId === serverId
- ? [...chatsStore.archived.values()]
- .filter(isConsoleGroupChatSummary)
- .filter((chat) => query === '' || chat.name.toLowerCase().includes(query))
- .sort((a, b) => a.name.localeCompare(b.name))
- : [];
- // Archived rooms in a messaging app; archived group chats come from the chats list above.
- const queryClient = useQueryClient();
+ // Archived rooms in a messaging app come from the server; archived group
+ // chats from the chats list, which follows the active workspace.
const archivedRoomsQuery = useQuery({
queryKey: ['archived-rooms', workspaceId],
queryFn: async () => {
@@ -82,26 +106,62 @@ const ServerRoomsPanel = observer(function ServerRoomsPanel() {
},
enabled: workspaceId !== null && !signedOut,
});
- const archivedRooms = (archivedRoomsQuery.data ?? [])
- .filter((room) => query === '' || room.name.toLowerCase().includes(query))
- .sort((a, b) => a.name.localeCompare(b.name));
- async function unarchiveRoom(room: RemoteRoomSummary) {
+ const archivedChats =
+ chatsStore.serverId === serverId
+ ? [...chatsStore.archived.values()].filter(isConsoleGroupChatSummary)
+ : [];
+
+ const toRow = (room: RemoteRoomSummary): RoomRow => {
+ const row = roomRow(room, viewerId);
+ // A chat's people are its members, which the chat list knows.
+ const chat = room.isConsoleChat ? chatsStore.chats.get(room.id) : undefined;
+ return chat ? { ...row, peopleCount: chat.memberCount } : row;
+ };
+ const activeRows = (scope === 'all' ? all : yours).map(toRow);
+ const archivedRows = [
+ ...(archivedRoomsQuery.data ?? []).map(toRow),
+ ...withConsoleGroupChats([], archivedChats).map((room) => ({
+ ...toRow(room),
+ archived: true,
+ })),
+ ].filter((row) => scope === 'all' || row.mine);
+ const rows = state === 'archived' ? archivedRows : activeRows;
+ const shown = filterRoomRows(rows, filter);
+ const apps = appOptions(rows);
+ const groups = groupOptions(rows);
+
+ async function unarchive(row: RoomRow) {
if (workspaceId === null) return;
try {
- await rpc.workspaces.setRoomArchived({ workspaceId, roomId: room.id, archived: false });
- await queryClient.invalidateQueries({ queryKey: ['archived-rooms', workspaceId] });
- await switchRoomsStore.refreshRoomState();
+ if (row.isConsoleChat) {
+ await chatsStore.unarchive(serverId, row.id);
+ } else {
+ await rpc.workspaces.setRoomArchived({ workspaceId, roomId: row.id, archived: false });
+ await queryClient.invalidateQueries({ queryKey: ['archived-rooms', workspaceId] });
+ await switchRoomsStore.refreshRoomState();
+ }
void refreshSidebarRoomState(true);
} catch (error) {
toast({ title: failureText(error, 'Could not unarchive the room.'), variant: 'destructive' });
}
}
+ const mayUnarchive = (row: RoomRow): boolean => {
+ if (row.isConsoleChat) return chatsStore.archived.get(row.id)?.canManage ?? false;
+ const room = (archivedRoomsQuery.data ?? []).find((each) => each.id === row.id);
+ return room !== undefined && workspaceId !== null
+ ? switchRoomsStore.roomPermissions(workspaceId, room).canWrite
+ : false;
+ };
return (
<ServerPage
- width={880}
- title="Your Rooms"
- description={`Rooms on ${server?.name ?? 'this server'}. Create one, see who is in it, and where it is bridged.`}
+ width={LIST_PAGE_WIDTH}
+ title="Rooms"
+ description={
+ scope === 'mine'
+ ? 'Rooms you own, take part in, or have an agent in.'
+ : `Every room on ${server?.name ?? 'this server'} you can see.`
+ }
action={
<Button
size="sm"
@@ -128,289 +188,255 @@ const ServerRoomsPanel = observer(function ServerRoomsPanel() {
<ServerTableEmpty>
This server&apos;s room list could not be read. Refresh from Home to try again.
</ServerTableEmpty>
- ) : all.length === 0 ? (
- <ServerTableEmpty>
- No rooms here yet. Create one to give your agents somewhere to work.
- </ServerTableEmpty>
) : (
- <div className="flex flex-col gap-6">
- <div className="flex items-center gap-2">
- {canShowAll && (
- <ToggleGroup
- multiple={false}
- value={[showAll ? 'all' : 'yours']}
- onValueChange={([value]) => {
- if (value) setShowAll(value === 'all');
+ <div className="flex flex-col gap-4">
+ <ListToolbar
+ scope={
+ <SegmentedControl
+ ariaLabel="Whose rooms"
+ value={scope}
+ onChange={(next) => {
+ setScope(next);
+ setFilter((current) => ({ ...current, app: null, groupId: null }));
}}
- >
- <ToggleGroupItem value="yours">Your rooms</ToggleGroupItem>
- <ToggleGroupItem value="all">All rooms</ToggleGroupItem>
- </ToggleGroup>
- )}
- <SearchInput
- containerClassName="flex-1"
- value={filter}
- onChange={(e) => setFilter(e.target.value)}
- placeholder="Filter rooms by name…"
- aria-label="Filter rooms by name"
- />
- </div>
- {/* The filter finding nothing is not the same as the server having no
- rooms, and the empty state above answers a question this user is not
- asking. */}
- {groups.length === 0 ? (
+ options={SCOPES}
+ />
+ }
+ search={
+ <SearchInput
+ containerClassName="w-full"
+ value={filter.query}
+ onChange={(e) => setFilter({ ...filter, query: e.target.value })}
+ placeholder="Search rooms…"
+ aria-label="Search rooms by name"
+ />
+ }
+ filters={
+ <>
+ <FilterSelect
+ label="Messaging app"
+ anyLabel="Any messaging app"
+ value={filter.app}
+ options={apps.map((app) => ({ value: app, label: app }))}
+ onChange={(app) => setFilter({ ...filter, app })}
+ />
+ <FilterSelect
+ label="Group"
+ anyLabel="Any group"
+ value={filter.groupId}
+ options={groups.map((group) => ({ value: group.id, label: group.name }))}
+ onChange={(groupId) => setFilter({ ...filter, groupId })}
+ />
+ <SegmentedControl
+ ariaLabel="Active or archived rooms"
+ value={state}
+ onChange={setState}
+ options={STATES}
+ />
+ </>
+ }
+ />
+ {state === 'archived' && archivedRoomsQuery.isError && (
+ <p className="text-xs text-destructive">
+ {failureText(archivedRoomsQuery.error, 'Could not list the archived rooms.')}
+ </p>
+ )}
+ {shown.length === 0 ? (
<p className="py-2 text-sm text-foreground-muted">
- {query === ''
- ? 'You are in none of these rooms yet. Choose All rooms to see the rest.'
- : `No room here matches “${filter.trim()}”.`}
+ {emptyText({ rows: rows.length, scope, state, query: filter.query })}
</p>
) : (
- groups.map((group) => (
- <MessagingAppGroup
- key={group.key}
- group={group}
- serverId={serverId}
- workspaceId={workspaceId}
- // Nothing folds while a filter is on. Typing a name and being
- // shown a "Show 3 more" where the match is hiding is the one
- // moment the fold would cost more than it saves.
- fold={query === ''}
- />
- ))
+ <RoomsTable
+ rows={shown}
+ scope={scope}
+ unarchive={state === 'archived' ? unarchive : null}
+ mayUnarchive={mayUnarchive}
+ />
)}
- <ArchivedFold
- count={archived.length + archivedRooms.length}
- error={
- (chatsStore.serverId === serverId ? chatsStore.archivedError : null) ??
- (archivedRoomsQuery.isError
- ? failureText(archivedRoomsQuery.error, 'Could not list the archived rooms.')
- : null)
- }
- >
- <div className="divide-y divide-border overflow-hidden rounded-[10px] border border-border">
- {archivedRooms.map((room) => (
- <div key={room.id} className="flex items-center gap-3 bg-background px-4 py-3">
- {hasBridgeIcon(room.bridgeType) ? (
- <BridgeIcon bridgeType={room.bridgeType} size={16} className="shrink-0" />
- ) : (
- <DoorOpen className="size-4 shrink-0 text-foreground-muted" />
- )}
- <button
- type="button"
- onClick={() => void openRoom(room.id)}
- className="min-w-0 flex-1 cursor-pointer truncate text-left text-sm font-medium text-foreground hover:underline"
- >
- {roomTitle(room)}
- </button>
- {workspaceId !== null &&
- switchRoomsStore.roomPermissions(workspaceId, room).canWrite && (
- <Button size="sm" variant="outline" onClick={() => void unarchiveRoom(room)}>
- Unarchive
- </Button>
- )}
- </div>
- ))}
- {archived.map((chat) => (
- <div key={chat.roomId} className="flex items-center gap-3 bg-background px-4 py-3">
- <button
- type="button"
- onClick={() => void openRoom(chat.roomId)}
- className="min-w-0 flex-1 cursor-pointer truncate text-left text-sm font-medium text-foreground hover:underline"
- >
- {chat.name}
- </button>
- {chat.canManage && (
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- void chatsStore.unarchive(serverId, chat.roomId).catch((error: unknown) =>
- toast({
- title: failureText(error, 'Could not unarchive the room.'),
- variant: 'destructive',
- })
- )
- }
- >
- Unarchive
- </Button>
- )}
- </div>
- ))}
- </div>
- </ArchivedFold>
</div>
)}
</ServerPage>
);
});
-/**
- * How many rooms a messaging app shows before the rest are folded away.
- *
- * A single busy workspace can hold more rooms than the whole page otherwise
- * has, and left whole it pushes every other app off the screen — so the page
- * stops answering "where are my rooms" and answers only "what is in Slack".
- * Five is enough to see the group is real and to recognise the room you came
- * for; the count in the heading always says how many there are in total, so
- * nothing is hidden silently.
- */
-const ROOMS_BEFORE_FOLD = 5;
+/** What an empty table means, which depends on why it is empty. */
+export function emptyText({
+ rows,
+ scope,
+ state,
+ query,
+}: {
+ rows: number;
+ scope: Scope;
+ state: State;
+ query: string;
+}): string {
+ if (rows > 0) return query.trim() ? `No room matches “${query.trim()}”.` : 'No room matches.';
+ if (state === 'archived') return 'No archived rooms.';
+ return scope === 'mine'
+ ? 'You are in no rooms yet. Create one, or choose All rooms to see the rest.'
+ : 'No rooms here yet. Create one to give your agents somewhere to work.';
+}
-const MessagingAppGroup = observer(function MessagingAppGroup({
- group,
- serverId,
- workspaceId,
- fold,
+function FilterSelect({
+ label,
+ anyLabel,
+ value,
+ options,
+ onChange,
}: {
- group: RoomGroup;
- serverId: string;
- workspaceId: string;
- /** Whether long groups are cut short. False while the list is filtered. */
- fold: boolean;
+ label: string;
+ anyLabel: string;
+ value: string | null;
+ options: { value: string; label: string }[];
+ onChange: (next: string | null) => void;
}) {
- const [open, setOpen] = useState(true);
- const [visible, setVisible] = useState(ROOMS_BEFORE_FOLD);
-
- const shown = fold ? group.rooms.slice(0, visible) : group.rooms;
- const remaining = group.rooms.length - shown.length;
- // One page at a time rather than the whole tail at once: a workspace with
- // forty rooms in it would otherwise unfold into the same wall the fold
- // exists to prevent, and there would be no way back to a readable page
- // short of collapsing the app entirely.
- const nextBatch = Math.min(remaining, ROOMS_BEFORE_FOLD);
-
+ const current = options.find((option) => option.value === value)?.label ?? anyLabel;
return (
- <section className="flex flex-col gap-2">
- <button
- type="button"
- aria-expanded={open}
- onClick={() => setOpen((v) => !v)}
- className="-mx-2 flex w-fit cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition-colors hover:bg-[var(--sel-soft)]"
- >
- <ChevronDown
- className={cn(
- 'size-3.5 shrink-0 text-foreground-muted transition-transform',
- !open && '-rotate-90'
- )}
- />
- {hasBridgeIcon(group.bridgeType) ? (
- <BridgeIcon bridgeType={group.bridgeType} size={16} />
- ) : (
- <MessagesSquare className="size-4 text-foreground-muted" />
- )}
- <span className="truncate text-sm font-medium text-foreground">{group.label}</span>
- <span className="shrink-0 text-xs text-foreground-muted">
- {group.rooms.length} {group.rooms.length === 1 ? 'room' : 'rooms'}
- </span>
- </button>
-
- {open && (
- <div className="divide-y divide-border overflow-hidden rounded-[10px] border border-border">
- {shown.map((room) => (
- <RoomRow key={room.id} room={room} serverId={serverId} workspaceId={workspaceId} />
- ))}
- {fold && group.rooms.length > ROOMS_BEFORE_FOLD && (
- <button
- type="button"
- onClick={() =>
- setVisible((v) => (remaining > 0 ? v + ROOMS_BEFORE_FOLD : ROOMS_BEFORE_FOLD))
- }
- className="flex w-full cursor-pointer items-center gap-1.5 px-4 py-2.5 text-sm text-foreground-muted transition-colors hover:bg-[var(--fill)] hover:text-foreground"
- >
- <ChevronDown className={cn('size-4 shrink-0', remaining === 0 && 'rotate-180')} />
- {remaining > 0 ? `Show ${nextBatch} more` : 'Show fewer'}
- </button>
- )}
- </div>
- )}
- </section>
+ <Select
+ value={value ?? ANY}
+ onValueChange={(next) => onChange(next === ANY ? null : (next as string))}
+ >
+ <SelectTrigger size="sm" className="w-auto min-w-[150px]" aria-label={label}>
+ <SelectValue>{current}</SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value={ANY}>{anyLabel}</SelectItem>
+ {options.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
);
-});
+}
-const RoomRow = observer(function RoomRow({
- room,
- serverId,
- workspaceId,
+const RoomsTable = observer(function RoomsTable({
+ rows,
+ scope,
+ unarchive,
+ mayUnarchive,
}: {
- room: RemoteRoomSummary;
- serverId: string;
- workspaceId: string;
+ rows: RoomRow[];
+ scope: Scope;
+ /** The way to unarchive a row, in the archived view. */
+ unarchive: ((row: RoomRow) => Promise<void>) | null;
+ mayUnarchive: (row: RoomRow) => boolean;
}) {
- const members = switchRoomsStore.localMemberIds(room.id);
- const { data: remoteAgents } = useWorkspaceAgents(workspaceId);
- const remoteById = new Map((remoteAgents ?? []).map((agent) => [agent.id, agent]));
- const localAgents = agentsStore
- .agentsOnServer(serverId)
- .filter((agent) => agent.switchAgentId != null && members.includes(agent.switchAgentId));
-
return (
- <button
- type="button"
- onClick={() => void openRoom(room.id)}
- // A solid hover rather than a translucent one, because the discs holding
- // the agent marks have to be filled with whatever the row is filled with
- // — an overlay would leave them reading as holes punched in the row.
- className="group/room flex w-full cursor-pointer items-center gap-3 bg-background px-4 py-3 text-left transition-colors hover:bg-[var(--fill)]"
- >
- <div className="flex min-w-0 flex-1 flex-col">
- <span className="flex items-center gap-2">
- <span className="truncate text-sm font-medium text-foreground">{roomTitle(room)}</span>
- <UnreadBadge roomId={room.id} />
- </span>
- {/* An empty room is a state, not a quantity. "0 agents" reads as a
- measurement of something that is working; a room nobody is in is a
- room that cannot answer, and it should say so in words. */}
- <span className="text-xs text-foreground-muted">
- {room.agentCount === 0
- ? 'No agent in this room yet'
- : `${room.agentCount} ${room.agentCount === 1 ? 'agent' : 'agents'}`}
- </span>
- </div>
-
- {/* The agents of this install that are in the room, by the mark of what
- they run. Deliberately not a second count: the number above is the
- server's, other people's agents included, and only these are ones this
- app could open. The tooltip says so rather than leaving two numbers on
- one row disagreeing in silence. */}
- {localAgents.length > 0 && (
- <Tooltip>
- <TooltipTrigger
- render={
- // Overlapped rather than spaced: this is one fact — who is in
- // the room — and a stack reads as that, where an evenly spaced
- // row reads as a set of separate controls to click.
- //
- // Each avatar keeps its ring, so what the one in front hides is a
- // clean circle rather than a bitten-into picture — the avatars
- // are all different, and letting them interlock made two agents
- // read as one broken image.
- <span className="flex shrink-0 items-center -space-x-1.5">
- {localAgents.map((agent) => (
+ <div className="overflow-hidden rounded-[10px] border border-border">
+ <table className="w-full border-collapse text-sm">
+ <thead>
+ <tr className="border-b border-border text-left text-xs text-foreground-muted">
+ <th className="px-3 py-2 font-normal">Room</th>
+ <th className="px-3 py-2 font-normal">Messaging app</th>
+ <th className="px-3 py-2 font-normal">Group</th>
+ <th className="px-3 py-2 font-normal">Owner</th>
+ <th className="px-3 py-2 font-normal">Access</th>
+ <th className="px-3 py-2 font-normal">Agents · people</th>
+ <th className="px-3 py-2 font-normal">Created</th>
+ {unarchive && <th className="px-3 py-2" />}
+ </tr>
+ </thead>
+ <tbody>
+ {rows.map((row) => (
+ <tr
+ key={row.id}
+ onClick={() => void openRoom(row.id)}
+ className="cursor-pointer border-b border-border last:border-b-0 hover:bg-[var(--fill)]"
+ >
+ <td className="px-3 py-2">
+ <span className="flex min-w-0 items-center gap-2">
+ <RoomMark row={row} />
<span
- key={agent.id}
- className="flex size-6 items-center justify-center rounded-full bg-background ring-1 ring-[var(--hair-soft)] transition-colors group-hover/room:bg-[var(--fill)]"
+ className={cn(
+ 'truncate',
+ // In All rooms, yours stand out; the rest are there to find.
+ scope === 'all' && !row.mine
+ ? 'text-foreground-muted'
+ : 'font-medium text-foreground'
+ )}
>
- <AgentAvatar
- name={agent.name}
- iconUrl={remoteById.get(agent.switchAgentId ?? '')?.iconUrl ?? null}
- serverId={serverId}
- size={22}
- />
+ {row.name}
</span>
- ))}
- </span>
- }
- />
- <TooltipContent>
- Your agents here: {localAgents.map((agent) => agent.name).join(', ')}
- </TooltipContent>
- </Tooltip>
- )}
- </button>
+ <UnreadBadge roomId={row.id} />
+ </span>
+ </td>
+ <td className="px-3 py-2 text-foreground">{row.appLabel}</td>
+ <td className="px-3 py-2 text-foreground">{row.groupName ?? '—'}</td>
+ <td className="px-3 py-2 text-foreground">{row.ownerLabel ?? '—'}</td>
+ <td className="px-3 py-2 text-foreground">
+ {row.access ? (
+ <Tooltip>
+ <TooltipTrigger render={<span>{ACCESS_SHORT[row.access]}</span>} />
+ <TooltipContent>{ACCESS_LABELS[row.access]}</TooltipContent>
+ </Tooltip>
+ ) : (
+ '—'
+ )}
+ </td>
+ <td className="px-3 py-2 text-foreground tabular-nums">
+ {row.agentCount} · {row.peopleCount ?? '—'}
+ </td>
+ <td className="px-3 py-2 text-foreground-muted">
+ {row.createdAt ? <AbsoluteDate value={row.createdAt} /> : '—'}
+ </td>
+ {unarchive && (
+ <td className="px-3 py-2 text-right">
+ {mayUnarchive(row) && (
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={(event) => {
+ event.stopPropagation();
+ void unarchive(row);
+ }}
+ >
+ Unarchive
+ </Button>
+ )}
+ </td>
+ )}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
);
});
+/** Where the room lives at a glance: its app's mark, or a lock for one only its people reach. */
+function RoomMark({ row }: { row: RoomRow }) {
+ if (row.privateChannel && !row.isConsoleChat) {
+ return (
+ <Lock className="size-3.5 shrink-0 text-foreground-muted" aria-label="Private channel" />
+ );
+ }
+ if (hasBridgeIcon(row.bridgeType)) {
+ return <BridgeIcon bridgeType={row.bridgeType} size={14} className="shrink-0" />;
+ }
+ return <MessagesSquare className="size-3.5 shrink-0 text-foreground-muted" />;
+}
+
+/** A day, with the year only when it is not this one. */
+function AbsoluteDate({ value }: { value: string }) {
+ const date = new Date(
+ value.includes('T') || value.includes('Z') ? value : value.replace(' ', 'T')
+ );
+ if (Number.isNaN(date.getTime())) return <>—</>;
+ const sameYear = date.getFullYear() === new Date().getFullYear();
+ return (
+ <time dateTime={date.toISOString()}>
+ {date.toLocaleDateString(undefined, {
+ day: 'numeric',
+ month: 'short',
+ ...(sameYear ? {} : { year: 'numeric' }),
+ })}
+ </time>
+ );
+}
+
export const serverRoomsView = {
WrapView: ({ children }: { children: React.ReactNode; serverId: string }) => <>{children}</>,
TitlebarSlot: ServerRoomsTitlebar,
diff --git a/console/apps/switch-console-desktop/src/renderer/features/templates/template-use-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/templates/template-use-view.tsx
index 2ab8c73db..a96774700 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/templates/template-use-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/templates/template-use-view.tsx
@@ -1213,7 +1213,7 @@ const TemplateUsePanel = observer(function TemplateUsePanel() {
});
}
const first = result.rooms[0];
- finish(first ? `Opening ${first.roomName}…` : 'Opening Your Rooms…', () =>
+ finish(first ? `Opening ${first.roomName}…` : 'Opening Rooms…', () =>
first ? navigate('room', { roomId: first.roomId }) : navigate('serverRooms', { serverId })
);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/templates/templates-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/templates/templates-view.tsx
index 34b4c8f54..e50e52d04 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/templates/templates-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/templates/templates-view.tsx
@@ -8,7 +8,6 @@ import {
MoreVertical,
Trash2,
Upload,
- UserRound,
} from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useCallback, useEffect, useMemo, useState } from 'react';
@@ -18,6 +17,7 @@ import { ServerPage } from '@renderer/features/switch-servers/server-page';
import { ServerSectionTitlebar } from '@renderer/features/switch-servers/server-section-titlebar';
import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';
+import { LIST_PAGE_WIDTH, ListToolbar } from '@renderer/lib/components/list-toolbar';
import { failureText } from '@renderer/lib/errors/describe-failure';
import { toast } from '@renderer/lib/hooks/use-toast';
import { rpc } from '@renderer/lib/ipc';
@@ -35,7 +35,6 @@ import {
} from '@renderer/lib/ui/dropdown-menu';
import { SearchInput } from '@renderer/lib/ui/search-input';
import { SegmentedControl } from '@renderer/lib/ui/segmented-control';
-import { Toggle } from '@renderer/lib/ui/toggle';
function useServerId(): string {
return useParams('templates').params.serverId;
@@ -48,6 +47,11 @@ const TemplatesTitlebar = observer(function TemplatesTitlebar() {
type Kind = 'agent' | 'room' | 'group';
type KindFilter = 'all' | Kind;
+const SCOPE_OPTIONS = [
+ { value: 'all', label: 'All' },
+ { value: 'mine', label: 'Mine' },
+] as const;
+
const KIND_OPTIONS = [
{ value: 'all', label: 'All' },
{ value: 'room', label: 'Rooms', icon: DoorOpen },
@@ -355,7 +359,7 @@ const TemplatesPanel = observer(function TemplatesPanel() {
return (
<ServerPage
- width={1000}
+ width={LIST_PAGE_WIDTH}
title="Templates"
description="Templates create agents and rooms on this workspace. Pick one, fill in what it asks, and everything it describes is created in one go, or nothing is."
action={
@@ -420,34 +424,38 @@ const TemplatesPanel = observer(function TemplatesPanel() {
</Alert>
)}
- <div className="flex flex-wrap items-center gap-2">
- <SearchInput
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- placeholder="Search name and description…"
- aria-label="Search templates by name and description"
- containerClassName="min-w-[220px] flex-1"
- className="h-8"
- />
- <SegmentedControl
- value={kind}
- onChange={setKind}
- options={KIND_OPTIONS}
- ariaLabel="Show templates of one kind"
- />
- <Toggle
- variant="outline"
- size="sm"
- pressed={onlyMine}
- onPressedChange={setOnlyMine}
- aria-label="Only templates you own"
- title={meId ? 'Only templates you saved' : 'Sign in to see which are yours'}
- disabled={meId === null}
- >
- <UserRound />
- Only mine
- </Toggle>
- </div>
+ <ListToolbar
+ // Whose templates first, as on Rooms and Connectors; only someone
+ // signed in has any to call theirs.
+ scope={
+ meId !== null && (
+ <SegmentedControl
+ value={onlyMine ? 'mine' : 'all'}
+ onChange={(next) => setOnlyMine(next === 'mine')}
+ options={SCOPE_OPTIONS}
+ ariaLabel="Whose templates"
+ />
+ )
+ }
+ search={
+ <SearchInput
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder="Search name and description…"
+ aria-label="Search templates by name and description"
+ containerClassName="w-full"
+ className="h-8"
+ />
+ }
+ filters={
+ <SegmentedControl
+ value={kind}
+ onChange={setKind}
+ options={KIND_OPTIONS}
+ ariaLabel="Show templates of one kind"
+ />
+ }
+ />
{templatesShown.length > 0 ? (
<div className={grid}>{templatesShown.map(card)}</div>
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/components/list-toolbar.tsx b/console/apps/switch-console-desktop/src/renderer/lib/components/list-toolbar.tsx
new file mode 100644
index 000000000..97fa6a043
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/list-toolbar.tsx
@@ -0,0 +1,30 @@
+import type { ReactNode } from 'react';
+
+/**
+ * The filter row the list pages share — Rooms, Templates and Connectors — so
+ * each puts the same thing in the same place: which slice you are looking at
+ * (yours, all) first, then the search filling the width, then whatever
+ * narrows it further.
+ */
+export function ListToolbar({
+ scope,
+ search,
+ filters,
+}: {
+ /** The scope switch, such as Mine | All rooms. */
+ scope?: ReactNode;
+ search: ReactNode;
+ /** Further filters, after the search. */
+ filters?: ReactNode;
+}) {
+ return (
+ <div className="flex flex-wrap items-center gap-2">
+ {scope && <div className="shrink-0">{scope}</div>}
+ <div className="min-w-[220px] flex-1">{search}</div>
+ {filters && <div className="flex shrink-0 flex-wrap items-center gap-2">{filters}</div>}
+ </div>
+ );
+}
+
+/** The width the list pages share, so moving between them does not reflow the column. */
+export const LIST_PAGE_WIDTH = 1000;
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
index c3f0ad800..39767beb3 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
@@ -66,7 +66,10 @@ vi.mock('@renderer/features/workspaces/workspaces-store', () => ({
},
}));
vi.mock('@renderer/features/switch-servers/switch-servers-store', () => ({
- switchServersStore: { servers: [{ id: 'srv', name: 'Server' }] },
+ switchServersStore: {
+ servers: [{ id: 'srv', name: 'Server' }],
+ statusFor: () => ({ connected: true, user: { id: 'me' } }),
+ },
}));
// The store's own rule for "yours": owned, a member, or an agent of yours inside.
vi.mock('@renderer/features/switch-servers/switch-rooms-store', () => ({
@@ -177,7 +180,9 @@ async function render(): Promise<void> {
}
const names = () =>
- [...container.querySelectorAll('button.group\\/room span.truncate')].map((s) => s.textContent);
+ [...container.querySelectorAll('tbody tr td:first-child span.truncate')].map(
+ (s) => s.textContent
+ );
const toggle = (label: string) =>
[...container.querySelectorAll('button')].find((b) => b.textContent === label);
@@ -188,38 +193,43 @@ it('lists your rooms by default, and drops a chat once you are removed from it',
expect(names()).toEqual(['yaml-room']);
});
-it('offers All rooms to someone who can read more: bridged rooms, never chats they are not in', async () => {
+it('shows every room you can read under All rooms, never chats you are not in', async () => {
await render();
await act(async () => toggle('All rooms')!.click());
- expect(names()).toEqual(['#public-slack', 'bobs-chat', 'private-tool-room', 'yaml-room']);
+ expect(names()).toEqual(['bobs-chat', 'private-tool-room', 'public-slack', 'yaml-room']);
await removeFromBobsChat();
- expect(names()).toEqual(['#public-slack', 'private-tool-room', 'yaml-room']);
+ expect(names()).toEqual(['private-tool-room', 'public-slack', 'yaml-room']);
});
-it('offers no choice to someone who can read only their own rooms', async () => {
- rooms.list.all = [
- room('bobs-chat', {
- viewerIsMember: true,
- channelType: 'channel_private',
- isConsoleChat: true,
- }),
- ];
+it('keeps the same columns in both, and marks a room only its people reach', async () => {
await render();
- expect(toggle('All rooms')).toBeUndefined();
+ const headers = [...container.querySelectorAll('thead th')].map((th) => th.textContent);
+ expect(headers).toEqual([
+ 'Room',
+ 'Messaging app',
+ 'Group',
+ 'Owner',
+ 'Access',
+ 'Agents · people',
+ 'Created',
+ ]);
+ expect(container.querySelector('[aria-label="Private channel"]')).not.toBeNull();
});
it('lists archived rooms under Archived, and brings one back', async () => {
archivedRooms.list = [
- room('old-slack', { bridgeType: 'slack', bridgeDisplayName: 'Slack', archived: true }),
+ room('old-slack', {
+ bridgeType: 'slack',
+ bridgeDisplayName: 'Slack',
+ archived: true,
+ viewerIsMember: true,
+ }),
];
await render();
for (let i = 0; i < 4; i++) await act(async () => await Promise.resolve());
- const fold = [...container.querySelectorAll('button')].find((b) =>
- /^Archived/.test(b.textContent ?? '')
- );
- expect(fold?.textContent).toBe('Archived (1)');
- await act(async () => fold!.click());
- expect(container.textContent).toContain('#old-slack');
+ await act(async () => toggle('Archived')!.click());
+ for (let i = 0; i < 4; i++) await act(async () => await Promise.resolve());
+ expect(names()).toEqual(['old-slack']);
await act(async () => toggle('Unarchive')!.click());
expect(setRoomArchived).toHaveBeenCalledWith({
workspaceId: 'ws',
diff --git a/console/apps/switch-console-desktop/src/shared/core/switch-servers/switch-servers.ts b/console/apps/switch-console-desktop/src/shared/core/switch-servers/switch-servers.ts
index 0e44b4fa5..5ba103f55 100644
--- a/console/apps/switch-console-desktop/src/shared/core/switch-servers/switch-servers.ts
+++ b/console/apps/switch-console-desktop/src/shared/core/switch-servers/switch-servers.ts
@@ -368,6 +368,13 @@ export type RemoteRoomSummary = {
* where Console works it out the same way (`roomPermissionsFor`).
*/
serverPermissions?: { canWrite: boolean; canManage: boolean; canUnlink: boolean };
+ /** The group the room is filed under, when the server says (the list does). */
+ groupId?: string | null;
+ groupName?: string | null;
+ ownerName?: string | null;
+ readVisibility?: RoomVisibility;
+ /** How many people Switch knows are in the room, when the server says. */
+ connectedUserCount?: number;
};
/**