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): re-ask for sign-in options when connectivity returns (CHOO-2042)

Louis Amaudruza8a0254eebaf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3117af9ac..451748375 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -301,6 +301,18 @@ version of their own to them without also giving them a release of their own.
so switchdash-launched Codex sessions run the published runtime. Ships in the
next switchdash release.
+#### Fixed
+- The server page no longer sits on _"Checking sign-in options…"_ forever after
+ connectivity returns. Which login methods a server offers was read once when
+ the page mounted, and a read that failed was never retried, so a blip left the
+ sign-in form unrendered until you navigated away or restarted. It now recovers
+ 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).
+
### [0.19.3] - 2026-08-09
#### Added
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.tsx
index a9de11acd..c48ad2f8c 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
@@ -43,7 +43,7 @@ export const ServersSidebarSection = observer(function ServersSidebarSection() {
void store.init();
void localServerStore.init();
void remoteServerStore.init();
- const onFocus = () => void store.refreshAllStatuses();
+ const onFocus = () => void store.recoverStale();
window.addEventListener('focus', onFocus);
return () => {
window.removeEventListener('focus', onFocus);
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
new file mode 100644
index 000000000..c95535b68
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
@@ -0,0 +1,230 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+
+const getAuthConfig = vi.hoisted(() => vi.fn());
+const getConnectionStatus = vi.hoisted(() => vi.fn());
+const listServers = vi.hoisted(() => vi.fn());
+const getActiveServerId = vi.hoisted(() => vi.fn());
+const setActiveServer = vi.hoisted(() => vi.fn());
+const removeServer = vi.hoisted(() => vi.fn());
+/** SSH hosts the reachability manager currently considers down. */
+const blockedHosts = vi.hoisted(() => new Set<string>());
+
+vi.mock('@renderer/lib/ipc', () => ({
+ events: { on: vi.fn() },
+ rpc: {
+ switchServers: {
+ getAuthConfig,
+ getConnectionStatus,
+ listServers,
+ getActiveServerId,
+ setActiveServer,
+ removeServer,
+ },
+ },
+}));
+vi.mock('@renderer/features/remote-hosts/host-reachability-store', () => ({
+ hostReachabilityStore: { isBlocked: (sshHost: string) => blockedHosts.has(sshHost) },
+}));
+
+const { SwitchServersStore } = await import('./switch-servers-store');
+
+const authConfig = { passwordLoginEnabled: true, oidcEnabled: false, oidcProviderLabel: null };
+
+function server(id: string, overrides: Partial<SwitchServer> = {}): SwitchServer {
+ return {
+ id,
+ name: id,
+ gatewayUrl: `https://${id}.example.com`,
+ apiUrl: `https://api.${id}.example.com`,
+ managed: false,
+ managementKind: null,
+ sshHost: null,
+ createdAt: '2026-01-01T00:00:00Z',
+ updatedAt: '2026-01-01T00:00:00Z',
+ ...overrides,
+ };
+}
+
+function remoteServer(id: string, sshHost: string): SwitchServer {
+ return server(id, { managed: true, managementKind: 'remote', sshHost });
+}
+
+function newStore(servers: SwitchServer[]) {
+ const store = new SwitchServersStore();
+ store.servers = servers;
+ return store;
+}
+
+/** A promise the test resolves by hand, to hold a fetch in flight. */
+function deferred<T>() {
+ let resolve!: (value: T) => void;
+ const promise = new Promise<T>((r) => {
+ resolve = r;
+ });
+ return { promise, resolve };
+}
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ blockedHosts.clear();
+ getConnectionStatus.mockImplementation(async (serverId: string) => ({
+ serverId,
+ connected: false,
+ user: null,
+ }));
+ getAuthConfig.mockResolvedValue(authConfig);
+});
+
+describe('fetching sign-in options', () => {
+ it('asks again after a failed fetch', async () => {
+ // The bug: one blip while the page mounted left the sign-in panel stuck on
+ // "Checking sign-in options…" for good, because nothing ever re-asked.
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+
+ await store.ensureAuthConfig('srv-a');
+ expect(store.authConfigFor('srv-a')).toBeNull();
+
+ await store.ensureAuthConfig('srv-a');
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+
+ it('does not ask again once it has an answer', async () => {
+ const store = newStore([server('srv-a')]);
+
+ await store.ensureAuthConfig('srv-a');
+ await store.ensureAuthConfig('srv-a');
+
+ expect(getAuthConfig).toHaveBeenCalledTimes(1);
+ });
+
+ it('collapses overlapping asks into one request', async () => {
+ // Several recovery signals can land together — a window focus while the
+ // page is mounting, say. That must not become several identical fetches.
+ const store = newStore([server('srv-a')]);
+ const inFlight = deferred<typeof authConfig>();
+ getAuthConfig.mockReturnValueOnce(inFlight.promise);
+
+ const first = store.ensureAuthConfig('srv-a');
+ const second = store.ensureAuthConfig('srv-a');
+ inFlight.resolve(authConfig);
+ await Promise.all([first, second]);
+
+ expect(getAuthConfig).toHaveBeenCalledTimes(1);
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+});
+
+describe('recovering when connectivity returns', () => {
+ it('re-drives a sign-in fetch that never landed', async () => {
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ await store.ensureAuthConfig('srv-a');
+
+ await store.recoverStale();
+
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+
+ it('leaves servers no login panel has asked about alone', async () => {
+ // Recovery rides the status sweep, which covers every server. Fetching an
+ // auth config for all of them would be new traffic nobody asked for.
+ const store = newStore([server('srv-a'), server('srv-b')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ await store.ensureAuthConfig('srv-a');
+ getAuthConfig.mockClear();
+
+ await store.recoverStale();
+
+ expect(getAuthConfig).toHaveBeenCalledTimes(1);
+ expect(getAuthConfig).toHaveBeenCalledWith('srv-a');
+ });
+
+ it('refreshes connection status as well', async () => {
+ const store = newStore([server('srv-a'), server('srv-b')]);
+
+ await store.recoverStale();
+
+ expect(getConnectionStatus).toHaveBeenCalledWith('srv-a');
+ expect(getConnectionStatus).toHaveBeenCalledWith('srv-b');
+ });
+
+ it('stops retrying a server that was removed', async () => {
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ await store.ensureAuthConfig('srv-a');
+ listServers.mockResolvedValue([]);
+ getActiveServerId.mockResolvedValue(null);
+ removeServer.mockResolvedValue(undefined);
+
+ await store.removeServer('srv-a');
+ getAuthConfig.mockClear();
+ await store.recoverStale();
+
+ expect(getAuthConfig).not.toHaveBeenCalled();
+ });
+});
+
+describe('a server on an unreachable host', () => {
+ it('skips the doomed fetch without raising the error banner', async () => {
+ blockedHosts.add('host-1');
+ const store = newStore([remoteServer('srv-a', 'host-1')]);
+
+ await store.ensureAuthConfig('srv-a');
+
+ expect(getAuthConfig).not.toHaveBeenCalled();
+ expect(store.error).toBeNull();
+ });
+
+ it('is asked again once the host comes back', async () => {
+ // The host un-blocking is the recovery signal here. Before, the page just
+ // swapped the host-unreachable panel for the stuck sign-in panel.
+ blockedHosts.add('host-1');
+ const store = newStore([remoteServer('srv-a', 'host-1')]);
+ await store.ensureAuthConfig('srv-a');
+
+ blockedHosts.delete('host-1');
+ await store.ensureAuthConfig('srv-a');
+
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+});
+
+describe('the manual refresh button', () => {
+ it('re-checks sign-in options, not just connection status', async () => {
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ await store.ensureAuthConfig('srv-a');
+
+ await store.refreshServer('srv-a');
+
+ expect(getConnectionStatus).toHaveBeenCalledWith('srv-a');
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+});
+
+describe('the error banner', () => {
+ it('clears once the sign-in fetch succeeds', async () => {
+ const store = newStore([server('srv-a')]);
+ getAuthConfig.mockRejectedValueOnce(new Error('offline'));
+ await store.ensureAuthConfig('srv-a');
+ expect(store.error).toBe('offline');
+
+ await store.recoverStale();
+
+ 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.
+ const store = newStore([server('srv-a')]);
+ await store.ensureAuthConfig('srv-a');
+ store.error = 'Invalid email or password';
+
+ await store.recoverStale();
+
+ expect(store.error).toBe('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 e091667c7..9bdff3e73 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
@@ -25,6 +25,12 @@ export class SwitchServersStore {
readonly statuses = new Map<string, ServerConnectionStatus>();
/** Auth config per server id, fetched lazily when a login panel needs it. */
readonly authConfigs = new Map<string, SwitchAuthConfig>();
+ /** Server ids a login panel has asked about. A failed or host-blocked fetch
+ * caches nothing, so this is what the recovery paths re-drive. */
+ private readonly authConfigWanted = new Set<string>();
+ /** 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>();
loadingServers = false;
/** Server ids with an in-flight status refresh. */
@@ -98,6 +104,32 @@ export class SwitchServersStore {
await Promise.all(this.servers.map((s) => this.refreshStatus(s.id)));
}
+ /**
+ * Re-drive everything that recovers when connectivity does: the connection
+ * status of every server, plus any auth config a login panel is still waiting
+ * on. Auth config only recovers if something asks again, so it has to ride
+ * the same signals as status rather than being a once-per-mount read.
+ *
+ * Only servers a login panel actually asked about are re-fetched, so this
+ * stays as cheap as the status sweep it accompanies.
+ */
+ async recoverStale(): Promise<void> {
+ const pending = [...this.authConfigWanted].filter((id) => !this.authConfigs.has(id));
+ await Promise.all([
+ this.refreshAllStatuses(),
+ ...pending.map((id) => this.ensureAuthConfig(id)),
+ ]);
+ }
+
+ /**
+ * The server page's manual re-check. Covers both what the status card reads
+ * and what the sign-in panel needs — refreshing only the status leaves a page
+ * that never got its auth config stuck on "Checking sign-in options…".
+ */
+ async refreshServer(serverId: string): Promise<void> {
+ await Promise.all([this.refreshStatus(serverId), this.ensureAuthConfig(serverId)]);
+ }
+
async refreshStatus(serverId: string): Promise<void> {
runInAction(() => {
this.refreshing.add(serverId);
@@ -123,19 +155,44 @@ export class SwitchServersStore {
}
}
+ /**
+ * Fetch which login methods a server offers, unless that is already known.
+ *
+ * Safe to call from every recovery path: a cached config short-circuits, and
+ * concurrent callers collapse into the one in-flight request. A failure
+ * caches nothing, so the next caller retries — which is the point, since the
+ * usual failure is a connectivity blip that later heals (CHOO-2042).
+ */
async ensureAuthConfig(serverId: string): Promise<void> {
+ runInAction(() => {
+ this.authConfigWanted.add(serverId);
+ });
if (this.authConfigs.has(serverId)) return;
+ if (this.authConfigInFlight.has(serverId)) return;
// The gateway of a server on an unreachable host cannot answer, and the
// host-unreachable surface already states why — don't paint the global
- // error banner with a doomed fetch (CHOO-1780).
+ // error banner with a doomed fetch (CHOO-1780). The host un-blocking is
+ // itself a recovery signal, so this is a skip, not a giving up.
if (this.isHostBlocked(serverId)) return;
+ runInAction(() => {
+ this.authConfigInFlight.add(serverId);
+ });
try {
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;
});
} catch (cause) {
this.setError(cause);
+ } finally {
+ runInAction(() => {
+ this.authConfigInFlight.delete(serverId);
+ });
}
}
@@ -236,6 +293,7 @@ export class SwitchServersStore {
this.activeServerId = activeServerId;
this.statuses.delete(serverId);
this.authConfigs.delete(serverId);
+ this.authConfigWanted.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 2d115f3b1..6989448d2 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
@@ -83,11 +83,17 @@ const ServerMainPanel = observer(function ServerMainPanel() {
void hostReachabilityStore.hydrate();
}, []);
+ // A blocked host answers nothing and this page renders the host-unreachable
+ // panel instead, so neither read below has a consumer while it is down.
+ // Reading it here also makes the host un-blocking a recovery signal: the
+ // effect re-runs and finally fetches what it skipped (CHOO-2042).
+ const hostBlocked = store.isHostBlocked(serverId);
+
useEffect(() => {
- if (!detailsVisible) return;
+ if (!detailsVisible || hostBlocked) return;
void store.refreshStatus(serverId);
void store.ensureAuthConfig(serverId);
- }, [serverId, store, detailsVisible]);
+ }, [serverId, store, detailsVisible, hostBlocked]);
if (!server) {
return (
@@ -216,7 +222,7 @@ const ServerMainPanel = observer(function ServerMainPanel() {
variant="outline"
size="sm"
disabled={refreshing}
- onClick={() => void store.refreshStatus(serverId)}
+ onClick={() => void store.refreshServer(serverId)}
>
<RefreshCw className="size-4" />
Refresh