Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: magpie web shows MAGPIE_PUBLIC_URL at the sidebar's foot and in About's Gateway URL, as the Gateway page does (noahhrreion on Discord)
yetone5215108e534f
diff --git a/docs/reference.md b/docs/reference.mdindex 5529897ca..a9100cd91 100644--- a/docs/reference.md+++ b/docs/reference.md@@ -1878,7 +1878,8 @@ URL shown in the console and CLI, including connection examples. Whileother machines are let in (Share on local network, or a `MAGPIE_ADDR` onthe network), the Gateway page's Connect starts at it until you pickanother address there, Settings › About lists it beside the local URL, and-`magpie web` shows it as the gateway's address. Local agent configs still+`magpie web` shows it as the gateway's address: on the Gateway page, in+About's Gateway URL and at the sidebar's foot. Local agent configs stilluse the local gateway address.Building an app or agent that should use magpie, or get a row on thediff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.mdindex d44b7e98b..ffd741cb2 100644--- a/docs/subsystems/gui-shell.md+++ b/docs/subsystems/gui-shell.md@@ -16,7 +16,7 @@ three.| API and assets | `Handler` serves `assets/` (embedded with `//go:embed assets`) and the `/api/*` routes, such as `/api/state`, `/api/set`, `/api/agents/{action}/{id}` and `/api/agents/restart/{id}` (a desktop app's Restart, after the row's confirm). `held` lets one API request's reads share one catalog build (`provider.Hold`), and drops it after any write. `revalidated` and `versionedPage` name each script by its content hash, so a cache never serves an old `app.js` under a new page; a file asked for under its current hash (`?v=`) is cached for good (`immutable`), anything else is revalidated by its ETag. | [`api.go`](../../internal/gui/api.go) || Browser mode | `StartWeb` serves the page and the gateway for `magpie web`. The browser signs in with a run key in a link. Gateway mode shows Providers, Gateway, Routing, Usage, Sessions, Plugins and Settings on a machine that is only a gateway. `webHandler` gzips the page's text files and the API's JSON for a browser that takes gzip (`webCompressed`, with a `-gzip` ETag that still answers 304); the app's own windows read the page in-process and get it uncompressed. The page's port answers the gateway's client routes too (`onePort`, `gateway.ClientPath`: `/v1/…`, `/v1beta/…`, `/mcp/…`, the Codex backend path and the routes without `/v1`; never `/api/*` or `/_magpie/*`, never a path that isn't clean), so one reverse-proxy location serves the page and the agents (zgcwkj on Discord). They skip the page's key and gzip and go to the gateway's own guards: `Server.Front` (lanGuard over Handler) in process when this process serves the gateway, or `toGateway`, a reverse proxy to `gateway.URL()`, when another magpie does; it keeps the Host and the forwarding headers and adds X-Forwarded-For for a peer that isn't loopback, so the other gateway judges the request as it came. See `TestWebOnePortServedHere`, `TestWebOnePortServedElsewhere` and `TestClientPathCoversHandler`. | [`web.go`](../../internal/gui/web.go), [`gatewaymode.go`](../../internal/gui/gatewaymode.go), [`oneport.go`](../../internal/gateway/oneport.go) || The page | `app.js` keeps one state object per view and renders it into a list, with no framework. The views have their own files: `plugins.js` and `context.js`, and those a plugin adds under `assets/plugins/<id>/` (the Gateway, Sessions, Library, Routing and Usage pages, see [plugin runtime](plugin-runtime.md)) (Usage's Context tab, and the context window card the Routing page draws under a request's story, fed by `/api/context` in `context.go`, which scores and tags each agent; clicking a part, a cell or an item opens its text from `/api/context/text`, the last 10 requests' masked bodies in memory (`openCtxText`), rendered 100 items and 20000 characters at a time; its "Tuned for you" cards are fed by `/api/tune` in `tune.go`, see [agent wiring](agent-wiring.md)). Strings go through `t()` with translations in `i18n.js`, and a plugin's own in its `i18n.js` (zh, zh-TW, ja and de; the English text is the key and the fallback). zh-TW is Traditional Chinese with Taiwan's words; a system language of zh-TW, zh-HK, zh-MO or any zh-Hant picks it, and the tray menu and notifications follow (`trayLang`). Dropdowns use `openProtoMenu`. Every app menu (`openProtoMenu`, `openRowMenu`, `openSessCombo`) is placed by `placeMenu`: under its anchor, or over it when the window runs out below; one that fits neither way takes the larger room, its height held to it, and scrolls inside itself, and a scroll inside a menu doesn't close it (#1437, `removed-groups-menu-scroll.test.cjs`). The highest any popover goes is `popTop`: 8px under `header.top` on a Mac window, where the traffic lights are drawn over the page, and 8px from the top elsewhere; `placeMenu`, the field picker's `placePop` (which also holds `#pop`'s height to that room) and an agent's model list (`openAgentModels`) all use it (#1573, `popover-mac-chrome.test.cjs`). Scrolling is done only by `scrollOnPurpose(e)` with the reader's event. | [`assets/app.js`](../../internal/gui/assets/app.js), [`assets/i18n.js`](../../internal/gui/assets/i18n.js) |-| Window navigation | In the window from 1024 points wide (`SIDE_AT`, the same width as app.css's `side-nav` rules), `layoutNav` moves the brand, the pages (`#nav`) and Settings into the sidebar (`#side`): the pages in four groups (Work, Models, Insights, Extend; a group none of whose pages shows, as in gateway mode, leaves out its name), the gateway's address at its foot (`sideGwRead`, read from `/api/providers` only while there is a sidebar), and the header a breadcrumb (`renderCrumb`). A page whose head holds only its tools (Library, Plugins, Settings) has them in the title bar after the breadcrumb, `tools` setting the room between it and the window's own buttons. When they don't fit there the tools show their icons alone (`tools-tight`; each keeps its name as `aria-label` and in its tooltip), then the breadcrumb drops its leading parts, and last the page's name is cut at its end, so no tool lies over the title (#2625, `title-bar-tools.test.cjs`). The open page's own tabs (`NAV_SUBS`: Usage, Library, Plugins, Settings) are listed under it as `.nav-s` rows (`role="tab"`, `data-of` the page tab's id) and the page's strip is hidden; a row's click clicks that tab at once, the selection (`.nav-hl`) having set off as the row was pressed (`navSubGlide`; back if the press leaves the row), and is the list's only shape: a row hovered or pressed has no ground of its own, and a `MutationObserver` draws the list again when the strip changes. A page's tabs share its one scroll, so a row that picks another tab opens it at its top (`scrollOnPurpose` with the row's click); the tab already open, picked again, leaves the page where it is (`sidebar-tab-top.test.cjs`). The list opens and folds with an iOS-like spring (`navSubEnter`, `navSubLeave`; none under reduced motion), and a folding list is out of reach at once. The open page's own row is marked the same way, by one shape (`.nav-top-hl`, the rows' own ground given up to it, hovered or pressed too) that `navTopGo` moves to the row picked on a damped spring, as iOS moves a selection (`NAV_SPRING`, SwiftUI's response 0.42s and damping 0.84; `navTopStep` steps it each frame): it sets off as the row is pressed and comes back if the press leaves the row or the page isn't left, turns with the speed it has when the press changes its mind, and follows its row while the list above it folds, landing where the row ends up. It is put in place, not sent, when the window opens on a page or the rows move under it at rest (a `ResizeObserver`), is away while Settings is open (it has its own selection at the foot), comes back fading in on its row, jumps under reduced motion, and isn't drawn in the header's tabs, which have their `.thumb`. `#nav` is `position: relative` in the sidebar for it, so `.seg`'s centring `left` and `top` are reset. See `sidebar-glide.test.cjs`. Narrower, the page beside a sidebar would be narrower than Usage's requests table needs (768 points), so they go back into the header's row, as a Mac sidebar gives way in a narrow window. At every width the reader can pick the sidebar or the header's tabs from the title bar's button (`#sideToggle`, ⌃⌘S or Ctrl+Shift+S; `toggleSideNav`), kept in localStorage `magpie.navLayout` (`side` or `top`) and so laid out from the first frame; none picked, the sidebar comes from `SIDE_AT`. Picked in a narrow window the sidebar is narrower (184 points under 860), and magpie web on a phone keeps its own tab bar and has no button. The two layouts trade places in a view transition (`navMorph`, app.css `.nav-morph`): the sidebar slides, each page's tab flies to its place in the other, and the page slides as one (its old image dropped, so no line prints twice); without view transitions, under reduced motion, or in the Linux app the change is at once: WebKitGTK with compositing off (`WEBKIT_DISABLE_COMPOSITING_MODE`, which `webkit_linux.go` sets under Wayland) crashes in a view transition. Elsewhere a transition still going after `MORPH_MAX` (1.5s) is skipped, so a webview that never ends one can't leave the window on the old layout's picture. See `side-toggle.test.cjs`. A window made wider or narrower drops what a click held (`heldWidth`): the page laid out again isn't the click's doing. The reader's own place is kept instead for a second while the page is laid out again (`relaid`, a `ResizeObserver` on the open page's parts calling `backToReader`): crossing `SIDE_AT` the browser clamps the scroll to each layout it passes through, and the page ended short of its foot (#1672, `text-size.test.cjs`). See `sidebar.test.cjs`. A sidebar longer than a short window keeps no scroll bar beside its pages: the native bars of `.side-scroll` and `.side-foot` are hidden, and `sideBars` lays a thin bar over each box's edge that shows while it scrolls, fades about a second after it stops (kept while hovered or dragged), can be dragged or clicked to page, and is gone when the box fits, the same in WebKit, WebView2 and WebKitGTK. See `sidebar-overlay-scrollbar.test.cjs`. The window opens on the page the reader last left, as a Mac app comes back as it was (molvqingtai and lc on Discord): `show` keeps the page in localStorage `magpie.lastView` (which the app's webview keeps across restarts, as it keeps `magpie.navLayout`), and `keptView` opens it at start. A page asked for in the address (`?view=`, the tray's links, a reload) wins, Agents too; a kept name that is no page opens the first page, and one gateway mode leaves out opens Providers (`show`). Opening on it scrolls nothing. See `last-page.test.cjs`. | [`assets/app.js`](../../internal/gui/assets/app.js), [`assets/app.css`](../../internal/gui/assets/app.css) |+| Window navigation | In the window from 1024 points wide (`SIDE_AT`, the same width as app.css's `side-nav` rules), `layoutNav` moves the brand, the pages (`#nav`) and Settings into the sidebar (`#side`): the pages in four groups (Work, Models, Insights, Extend; a group none of whose pages shows, as in gateway mode, leaves out its name), the gateway's address at its foot (`sideGwRead`, read from `/api/providers` only while there is a sidebar, or drawn at once from boot.js's `sideGateway`; on a page other machines open, `magpie web`, it is `MAGPIE_PUBLIC_URL` while they are let in, as the Gateway page's address and About's Gateway URL are, noahhrreion on Discord; a port applied in Settings redraws it), and the header a breadcrumb (`renderCrumb`). A page whose head holds only its tools (Library, Plugins, Settings) has them in the title bar after the breadcrumb, `tools` setting the room between it and the window's own buttons. When they don't fit there the tools show their icons alone (`tools-tight`; each keeps its name as `aria-label` and in its tooltip), then the breadcrumb drops its leading parts, and last the page's name is cut at its end, so no tool lies over the title (#2625, `title-bar-tools.test.cjs`). The open page's own tabs (`NAV_SUBS`: Usage, Library, Plugins, Settings) are listed under it as `.nav-s` rows (`role="tab"`, `data-of` the page tab's id) and the page's strip is hidden; a row's click clicks that tab at once, the selection (`.nav-hl`) having set off as the row was pressed (`navSubGlide`; back if the press leaves the row), and is the list's only shape: a row hovered or pressed has no ground of its own, and a `MutationObserver` draws the list again when the strip changes. A page's tabs share its one scroll, so a row that picks another tab opens it at its top (`scrollOnPurpose` with the row's click); the tab already open, picked again, leaves the page where it is (`sidebar-tab-top.test.cjs`). The list opens and folds with an iOS-like spring (`navSubEnter`, `navSubLeave`; none under reduced motion), and a folding list is out of reach at once. The open page's own row is marked the same way, by one shape (`.nav-top-hl`, the rows' own ground given up to it, hovered or pressed too) that `navTopGo` moves to the row picked on a damped spring, as iOS moves a selection (`NAV_SPRING`, SwiftUI's response 0.42s and damping 0.84; `navTopStep` steps it each frame): it sets off as the row is pressed and comes back if the press leaves the row or the page isn't left, turns with the speed it has when the press changes its mind, and follows its row while the list above it folds, landing where the row ends up. It is put in place, not sent, when the window opens on a page or the rows move under it at rest (a `ResizeObserver`), is away while Settings is open (it has its own selection at the foot), comes back fading in on its row, jumps under reduced motion, and isn't drawn in the header's tabs, which have their `.thumb`. `#nav` is `position: relative` in the sidebar for it, so `.seg`'s centring `left` and `top` are reset. See `sidebar-glide.test.cjs`. Narrower, the page beside a sidebar would be narrower than Usage's requests table needs (768 points), so they go back into the header's row, as a Mac sidebar gives way in a narrow window. At every width the reader can pick the sidebar or the header's tabs from the title bar's button (`#sideToggle`, ⌃⌘S or Ctrl+Shift+S; `toggleSideNav`), kept in localStorage `magpie.navLayout` (`side` or `top`) and so laid out from the first frame; none picked, the sidebar comes from `SIDE_AT`. Picked in a narrow window the sidebar is narrower (184 points under 860), and magpie web on a phone keeps its own tab bar and has no button. The two layouts trade places in a view transition (`navMorph`, app.css `.nav-morph`): the sidebar slides, each page's tab flies to its place in the other, and the page slides as one (its old image dropped, so no line prints twice); without view transitions, under reduced motion, or in the Linux app the change is at once: WebKitGTK with compositing off (`WEBKIT_DISABLE_COMPOSITING_MODE`, which `webkit_linux.go` sets under Wayland) crashes in a view transition. Elsewhere a transition still going after `MORPH_MAX` (1.5s) is skipped, so a webview that never ends one can't leave the window on the old layout's picture. See `side-toggle.test.cjs`. A window made wider or narrower drops what a click held (`heldWidth`): the page laid out again isn't the click's doing. The reader's own place is kept instead for a second while the page is laid out again (`relaid`, a `ResizeObserver` on the open page's parts calling `backToReader`): crossing `SIDE_AT` the browser clamps the scroll to each layout it passes through, and the page ended short of its foot (#1672, `text-size.test.cjs`). See `sidebar.test.cjs`. A sidebar longer than a short window keeps no scroll bar beside its pages: the native bars of `.side-scroll` and `.side-foot` are hidden, and `sideBars` lays a thin bar over each box's edge that shows while it scrolls, fades about a second after it stops (kept while hovered or dragged), can be dragged or clicked to page, and is gone when the box fits, the same in WebKit, WebView2 and WebKitGTK. See `sidebar-overlay-scrollbar.test.cjs`. The window opens on the page the reader last left, as a Mac app comes back as it was (molvqingtai and lc on Discord): `show` keeps the page in localStorage `magpie.lastView` (which the app's webview keeps across restarts, as it keeps `magpie.navLayout`), and `keptView` opens it at start. A page asked for in the address (`?view=`, the tray's links, a reload) wins, Agents too; a kept name that is no page opens the first page, and one gateway mode leaves out opens Providers (`show`). Opening on it scrolls nothing. See `last-page.test.cjs`. | [`assets/app.js`](../../internal/gui/assets/app.js), [`assets/app.css`](../../internal/gui/assets/app.css) || Settings › Privacy | The page opens on what masking kept from vendors (`drawMaskObs` in app.js, fed by `/api/masking/summary`): the values masked over 7 or 30 days with a chart of the days, the kinds, what only the local model found, agents to providers, and the values masked most, each shown only while pointed at (`maskTip`, `/api/masking/value`, which says it is gone after a restart). Its records (`drawMaskRecs`, `/api/masking/records` and `/api/masking/record`) take the page's place, filtered by kind, finder, agent or provider, a day at a time, each opening on the text the vendor saw with its placeholders marked. `maskedBadge`, on the Gateway page's recent calls and the Routing page's log, opens a request's own record (`openMaskRecord`), in amber with the count sent as written when every value found was on Warn. Below the card, *What to mask*, *How it's found* (the rules, always on while anything is masked, and the local model on top of them), *When a value is found* (Mask, Warn or Block per kind, the secret kinds first and the personal ones behind *Show all kinds*, and the *Never mask* list; `renderMaskActions`), *Try it* (`renderMaskTry`, the text as the vendor would get it from `/api/masking/preview`, kept in no storage) and *Sharing*. See [gateway routing](gateway-routing.md) for what is recorded. | [`assets/app.js`](../../internal/gui/assets/app.js), [`masking.go`](../../internal/gui/masking.go) || Built-in plugins | Plugins › Built-in, the page's first tab (`drawBuiltin` in `plugins.js`, rows by `renderBuiltins` in `app.js`), lists magpie's built-in plugins, each with a name, a line on what it is and a switch: Routing groups, Library, Observability, Sessions, Warm-up and check-in, and the Gateway and Routing pages (Essential). A plugin on with settings has their rows under its row, drawn from its schema by the kernel's `ui.form`, and a change posts `{id, config}`. The Gateway page is drawn by its plugin's own scripts through the window's kernel (`kernel.js`, `assets/plugins/gateway/`); see the [plugin runtime](plugin-runtime.md), "The window's kernel". They are `plugins/*` registered with the [plugin runtime](plugin-runtime.md); `GET /api/plugins/builtin` says each one (`builtinJSON`: on is active, the user's own choice, what of it is in use) and `POST {id, on}` (or `{id, config}`) writes plugins.yml. A page marks what goes with a plugin `data-feature="<id>"`. Off, `featureStyle` hides everything so marked (rows drawn later too), `navHides` leaves its page's tab out of the sidebar and the header, `show` opens Agents for an address kept for it, and `setSetTab`, `partShows` and `findSettings` leave its Settings tab and rows out, of the search too. One in use stays on: its switch is disabled and the row says what uses it, and the POST refuses it off. A plugins.yml that doesn't parse is said above the list and no switch moves. `boot.js` says which are off (`featuresOff`) and their settings (`pluginConfig`) before the first paint, and `settings.builtins` carries the list on every state read. The TUI doesn't follow them. See `builtins.test.cjs`, `builtins_test.go`. | [`builtins.go`](../../internal/gui/builtins.go), [`assets/plugins.js`](../../internal/gui/assets/plugins.js), [`assets/app.js`](../../internal/gui/assets/app.js) || No GUI build | `-tags nogui` builds magpie without the GUI: `hasGUI` is false and `runGUI` says to use `magpie tui`. The files of `internal/gui` that need Wails build under `!nogui`. | [`gui_off.go`](../../internal/cli/gui_off.go) |diff --git a/internal/gui/api.go b/internal/gui/api.goindex 0a9248103..3ad3c3394 100644--- a/internal/gui/api.go+++ b/internal/gui/api.go@@ -853,7 +853,14 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {// in (#1519's read waits for the agents); only this process's own,// for one served by another magpie is the providers' read to findif served.Load() != nil {- boot["sideGateway"] = map[string]any{"url": gateway.URL(), "running": true, "boot": true}+ side := map[string]any{"url": gateway.URL(), "running": true, "boot": true}+ // and MAGPIE_PUBLIC_URL while other machines are let in, which+ // a page they open (magpie web) shows instead (noahhrreion on+ // Discord: in Docker the line said the container's loopback)+ if u := gateway.PublicURL(); u != "" && (s.LAN || gateway.OnNetwork()) {+ side["publicURL"] = u+ }+ boot["sideGateway"] = side}// and the settings of those the page draws (kernel.js)boot["pluginConfig"] = builtinConfig(list)diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 7f1a0ca03..4c051e7f3 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -19581,9 +19581,11 @@ function renderSettings() {// portable (a data folder beside magpie, #508): everything is in thererow(t("Config folder"), s.portable ? t("Portable: everything magpie keeps, in the data folder beside it") : t("providers, profiles and these settings"), s.dir, copyBtn(s.dir, t("Path")), open);renderCLI(row(t("Command line"), t("Checking your shells…"), ""));- row(t("Gateway URL"), t("the address every agent is pointed at"), s.gateway, copyBtn(s.gateway, t("Gateway URL")));+ // served to other machines (magpie web), the one they reach (noahhrreion)+ const gw = web && s.publicURL || s.gateway;+ row(t("Gateway URL"), t("the address every agent is pointed at"), gw, copyBtn(gw, t("Gateway URL")));// MAGPIE_PUBLIC_URL, where other machines reach it (#1551)- if (s.publicURL) row(t("Public address"), t("MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key"), s.publicURL, copyBtn(s.publicURL, t("Public address"))).id = "publicURLRow";+ if (s.publicURL && gw !== s.publicURL) row(t("Public address"), t("MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key"), s.publicURL, copyBtn(s.publicURL, t("Public address"))).id = "publicURLRow";const join = el("button", "discord");join.innerHTML = DISCORD_SVG;join.append(el("span", "", t("Join Discord")));@@ -24294,8 +24296,11 @@ function renderSideGw(g) {g = sideGwAt;b.hidden = !g?.url;if (b.hidden) return;- let host = g.url;- try { host = new URL(g.url).host; } catch {}+ // a page other machines open (magpie web) says where they reach it,+ // MAGPIE_PUBLIC_URL, as the Gateway page does (#1551; noahhrreion)+ const url = web && g.publicURL || g.url;+ let host = url;+ try { host = new URL(url).host; } catch {}b.classList.toggle("off", !g.running);const s = b.querySelector("span");s.textContent = g.running ? t("Gateway") + " " + host : t("Gateway stopped");@@ -24303,7 +24308,7 @@ function renderSideGw(g) {// gateway leaves it no room ("Zugangspunkt") says the address alone, the// word kept in its tooltipif (g.running && s.scrollWidth > s.clientWidth) s.textContent = host;- b.title = g.running ? t("Gateway") + " " + g.url : g.url;+ b.title = g.running ? t("Gateway") + " " + url : url;}if (mode === "window") {$("#sideGw").onclick = () => { show("gateway"); $("#sideGw").blur(); };diff --git a/internal/gui/builtins_test.go b/internal/gui/builtins_test.goindex c8d17c151..fadcceb62 100644--- a/internal/gui/builtins_test.go+++ b/internal/gui/builtins_test.go@@ -163,6 +163,18 @@ func TestBootSaysWhereItsGatewayListens(t *testing.T) {if b := boot(); !strings.Contains(b, `"sideGateway":{"boot":true,"running":true,"url":"http://127.0.0.1:3483"}`) {t.Fatalf("every interface, reached on loopback: %s", b)}+ // MAGPIE_PUBLIC_URL goes with it while other machines are let in, for+ // magpie web's page to show (noahhrreion on Discord, in Docker), and+ // not while the gateway is this computer's alone+ t.Setenv("MAGPIE_PUBLIC_URL", "http://nas.local:3425")+ if b := boot(); !strings.Contains(b, `"sideGateway":{"boot":true,"publicURL":"http://nas.local:3425","running":true,"url":"http://127.0.0.1:3483"}`) {+ t.Fatalf("on the network, with MAGPIE_PUBLIC_URL: %s", b)+ }+ t.Setenv("MAGPIE_ADDR", "127.0.0.1:3483")+ if b := boot(); strings.Contains(b, "nas.local") {+ t.Fatalf("on loopback, not shared: %s", b)+ }+ t.Setenv("MAGPIE_PUBLIC_URL", "")served.Store(nil)if b := boot(); strings.Contains(b, "sideGateway") {t.Fatalf("stopped: %s", b)diff --git a/internal/gui/tests/fixtures/caller-keys.cjs b/internal/gui/tests/fixtures/caller-keys.cjsindex 66f34ff1c..756046838 100644--- a/internal/gui/tests/fixtures/caller-keys.cjs+++ b/internal/gui/tests/fixtures/caller-keys.cjs@@ -57,7 +57,10 @@ function fixture(lang, theme, events, options = {}) {return async (route) => {const req = route.request(), url = new URL(req.url());const json = (data) => route.fulfill({ json: data });- if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme, web: !!options.web })};` });+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme, web: !!options.web,+ // with options.publicURL, where this process's gateway listens, as+ // magpie's boot.js says it, MAGPIE_PUBLIC_URL with it while shared+ ...(options.publicURL ? { sideGateway: { url: "http://127.0.0.1:3999", running: true, boot: true, ...publicURL() } } : {}) })};` });if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });if (url.pathname === "/favicon.ico") return route.fulfill({ status: 204 });if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme } });diff --git a/internal/gui/tests/public-url-default.test.cjs b/internal/gui/tests/public-url-default.test.cjsindex c1d69e584..4a819e656 100644--- a/internal/gui/tests/public-url-default.test.cjs+++ b/internal/gui/tests/public-url-default.test.cjs@@ -14,7 +14,10 @@ const { openPart } = require("./reader.cjs");// wins after a reload. Served to other machines (magpie web), the// gateway's address and Settings' MCP server show the public URL too; in// the app they stay this computer's. Without MAGPIE_PUBLIC_URL nothing-// changes: Connect starts at this computer's.+// changes: Connect starts at this computer's. The sidebar's gateway line+// and About's Gateway URL follow the same rule (noahhrreion on Discord:+// magpie web in Docker with MAGPIE_PUBLIC_URL, and the line at the foot+// said the container's own address).const PUBLIC = "https://magpie.example.com";const LOCAL = "http://127.0.0.1:3999";const LANGS = ["en", "zh", "zh-TW", "ja", "de"];@@ -64,6 +67,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.doesNotMatch(await shown("#connect pre.snip"), /127\.0\.0\.1/);// in the app, the gateway's own address stays this computer'sassert.equal(await shown("#gateway .url code"), LOCAL);+ if (width >= 1100) assert.match(await shown("#sideGw span"), /127\.0\.0\.1:3999/);await page.locator("#connectAddress").click();assert.match(await page.locator(".proto-menu .pm-item", { hasText: "magpie.example.com" }).textContent(), new RegExp(words[lang]));await fits("Gateway");@@ -95,6 +99,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.equal(await shown("#connectAddress"), PUBLIC + "/v1");await keyed(page, PUBLIC + "/v1");assert.equal(await shown("#gateway .url code"), PUBLIC);+ // the sidebar's line at its foot, there at this width, says it too+ if (width >= 1100) {+ assert.match(await shown("#sideGw span"), /magpie\.example\.com/);+ assert.doesNotMatch(await page.locator("#sideGw").getAttribute("title"), /127\.0\.0\.1/);+ }+ // and About's Gateway URL, with no second row saying the same+ await settingsTab("about");+ await page.locator("#about .row").first().waitFor();+ assert.match(await shown("#about"), /magpie\.example\.com/);+ assert.doesNotMatch(await shown("#about"), /127\.0\.0\.1/);+ assert.equal(await page.locator("#publicURLRow").count(), 0);await settingsTab("models");assert.equal(await shown("#searchMcpRow code"), PUBLIC + "/mcp/magpie/web-search");assert.deepEqual(errors, []);