From 6a6c068685645e6f5bfbaf7d24cfd7c3279c4756 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 27 Oct 2026 12:35:38 +0800 Subject: [PATCH] gui: the sidebar's gateway line says the port just applied in Settings, not the one before (noahhrreion on Discord) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gateway address shown at the window's foot differed from the one set. Applying a port in Settings › Gateway address moved the gateway and redrew the Settings row, but the sidebar's gateway line kept the address it had drawn at start (boot.js's, or the Providers list's), as did the list's own gateway URL, until the Providers page was loaded again. Both are now updated from the reply of /api/settings/port. Run (worktree at origin/main 531b44a9a + this): - gateway-port.test.cjs in Chromium and WebKit, en and zh: ok; it now widens the window so the sidebar shows and waits for 127.0.0.1:3591 in its line, with no 3425 left in its tooltip - sidebar, i18n-keys, settings-general, settings-sections, gateway-mode GUI tests: 58 pass, 0 fail - go test -run Budget ./internal/gui/: ok (core script budget not raised) Broken by hand: without the renderSideGw call, gateway-port is red in Chromium (TimeoutError waiting for 3591 in the sidebar line). Not tried: the reporter's own setup. They said "bottom right", and the line is at the sidebar's bottom left, so this is the divergence found, not one confirmed with them. MAGPIE_ADDR and LAN sharing were read in the source and draw from the same gateway.URL(). --- internal/gui/assets/app.js | 5 +++++ internal/gui/tests/gateway-port.test.cjs | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index d254848ba..7f1a0ca03 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -22456,6 +22456,11 @@ function renderPort(s) { const n = res.port?.moved?.length || 0; if (res.port?.error) status(res.port.error, "err"); else status(n ? t("Gateway on port {p}; {n} agents moved with it", { p, n }) : t("Gateway on port {p}", { p }), "ok", 2500); + // the sidebar's gateway line, and the list's address the pages + // copy, say where it is now, not the port before (noahhrreion on + // Discord: it kept the old one until Providers was opened) + if (res.settings?.gateway) renderSideGw({ ...sideGwAt, url: res.settings.gateway, running: true }); + if (providers) loadProviders().catch(() => {}); renderSettings(); }) .catch((e) => { d.value = field.value; d.err = portSays(e.message); status(d.err, "err"); renderSettings(); }); diff --git a/internal/gui/tests/gateway-port.test.cjs b/internal/gui/tests/gateway-port.test.cjs index ed1ed0fef..832435239 100644 --- a/internal/gui/tests/gateway-port.test.cjs +++ b/internal/gui/tests/gateway-port.test.cjs @@ -4,7 +4,8 @@ // 1024 to 65535 can be typed and applied. One out of range is refused in the // page; one another program has is refused with the gateway's reason, in the // page's language, what was typed kept; a free one moves the gateway and -// says how many agents moved with it, and the row then says the new URL. +// says how many agents moved with it, and the row then says the new URL, +// as does the sidebar's gateway line (noahhrreion on Discord). // With MAGPIE_ADDR set the field is off, shows its host:port and says why; // the row is titled an address, not a port, since it shows one there // (Chicring on Discord), and says only the port is typed. The field is an @@ -41,7 +42,7 @@ function server(lang, over, posts) { const req = route.request(); const url = new URL(req.url()); const json = (data, status = 200) => route.fulfill({ status, json: data }); - if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false,sideGateway:{url:"http://127.0.0.1:3425",running:true,boot:true}};` }); if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" }, fx: s.fx }); if (url.pathname === "/api/settings/port") { @@ -172,6 +173,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.waitForFunction((want) => document.querySelector("#portList .sub")?.textContent.trim() === want, w.now("http://127.0.0.1:3591")); assert.equal(await field.inputValue(), "3591"); assert.deepEqual(posts, [3500, 3591]); + // the sidebar's gateway line says the new address too, not the + // port before until Providers is opened (noahhrreion on Discord) + // (the window made wide enough for the sidebar, as the + // reporter's was) + await page.setViewportSize({ width: 1200, height: 360 }); + await page.waitForFunction(() => document.body.classList.contains("side-nav") && !document.querySelector("#sideGw").hidden); + await page.waitForFunction(() => document.querySelector("#sideGw span")?.textContent.includes("127.0.0.1:3591")); + assert(!(await page.locator("#sideGw").getAttribute("title")).includes(":3425"), "the sidebar's tooltip still says 3425"); assert.equal(await scroll(), before, "applying moved the page"); assert.deepEqual(errors, []); }