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(switchdash): tell the user to sign in instead of calling it a failure (CHOO-1943)
Louis Amaudruzb077c13a9aba
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-tree.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-tree.tsxindex 63eafc611..d3db97d08 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-tree.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-tree.tsx@@ -61,6 +61,7 @@ const AgentSessions = observer(function AgentSessions({<RoomRowlabel={roomLabel(roomKey)}nameKnown={isRoomNameKnown(roomKey)}+ nameBlockedBySignIn={switchRoomsStore.roomNameBlockedBySignIn(roomKey)}count={roomSessions.length}expanded={roomExpanded}depth={depth}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-tree.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-tree.tsxindex c6d96be1c..2e4b75b36 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-tree.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-tree.tsx@@ -134,6 +134,7 @@ export const RoomTree = observer(function RoomTree() {<RoomRowlabel={roomLabel(roomKey)}nameKnown={isRoomNameKnown(roomKey)}+ nameBlockedBySignIn={switchRoomsStore.roomNameBlockedBySignIn(roomKey)}count={agentsInRoom.length}undrawableCount={switchRoomsStore.undrawableMemberCount(roomKey)}expanded={expanded}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsxindex f1bfbe7ee..7a9048e9e 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx@@ -7,6 +7,7 @@ import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reacimport { switchRoomsStore as roomConnectionsStore } from '@renderer/features/switch-rooms/switch-rooms-store';import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';+import { useNavigate } from '@renderer/lib/layout/navigation-provider';import { sidebarStore } from '@renderer/lib/stores/app-state';import { AgentTree } from './agent-tree';import { RoomTree } from './room-tree';@@ -126,31 +127,67 @@ export const SidebarGroupedList = observer(function SidebarGroupedList() {* look identical otherwise.*/const RoomStateDisclosure = observer(function RoomStateDisclosure() {- const unreadableServers = switchRoomsStore.unreadableServerNames;+ const { navigate } = useNavigate();+ const signedOut = switchRoomsStore.serversNotSignedIn;+ const failed = switchRoomsStore.serversThatFailedToLoad;++ // Being signed out is the whole explanation, so it is said on its own: the+ // memberships that "didn't load" are the same fact, and offering a retry for+ // something only a sign-in can fix sends the user in a circle.+ if (signedOut.length > 0) {+ return (+ <DisclosureBar>+ Sign in to {signedOut.map((s) => s.name).join(', ')} to see{' '}+ {signedOut.length === 1 ? 'its' : 'their'} rooms.{' '}+ <DisclosureAction onClick={() => navigate('server', { serverId: signedOut[0].id })}>+ Sign in+ </DisclosureAction>+ </DisclosureBar>+ );+ }+const unknownMemberships = switchRoomsStore.agentsWithUnknownMembership;- if (unreadableServers.length === 0 && unknownMemberships === 0) return null;+ if (failed.length === 0 && unknownMemberships === 0) return null;const reasons: string[] = [];- if (unreadableServers.length > 0) reasons.push(`couldn’t reach ${unreadableServers.join(', ')}`);+ if (failed.length > 0) reasons.push(`couldn’t reach ${failed.map((s) => s.name).join(', ')}`);if (unknownMemberships > 0) {reasons.push(`${unknownMemberships} ${unknownMemberships === 1 ? 'agent’s' : 'agents’'} rooms didn’t load`);}+ return (+ <DisclosureBar>+ Rooms may be out of date — {reasons.join('; ')}.{' '}+ <DisclosureAction onClick={() => void loadSidebarState(true)}>Retry</DisclosureAction>+ </DisclosureBar>+ );+});++function DisclosureBar({ children }: { children: React.ReactNode }) {return (<div className="mb-1 flex items-start gap-1.5 rounded-md bg-background-secondary px-2 py-1.5 text-xs text-foreground-muted"><AlertTriangle className="mt-px h-3.5 w-3.5 shrink-0" />- <span className="min-w-0 flex-1">- Rooms may be out of date — {reasons.join('; ')}.{' '}- <button- type="button"- className="underline underline-offset-2 hover:text-foreground"- onClick={() => void loadSidebarState(true)}- >- Retry- </button>- </span>+ <span className="min-w-0 flex-1">{children}</span></div>);-});+}++function DisclosureAction({+ onClick,+ children,+}: {+ onClick: () => void;+ children: React.ReactNode;+}) {+ return (+ <button+ type="button"+ className="underline underline-offset-2 hover:text-foreground"+ onClick={onClick}+ >+ {children}+ </button>+ );+}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsxindex c17214273..ffe0a003e 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx@@ -120,12 +120,16 @@ export function RoomRow({bridgeType = null,undrawableCount = null,nameKnown = true,+ nameBlockedBySignIn = false,}: {label: string;count: number;/** False when `label` is a stand-in because the room's name has not loaded.* Rendered as visibly provisional rather than as the room's name. */nameKnown?: boolean;+ /** True when the name is missing because the room's server is signed out —+ * something to act on, not to wait for. */+ nameBlockedBySignIn?: boolean;/** Members the server counts that this install cannot draw — agents* registered on another switchdash, plus any whose membership failed to load.* Disclosed next to the count so a member that exists but cannot be shown is@@ -195,8 +199,9 @@ export function RoomRow({}/><TooltipContent>- This room's name hasn't loaded — its server is disconnected or did not- respond. Shown by id until it does.+ {nameBlockedBySignIn+ ? 'Sign in to this room’s server to see its name. Shown by id until then.'+ : 'This room’s name hasn’t loaded yet — shown by id until it does.'}</TooltipContent></Tooltip>)}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsxindex f5435065c..a9de11acd 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx@@ -32,6 +32,7 @@ import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';import { SidebarMenu, SidebarMenuButton } from '../sidebar/sidebar-primitives';import { localServerStore } from './local-server-store';import { remoteServerStore } from './remote-server-store';+import { serverAvailability } from './server-availability';import { switchServersStore } from './switch-servers-store';export const ServersSidebarSection = observer(function ServersSidebarSection() {@@ -212,15 +213,9 @@ const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: stri// session, or room must not clear the "this server is selected" affordance.const isScoped = store.activeServerId === serverId;- // A managed server that isn't running has no gateway to reach, so it can't be- // signed into — show it as dormant (grey dot, no sign-in) until it's started.- const managedRunning = !server.managed- ? true- : server.managementKind === 'remote' && server.sshHost- ? remoteServerStore.isRunning(server.sshHost)- : localServerStore.isRunning;- const dormant = server.managed && !managedRunning;- const needsSignIn = !dormant && !connected;+ const availability = serverAvailability(serverId);+ const dormant = availability === 'dormant';+ const needsSignIn = availability === 'signed-out';// Drift is reported for a stopped stack too — its volumes still hold the// schema the last version migrated to — so this is deliberately not gated ondiff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/server-availability.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/server-availability.tsnew file mode 100644index 000000000..7846c82cc--- /dev/null+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/server-availability.ts@@ -0,0 +1,33 @@+import { localServerStore } from './local-server-store';+import { remoteServerStore } from './remote-server-store';+import { switchServersStore } from './switch-servers-store';++/**+ * Why a server's data is or is not available right now.+ *+ * - `available` — signed in; its rooms and agents can be read.+ * - `signed-out` — reachable but not signed in. Nothing can be read until the+ * user signs in, so retrying is pointless; the fix is an action they take.+ * - `dormant` — a managed stack that is not running. There is no gateway to+ * sign in to yet, so this is not a sign-in prompt either.+ */+export type ServerAvailability = 'available' | 'signed-out' | 'dormant';++/**+ * A managed server that is not running has no gateway to reach, so it cannot be+ * signed into — it is dormant rather than signed out. Shared by the server rows+ * and anything that reports on a server's data being unavailable, so the two+ * cannot describe the same server differently.+ */+export function serverAvailability(serverId: string): ServerAvailability {+ const server = switchServersStore.servers.find((s) => s.id === serverId);+ if (!server) return 'signed-out';++ const managedRunning = !server.managed+ ? true+ : server.managementKind === 'remote' && server.sshHost+ ? remoteServerStore.isRunning(server.sshHost)+ : localServerStore.isRunning;+ if (server.managed && !managedRunning) return 'dormant';+ return switchServersStore.isConnected(serverId) ? 'available' : 'signed-out';+}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.tsindex 8672a7fc9..8f6a49dc1 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts@@ -15,6 +15,8 @@ vi.mock('@renderer/lib/ipc', () => ({rpc: { switchServers: { listRemoteRooms, listAgentRooms } },}));vi.mock('./switch-servers-store', () => ({ switchServersStore: serversStore }));+vi.mock('./local-server-store', () => ({ localServerStore: { isRunning: true } }));+vi.mock('./remote-server-store', () => ({ remoteServerStore: { isRunning: () => true } }));const { SwitchRoomsStore } = await import('./switch-rooms-store');@@ -131,8 +133,7 @@ describe('listed rooms', () => {const store = new SwitchRoomsStore();await store.loadRoomNames();- expect(store.roomStateIncomplete).toBe(true);- expect(store.unreadableServerNames).toEqual(['Alpha']);+ expect(store.serversThatFailedToLoad.map((s) => s.name)).toEqual(['Alpha']);});it('asks only the active server for its rooms', async () => {@@ -165,12 +166,12 @@ describe('listed rooms', () => {// Search loads every server, so Alpha's failure is on the record...await store.loadRoomsOnAllServers();- expect(store.unreadableServerNames).toEqual(['Alpha']);+ expect(store.serversThatFailedToLoad.map((s) => s.name)).toEqual(['Alpha']);// ...but it must not surface while Beta is the server on screen.serversStore.activeServerId = 'srv-b';- expect(store.roomStateIncomplete).toBe(false);- expect(store.unreadableServerNames).toEqual([]);+ expect(store.serversThatFailedToLoad).toEqual([]);+ expect(store.serversNotSignedIn).toEqual([]);});it('does not report a disconnected server you are not viewing', async () => {@@ -185,24 +186,41 @@ describe('listed rooms', () => {const store = new SwitchRoomsStore();await store.loadRoomsOnAllServers();- expect(store.unreadableServerNames).toEqual([]);+ expect(store.serversNotSignedIn).toEqual([]);serversStore.isConnected = () => true;});- it('counts a server it never asked as unknown, not as having no rooms', async () => {+ it('reports a server it is not signed in to as needing sign-in, not as failed', async () => {+ // Signing in is an action the user takes; a retry button cannot fix it, and+ // calling it a failure sends them round in a circle.serversStore.servers = [{ id: 'srv-a', name: 'Alpha' },{ id: 'srv-b', name: 'Beta' },];+ serversStore.activeServerId = 'srv-b';serversStore.isConnected = (serverId: string) => serverId !== 'srv-b';listRemoteRooms.mockImplementation(async () => []);const store = new SwitchRoomsStore();await store.loadRoomNames();- expect(store.roomStateIncomplete).toBe(true);- expect(store.unreadableServerNames).toEqual(['Beta']);+ expect(store.serversNotSignedIn.map((s) => s.name)).toEqual(['Beta']);+ expect(store.serversThatFailedToLoad).toEqual([]);+ serversStore.isConnected = () => true;+ });++ it('marks a room’s name as blocked on sign-in when its server is signed out', async () => {+ serversStore.servers = [{ id: 'srv-a', name: 'Alpha' }];+ serversStore.activeServerId = 'srv-a';+ serversStore.isConnected = () => false;+ listRemoteRooms.mockImplementation(async () => []);++ const store = new SwitchRoomsStore();+ await store.loadRoomNames();++ expect(store.roomNameBlockedBySignIn('some-room')).toBe(true);serversStore.isConnected = () => true;+ expect(store.roomNameBlockedBySignIn('some-room')).toBe(false);});it('clears a server’s failure once it can be read again', async () => {@@ -212,13 +230,12 @@ describe('listed rooms', () => {});const store = new SwitchRoomsStore();await store.loadRoomNames();- expect(store.roomStateIncomplete).toBe(true);+ expect(store.serversThatFailedToLoad.map((s) => s.name)).toEqual(['Alpha']);listRemoteRooms.mockImplementation(async () => [room('back', 'user-of-srv-a')]);await store.loadRoomNames();- expect(store.roomStateIncomplete).toBe(false);- expect(store.unreadableServerNames).toEqual([]);+ expect(store.serversThatFailedToLoad).toEqual([]);});});diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.tsindex d0abb426e..9c72c4a7a 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts@@ -5,6 +5,7 @@ import type {RemoteRoomSummary,} from '@shared/core/switch-servers/switch-servers';import { UNBRIDGED_FILTER_VALUE } from '@shared/view-state';+import { serverAvailability } from './server-availability';import { switchServersStore } from './switch-servers-store';/** Cache key for an agent's room membership: server + Switch agent id. */@@ -282,31 +283,51 @@ export class SwitchRoomsStore {}/**- * Whether the room catalogue on screen is known to be incomplete — a server- * that could not be read, or one that is not connected so was never asked.+ * Whether a room's name is missing because switchdash is not signed in to its+ * server, rather than because the load has not finished.*- * The sidebar renders last-known rooms either way, which is the right call;- * this is what stops it from passing them off as current.+ * The room itself is known — an agent's membership put it there — so the row+ * has to say something. Which of the two it is decides whether the user is+ * being asked to wait or to act.*/- get roomStateIncomplete(): boolean {- return this.unreadableServerNames.length > 0;+ roomNameBlockedBySignIn(roomId: string): boolean {+ const serverId = this.roomServerById.get(roomId) ?? switchServersStore.activeServerId;+ if (!serverId) return false;+ return serverAvailability(serverId) === 'signed-out';}/**- * Names of the servers behind {@link roomStateIncomplete}, for disclosure.+ * Servers on screen whose room list was asked for and failed.*- * Scoped to the servers on screen. A server you are not looking at being- * unreachable says nothing about what you are looking at, and reporting it- * teaches you to ignore the warning.+ * Distinct from {@link serversNotSignedIn}: this is a fault, it may be+ * transient, and retrying is a sensible thing to offer.*/- get unreadableServerNames(): string[] {- const inScope = new Set(this.serverIdsInScope);- const ids = [...new Set([...this.roomListErrors.keys(), ...this.unreachableServerIds])].filter(- (id) => inScope.has(id)+ get serversThatFailedToLoad(): { id: string; name: string }[] {+ return this.namedServersInScope([...this.roomListErrors.keys()]);+ }++ /**+ * Servers on screen that were never asked because switchdash is not signed in+ * to them.+ *+ * Not a fault and not retryable — the user has to sign in. Reporting it as a+ * failure with a retry button offers an action that cannot work.+ */+ get serversNotSignedIn(): { id: string; name: string }[] {+ return this.namedServersInScope(+ this.unreachableServerIds.filter((id) => serverAvailability(id) === 'signed-out'));- return ids- .map((id) => switchServersStore.servers.find((s) => s.id === id)?.name ?? id)- .sort((a, b) => a.localeCompare(b));+ }++ private namedServersInScope(serverIds: string[]): { id: string; name: string }[] {+ const inScope = new Set(this.serverIdsInScope);+ return [...new Set(serverIds)]+ .filter((id) => inScope.has(id))+ .map((id) => ({+ id,+ name: switchServersStore.servers.find((s) => s.id === id)?.name ?? id,+ }))+ .sort((a, b) => a.name.localeCompare(b.name));}/**