settings: every row has its line and the same room above and below its words

The owner (10-22, a screenshot of Settings → General): no line above
"Open at login", and the rows' space above and below differed.

- The line between rows is `.row + .row`; Settings' agent-pref link box
  (#agentPrefLinks, empty but while searching) sits between "Provider in
  model names" and "Open at login", so that row had none. The row after
  the box, and the box's own first row, now get it.
- In the window every row had `body.window .row`'s 7px, which beat
  `.row.pref` on specificity: one-line rows were centred by min-height
  (13-15px around their words), a row with a line under its name had
  7-8px. Every settings row now has 12px above and below; the Language
  and Session terminal buttons are 26px as the segments are, so every
  one-line row is 51px and a two-line row 61px, in both engines.
- A row's new line now grows it ~12px (was 1-2px under min-height).
  hold() kept a view at its top only while the clicked control moved
  less than half its height, so turning automatic updates off scrolled
  About 12px (#2134 says the view stays at its top). The bound is now the
  control's height; #961's ~138px stage still holds the bar.
- turn-done, reset-reminder and usage-alert clicked a switch left under
  the window's foot or the tabs; Playwright's scroll to it read as the
  page moving. They now reach() it first; update-restart's at-top bound
  is "less than the switch's height", not 4px.

Run at this tree (worktree magpie-wt/setrows, base 86254d404):
- settings-general: 20/20 (chromium+webkit, 5 languages, 1000/440).
  Red with the old CSS (fullContextRow 7px above), and red with only
  the line rule taken out ("loginRow has no line above it").
- The 94 GUI files that touch settings rows: 1559 pass, 61 red; against
  the old CSS 56 of them passed. Those 56 are fixed above:
  update-restart + update-auto 32/32, turn-done + reset-reminder +
  usage-alert 36/36. mobile-web's desktop screenshots differ from
  origin/main by design (the change itself).
- Red on the old CSS too: s3-sync (webkit en), usage-checkin (webkit en,
  zh).
- go test ./internal/gui ok.
Not run before push: the whole GUI suite (830 files) is running now;
reds it finds go in their own commits.
This commit is contained in:
yetone
2026-10-22 18:51:56 +08:00
parent ccbc727818
commit 46176fc14f
7 changed files with 61 additions and 23 deletions
+8 -2
View File
@@ -555,6 +555,9 @@ body.panel .list { border: 0; border-radius: 10px; box-shadow: var(--card-edge);
.row { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 5px 9px 5px 11px; }
body.window .row { min-height: 48px; padding: 7px 12px 7px 14px; gap: 12px; }
.row + .row, .editor + .row, .row + .editor { border-top: 1px solid var(--line-2); }
/* Settings' agent-pref link box sits between two rows, empty but for a search:
the row after it, and its own first row, still get their line (the owner, 10-22) */
#agentPrefLinks + .row, .row + #agentPrefLinks > .row:first-child { border-top: 1px solid var(--line-2); }
.row .ic { width: 18px; height: 18px; }
body.window .row .ic { width: 22px; height: 22px; }
.row .name { font-weight: 500; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@@ -3411,7 +3414,10 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0
/* a built-in page a plugin's page replaces steps aside in the sidebar */
#nav button[data-replaced] { display: none !important; }
img.nav-ic { border-radius: 3px; object-fit: contain; }
.row.pref { min-height: 50px; padding: 8px 12px 8px 14px; gap: 14px; }
/* one space above and below every row's content, a row with a line under its
name too: the window's 7px for every row made those read cramped beside the
one-line rows, which min-height centred (the owner, 10-22) */
.row.pref, body.window .row.pref { min-height: 48px; padding: 12px 12px 12px 14px; gap: 14px; }
.row.pref .who { flex: 1 1 auto; }
.row.pref .sub { margin-top: 2px; color: var(--fg-2); }
.row.pref.font-row { flex-wrap: wrap; gap: 8px 14px; }
@@ -3439,7 +3445,7 @@ img.nav-ic { border-radius: 3px; object-fit: contain; }
#otelList .otel-stacked .segs { margin-left: 0; max-width: 100%; flex-wrap: wrap; }
#otelList .otel-env { padding: 12px 14px; border-top: 1px solid var(--line-2); font-size: 11.5px; color: var(--muted); }
.session-terminal-select, .pref-pick { max-width: min(230px, 45%); height: 29px; color: var(--fg); }
.session-terminal-select, .pref-pick { max-width: min(230px, 45%); height: 26px; color: var(--fg); }
.session-terminal-select:focus-visible, .pref-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.pref .segs { flex: none; margin-left: auto; }
.proxy-segs { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-left: auto; min-width: 0; max-width: 100%; }
+6 -4
View File
@@ -23882,10 +23882,12 @@ function hold(h) {
// what was clicked moves it down rather than scrolling the view to follow
// it. Turning automatic updates off grew the Version row above the
// switch once the save answered, and the view slid 2px off its top (#2134).
// Only while what was clicked stays under the pointer, moved by less than
// half its height: a day picked on Routing brings its stage in above the
// bar (~138px), and the bar is held where it was clicked (#961)
if (h.top && want > 0 && Math.abs(d) < a[0].getBoundingClientRect().height / 2) want = 0;
// Only while what was clicked moved by less than its height, a line come
// in above it: a day picked on Routing brings its stage in above the bar
// (~138px), and the bar is held where it was clicked (#961). Half its
// height was too little once a settings row kept 12px above and below its
// words: the Version row's line grew it 12px past a 22px switch (10-22)
if (h.top && want > 0 && Math.abs(d) < a[0].getBoundingClientRect().height) want = 0;
// a view at its top when clicked stays there rather than be given room
// to scroll down: a chip saved in the panel's Profiles came in above the
// button held, and room made for the button slid the chip up under the
+11 -5
View File
@@ -9,7 +9,7 @@ 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 { watchSettingsReads, settingsDrawn, reach } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
@@ -83,19 +83,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator("#resetReminderSegs .opt.on").textContent(), w.off);
assert.equal(await page.locator("#resetReminderRow select").count(), 0);
await page.locator("#resetReminderRow").scrollIntoViewIfNeeded();
await page.waitForTimeout(200);
const top = await page.locator("#view-settings").evaluate((v) => v.scrollTop);
// each control wheeled wholly into sight, clear of the tabs and the
// window's foot, before it is clicked: Playwright's own scroll to one
// cut off moved the page, not the click (10-22, taller rows)
const scrolled = () => page.locator("#view-settings").evaluate((v) => v.scrollTop);
await reach(page, opts.nth(2));
let top = await scrolled();
await opts.nth(2).click();
assert.equal((await posted(1)).resetReminder, 24);
await page.waitForTimeout(300);
assert.equal(await page.locator("#resetReminderSegs .opt.on").textContent(), w.h(24));
assert.equal(await scrolled(), top, "the click moved the page");
// another setting saved later keeps it
await reach(page, page.locator("#currencySegs .opt", { hasText: w.cny }));
top = await scrolled();
await page.locator("#currencySegs .opt", { hasText: w.cny }).click();
assert.equal((await posted(2)).resetReminder, 24, "kept by another save");
await page.waitForTimeout(300);
assert.equal(await page.locator("#view-settings").evaluate((v) => v.scrollTop), top, "no click moved the page");
assert.equal(await scrolled(), top, "no click moved the page");
await opts.nth(0).click();
assert.equal((await posted(3)).resetReminder, 0, "Off saves 0");
+15 -1
View File
@@ -12,7 +12,11 @@
// - 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.
// - 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");
@@ -83,6 +87,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}),
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`);
@@ -96,6 +105,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
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");
+11 -5
View File
@@ -9,7 +9,7 @@ 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 { watchSettingsReads, settingsDrawn, reach } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
@@ -96,19 +96,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
});
assert.deepEqual(over, [], "nothing past the edge");
await page.locator("#turnDoneRow").scrollIntoViewIfNeeded();
await page.waitForTimeout(200);
const top = await page.locator("#view-settings").evaluate((v) => v.scrollTop);
// each control wheeled wholly into sight, clear of the tabs and the
// window's foot, before it is clicked: Playwright's own scroll to one
// cut off moved the page, not the click (10-22, taller rows)
const scrolled = () => page.locator("#view-settings").evaluate((v) => v.scrollTop);
await reach(page, opts.nth(2));
let top = await scrolled();
await opts.nth(2).click();
assert.equal((await posted(1)).turnDoneAlert, 180);
await page.waitForTimeout(300);
assert.equal(await page.locator("#turnDoneSegs .opt.on").textContent(), w.m(3));
assert.equal(await scrolled(), top, "the click moved the page");
// another setting saved later keeps it
await reach(page, page.locator("#currencySegs .opt").nth(1));
top = await scrolled();
await page.locator("#currencySegs .opt").nth(1).click();
assert.equal((await posted(2)).turnDoneAlert, 180, "kept by another save");
await page.waitForTimeout(300);
assert.equal(await page.locator("#view-settings").evaluate((v) => v.scrollTop), top, "no click moved the page");
assert.equal(await scrolled(), top, "no click moved the page");
await opts.nth(0).click();
assert.equal((await posted(3)).turnDoneAlert, 0, "Off saves 0");
+6 -5
View File
@@ -147,10 +147,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// automatic updates off: kept, dimmed, says when it works
// (the version row above then says automatic updates are off, a
// line that can grow it by a pixel or two: what is held is the
// control clicked, where it is on the screen, unless the view is at
// its top, which stays at its top and lets the switch move down by
// those pixels, #2134)
// line that grows it about 12px: what is held is the control
// clicked, where it is on the screen, unless the view is at its
// top, which stays at its top and lets the switch move down by
// less than its height, #2134)
await showRow(page, auto);
const settings = page.locator("#view-settings");
const atTop = await settings.evaluate((v) => v.scrollTop < 1);
@@ -164,7 +164,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const y1 = (await auto.locator(".opt").nth(0).boundingBox()).y;
if (atTop) {
assert.equal(await settings.evaluate((v) => v.scrollTop), 0, "a view at its top stays at its top");
assert.ok(y1 - y0 >= -1 && y1 - y0 <= 4, `the clicked switch moved ${y1 - y0}px`);
const tall = (await auto.locator(".opt").nth(0).boundingBox()).height;
assert.ok(y1 - y0 >= -1 && y1 - y0 < tall, `the clicked switch moved ${y1 - y0}px, its height ${tall}px`);
} else assert.ok(Math.abs(y1 - y0) <= 1, `the clicked switch moved ${y1 - y0}px`);
// and off again
+4 -1
View File
@@ -12,7 +12,7 @@ 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 { watchSettingsReads, settingsDrawn, reach } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
@@ -138,6 +138,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// scrolled down with the wheel (the rows to the middle, clear of
// the footer), turning it on moves nothing
await wheelTo(page);
// and the switch clear of the tabs: Playwright's own scroll to one
// under them moved the page, not the click (10-22, taller rows)
await reach(page, usageSegs.nth(1));
const before = await view(page);
assert(before > 0, "the settings list must be long enough to scroll");
await usageSegs.nth(1).click();