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): stop dumping raw discovery errors in the sidebar (CHOO-2972) (#565)
Louis Amaudruz24a5780e2e8b
diff --git a/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.test.ts b/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.test.tsindex 3e0492a85..87e14f0f7 100644--- a/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.test.ts@@ -1,4 +1,8 @@import { beforeEach, afterEach, expect, it, vi } from 'vitest';+import {+ HostUnreachableError,+ unknownHostReachability,+} from '@shared/core/remote-hosts/reachability';import {DISCOVERY_MAX_BACKOFF_MS,DISCOVERY_MS,@@ -280,3 +284,35 @@ it('waits longer after each failed round and returns to its pace once one succeevi.useRealTimers();}});++const downHost = new HostUnreachableError({+ ...unknownHostReachability('hoot-agent-host'),+ status: 'unreachable',+ lastError: 'Connection lost before handshake',+ lastCheckedAt: '2026-09-27T10:52:57.945Z',+});++it('does not report a host that is down, which its agents already show', async () => {+ mocks.list.mockRejectedValueOnce(new Error('Temporarily unavailable'));+ await tick();+ expect(remoteSessionReconciler.errors()).toHaveLength(1);+ mocks.list.mockRejectedValueOnce(downHost);+ await tick();+ expect(remoteSessionReconciler.errors()).toEqual([]);+});++it('does not report a room lookup that failed only because a host is down', async () => {+ mocks.list.mockResolvedValue([{ ...session, roomIds: ['room'] }]);+ mocks.room.mockRejectedValueOnce(downHost);+ await tick();+ expect(mocks.create).not.toHaveBeenCalled();+ expect(remoteSessionReconciler.errors()).toEqual([]);+});++it('reports a failure in its own words, without the exception class', async () => {+ mocks.list.mockRejectedValueOnce(new TypeError('Host listing was not valid JSON.'));+ await tick();+ expect(remoteSessionReconciler.errors()).toEqual([+ { agentId: 'local', message: 'Host listing was not valid JSON.' },+ ]);+});diff --git a/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.ts b/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.tsindex cc84c333a..3c55d10a9 100644--- a/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.ts+++ b/console/apps/switch-console-desktop/src/main/core/agents/remote-session-reconciler.ts@@ -13,6 +13,7 @@ import { events } from '@main/lib/events';import { log } from '@main/lib/logger';import { AGENT_PROVIDER_IDS } from '@shared/core/providers/agent-provider-registry';import { makeHookSessionId } from '@shared/core/providers/hook-session-id';+import { HostUnreachableError } from '@shared/core/remote-hosts/reachability';import { sessionStatusUpdatedChannel } from '@shared/core/sessions/sessionEvents';import { getAgentById } from './getAgentById';@@ -165,7 +166,8 @@ class RemoteSessionReconciler {agent.switchAgentId);} catch (error) {- failures.push(String(error));+ if (error instanceof HostUnreachableError) throw error;+ failures.push(errorMessage(error));}}if (failures.length)@@ -176,7 +178,13 @@ class RemoteSessionReconciler {this.failedRounds.delete(agentId);} catch (error) {this.failedRounds.set(agentId, (this.failedRounds.get(agentId) ?? 0) + 1);- const message = `Session discovery failed: ${String(error)}`;+ // A host that is down already marks each of its agents and clears on its+ // own once the host answers, so it is not a discovery failure of its own.+ if (error instanceof HostUnreachableError) {+ this.failures.delete(agentId);+ return;+ }+ const message = errorMessage(error);const changed = this.failures.get(agentId) !== message;this.failures.set(agentId, message);if (changed)@@ -189,4 +197,8 @@ class RemoteSessionReconciler {}}}+/** The failure's own words, without the exception class `String(error)` puts in front. */+function errorMessage(error: unknown): string {+ return error instanceof Error ? error.message : String(error);+}export const remoteSessionReconciler = new RemoteSessionReconciler();diff --git a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsxindex 8af1cb342..e1cd53a5b 100644--- a/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/remote-hosts/host-trouble-indicator.tsx@@ -60,8 +60,7 @@ export const HostTroubleIndicator = observer(function HostTroubleIndicator({<TooltipContent>{status.kind === 'auth-failed'? `SSH authentication to ${sshHost} failed — work is paused until you retry`- : `Host ${sshHost} is unreachable — work is paused`}- {reachability.lastError ? ` · ${reachability.lastError}` : ''}+ : `Host ${sshHost} is unreachable — work is paused until it answers`}</TooltipContent></Tooltip>);diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsxindex 8eafba01d..1f529a096 100644--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx@@ -33,6 +33,7 @@ import {import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';import { cn } from '@renderer/utils/utils';import type { Agent } from '@shared/core/agents/agents';+import { DiscoveryFailureIndicator } from './discovery-failure-indicator';import { SidebarItemMiniButton, SidebarMenuAction, SidebarMenuRow } from './sidebar-primitives';import { agentExpandKey, depthIndent } from './sidebar-store';@@ -155,6 +156,7 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({Shared with the room-grouped rows so the two trees cannotdisagree about the same agent (CHOO-1682/1809). */}<HostTroubleIndicator sshHost={sshHost} agentId={agent.providerId ?? null} />+ <DiscoveryFailureIndicator agentId={agent.id} label={label} />{agent.providerId && (<ProviderIssueIndicatorproviderId={agent.providerId}diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/discovery-failure-indicator.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/discovery-failure-indicator.tsxnew file mode 100644index 000000000..871b809f2--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/discovery-failure-indicator.tsx@@ -0,0 +1,62 @@+import { useMutation, useQuery } from '@tanstack/react-query';+import { TriangleAlert } from 'lucide-react';+import { describeFailure } from '@renderer/lib/errors/describe-failure';+import { useToast } from '@renderer/lib/hooks/use-toast';+import { rpc } from '@renderer/lib/ipc';+import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';+import { SidebarItemMiniButton } from './sidebar-primitives';++/** Every agent's discovery failure, polled once and shared by all the rows that ask. */+export function useDiscoveryFailures() {+ return useQuery({+ queryKey: ['sdk-discovery-errors'],+ queryFn: () => rpc.sdkHost.discoveryErrors(),+ refetchInterval: 3000,+ });+}++/**+ * A warning on an agent whose sessions could not be read from its host, which+ * retries when clicked. A host that is down is not reported here: the host's+ * own indicator on the same row already says so.+ */+export function DiscoveryFailureIndicator({ agentId, label }: { agentId: string; label: string }) {+ const { toast } = useToast();+ const query = useDiscoveryFailures();+ const retry = useMutation({+ mutationFn: () => rpc.sdkHost.retryDiscovery(agentId),+ onSettled: () => query.refetch(),+ onError: (error) => {+ const { headline, detail } = describeFailure(+ error,+ `Could not retry loading ${label}'s sessions.`+ );+ toast({ title: headline, description: detail ?? undefined, variant: 'destructive' });+ },+ });+ const failure = query.data?.find((entry) => entry.agentId === agentId);+ if (!failure) return null;+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <SidebarItemMiniButton+ type="button"+ aria-label={`Could not load sessions for ${label}. Retry`}+ disabled={retry.isPending}+ onClick={(event) => {+ event.stopPropagation();+ retry.mutate();+ }}+ >+ <TriangleAlert className="h-3.5 w-3.5 shrink-0 text-foreground-warning" />+ </SidebarItemMiniButton>+ }+ />+ <TooltipContent className="max-w-xs">+ <p>Couldn’t load this agent’s sessions — click to retry.</p>+ <p className="mt-1 text-foreground-muted">{failure.message}</p>+ </TooltipContent>+ </Tooltip>+ );+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.test.ts b/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.test.tsdeleted file mode 100644index 27baa1e00..000000000--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.test.ts+++ /dev/null@@ -1,30 +0,0 @@-import { expect, it } from 'vitest';-import { groupDiscoveryFailures } from './group-discovery-failures';--const unreachable = 'Session discovery failed: Could not reach http://localhost:5173';--// A server going down failed discovery for every agent on it, and the sidebar-// rendered one identical banner and retry button per agent.-it('reports one banner for agents that failed for the same reason', () => {- const grouped = groupDiscoveryFailures(- ['a', 'b', 'c', 'd'].map((agentId) => ({ agentId, message: unreachable }))- );- expect(grouped).toEqual([{ message: unreachable, agentIds: ['a', 'b', 'c', 'd'] }]);-});--it('keeps failures apart when their causes differ', () => {- expect(- groupDiscoveryFailures([- { agentId: 'a', message: unreachable },- { agentId: 'b', message: 'Session discovery failed: unsupported provider' },- { agentId: 'c', message: unreachable },- ])- ).toEqual([- { message: unreachable, agentIds: ['a', 'c'] },- { message: 'Session discovery failed: unsupported provider', agentIds: ['b'] },- ]);-});--it('reports nothing when discovery is healthy', () => {- expect(groupDiscoveryFailures([])).toEqual([]);-});diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.ts b/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.tsdeleted file mode 100644index 6a4287fae..000000000--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/group-discovery-failures.ts+++ /dev/null@@ -1,16 +0,0 @@-/**- * Discovery reports a failure per agent, so one unreachable server fills the- * sidebar with the same line once for every agent on it. Agents that failed for- * the same reason share a cause and a retry, so they share a message.- *- * Order follows first appearance, so a banner does not move as other agents- * fail and recover around it.- */-export function groupDiscoveryFailures(- failures: { agentId: string; message: string }[]-): { message: string; agentIds: string[] }[] {- const byMessage = new Map<string, string[]>();- for (const failure of failures)- byMessage.set(failure.message, [...(byMessage.get(failure.message) ?? []), failure.agentId]);- return [...byMessage].map(([message, agentIds]) => ({ message, agentIds }));-}diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsxindex 16346bef2..aa62c7c82 100644--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx@@ -24,6 +24,7 @@ import {import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';import { cn } from '@renderer/utils/utils';import type { Agent } from '@shared/core/agents/agents';+import { DiscoveryFailureIndicator } from './discovery-failure-indicator';import { SidebarItemMiniButton, SidebarMenuAction, SidebarMenuRow } from './sidebar-primitives';import { depthIndent, roomAgentGroupKey } from './sidebar-store';@@ -142,6 +143,7 @@ export const RoomAgentRow = observer(function RoomAgentRow({sshHost={location.data?.sshHost ?? null}agentId={agent.providerId ?? null}/>+ <DiscoveryFailureIndicator agentId={agent.id} label={label} />{agent.providerId && (<ProviderIssueIndicatorproviderId={agent.providerId}diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-discovery-status.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-discovery-status.tsxindex 612172c92..ab704b642 100644--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-discovery-status.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-discovery-status.tsx@@ -1,48 +1,28 @@-import { useMutation, useQuery } from '@tanstack/react-query';-import { observer } from 'mobx-react-lite';-import { agentsStore } from '@renderer/features/locations/stores/agents-store';-import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';-import { rpc } from '@renderer/lib/ipc';import { Button } from '@renderer/lib/ui/button';-import { groupDiscoveryFailures } from './group-discovery-failures';-export const SessionDiscoveryStatus = observer(function SessionDiscoveryStatus() {- const query = useQuery({- queryKey: ['sdk-discovery-errors'],- queryFn: () => rpc.sdkHost.discoveryErrors(),- refetchInterval: 3000,- });- const retry = useMutation({- mutationFn: (agentIds: string[]) =>- Promise.all(agentIds.map((agentId) => rpc.sdkHost.retryDiscovery(agentId))),- onSuccess: () => query.refetch(),- });- const grouped = groupDiscoveryFailures(- (query.data ?? []).filter(- (failure) =>- agentsStore.agentById(failure.agentId)?.serverId === switchServersStore.activeServerId- )- );+import { useDiscoveryFailures } from './discovery-failure-indicator';++/**+ * Console could not ask for discovery failures at all, so no agent row can+ * show its own. Each agent's failure is on its row; this is only the case that+ * belongs to none of them.+ */+export function SessionDiscoveryStatus() {+ const query = useDiscoveryFailures();+ if (!query.error) return null;return (- <>- {(query.error || retry.error) && (- <div role="alert" className="px-3 py-2 text-xs text-foreground-destructive">- Session discovery unavailable: {String(query.error || retry.error)}- </div>- )}- {grouped.map(({ message, agentIds }) => (- <div key={message} role="alert" className="px-3 py-2 text-xs text-foreground-destructive">- {message}- {agentIds.length > 1 && ` (${agentIds.length} agents)`}- <Button- size="sm"- variant="outline"- disabled={retry.isPending}- onClick={() => retry.mutate(agentIds)}- >- Retry discovery- </Button>- </div>- ))}- </>+ <div+ role="alert"+ className="flex items-center justify-between gap-2 px-3 py-2 text-xs text-foreground-warning"+ >+ <span>Couldn’t check your agents’ sessions.</span>+ <Button+ size="sm"+ variant="outline"+ disabled={query.isFetching}+ onClick={() => void query.refetch()}+ >+ Retry+ </Button>+ </div>);-});+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-issue-indicator.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-issue-indicator.tsxindex a86199132..7094bef68 100644--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-issue-indicator.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-issue-indicator.tsx@@ -5,13 +5,16 @@ import { events, rpc } from '@renderer/lib/ipc';import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';import { sessionIssueChangedChannel } from '@shared/core/sessions/sessionEvents';+const ISSUE_TEXT = 'This session couldn’t start or stopped on an error — open it to see why.';+export const sessionIssueQueryKey = (sessionId: string) => ['session-issue', sessionId];/*** A warning on a session row whose start failed or whose host stopped on a- * failure, with the reason in its tooltip. Asked once, then refreshed only- * when main says the session's health changed, so a sidebar full of sessions- * does not poll.+ * failure. The reason itself is shown where it can be acted on — the open+ * session, which can restart it — so the row only says that there is one.+ * Asked once, then refreshed only when main says the session's health changed,+ * so a sidebar full of sessions does not poll.*/export function SessionIssueIndicator({ sessionId }: { sessionId: string }) {const queryClient = useQueryClient();@@ -34,11 +37,11 @@ export function SessionIssueIndicator({ sessionId }: { sessionId: string }) {<Tooltip><TooltipTrigger><TriangleAlert- aria-label={`Session problem: ${issue}`}+ aria-label={ISSUE_TEXT}className="h-3.5 w-3.5 shrink-0 text-foreground-destructive"/></TooltipTrigger>- <TooltipContent>{issue}</TooltipContent>+ <TooltipContent>{ISSUE_TEXT}</TooltipContent></Tooltip>);}