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): make manual refresh re-check a server's sign-in options

Wojciech Wojtyniak2870aba59f3a
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 cdc3dd99b..d3a5926b2 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
@@ -235,6 +235,36 @@ describe('the manual refresh button', () => {
expect(getConnectionStatus).toHaveBeenCalledWith('srv-a');
expect(store.authConfigFor('srv-a')).toEqual(authConfig);
});
+
+ it('re-fetches sign-in options even when a config is already cached', async () => {
+ // The bug: once cached, ensureAuthConfig's short-circuit meant Refresh
+ // never asked again — a server that gained OIDC after Console cached
+ // password-only kept showing password-only until the app restarted.
+ const store = newStore([server('srv-a')]);
+ await store.ensureAuthConfig('srv-a');
+ expect(store.authConfigFor('srv-a')).toEqual(authConfig);
+
+ const updatedConfig = {
+ passwordLoginEnabled: true,
+ oidcEnabled: true,
+ oidcProviderLabel: 'WorkOS',
+ };
+ getAuthConfig.mockResolvedValueOnce(updatedConfig);
+
+ await store.refreshServer('srv-a');
+
+ expect(store.authConfigFor('srv-a')).toEqual(updatedConfig);
+ });
+
+ it('does not make the mount path re-fetch a cached config', async () => {
+ const store = newStore([server('srv-a')]);
+ await store.ensureAuthConfig('srv-a');
+ getAuthConfig.mockClear();
+
+ await store.ensureAuthConfig('srv-a');
+
+ expect(getAuthConfig).not.toHaveBeenCalled();
+ });
});
describe('a server that cannot be reached', () => {
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 958970581..4789fad3f 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
@@ -165,7 +165,7 @@ export class SwitchServersStore {
* 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)]);
+ await Promise.all([this.refreshStatus(serverId), this.refreshAuthConfig(serverId)]);
}
async refreshStatus(serverId: string): Promise<void> {
@@ -209,6 +209,26 @@ export class SwitchServersStore {
this.authConfigWanted.add(serverId);
});
if (this.authConfigs.has(serverId)) return;
+ await this.fetchAuthConfig(serverId);
+ }
+
+ /**
+ * 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:
+ * `unreachable` is the disclosed signal that the answer might be out of
+ * date, so dropping the cache would only trade one indefinite state for
+ * another.
+ */
+ async refreshAuthConfig(serverId: string): Promise<void> {
+ runInAction(() => {
+ this.authConfigWanted.add(serverId);
+ });
+ await this.fetchAuthConfig(serverId);
+ }
+
+ private async fetchAuthConfig(serverId: string): Promise<void> {
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