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): read an agent's name from the database, not the gateway (CHOO-1943)
Louis Amaudruzbbd4d281537b
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-session-settings-section.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-session-settings-section.tsxindex fdc21b0c8..25c6cad9a 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-session-settings-section.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-session-settings-section.tsx@@ -1,6 +1,5 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import { useState } from 'react';-import { useRemoteAgentName } from '@renderer/features/switch-servers/use-remote-agent-name';import { rpc } from '@renderer/lib/ipc';import { Field, FieldDescription, FieldTitle } from '@renderer/lib/ui/field';import { Switch } from '@renderer/lib/ui/switch';@@ -53,11 +52,7 @@ export function AutoSessionSettingsSection({key={agent.id}className="flex items-center justify-between gap-3 rounded-md border border-border px-2 py-1.5">- <AgentLabel- serverId={agent.serverId as string}- switchAgentId={agent.switchAgentId as string}- fallback={agent.name}- />+ <AgentLabel name={agent.name} /><AutoSessionSwitch agentId={agent.id} /></div>))}@@ -67,17 +62,9 @@ export function AutoSessionSettingsSection({);}-/** Renders an agent's registered Switch name (not the directory basename). */-function AgentLabel({- serverId,- switchAgentId,- fallback,-}: {- serverId: string;- switchAgentId: string;- fallback: string;-}) {- const name = useRemoteAgentName(serverId, switchAgentId, fallback);+/** Renders an agent's Switch name — the stored one, which is what was+ * registered on the server. */+function AgentLabel({ name }: { name: string }) {return <span className="truncate text-sm">{name}</span>;}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsxindex 6ec3a80ef..b88dfec99 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/agent-item.tsx@@ -18,7 +18,6 @@ import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reacimport { HostTroubleIndicator } from '@renderer/features/remote-hosts/host-trouble-indicator';import { hasSessionError } from '@renderer/features/sessions/stores/session-selectors';import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';-import { useRemoteAgentName } from '@renderer/features/switch-servers/use-remote-agent-name';import { AgentIcon } from '@renderer/lib/components/agent-icon';import { useToast } from '@renderer/lib/hooks/use-toast';import { rpc } from '@renderer/lib/ipc';@@ -64,13 +63,10 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({const agentName = agent.name;const location = getLocationStore(agent.locationId);- // The row is labelled by the agent's registered Switch name; fall back to the- // stored name until (or unless) the lookup resolves.- const label = useRemoteAgentName(- agent.serverId,- agent.switchAgentId,- agent.name || agentName || 'Unnamed agent'- );+ // The agent's name IS its Switch identity: switchdash chose it, registered it+ // under that name, and keys its credentials and definition by it. Reading the+ // stored one is reading the same value the server holds.+ const label = agent.name || agentName || 'Unnamed agent';const expanded = sidebarStore.isGroupExpanded(agentExpandKey(agent.id));const toggle = () => sidebarStore.toggleGroupExpanded(agentExpandKey(agent.id));diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsxindex 2a3433ca3..38d83981c 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/room-agent-row.tsx@@ -3,7 +3,6 @@ import { observer } from 'mobx-react-lite';import { getLocationStore } from '@renderer/features/locations/stores/location-selectors';import { HostTroubleIndicator } from '@renderer/features/remote-hosts/host-trouble-indicator';import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';-import { useRemoteAgentName } from '@renderer/features/switch-servers/use-remote-agent-name';import { AgentIcon } from '@renderer/lib/components/agent-icon';import { useToast } from '@renderer/lib/hooks/use-toast';import { rpc } from '@renderer/lib/ipc';@@ -50,13 +49,9 @@ export const RoomAgentRow = observer(function RoomAgentRow({const location = getLocationStore(agent.locationId);- // Labelled by the agent's registered Switch name — this is a Switch room's- // member list, so the Switch identity is the one that matters here.- const label = useRemoteAgentName(- agent.serverId,- agent.switchAgentId,- agent.name || 'Unnamed agent'- );+ // This is a Switch room's member list, so the Switch identity is what matters+ // — and that is the stored name: it is what was registered on the server.+ const label = agent.name || 'Unnamed agent';const expandKey = roomAgentGroupKey(roomId, agent.id);const expanded = sidebarStore.isGroupExpanded(expandKey);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 c072e533e..86a010cb4 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@@ -20,6 +20,23 @@ import { switchIdentities } from './sidebar-tree-data';*/const ROOM_STATE_RECONCILE_MS = 60_000;+/**+ * Re-read everything the sidebar's trees are built from: this install's agents,+ * their room membership, and the room catalogue.+ *+ * One function for every "catch up with the world" trigger — first paint, window+ * focus, signing in to a server, the background reconcile, the retry button. The+ * bug being fixed here is triggers refreshing different subsets, so they share+ * one.+ */+async function loadSidebarState(force: boolean): Promise<void> {+ await agentsStore.load();+ await Promise.all([+ switchRoomsStore.ensureMembershipsFor(switchIdentities(), { force }),+ switchRoomsStore.loadRoomNames(),+ ]);+}+/*** The sidebar body: loads what both trees read, then hands over to whichever* one the current grouping calls for.@@ -34,22 +51,15 @@ export const SidebarGroupedList = observer(function SidebarGroupedList() {const scrollerRef = useRef<HTMLDivElement>(null);useScrollSelectionIntoView(scrollerRef);- // Live session→room connections, room names and room membership all live on- // the server; pull them once on mount and refresh on focus.useEffect(() => {roomConnectionsStore.ensureLoaded();void hostReachabilityStore.hydrate();- // Room membership is what puts an agent under a room, so it is loaded for- // every agent up front rather than lazily per row.- const loadRooms = async (force: boolean) => {- await agentsStore.load();- await switchRoomsStore.ensureMembershipsFor(switchIdentities(), { force });- };- void loadRooms(false);+ // The servers have to be known before their rooms can be asked for, but the+ // agents and their membership do not wait on that.+ void loadSidebarState(false);void switchServersStore.init().then(() => switchRoomsStore.loadRoomNames());- const onFocus = () => {- void loadRooms(true).then(() => switchRoomsStore.loadRoomNames());- };++ const onFocus = () => void loadSidebarState(true);window.addEventListener('focus', onFocus);// A server that was not connected when the rooms were loaded contributed@@ -62,7 +72,7 @@ export const SidebarGroupedList = observer(function SidebarGroupedList() {.map((s) => s.id).sort().join(','),- () => void loadRooms(true).then(() => switchRoomsStore.loadRoomNames())+ () => void loadSidebarState(true));// Nothing pushes room state to the app: a membership changed from Slack,@@ -71,7 +81,7 @@ export const SidebarGroupedList = observer(function SidebarGroupedList() {// refocuses — so reconcile on a slow timer as well.const reconcile = setInterval(() => {if (document.hidden) return;- void switchRoomsStore.refreshRoomState();+ void loadSidebarState(true);}, ROOM_STATE_RECONCILE_MS);return () => {@@ -132,7 +142,7 @@ const RoomStateDisclosure = observer(function RoomStateDisclosure() {<buttontype="button"className="underline underline-offset-2 hover:text-foreground"- onClick={() => void switchRoomsStore.refreshRoomState()}+ onClick={() => void loadSidebarState(true)}>Retry</button>diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/use-remote-agent-name.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/use-remote-agent-name.tsdeleted file mode 100644index 0fd13fe11..000000000--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/use-remote-agent-name.ts+++ /dev/null@@ -1,31 +0,0 @@-import { useQuery } from '@tanstack/react-query';-import { rpc } from '@renderer/lib/ipc';-import { switchServersStore } from './switch-servers-store';--/**- * The agent's registered Switch name (e.g. `claude-code.my-repo.me`), resolved- * from the gateway. Prefer this over the local `Agent.name`, which is only the- * working-directory basename and does not identify the agent. Falls back to- * `fallback` while loading or when the agent can't be resolved.- *- * A server on an unreachable host is not queried: the name is cosmetic, and one- * row per agent retrying a call that cannot succeed is pure noise. Reading the- * observable here means the queries resume on their own when the host returns.- */-export function useRemoteAgentName(- serverId: string | null | undefined,- switchAgentId: string | null | undefined,- fallback: string-): string {- const hostBlocked = serverId ? switchServersStore.isHostBlocked(serverId) : false;- const query = useQuery({- queryKey: ['remote-agent-name', serverId, switchAgentId],- queryFn: () =>- rpc.switchServers.getRemoteAgent({- serverId: serverId as string,- agentId: switchAgentId as string,- }),- enabled: !!serverId && !!switchAgentId && !hostBlocked,- });- return query.data?.name?.trim() || fallback;-}