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): surface failed reasoning polls and chat reconnects (CHOO-3783)
raullopez-sandboxa33977a9225c
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-header.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-header.tsxindex 8ea435afc..3144d2adf 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-header.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-header.tsx@@ -13,6 +13,7 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from '@renderer/lib/ui/dropdown-menu';+import { log } from '@renderer/utils/logger';import { type ChatSummary, chatAgentLabel } from '@shared/core/chats/chats';import type { AgentActivity } from '../stores/chat-activity-store';import { chatsStore } from '../stores/chats';@@ -85,7 +86,17 @@ export const ChatHeaderControls = observer(function ChatHeaderControls({>{stream}{chatsStore.streamState === 'offline' && (- <Button size="sm" variant="ghost" onClick={() => void rpc.chats.connect(serverId)}>+ <Button+ size="sm"+ variant="ghost"+ onClick={() =>+ void rpc.chats.connect(serverId).catch((error: unknown) => {+ const title = failureText(error, 'Could not reconnect the live chat feed.');+ log.warn('Chat feed reconnect failed', { serverId, error: title });+ toast({ title, variant: 'destructive' });+ })+ }+ >Reconnect</Button>)}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-panel.tsxindex 4a59e644b..1be1752b7 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-panel.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-panel.tsx@@ -307,7 +307,9 @@ const ActivityUnavailable = observer(function ActivityUnavailable({const feedDown = activities.length > 0 && agentActivities.feedDown.has(serverId);const tooOld = agentActivities.feedDown.get(serverId) === SERVER_TOO_OLD_FOR_ACTIVITY;const notes = activities.flatMap((activity) =>- [activity.feedError, activity.resolveError].filter((note) => note !== null)+ [activity.feedError, activity.resolveError, activity.reasoningError].filter(+ (note) => note !== null+ ));const unique = [...new Set(notes)].filter((note) => !(feedDown && tooOld && note === SERVER_TOO_OLD_FOR_ACTIVITY)diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-activity-store.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-activity-store.tsindex e057f6d03..4dba357a3 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-activity-store.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-activity-store.ts@@ -1,5 +1,6 @@import { makeAutoObservable, observable, reaction, runInAction } from 'mobx';import { failureText } from '@renderer/lib/errors/describe-failure';+import { log } from '@renderer/utils/logger';import type {ChatActivityItem,ChatActivityTarget,@@ -109,6 +110,8 @@ export class AgentActivity {resolveError: string | null = null;/** Why the room's activity snapshot could not be read; null once it has been. */feedError: string | null = null;+ /** Why the host's reasoning could not be read; null once a read succeeds. */+ reasoningError: string | null = null;readonly items = observable.map<string, ChatActivityItem>({}, { deep: false });readonly approvals = observable.map<string, ChatApproval>({}, { deep: false });/** Retries sent from here, by the failed turn each runs again. */@@ -378,8 +381,24 @@ export class AgentActivity {.filter((turn) => turn.sessionId === target.sessionId).map((turn) => turn.turnId);if (!turnIds.length) return;- const list = await this.api.reasoning(target.hostAgentKey, target.sessionId, turnIds);+ let list: ReasoningList | null;+ try {+ list = await this.api.reasoning(target.hostAgentKey, target.sessionId, turnIds);+ } catch (error) {+ const message = failureText(error, "The agent's reasoning could not be read.");+ if (this.reasoningError === null)+ log.warn('Could not read agent reasoning from its host; retrying while it works', {+ agentId: this.agentId,+ sessionId: target.sessionId,+ error: message,+ });+ runInAction(() => {+ this.reasoningError = message;+ });+ return;+ }runInAction(() => {+ this.reasoningError = null;if (!list) return;for (const turn of list.turns) this.reasoning.set(turn.turnId, turn);for (const turn of list.tools ?? [])diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.tsindex c99cf0740..ff3fb5bf7 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts@@ -22,6 +22,9 @@ import {import type { ChatMessage } from '@shared/core/chats/chats';import { RpcError } from '@shared/lib/ipc/rpc-error';+const warn = vi.hoisted(() => vi.fn());+vi.mock('@renderer/utils/logger', () => ({ log: { warn } }));+let clock = 0;function row(turnId: string,@@ -955,4 +958,33 @@ describe('AgentActivities', () => {expect(activity.toolDetails.get(tool.itemId)).toEqual(tool);activities.release(activity);});++ it('shows a failed reasoning read once, warning once, until a read succeeds', async () => {+ let fail = true;+ const { api } = fakeApi([]);+ api.resolve = async () => ({+ kind: 'session',+ target: 'local',+ hostAgentKey: 'console-a',+ sessionId: 's1',+ });+ api.reasoning = async () => {+ if (fail) throw new Error('Host unreachable');+ return { epoch: 'e1', turns: [] };+ };+ const activities = new AgentActivities(api, memoryStorage());+ const activity = activities.acquire('server', null, 'room-1', 'agent-a');+ await vi.waitFor(() => expect(activity.target?.kind).toBe('session'));+ const turns = [{ ...turnOf([], 'running'), turnId: 't1' }];+ warn.mockClear();+ await activity.readReasoning(turns);+ await activity.readReasoning(turns);+ expect(activity.reasoningError).not.toBeNull();+ expect(warn).toHaveBeenCalledTimes(1);++ fail = false;+ await activity.readReasoning(turns);+ expect(activity.reasoningError).toBeNull();+ activities.release(activity);+ });});