gui: Settings' gateway row is titled an address, and says only its port is typed here (Chicring on Discord)
Chicring: Settings showed "网关端口" (gateway port), but the row showed
MAGPIE_ADDR's host:port.
What the field takes, from the code: renderPort posts to
/api/settings/port, and setPort (internal/gui/port.go) accepts only a port
from 1024 to 65535 (settings.CheckPort). The gateway listens on that port,
on 127.0.0.1, or on 0.0.0.0 while shared on the LAN. When MAGPIE_ADDR is
set, it is the whole host:port and comes first. The row then shows its
value and is disabled. So the row is the gateway's address, but only its
port is typed here; it isn't a second way to write MAGPIE_ADDR.
The row is renamed in every language: Gateway address / 网关地址 / 閘道位址 /
ゲートウェイのアドレス / Adresse des Zugangspunkts. The new hint says "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}". With
MAGPIE_ADDR set, the hint says "MAGPIE_ADDR={addr} sets the gateway's whole
address, host:port: unset it to set the port here". The CLI help (cpu,
healthcheck, heap, quota, statusline) and setPort's comment named
"Settings' Gateway port". They now say "the port in Settings' Gateway
address".
Test: gateway-port.test.cjs pins the new name and hints in en and zh. With
MAGPIE_ADDR set, it now also checks that the field shows 127.0.0.1:3426
and that the row's name and aria-label say the address. gui-zh-tw, gui-ja,
gui-de and i18n-keys cover the other languages. Broken by hand: on the old
app.js it is red, "not ok 1 - en expected: 'Gateway address' actual:
'Gateway port'", and zh red against '网关地址'.
What was run. The whole suites ran at dcf7eeae3, which was these two commits
on origin/main 592899467. They were rebased cleanly onto 5c557c793 and
re-checked there.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./... and
GOOS=windows go vet ./...: ok, at both heads.
- GOMODCACHE=... go test -timeout 45m ./... in a sandbox HOME: 63 ok.
internal/agent, internal/gateway and internal/library hit the 45m package
timeout while other sessions' full suites ran (load ~27-40). Their stacks
were in short tests (TestDisconnectStaysThroughSync 21s,
TestSub2APIThinkingOffRefused 0s, TestSkillHow 10s), so nothing hung.
Each passed when run alone:
"ok internal/agent 1127.439s", "ok internal/gateway 1044.808s",
"ok internal/library 1029.999s".
- The whole GUI suite, node --test --test-concurrency=2
internal/gui/tests/*.test.cjs, with playwright 1.62.0:
- BROWSER=chromium: "# tests 5862 # pass 5844 # fail 18".
- BROWSER=webkit: "# tests 5854 # pass 5835 # fail 19".
Every red file was rerun alone on a freshly fetched origin/main
(a3ebed202 / 5c557c793) and is red there too:
- library-row-remove (chromium, 4 of 8 runs on main): filed #3099.
- quota-count-wrap and quota-name-translated (webkit): #2228.
- usage-agents-hide (both engines): #2276.
- usage-fold (chromium): #2163.
- plugin-card-update (webkit, 2 of 4 runs on 5c557c793): #3079.
- s3-sync (webkit): #2448.
- usage-checkin's Qoder tab (webkit): #2549.
- tray-usages and routing-rule-remove: passed alone on both trees.
None of these files touch the provider editor or the gateway address row.
- At 5c557c793 + these commits: decide-endpoint-label, gateway-port,
system-one, remote-magpie, i18n-keys, gui-zh-tw, gui-ja, gui-de and
lan-docker in both engines: "# tests 54 # pass 54 # fail 0".
go test ./internal/gui ./internal/cli: ok.
This commit is contained in:
@@ -33,7 +33,7 @@ const cpuUsage = `usage: magpie cpu [<file>] [--seconds N]
|
||||
magpie then prints the file, the CPU time the process used while recording and its
|
||||
goroutines: send both. The profile holds where the time went (function names, source
|
||||
lines) and the path of the magpie program, not keys or messages; go tool pprof <file>
|
||||
reads it. It asks the gateway at Settings' Gateway port (or MAGPIE_ADDR) over loopback.`
|
||||
reads it. It asks the gateway at the port in Settings' Gateway address (or MAGPIE_ADDR) over loopback.`
|
||||
|
||||
// cpuArgs reads magpie cpu's arguments: the file, "" for the default, and
|
||||
// the seconds to record.
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// healthcheck: magpie healthcheck — exits 0 when a magpie gateway answers
|
||||
// at its address (MAGPIE_ADDR, else Settings' Gateway port on 127.0.0.1,
|
||||
// at its address (MAGPIE_ADDR, else the port in Settings' Gateway address on 127.0.0.1,
|
||||
// 3425 unless set), for a container's
|
||||
// HEALTHCHECK, which has no curl to ask it with.
|
||||
func healthcheck() error {
|
||||
|
||||
@@ -28,7 +28,7 @@ const heapUsage = `usage: magpie heap [<file>]
|
||||
as Go counts it (its heap, what it took from the system, its goroutines): send both.
|
||||
The profile holds where memory was allocated (function names, source lines, sizes) and
|
||||
the path of the magpie program, not keys or messages; go tool pprof <file> reads it.
|
||||
It asks the gateway at Settings' Gateway port (or MAGPIE_ADDR) over loopback.`
|
||||
It asks the gateway at the port in Settings' Gateway address (or MAGPIE_ADDR) over loopback.`
|
||||
|
||||
// heapWait bounds the ask: the profile runs a collection first, which on a
|
||||
// heap of gigabytes takes a while.
|
||||
|
||||
@@ -26,7 +26,7 @@ const quotaUsage = `usage: magpie quota [<provider>…] [--json]
|
||||
when it starts again, and each key's balance, asked of the vendors now (or less than
|
||||
a minute ago). --json is for scripts and agents, each entry with lastServedAt, when it
|
||||
last answered through the gateway, and last: true on the latest; the gateway answers the same at
|
||||
GET http://127.0.0.1:3425/v1/magpie/quotas (on Settings' Gateway port), and to another machine only while magpie is
|
||||
GET http://127.0.0.1:3425/v1/magpie/quotas (on the port in Settings' Gateway address), and to another machine only while magpie is
|
||||
shared on the local network, with its key as the API key (Authorization: Bearer or x-api-key)
|
||||
A Codex account that holds rate-limit resets says how many; quota reset spends one,
|
||||
starting the account's current windows again (the one Codex is signed in to unless
|
||||
|
||||
@@ -34,7 +34,7 @@ const statuslineUsage = `usage: magpie statusline [<provider|account>…]
|
||||
~/.claude/settings.json yourself (magpie doesn't write it, a status line such as
|
||||
claude-hud may hold it):
|
||||
"statusLine": {"type": "command", "command": "magpie statusline"}
|
||||
It asks the gateway on this computer (Settings' Gateway port, or MAGPIE_ADDR), never
|
||||
It asks the gateway on this computer (the port in Settings' Gateway address, or MAGPIE_ADDR), never
|
||||
a vendor, and prints nothing when the gateway isn't running.`
|
||||
|
||||
// statuslineWait bounds each ask of the gateway: Claude Code shows the line
|
||||
|
||||
@@ -22730,11 +22730,12 @@ function editRedactRule(r, n, row) {
|
||||
if (d.err) head.querySelector(".sub").classList.add("err");
|
||||
}
|
||||
|
||||
// renderPort: the gateway's port on this computer (Magic_zero on Discord:
|
||||
// 3425 taken by another program, or one easier to tell apart). Any port
|
||||
// from 1024 up can be typed; magpie moves its gateway there and every
|
||||
// renderPort: the gateway's address on this computer (Magic_zero on Discord:
|
||||
// 3425 taken by another program, or one easier to tell apart). Only its
|
||||
// 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, set, comes first and the field says so.
|
||||
// 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).
|
||||
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
|
||||
@@ -22749,23 +22750,23 @@ 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 port")));
|
||||
who.append(el("div", "name", t("Gateway address")));
|
||||
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 port"));
|
||||
field.setAttribute("aria-label", t("Gateway address"));
|
||||
const save = el("button", "text", t("Apply"));
|
||||
if (s.addrEnv) {
|
||||
field.value = s.addrEnv;
|
||||
field.disabled = save.disabled = true;
|
||||
sub.textContent = t("MAGPIE_ADDR={addr} sets the gateway’s address: unset it to set the port here", { addr: s.addrEnv });
|
||||
sub.textContent = t("MAGPIE_ADDR={addr} sets the gateway’s whole address, host:port: unset it to set the port here", { addr: s.addrEnv });
|
||||
} else if (d.err) {
|
||||
sub.textContent = d.err;
|
||||
sub.classList.add("err");
|
||||
} else sub.textContent = t("Agents magpie connected move with it. Now {url}", { url: s.gateway || "" });
|
||||
} else sub.textContent = t("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}", { url: s.gateway || "" });
|
||||
who.append(sub);
|
||||
save.onclick = () => {
|
||||
const p = Number(field.value.trim());
|
||||
|
||||
+12
-12
@@ -939,9 +939,9 @@ const I18N = {
|
||||
"Public address": "公网地址",
|
||||
"MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:其他电脑访问网关的地址,需带网关密钥",
|
||||
"Share on local network": "局域网共享",
|
||||
"Gateway port": "网关端口",
|
||||
"Agents magpie connected move with it. Now {url}": "改了之后,已接入 magpie 的 Agent 会一起换过去。当前 {url}",
|
||||
"MAGPIE_ADDR={addr} sets the gateway’s address: unset it to set the port here": "MAGPIE_ADDR={addr} 已指定网关地址:去掉这个环境变量后才能在这里设端口",
|
||||
"Gateway address": "网关地址",
|
||||
"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 之间的数字",
|
||||
"Port {p} is in use by another program: pick another one": "端口 {p} 已被其他程序占用,请换一个",
|
||||
"Another magpie serves the gateway at {url}: set its port there, or quit it first": "另一个 magpie 正在 {url} 提供网关:请在那边设端口,或先退出它",
|
||||
@@ -4775,9 +4775,9 @@ const I18N = {
|
||||
"Public address": "公開位址",
|
||||
"MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:其他電腦連到閘道的位址,需帶閘道金鑰",
|
||||
"Share on local network": "區域網共享",
|
||||
"Gateway port": "閘道連接埠",
|
||||
"Agents magpie connected move with it. Now {url}": "改了之後,已接入 magpie 的 Agent 會一起換過去。目前 {url}",
|
||||
"MAGPIE_ADDR={addr} sets the gateway’s address: unset it to set the port here": "MAGPIE_ADDR={addr} 已指定閘道位址:去掉這個環境變數後才能在這裡設連接埠",
|
||||
"Gateway address": "閘道位址",
|
||||
"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 之間的數字",
|
||||
"Port {p} is in use by another program: pick another one": "連接埠 {p} 已被其他程式佔用,請換一個",
|
||||
"Another magpie serves the gateway at {url}: set its port there, or quit it first": "另一個 magpie 正在 {url} 提供閘道:請在那邊設連接埠,或先退出它",
|
||||
@@ -8583,9 +8583,9 @@ const I18N = {
|
||||
"Public address": "公開アドレス",
|
||||
"MAGPIE_PUBLIC_URL: where other computers reach the gateway, with a gateway key": "MAGPIE_PUBLIC_URL:他のコンピュータがゲートウェイに接続するアドレス(ゲートウェイキーが必要)",
|
||||
"Share on local network": "ローカルネットワークで共有",
|
||||
"Gateway port": "ゲートウェイのポート",
|
||||
"Agents magpie connected move with it. Now {url}": "magpie に接続したエージェントも一緒に移ります。現在 {url}",
|
||||
"MAGPIE_ADDR={addr} sets the gateway’s address: unset it to set the port here": "MAGPIE_ADDR={addr} がゲートウェイのアドレスを指定しています。ここでポートを設定するには解除してください",
|
||||
"Gateway address": "ゲートウェイのアドレス",
|
||||
"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 の数値です",
|
||||
"Port {p} is in use by another program: pick another one": "ポート {p} は他のプログラムが使用中です。別のポートを選んでください",
|
||||
"Another magpie serves the gateway at {url}: set its port there, or quit it first": "別の magpie が {url} でゲートウェイを提供しています。そちらでポートを設定するか、先に終了してください",
|
||||
@@ -12405,9 +12405,9 @@ const I18N = {
|
||||
"Public address": "Öffentliche Adresse",
|
||||
"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 port": "Port des Zugangspunkts",
|
||||
"Agents magpie connected move with it. Now {url}": "Mit magpie verbundene Agenten ziehen mit um. Jetzt {url}",
|
||||
"MAGPIE_ADDR={addr} sets the gateway’s address: unset it to set the port here": "MAGPIE_ADDR={addr} legt die Adresse des Zugangspunkts fest: entferne die Variable, um den Port hier zu setzen",
|
||||
"Gateway address": "Adresse 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",
|
||||
"Port {p} is in use by another program: pick another one": "Port {p} wird von einem anderen Programm verwendet: wähle einen anderen",
|
||||
"Another magpie serves the gateway at {url}: set its port there, or quit it first": "Ein anderes magpie stellt den Zugangspunkt unter {url} bereit: setze den Port dort oder beende es zuerst",
|
||||
|
||||
@@ -62,8 +62,8 @@ func errPortTaken(p int) error {
|
||||
return fmt.Errorf("port %d is in use by another program: pick another one", p)
|
||||
}
|
||||
|
||||
// setPort moves the gateway to port p (0 for the default) — Settings'
|
||||
// Gateway port (Magic_zero on Discord: 3425 was taken, and a port of one's
|
||||
// setPort moves the gateway to port p (0 for the default) — the port in
|
||||
// Settings' Gateway address (Magic_zero on Discord: 3425 was taken, and a port of one's
|
||||
// own is easier to tell apart): it checks nothing listens there, saves it,
|
||||
// moves the gateway this magpie serves (or starts it, when the port it was
|
||||
// on was taken), and then every agent connected to magpie, whose configs
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Settings › Gateway port (Magic_zero on Discord: 3425 was taken by another
|
||||
// Settings › Gateway address (Magic_zero on Discord: 3425 was taken by another
|
||||
// program, and a port of one's own is easier to tell apart): any port from
|
||||
// 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.
|
||||
// With MAGPIE_ADDR set the field is off and says why. The field is an
|
||||
// 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
|
||||
// input, not a native <select>; applying never scrolls the page; no
|
||||
// coloured left border. English and Chinese, Chromium and WebKit; no
|
||||
// backend, the API is faked here.
|
||||
@@ -62,20 +64,20 @@ function server(lang, over, posts) {
|
||||
|
||||
const words = {
|
||||
en: {
|
||||
name: "Gateway port", apply: "Apply",
|
||||
now: (u) => "Agents magpie connected move with it. Now " + u,
|
||||
name: "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",
|
||||
moved: "Gateway on port 3591; 2 agents moved with it",
|
||||
env: "MAGPIE_ADDR=127.0.0.1:3426 sets the gateway’s address: unset it to set the port here",
|
||||
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: "应用",
|
||||
now: (u) => "改了之后,已接入 magpie 的 Agent 会一起换过去。当前 " + u,
|
||||
name: "网关地址", apply: "应用",
|
||||
now: (u) => "这里只设端口(1024 到 65535);MAGPIE_ADDR=主机:端口 可指定完整地址。改了之后,已接入 magpie 的 Agent 会一起换过去。当前 " + u,
|
||||
range: "端口是 1024 到 65535 之间的数字",
|
||||
taken: "端口 3500 已被其他程序占用,请换一个",
|
||||
moved: "网关已换到端口 3591,2 个 Agent 已跟着换过去",
|
||||
env: "MAGPIE_ADDR=127.0.0.1:3426 已指定网关地址:去掉这个环境变量后才能在这里设端口",
|
||||
env: "MAGPIE_ADDR=127.0.0.1:3426 已指定网关的完整地址(主机:端口):去掉这个环境变量后才能在这里设端口",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -178,6 +180,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const { page, errors, posts } = await open(lang, { addrEnv: "127.0.0.1:3426", gateway: "http://127.0.0.1:3426" });
|
||||
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);
|
||||
assert(await row.getByRole("button", { name: w.apply }).isDisabled());
|
||||
assert.equal((await row.locator(".sub").textContent()).trim(), w.env);
|
||||
assert.deepEqual(posts, []);
|
||||
|
||||
Reference in New Issue
Block a user