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
feat(switchdash): label sidebar agents by registered Switch name (CHOO-1082) (#24)
Louis Amaudruz87df11b2661a
diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-servers/controller.ts b/dash/apps/switchdash-desktop/src/main/core/switch-servers/controller.tsindex 3fe9d85a9..505bc3682 100644--- a/dash/apps/switchdash-desktop/src/main/core/switch-servers/controller.ts+++ b/dash/apps/switchdash-desktop/src/main/core/switch-servers/controller.ts@@ -28,6 +28,7 @@ import { createRPCController } from '@shared/lib/ipc/rpc';import { type LoginError, oidcLogin, passwordLogin } from './auth';import {agentExistsOnServer,+ fetchAgentDetail,fetchAgentRooms,fetchAgents,fetchAuthConfig,@@ -153,6 +154,12 @@ export const switchServersController = createRPCController({listRemoteAgents: async (serverId: string): Promise<RemoteAgentSummary[]> =>fetchAgents(await requireServer(serverId)),+ getRemoteAgent: async (params: {+ serverId: string;+ agentId: string;+ }): Promise<RemoteAgentSummary> =>+ fetchAgentDetail(await requireServer(params.serverId), params.agentId),+listRemoteRooms: async (serverId: string): Promise<RemoteRoomSummary[]> =>fetchRooms(await requireServer(serverId)),diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-servers/gateway-client.ts b/dash/apps/switchdash-desktop/src/main/core/switch-servers/gateway-client.tsindex 395a38f77..820a1de90 100644--- a/dash/apps/switchdash-desktop/src/main/core/switch-servers/gateway-client.ts+++ b/dash/apps/switchdash-desktop/src/main/core/switch-servers/gateway-client.ts@@ -177,6 +177,39 @@ export async function fetchAgents(server: SwitchServer): Promise<RemoteAgentSumm}));}+/**+ * Fetch one agent's registered detail by id (`GET /agents/{id}`, which returns+ * the gateway `AgentDetail` — a superset of `AgentSummary`). Used to resolve an+ * agent's registered Switch name for display. A 404 surfaces as a `GatewayError`+ * so callers can distinguish "not on this server" from other failures.+ */+export async function fetchAgentDetail(+ server: SwitchServer,+ agentId: string+): Promise<RemoteAgentSummary> {+ const res = await gatewayFetch(server, `/agents/${encodeURIComponent(agentId)}`, {+ authenticated: true,+ });+ const json = (await res.json()) as {+ id: string;+ name: string;+ description: string;+ connector_type: string;+ owner_name: string | null;+ known_agent_type: string | null;+ created_at: string;+ };+ return {+ id: json.id,+ name: json.name,+ description: json.description,+ connectorType: json.connector_type,+ ownerName: json.owner_name,+ knownAgentType: json.known_agent_type,+ createdAt: json.created_at,+ };+}+/*** Whether `agentId` is a registered agent on `server`. Used to verify the user's* chosen server actually owns the agent before linking it. A 404 from thediff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/location-item.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/location-item.tsxindex cb98d2042..e3f285d9b 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/location-item.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/location-item.tsx@@ -75,6 +75,20 @@ export const SidebarLocationItem = observer(function SidebarLocationItem({enabled: !!locationId,});+ // The row is labelled by the agent's registered Switch name (its identity on+ // the server), not the local directory-derived location name. Resolve it by+ // id from the gateway, keyed on (server, switch agent id) so it caches and is+ // shared across rows for the same agent.+ const remoteAgentQuery = useQuery({+ queryKey: ['remoteAgentName', agentQuery.data?.serverId, agentQuery.data?.switchAgentId],+ queryFn: async () =>+ rpc.switchServers.getRemoteAgent({+ serverId: agentQuery.data!.serverId!,+ agentId: agentQuery.data!.switchAgentId!,+ }),+ enabled: !!agentQuery.data?.serverId && !!agentQuery.data?.switchAgentId,+ });+const location = getLocationStore(locationId);const currentLocationId =@@ -97,7 +111,13 @@ export const SidebarLocationItem = observer(function SidebarLocationItem({const iconClass ='absolute h-4 w-4 opacity-100 transition-opacity duration-150 group-hover/row:opacity-0';- const locationLabel = location.name ?? 'agent';+ // Registered Switch name wins. While the lookup is still in flight, keep the+ // local name so the row does not flash; once it settles without a name+ // (server unlinked, agent unregistered, or offline) show a stable placeholder.+ const switchName = remoteAgentQuery.data?.name?.trim() || null;+ const locationLabel =+ switchName ??+ (remoteAgentQuery.isLoading ? (location.name ?? 'Unnamed agent') : 'Unnamed agent');const toggleExpanded = () => sidebarStore.toggleLocationExpanded(locationId);// Clicking the row opens the agent's page (Sessions / Subagents / Settings),@@ -185,7 +205,7 @@ export const SidebarLocationItem = observer(function SidebarLocationItem({)}><span className="flex min-w-0 items-center gap-1.5">- <span className="truncate">{location.name}</span>+ <span className="truncate">{locationLabel}</span>{location.data?.sshHost != null && (<Tooltip><TooltipTrigger>@@ -262,7 +282,7 @@ export const SidebarLocationItem = observer(function SidebarLocationItem({onClick={() => {void confirmDeleteAgent({locationId,- locationLabel: location.name ?? 'this agent',+ locationLabel: switchName ?? location.name ?? 'this agent',onDeleted: () => {if (isLocationActive) navigate('home');},