settings: the LAN address row has no blank band under it

The owner (11-08): in Settings › Network, under Share on local network,
the Address row had an empty band under the address, so the card's
spacing was uneven. The row places its controls in a fixed height (50px).
With a pointer that hovers, 8e9b048b6 made Settings' rows content-box,
so the row's 24px of padding was added under that height: 75px, its
controls in the top 51. The row now stays border-box, 51px like the
rows around it; the two-line narrow layout is 81px, 13 under its second
line as over its first (it was 7-8 even before).

lan-address-height.test.cjs: the room under the controls equals the room
over them, and wide, the row is as tall as the one above it. One address
and several, 1300px and 560px, en and zh, Chromium and WebKit.

Run on mote, at this tree:
- lan-address-height, lan-public, lan-docker: 55 of 60 pass; the 5
  WebKit lan-docker reds are browserType.launch timeouts (mote's load at
  ~650). Those 5 pass in the run before at this same CSS, whose own reds
  were launch timeouts too.
Broken by hand: the new test at the base (no fix), Chromium: 8 of 8 red,
row 75px (101 narrow), 36px under the controls and 13 over.
Not tried: the real app; the full GUI suite (only the LAN files reach
this row's CSS).
This commit is contained in:
yetone
2026-11-09 08:39:05 +08:00
parent 2a64b4bcb7
commit 26e9c95665
2 changed files with 91 additions and 2 deletions
+6 -2
View File
@@ -4020,7 +4020,11 @@ input.words.search-key, input.words.search-url { flex: 1 1 120px; width: auto; m
.prefs .val.searcher-then-list > .rt-cond { min-width: 0; max-width: 100%; }
.searcher-then-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.side-effort .effort-ic svg { width: 100%; height: 100%; }
.row.pref.lan-address-row { position: relative; height: 50px; transition: height .28s var(--ease); }
/* its controls are placed in a fixed height, so it stays border-box where
Settings' other rows go content-box (a pointer that hovers): there the
padding was added under it, a blank band below the address (the owner,
11-08). 51, as tall as the rows around it. */
.row.pref.lan-address-row, #view-settings .row.pref.lan-address-row { position: relative; box-sizing: border-box; height: 51px; transition: height .28s var(--ease); }
.row.pref.lan-address-row .who { position: absolute; top: 16px; left: 14px; }
.prefs .lan-address-row .val { max-width: 64%; }
/* Browser access: a link per address, each with its copy button */
@@ -4045,7 +4049,7 @@ input.words.search-key, input.words.search-url { flex: 1 1 120px; width: auto; m
.pop.proto-menu.lan-address-menu { width: min(320px, calc(100vw - 16px)); max-height: min(360px, 70vh); overflow-y: auto; }
.lan-address-menu .pm-name { font: var(--code-style, normal) var(--code-weight, 400) 12px var(--code-font, var(--code)); font-stretch: var(--code-stretch, 100%); }
@media (max-width: 600px) {
.row.pref.lan-address-row { height: 76px; }
.row.pref.lan-address-row, #view-settings .row.pref.lan-address-row { height: 81px; } /* 13 under its second line, as over its first */
.lan-address-controls .segs { right: 12px; }
.row.pref .proto.pick.lan-interface { top: 44px; }
.lan-address-controls .lan-address-text { top: 47px; }
@@ -0,0 +1,85 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Settings › Network: Share on local network's Address row is as tall as its
// controls, with the same room above them as below (the owner, 11-08: a
// blank band under the address made the card's spacing uneven). With a
// pointer that hovers, Settings' rows are content-box, and the row's fixed
// height had the padding added under it. One address and several, wide and
// narrow, Chromium and WebKit, English and Chinese.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const { watchSettingsReads, settingsDrawn } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
function server(lang, lanURLs) {
const s = {
theme: "light", lang, tray: "panel", currency: "usd", proxy: "", redactWords: [],
version: "0.1.400", dir: "/config/magpie", gateway: "http://0.0.0.0:3425", proxyNow: "none", proxySource: "none",
visionModels: [], imageGenModels: [], workbuddyCheckins: [],
lan: true, lanKey: "sk-magpie-0123456789abcdef", lanURLs, lanPublic: [],
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
};
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" }, fx: s.fx });
if (url.pathname === "/api/settings") return json(s);
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/usage/quotas") return json([]);
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
await route.fulfill({ body: await fs.readFile(file), contentType });
};
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(engine + ": the LAN address row is as tall as its controls", async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const lang of ["en", "zh"]) {
for (const urls of [["http://10.0.0.175:3425"], ["http://10.0.0.175:3425", "http://192.168.1.5:3425"]]) {
for (const width of [1300, 560]) {
const what = `${lang} ${urls.length} address(es) at ${width}px`;
await t.test(what, async () => {
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
const page = await ctx.newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", server(lang, urls));
await watchSettingsReads(page);
await page.goto("http://localhost:3430/?view=settings&tab=network");
await settingsDrawn(page);
await page.locator("#lanList .lan-address-row .lan-copy button").waitFor();
const m = await page.evaluate(() => {
const rows = [...document.querySelectorAll("#lanList > .row")];
const r = document.querySelector("#lanList .lan-address-row");
const rb = r.getBoundingClientRect();
const parts = [...r.querySelectorAll(".lan-address-controls > *, .who")].map((e) => e.getBoundingClientRect()).filter((b) => b.height);
return {
hover: matchMedia("(hover: hover)").matches,
share: rows[0].getBoundingClientRect().height, row: rb.height,
above: Math.min(...parts.map((b) => b.top)) - rb.top,
below: rb.bottom - Math.max(...parts.map((b) => b.bottom)),
};
});
const at = what + ": " + JSON.stringify(m);
assert.ok(m.hover, "the page has a pointer that hovers, where the rows are content-box: " + at);
assert.ok(Math.abs(m.above - m.below) <= 2, "as much room below the controls as above: " + at);
if (width > 600) assert.ok(Math.abs(m.row - m.share) <= 1, "as tall as the row above it: " + at);
assert.deepEqual(errors, []);
await ctx.close();
});
}
}
}
});
}