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): an unsaved chat's header says New Chat, not the last chat's name
raullopez-sandboxf7174ea19c2a
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/chat-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/chat-view.tsxindex 08b1f92f2..822848eea 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/chat-view.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/chat-view.tsx@@ -12,7 +12,7 @@ import { useOpenGroupAsRoom } from './console-chat-redirect';import { directChats } from './start-direct-chat';import { agentChatsFlag } from './stores/agent-chats-flag';import { chatsStore } from './stores/chats';-import { UNSAVED_CHAT_PREFIX } from './stores/direct-chat-starter';+import { UNSAVED_CHAT_NAME, UNSAVED_CHAT_PREFIX } from './stores/direct-chat-starter';type ChatParams = { serverId: string; roomId: string; agentId: string | null };@@ -29,7 +29,9 @@ const ChatTitlebar = observer(function ChatTitlebar() {{chat ? (<ChatHeaderTitle serverId={params.serverId} chat={chat} />) : (- <span className="text-sm text-foreground-muted">Chat</span>+ <span className="text-sm text-foreground-muted">+ {directChats.unsavedChat(params.roomId) ? UNSAVED_CHAT_NAME : 'Chat'}+ </span>)}</div>}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.tsindex c0861343a..7a3d35f31 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts@@ -3,6 +3,9 @@ import type { ChatSummary } from '@shared/core/chats/chats';/** Prefix of the id a direct chat goes by on screen until its room exists. */export const UNSAVED_CHAT_PREFIX = 'unsaved-chat:';+/** What an unsaved chat is called: the name the server gives a chat made without one. */+export const UNSAVED_CHAT_NAME = 'New Chat';+export type UnsavedChat = {serverId: string;agentId: string;diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsxindex 509435e4f..7d8a10250 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/agent-chats.tsx@@ -133,11 +133,16 @@ function conversationsOf({ serverId, workspaceId, agentId }: ManagedAgentView) {};}-/** The direct chat open on an agent's page: the one in the params, archived or not, else its newest. */+/**+ * The direct chat open on an agent's page: the one in the params, archived or+ * not, else its newest; none while the open chat is unsaved, so nothing of+ * another chat stands in for it.+ */export function openAgentChat(agent: ManagedAgentView,roomId: string | undefined): ChatSummary | null {+ if (roomId && directChats.unsavedChat(roomId)) return null;const { direct, archived } = conversationsOf(agent);return [...direct, ...archived].find((chat) => chat.roomId === roomId) ?? direct[0] ?? null;}diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsxindex 5655bf6b6..97dfb6a2f 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx@@ -4,6 +4,8 @@ import type { ReactNode } from 'react';import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';import { ChatHeaderControls } from '@renderer/features/chats/components/chat-header';import { useAgentActivities } from '@renderer/features/chats/components/chat-panel';+import { directChats } from '@renderer/features/chats/start-direct-chat';+import { UNSAVED_CHAT_NAME } from '@renderer/features/chats/stores/direct-chat-starter';import {embeddedRoomFallbackTab,OpenInMessagingApp,@@ -110,7 +112,10 @@ const ManagedAgentTitlebar = observer(function ManagedAgentTitlebar() {? agentSectionLabel(section): room? (switchRoomsStore.roomNameById(room) ?? room)- : chat?.name}+ : (chat?.name ??+ (params.roomId && directChats.unsavedChat(params.roomId)+ ? UNSAVED_CHAT_NAME+ : null))}</span>{room && (<span className="shrink-0 [-webkit-app-region:no-drag]">diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-chats-sections.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-chats-sections.test.tsxindex f60a8cf54..44c14461c 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-chats-sections.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/agent-chats-sections.test.tsx@@ -99,8 +99,9 @@ vi.mock('@renderer/features/chats/components/chat-panel', async (importOriginal)import '@renderer/index.css';import { runInAction } from 'mobx';+import { directChats } from '@renderer/features/chats/start-direct-chat';import { chatsStore } from '@renderer/features/chats/stores/chats';-import { AgentChats } from '@renderer/features/managed-agents/agent-chats';+import { AgentChats, openAgentChat } from '@renderer/features/managed-agents/agent-chats';import { roomEmbedSlotStore } from '@renderer/features/switch-rooms/room-embed-slot';import { appState } from '@renderer/lib/stores/app-state';import type { ChatSummary } from '@shared/core/chats/chats';@@ -371,6 +372,48 @@ it('follows the open direct chat into its room when it becomes a group, not an o}});+it('opens no other chat in place of an unsaved one, so its header is not that chat’s', () => {+ const previous = {+ roomId: 'previous',+ name: 'QA review',+ channelType: 'direct',+ bridgeType: null,+ channelName: null,+ agents: [+ {+ id: 'agent-1',+ name: 'pm-agent',+ displayName: null,+ iconUrl: null,+ provider: null,+ alias: null,+ ownerName: null,+ ownedByViewer: true,+ },+ ],+ canManage: true,+ ownsAgent: true,+ memberUserIds: [],+ memberCount: 1,+ unreadCount: 0,+ lastMessage: null,+ } satisfies ChatSummary;+ try {+ runInAction(() => {+ chatsStore.serverId = 'server-1';+ });+ chatsStore.upsert(previous);+ const unsaved = directChats.start('server-1', 'agent-1');+ expect(openAgentChat(AGENT, unsaved)).toBeNull();+ expect(openAgentChat(AGENT, undefined)?.roomId).toBe('previous');+ } finally {+ runInAction(() => {+ chatsStore.chats.delete('previous');+ chatsStore.serverId = null;+ });+ }+});+it('offers a new room or an existing one from the Rooms section, with the agent picked', async () => {const { showModal } = await import('@renderer/lib/modal/modal-provider');vi.mocked(showModal).mockClear();