Skip to content

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

feat(console): rename a group room from its Configuration

raullopez-sandbox7b50a739465a
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 7d5480d8b..19caf4111 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
@@ -2982,7 +2982,7 @@ export async function fetchRoomAgentIds(server: SwitchServer, roomId: string): P
export async function updateRoom(
server: SwitchServer,
roomId: string,
- changes: { description?: string; instructions?: string }
+ changes: { name?: string; description?: string; instructions?: string }
): Promise<RemoteRoomDetail> {
const res = await gatewayFetch(server, `/rooms/${encodeURIComponent(roomId)}`, {
authenticated: true,
diff --git a/console/apps/switch-console-desktop/src/main/core/workspaces/controller.ts b/console/apps/switch-console-desktop/src/main/core/workspaces/controller.ts
index f4d0f0c2d..c605d06d5 100644
--- a/console/apps/switch-console-desktop/src/main/core/workspaces/controller.ts
+++ b/console/apps/switch-console-desktop/src/main/core/workspaces/controller.ts
@@ -891,6 +891,7 @@ export const workspacesController = createRPCController({
updateRoom: (params: UpdateRoomParams): Promise<RemoteRoomDetail> =>
withReachableWorkspaceSession(params.workspaceId, (server) =>
updateRoom(server, params.roomId, {
+ name: params.name,
description: params.description,
instructions: params.instructions,
})
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 a7991ba32..8693d3768 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
@@ -8,6 +8,7 @@ import { opensAsConsoleChat } from '@renderer/features/chats/console-chat-redire
import { chatFailure } from '@renderer/features/chats/stores/chat-errors';
import { chatsStore } from '@renderer/features/chats/stores/chats';
import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';
import { isConsoleGroupChatSummary } from '@renderer/features/switch-servers/room-filters';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
@@ -620,13 +621,16 @@ type SaveState = { phase: 'idle' | 'saving' | 'saved' } | { phase: 'failed'; mes
*/
function GeneralSection({ workspaceId, room }: { workspaceId: string; room: RemoteRoomDetail }) {
const queryClient = useQueryClient();
+ const savedName = room.name;
const savedDescription = room.description;
const savedInstructions = room.instructions ?? '';
+ const [name, setName] = useState(savedName);
const [description, setDescription] = useState(savedDescription);
const [instructions, setInstructions] = useState(savedInstructions);
const [state, setState] = useState<SaveState>({ phase: 'idle' });
- const dirty = description !== savedDescription || instructions !== savedInstructions;
+ const renamed = name.trim() !== savedName;
+ const dirty = renamed || description !== savedDescription || instructions !== savedInstructions;
async function save() {
setState({ phase: 'saving' });
@@ -634,11 +638,18 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo
const updated = await rpc.workspaces.updateRoom({
workspaceId,
roomId: room.id,
+ ...(renamed ? { name: name.trim() } : {}),
description,
instructions,
});
queryClient.setQueryData(roomDetailKey(workspaceId, room.id), updated);
+ setName(updated.name);
setState({ phase: 'saved' });
+ // The name shows in the sidebar, the room lists and the chat's title.
+ if (renamed) {
+ void refreshSidebarRoomState(true);
+ void chatsStore.refreshSummaries();
+ }
} catch (cause) {
setState({ phase: 'failed', message: failureText(cause, 'Could not save the change.') });
}
@@ -648,6 +659,18 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo
<section className="flex flex-col gap-4">
<h2 className="text-sm font-semibold text-foreground">General</h2>
+ <Field label="Name" hint="What everyone in the room sees it called.">
+ <Input
+ className="h-9"
+ aria-label="Name"
+ value={name}
+ onChange={(e) => {
+ setName(e.target.value);
+ setState({ phase: 'idle' });
+ }}
+ />
+ </Field>
+
<Field
label="Description"
hint="Helps other people and agents understand what this room is for."
@@ -682,7 +705,7 @@ function GeneralSection({ workspaceId, room }: { workspaceId: string; room: Remo
<Button
type="button"
size="sm"
- disabled={!dirty || state.phase === 'saving'}
+ disabled={!dirty || name.trim() === '' || state.phase === 'saving'}
onClick={() => void save()}
>
{state.phase === 'saving' ? 'Saving…' : 'Save'}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx
index 395dfe9a7..e851986e0 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-configuration-save.test.tsx
@@ -44,6 +44,13 @@ vi.mock('@renderer/features/switch-servers/switch-rooms-store', () => ({
},
}));
+const refreshSidebarRoomState = vi.hoisted(() => vi.fn(async () => {}));
+vi.mock('@renderer/features/sidebar/sidebar-tree-data', () => ({
+ refreshSidebarRoomState,
+ refreshSidebarRoomStateAfterOnboarding: vi.fn(),
+}));
+
+import { chatsStore } from '@renderer/features/chats/stores/chats';
import { RoomConfigurationPanel } from '@renderer/features/switch-rooms/room-configuration-panel';
const ROOM = {
@@ -187,4 +194,29 @@ describe('a room’s description and instructions', () => {
// Still offered, because the edit is still there and still unwritten.
expect(saveButton(el).disabled).toBe(false);
});
+ it('renames the room, and reads its name again wherever it shows', async () => {
+ const refreshSummaries = vi.spyOn(chatsStore, 'refreshSummaries').mockResolvedValue();
+ const el = await renderPanel();
+ await type(el.querySelector<HTMLInputElement>('input[aria-label="Name"]')!, ' Ship review ');
+
+ await act(async () => saveButton(el).click());
+ for (let i = 0; i < 5; i++) await act(async () => await Promise.resolve());
+
+ expect(updateRoom).toHaveBeenCalledWith({
+ workspaceId: 'ws-1',
+ roomId: 'room-1',
+ name: 'Ship review',
+ description: 'The original description',
+ instructions: 'The original instructions',
+ });
+ expect(refreshSidebarRoomState).toHaveBeenCalledWith(true);
+ expect(refreshSummaries).toHaveBeenCalled();
+ expect(el.textContent).toContain('Saved.');
+ });
+
+ it('does not save an empty name', async () => {
+ const el = await renderPanel();
+ await type(el.querySelector<HTMLInputElement>('input[aria-label="Name"]')!, ' ');
+ expect(saveButton(el).disabled).toBe(true);
+ });
});
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 d88d906c1..c7e812704 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
@@ -381,6 +381,7 @@ export type RetireOutcome = {
export type UpdateRoomParams = {
workspaceId: string;
roomId: string;
+ name?: string;
description?: string;
instructions?: string;
};