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): a renamed agent's new name shows in room participants and mentions without a reload
raullopez-sandboxb9e94e4b0576
diff --git a/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.test.ts b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.test.tsnew file mode 100644index 000000000..e3bd0e6ac--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it, vi } from 'vitest';++const refreshSummaries = vi.fn(async () => {});+vi.mock('@renderer/features/chats/stores/chats', () => ({ chatsStore: { refreshSummaries } }));++const { agentNamesChanged } = await import('./agent-names-changed');+const { queryClient } = await import('@renderer/lib/query-client');++describe('agentNamesChanged', () => {+ it('reads again the room participants, chat members, workspace agents and chat summaries', () => {+ const invalidate = vi.spyOn(queryClient, 'invalidateQueries').mockResolvedValue();+ agentNamesChanged();+ expect(invalidate.mock.calls.map(([filters]) => filters?.queryKey)).toEqual([+ ['remote-room-detail'],+ ['chat-members'],+ ['workspace-agents'],+ ]);+ expect(refreshSummaries).toHaveBeenCalledTimes(1);+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.ts b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.tsnew file mode 100644index 000000000..bd3201a31--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/agent-names-changed.ts@@ -0,0 +1,13 @@+import { chatsStore } from '@renderer/features/chats/stores/chats';+import { queryClient } from '@renderer/lib/query-client';++/**+ * An agent's name or display name changed: read again what shows it in rooms+ * and chats, which nothing else refreshes until a reload — the rooms' own+ * participant lists and the chat summaries mention suggestions are read from.+ */+export function agentNamesChanged(): void {+ for (const key of ['remote-room-detail', 'chat-members', 'workspace-agents'])+ void queryClient.invalidateQueries({ queryKey: [key] });+ void chatsStore.refreshSummaries();+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/agent-identity/rename-agent-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/rename-agent-modal.tsxindex ba6081c0b..dcda654cb 100644--- a/console/apps/switch-console-desktop/src/renderer/features/agent-identity/rename-agent-modal.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/agent-identity/rename-agent-modal.tsx@@ -14,6 +14,7 @@ import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';import { Input } from '@renderer/lib/ui/input';import type { AgentRenameOutcome } from '@shared/core/switch-servers/switch-servers';import { labelFollowsName, labelFromName } from './agent-label';+import { agentNamesChanged } from './agent-names-changed';// The server's own rule, checked here only to say so before a round trip.const NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;@@ -100,6 +101,7 @@ export function RenameAgentModal({);}}+ agentNamesChanged();onSuccess({ outcome, localProblem });};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 0506e91e6..8e14af3ae 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@@ -218,6 +218,28 @@ export class ChatsStore {});}+ /**+ * Read every chat's summary again. What a summary says of its agents, such+ * as a name, can change with no message or summary on the feed (an agent+ * renamed), and the participants and mention suggestions are read from it.+ */+ async refreshSummaries(): Promise<void> {+ const serverId = this.serverId;+ if (!serverId) return;+ try {+ const chats = await this.api.list(serverId);+ if (serverId !== this.serverId) return;+ runInAction(() => {+ for (const chat of chats) this.upsert(chat);+ });+ } catch (error) {+ if (serverId !== this.serverId) return;+ runInAction(() => {+ this.listError = failureText(error, 'Your chats could not be listed.');+ });+ }+ }+private relisting = false;private async relist(serverId: string): Promise<void> {diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsxindex 4e9bf2680..c0d4cd2b8 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx@@ -2,6 +2,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query';import { Plus } from 'lucide-react';import { useEffect, useMemo, useState } from 'react';import { AgentIdentityActions } from '@renderer/features/agent-identity/agent-identity-actions';+import { agentNamesChanged } from '@renderer/features/agent-identity/agent-names-changed';import { LocalDirectorySelector } from '@renderer/features/locations/components/add-agent-modal/local-directory-selector';import type {FormState,@@ -155,6 +156,7 @@ function ManagedAgentPageContent({if (edit.displayName !== undefined) {await rpc.workspaces.updateAgentDisplayName({ ...target, displayName: edit.displayName });done.push('its display name');+ agentNamesChanged();}if (edit.description !== undefined) {await rpc.workspaces.updateAgentDescription({ ...target, description: edit.description });diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-managed-agents.test.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-managed-agents.test.tsindex acdb3d12e..fa5ea062b 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-managed-agents.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-managed-agents.test.ts@@ -1,6 +1,7 @@import { describe, expect, it, vi } from 'vitest';import type { ManagedAgentView } from '@shared/core/managed-agents/managed-agents';+vi.mock('@renderer/features/agent-identity/agent-names-changed', () => ({ agentNamesChanged: () => {} }));vi.mock('@renderer/lib/ipc', () => ({ rpc: {} }));vi.mock('@renderer/features/switch-servers/server-availability', () => ({serverAvailability: () => 'available',diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.test.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.test.tsindex 702e0b5cf..8f2128302 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.test.ts@@ -22,6 +22,9 @@ vi.mock('@renderer/features/workspaces/workspaces-store', () => ({workspacesStore: { idOnServerInScope: () => 'w1' },}));+const agentNamesChanged = vi.fn();+vi.mock('@renderer/features/agent-identity/agent-names-changed', () => ({ agentNamesChanged }));+const { useUserChangesLive } = await import('./use-user-changes');(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;@@ -70,6 +73,18 @@ describe('useUserChangesLive', () => {});});expect(invalidate).toHaveBeenCalledTimes(1);+ expect(agentNamesChanged).not.toHaveBeenCalled();++ // A managed agent changed, maybe its name: rooms and chats read it again.+ await act(async () => {+ emit({+ serverId: 's1',+ workspaceId: 'w1',+ type: 'changed',+ changes: [{ kind: 'managed_agent', id: 'a1' }],+ });+ });+ expect(agentNamesChanged).toHaveBeenCalledTimes(1);await act(async () => root.unmount());expect(unwatch).toHaveBeenCalledTimes(1);diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.tsindex 47074bce6..9c5bfd5f3 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/use-user-changes.ts@@ -1,5 +1,6 @@import { type QueryClient, useQueryClient } from '@tanstack/react-query';import { useEffect, useState } from 'react';+import { agentNamesChanged } from '@renderer/features/agent-identity/agent-names-changed';import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { events, rpc } from '@renderer/lib/ipc';import { userChangesChannel } from '@shared/events/userChangesEvents';@@ -40,6 +41,8 @@ function startFeed(queryClient: QueryClient, serverId: string, workspaceId: strisetLive(false);} else {refresh();+ // A managed agent's name may be what changed, which rooms and chats show too.+ if (event.changes.some((change) => change.kind === 'managed_agent')) agentNamesChanged();}});void rpc.userChanges.watch(serverId, workspaceId).then((isLive) => {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 fde7db060..0e41a2122 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@@ -105,6 +105,20 @@ function setup(}describe('ChatsStore', () => {+ it('reads every summary again, so a renamed agent shows its new name', async () => {+ let name = 'ada';+ const { store } = setup(async () => {+ const chat = summary('r1', 1);+ return [{ ...chat, agents: [{ ...chat.agents[0], name }] }];+ });+ await store.connect('s1');+ expect(store.chats.get('r1')?.agents[0].name).toBe('ada');++ name = 'blair';+ await store.refreshSummaries();+ expect(store.chats.get('r1')?.agents[0].name).toBe('blair');+ });+it('stops the feed of the server it no longer follows', async () => {const { store, api } = setup(async () => []);await store.connect('s1');