From 8ee75adbfe944842c906b9a69a331ac4af629dd1 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 31 Oct 2026 03:50:34 +0800 Subject: [PATCH] gui: the Gateway card's state sits centred on its title's line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The owner, on the Gateway page's status card: "这里没有水平对齐". The state ("运行中", 11px) sat on the 15px title's baseline. A smaller run of CJK text on a shared baseline reads as dropped below it: the title's ink ran rows 40-61 of the screenshot and the state's 42-61, so the state's middle was about a pixel low. .gw .name is now a flex row with align-items: center and an 8px gap (as .mask-act .name already is). The state keeps its ellipsis for long text (min-width: 0). gateway-card.test.cjs now measures the title text's middle against the state's and allows 0.25px. Run: - gateway-card.test.cjs, chromium on mote: 10 of 10 ok. WebKit on mote hangs at browserType.launch right now (a bare webkit.launch timed out at 60s, load ~30), so it ran on the Linux box (magpie-desktop): 10 of 10 ok. - Broken by hand: the old app.css with the new test, both engines, 5 languages, 2 widths: 20 of 20 red, "the state's middle is 0.5px off the title's". - All 30 gateway GUI files at once on the Linux box, both engines: 299 ok, 1 red. The red was gateway-caller-keys webkit en:138, the sideways-scroll read right after setViewportSize. That is #3797, now commented on. It passed 3 of 3 alone on this branch and on origin/main 74f812eaf. At the pushed head (rebased on 333e7f573): gateway-card and gateway-older on the Linux box, 24 of 24 ok; go test ./internal/gui -run Budget|CSS|Asset on mote ok. Not tried: the whole GUI suite, and macOS WebKit (launch hangs on mote). The change is two CSS rules scoped to .gw .name. --- internal/gui/assets/app.css | 5 ++++- internal/gui/tests/gateway-card.test.cjs | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index d85470c0b..40eb7948a 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -2337,7 +2337,10 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; } .gw .gw-mark.on .led { fill: var(--green); } /* narrow, the fix button goes under the state rather than squeeze it */ .gw .who { flex: 1 1 15em; min-width: 0; } -.gw .name .state { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--green); } +/* the state centred on the title's line, not sat on its baseline: a + smaller run of CJK on the baseline reads as dropped below it */ +.gw .name { display: flex; align-items: center; gap: 8px; } +.gw .name .state { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 500; color: var(--green); } .gw .gw-mark:not(.on) ~ .who .state { color: var(--amber); } .gw .sub.old { white-space: normal; overflow: visible; text-overflow: clip; } .gw .sub.err { color: var(--red); overflow-wrap: anywhere; } diff --git a/internal/gui/tests/gateway-card.test.cjs b/internal/gui/tests/gateway-card.test.cjs index 31c0d0569..db9a34b4f 100644 --- a/internal/gui/tests/gateway-card.test.cjs +++ b/internal/gui/tests/gateway-card.test.cjs @@ -47,6 +47,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", // the mark in its tile, the state beside it assert.equal(await page.locator("#gateway > .gw-mark.on svg .led").count(), 2, "the mark's two lights"); assert.equal(await page.locator("#gateway .url").count(), 0, "no address pill in the status row"); + // the state centred on the title's line, not sat low on its baseline + // (the owner: "没有水平对齐") + const off = await page.locator("#gateway .name").evaluate((n) => { + const r = document.createRange(); + r.selectNodeContents(n.firstChild); + const a = r.getBoundingClientRect(), b = n.querySelector(".state").getBoundingClientRect(); + return Math.abs((a.top + a.bottom) / 2 - (b.top + b.bottom) / 2); + }); + assert(off <= 0.25, `the state's middle is ${off}px off the title's`); // Connect folded by default, its base URL in its head assert.equal(await page.locator("#foldConnect").getAttribute("aria-expanded"), "false", "Connect starts folded"); assert(await page.locator("#connect").evaluate((c) => c.hidden));