gui: every page keeps its scrollbar's room, so nothing opening in it narrows the page
The owner, on Agents: opening an agent's details ran the page past the window, the scrollbar appeared, and the whole page went 8px narrower in one frame (and back when it closed). Every page had this; only Usage and Routing kept the bar's room (87d83e7ab). - .view is overflow-y: scroll everywhere, so the bar's room is always kept. Its track is transparent (the app's own thin bar, 8px on the Mac, 10px on Windows and Linux), so a page that fits shows nothing there. The Usage/Routing rule it replaces is gone. - A framed dialog's fields did the same on Windows and Linux; they keep the 10px too, out of their right padding, as the Mac's already did. - Between 601 and 640px the agent row's start-model picker is 184px, not 196px, so the name keeps the 150px agent-layout holds it to. Test: page-width-steady, both engines, Mac's bar and Windows' bar: every page this fixture opens (>= 8) grown past the window keeps its width, and so does a framed dialog's body; an agent's details opened past the window move its row by 0px, in all five languages. Run on mote at this head (29181eb78+ this): page-width-steady, agent-layout, heatmap-scrollbar, routing-ctx-still 40 of 40; go test -run Budget ./internal/gui ok. Before the last rebase, 49 GUI files that measure widths or scrollbars (panel-*, gui-* languages and others), both engines: 593 of 600; the reds were agent-layout webkit en at 601px (fixed above, then 24 of 24) and usage-ledger's "newest live route" in both engines, red the same on the base (#3104). Broken by hand: the old app.css with the new test is red in all 16 (8px narrower on the Mac, 10px with Windows' bar); without only the dialog rule, the two Windows cases are red (fields 10px narrower). Not tried: the whole GUI suite (mote is running another session's; it runs after this push), and the real Windows and Linux apps.
This commit is contained in:
+17
-10
@@ -525,7 +525,17 @@ body:not(.side-nav) .side-toggle .st-pane { opacity: 0; }
|
||||
@keyframes side-out { to { transform: translateX(-100%); } }
|
||||
|
||||
/* ---- lists ---------------------------------------------------------------- */
|
||||
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 4px; display: flex; flex-direction: column; animation: view-in .24s var(--ease); }
|
||||
/* every page keeps its bar's room, whether it runs past the window or
|
||||
not: a row that opens (an agent's details, a fold, a card's list) made
|
||||
the bar appear and the whole page 8px narrower in one frame, and shake
|
||||
back when it closed (the owner, on Agents). The track is transparent,
|
||||
so a page that fits shows nothing there. Usage and Routing needed it
|
||||
first: their square-celled grids (the year heatmap, Sessions' calendar,
|
||||
the context waffle) grow taller as they grow wider, so near the
|
||||
window's height WebKit laid the page out at the full width under the
|
||||
bar and, on each redraw, 8px narrower for a few frames (@LingYi_Stu on
|
||||
X) */
|
||||
.view { flex: 1; min-height: 0; overflow-y: scroll; padding: 0 12px 4px; display: flex; flex-direction: column; animation: view-in .24s var(--ease); }
|
||||
/* a box that scrolls in a page, marked by app.js while it overflows: the
|
||||
wheel at its ends stays with it (contain keeps the Mac's bounce on it).
|
||||
Only then: Chromium holds the wheel even in a box that doesn't overflow.
|
||||
@@ -564,15 +574,9 @@ body.mac :is(.view, .modal .dialog, .modal .editor.framed > .ebody, .heat-scroll
|
||||
and scrolled sideways; the bar's room is always kept, out of the right
|
||||
padding, so the fields end where they did */
|
||||
body.mac .modal .editor.framed > .ebody { overflow-y: scroll; padding-right: 10px; }
|
||||
/* Usage and Routing keep their bar's room too, whether the page runs past
|
||||
the window or not. Their square-celled grids (the year heatmap, Sessions'
|
||||
calendar, the context waffle) grow taller as they grow wider, so near the
|
||||
window's height WebKit could lay the page out at the full width under the
|
||||
bar and, on each redraw (Requests' 5s refresh), 8px narrower for a few
|
||||
frames: the head's refresh, interval and cost shook sideways with Today
|
||||
picked (@LingYi_Stu on X). The other pages have no such grid and keep the
|
||||
8px while short */
|
||||
body.window :is(#view-usage, #view-routing) { overflow-y: scroll; }
|
||||
/* the same on Windows and Linux, whose bar is 10px: a field that opens
|
||||
(an advanced section, a long error) no longer narrows the body under it */
|
||||
body:not(.mac):not(.web) .modal .editor.framed > .ebody { overflow-y: scroll; padding-right: 8px; }
|
||||
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }
|
||||
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; }
|
||||
@@ -4237,6 +4241,9 @@ body.window .row + .row.agent.conn > .who { min-height: 41px; } /* the line abov
|
||||
/* the model it starts on, beside the switch: one width down the list, so
|
||||
the pickers and the switches line up */
|
||||
.row.agent.conn > .field.ag-start { flex: none; width: 196px; margin-left: 8px; align-self: center; justify-content: flex-start; }
|
||||
/* just above the narrow layout the page keeps its bar's 8px too, so the
|
||||
picker gives that back and the name keeps its 150px */
|
||||
@media (max-width: 640px) { body.window .row.agent.conn > .field.ag-start { width: 184px; } }
|
||||
.row.agent.conn > .who + .field.ag-start { margin-left: auto; }
|
||||
.row.agent.conn > .field.ag-start .v { flex: 1; text-align: left; }
|
||||
.row.agent.conn > .field.ag-start .chev { margin-left: auto; }
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The owner, on Agents: opening a row's details made the page run past the
|
||||
// window, the scrollbar appeared, and the whole page went 8px narrower in
|
||||
// one frame, shaking back when it closed. Every page keeps its bar's room
|
||||
// whether it runs past the window or not, so nothing in it moves sideways
|
||||
// when something opens: each page is grown past the window here and its
|
||||
// width held, and the owner's own case (an agent's details opened) is
|
||||
// played out. Chromium keeps its scrollbars on (Playwright hides them by
|
||||
// default), and both engines draw the app's own thin bar, as the app does:
|
||||
// the Mac's 8px one and, with the platform said to be Windows, the 10px
|
||||
// one Windows and Linux get. A dialog's fields keep their bar's room too.
|
||||
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");
|
||||
|
||||
function serve(lang) {
|
||||
const state = {
|
||||
agents: [{
|
||||
id: "pi", name: "Pi", icon: "generic", wired: true, path: "~/.pi/agent/settings.json",
|
||||
fields: [{ key: "model", label: "model", value: "magpie/deepseek/deepseek-v4-pro", options: [{ value: "magpie/deepseek/deepseek-v4-pro", label: "DeepSeek V4 Pro", ref: "deepseek/deepseek-v4-pro" }] }],
|
||||
}],
|
||||
profiles: [], settings: { lang, theme: "dark" },
|
||||
};
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: "dark", web: false })};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (url.pathname === "/api/settings") return json(state.settings);
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [], pools: [] });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
||||
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 route.fulfill({ body: await fs.readFile(file).catch(() => ""), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
// the shown page: its id, how wide its content is, whether it runs past the window
|
||||
const shown = (page) => page.evaluate(() => {
|
||||
const v = [...document.querySelectorAll(".view")].find((x) => !x.hidden && x.offsetParent);
|
||||
return v && { id: v.id, width: v.clientWidth, over: v.scrollHeight > v.clientHeight + 1 };
|
||||
});
|
||||
|
||||
// a page told it runs on this platform (the app reads navigator.platform)
|
||||
const onPlatform = async (browser, platform, viewport) => {
|
||||
const context = await browser.newContext({ viewport, reducedMotion: "reduce" });
|
||||
await context.addInitScript((p) => Object.defineProperty(Navigator.prototype, "platform", { get: () => p }), platform);
|
||||
return context.newPage();
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) for (const platform of ["MacIntel", "Win32"]) {
|
||||
const launch = () => (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium", ignoreDefaultArgs: ["--hide-scrollbars"] }));
|
||||
|
||||
test(`${engine} ${platform}: no page narrows when it grows past the window`, async (t) => {
|
||||
const browser = await launch();
|
||||
t.after(() => browser.close());
|
||||
const page = await onPlatform(browser, platform, { width: 1100, height: 700 });
|
||||
page.setDefaultTimeout(6000);
|
||||
await page.route("**/*", serve("en"));
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
const ids = await page.evaluate(() => [...document.querySelectorAll(".view[id^='view-']")].map((v) => v.id.slice(5)));
|
||||
assert(ids.length >= 8, `pages found: ${ids}`);
|
||||
let tried = 0;
|
||||
for (const id of ids) {
|
||||
await page.goto(`http://magpie.test/?view=${id}`);
|
||||
const before = await shown(page).catch(() => null);
|
||||
if (!before || before.id !== `view-${id}`) continue; // a page this fixture doesn't open
|
||||
tried++;
|
||||
// whatever opens in it: a block taller than the window, then gone
|
||||
const grown = await page.evaluate((vid) => {
|
||||
const v = document.getElementById(vid), b = document.createElement("div");
|
||||
b.id = "grow-test"; b.style.cssText = "flex:none;height:3000px";
|
||||
v.append(b);
|
||||
const r = { width: v.clientWidth, over: v.scrollHeight > v.clientHeight + 1 };
|
||||
b.remove();
|
||||
return r;
|
||||
}, before.id);
|
||||
const after = await shown(page);
|
||||
assert(grown.over, `${id}: the block ran past the window`);
|
||||
assert.equal(grown.width, before.width, `${id}: the page narrowed by ${before.width - grown.width}px when it ran past the window`);
|
||||
assert.equal(after.width, before.width, `${id}: the page changed width when it was short again`);
|
||||
}
|
||||
assert(tried >= 8, `pages tried: ${tried}`);
|
||||
|
||||
// a dialog's fields: one that opens past the dialog's height leaves
|
||||
// them as wide as they were
|
||||
const fields = await page.evaluate(() => {
|
||||
const m = document.createElement("div"); m.className = "modal";
|
||||
m.innerHTML = '<div class="dialog"><div class="editor framed"><div class="ehead">head</div><div class="ebody"><div id="f1">field</div></div><div class="bar">bar</div></div></div>';
|
||||
document.body.append(m);
|
||||
const body = m.querySelector(".ebody"), w0 = body.clientWidth, f0 = m.querySelector("#f1").getBoundingClientRect().width;
|
||||
const b = document.createElement("div"); b.style.cssText = "height:3000px;grid-column:1/-1"; body.append(b);
|
||||
const r = { w0, w1: body.clientWidth, f0, f1: m.querySelector("#f1").getBoundingClientRect().width, over: body.scrollHeight > body.clientHeight + 1, bar: body.offsetWidth - body.clientWidth };
|
||||
m.remove();
|
||||
return r;
|
||||
});
|
||||
assert(fields.over, "the dialog's fields ran past it");
|
||||
assert(fields.bar > 0, "the dialog draws the app's bar");
|
||||
assert.equal(fields.w1, fields.w0, `the dialog's fields narrowed by ${fields.w0 - fields.w1}px`);
|
||||
assert.equal(fields.f1, fields.f0, "a field narrowed when the dialog's fields ran past it");
|
||||
});
|
||||
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
if (platform !== "MacIntel" && lang !== "en") continue; // one language is enough for the other bar
|
||||
test(`${engine} ${platform} ${lang}: opening an agent's details past the window moves nothing sideways`, async (t) => {
|
||||
const browser = await launch();
|
||||
t.after(() => browser.close());
|
||||
const page = await onPlatform(browser, platform, { width: 1000, height: 330 });
|
||||
page.setDefaultTimeout(6000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang));
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
const row = page.locator('.row.agent[data-id="pi"]');
|
||||
await row.waitFor();
|
||||
if (await row.locator(".ag-exp").count()) await row.locator(".ag-link").click(); // start folded
|
||||
await page.waitForFunction(() => !document.querySelector('.row.agent[data-id="pi"] .ag-exp'));
|
||||
const edge = () => row.evaluate((r) => { const b = r.getBoundingClientRect(); return { left: b.left, right: b.right }; });
|
||||
const before = { ...(await shown(page)), edge: await edge() };
|
||||
assert(!before.over, `${lang}: the page fits before the details open`);
|
||||
await row.locator(".ag-link").click();
|
||||
await row.locator(".ag-exp").waitFor();
|
||||
const open = { ...(await shown(page)), edge: await edge() };
|
||||
assert(open.over, `${lang}: the details run the page past the window`);
|
||||
assert.equal(open.width, before.width, `${lang}: the page narrowed by ${before.width - open.width}px`);
|
||||
assert.deepEqual(open.edge, before.edge, `${lang}: the agent's row moved sideways`);
|
||||
await row.locator(".ag-link").click();
|
||||
await page.waitForFunction(() => !document.querySelector('.row.agent[data-id="pi"] .ag-exp'));
|
||||
assert.deepEqual(await edge(), before.edge, `${lang}: the row moved sideways when the details closed`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user