fix(ui): stop reconnect loop on auth failure, surface login gate

This commit is contained in:
Val Alexander
2026-02-22 05:49:53 -06:00
parent e80c803fa8
commit 79ae8148f7
2 changed files with 12 additions and 0 deletions

View File

@@ -170,6 +170,11 @@ export function connectGateway(host: GatewayHost) {
return;
}
host.connected = false;
// Code 1008 = Policy Violation (auth failure) — show the gateway's reason directly
if (code === 1008) {
host.lastError = reason || "Authentication failed. Check your gateway token.";
return;
}
// Code 1012 = Service Restart (expected during config saves, don't show as error)
if (code !== 1012) {
host.lastError = `disconnected (${code}): ${reason || "no reason"}`;

View File

@@ -109,6 +109,13 @@ export class GatewayBrowserClient {
this.ws = null;
this.flushPending(new Error(`gateway closed (${ev.code}): ${reason}`));
this.opts.onClose?.({ code: ev.code, reason });
// 1008 = Policy Violation (gateway auth rejection).
// Don't auto-reconnect on auth failures — surface the login gate
// so the user can fix their token/password instead of looping.
if (ev.code === 1008) {
this.closed = true;
return;
}
this.scheduleReconnect();
});
this.ws.addEventListener("error", () => {