From fa7e466acd0ea8f58ec383655ec98b3c61e287e4 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Nov 2026 03:55:09 +0800 Subject: [PATCH] gui: Settings' gateway row is titled a port when a port is what it takes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The owner (11-12): the row over a field that takes 3425 read 网关地址 (Gateway address). Only the port is typed there; it is titled Gateway port (网关端口, 閘道連接埠, ゲートウェイのポート, Port des Zugangspunkts), and the field's aria-label with it. With MAGPIE_ADDR set the field shows the whole host:port, off, and the row keeps Gateway address, as Chicring asked before. Run (mote, both engines): gateway-port, i18n-keys, i18n-en-no-cjk, 14 of 14 ok. Broken by hand: settings.js put back as on origin/main, gateway-port red in both engines (expected 'Gateway port'). Not tried: the real app. --- internal/gui/assets/i18n.js | 4 ++++ internal/gui/assets/plugins/gateway/settings.js | 11 ++++++++--- internal/gui/tests/gateway-port.test.cjs | 9 +++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index a09e4caa8..2f2c1427f 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -1354,6 +1354,7 @@ const I18N = { "MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:其他电脑访问网关的地址,需带网关密钥", "Share on local network": "局域网共享", "Gateway address": "网关地址", + "Gateway port": "网关端口", "Only the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole address instead. Agents magpie connected move with it. Now {url}": "这里只设端口(1024 到 65535);MAGPIE_ADDR=主机:端口 可指定完整地址。改了之后,已接入 magpie 的 Agent 会一起换过去。当前 {url}", "MAGPIE_ADDR={addr} sets the gateway’s whole address, host:port: unset it to set the port here": "MAGPIE_ADDR={addr} 已指定网关的完整地址(主机:端口):去掉这个环境变量后才能在这里设端口", "A port is a number from 1024 to 65535": "端口是 1024 到 65535 之间的数字", @@ -6503,6 +6504,7 @@ const I18N = { "MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:其他電腦連到閘道的位址,需帶閘道金鑰", "Share on local network": "區域網共享", "Gateway address": "閘道位址", + "Gateway port": "閘道連接埠", "Only the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole address instead. Agents magpie connected move with it. Now {url}": "這裡只設連接埠(1024 到 65535);MAGPIE_ADDR=主機:連接埠 可指定完整位址。改了之後,已接入 magpie 的 Agent 會一起換過去。目前 {url}", "MAGPIE_ADDR={addr} sets the gateway’s whole address, host:port: unset it to set the port here": "MAGPIE_ADDR={addr} 已指定閘道的完整位址(主機:連接埠):去掉這個環境變數後才能在這裡設連接埠", "A port is a number from 1024 to 65535": "連接埠是 1024 到 65535 之間的數字", @@ -11623,6 +11625,7 @@ const I18N = { "MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:他のコンピュータがゲートウェイに接続するアドレス(ゲートウェイキーが必要)", "Share on local network": "ローカルネットワークで共有", "Gateway address": "ゲートウェイのアドレス", + "Gateway port": "ゲートウェイのポート", "Only the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole address instead. Agents magpie connected move with it. Now {url}": "ここで設定するのはポート(1024〜65535)だけです。アドレス全体は MAGPIE_ADDR=ホスト:ポート で指定します。magpie に接続したエージェントも一緒に移ります。現在 {url}", "MAGPIE_ADDR={addr} sets the gateway’s whole address, host:port: unset it to set the port here": "MAGPIE_ADDR={addr} がゲートウェイのアドレス全体(ホスト:ポート)を指定しています。ここでポートを設定するには解除してください", "A port is a number from 1024 to 65535": "ポートは 1024〜65535 の数値です", @@ -16758,6 +16761,7 @@ const I18N = { "MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL: wo andere Computer das Gateway erreichen, mit einem Gateway-Schlüssel", "Share on local network": "Im lokalen Netzwerk freigeben", "Gateway address": "Adresse des Zugangspunkts", + "Gateway port": "Port des Zugangspunkts", "Only the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole address instead. Agents magpie connected move with it. Now {url}": "Hier wird nur der Port gesetzt, 1024 bis 65535; MAGPIE_ADDR=Host:Port legt die ganze Adresse fest. Mit magpie verbundene Agenten ziehen mit um. Jetzt {url}", "MAGPIE_ADDR={addr} sets the gateway’s whole address, host:port: unset it to set the port here": "MAGPIE_ADDR={addr} legt die ganze Adresse des Zugangspunkts fest (Host:Port): entferne die Variable, um den Port hier zu setzen", "A port is a number from 1024 to 65535": "Ein Port ist eine Zahl von 1024 bis 65535", diff --git a/internal/gui/assets/plugins/gateway/settings.js b/internal/gui/assets/plugins/gateway/settings.js index e50456745..6dd931ecf 100644 --- a/internal/gui/assets/plugins/gateway/settings.js +++ b/internal/gui/assets/plugins/gateway/settings.js @@ -10,7 +10,8 @@ // port, 1024 up, is typed here; magpie moves its gateway there and every // agent it connected with it, or says why it can't (another program has // it). MAGPIE_ADDR, a whole host:port, comes first and the field shows it, -// off (Chicring on Discord: the row was titled a port while it showed one). +// off, the row titled an address then (Chicring on Discord: the row was +// titled a port while it showed one). let portDraft = { value: null, err: "" }; // portSays is the gateway's word on a port it couldn't take, in the page's // language: it says the port, so it is matched rather than looked up @@ -25,14 +26,18 @@ function renderPort(s) { const box = $("#portList"); const r = el("div", "row pref port-row"); const who = el("div", "who"); - who.append(el("div", "name", t("Gateway address"))); + // a port is all that is typed here, so it is called one; MAGPIE_ADDR's + // whole host:port is an address (the owner, 11-12: the row titled an + // address over a field that takes 3425) + const title = t(s.addrEnv ? "Gateway address" : "Gateway port"); + who.append(el("div", "name", title)); const sub = el("div", "sub"); const d = portDraft; const now = s.addrEnv ? "" : String(s.port || 3425); const field = input(d.value ?? now, "3425"); field.className = "words gateway-port"; field.inputMode = "numeric"; - field.setAttribute("aria-label", t("Gateway address")); + field.setAttribute("aria-label", title); const save = el("button", "text", t("Apply")); if (s.addrEnv) { field.value = s.addrEnv; diff --git a/internal/gui/tests/gateway-port.test.cjs b/internal/gui/tests/gateway-port.test.cjs index f579c7eb7..523f186d0 100644 --- a/internal/gui/tests/gateway-port.test.cjs +++ b/internal/gui/tests/gateway-port.test.cjs @@ -65,7 +65,7 @@ function server(lang, over, posts) { const words = { en: { - name: "Gateway address", apply: "Apply", + name: "Gateway port", addr: "Gateway address", apply: "Apply", now: (u) => "Only the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole address instead. Agents magpie connected move with it. Now " + u, range: "A port is a number from 1024 to 65535", taken: "Port 3500 is in use by another program: pick another one", @@ -73,7 +73,7 @@ const words = { env: "MAGPIE_ADDR=127.0.0.1:3426 sets the gateway’s whole address, host:port: unset it to set the port here", }, zh: { - name: "网关地址", apply: "应用", + name: "网关端口", addr: "网关地址", apply: "应用", now: (u) => "这里只设端口(1024 到 65535);MAGPIE_ADDR=主机:端口 可指定完整地址。改了之后,已接入 magpie 的 Agent 会一起换过去。当前 " + u, range: "端口是 1024 到 65535 之间的数字", taken: "端口 3500 已被其他程序占用,请换一个", @@ -191,8 +191,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const row = page.locator("#portList .port-row"); assert(await row.locator("input.gateway-port").isDisabled()); assert.equal(await row.locator("input.gateway-port").inputValue(), "127.0.0.1:3426"); - assert.equal((await row.locator(".name").textContent()).trim(), w.name); - assert.equal(await row.locator("input.gateway-port").getAttribute("aria-label"), w.name); + // the whole host:port shown: an address, not a port + assert.equal((await row.locator(".name").textContent()).trim(), w.addr); + assert.equal(await row.locator("input.gateway-port").getAttribute("aria-label"), w.addr); assert(await row.getByRole("button", { name: w.apply }).isDisabled()); assert.equal((await row.locator(".sub").textContent()).trim(), w.env); assert.deepEqual(posts, []);