From 8fa62985b9200dc5a39332ecf8716cd44e8356b6 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 27 Mar 2026 10:13:26 +0000 Subject: [PATCH] fix: preserve tui local auth with url overrides --- src/tui/gateway-chat.test.ts | 22 ++++++++++++++++++++++ src/tui/gateway-chat.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/tui/gateway-chat.test.ts b/src/tui/gateway-chat.test.ts index 9d12b42a786..b41e82f4f96 100644 --- a/src/tui/gateway-chat.test.ts +++ b/src/tui/gateway-chat.test.ts @@ -368,6 +368,28 @@ describe("resolveGatewayConnection", () => { const result = await resolveGatewayConnection({}); expect(result.allowInsecureLocalOperatorUi).toBe(true); }); + + it("preserves insecure local operator ui auth when a loopback url override is provided", async () => { + loadConfig.mockReturnValue({ + gateway: { + mode: "local", + controlUi: { + allowInsecureAuth: true, + }, + auth: { + mode: "token", + token: "config-token", + }, + }, + }); + + const result = await resolveGatewayConnection({ + url: "ws://127.0.0.1:18791", + token: "override-token", + }); + expect(result.allowInsecureLocalOperatorUi).toBe(true); + expect(result.token).toBe("override-token"); + }); }); describe("GatewayChatClient", () => { diff --git a/src/tui/gateway-chat.ts b/src/tui/gateway-chat.ts index 9c50efe1f06..d3ebd5407e4 100644 --- a/src/tui/gateway-chat.ts +++ b/src/tui/gateway-chat.ts @@ -310,7 +310,7 @@ export async function resolveGatewayConnection( url, token: explicitAuth.token, password: explicitAuth.password, - allowInsecureLocalOperatorUi: false, + allowInsecureLocalOperatorUi, }; }