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(console): disclose a persistently failing sign-in-options check

Wojciech Wojtyniak73fb96370e7f
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-sign-in.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-sign-in.tsx
index 5b9c613ef..06b036be2 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-sign-in.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-sign-in.tsx
@@ -1,3 +1,4 @@
+import { TriangleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useState } from 'react';
import { Button } from '@renderer/lib/ui/button';
@@ -18,6 +19,11 @@ import { switchServersStore } from './switch-servers-store';
export type ServerSignIn = {
/** Which methods the server offers, or null while that is still unknown. */
config: SwitchAuthConfig | null;
+ /** Whether the last attempt to read sign-in options failed. The page never
+ * lets this evict a reachable server (see `isUnreachable` on the store), so
+ * this is the only place that failure is visible — `config` may be a stale
+ * answer from before the endpoint broke, or null if it never succeeded. */
+ configCheckFailed: boolean;
email: string;
password: string;
setEmail: (value: string) => void;
@@ -56,6 +62,7 @@ export function useServerSignIn(serverId: string): ServerSignIn {
return {
config: switchServersStore.authConfigFor(serverId),
+ configCheckFailed: switchServersStore.authConfigCheckFailed(serverId),
email,
password,
setEmail,
@@ -107,11 +114,24 @@ export const ServerSignInFields = observer(function ServerSignInFields({
};
if (!config) {
- return <p className="text-sm text-foreground-muted">Checking sign-in options…</p>;
+ return (
+ <p className="text-sm text-foreground-muted">
+ {signIn.configCheckFailed
+ ? 'Could not check sign-in options.'
+ : 'Checking sign-in options…'}
+ </p>
+ );
}
return (
<div className="flex flex-col gap-4">
+ {signIn.configCheckFailed && (
+ <p className="flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500">
+ <TriangleAlert className="size-3 shrink-0" />
+ Could not check for updated sign-in options — showing what was last known.
+ </p>
+ )}
+
{config.passwordLoginEnabled && (
<div className="flex flex-col gap-3">
<div className="space-y-1.5">
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
index 4eaa39cab..06046cc9e 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
@@ -305,6 +305,42 @@ describe('the reachability flag under concurrent checks', () => {
});
});
+describe('a persistently broken sign-in-options endpoint', () => {
+ it('stays disclosed to the sign-in panel without evicting an otherwise reachable server', async () => {
+ // The durable case, as opposed to the transient one above: the
+ // sign-in-options endpoint never recovers while the server itself stays
+ // fine. isUnreachable must not flip true — once a status read has ever
+ // landed, it is the sole authority, so this failure can never reach it
+ // again — but the failure must still be visible *somewhere*, or the panel
+ // would silently keep showing a stale answer as if it were current,
+ // forever, for the rest of the session.
+ const store = newStore([server('srv-a')]);
+ await store.ensureAuthConfig('srv-a');
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ getAuthConfig.mockRejectedValue(new Error('fetch failed'));
+
+ await store.refreshServer('srv-a');
+ await store.refreshServer('srv-a');
+ await store.refreshServer('srv-a');
+
+ expect(store.isUnreachable('srv-a')).toBe(false);
+ expect(store.authConfigCheckFailed('srv-a')).toBe(true);
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+ });
+
+ it('clears once the endpoint answers again', async () => {
+ const store = newStore([server('srv-a')]);
+ await store.ensureAuthConfig('srv-a');
+ getAuthConfig.mockRejectedValueOnce(new Error('fetch failed'));
+ await store.refreshServer('srv-a');
+ expect(store.authConfigCheckFailed('srv-a')).toBe(true);
+
+ await store.refreshServer('srv-a');
+
+ expect(store.authConfigCheckFailed('srv-a')).toBe(false);
+ });
+});
+
describe('a server that cannot be reached', () => {
it('is flagged when the sign-in read fails', async () => {
const store = newStore([server('srv-a')]);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
index d160b5083..2108cb84a 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
@@ -39,10 +39,16 @@ export class SwitchServersStore {
* {@link authConfigUnreachable} so a hiccup on the sign-in-options endpoint
* cannot evict a server whose status just came back fine. */
readonly statusUnreachable = new Set<string>();
- /** Server ids whose last auth-config read failed. Only decisive before any
- * status read has ever run for that server — the mount-time window where
- * status is still unknown but a totally unreachable gateway has already
- * failed the auth-config call. */
+ /**
+ * Server ids whose last auth-config read failed. Decisive for page-level
+ * reachability only before any status read has ever run for that server —
+ * once one has, {@link isUnreachable} never looks at this again, since a
+ * server can be perfectly reachable while only its sign-in-options endpoint
+ * stays broken. It does not stop mattering there: {@link
+ * authConfigCheckFailed} exposes it separately so the sign-in panel can
+ * disclose a persistently failing check instead of silently reusing a
+ * cached answer forever.
+ */
readonly authConfigUnreachable = new Set<string>();
loadingServers = false;
@@ -104,6 +110,19 @@ export class SwitchServersStore {
return this.authConfigUnreachable.has(serverId);
}
+ /**
+ * Whether the last sign-in-options read failed, regardless of what
+ * {@link isUnreachable} says. A server can be fully reachable — status
+ * fine, maybe even signed in — while its sign-in-options endpoint stays
+ * persistently broken; that failure never gates the page, so this is the
+ * only place it is visible. The sign-in panel reads it to disclose that the
+ * options on screen might be out of date rather than silently offering a
+ * cached answer forever.
+ */
+ authConfigCheckFailed(serverId: string): boolean {
+ return this.authConfigUnreachable.has(serverId);
+ }
+
async init(): Promise<void> {
runInAction(() => {
this.loadingServers = true;
@@ -174,20 +193,25 @@ export class SwitchServersStore {
}
/**
- * 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…".
+ * A manual, explicit re-check: the server page's header button and the
+ * unreachable card's own Retry click. 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…", and a click is a single bounded request, so it can afford the
+ * full check even where the automatic probe below cannot.
*/
async refreshServer(serverId: string): Promise<void> {
await Promise.all([this.refreshStatus(serverId), this.refreshAuthConfig(serverId)]);
}
/**
- * The unreachable card's probe, on its 10-second timer and its own Retry
- * button alike. Only connectivity is worth re-checking on a fixed interval;
- * sign-in options keep the once-cached behavior of {@link ensureAuthConfig}
- * so a genuine outage does not turn into two doomed round trips forever —
- * only one, until either succeeds.
+ * The unreachable card's automatic 10-second timer. Only connectivity is
+ * worth re-checking on a fixed interval; sign-in options keep the
+ * once-cached behavior of {@link ensureAuthConfig} so a genuine outage does
+ * not turn into two doomed round trips on every tick, forever — the panel's
+ * own {@link authConfigCheckFailed} disclosure, plus the card's manual
+ * Retry button, are what re-drive a persistently broken sign-in-options
+ * endpoint instead.
*/
async retryConnection(serverId: string): Promise<void> {
await Promise.all([this.refreshStatus(serverId), this.ensureAuthConfig(serverId)]);
@@ -241,10 +265,11 @@ export class SwitchServersStore {
* Re-fetch a server's login methods even though one is already cached — for
* the manual refresh path, where the cached answer is exactly what might be
* wrong (an operator turning on OIDC after Console cached password-only). A
- * failed refresh leaves the stale config in place rather than clearing it:
- * a server that is otherwise reachable keeps working on what it already
- * knew, and {@link isUnreachable} does not let this failure alone evict a
- * server whose connection status is fine (see {@link authConfigUnreachable}).
+ * failed refresh leaves the stale config in place rather than clearing it,
+ * and {@link isUnreachable} does not let this failure alone evict a server
+ * whose connection status is fine — but the staleness itself is not
+ * silent: {@link authConfigCheckFailed} discloses it to the sign-in panel,
+ * which is the one place still showing what this fetch returned.
*/
async refreshAuthConfig(serverId: string): Promise<void> {
runInAction(() => {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
index b50a5240d..50a6f5a4f 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
@@ -417,7 +417,8 @@ const ServerUnreachableCard = observer(function ServerUnreachableCard({
// something would leave a server that recovered looking down. This only
// re-checks connectivity, not sign-in options: those keep their once-cached
// behavior so a real outage does not turn into two doomed round trips on
- // every tick, forever.
+ // every tick, forever. A single explicit click is a different budget — see
+ // the Retry button below, which pays for the full check.
useEffect(() => {
const timer = setInterval(() => {
if (!document.hidden) void store.retryConnection(serverId);
@@ -438,7 +439,11 @@ const ServerUnreachableCard = observer(function ServerUnreachableCard({
variant="outline"
size="sm"
disabled={retrying}
- onClick={() => void store.retryConnection(serverId)}
+ // A full refreshServer, not the lighter retryConnection the timer
+ // above uses: a click is one bounded request, not a forever-repeating
+ // one, so it can afford to also re-check sign-in options — the one
+ // way a persistently broken sign-in-options endpoint gets re-driven.
+ onClick={() => void store.refreshServer(serverId)}
>
<RefreshCw className={retrying ? 'size-4 animate-spin' : 'size-4'} />
Retry