Skip to content

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

fix(console): follow managed-agent notices for names from the chat activity wiring

raullopez-sandbox168c0483e8dd
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/activities.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/activities.ts
index f40e70679..80daaf8e6 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/activities.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/activities.ts
@@ -1,3 +1,4 @@
+import { agentNamesChanged } from '@renderer/features/agent-identity/agent-names-changed';
import { changesRooms } from '@renderer/features/switch-servers/room-changing-tools';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { events, rpc } from '@renderer/lib/ipc';
@@ -10,6 +11,7 @@ import {
chatResetChannel,
} from '@shared/core/chats/chatEvents';
import { roomHealthChangedChannel } from '@shared/core/switch-rooms/switchRoomEvents';
+import { userChangesChannel } from '@shared/events/userChangesEvents';
import { AgentActivities } from './chat-activity-store';
import { chatsStore } from './chats';
@@ -61,3 +63,8 @@ events.on(chatRemovedChannel, ({ serverId, roomId, reason }) => {
if (reason === 'access') agentActivities.drop(serverId, roomId);
});
events.on(chatResetChannel, ({ serverId }) => agentActivities.drop(serverId, null));
+// A managed agent changed, maybe its name, which rooms and chats show too.
+events.on(userChangesChannel, (event) => {
+ if (event.type === 'changed' && event.changes.some((change) => change.kind === 'managed_agent'))
+ agentNamesChanged();
+});
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.ts
index e68f77c37..acdb3d12e 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,9 +1,6 @@
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.ts
index 8f2128302..702e0b5cf 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,9 +22,6 @@ 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;
@@ -73,18 +70,6 @@ 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.ts
index 9c5bfd5f3..47074bce6 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,6 +1,5 @@
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';
@@ -41,8 +40,6 @@ function startFeed(queryClient: QueryClient, serverId: string, workspaceId: stri
setLive(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) => {