arculongus (English UI, screenshot) couldn't read many Settings rows: the
line under a setting's name ended in "…". The generic `.row .sub` rule holds
a row's line to one line with an ellipsis; a few Settings rows opted out
(`.wraps`) and the rest were cut, among them Image generation's ChatGPT
note, Image recognition MCP server and Web search's Searches for other
models.
Fixed for the class, not the rows in the screenshot: every setting row's
line (`.row.pref .sub`) now wraps whole beside its control. That covers
every Settings part, Plugins › Built-in and an agent's own settings (the
same rows). The control keeps its size (`.prefs .val` is `flex: none`,
max 60%), and nothing else in the layout moves. The window is never
narrower than 560pt, so a row stays a few lines at most. Lines elsewhere (provider
and account cards, chips, URLs) stay one line; their full text is already
reachable through the hover title.
Tests:
- New settings-lines-wrap.test.cjs checks every visible Settings part plus
Plugins › Built-in, in chromium and webkit, en/zh/zh-TW/ja/de, at
1000px and 440px. No row's line is cut or nowrap, each control stays
inside its row, and the page never scrolls sideways (more than 30 rows
checked). It also checks the three reported rows by name.
- Tests that assumed one-line rows now follow the taller rows:
- searcher-pick: the help wraps rather than ellipsizing with a title.
- settings-general: one line only at 1000px, never cut at either width.
- reader.cjs reach(): goes up to 8,000px, not 2,400.
- member-model-setting, turn-done, connect-address-kept, tray-cost and
tray-totals: wheel to the control with reach() before
clicking, not scrollIntoViewIfNeeded or Playwright's own scroll, which
the app undoes.
- update-download, update-restart and tray-totals: a click whose row
grows a line may scroll, but only to keep the clicked control under
the pointer (the app's hold, #2134). tray-totals allows 2px, because
WebKit's whole-pixel scrolls drifted 1.3px over four holds.
- mobile-web: compares against an origin/main baseline without this
change.
- Docs: gui-shell.md and gateway-routing.md.
Run (worktree from origin/main a6399dd49, then rebased):
- The new test passes 20/20. Broken by hand: pointed at the old assets
(MAGPIE_WRAP_ASSETS), it is red 10/10 in chromium and red in webkit
("general: a row's line is cut short").
- Whole GUI suite (872 files) in two runs, at concurrency 3-4 and load
20-150:
- The 170 Settings-reaching files first: 2515/2575.
- Then the other 702: 9767/9920.
- Each red was rerun on settings-wrap-base. The files this change made
red (settings-general, turn-done, update-download, update-restart,
member-model-setting, codex-auto-reset-settings, mobile-web,
connect-address-kept, quota-reads, tray-cost, tray-totals) are fixed
above and pass on rerun: 86/86, 34/34, 112/112 and 50/50.
- Also red on origin/main, already filed:
- redact-words-any-case: #3500
- s3-sync webkit: #2448
- usage-checkin Qoder tab: #2549
- plugin-card-update: #3079
- builtins and gateway-mode masking tab: #3498
- fonts webkit: #3227
- The other files red on origin/main 31bff66be, run alone at a
comparable count, all have issues: routing-pause #3410,
routing-rule-effort #3411, routing-rule-remove #3094/#3096,
routing-intent-entry #3408, routing-live-patch #2174, routing-manual
#3409, routing-steady #3412, menu-input-scroll #3402, header-centre
#3479, gateway-caller-keys #2572, gateway-key-models #2648,
gateway-key-limit #3523, quota-count-wrap #3404, usage-agents-hide
#3414, usage-fold #3415, usage-ledger #3001/#3104, sidebar and
gateway-mode #3498, account-discovery #3497, sidebar-overlay-scrollbar
#1863, account-alias #2984.
- provider-user-agent failed only on browserType.launch timeouts (load)
and passed on rerun.
- After the rebase onto b027ca264, these were run again at the pushed head: the
14 changed or affected GUI files (the new test, the eleven above,
quota-reads, which main already wheels, and i18n-keys) passed 302/302.
go test -tags nogui ./internal/gui (budgets included) was ok, with no
budget raised.
- Before and after screenshots, Settings › Models at 1000px and 700px,
chromium and webkit, were looked at: the rows that ended in an ellipsis
now read whole, and each control has the size and place it had before.
Not tried: the real app (WKWebView, WebKitGTK, WebView2). This is a CSS
white-space change with no motion and no new API.
161 lines
12 KiB
JavaScript
161 lines
12 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// 1ooogle on X redrew Settings → General the way macOS System Settings reads:
|
|
// a row says its name alone where the name says enough, a line under it only
|
|
// where it tells something the name can't, and Language is one menu button
|
|
// showing the language picked, not six segments. In every language, at
|
|
// 1000px and 440px, in both engines, on a Mac (the Dock and Session terminal
|
|
// rows show only there), with the API faked:
|
|
// - the rows whose names say enough have no line under them, and the lines
|
|
// kept are never cut short, one line each on a wide window (narrower,
|
|
// they wrap whole beside the control: arculongus on Discord);
|
|
// - Codex's and Claude Code's own settings aren't here: they are on the
|
|
// agents' rows (the owner, 10-20);
|
|
// - Language is a button (never a native <select>) showing the language;
|
|
// its menu, the app's own, lists all six, and a pick saves lang and
|
|
// draws the page in it, the button staying under the pointer;
|
|
// - no row has a coloured stripe down its left;
|
|
// - every row past the first has its line, the one after the agents' empty
|
|
// link box too, and as much room above and below its words as any other:
|
|
// the window's 7px left a row with a line under its name cramped, and the
|
|
// one-line rows of one height (the owner, 10-22).
|
|
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");
|
|
const names = { en: "English", zh: "简体中文", "zh-TW": "繁體中文", ja: "日本語", de: "Deutsch" };
|
|
const appearance = { en: "Appearance", zh: "外观", "zh-TW": "外觀", ja: "外観", de: "Darstellung" };
|
|
const system = { en: "System", zh: "跟随系统", "zh-TW": "跟隨系統", ja: "システム", de: "System" };
|
|
// the rows whose name says enough, found by the control they hold
|
|
const bare = ["#themeSegs", "#colorblindSegs", "#langPick", "#textSizeSegs", "#traySegs", "#plainNamesSegs", "#loginSegs", "#dockSegs"];
|
|
// the rows that keep a line, one each
|
|
const kept = ["#lightweightSegs", "#keepAwakeSegs", "#sessionTerminalRow .sess-pick"];
|
|
|
|
function serve(lang, posted, st) {
|
|
const settings = () => ({ lang, theme: "light", searchVendors: [], searchAPIs: [], ...st });
|
|
return async (r) => {
|
|
const url = new URL(r.request().url());
|
|
const json = (data, status = 200) => r.fulfill({ status, json: data });
|
|
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
|
|
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: settings() });
|
|
if (url.pathname === "/api/settings") {
|
|
if (r.request().method() === "POST") {
|
|
const b = JSON.parse(r.request().postData());
|
|
posted.push(b);
|
|
Object.assign(st, b);
|
|
}
|
|
return json(settings());
|
|
}
|
|
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
|
|
if (url.pathname === "/api/groups") return json({ models: [], groups: [], pools: [] });
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/usage/quotas") return json([]);
|
|
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 r.fulfill({ body: await fs.readFile(file), contentType });
|
|
};
|
|
}
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [1000, 440]) {
|
|
test(`${engine} ${lang} ${width}px: Settings → General says each name alone where it says enough, Language one menu`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
const page = await (await browser.newContext({ viewport: { width, height: 760 } })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.addInitScript(() => Object.defineProperty(navigator, "platform", { get: () => "MacIntel" }));
|
|
const posted = [], st = {};
|
|
await page.route("**/*", serve(lang, posted, st));
|
|
await watchSettingsReads(page);
|
|
await page.goto("http://magpie.test/?view=settings&tab=general");
|
|
await settingsDrawn(page);
|
|
await page.locator("#langPick span").waitFor();
|
|
|
|
const rows = await page.evaluate(([bare, kept]) => {
|
|
const row = (sel) => document.querySelector(sel)?.closest(".row");
|
|
return {
|
|
bare: bare.map((sel) => { const r = row(sel); return [sel, !r ? "missing" : r.hidden ? "hidden" : [...r.querySelectorAll(".sub")].filter((s) => s.getClientRects().length && s.textContent.trim()).map((s) => s.textContent)]; }),
|
|
kept: kept.map((sel) => {
|
|
const r = row(sel), s = r?.querySelector(".sub");
|
|
return [sel, !r || r.hidden ? "missing" : !s ? "no line" : { text: s.textContent, lines: Math.round(s.getBoundingClientRect().height / parseFloat(getComputedStyle(s).lineHeight || 16)), cut: s.scrollWidth > s.clientWidth + 1 }];
|
|
}),
|
|
stripes: [...document.querySelectorAll("#setPage-general .row")].filter((r) => parseFloat(getComputedStyle(r).borderLeftWidth) > 1).length,
|
|
sideways: document.documentElement.scrollWidth > innerWidth,
|
|
rule: [...document.querySelectorAll("#setPage-general .row.pref")].filter((r) => r.getClientRects().length).map((r, i) => {
|
|
const b = r.getBoundingClientRect(), w = r.querySelector(".who").getBoundingClientRect(), line = parseFloat(getComputedStyle(r).borderTopWidth);
|
|
const oneLine = ![...r.querySelectorAll(".who .sub")].some((s) => s.getClientRects().length && s.textContent.trim());
|
|
return { id: r.id || r.querySelector(".name").textContent, lined: i === 0 || line >= 1, above: w.top - b.top - line, below: b.bottom - w.bottom, height: Math.round(b.height - line), oneLine };
|
|
}),
|
|
};
|
|
}, [bare, kept]);
|
|
for (const [sel, subs] of rows.bare) assert.deepEqual(subs, [], `${sel}'s row says its name alone`);
|
|
// Long conversations stays here with no Codex or Claude Code, as in
|
|
// this fixture (agent-prefs.test.cjs)
|
|
assert.equal(await page.locator("#view-settings :is(#codexAgentsV1Row, #codexAsyncRow, #codexTitlesRow, #codexDescriptionsRow, #codexPredictionsRow, #codexAutoReviewRow, #codexMemoriesRow)").count(), 0, "an agent's own settings are on its row");
|
|
for (const [sel, sub] of rows.kept) {
|
|
assert.equal(typeof sub, "object", `${sel}: ${sub}`);
|
|
assert.ok(sub.text.trim(), `${sel}: ${JSON.stringify(sub)}`);
|
|
if (width === 1000) assert.ok(sub.lines <= 1, `${sel} takes more than one line: ${JSON.stringify(sub)}`);
|
|
assert.equal(sub.cut, false, `${sel}'s line is cut short: ${sub.text}`);
|
|
}
|
|
assert.equal(rows.stripes, 0, "a row has a stripe down its left");
|
|
assert.equal(rows.sideways, false, "the page scrolls sideways");
|
|
for (const r of rows.rule) {
|
|
assert.ok(r.lined, `${r.id} has no line above it`);
|
|
assert.ok(r.above >= 11.5 && r.below >= 11.5, `${r.id}'s words sit close to its lines: ${JSON.stringify(r)}`);
|
|
}
|
|
if (width === 1000) assert.equal(new Set(rows.rule.filter((r) => r.oneLine).map((r) => r.height)).size, 1, `one-line rows of more than one height: ${JSON.stringify(rows.rule)}`);
|
|
|
|
// Language: one button showing the language, the app's menu listing all six
|
|
const pick = page.locator("#langPick");
|
|
assert.equal(await pick.evaluate((b) => b.tagName), "BUTTON");
|
|
assert.equal(await page.locator("#setPage-general select").count(), 0, "no native <select>");
|
|
assert.equal(await pick.innerText(), names[lang]);
|
|
const fits = await pick.evaluate((b) => { const r = b.closest(".row").getBoundingClientRect(), x = b.getBoundingClientRect(), s = b.querySelector("span"); return x.right <= r.right + 0.5 && x.left >= r.left && s.scrollWidth <= s.clientWidth + 1; });
|
|
assert.ok(fits, "the language button doesn't fit its row");
|
|
// the click moves nothing: the button stays under the pointer, even as
|
|
// the page drawn in another language grows above it (the view scrolls
|
|
// to hold it, as every click on Settings does)
|
|
const where = () => pick.evaluate((b) => { const v = document.querySelector("#view-settings"); return { top: b.getBoundingClientRect().top, inPage: b.getBoundingClientRect().top - b.closest(".set-page, section, [id^=setPage-]").getBoundingClientRect().top, scrolled: v.scrollTop }; });
|
|
// the page comes in animated: a place read mid-way isn't where it rests
|
|
const rest = () => page.evaluate(() => Promise.all(document.getAnimations().map((a) => a.finished.catch(() => {}))));
|
|
await rest();
|
|
const before = await where();
|
|
const b = await pick.boundingBox();
|
|
await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2);
|
|
const items = page.locator(".proto-menu .pm-item");
|
|
await items.first().waitFor();
|
|
assert.equal(await pick.getAttribute("aria-expanded"), "true");
|
|
const menu = await items.evaluateAll((bs) => bs.map((b) => ({ name: b.querySelector(".pm-name").textContent, on: b.classList.contains("on"), inside: b.getBoundingClientRect().right <= innerWidth && b.getBoundingClientRect().left >= 0 })));
|
|
assert.deepEqual(menu.map((m) => m.name), [system[lang], "English", "简体中文", "繁體中文", "日本語", "Deutsch"]);
|
|
assert.deepEqual(menu.filter((m) => m.on).map((m) => m.name), [names[lang]]);
|
|
assert.ok(menu.every((m) => m.inside), `the menu runs off the window: ${JSON.stringify(menu)}`);
|
|
// pick another language: saved, and the page drawn in it
|
|
const to = lang === "ja" ? "de" : "ja";
|
|
const item = items.nth(["system", "en", "zh", "zh-TW", "ja", "de"].indexOf(to));
|
|
const ib = await item.boundingBox();
|
|
await page.mouse.click(ib.x + ib.width / 2, ib.y + ib.height / 2);
|
|
for (let i = 0; i < 50 && posted.at(-1)?.lang !== to; i++) await page.waitForTimeout(50);
|
|
assert.equal(posted.at(-1)?.lang, to, `posted ${JSON.stringify(posted)}`);
|
|
await page.waitForFunction(([n]) => document.querySelector("#langPick")?.textContent === n, [names[to]]);
|
|
const head = page.locator("#setPage-general .row .name").first();
|
|
for (let i = 0; i < 50 && (await head.innerText()) !== appearance[to]; i++) await page.waitForTimeout(50);
|
|
assert.equal(await head.innerText(), appearance[to]);
|
|
assert.equal(await page.locator(".proto-menu").count(), 0, "the menu stays open");
|
|
await rest();
|
|
const after = await where();
|
|
assert.ok(Math.abs(after.inPage - before.inPage) <= 1, `the rows above the language moved: ${JSON.stringify([before, after])}`);
|
|
// a view at its top can't scroll up to hold it as the header above shrinks
|
|
if (after.scrolled > 0) assert.ok(Math.abs(after.top - before.top) <= 1, `the click moved the language button: ${JSON.stringify([before, after])}`);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|