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): say a server is unreachable once, not three ways (CHOO-2042)

Louis Amaudruzef4a855e36e5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 451748375..8b93c23c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -309,9 +309,15 @@ version of their own to them without also giving them a release of their own.
on the signals connection status already used — the page's Refresh button,
returning to the app window, and a remote host becoming reachable again. The
Refresh button in particular re-checked only the connection status, so the one
- control a user would reach for did nothing visible. A stale error banner now
- clears once the read succeeds, while still leaving a live error such as a
- rejected password on screen (CHOO-2042).
+ control a user would reach for did nothing visible (CHOO-2042).
+- A server whose gateway cannot be reached now says so in one line and retries
+ on its own, instead of stacking three surfaces that each described the same
+ failure differently: a red banner quoting a raw internal error
+ (`Error invoking remote method 'switchServers.getAuthConfig': …`), a
+ "Not signed in" row, and a sign-in panel that claimed to be checking options
+ it would never receive. There is nothing to sign into while the gateway is
+ down, so the sign-in form no longer appears at all. The underlying error goes
+ to the console (CHOO-2042).
### [0.19.3] - 2026-08-09
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
index c95535b68..231e8315a 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
@@ -68,6 +68,8 @@ function deferred<T>() {
beforeEach(() => {
vi.clearAllMocks();
blockedHosts.clear();
+ // The store logs the raw gateway error rather than showing it. Expected here.
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
getConnectionStatus.mockImplementation(async (serverId: string) => ({
serverId,
connected: false,
@@ -204,21 +206,70 @@ describe('the manual refresh button', () => {
});
});
-describe('the error banner', () => {
- it('clears once the sign-in fetch succeeds', async () => {
+describe('a server that cannot be reached', () => {
+ it('is flagged when the sign-in read fails', async () => {
const store = newStore([server('srv-a')]);
- getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ getAuthConfig.mockRejectedValueOnce(new Error('fetch failed'));
+
await store.ensureAuthConfig('srv-a');
- expect(store.error).toBe('offline');
- await store.recoverStale();
+ expect(store.isUnreachable('srv-a')).toBe(true);
+ });
+
+ it('is flagged when the status read fails', async () => {
+ const store = newStore([server('srv-a')]);
+ getConnectionStatus.mockRejectedValueOnce(new Error('fetch failed'));
+
+ await store.refreshStatus('srv-a');
+
+ expect(store.isUnreachable('srv-a')).toBe(true);
+ });
+
+ it('never puts the raw gateway error in the banner', async () => {
+ // What used to reach the user: "Error invoking remote method
+ // 'switchServers.getAuthConfig': GatewayError: ... fetch failed". Our own
+ // IPC method name is not something anyone can act on.
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(
+ new Error("Error invoking remote method 'switchServers.getAuthConfig': fetch failed")
+ );
+
+ await store.ensureAuthConfig('srv-a');
expect(store.error).toBeNull();
});
- it('survives a status refresh, which has no idea whether it is stale', async () => {
- // A rejected password lives in the same field. A background status sweep
- // clearing it would delete the one thing telling the user what went wrong.
+ it('clears the flag once it answers again', async () => {
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('fetch failed'));
+ getConnectionStatus.mockRejectedValueOnce(new Error('fetch failed'));
+ await store.refreshServer('srv-a');
+ expect(store.isUnreachable('srv-a')).toBe(true);
+
+ await store.refreshServer('srv-a');
+
+ expect(store.isUnreachable('srv-a')).toBe(false);
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+
+ it('is flagged per server, not across the app', async () => {
+ const store = newStore([server('srv-a'), server('srv-b')]);
+ getConnectionStatus.mockImplementation(async (serverId: string) => {
+ if (serverId === 'srv-a') throw new Error('fetch failed');
+ return { serverId, connected: false, user: null };
+ });
+
+ await store.refreshAllStatuses();
+
+ expect(store.isUnreachable('srv-a')).toBe(true);
+ expect(store.isUnreachable('srv-b')).toBe(false);
+ });
+});
+
+describe('the error banner', () => {
+ it('survives a background refresh, which cannot tell whether it is stale', async () => {
+ // A rejected password lives in the same field. A background sweep clearing
+ // it would delete the one thing telling the user what went wrong.
const store = newStore([server('srv-a')]);
await store.ensureAuthConfig('srv-a');
store.error = 'Invalid email or password';
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
index 9bdff3e73..64ec5c85b 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
@@ -31,6 +31,10 @@ export class SwitchServersStore {
/** Server ids with an auth-config fetch in flight, so several recovery
* signals arriving at once collapse into a single request. */
private readonly authConfigInFlight = new Set<string>();
+ /** Server ids whose last gateway read failed. The page shows a single
+ * "cannot reach" state for these: with the gateway down there is nothing to
+ * sign into, so a sign-in form would be a dead end dressed up as a choice. */
+ readonly unreachable = new Set<string>();
loadingServers = false;
/** Server ids with an in-flight status refresh. */
@@ -71,6 +75,11 @@ export class SwitchServersStore {
return this.statuses.get(serverId)?.connected ?? false;
}
+ /** Whether the last read of this server's gateway failed to reach it. */
+ isUnreachable(serverId: string): boolean {
+ return this.unreachable.has(serverId);
+ }
+
async init(): Promise<void> {
runInAction(() => {
this.loadingServers = true;
@@ -138,15 +147,18 @@ export class SwitchServersStore {
const status = await rpc.switchServers.getConnectionStatus(serverId);
runInAction(() => {
this.statuses.set(serverId, status);
+ this.unreachable.delete(serverId);
});
- } catch {
+ } catch (cause) {
// An unreachable server is a real, displayable state — record it as
- // disconnected (the per-server status dot shows it). A background poll
- // failure must NOT raise the page-level `error` banner: that field is
- // global, so one unreachable server would paint an error over every
- // server's view.
+ // disconnected (the per-server status dot shows it) and flag the server
+ // so its page can say so in one line. A background poll failure must NOT
+ // raise the page-level `error` banner: that field is global, so one
+ // unreachable server would paint an error over every server's view.
+ console.warn(`[switch-servers] could not read status for ${serverId}`, cause);
runInAction(() => {
this.statuses.set(serverId, { serverId, connected: false, user: null });
+ this.unreachable.add(serverId);
});
} finally {
runInAction(() => {
@@ -181,14 +193,17 @@ export class SwitchServersStore {
const config = await rpc.switchServers.getAuthConfig(serverId);
runInAction(() => {
this.authConfigs.set(serverId, config);
- // An answer means the gateway is reachable again, so a banner left over
- // from the fetch that failed is stale. Only a successful fetch clears
- // it: a background status refresh must not wipe a live error the user
- // still needs to read, such as a rejected password.
- this.error = null;
+ this.unreachable.delete(serverId);
});
} catch (cause) {
- this.setError(cause);
+ // Not the error banner: the raw text is our own IPC method name wrapped
+ // around a fetch failure, which tells the user nothing they can act on.
+ // The page states the one thing that matters, that the server cannot be
+ // reached, and the detail stays in the console for us.
+ console.warn(`[switch-servers] could not read auth config for ${serverId}`, cause);
+ runInAction(() => {
+ this.unreachable.add(serverId);
+ });
} finally {
runInAction(() => {
this.authConfigInFlight.delete(serverId);
@@ -294,6 +309,7 @@ export class SwitchServersStore {
this.statuses.delete(serverId);
this.authConfigs.delete(serverId);
this.authConfigWanted.delete(serverId);
+ this.unreachable.delete(serverId);
});
// Keep a server scoped when any remain (the sidebar scopes to it).
if (!this.activeServerId && servers.length > 0) {
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
index 6989448d2..2da0f99ba 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
@@ -1,4 +1,4 @@
-import { ExternalLink, MoreVertical, Pencil, RefreshCw, Trash2 } from 'lucide-react';
+import { ExternalLink, MoreVertical, Pencil, PlugZap, RefreshCw, Trash2 } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useState } from 'react';
import { type GuardResult, type ViewDefinition } from '@renderer/app/view-registry';
@@ -202,7 +202,11 @@ const ServerMainPanel = observer(function ServerMainPanel() {
<LocalServerControls />
))}
- {detailsVisible && (
+ {detailsVisible && store.isUnreachable(serverId) && (
+ <ServerUnreachableCard serverId={serverId} />
+ )}
+
+ {detailsVisible && !store.isUnreachable(serverId) && (
<>
<div className={`${card} flex items-center justify-between gap-3`}>
<div className="flex items-center gap-2 text-sm">
@@ -264,6 +268,57 @@ const ServerMainPanel = observer(function ServerMainPanel() {
);
});
+/** How often the page re-probes a server it could not reach, while the user is
+ * looking at it. Short enough to feel like it is trying, long enough not to
+ * hammer a gateway that is down. */
+const UNREACHABLE_RETRY_MS = 10_000;
+
+/**
+ * The whole page when a server's gateway cannot be reached. There is nothing to
+ * sign into and no status worth reading, so this replaces both rather than
+ * stacking a red banner on top of a sign-in form that can never work. The raw
+ * gateway error stays in the console: naming our own IPC method at the user
+ * gives them nothing to act on (CHOO-2042).
+ */
+const ServerUnreachableCard = observer(function ServerUnreachableCard({
+ serverId,
+}: {
+ serverId: string;
+}) {
+ const store = switchServersStore;
+ const retrying = store.refreshing.has(serverId);
+
+ // Keep probing while this is on screen. Waiting for the user to press
+ // something would leave a server that recovered looking down.
+ useEffect(() => {
+ const timer = setInterval(() => {
+ if (!document.hidden) void store.refreshServer(serverId);
+ }, UNREACHABLE_RETRY_MS);
+ return () => clearInterval(timer);
+ }, [serverId, store]);
+
+ return (
+ <div className={`${card} flex items-center justify-between gap-3`}>
+ <div className="flex items-center gap-2 text-sm">
+ <PlugZap className="size-4 text-amber-500" />
+ <span className="text-foreground">Cannot reach the server</span>
+ <span className="text-foreground-muted">
+ {retrying ? 'Reconnecting…' : 'Check your connection.'}
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={retrying}
+ onClick={() => void store.refreshServer(serverId)}
+ >
+ <RefreshCw className={retrying ? 'size-4 animate-spin' : 'size-4'} />
+ Retry
+ </Button>
+ </div>
+ );
+});
+
function StatusDot({ connected }: { connected: boolean }) {
return (
<span