Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(switchdash): show the host-unreachable panel on a mounted location too (CHOO-1682)

amaudruz5eb31c7226b8
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/main-panel/main-panel.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/main-panel/main-panel.tsx
index 429cb28ff..bae34e117 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/main-panel/main-panel.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/main-panel/main-panel.tsx
@@ -27,11 +27,13 @@ export const LocationMainPanel = observer(function LocationMainPanel() {
return <PendingLocationStatus location={store} />;
}
- // A blocked host outranks every other failure state: the location cannot
- // bootstrap, mount, or find its path while its host is down, and showing the
- // downstream symptom instead of the cause is what CHOO-1682 is about.
+ // A blocked host outranks every other view state, mounted included (CHOO-1682).
+ // A location that mounted before its host went down is still backed by nothing:
+ // its sessions, settings writes and sidecar controls all ride the SSH transport,
+ // so leaving the tabs up offers actions that can only fail. The panel names the
+ // cause instead, and the pane comes back on its own when the host does.
const sshHost = store?.data?.sshHost ?? null;
- if (sshHost && hostReachabilityStore.isBlocked(sshHost) && kind !== 'ready') {
+ if (sshHost && hostReachabilityStore.isBlocked(sshHost)) {
return <HostUnreachablePanel reachability={hostReachabilityStore.get(sshHost)} />;
}
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.tsx
index 036307323..601f0a8e0 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
@@ -1,4 +1,3 @@
-import { useQuery } from '@tanstack/react-query';
import {
Bot,
ChevronRight,
@@ -19,6 +18,7 @@ import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reac
import { 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';
@@ -71,16 +71,11 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
// The row is labelled by the agent's registered Switch name; fall back to the
// stored name until (or unless) the lookup resolves.
- const remoteAgentQuery = useQuery({
- queryKey: ['remoteAgentName', agent.serverId, agent.switchAgentId],
- queryFn: () =>
- rpc.switchServers.getRemoteAgent({
- serverId: agent.serverId!,
- agentId: agent.switchAgentId!,
- }),
- enabled: !!agent.serverId && !!agent.switchAgentId,
- });
- const label = remoteAgentQuery.data?.name?.trim() || agent.name || agentName || 'Unnamed agent';
+ const label = useRemoteAgentName(
+ agent.serverId,
+ agent.switchAgentId,
+ 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.tsx
index b17b538d5..2ce023695 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
@@ -1,9 +1,9 @@
-import { useQuery } from '@tanstack/react-query';
import { Bot, ChevronRight, DoorOpen, Plus } from 'lucide-react';
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';
@@ -52,16 +52,11 @@ export const RoomAgentRow = observer(function RoomAgentRow({
// 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 remoteAgentQuery = useQuery({
- queryKey: ['remoteAgentName', agent.serverId, agent.switchAgentId],
- queryFn: () =>
- rpc.switchServers.getRemoteAgent({
- serverId: agent.serverId!,
- agentId: agent.switchAgentId!,
- }),
- enabled: !!agent.serverId && !!agent.switchAgentId,
- });
- const label = remoteAgentQuery.data?.name?.trim() || agent.name || 'Unnamed agent';
+ const label = useRemoteAgentName(
+ agent.serverId,
+ agent.switchAgentId,
+ 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/switch-servers/use-remote-agent-name.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/use-remote-agent-name.ts
index 7b5706858..0fd13fe11 100644
--- 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.ts
@@ -1,17 +1,23 @@
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,
- switchAgentId: string | null,
+ 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: () =>
@@ -19,7 +25,7 @@ export function useRemoteAgentName(
serverId: serverId as string,
agentId: switchAgentId as string,
}),
- enabled: serverId !== null && switchAgentId !== null,
+ enabled: !!serverId && !!switchAgentId && !hostBlocked,
});
- return query.data?.name ?? fallback;
+ return query.data?.name?.trim() || fallback;
}