settings: a row's explanation shows on hover, not under every name

The owner (11-02, a screenshot of Settings › 模型): hide the lines that
explain a setting and show them on hover, so the page reads quiet and
open ("很简洁,很有呼吸感"). Settings' rows now rest as a name and a
control. The pointer resting on a row (450ms, so passing over rows shows
nothing), or a key reaching its control, shows its explanation whole in a
card under the row's name, or over the row where the window ends; the
card takes no pointer and no row moves. It goes when the pointer or focus
leaves, a key is pressed, or the page scrolls (focus's card follows its
row instead, as Tab scrolls it into sight).

- app.css: in #view-settings, under (hover: hover), a .row.pref's plain
  .sub lines are clipped out of sight, not removed, so a screen reader
  and the search still read them; each carries --hint: 1, which the card
  reads. A search shows them in place again, as before. A touch screen
  keeps them all.
- Stays in sight: errors (.err, .bad), states (.say, [role=status],
  .proxy-check), warnings (.image-gen-hidden, .sync-sign-in,
  .vision-not-marked), .no-names, .pv-hits, .feat-why, .font-note, the
  proxy in use (#proxySub), and any line with a button, link, input,
  code or a search provider's failure note in it (.acts, which
  settingshints.js sets on each such line as it is drawn, through a
  MutationObserver, so before it is painted: Safari before 15.4 has no
  :has(), and old-webkit holds the styles to 15.0). Disclosures stay too: what tracing sends (otel's
  sessions row) and the allow list's addresses, as do a disabled
  pattern's matches. .say is new, on the lines that are a state, not an
  explanation: the version row's update state, a sync's last sync, the
  sync notice, the web page's "Served" line, the local masking model's
  state (downloading, on, failed; its two explaining lines, before it is
  on, are hidden) and what Check in now came to.
- One-line rows are one height: a row left with its name alone was 48
  to 51px by its control (the owner, 10-22: one-line rows of one
  height), so under (hover: hover) every Settings .row.pref has a 27px
  content-box min-height, 51px with its padding, its line above outside
  it. Check in now's row aligns to its top, so its result line grows the
  row down and the button stays where it was pressed.
- app.js stays in the core budget (1,533,799 of 1,533,802 at this
  head, on main's 1,533,789) with three comments shortened, no raise.
- settingshints.js: the card and the .acts marks, a module app.js
  imports at start, not in index.html (one line in app.js; old-webkit's
  list of such modules names it). Its :focus-visible check is in a try,
  as Safari before 15.4 throws on it.

Tests, run on mote (macOS) at this tree:
- settings-hints.test.cjs (new): Chromium and WebKit, 1100 and 420px,
  en/zh/zh-TW/ja/de, Settings › Models. At rest the Image recognition MCP
  server's line is out of sight and still in the page; a gone model's
  error and an unticked image model's warning stay in sight; hover shows
  the whole line in a card off the row's name, inside the window, no row
  box moved, pointer-events none; the pointer leaving hides it; Tab (or
  Option-Tab in WebKit) to the row's copy button shows it; a search shows
  it in place; a line given a link shows at once and rests again when
  the link goes. 20/20 green.
- Broken by hand: with the clipping rule's body gone, 20/20 red on "the
  explanation shows at rest"; with app.js's import line gone, 20/20 red
  waiting for the card; with the .acts observer gone, Chromium 10/10 red
  on the link line. Before the kept lines and the row height were
  in, checkin-now-account was 20 red (the result line hidden, then the
  button moved 7px) and settings-general 10 red at 1000px (one-line rows
  48, 50 and 51px); both green with them.
- settings-lines-wrap.test.cjs: a hidden explanation is skipped by its
  "cut short" measure and checked whole in its card instead (#visionMcpRow
  and the searcher row). 20/20 green.
- 22 more GUI files checked a Settings explanation's text, width or
  wrapping in place; each now checks the text and that it is hinted, and
  skips its geometry (redact-*, privacy-model, settings-general,
  searcher-pick, disabled-models, the *-setting rows, images-codex-one,
  and reply-model-setting, new on main since: red 20 of 22 on ".sub
  fits" until it got the same check, then 22/22).
  These 24 files: 536 pass, 2 fail, both images-codex-one's #pop picker
  race, red the same on untouched origin/main 173b7e274 alone (13/18;
  #4618, commented).
- At this tree, on mote: those 25 files, old-webkit and i18n-keys, all
  green but images-codex-one's #4618 race (3 red). After the last
  rebase (ae060550b, 1a92a97ca) and the comments cut: privacy-model,
  settings-hints, old-webkit, desktop-tiers, i18n-keys green, and
  -run 'Budget|Core' ./internal/gui ok. old-webkit was red before .acts (":has()
  (Safari 15.4)" and settingshints.js unlisted). go test -count=1
  ./internal/gui: ok but TestMainWindowCorners (#3949, macOS 27).
- The whole GUI suite on mote (concurrency 3), one commit before .acts:
  cut short when mote went down mid-run (it rebooted). 25 files had
  reds by then. The 4 that open Settings are main's filed reds
  (gateway-caller-keys #3797, omarchy #4624, mobile-web #3952,
  images-codex-one #4618); the other 21 don't open Settings. Run on
  Linux (wsl-run, magpie-desktop), those 21: 269 pass, 98 fail here;
  270 pass, 97 fail on untouched origin/main 173b7e274, the same files
  red. The one difference was old-webkit, fixed above.
  The whole suite was not run again after .acts.

Not tried: the real app's WebKitGTK (Linux) and WebView2 (Windows), and
a real touch screen; the (hover: none) path is only by the media query.
This commit is contained in:
yetone
2026-11-03 09:47:25 +08:00
parent 1a92a97caa
commit 8e9b048b65
27 changed files with 392 additions and 66 deletions
+27
View File
@@ -3809,6 +3809,33 @@ input.words.compact-num { flex: none; width: 76px; font-variant-numeric: tabular
.row.pref.redact-kind .sub { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
/* an update that failed says why in full (the version row) */
.row .sub.wraps { white-space: normal; overflow-wrap: anywhere; }
/* Settings' lines that explain a setting rest out of sight, so the page is
its names and controls (the owner, 11-02): the pointer resting on a row,
or a key reaching it, shows them in a card under its name
(settingshints.js), and the rows don't move. They stay read by a screen
reader and by the search, which shows them in place. What isn't an
explanation stays: an error, a state (.say: the Version row's update,
a sync's last sync, the local model's, a check-in's result; the proxy
in use; a pattern's matches), a warning, a disclosure (what tracing
sends, who the allow list lets in), a line with a button or link in
it. A touch screen, with no hover, keeps them all. */
@media (hover: hover) {
#view-settings:not(.set-searching) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) {
--hint: 1; position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
/* a row left with its name alone is as tall as any other: its control
(a switch, a field, a shortcut) no longer sets it apart */
#view-settings .row.pref:not(.feat-set) { box-sizing: content-box; min-height: 27px; } /* 51 with its padding, a line above it outside */
/* Check in now's result comes under its name and the row grows down,
its button held where it was pressed */
#view-settings .ci-now-row { align-items: flex-start; }
}
.set-hint { position: fixed; z-index: 60; max-width: min(380px, calc(100vw - 32px)); padding: 8px 11px; border-radius: 9px; background: var(--pop-bg); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); font-size: 12px; line-height: 1.45; color: var(--fg-2); overflow-wrap: anywhere; pointer-events: none; opacity: 0; transform: translateY(-2px); transition: opacity .14s ease, transform .14s ease; }
.set-hint.on { opacity: 1; transform: none; }
.set-hint > p { margin: 0; }
.set-hint > p + p { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .set-hint { transition: none; transform: none; } }
:root[data-motion="reduce"] .set-hint { transition: none; transform: none; }
.prefs .val.rule-add { flex: 1 1 100%; max-width: none; margin-left: 0; gap: 6px; }
input.words.rule-kind { flex: none; width: 110px; }
input.words.gateway-port { flex: none; width: 110px; font-variant-numeric: tabular-nums; }input.words.rule-match { flex: 1 1 auto; width: auto; min-width: 0; }
+11 -12
View File
@@ -19481,10 +19481,10 @@ function setSetTab(tab, remember) {
if (b) setSetTab(b.dataset.set, true);
};
tabKeys(tabs, "button[data-set]");
// the tabs held at the top (app.css, #2396): a hairline under them once
// the page has scrolled beneath, as the Library's
// held tabs (#2396): a hairline once scrolled under
const sv = $("#view-settings"), head = sv.querySelector(":scope > .set-head");
sv.addEventListener("scroll", () => head.classList.toggle("stuck", sv.scrollTop > 0), { passive: true });
import("./settingshints.js").catch(() => {});
// opened on a part (a reload, a link): that part, and remembered
if (mode === "window" && params.get("view") === "settings" && SET_TABS.includes(params.get("tab"))) {
setTab = params.get("tab");
@@ -20031,6 +20031,7 @@ async function renderSync(v) {
// a failure is shown whole: what the server sent and what to do don't
// fit one line
if (v.error) sub.classList.add("bad", "wraps");
if (v.on) sub.classList.add("say");
// usage that couldn't be shared is a line of its own, in red: beside
// "Synced" in the same grey it read as part of a sync that went fine
// (#1259)
@@ -20060,8 +20061,8 @@ async function renderSync(v) {
else if (n.here?.length) lines.push(t("Replaced here by newer ones from another computer: {parts}", { parts: parts(n.here) }));
if (n.there?.length) lines.push(t("Replaced on the server by this computer's newer ones: {parts}", { parts: parts(n.there) }));
const who = el("div", "who");
for (const l of lines) who.append(el("div", "sub", l));
who.append(el("div", "sub", t(n.restored ? "This computer's setup from before is kept in the sync folder." : "The copies replaced are kept in the sync folder.")));
for (const l of lines) who.append(el("div", "sub say", l));
who.append(el("div", "sub say", t(n.restored ? "This computer's setup from before is kept in the sync folder." : "The copies replaced are kept in the sync folder.")));
const val = el("div", "val");
if (n.restored && v.undo) val.append(btn(t("Undo"), async (e) => {
e.target.classList.add("busy");
@@ -21868,11 +21869,8 @@ function renderRedact(s, keep) {
}
}
// privacyModelRow: the local masking model (internal/pii), downloaded when
// it is turned on and then asked beside the rules. Its state is its own
// (privacy-model): read when the row is drawn, and each second while it
// downloads or starts. Under it, once the model can run, its threshold
// (pmScore).
// privacyModelRow: the local masking model (internal/pii); its state read
// on drawing, each second while it downloads or starts; then pmScore.
let pmState = null, pmTimer = 0;
function privacyModelRow(box, why) {
const r = el("div", "row pref" + (why ? " pm-wait" : ""));
@@ -21885,7 +21883,7 @@ function privacyModelRow(box, why) {
if (why) {
clearTimeout(pmTimer);
const who = el("div", "who");
who.append(name(), el("div", "sub", why));
who.append(name(), el("div", "sub say", why));
r.append(who);
return;
}
@@ -21893,7 +21891,7 @@ function privacyModelRow(box, why) {
const draw = (m) => {
if (!r.isConnected) return;
const who = el("div", "who"), val = el("div", "val");
who.append(name(), el("div", "sub", pmSub(m)));
who.append(name(), el("div", m && (m.on || m.installed || !m.supported || pmBusy(m) || m.error || m.models?.some((x) => x.error)) ? "sub say" : "sub", pmSub(m)));
if (m?.supported || m?.installed) {
if (m.models?.length > 1) val.append(pmPick(m, (id) => act("pick", id)));
if (pmBusy(m)) {
@@ -22358,7 +22356,7 @@ async function renderUpdate(r, u) {
if (u == null) {
const bare = !r.querySelector(".sub"), early = bare && !updateBusy && Date.now() - updateLast?.at < 3e4;
if (early) renderUpdate(r, updateLast);
else if (bare) r.querySelector(".who").append(el("div", "sub", "\u00a0"));
else if (bare) r.querySelector(".who").append(el("div", "sub say", "\u00a0"));
u = await api(updatePath("update?fresh=1")).catch(() => null);
if (!u || !r.isConnected || seqOf(r) !== seq) return;
if (early) updateSeq.set(r, seq + 1); // stops timers
@@ -22366,6 +22364,7 @@ async function renderUpdate(r, u) {
updateLast = u, u.at ??= Date.now();
const who = r.querySelector(".who"), val = r.querySelector(".val");
const sub = who.querySelector(".sub") || who.appendChild(el("div", "sub"));
sub.classList.add("say");
sub.title = "";
sub.classList.remove("wraps");
// the release page's button outlives a redraw: a download redraws every
+1
View File
@@ -22,6 +22,7 @@ window.ciNowFill = function (row, s, by) {
const said = checkinNowSaid[by];
sub.textContent = said ? said.text : t("Checks one account in once now; the daily check-in's switches stay as they are");
sub.classList.toggle("err", !!said?.bad);
sub.classList.toggle("say", !!said); // what came of it: a state, kept in sight
const b = el("button", "text ci-now-go", t(accts.length > 1 ? "Check in…" : "Check in"));
b.type = "button";
b.disabled = !!said?.busy;
@@ -406,7 +406,7 @@ function renderWebPage(asked) {
segs([["", t("Off")], ["local", t("This computer")], ["lan", t("Local network")]], s.mode || "", (mode) => set({ mode }))).classList.add("web-page-mode");
if (s.mode) {
const why = s.error ? el("div", "sub err", s.error.startsWith("port ") ? t("Port {p} is taken by another program, magpie web perhaps: magpie tries again every few seconds", { p: s.port }) : t(s.error))
: el("div", "sub", s.serving ? t("Served; anyone with this link can change every setting") : t("Starting…"));
: el("div", "sub say", s.serving ? t("Served; anyone with this link can change every setting") : t("Starting…"));
const links = [s.link, ...(s.mode === "lan" ? s.network || [] : [])].filter(Boolean);
const box2 = el("div", "web-page-links");
for (const l of links) {
+75
View File
@@ -0,0 +1,75 @@
// Settings' explanations, shown on asking (the owner, 11-02: "让整个设计
// 页面看起来很简洁,很有呼吸感"). app.css keeps a row's lines that explain
// it out of sight (--hint: 1 on each); the pointer resting on the row, or a
// key reaching it, shows them here in a card under the row's name, over
// the page, so no row moves. The card takes no pointer: a click goes to
// what is under it. It goes when the pointer or focus leaves the row, the
// page scrolls, a key is pressed or the row is drawn again. Imported by
// app.js when the pointer or focus first comes to Settings, not at start.
const view = document.getElementById("view-settings");
const card = el("div", "set-hint");
card.setAttribute("aria-hidden", "true"); // a screen reader reads the lines in the row
document.body.append(card);
let row = null, wait = 0;
const acts = () => {
for (const s of view.querySelectorAll(".row.pref > .who > .sub")) s.classList.toggle("acts", !!s.querySelector("a, button, input, select, code, .searcher-failed"));
};
// before the page is painted again: no frame shows such a line hidden
new MutationObserver(acts).observe(view, { childList: true, subtree: true });
acts();
const hints = (r) => [...r.querySelectorAll(":scope > .who > .sub")]
.filter((s) => !s.hidden && getComputedStyle(s).getPropertyValue("--hint").trim() === "1" && s.textContent.trim());
function hide() {
clearTimeout(wait);
row = null;
card.classList.remove("on");
card.hidden = true;
}
function show(r) {
const subs = r.isConnected && !view.hidden ? hints(r) : [];
if (!subs.length) return hide();
card.replaceChildren(...subs.map((s) => el("p", "", s.textContent.trim())));
card.hidden = false;
const who = r.querySelector(":scope > .who").getBoundingClientRect(), box = r.getBoundingClientRect();
const w = card.offsetWidth, h = card.offsetHeight;
const left = Math.max(16, Math.min(who.left, innerWidth - 16 - w));
// under the row, or over it where the window ends first
const top = box.bottom + 4 + h <= innerHeight - 8 ? box.bottom + 4 : Math.max(8, box.top - 4 - h);
card.style.left = left + "px";
card.style.top = top + "px";
requestAnimationFrame(() => row === r && card.classList.add("on"));
}
function point(r, now) {
if (r === row) return;
hide();
if (!r) return;
row = r;
// a pointer passing over rows on its way shows nothing; resting does
wait = setTimeout(() => show(r), now ? 0 : 450);
}
const rowOf = (n) => n instanceof Element ? n.closest("#view-settings .row.pref") : null;
view.addEventListener("pointerover", (e) => e.pointerType !== "touch" && point(rowOf(e.target)));
view.addEventListener("pointerleave", () => hide());
view.addEventListener("pointerdown", () => hide(), true);
view.addEventListener("focusin", (e) => {
let key = true;
try { key = e.target.matches(":focus-visible"); } catch {} // Safari before 15.4
if (key) point(rowOf(e.target), true);
});
view.addEventListener("focusout", (e) => {
if (!rowOf(e.relatedTarget) || rowOf(e.relatedTarget) !== row) hide();
});
// a scroll takes the pointer's card away; focus's follows its row, which
// a key moving focus scrolls into sight
view.addEventListener("scroll", () => row?.contains(document.activeElement) ? show(row) : hide(), { passive: true, capture: true });
addEventListener("keydown", (e) => !/^(Tab|Shift|Alt|Meta|Control)$/.test(e.key) && hide(), true);
addEventListener("resize", hide);
hide();
// the pointer already on a row, or focus, as the import came
{
const on = view.querySelector(".row.pref:hover") || rowOf(document.activeElement);
if (on) point(on);
}
@@ -75,7 +75,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
assert.equal(await row.locator(".name").textContent(), w.name);
assert((await row.locator(".sub").textContent()).includes(w.sub));
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
@@ -73,7 +73,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await row.locator(".name").textContent(), w.name);
const sub = await row.locator(".sub").textContent();
assert(sub.includes(w.sub) && sub.includes(w.risk), sub);
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
@@ -75,7 +75,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await row.locator(".name").textContent(), w.name);
const sub = await row.locator(".sub").textContent();
assert(sub.includes(w.sub) && sub.includes(w.risk), sub);
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
+7 -2
View File
@@ -2,7 +2,8 @@
// Settings › Models › Disabled models (#1867, oxsean: a model the user
// never wants, claude-fable-5, kept being reached through a group, a
// fallback and an old session): the list says what it covers — only
// requests through magpie — each pattern with the models it turns off
// requests through magpie, on hover, as Settings' explanations are (the
// owner, 11-02) — each pattern with the models it turns off
// now and Enable; Disable… takes a model from the picker or a glob typed
// into it. Each saves the whole list on its own route, the page not moved
// by the click. In English, Chinese, Japanese and German, 1100 and 420 wide.
@@ -92,10 +93,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await fable.locator(".sub").textContent(), w.hits);
for (const part of [`#disabledAddRow .name`, `#disabledAddRow .sub`, `#disabledAdd`, `.disabled-model .name`, `.disabled-model .sub`, `.disabled-model button`]) {
const fit = await page.locator("#disabledModelsList " + part).first().evaluate((e) => {
// the add row's line explains it: out of sight at rest, whole in
// the hover card (settings-hints.test.cjs)
if (getComputedStyle(e).getPropertyValue("--hint").trim() === "1") return "hint";
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
});
assert(fit, `${part} fits at ${width}`);
if (part === "#disabledAddRow .sub") assert.equal(fit, "hint", `${part} shows at rest at ${width}`);
else assert.equal(fit, true, `${part} fits at ${width}`);
}
// Disable…: a glob typed into the picker is taken as typed
@@ -80,7 +80,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
assert.equal(await row.locator(".name").textContent(), w.name);
assert((await row.locator(".sub").textContent()).includes(w.sub));
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
+7 -5
View File
@@ -2,7 +2,8 @@
// #1865: chatgpt.com's Codex images backend draws the same image for
// gpt-image-2, gpt-image-2.5 or a made-up name, so Settings › Models ›
// Image generation lists a ChatGPT account's one GPT Image, its note saying
// ChatGPT picks the model, and the row says so while it draws. Before, it
// ChatGPT picks the model, and the row says so while it draws (in its
// hover card: the line explaining it rests out of sight). Before, it
// listed GPT Image 2 and 2.5 as if they differed. A gpt-image-2.5 saved
// when it was listed (imageGenShown) shows as that entry, is ticked in the
// picker, and picking that entry again saves nothing over it. An API key's
@@ -108,14 +109,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const button = draw.locator("button.rt-cond");
assert.equal((await button.textContent()).trim(), "GPT Image · Codex");
const line = draw.locator(".image-gen-vendor");
assert.equal(await line.isVisible(), true);
// the line explains the list: it rests out of sight, shown whole in the
// row's hover card (settings-hints.test.cjs)
assert.equal(await line.evaluate((e) => e.isConnected && getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
assert.match((await line.textContent()).trim(), want[lang].vendor);
assert.equal(await draw.locator(".image-gen-missing").count(), 0);
const fit = await page.evaluate(() => {
const l = document.querySelector("#imagesList .image-gen-vendor"), row = l.closest(".row").getBoundingClientRect(), r = l.getBoundingClientRect();
return { inRow: r.left >= row.left - 1 && r.right <= row.right + 1, scroll: document.documentElement.scrollWidth - document.documentElement.clientWidth };
return { scroll: document.documentElement.scrollWidth - document.documentElement.clientWidth };
});
assert.deepEqual(fit, { inRow: true, scroll: 0 });
assert.deepEqual(fit, { scroll: 0 });
shots.push([`${lang}-${width}`, await page.screenshot({ fullPage: true })]);
await click(page, button);
@@ -74,7 +74,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
assert.equal(await row.locator(".name").textContent(), w.name);
assert((await row.locator(".sub").textContent()).includes(w.sub));
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
+1 -1
View File
@@ -156,7 +156,7 @@ test("compat.js is the first of the page's own scripts", async () => {
// Sync, scrollends.js on the window's first scroll, profilerename.js
// when a saved profile's Rename is pressed; the checks above
// still read them
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
});
test("the styles hold up in Safari 15.0", async () => {
+16 -11
View File
@@ -2,9 +2,11 @@
// Settings → Privacy's local masking model (#1977): a row under the masking
// switches, there while either is on. On downloads the model, its progress
// shown and a Cancel beside it; once it is on, the row says where it runs.
// Off, a downloaded model can be deleted, after asking. Its words are shown
// in full, in every language, in a wide window and a narrow one, and a
// click moves nothing. Under it, the model's threshold is picked from the
// Off, a downloaded model can be deleted, after asking. What it says while
// downloading or on is a state, shown in full; off, its line explains it
// and rests out of sight, for the hover card (settingshints.js), as the
// threshold's does. In every language, in a wide window and a narrow one,
// and a click moves nothing. Under it, the model's threshold is picked from the
// app's menu too.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -110,8 +112,9 @@ const runs = {
failed: { device: "CPU", gpuError: "prediction failed" }, cpu: { device: "CPU" },
};
// what the row shows: its words and its New mark, whether they are cut,
// that it is inside the list, and that it is the page's first setting
// what the row shows: its words and its New mark, whether they rest out of
// sight for the hover card (hint) or are cut, that it is inside the list,
// and that it is the page's first setting
const look = (page) => page.evaluate(() => {
const r = document.querySelector("#privacyModelRow"), list = r.closest(".list").getBoundingClientRect();
const sub = r.querySelector(".sub"), b = r.getBoundingClientRect(), v = r.querySelector(".val").getBoundingClientRect();
@@ -119,6 +122,7 @@ const look = (page) => page.evaluate(() => {
name: r.querySelector(".name").firstChild.textContent, badge: r.querySelector(".name .badge.new")?.textContent, sub: sub.textContent,
first: r === document.querySelector("#setPage-privacy .list.prefs > .row"),
on: r.querySelector(".segs .opt.on")?.textContent, buttons: [...r.querySelectorAll("button.text")].map((x) => x.textContent),
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
inside: b.left >= list.left - 1 && b.right <= list.right + 1 && v.right <= b.right + 1,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
@@ -141,7 +145,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert(m.first, "the model is the first setting under the card");
assert(m.sub.includes("1.6 GB"), `says what it downloads: ${m.sub}`);
if (lang !== "en") assert(!/no rule can find|Turning it on/.test(m.sub), `translated: ${m.sub}`);
assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert(m.hint && m.inside && !m.wide, `off, the explanation rests out of sight, for the hover card: ${JSON.stringify(m)}`);
await page.mouse.move(width / 2, 300);
for (let i = 0; i < 20 && (await row.boundingBox()).y > 900; i++) {
@@ -157,12 +161,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
m = await look(page);
assert.equal(m.buttons.length, 1, "a Cancel while it downloads");
assert.equal(m.on, w.on);
assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert(!m.hint && !m.cut && m.inside && !m.wide, `the download's progress shown in full and inside: ${JSON.stringify(m)}`);
// then on, on the GPU
await page.waitForFunction((want) => document.querySelector("#privacyModelRow .sub").textContent === want, w.gpu);
m = await look(page);
assert.deepEqual(m.buttons, [], "nothing to cancel or delete while it is on");
assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert(!m.hint && !m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert.deepEqual(posts, ["on"]);
assert.deepEqual(await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]), before, "the click moved nothing");
assert.deepEqual(errors, []);
@@ -180,7 +184,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const m = await look(page);
await browser.close();
assert.equal(m.sub, runWords[lang][k], k);
assert(!m.cut && m.inside && !m.wide, `${k} shown in full and inside: ${JSON.stringify(m)}`);
assert(!m.hint && !m.cut && m.inside && !m.wide, `${k} shown in full and inside: ${JSON.stringify(m)}`);
assert.deepEqual(errors, []);
}
});
@@ -248,7 +252,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator("#privacyModelRow select").count(), 0, "no native select");
assert.equal((await pick.textContent()).trim(), "Privacy Filter");
let m = await look(page);
assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert(!m.hint && !m.cut && m.inside && !m.wide, `where it runs shown in full and inside: ${JSON.stringify(m)}`);
// the menu and the switch are two boxes: they stand apart, on one line
const gap = await page.evaluate(() => {
const p = document.querySelector("#privacyModelRow .pm-model").getBoundingClientRect(), s = document.querySelector("#privacyModelRow .segs").getBoundingClientRect();
@@ -298,6 +302,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const sub = r.querySelector(".sub"), b = r.getBoundingClientRect(), list = r.closest(".list").getBoundingClientRect();
return {
name: r.querySelector(".name").textContent, sub: sub.textContent, pick: r.querySelector("button.pm-score").textContent.trim(),
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
inside: b.left >= list.left - 1 && b.right <= list.right + 1, wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
@@ -306,7 +311,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(m.name, w.name);
if (lang !== "en") assert(!/less sure/.test(m.sub), `translated: ${m.sub}`);
assert.equal(m.pick, "0.8");
assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`);
assert(m.hint && m.inside && !m.wide, `the threshold's explanation rests out of sight, for the hover card: ${JSON.stringify(m)}`);
const before = await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]);
const menu = page.locator(".proto-menu");
const items = async () => {
+4 -1
View File
@@ -92,7 +92,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await reach(page, row);
assert.equal(await row.locator(".name").textContent(), w.name);
assert.ok((await row.locator(".sub").textContent()).includes(w.sub));
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.left >= 0 && r.right <= innerWidth + 1;
+5 -3
View File
@@ -2,8 +2,9 @@
// Settings' kinds of personal data (lc on Discord): under Mask personal data,
// while it is on, a row for each kind with Off/On, showing the user's choice
// or the kind's default; a click saves that kind alone with the rest of the
// settings as they were, and moves nothing. Their words are shown in full and
// nothing runs off the page. In every language, in a wide window and a
// settings as they were, and moves nothing. Their words are shown in full,
// or, where they only explain the kind, rest out of sight for the hover
// card (settingshints.js), and nothing runs off the page. In every language, in a wide window and a
// narrow one.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -91,6 +92,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
return {
id: r.dataset.redact, name: r.querySelector(".name").textContent, sub: sub.textContent,
on: r.querySelector(".segs .opt.on")?.textContent,
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
inside: b.left >= list.left - 1 && b.right <= list.right + 1 && v.right <= b.right + 1,
};
@@ -106,7 +108,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(Object.fromEntries(m.rows.map((r) => [r.id, r.on === onWord ? "on" : "off"])), want);
assert.equal(m.rows.find((r) => r.id === "ip").name, w.ip);
for (const r of m.rows) {
assert(r.sub.length > 4 && !r.cut, `${r.id}'s words shown in full: ${r.sub}`);
assert(r.sub.length > 4 && (r.hint || !r.cut), `${r.id}'s words shown in full, or kept for the hover card: ${r.sub}`);
assert(r.inside, `${r.id} inside the list`);
if (lang !== "en" && r.id !== "iban") assert.notEqual(r.name, english[r.id], `${r.id} translated`);
if (lang !== "en") assert.notEqual(r.sub, englishSub[r.id], `${r.id}'s words translated`);
+4 -2
View File
@@ -3,7 +3,8 @@
// 只有移除,能否增加一个编辑功能): each rule's row has Edit beside Remove.
// Edit opens the rule in its own row, where it stands, with its name, prefix
// or regex and what it matches filled in, the fields on a line under its
// words, none on top of another. Cancel changes nothing and sends nothing.
// words (its name, where its explanation rests out of sight for the hover
// card), none on top of another. Cancel changes nothing and sends nothing.
// A pattern the gateway refuses is said in the row, what was typed kept and
// the rule as it was; a good one is saved in the same place. No click moves
// the page. In every language, in a wide window and a narrow one.
@@ -110,7 +111,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// its fields on a line under its words, inside the row, none on top of another
const m = await ed.evaluate((r) => {
const box = (e) => { const b = e.getBoundingClientRect(); return { l: b.left, r: b.right, t: b.top, b: b.bottom, mid: (b.top + b.bottom) / 2, w: b.width }; };
return { row: box(r), sub: box(r.querySelector(".sub")), tools: [...r.querySelectorAll(".val input, .val .segs, .val button:not(.opt)")].map((e) => ({ cls: e.className, ...box(e) })), pageW: document.documentElement.scrollWidth, winW: innerWidth };
const sub = r.querySelector(".sub"), words = getComputedStyle(sub).getPropertyValue("--hint").trim() === "1" ? r.querySelector(".name") : sub;
return { row: box(r), sub: box(words), tools: [...r.querySelectorAll(".val input, .val .segs, .val button:not(.opt)")].map((e) => ({ cls: e.className, ...box(e) })), pageW: document.documentElement.scrollWidth, winW: innerWidth };
});
assert.deepEqual(m.tools.map((e) => e.cls.split(" ")[0]), ["words", "segs", "words", "text", "text"], "name, prefix or regex, match, Save, Cancel");
for (const e of m.tools) assert(e.w > 0 && e.l >= m.row.l - 1 && e.r <= m.row.r + 1, `in the row: ${JSON.stringify(m)}`);
+7 -6
View File
@@ -1,7 +1,8 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Settings' Masking rules row (TechVerser on X: 这个地方错位了吗?): its words
// are shown in full, and its fields — a name, prefix or regex, what to match,
// Add — sit on one line under them, from the row's left edge to its right,
// rest out of sight for the hover card (settingshints.js), and its fields —
// a name, prefix or regex, what to match, Add — sit on one line under its
// name, from the row's left edge to its right,
// none on top of another, the rules already added listed after it as before.
// In English and Chinese, in a wide window and a narrow one.
const assert = require("node:assert/strict");
@@ -64,19 +65,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const val = r.querySelector(".val");
return {
name: r.querySelector(".name").textContent, sub: sub.textContent,
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
who: box(r.querySelector(".who")), val: box(val), subBox: box(sub),
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
who: box(r.querySelector(".who")), val: box(val), nameBox: box(r.querySelector(".name")),
tools: [...val.children].map((e) => ({ cls: e.className, ...box(e) })),
};
});
assert.equal(m.name, w.name);
assert(m.sub.includes(w.sub) && m.sub.length > 20, `the row's words: ${m.sub}`);
assert(!m.cut, "the row's words are shown in full");
assert(m.hint, "the row's words rest out of sight, for the hover card");
assert.deepEqual(m.tools.map((e) => e.cls.split(" ")[0]), ["words", "segs", "words", "text"], "name, prefix or regex, match, Add");
const mid = m.tools[0].mid;
for (const e of m.tools) assert(Math.abs(e.mid - mid) < 2, `on one line: ${JSON.stringify(m.tools)}`);
for (let i = 1; i < m.tools.length; i++) assert(m.tools[i].l >= m.tools[i - 1].r, `none on top of another: ${JSON.stringify(m.tools)}`);
assert(m.tools[0].t >= m.subBox.b, "the fields are under the words");
assert(m.tools[0].t >= m.nameBox.b, "the fields are under the name");
assert(Math.abs(m.tools[0].l - m.who.l) < 1.5, `from the row's left edge: ${m.tools[0].l} vs ${m.who.l}`);
assert(Math.abs(m.tools[3].r - m.val.r) < 1.5, `to its right: ${m.tools[3].r} vs ${m.val.r}`);
+2 -2
View File
@@ -76,7 +76,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
name: r.querySelector(".name").textContent, sub: sub.textContent,
on: r.querySelector(".segs .opt.on")?.textContent,
first: r.previousElementSibling?.querySelector(".name")?.textContent === t("Mask secrets"),
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
inside: b.left >= list.left - 1 && b.right <= list.right + 1,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
@@ -84,7 +84,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(m.name, w.name);
assert.equal(m.on, w.off, "off unless the user turned it on");
assert(m.first, "right under Mask secrets");
assert(!m.cut && m.inside && !m.wide, "shown in full, inside the page");
assert(m.hint && m.inside && !m.wide, "its explanation rests out of sight, for the hover card, inside the page");
if (lang !== "en") assert(!m.sub.includes("made-up"), "its words translated");
const before = await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]);
@@ -74,7 +74,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
on: r.querySelector(".segs .opt.on")?.textContent,
// right under the words themselves
after: r.previousElementSibling?.querySelector("input.words") != null,
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
inside: b.left >= list.left - 1 && b.right <= list.right + 1,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
@@ -82,7 +82,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(m.name, w.name);
assert.equal(m.on, w.off, "off unless the user turned it on");
assert(m.after, "under Masked words");
assert(!m.cut && m.inside && !m.wide, "shown in full, inside the page");
assert(m.hint && m.inside && !m.wide, "its explanation rests out of sight, for the hover card, inside the page");
if (lang !== "en") assert(!m.sub.includes("A word also matches"), "its words translated");
const before = await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]);
@@ -74,7 +74,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
on: r.querySelector(".segs .opt.on")?.textContent,
// right under Masked words in any case
after: r.previousElementSibling?.id === "redactWordsAnyCaseRow",
cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1,
hint: getComputedStyle(sub).getPropertyValue("--hint").trim() === "1",
inside: b.left >= list.left - 1 && b.right <= list.right + 1,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
@@ -82,7 +82,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(m.name, w.name);
assert.equal(m.on, w.off, "off unless the user turned it on");
assert(m.after, "under Masked words in any case");
assert(!m.cut && m.inside && !m.wide, "shown in full, inside the page");
assert(m.hint && m.inside && !m.wide, "its explanation rests out of sight, for the hover card, inside the page");
if (lang !== "en") assert(!m.sub.includes("A word is not masked"), "its words translated");
const before = await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]);
@@ -76,7 +76,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
assert.equal(await row.locator(".name").textContent(), w.name);
assert((await row.locator(".sub").textContent()).includes(w.sub));
for (const part of [".name", ".sub", ".segs"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", ".segs"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
@@ -99,7 +99,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head);
assert.equal(await row.locator("select").count(), 0, "no native select");
assert.equal((await row.locator("button.sess-pick").textContent()).trim(), w.member, "memberModel on shows the member");
for (const part of [".name", ".sub", "button.sess-pick"]) {
// its explanation rests out of sight, shown whole in the row's hover card
// (settings-hints.test.cjs)
assert.equal(await row.locator(".sub").first().evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "1", "the explanation shows at rest");
for (const part of [".name", "button.sess-pick"]) {
const fit = await row.locator(part).first().evaluate((e) => {
const r = e.getBoundingClientRect();
return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
+16 -5
View File
@@ -14,9 +14,10 @@
// keeps the pick (prefsKeep). No click moves the page. English and Chinese, Chromium and
// WebKit, with the API faked. Search help covers costs for every provider and
// explains current eligibility without claiming a provider can never search.
// The help is also checked in Japanese and German, wrapped whole beside the
// picker at every width (arculongus on Discord: cut with an ellipsis on the
// desktop, it couldn't be read; settings-lines-wrap.test.cjs).
// The help is also checked in Japanese and German, whole in the hover card
// at every width (the owner, 11-02: a row's explanation rests out of sight;
// before, it wrapped whole beside the picker, arculongus on Discord: cut
// with an ellipsis on the desktop, it couldn't be read).
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -355,6 +356,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await row.locator(".searcher-relays").innerText(), h.relays);
assert.equal(await row.locator(".searcher-left-out").innerText(), h.left);
assert.equal(await row.locator("button.searcher-pick").innerText(), "Claude Haiku 4.5 · MyRelay");
const sub = row.locator(".sub");
assert.equal(await sub.getAttribute("class"), "sub", "every setting row's line wraps, with no class of its own to opt in");
// the help explains the row: it rests out of sight and the
// pointer on the row shows it whole in the card (the owner,
// 11-02; settings-hints.test.cjs), the hover above showing it
if (await sub.evaluate((s) => getComputedStyle(s).getPropertyValue("--hint").trim() === "1")) {
const card = page.locator(".set-hint.on");
await card.waitFor();
assert((await card.innerText()).includes(h.help), "the card has the help");
assert((await card.innerText()).includes(h.relays), "the card has the relays");
continue;
}
const layout = await row.evaluate((r) => {
const sub = r.querySelector(".sub");
const b = r.querySelector("button.searcher-pick").getBoundingClientRect();
@@ -367,8 +380,6 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
(s.right <= b.left + 1 || s.bottom <= b.top + 1) };
});
assert(layout.clipped <= 1 && layout.fits, JSON.stringify(layout));
const sub = row.locator(".sub");
assert.equal(await sub.getAttribute("class"), "sub", "every setting row's line wraps, with no class of its own to opt in");
assert.equal(layout.whiteSpace, "normal", "the help wraps");
assert(layout.overflow <= 1, JSON.stringify(layout));
if (process.env.ARTIFACT_DIR) {
+9 -3
View File
@@ -7,7 +7,9 @@
// 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);
// they wrap whole beside the control: arculongus on Discord); a line
// that explains its row rests out of sight and shows whole in the
// hover card instead (the owner, 11-02; settings-hints.test.cjs);
// - 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;
@@ -81,17 +83,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const rows = await page.evaluate(([bare, kept]) => {
const row = (sel) => document.querySelector(sel)?.closest(".row");
// an explanation rests out of sight, its words in the hover card
// (settingshints.js); the row reads as its name alone
const hint = (s) => getComputedStyle(s).getPropertyValue("--hint").trim() === "1";
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 }];
return [sel, !r || r.hidden ? "missing" : !s ? "no line" : hint(s) ? { text: s.textContent, hint: true } : { 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());
const oneLine = ![...r.querySelectorAll(".who .sub")].some((s) => s.getClientRects().length && s.textContent.trim() && !hint(s));
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 };
}),
};
@@ -103,6 +108,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
for (const [sel, sub] of rows.kept) {
assert.equal(typeof sub, "object", `${sel}: ${sub}`);
assert.ok(sub.text.trim(), `${sel}: ${JSON.stringify(sub)}`);
if (sub.hint) continue; // shown whole in the hover card (settings-hints.test.cjs)
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}`);
}
+153
View File
@@ -0,0 +1,153 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// The owner (11-02): Settings' lines that explain a setting are hidden, and
// shown on hover, so the page reads as its names and controls ("很简洁,很有
// 呼吸感"). In the window, in both engines, at 1100px and 420px, in every
// language, on Settings › Models:
// - at rest a row's explanation is out of sight (Image recognition MCP
// server's, Image generation's), but still in the page, for a screen
// reader and the search;
// - the pointer resting on the row shows it whole in a card under or over
// the row, not over its name, and no row on the page moves;
// - the pointer leaving the row takes the card away;
// - a key reaching the row's control shows it too;
// - an error (a picked model that's gone) and a warning (the image model
// picked is unticked in its provider) stay in sight at rest;
// - a search shows the explanations in place, and finds a row by them.
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, openPart } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
function settings(lang) {
return {
theme: "light", lang, tray: "panel", currency: "usd", textSize: 100, proxy: "", proxyNow: "none", proxySource: "none",
redact: true, redactPersonal: true, redactWords: [], version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
lanURLs: [], searchVendors: [], searchAPIs: [],
// the picked model is gone: Image recognition says so, in red
vision: "zz/gone", visionMissing: "zz/gone", visionAuto: "codex/gpt-5",
visionModels: [{ id: "codex/gpt-5", name: "GPT-5", provider: "codex", providerName: "Codex" }],
// the image model picked is unticked in its provider: a warning
imageGen: "codex/gpt-image-2", imageGenHidden: true, imageGenAuto: "codex/gpt-image-2",
imageGenModels: [{ id: "codex/gpt-image-2", name: "GPT Image", provider: "codex", providerName: "Codex", icon: "openai", vendorPicks: true }],
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
};
}
function serve(lang) {
return async (r) => {
const url = new URL(r.request().url());
const json = (data) => r.fulfill({ 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(lang) });
if (url.pathname === "/api/settings") return json(settings(lang));
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/builtin") return json([]);
if (url.pathname === "/api/plugins") return json({ bun: true, bunVersion: "1.4.2", plugins: [], picker: false, movable: [] });
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)];
const body = await fs.readFile(file).catch(() => null);
await (body ? r.fulfill({ body, contentType }) : r.fulfill({ status: 404, body: "" }));
};
}
// every row's box on the part shown, to tell that none moved
const boxes = () => [...document.querySelectorAll("#setPage-models .row.pref")].map((r) => {
const b = r.getBoundingClientRect();
return [Math.round(b.top), Math.round(b.height)].join(",");
});
const inSight = (e) => { const b = e.getBoundingClientRect(); return b.height > 4 && b.width > 4; };
const engines = process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"];
for (const engine of engines) {
test(`${engine}: Settings' explanations show on hover and focus`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
t.after(() => browser.close());
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [1100, 420]) {
await t.test(`${lang} at ${width}px`, async () => {
const ctx = await browser.newContext({ viewport: { width, height: 800 }, reducedMotion: "reduce" });
const page = await ctx.newPage();
page.setDefaultTimeout(8000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.addInitScript(() => Object.defineProperty(navigator, "platform", { get: () => "MacIntel" }));
await page.route("**/*", serve(lang));
await watchSettingsReads(page);
await page.goto("http://magpie.test/?view=settings&tab=models");
await settingsDrawn(page);
await openPart(page, "models");
const mcp = page.locator("#visionMcpRow");
await mcp.waitFor();
const hint = mcp.locator(":scope > .who > .sub").first();
const text = (await hint.textContent()).trim();
assert.ok(text.length > 20, "the MCP server row has its explanation");
// at rest: out of sight, but in the page
assert.equal(await hint.evaluate(inSight), false, "the explanation shows at rest");
assert.equal(await hint.evaluate((e) => e.isConnected && !e.hidden), true);
// an error and a warning stay in sight
const err = page.locator("#imagesList .vision-missing");
await err.waitFor({ state: "attached" });
assert.equal(await err.evaluate(inSight), true, "the gone model's error is out of sight");
const warn = page.locator("#imagesList .image-gen-hidden");
await warn.waitFor({ state: "attached" });
assert.equal(await warn.evaluate(inSight), true, "the unticked image model's warning is out of sight");
// a line with something to press in it stays in sight, as it is
// drawn: given a link, the MCP line shows; the link gone, it rests
// again (settingshints.js marks it .acts; Safari 15.0 has no :has())
await hint.evaluate((e) => e.append(Object.assign(document.createElement("a"), { href: "#", textContent: "Open" })));
await page.waitForFunction((e) => { const b = e.getBoundingClientRect(); return b.height > 4 && b.width > 4; }, await hint.elementHandle());
await hint.evaluate((e) => e.querySelector("a").remove());
await page.waitForFunction((e) => e.getBoundingClientRect().height <= 4, await hint.elementHandle());
// the pointer resting on the row: a card with the whole line, and
// nothing moves
await mcp.evaluate((e) => e.scrollIntoView({ block: "center" }));
await page.mouse.move(1, 1);
const before = await page.evaluate(boxes);
await mcp.locator(":scope > .who > .name").hover();
const card = page.locator(".set-hint.on");
await card.waitFor();
assert.equal((await card.textContent()).includes(text), true, "the card doesn't say the row's line");
const name = await mcp.locator(":scope > .who > .name").boundingBox(), cb = await card.boundingBox();
assert.ok(cb.y >= name.y + name.height || cb.y + cb.height <= name.y, "the card covers the row's name");
assert.ok(cb.x >= 15 && cb.x + cb.width <= width - 15, `the card runs out of the window: ${JSON.stringify(cb)}`);
assert.deepEqual(await page.evaluate(boxes), before, "a row moved when the card showed");
assert.equal(await card.evaluate((e) => getComputedStyle(e).pointerEvents), "none");
// the pointer gone: the card goes
await page.mouse.move(1, 1);
await page.locator(".set-hint").waitFor({ state: "hidden" });
// a key reaching the row's control shows it
const ctl = mcp.locator(":scope > .val button").first();
await ctl.focus();
// (WebKit's Tab passes buttons by, as Safari's does; Option-Tab doesn't)
const tab = engine === "webkit" ? "Alt+Tab" : "Tab";
await page.keyboard.press("Shift+" + tab);
await page.keyboard.press(tab);
assert.equal(await mcp.evaluate((r) => r.contains(document.activeElement)), true, "Tab didn't come back to the row's copy button");
await card.waitFor();
assert.equal((await card.textContent()).includes(text), true, "focus showed another row's card");
await page.mouse.move(1, 1);
// the search: explanations in place, and a row found by one
const words = text.split(/\s+/).find((w) => w.length > 5 && !/[<>:]/.test(w)) || text.slice(0, 6);
await page.locator("#setQ").fill(words.toLowerCase());
await page.locator("#view-settings.set-searching").waitFor();
await mcp.waitFor();
assert.equal(await hint.evaluate(inSight), true, "a search keeps the explanation out of sight");
assert.deepEqual(errors, []);
await ctx.close();
});
}
});
}
@@ -69,6 +69,9 @@ const measure = (scope) => {
const rb = r.getBoundingClientRect();
for (const s of r.querySelectorAll(".who .sub")) {
if (!shown(s) || !s.textContent.trim()) continue;
// an explanation kept out of sight shows whole in its card on hover
// (settings-hints.test.cjs)
if (getComputedStyle(s).getPropertyValue("--hint").trim() === "1") continue;
const cs = getComputedStyle(s);
if (s.scrollWidth > s.clientWidth + 1 || cs.whiteSpace === "nowrap") cut.push({ text: s.textContent.slice(0, 80), scroll: s.scrollWidth, width: s.clientWidth, whiteSpace: cs.whiteSpace });
}
@@ -115,7 +118,17 @@ for (const engine of engines) {
await openPart(page, "models");
for (const sel of ["#imagesList .image-gen-vendor", "#visionMcpRow .sub", ".searcher-row .who > .sub"]) {
const s = page.locator(sel).first();
await s.waitFor();
await s.waitFor({ state: "attached" });
if (await s.evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim() === "1")) {
// out of sight at rest: the row's card shows it whole
await s.evaluate((e) => e.closest(".row.pref").scrollIntoView({ block: "center" }));
await s.locator("xpath=ancestor::div[contains(concat(' ', @class, ' '), ' pref ')][1]").locator(":scope > .who > .name").hover();
const card = page.locator(".set-hint.on");
await card.waitFor();
assert.ok((await card.textContent()).includes((await s.textContent()).trim()), `${sel} isn't in its card`);
await page.mouse.move(0, 0);
continue;
}
const whole = await s.evaluate((e) => e.scrollWidth <= e.clientWidth + 1 && getComputedStyle(e).whiteSpace !== "nowrap");
assert.equal(whole, true, `${sel} is cut`);
}