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
fix(console): refresh a chat's members when the summary names new people
raullopez-sandboxedb4c6e284b5
diff --git a/console/apps/switch-console-desktop/src/main/core/chats/chat-stream.test.ts b/console/apps/switch-console-desktop/src/main/core/chats/chat-stream.test.tsindex fcb202895..2e597d306 100644--- a/console/apps/switch-console-desktop/src/main/core/chats/chat-stream.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/chats/chat-stream.test.ts@@ -14,7 +14,7 @@ function summary(roomId: string, seq: number | null): ChatSummary {channelName: null,agents: [],canManage: true,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage:seq === null ? null : { seq, sentAt: '2026-01-01T00:00:00Z', preview: '', senderName: '' },};diff --git a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.tsindex 4e6d009a0..ee626f888 100644--- a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts@@ -29,7 +29,7 @@ function row(roomId: string, channelType: string) {channelName: null,agents: [],canManage: true,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: null,};}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chats-store.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chats-store.tsindex 6ca0ae361..621a26290 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chats-store.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chats-store.ts@@ -243,15 +243,6 @@ export class ChatsStore {});}- /**- * Calls `onChange` whenever the chat's summary changes on the feed or from- * here, which is when what is known of its membership may have moved.- * Returns the disposer.- */- onChatChange(roomId: string, onChange: () => void): () => void {- return reaction(() => this.chats.get(roomId), onChange);- }-/** The chats an agent is in, newest activity first. */chatsOfAgent(agentId: string): ChatSummary[] {return [...this.chats.values()]diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/empty-chat-finder.test.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/empty-chat-finder.test.tsindex 48497f460..d34fcd63d 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/empty-chat-finder.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/empty-chat-finder.test.ts@@ -10,7 +10,7 @@ const makeChat = (overrides: Partial<ChatSummary> = {}): ChatSummary => ({channelName: null,agents: [{ id: 'agent-1', name: 'Agent', displayName: null, iconUrl: null, provider: null, alias: null, ownerName: null, ownedByViewer: false }],canManage: false,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: null,...overrides,});diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsxindex 1dcbb8ba1..1c95cd631 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@@ -1,7 +1,7 @@import { useQuery, useQueryClient } from '@tanstack/react-query';import { ExternalLink, FileText, Loader2, Plus, RefreshCw, Search, X } from 'lucide-react';import { observer } from 'mobx-react-lite';-import { useEffect, useState } from 'react';+import { useState } from 'react';import { opensAsConsoleChat } from '@renderer/features/chats/console-chat-redirect';import { chatFailure } from '@renderer/features/chats/stores/chat-errors';import { chatsStore } from '@renderer/features/chats/stores/chats';@@ -94,6 +94,14 @@ const ChatConfiguration = observer(function ChatConfiguration({);});+/**+ * The query for a chat's members, keyed on who the live summary says is in it,+ * so an add, a removal or a swap by anyone reads the list again.+ */+export function chatMembersQueryKey(serverId: string, chat: ChatSummary) {+ return ['chat-members', serverId, chat.roomId, chat.memberUserIds.join(',')] as const;+}+/** Who is in a group chat; a manager adds and removes agents and people through the chat. */const ChatParticipantsSection = observer(function ChatParticipantsSection({serverId,@@ -106,18 +114,11 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({}) {const queryClient = useQueryClient();const roomId = chat.roomId;- const membersKey = ['chat-members', serverId, roomId] as const;+ const membersKey = chatMembersQueryKey(serverId, chat);const members = useQuery({queryKey: membersKey,queryFn: () => rpc.chats.members(serverId, roomId),});- useEffect(- () =>- chatsStore.onChatChange(roomId, () => {- void queryClient.invalidateQueries({ queryKey: ['chat-members', serverId, roomId] });- }),- [queryClient, serverId, roomId]- );const [adding, setAdding] = useState<'agent' | 'person' | null>(null);const [removing, setRemoving] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.test.tsindex f59463187..0d17dbbe5 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.test.ts@@ -61,7 +61,7 @@ const chat = (roomId: string, extra: Partial<ChatSummary> = {}): ChatSummary =>channelName: null,agents: [agent],canManage: false,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: null,...extra,});diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-agent-conversations.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-agent-conversations.test.tsindex 5fb475eca..2a80bdbe6 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-agent-conversations.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-agent-conversations.test.ts@@ -22,7 +22,7 @@ const summary = (overrides: Partial<ChatSummary>): ChatSummary => ({channelName: null,agents: [],canManage: false,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: null,...overrides,});diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.tsindex 8037f8662..ffd7f043f 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts@@ -2,7 +2,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { createElement } from 'react';import { renderToStaticMarkup } from 'react-dom/server';import { describe, expect, it, vi } from 'vitest';-import { RoomConfigurationPanel } from '@renderer/features/switch-rooms/room-configuration-panel';+import {+ chatMembersQueryKey,+ RoomConfigurationPanel,+} from '@renderer/features/switch-rooms/room-configuration-panel';import type { ChatSummary } from '@shared/core/chats/chats';const chat = vi.hoisted(() => ({ current: null as ChatSummary | null }));@@ -37,16 +40,15 @@ function render(canManage: boolean): string {agents: [agent],canManage,ownsAgent: false,+ memberUserIds: ['u1', 'u2'],+ memberCount: 2,lastMessage: null,};const client = new QueryClient();- client.setQueryData(- ['chat-members', 's', 'r'],- [- { userId: 'u1', name: 'Alice', isOwner: true },- { userId: 'u2', name: 'Bob', isOwner: false },- ]- );+ client.setQueryData(chatMembersQueryKey('s', chat.current), [+ { userId: 'u1', name: 'Alice', isOwner: true },+ { userId: 'u2', name: 'Bob', isOwner: false },+ ]);return renderToStaticMarkup(createElement(QueryClientProvider,@@ -78,3 +80,24 @@ describe('RoomConfigurationPanel for a group chat', () => {expect(html).not.toContain('aria-label="Remove');});});++describe('chatMembersQueryKey', () => {+ it('reads the members again on an add, a removal or a swap, not on a new message', () => {+ render(true);+ const base = chat.current!;+ const key = (memberUserIds: string[], extra: Partial<ChatSummary> = {}) =>+ chatMembersQueryKey('s', {+ ...base,+ memberUserIds,+ memberCount: memberUserIds.length,+ ...extra,+ });+ const now = key(['u1', 'u2']);+ expect(key(['u1', 'u2', 'u3'])).not.toEqual(now);+ expect(key(['u1'])).not.toEqual(now);+ expect(key(['u1', 'u3'])).not.toEqual(now);+ expect(+ key(['u1', 'u2'], { lastMessage: { seq: 9, sentAt: '', preview: 'hi', senderName: 'Bob' } })+ ).toEqual(now);+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-titler.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-titler.test.tsindex a8cb18759..57df553d4 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-titler.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-titler.test.ts@@ -11,7 +11,7 @@ function summary(roomId: string, channelType: ChatSummary['channelType'] = 'direchannelName: null,agents: [{ id: 'a1', name: 'ada', displayName: null, iconUrl: null, provider: null, alias: null, ownerName: null, ownedByViewer: false }],canManage: true,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: null,};}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.tsindex e477f8747..e06938aa5 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts@@ -22,7 +22,7 @@ function summary(roomId: string, seq: number): ChatSummary {channelName: null,agents: [{ id: 'a1', name: 'ada', displayName: null, iconUrl: null, provider: null, alias: null, ownerName: null, ownedByViewer: false }],canManage: true,- ownsAgent: false,+ ownsAgent: false, memberUserIds: [], memberCount: 0,lastMessage: { seq, sentAt: '2026-01-01T00:00:00Z', preview: 'hi', senderName: 'Ada' },};}@@ -282,24 +282,6 @@ async function viewer() {}describe('ChatsStore membership', () => {- it('tells a viewer with the chat open when the feed changes it, without reopening', async () => {- const alice = await viewer();- const bob = await viewer();- const seen = { alice: 0, bob: 0 };- const stopAlice = alice.store.onChatChange('g', () => seen.alice++);- const stopBob = bob.store.onChatChange('g', () => seen.bob++);- // The server re-announces the chat to both members after Alice changes it.- const changed = { ...bob.group, agents: [] };- alice.push(changed);- bob.push(changed);- bob.push({ ...changed, roomId: 'other' });- expect(seen).toEqual({ alice: 1, bob: 1 });- stopBob();- bob.push({ ...changed, name: 'renamed' });- expect(seen.bob).toBe(1);- stopAlice();- });-it('keeps both of two quick agent removals and a feed update in between', async () => {const { store, push, group } = await viewer();const a = (id: string) => ({ ...group.agents[0], id });diff --git a/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts b/console/apps/switch-console-desktop/src/shared/core/chats/chats.tsindex 39497f9e1..a84fcc09a 100644--- a/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts+++ b/console/apps/switch-console-desktop/src/shared/core/chats/chats.ts@@ -29,6 +29,9 @@ export const chatSummarySchema = z.object({canManage: z.boolean(),/** The viewer owns one of the agents, which keeps them in the room: they cannot leave it. */ownsAgent: z.boolean().default(false),+ /** The people in the chat, by user id, sorted. */+ memberUserIds: z.array(z.string()),+ memberCount: z.number().int(),lastMessage: z.object({seq: z.number().int(),