gui: the tray panel shrinks back to a short tab, gliding there
The tray panel was held at its tallest tab's height (#124): fit() measured every tab and asked for the largest. Once Routing or Usage had been opened, Agents sat over empty room under its rows until the panel was let go (refeccd on Discord, macOS). fit() now lays every tab out the same way and asks for the height of the tab showing (Agents when none is set), so the panel shrinks as well as grows. #124's complaint was the panel jumping bigger on a tab switch, so a tab picked glides the edge there instead (TAB_GLIDE: 240ms on app.css's --ease-out, as .nav-hl; a jump under reduced motion). Content fits inside a tab (rows unrolling, Allowances landing) are unchanged. Siblings: the Go side already shrinks on every OS. FitPanel takes the height asked, panelFrame clamps it to panelMin/panelMax/the screen, and glidePanel animates the Mac's frame with its top under the menu bar and steps Windows/Linux by the tray icon. All three take their height from this one fit(), so nothing there changed. The web host has no panel. panel-fit-tabs.test.cjs gets "the tray panel shrinks back to a short tab": two agents and Routing's eight requests, Agents -> Routing -> Agents, with reduced motion and without. Agents' height is asked again, and the tab's fit carries ms=240 and the ease (none under reduced motion). Its Routing-skeleton check now picks the Routing tab first, as that is the tab whose height it is about. panel-usage's assertion is now the showing tab's height, not the tallest. Run on mote (mote-run). At this commit, rebased ond32a7a70c: gofmt -l internal/gui nothing; go test -tags nogui ./internal/gui ok (sandbox HOME); panel-fit-tabs, panel-usage, panel-fit-order, panel-fold 40/40. Earlier, at the same change onc7c05dcf2: - new test on origin/main's app.js: 10 of 10 red, Chromium and WebKit x en/zh/zh-TW/ja/de: "reduce: Routing asked no taller a panel than two agents: 163 629" (the short tab asked the tallest's 629) - with the change: panel-fit-tabs + panel-usage 24/24 ok (both engines, five languages); again at the rebased head with i18n-keys: 27/28, the one red is i18n-keys' "a plugin's words are its own", filed as #5332, #5426, #5482 - the 46 GUI files that read /api/window/fit (atd32a7a70c, before the rebase; the change is the same): 1182/1186. Reds, none in the panel: images-codex-one (Settings window; red alone on origin/maind32a7a70ctoo, #4618, commented) and view-open-wheel's "wheels unheard, usage, en, 1000px" in WebKit (window only, no panel page, where fit() returns at once; #4132) - gofmt -l internal/gui: nothing; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet ./internal/gui: ok - go test -tags nogui ./internal/gui (sandbox HOME, pinned caches): ok (before trimming, TestCoreScriptBudget was 346 bytes over; the comments were cut, the budget not raised) Not tried: the real app's panel on the Mac, Windows or Linux (no desktop session driven); the whole GUI suite (mote's suite.lock queue was full); go test ./... . Reported-by: refeccd (Discord)
This commit is contained in:
@@ -623,6 +623,7 @@ covers it in both engines, every language and a narrow window.
|
||||
- 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. An engine with no `overscroll-behavior` (Safari 15, macOS 12's WebKit until Safari is updated; Safari 16+, WebKitGTK and Chromium have it) gets the same from `compat.js`: a wheel over a `.holds` box at its end in the wheel's direction is cancelled, so there the Mac's bounce at the box's end is lost. A guard in `inner-scroll-contain.test.cjs` builds every rule in every stylesheet under assets that scrolls a box vertically from its own selector, fills it and points at it, and fails naming the file and selector of one that doesn't hold the wheel (a rule that sets `overscroll-behavior` back to auto, or a box `holds` doesn't reach). 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. A dot never says good or failed by colour alone: a failed state's dot is the same box drawn as an x (`--x-mark`, a mask over its red, scaled 1.5 so it reads as heavy as the round dot), since red and green dots read as one colour to a red-green colour-blind reader (coolmantou on Discord). That holds for Test models (`.tdot`), an agent's status line (`.ag-dot`), the check-in (`.ci-dot`), the request ledger (`.led .st .dot`), Routing's tries, steps and preview (`.rt-req`/`.rt-probe`, `.rt-steps`, `.ps-dst`) and a Library server's health (`.lib-health.err`); see `status-dot-shape.test.cjs`.
|
||||
- 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 tray panel is as tall as the tab showing, from `panelMin` to `panelMax` and the screen's room (`panelFrame` in [`textsize.go`](../../internal/gui/textsize.go)), and shrinks as well as grows: `fit` in [`app.js`](../../internal/gui/assets/app.js) lays every tab out to measure the one showing and asks `/api/window/fit` for its height. A tab picked glides the panel's edge there (`TAB_GLIDE`, 240ms on app.css's `--ease-out`; a jump under reduced motion), which `glidePanel` carries out by the tray icon: on the Mac the system animates the frame with its top edge under the menu bar, elsewhere `stepGlide` sets the size a frame at a time and places the panel by the icon again. It was held at the tallest tab's height (#124) until a short tab sat over empty room once a tall one had been opened (refeccd on Discord). See `panel-fit-tabs.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`.
|
||||
- An allowance card can be hidden from Usage › Overview (whqtian_07012 on Discord: StepFun's plan wanted, its balance not). Right-click a card, or press it long on a touch screen (`quotaCardMenus` in `plugins/usage/page.js`), and the app menu offers *Hide from Overview*; an account of a card with several says *Hide this account from Overview*, and a plan card carrying its key's balance (`keyCards`) also offers *Hide its balance from Overview*, which keeps the plan. Each is kept by its tray card id and kind (`cardHideKey`: `stepfun|balance`, `kimi|me@x|plan`) in `settings.UsageCardsHidden` through the same `POST /api/usage/arrange` (`cardsHidden`), and kept by the Settings save. `overviewCards` leaves them out before `keyCards`, so routing, caps, the counting, the Accounts list, the tray panel (which has its own *Arrange*) and the menu bar cells never hear of it; a cell clicked for a hidden card shows it until the page is left (`usagePeek`). Such a card's menu offers *Show in Overview*, not Hide again, since the "{n} hidden" line leaves it out while it shows. A "{n} hidden" line under the cards (`#quotaHid`, `renderQuotaHid`) opens them, each with *Unhide*, and *Show all* from two. The line is drawn in `--muted`, not `--faint`, so it can be read and found (3:1 or more), and while any are hidden every card's menu ends with *Show {n} Hidden*, which opens the line with the keyboard on it and brings it into sight on the menu's click (`openHidden`; yuu003348 on Discord found no way back). See `TestUsageArrangeCardsHidden`, `usage-cards-hide.test.cjs` and `usage-hidden-way-back.test.cjs`.
|
||||
- A client in the Usage page's Agents list can be hidden from that list (ikunbots on X): its row's "…" button or right-click opens the row menu with *Hide from this list*, saved by client id in `settings.UsageAgentsHidden` through the same `POST /api/usage/arrange` (`agentsHidden`), and kept by the Settings save. The ledger, the totals and the chart still count a hidden client. A "{n} hidden" line under the list opens them, each with *Unhide* (`hideUsageAgent`), and while any are hidden the row menu ends with *Show {n} Hidden*, which opens it as the cards' does (`openHidden`). See `TestUsageArrangeAgentsHidden`, `usage-agents-hide.test.cjs` and `usage-hidden-way-back.test.cjs`.
|
||||
|
||||
@@ -4229,6 +4229,8 @@ const UNROLL = { ms: 340, ease: ".23,1,.32,1" };
|
||||
const ROW_OPEN = { ms: 320, ease: ".25,.3,.1,1" };
|
||||
const ROW_CLOSE = { ms: 260, ease: ".25,.3,.1,1" };
|
||||
const ROLLUP = { ms: 260, ease: ".23,1,.32,1" };
|
||||
// a tab picked: --ease-out, as .nav-hl
|
||||
const TAB_GLIDE = { ms: 240, ease: ".23,1,.32,1" };
|
||||
|
||||
// tintPanel hands the colour the panel's page shows to the system, to paint
|
||||
// under the page, which then leaves its own background clear: the page is
|
||||
@@ -4292,9 +4294,8 @@ if (mode === "window") {
|
||||
|
||||
// extra is room about to be taken (or given back), e.g. by agents unrolling;
|
||||
// glide moves the panel's edge there over time instead of at once.
|
||||
// The panel is as tall as its tallest tab, not the one showing, so it keeps
|
||||
// its height as the tabs change and a shorter tab leaves room below (#124).
|
||||
// Margins count; tabs lay out at once (hiding one ends its motion).
|
||||
// The panel is as tall as the tab showing, shrinking too (refeccd on
|
||||
// Discord); a tab picked glides there. Margins count; tabs lay out at once.
|
||||
function fit(extra = 0, glide) {
|
||||
if (mode !== "panel") return;
|
||||
const body = document.body, v = $("#view-agents"), tab = body.dataset.ptab, f = parseFloat, vs = getComputedStyle(v);
|
||||
@@ -4305,7 +4306,7 @@ function fit(extra = 0, glide) {
|
||||
const o = { agentsLead: "agents", agents: "agents", panelQuota: "usage", panelUsage: "stats", panelRouting: "routing" }[c.id];
|
||||
for (const t in n) if (!o || o == t) n[t] += px;
|
||||
}
|
||||
const h = Math.ceil(body.clientHeight - v.offsetHeight + f(vs.paddingTop) + f(vs.paddingBottom) + Math.max(...Object.values(n)));
|
||||
const h = Math.ceil(body.clientHeight - v.offsetHeight + f(vs.paddingTop) + f(vs.paddingBottom) + n[n[tab] === undefined ? "agents" : tab]);
|
||||
if (tab) body.dataset.ptab = tab;
|
||||
if (h === fit.last) return;
|
||||
fit.last = h;
|
||||
@@ -17081,7 +17082,7 @@ function setPanelTab(tab) {
|
||||
// the tab remembered is drawn as the page loads, before what the tab is drawn with,
|
||||
// further down, is set: a microtask later, when all of it is
|
||||
queueMicrotask(panelUseShown);
|
||||
fit();
|
||||
fit(0, TAB_GLIDE);
|
||||
}
|
||||
// Scroll to a requested card, or resume its highlight after a redraw.
|
||||
function flashCard(card, target = card, elapsed = 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The tray panel's height (fit) is its tallest tab's, every part of it
|
||||
// The tray panel's height (fit) is the showing tab's, every part of it
|
||||
// counted: the header, the tabs and the gap under them, the view's padding,
|
||||
// what sits around a tab's section (the Get started card, the fold under
|
||||
// the agents) and the foot. Summing the sections alone left the view short
|
||||
@@ -7,7 +7,9 @@
|
||||
// (CyberCaius on Discord, on Windows). And on the first open, while the
|
||||
// trace is on its way, the Routing tab's skeleton is as tall as what comes,
|
||||
// so the panel doesn't grow when it lands; today's line is asked for at
|
||||
// once, not after the trace.
|
||||
// once, not after the trace. Going back from a tall tab to a short one the
|
||||
// panel shrinks again, gliding there (refeccd on Discord: it stayed at the
|
||||
// tallest tab's height).
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -27,7 +29,7 @@ const ids = ["codex", "claude", "gemini", "opencode", "kimi", "qwen", "crush", "
|
||||
// held: promises the trace's and today's first answers wait for
|
||||
function serve(page, lang, agents, held = {}) {
|
||||
const state = { agents: ids.slice(0, agents).map((id) => ({ id, name: id, path: "/test/" + id, fields: [] })), profiles: [], settings: { lang, theme: "light" } };
|
||||
const fits = [];
|
||||
const fits = [], asks = [];
|
||||
const handler = async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
@@ -47,6 +49,7 @@ function serve(page, lang, agents, held = {}) {
|
||||
// the window takes the height asked for, as the tray's does
|
||||
const h = Number(url.searchParams.get("h"));
|
||||
fits.push(h);
|
||||
asks.push(url.searchParams);
|
||||
await page.setViewportSize({ width: 380, height: h }).catch(() => {});
|
||||
return route.fulfill({ status: 204 });
|
||||
}
|
||||
@@ -59,7 +62,7 @@ function serve(page, lang, agents, held = {}) {
|
||||
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), contentType });
|
||||
};
|
||||
return { handler, fits };
|
||||
return { handler, fits, asks };
|
||||
}
|
||||
|
||||
// the view's overflow on each tab, after the panel was fitted
|
||||
@@ -119,6 +122,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator("#agents .row.agent").nth(1).waitFor();
|
||||
await page.waitForFunction(() => /42/.test(document.querySelector("#panelRouting .pr-today")?.textContent || ""), null, { timeout: 3000 })
|
||||
.catch(() => assert.fail("today's line waited for the trace: " + JSON.stringify(fits)));
|
||||
await page.locator('#ptabs [data-ptab="routing"]').click();
|
||||
const before = await settled(page, fits);
|
||||
release();
|
||||
await page.locator("#panelRouting .pr-req").first().waitFor({ state: "attached" });
|
||||
@@ -151,5 +155,40 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual({ now: kept.now, moved: kept.moved }, { now: kept.top, moved: 0 }, "measuring the tabs scrolled the view");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// two agents and Routing's eight requests: Routing is the tall tab
|
||||
test(`${engine} ${lang}: the tray panel shrinks back to a short tab`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const motion of ["reduce", "no-preference"]) {
|
||||
const errors = [];
|
||||
const page = await (await browser.newContext({ viewport: { width: 380, height: 200 }, reducedMotion: motion })).newPage();
|
||||
page.setDefaultTimeout(8000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const s = serve(page, lang, 2);
|
||||
await page.route("**/*", s.handler);
|
||||
await page.goto("http://magpie.test/?mode=panel");
|
||||
await page.locator("#panelRouting .pr-req").first().waitFor({ state: "attached" });
|
||||
await page.locator("#agents .row.agent").nth(1).waitFor();
|
||||
const short = await settled(page, s.fits);
|
||||
await page.locator('#ptabs [data-ptab="routing"]').click();
|
||||
const tall = await settled(page, s.fits);
|
||||
assert(tall > short, `${motion}: Routing asked no taller a panel than two agents: ${s.fits.join(" ")}`);
|
||||
const over = await page.evaluate(() => { const v = document.querySelector("#view-agents"); return v.scrollHeight - v.clientHeight; });
|
||||
assert(over <= 0, `${motion}: Routing overflows by ${over}px`);
|
||||
const n = s.asks.length;
|
||||
await page.locator('#ptabs [data-ptab="agents"]').click();
|
||||
const back = await settled(page, s.fits);
|
||||
assert.equal(back, short, `${motion}: back on two agents the panel kept ${back}, not ${short}: ${s.fits.join(" ")}`);
|
||||
// the tab picked glides the edge on app.css's ease-out, a jump when
|
||||
// motion is reduced
|
||||
const ask = s.asks[n];
|
||||
if (motion === "reduce") assert.equal(ask.get("ms"), null, `a glide under reduced motion: ${ask}`);
|
||||
else assert.deepEqual([ask.get("ms"), ask.get("ease")], ["240", ".23,1,.32,1"], `the tab's fit: ${ask}`);
|
||||
assert.deepEqual(errors, []);
|
||||
await page.context().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,19 +197,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(tip.includes("Claude") && tip.includes("Relay"), tip);
|
||||
await p.mouse.move(2, 2);
|
||||
|
||||
// Native fit includes the Usage tab, and all controls fit without
|
||||
// scrolling: each tab's whole layout (the view's padding, the header,
|
||||
// Native fit is the tab showing, and all its controls fit without
|
||||
// scrolling: the tab's whole layout (the view's padding, the header,
|
||||
// tabs and foot), not its section's height alone
|
||||
const need = await p.evaluate(() => {
|
||||
const body = document.body, v = document.querySelector("#view-agents"), tab = body.dataset.ptab, out = {};
|
||||
const body = document.body, v = document.querySelector("#view-agents"), tab = body.dataset.ptab, out = { tab };
|
||||
for (const t of ["agents", "usage", "stats", "routing"]) { body.dataset.ptab = t; out[t] = Math.ceil(body.clientHeight - v.offsetHeight + v.scrollHeight); }
|
||||
body.dataset.ptab = tab;
|
||||
return out;
|
||||
});
|
||||
const height = Math.max(...Object.values(need));
|
||||
const height = need[need.tab];
|
||||
for (let i=0;i<40 && fitted.at(-1) !== height;i++) await p.waitForTimeout(25);
|
||||
assert(fitted.at(-1) >= need.usage, `the panel fits the Usage tab: ${fitted.at(-1)} < ${need.usage}`);
|
||||
assert.equal(fitted.at(-1),height,"the panel fits its tallest tab including Usage");
|
||||
assert.equal(fitted.at(-1),height,`the panel fits the ${need.tab} tab showing`);
|
||||
const scroll = () => p.locator("#view-agents").evaluate(v => v.scrollTop);
|
||||
const before = await scroll();
|
||||
await p.locator("#panelUsage .pu-card .segs .opt").nth(1).click();
|
||||
|
||||
Reference in New Issue
Block a user