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)
noahhrreion runs magpie in Docker and sets the gateway's address with MAGPIE_PUBLIC_URL; the address at the foot of the page didn't show it. Since #1551 a page other machines open (magpie web) shows MAGPIE_PUBLIC_URL, while they are let in, as the gateway's address on the Gateway page, starts Connect and its snippets at it, and uses it for Settings' MCP addresses. Two places still said the container's loopback: - the sidebar's gateway line (renderSideGw): it drew providers' and boot.js's `url` only. It now draws `publicURL` in magpie web, and boot.js's `sideGateway` carries it (same rule as settingsState: shared, or MAGPIE_ADDR on the network, as the image's 0.0.0.0 is) - Settings › About's Gateway URL: in magpie web it is the public URL, and the separate Public address row, then the same, is left out In the app on this computer both stay the local address that agents here are pointed at, as before. The address list in Share on local network already gives MAGPIE_PUBLIC_URL alone, and Connect and the copy buttons were already at it. Run (worktree at origin/main11dcc743f+ this, darwin/arm64, load ~150): - go test -count=1 ./internal/gui/: ok (TestBootSaysWhereItsGatewayListens now checks publicURL is in sideGateway on the network and absent on loopback; the script budget tests pass, not raised) - gofmt -l clean; go vet darwin and windows on internal/gui. The linux vet of internal/gui doesn't build Wails without cgo on this Mac, in Wails itself, as on main - public-url-default.test.cjs, Chromium and WebKit, en zh zh-TW ja de, 1100 and 420 wide: 26 pass - the 18 GUI files on the changed caller-keys fixture plus sidebar, gateway-port, i18n-keys, settings-general, settings-sections and settings-search, 3 wide: 322 pass, 4 fail. Rerun 1 wide, 3 passed and gateway-caller-keys webkit stayed red at line 137; it is red 4 of 5 on11dcc743fwithout this change too, #3797. gateway-key-models webkit (#2648) and gateway-own-key zh 440 (#3842, filed now) passed alone. Broken by hand: - renderSideGw back on g.url: public-url-default's magpie web test red at 1100 wide - About back on s.gateway: red at both widths - boot.js without publicURL: TestBootSaysWhereItsGatewayListens red Not tried: a real Docker container with MAGPIE_PUBLIC_URL; the page was driven with a faked API. Not asked of the reporter yet: whether they open magpie web, or the desktop app, which keeps the local address.
This commit is contained in:
+2
-1
@@ -1878,7 +1878,8 @@ URL shown in the console and CLI, including connection examples. While
|
||||
other machines are let in (Share on local network, or a `MAGPIE_ADDR` on
|
||||
the network), the Gateway page's Connect starts at it until you pick
|
||||
another 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 still
|
||||
use the local gateway address.
|
||||
|
||||
Building an app or agent that should use magpie, or get a row on the
|
||||
|
||||
File diff suppressed because one or more lines are too long
+8
-1
@@ -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 find
|
||||
if 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)
|
||||
|
||||
@@ -19581,9 +19581,11 @@ function renderSettings() {
|
||||
// portable (a data folder beside magpie, #508): everything is in there
|
||||
row(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 tooltip
|
||||
if (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(); };
|
||||
|
||||
@@ -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)
|
||||
|
||||
+4
-1
@@ -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 } });
|
||||
|
||||
@@ -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's
|
||||
assert.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, []);
|
||||
|
||||
Reference in New Issue
Block a user