routing: the group being edited reads as selected, its Save in reach (Jiabubu)
Jiabubu (Discord, #feedback): on Routing, the group being edited looked like the groups above it, and Save was a small text button at the editor's foot, a long scroll down. The editor in the groups list now reads as the selected row: a soft accent tint (4% over the card) and a 1.5px accent ring all round, its corners following the list's when it is first or last. No stripe down one side. Its bar (Remove, Cancel, Save) is sticky at the bottom of the view while the editor's rows scroll by, on the editor's own tint, and sits where it always was once its foot is reached. Cancel and Save are 28px tall at 13px (were 23px at 12px); the web's 44px touch size still wins on a phone. The list clips its overflow instead of hiding it (overflow: clip, with hidden as the fallback), so the bar can stick. Nothing else on the page moves (#1354). Measured, editing the third of four groups (a ten-member group) with its head near the top of a 760px window: Save was at y 1845 (1000 wide) and 3013 (420 wide), out of sight; now at 714 and 694, in sight, in Chromium and WebKit. group-editor-selected.test.cjs, in Chromium and WebKit, desktop and web, 1100/770/420 wide, en/zh/zh-TW/ja/de (and dark in zh): the editor is tinted apart from the other rows and has a ring, both sides alike; scrolled by the reader to its head, Save and Cancel are in the window, uncovered, 28px and 13px or more; scrolled to its foot, the bar follows the last row inside the editor. Broken by hand: with origin/main's routing.css it fails at "light desktop 1100 en: the editor is tinted apart from the other groups"; with only the list's overflow: clip taken out, at "Save is in the window (1353-1381)". Run on mote at this tree (on origin/main8abdf53a8), with mote at load 164-191 from other sessions: the new test 2 of 2 ok; the GUI files this can reach (360 files, every one naming a usage card, the panel card, the routing page, app.css, i18n or a budget; both engines, every language, narrow widths), 5573 of 5668 ok. The 22 red files were run again alone at this head and at8abdf53a8: three were this change (routing-save-blank and routing-save-keeps-the-row wheeled until Save was in sight, which it now is at once, so they wheel to the editor's foot; quota-holds took a faded "not enough data" as muted, now the reset line's caption colour), fixed here and green at concurrency 2. The rest are red at8abdf53a8too (account-eye #4244, routing-rule-* #4585, tray-cell-click and usage-fold #4790, numbers on #4932). The whole suite was started once and stopped at 316 tests after an hour at that load; it was not run to the end. Rebased on origin/main1851ead1a(app.css and the usage page changed), then run again at the pushed head: go test -run 'Budget|CSS' ./internal/gui ok, and quota-caption-contrast, group-editor-selected, quota-holds, routing-save-blank, routing-save-keeps-the-row, plan-credits and balance-fix, 154 of 154 ok in both engines. Not tried: the real app's window, and WebKitGTK on Linux. Reported by Jiabubu on Discord (#feedback).
This commit is contained in:
@@ -561,6 +561,19 @@ button.rt-session { cursor: pointer; }
|
||||
.rt-group.rt-gpick { cursor: default; }
|
||||
.rt-group.rt-gpick.on { background: var(--card-2); }
|
||||
.rt-gedit { cursor: default; scroll-margin-top: 12px; }
|
||||
/* the group being edited reads as selected among the others: a soft tint
|
||||
and an accent ring, as a list marks its selected row; its Save and
|
||||
Cancel stay at the bottom of the window while its rows scroll by, at a
|
||||
push button's size (Jiabubu on Discord). The list clips instead of
|
||||
hiding its overflow, so the bar can stick. */
|
||||
.list.rt-groups { overflow: hidden; overflow: clip; }
|
||||
.rt-groups > .rt-gedit { --ged-bg: color-mix(in srgb, var(--accent) 4%, var(--card)); background: var(--ged-bg); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); }
|
||||
.rt-groups > .rt-gedit:first-child { border-radius: 11px 11px 0 0; }
|
||||
.rt-groups > .rt-gedit:last-child { border-radius: 0 0 11px 11px; }
|
||||
.rt-groups > .rt-gedit:only-child { border-radius: 11px; }
|
||||
.rt-groups > .rt-gedit + * { border-top-color: transparent; }
|
||||
.rt-gedit > .bar { position: sticky; bottom: 0; z-index: 3; background: var(--ged-bg, var(--card)); padding-bottom: 10px; margin-bottom: -10px; }
|
||||
.rt-gedit > .bar > button.text:not(.danger) { height: 28px; padding: 0 12px; border-radius: 7px; font-size: 13px; }
|
||||
.rt-gedit .ehead.folds { cursor: pointer; }
|
||||
.rt-gedit .ehead.folds:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
.rt-gedit .segs { max-width: 100%; }
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Editing a routing group (Jiabubu on Discord, #feedback): the group being
|
||||
// edited looked like the groups around it, and Save was a small text button
|
||||
// at the editor's foot, a long scroll down. Now the editor reads as the
|
||||
// selected row (a tint and an accent ring, no stripe down one side), and
|
||||
// its Save and Cancel stay in the window while the editor's rows scroll by,
|
||||
// at a push button's size. In both engines, desktop and web, at 1100, 770
|
||||
// and 420, in every language.
|
||||
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 assets = path.resolve(__dirname, "../assets");
|
||||
const ids = ["an/opus", "an/sonnet", "oa/gpt-5", "oa/gpt-5-mini", "gg/gemini-3-pro", "gg/gemini-3-flash", "ds/deepseek-v4", "kk/kimi-k3", "zh/glm-5", "qw/qwen-4"];
|
||||
const models = ids.map((id) => ({ id, name: id.split("/")[1], providerName: id.split("/")[0].toUpperCase(), icon: "generic" }));
|
||||
const grp = (id, name, members) => ({ id, name, members, match: [], fast: [], off: [], routing: "order", ready: true, memberInfo: members.map((m) => ({ id: m, ready: true })) });
|
||||
const groups = () => ({ models, pools: [], groups: [grp("fast", "Fast", ids.slice(0, 3)), grp("cheap", "Cheap", ids.slice(3, 6)), grp("coding", "Coding", ids), grp("free", "Free", ids.slice(6))] });
|
||||
|
||||
function serve(lang, theme, web) {
|
||||
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme } };
|
||||
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:"${theme}",web:${web}};` });
|
||||
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/gateway/trace") {
|
||||
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
|
||||
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
|
||||
if (url.pathname === "/api/groups") return json(groups());
|
||||
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.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"])) {
|
||||
test(`${engine}: the group being edited reads as selected, its Save in reach`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const theme of ["light", "dark"]) {
|
||||
for (const web of [false, true]) {
|
||||
for (const width of [1100, 770, 420]) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
// the other theme in one language a width is enough
|
||||
if (theme === "dark" && lang !== "zh") continue;
|
||||
const at = `${theme} ${web ? "web" : "desktop"} ${width} ${lang}`;
|
||||
const context = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce", colorScheme: theme });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, theme, web));
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const card = page.locator(".rt-group", { hasText: "Coding" });
|
||||
await card.waitFor();
|
||||
await card.locator("button.text").first().click();
|
||||
const ed = page.locator(".rt-gedit");
|
||||
await ed.waitFor();
|
||||
// the editor's head at the top of the window, its foot far below
|
||||
// as the reader scrolls (the app puts back a scroll that isn't theirs)
|
||||
await page.mouse.move(width / 2, 400);
|
||||
await page.mouse.wheel(0, Math.round((await ed.boundingBox()).y) - 90);
|
||||
await page.waitForFunction(() => document.querySelector(".rt-gedit").getBoundingClientRect().top < 200);
|
||||
const got = await page.evaluate(() => {
|
||||
const ed = document.querySelector(".rt-gedit");
|
||||
const row = document.querySelector(".rt-groups > .rt-group");
|
||||
const cs = getComputedStyle(ed), rs = getComputedStyle(row);
|
||||
const save = ed.querySelector(":scope > .bar > .primary"), cancel = [...ed.querySelectorAll(":scope > .bar > .text")].find((b) => !b.classList.contains("primary") && !b.classList.contains("danger"));
|
||||
const r = save.getBoundingClientRect(), cx = r.left + r.width / 2, cy = r.top + r.height / 2;
|
||||
const hit = document.elementFromPoint(cx, cy);
|
||||
return {
|
||||
tall: ed.getBoundingClientRect().bottom > innerHeight + 50 && ed.getBoundingClientRect().top < 200,
|
||||
bg: cs.backgroundColor, rowBg: rs.backgroundColor, ring: cs.boxShadow,
|
||||
sides: [cs.borderLeftWidth, cs.borderRightWidth, cs.borderLeftColor, cs.borderRightColor],
|
||||
save: { top: r.top, bottom: r.bottom, h: r.height, font: parseFloat(getComputedStyle(save).fontSize), onTop: save === hit || save.contains(hit) },
|
||||
cancel: { h: cancel.getBoundingClientRect().height, font: parseFloat(getComputedStyle(cancel).fontSize) },
|
||||
};
|
||||
});
|
||||
assert.ok(got.tall, `${at}: the editor starts near the top and runs past the window (the case under test)`);
|
||||
assert.notEqual(got.bg, got.rowBg, `${at}: the editor is tinted apart from the other groups`);
|
||||
assert.match(got.ring, /inset/, `${at}: the editor has a ring all round`);
|
||||
assert.equal(got.sides[0], got.sides[1], `${at}: no stripe down one side`);
|
||||
assert.equal(got.sides[2], got.sides[3], `${at}: no coloured stripe down one side`);
|
||||
assert.ok(got.save.top >= 0 && got.save.bottom <= 700, `${at}: Save is in the window (${Math.round(got.save.top)}–${Math.round(got.save.bottom)})`);
|
||||
assert.ok(got.save.onTop, `${at}: nothing covers Save`);
|
||||
assert.ok(got.save.h >= 28 && got.save.font >= 13, `${at}: Save is a push button's size (${got.save.h}px, ${got.save.font}px)`);
|
||||
assert.ok(got.cancel.h >= 28 && got.cancel.font >= 13, `${at}: Cancel matches it (${got.cancel.h}px, ${got.cancel.font}px)`);
|
||||
// scrolled to the foot, the bar is where it always was: after
|
||||
// the editor's last row
|
||||
{
|
||||
const b = await ed.boundingBox();
|
||||
await page.mouse.wheel(0, Math.round(b.y + b.height - 700 + 40));
|
||||
}
|
||||
await page.waitForFunction(() => document.querySelector(".rt-gedit").getBoundingClientRect().bottom <= innerHeight);
|
||||
const foot = await page.evaluate(() => {
|
||||
const ed = document.querySelector(".rt-gedit"), bar = ed.querySelector(":scope > .bar");
|
||||
const last = bar.previousElementSibling;
|
||||
return { gap: bar.getBoundingClientRect().top - last.getBoundingClientRect().bottom, edBottom: ed.getBoundingClientRect().bottom - bar.getBoundingClientRect().bottom };
|
||||
});
|
||||
assert.ok(foot.gap >= 0, `${at}: at the foot the bar follows the last row (${foot.gap})`);
|
||||
assert.ok(foot.edBottom >= 0, `${at}: and sits inside the editor`);
|
||||
assert.deepEqual(errors, [], at);
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,11 +101,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await save.waitFor();
|
||||
const view = page.locator("#view-routing");
|
||||
const box = await view.boundingBox();
|
||||
// the reader scrolls down to the Save, as they must: the editor is taller
|
||||
// than the window
|
||||
// the reader scrolls down to the editor's foot: the editor is taller
|
||||
// than the window (its Save stays in sight on the way, held at the
|
||||
// view's foot, but the case here is a Save from down the page)
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
||||
for (let i = 0; i < 200; i++) {
|
||||
const b = await save.boundingBox();
|
||||
const b = await page.locator(".rt-gedit").boundingBox();
|
||||
if (b && b.y + b.height <= box.y + box.height) break;
|
||||
if (await view.evaluate((v) => v.scrollTop + v.clientHeight >= v.scrollHeight - 1)) break;
|
||||
await page.mouse.wheel(0, 120);
|
||||
|
||||
@@ -110,11 +110,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await save.waitFor();
|
||||
const view = page.locator("#view-routing");
|
||||
const box = await view.boundingBox();
|
||||
// the reader scrolls down to the Save, as they must: the editor is taller
|
||||
// than the window
|
||||
// the reader scrolls down to the editor's foot: the editor is taller
|
||||
// than the window (its Save stays in sight on the way, held at the
|
||||
// view's foot, but the case here is a Save from down the page)
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
||||
for (let i = 0; i < 200; i++) {
|
||||
const b = await save.boundingBox();
|
||||
const b = await page.locator(".rt-gedit").boundingBox();
|
||||
if (b && b.y + b.height <= box.y + box.height) break;
|
||||
if (await view.evaluate((v) => v.scrollTop + v.clientHeight >= v.scrollHeight - 1)) break;
|
||||
await page.mouse.wheel(0, 120);
|
||||
|
||||
Reference in New Issue
Block a user