Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: an inner list wheeled to its end keeps the wheel; the page stays put

yetoned74ef5e04cf4
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md
index fdf9d1874..7c5e88ff0 100644
--- a/docs/subsystems/gui-shell.md
+++ b/docs/subsystems/gui-shell.md
@@ -399,6 +399,7 @@ covers it in both engines, every language and a narrow window.
- A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (`backToReader` in the click guard, #1554). What was clicked is held where it was (`hold`); a view at its top when clicked stays at its top, and what comes in above the control moves it down instead (#2134, `update-auto.test.cjs`), as long as it moves less than half its own height and so stays under the pointer. When what the click does leaves the page shorter under it (a list emptied), the view keeps room at its foot for it to stay (`.view-room`), room that goes as the reader scrolls back. A control under what it unrolls (`data-unrolls`, "Show 7 more") goes down with what it opens: what's held is the part it is in, so the rows open downwards. Anything larger above it, as the stage a day picked on Routing brings in above the bar, is scrolled past, and the control stays where it was clicked (`routing-days-fit.test.cjs`, `routing-failed-open.test.cjs`).
- A scroll not the reader's is put back, so every way the reader scrolls has to count as theirs: the wheel and a trackpad's coast after the lift (WebKit on the Mac plays the coast itself and the page hears its scrolls with no wheel for each, so the wheel starts the same chain a touch fling does, `flings`/`flingUntil`: each scroll keeps the next one the reader's till it rests, and a click ends it; issenn on Discord, `view-trackpad-coast.test.cjs`), a wheel or coast the page is never told of (macOS 13's WebKit, Safari 16.6's, scrolled a view under wheels it never dispatched, so every scroll was put back and only the bar's drag moved the page: three scrolls put back the same way within a second are taken as the reader's run and given back, and so is each one after it that goes on the same way within a second of the last, so a wheel turned slowly or on a loaded Mac loses no step; a scroll by code is one, not a run, and two at rest are still put back; issenn on Discord, `view-wheel-unheard.test.cjs`. Under a click's 4s hold the same holds: only a put-back that comes with the page redrawn since the hold last held (`redrawn`: the view's height or where the first held parts sit moved from `h.lay`) is the hold's and never counts toward a run, so a profile opened on the Agents page and wheeled through at once scrolls, issennknight on Discord, `view-wheel-after-click.test.cjs`. The parts `h.lay` measures are those still in the page that scroll with it: a part drawn again since (the Usage page's tabs, the agents' list under an agent opened or closed) is a redraw once, not at every scroll, and a sticky one (Settings' tabs at a narrow width) is left out, as it sits still while the page scrolls; `view-wheel-after-redraw.test.cjs`), a touch and its fling, the keys, a drag, the scrollbar's own drag (`barDrag`, #1089) and the middle button's autoscroll (`panning`, 多喝热水 on Discord). Chromium and WebView2 give the autoscroll a press of button 1 and then no event of the reader's while it scrolls; from that press the view follows it till Chromium ends it, on the next press (which reaches the page only as a pointerup), a key (a keyup), or the lift after the mouse moved while held. A field the guard brings back into view after putting a scroll back is one focused since the reader last scrolled that view, not one they scrolled away from (`scrolledFrom`): the middle press focuses the button under it. See `view-middle-autoscroll.test.cjs`.
- Typing never moves the page either. A textarea that grows with its text (the Library's `autosize` in plugins/library/client.js: a set's text, an agent's own text, a skill's description, a subagent's fields) is measured at height auto with what holds it kept at its height, so the page never goes short for a moment: a page gone short has its view's scroll clamped by the browser at every input, an input method's every composing step included, and the guard's putting it back pulled a textarea taller than the view to one of its edges (#2636, `library-ime-scroll.test.cjs`).
+- A box that scrolls inside a page keeps the wheel at its ends: wheeled past its top or foot, the page stays where it was (碳碳双键 on Discord, Requests' list on Usage). `holds` in app.js marks every box between the pointer and its `.view` that scrolls vertically and overflows (`.holds`), on `pointerover` and on each wheel, and app.css gives `.holds` `overscroll-behavior-y: contain` (the Mac's bounce stays, on the box). It is not one CSS rule for every box because Chromium (WebView2, magpie web) holds the wheel in a box told to contain even when it doesn't overflow, and in one that scrolls only sideways, so a short list or a wide table would stop the page. `.holds` is under `:where()`, so a rule that passes the wheel on still does (`.mchips` in a short window, #833). The page itself (`.view`) and the document chain as before. See `inner-scroll-contain.test.cjs`.
- There are no native `<select>` elements and no colored left-border stripes. State is shown with a dot or a swatch.
- What the window shows can be selected and copied, its controls can't, as in a Mac app (Outvi V on Discord: nothing could be copied into a bug report). The page is `user-select: none`, and two `:where()` rules after `body` in `app.css` make text content selectable (paragraphs, `pre` and `code`, a detail's values, hints and notes, every error class, a conversation, a request's story on Routing) and keep every control unselectable with what is in it (buttons, labels, tabs, menus, the navigation, grips). Both have no specificity, so a view's own rule still decides, as a list being sorted does; a field stays selectable. See `user-select.test.cjs`.
- The Usage page's cards and the tray panel's Allowances tab share one order, `settings.UsageOrder` (`byUsageOrder`). In the panel a balance-only card stands where that order puts it, and balances next to each other share one *Balances* grid (`panelBalances`, #1510); none is gathered after the plans. The panel's *Arrange* (`panelArrange`) moves rows in it and hides subscriptions from that tab alone (`settings.PanelUsageHidden`); both save through `POST /api/usage/arrange`, which changes only the field it is sent, and the Settings save keeps both. Hiding is display only: a menu bar cell's card shows though hidden (`panelPeek`). See `TestUsageArrangePanelHidden`, `panel-arrange.test.cjs` and `panel-balance-order.test.cjs`.
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css
index cb1c7509b..440649504 100644
--- a/internal/gui/assets/app.css
+++ b/internal/gui/assets/app.css
@@ -526,6 +526,11 @@ body:not(.side-nav) .side-toggle .st-pane { opacity: 0; }
/* ---- 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); }
+/* 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.
+ :where() weighs nothing, so .mchips in a short window still passes it on */
+:where(.holds) { overscroll-behavior-y: contain; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
@media (prefers-reduced-motion: reduce) { .view { animation-name: fade-in; } }
body.window .view { padding: 2px 16px 8px; }
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 12858f5ca..e4011aade 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -22880,8 +22880,11 @@ function givesBack(e, dir) {
putBack = putBack.filter((p) => !mine(p));
for (const p of back) p.v.scrollTop += p.by;
}
+// marks a box that scrolls in a page while it overflows (.holds, app.css)
+const holds = (e) => { for (let b = e.target; b instanceof Element && !b.matches(".view,body"); b = b.parentNode) b.classList.toggle("holds", b.scrollHeight > b.clientHeight + 1 && /auto|scroll/.test(getComputedStyle(b).overflowY)); };
+addEventListener("pointerover", holds, { capture: true, passive: true });
let touchY = null;
-addEventListener("wheel", (e) => { flings(); givesBack(e, Math.sign(e.deltaY)); }, { capture: true, passive: true });
+addEventListener("wheel", (e) => { holds(e); flings(); givesBack(e, Math.sign(e.deltaY)); }, { capture: true, passive: true });
addEventListener("touchstart", (e) => { touchY = e.touches[0]?.clientY ?? null; }, { capture: true, passive: true });
addEventListener("touchmove", (e) => {
readerScrolls(250);
diff --git a/internal/gui/tests/README.md b/internal/gui/tests/README.md
index 14d8affb5..042a7346c 100644
--- a/internal/gui/tests/README.md
+++ b/internal/gui/tests/README.md
@@ -2547,3 +2547,14 @@ reason, the "Not encrypted" row on the local network, no native select or
left border, nothing wider or cut off at 360px, and no such section (nor a
read of it) in a browser on the page. Every language, Chromium and WebKit,
with the API faked.
+
+## Inner scroll boxes keep the wheel
+
+`inner-scroll-contain.test.cjs` wheels a box that scrolls inside a page past
+its foot and its top and checks the page's scrollTop didn't move: Routing's
+requests list grouped by session (the reporter's "No session ID" rows, en
+and zh, two sizes), and boxes of each kind added to the same page (calls'
+bodies, Sessions' talk, model lists, Library picks, diffs, and a new box
+naming no rule). A list too short to scroll and boxes that scroll only
+sideways still let the wheel move the page, and the model chips in a short
+window still pass it on (#833). Chromium and WebKit.
diff --git a/internal/gui/tests/inner-scroll-contain.test.cjs b/internal/gui/tests/inner-scroll-contain.test.cjs
new file mode 100644
index 000000000..d8b49437d
--- /dev/null
+++ b/internal/gui/tests/inner-scroll-contain.test.cjs
@@ -0,0 +1,202 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// 碳碳双键 on Discord: a list that scrolls inside a page (Usage's requests,
+// "No session ID" and its workbuddy rows), wheeled to its top or its foot,
+// went on to scroll the whole page, so the first and last rows were hard to
+// read without the page jumping; "in many places". A box that scrolls inside
+// a page now keeps the wheel at its ends, every such box (one rule in
+// app.css), while a box that scrolls only sideways still lets the wheel move
+// the page, and a short window's model chips still pass it on (悠悠哥, #833).
+// Wheeled past each end, the page's scrollTop stays where it was, in
+// Chromium and WebKit, in English and Chinese.
+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 engines = process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"];
+const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
+
+const now = new Date();
+const day = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map((n) => String(n).padStart(2, "0")).join("-");
+const at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();
+// the reporter's rows: WorkBuddy's deepseek, no session id, under a
+// session that has one
+const who = { id: "workbuddy-key", provider: "workbuddy", name: "WorkBuddy", who: "key-1", kind: "key", model: "deepseek-v4.1-flash", routing: "", used: 0 };
+const routes = Array.from({ length: 40 }, (_, i) => ({ id: 100 - i, seq: 100 - i, time: at(i), agent: "workbuddy", model: "deepseek-v4.1-flash", provider: "workbuddy", order: [who],
+ tries: [{ id: who.id, model: "deepseek-v4.1-flash", start: at(i), done: true, status: 200, ms: 1200 }], done: true, status: 200, ms: 1200, tokens: 3000, ...(i < 4 ? { agent: "codex", session: "chat-1" } : {}) }));
+const agents = Array.from({ length: 14 }, (_, i) => ({ id: "a" + i, name: "Agent " + i, path: "/t/a" + i + ".json", icon: "generic", wired: true,
+ fields: [{ key: "model", label: "model", value: "m", options: [{ value: "m", label: "M", ref: "a/m" }] }] }));
+
+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:true};` });
+ 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: { lang, theme: "light" } });
+ if (url.pathname === "/api/gateway/trace") {
+ if (url.searchParams.get("wait")) await new Promise((ok) => setTimeout(ok, 100));
+ return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: routes.length, rerouted: 0, errors: 0 }, routes });
+ }
+ if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [{ day, requests: routes.length }], routes: url.searchParams.get("day") ? routes : [] });
+ if (url.pathname === "/api/groups") return json({ groups: [] });
+ if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true, window: true } });
+ 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 });
+ };
+}
+
+// the wheel, over the middle of box, n turns of dy, and a moment to settle
+async function wheel(page, box, dy, n) {
+ const b = await box.boundingBox();
+ await page.mouse.move(b.x + b.width / 2, b.y + b.height / 2);
+ for (let i = 0; i < n; i++) { await page.mouse.wheel(0, dy); await page.waitForTimeout(60); }
+ await page.waitForTimeout(400);
+}
+const tops = async (view, box) => view.evaluate((v, b) => ({ page: v.scrollTop, pageRange: v.scrollHeight - v.clientHeight, box: b.scrollTop, boxRange: b.scrollHeight - b.clientHeight }), await box.elementHandle());
+
+// box brought to the page's middle by the wheel at the page's own left
+// edge, as a reader would (the page puts a scroll by code back where the
+// reader left it)
+async function bringIn(page, view, box) {
+ const vb = await view.boundingBox();
+ for (let i = 0; i < 40; i++) {
+ const b = await box.boundingBox(), off = b.y + b.height / 2 - (vb.y + vb.height / 2);
+ if (Math.abs(off) < 40) break;
+ await page.mouse.move(vb.x + 3, vb.y + vb.height / 2);
+ await page.mouse.wheel(0, Math.sign(off) * Math.min(100, Math.abs(off)));
+ await page.waitForTimeout(80);
+ }
+ await page.waitForTimeout(300);
+}
+// past each end of box, the page stays put
+async function heldAtEnds(page, view, box, what) {
+ await bringIn(page, view, box);
+ let s = await tops(view, box);
+ assert.ok(s.boxRange > 20, `${what} scrolls: ${JSON.stringify(s)}`);
+ assert.ok(s.page > 0 && s.page < s.pageRange, `${what}: the page can move both ways: ${JSON.stringify(s)}`);
+
+ // at its foot, wheeled on down
+ await box.evaluate((b) => { b.scrollTop = b.scrollHeight; });
+ await page.waitForTimeout(100);
+ const before = (await tops(view, box)).page;
+ await wheel(page, box, 120, 6);
+ s = await tops(view, box);
+ assert.ok(s.box >= s.boxRange - 1, `${what} still at its foot: ${JSON.stringify(s)}`);
+ assert.equal(s.page, before, `${what}, wheeled past its foot: the page didn't move`);
+
+ // up to its top by the wheel, and on up
+ await wheel(page, box, -120, Math.ceil(s.boxRange / 120) + 6);
+ s = await tops(view, box);
+ assert.equal(s.box, 0, `${what} wheeled to its top: ${JSON.stringify(s)}`);
+ assert.equal(s.page, before, `${what}, wheeled past its top: the page didn't move`);
+}
+
+for (const engine of engines) {
+ test(`${engine}: Requests' list on its page keeps the wheel at its ends`, async (t) => {
+ const browser = await launch(engine);
+ const errors = [];
+ t.after(async () => {
+ if (errors.length) console.log(errors);
+ await browser.close();
+ });
+ for (const lang of ["en", "zh"]) for (const [width, height] of [[900, 560], [1300, 600]]) {
+ await t.test(`${lang}, ${width}x${height}`, async () => {
+ const ctx = await browser.newContext({ viewport: { width, height }, reducedMotion: "reduce" });
+ const page = await ctx.newPage();
+ page.setDefaultTimeout(5000);
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", serve(lang));
+ await page.goto("http://magpie.test/?view=routing");
+ const view = page.locator("#view-routing");
+ await page.locator("#view-routing .rt-req").nth(39).waitFor();
+ // grouped by session, as the reporter's list was
+ await page.locator("#view-routing .rt-group-by button").nth(1).click();
+ assert.equal(await page.locator("#view-routing div.rt-session .nm").textContent(), lang === "zh" ? "未提供会话标识" : "No session ID");
+ await page.waitForTimeout(500);
+ await heldAtEnds(page, view, page.locator("#view-routing .rt-reqs").first(), "the requests' list");
+ await ctx.close();
+ });
+ }
+ assert.deepEqual(errors, []);
+ });
+
+ // The class, on the same page with the app's own stylesheets and
+ // scripts: a box of each kind that scrolls inside a page, one added
+ // later that names no rule of its own, and the boxes that must still let
+ // the wheel move the page: a list too short to scroll (Chromium holds the
+ // wheel in one that is told to contain, overflowing or not) and the ones
+ // that scroll only sideways.
+ test(`${engine}: every box that scrolls inside a page keeps the wheel; the others pass it on`, async (t) => {
+ const browser = await launch(engine);
+ t.after(() => browser.close());
+ const lines = (n) => Array.from({ length: n }, (_, i) => `a line of text ${i + 1}`).join("\n");
+ const rows = (n, tag = "div") => Array.from({ length: n }, (_, i) => `<${tag} style="height:28px;flex:0 0 100%">row ${i + 1}</${tag}>`).join("");
+ const wide = `<div style="width:2400px;height:60px">wide</div>`;
+ const held = {
+ "rt-reqs": `<div class="rt-reqs" data-box>${rows(40)}</div>`,
+ "call-pre": `<div class="call-body"><pre data-box>${lines(60)}</pre></div>`,
+ "sess-talk": `<div class="sess-talk" data-box>${rows(60)}</div>`,
+ "add-models-list": `<div class="add-models-list" data-box>${rows(30)}</div>`,
+ "mnames": `<div class="mnames" data-box>${rows(30)}</div>`,
+ "mchips": `<div class="mchips" data-box>${rows(40, "span")}</div>`,
+ "lib-picks": `<div class="lib-picks" data-box>${rows(30)}</div>`,
+ "rt-steps": `<ol class="rt-steps" data-box>${rows(20, "li")}</ol>`,
+ "ag-diff-box": `<div class="ag-diff-box" data-box>${rows(30)}</div>`,
+ "a new box": `<div style="max-height:200px;overflow-y:auto" data-box>${rows(30)}</div>`,
+ };
+ const passed = {
+ "a short rt-reqs": `<div class="rt-reqs" data-box>${rows(3)}</div>`,
+ "heat-scroll": `<div class="heat-scroll" data-box>${wide}</div>`,
+ "led-wrap": `<div class="led-wrap" data-box>${wide}</div>`,
+ "snip": `<pre class="snip" data-box>${"x".repeat(600)}</pre>`,
+ };
+ const ctx = await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" });
+ const page = await ctx.newPage();
+ page.setDefaultTimeout(5000);
+ await page.route("**/*", serve("en"));
+ await page.goto("http://magpie.test/?view=routing");
+ const view = page.locator("#view-routing");
+ await page.locator("#view-routing .rt-req").nth(39).waitFor();
+ await view.evaluate((v, html) => v.insertAdjacentHTML("beforeend", html),
+ Object.entries({ ...held, ...passed }).map(([id, h]) => `<div data-id="${id}" style="flex:none;margin:240px 0">${h}</div>`).join("") + `<div style="flex:none;height:900px"></div>`);
+ const box = (id) => page.locator(`[data-id="${id}"] [data-box]`);
+ for (const id of Object.keys(held)) await t.test(id, () => heldAtEnds(page, view, box(id), id));
+ for (const id of Object.keys(passed)) await t.test(id + " passes the wheel on", async () => {
+ await bringIn(page, view, box(id));
+ const s = await tops(view, box(id));
+ assert.ok(s.page < s.pageRange - 300, `${id}: the page can move down: ${JSON.stringify(s)}`);
+ await wheel(page, box(id), 120, 2);
+ assert.ok((await tops(view, box(id))).page > s.page, `${id}, wheeled down over: the page moved`);
+ // and up past its top
+ await bringIn(page, view, box(id));
+ const up = await tops(view, box(id));
+ await wheel(page, box(id), -120, 2);
+ const after = await tops(view, box(id));
+ assert.ok(after.page < up.page, `${id}, wheeled up over: the page moved: ${JSON.stringify([up, after])}`);
+ });
+ // the page itself chains as before
+ assert.equal(await view.evaluate((v) => getComputedStyle(v).overscrollBehaviorY), "auto", "the page's own");
+ await ctx.close();
+
+ // a short window: the model chips pass the wheel on to the editor's
+ // body, as #833 asked (悠悠哥 on Discord: the body could never be
+ // wheeled on past them)
+ const short = await browser.newPage({ viewport: { width: 900, height: 600 } });
+ await short.route("**/*", serve("en"));
+ await short.goto("http://magpie.test/?view=routing");
+ await short.locator("#view-routing .rt-req").nth(39).waitFor();
+ await short.locator("#view-routing").evaluate((v, html) => v.insertAdjacentHTML("afterbegin", html), held.mchips);
+ const chips = short.locator("#view-routing .mchips");
+ const b = await chips.boundingBox();
+ await short.mouse.move(b.x + 20, b.y + 20);
+ await short.waitForTimeout(100);
+ assert.ok(await chips.evaluate((m) => m.scrollHeight > m.clientHeight), "the chips scroll");
+ assert.equal(await chips.evaluate((m) => getComputedStyle(m).overscrollBehaviorY), "auto", "the chips in a short window pass the wheel on");
+ await short.close();
+ });
+}
diff --git a/internal/gui/tests/routing-scroll-end.test.cjs b/internal/gui/tests/routing-scroll-end.test.cjs
index 595021d54..d79645be7 100644
--- a/internal/gui/tests/routing-scroll-end.test.cjs
+++ b/internal/gui/tests/routing-scroll-end.test.cjs
@@ -77,9 +77,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const room = await page.locator(".rt-more").first().evaluate((e) => e.getBoundingClientRect().width);
assert.equal(await tracks(page, ".rt-cols"), room >= 1150 ? 2 : 1, "the requests and the accounts, side by side or one under the other");
- // down to the end, by the wheel
+ // down to the end, by the wheel over the page's own gutter: the
+ // requests' list keeps the wheel at its ends (inner-scroll-contain)
const box = await view.boundingBox();
- await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ await page.mouse.move(box.x + 3, box.y + box.height / 2);
for (let i = 0; i < 20; i++) { await page.mouse.wheel(0, 300); await page.waitForTimeout(40); }
await page.waitForTimeout(300);
// and on at the end, as the page is redrawn: each turn of the wheel