Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
context: the map counts on as a live request grows, and keeps its tip
yetonef1537d9f95aa
diff --git a/internal/gui/assets/context.js b/internal/gui/assets/context.jsindex c5eb4b5c7..325777723 100644--- a/internal/gui/assets/context.js+++ b/internal/gui/assets/context.js@@ -32,6 +32,8 @@return String(n);};const pct = (x) => Math.round(x * 100) + "%";+ // a count of tokens that a redraw counts on from what it said (morph)+ const num = (tag, cls, n) => { const e = el(tag, cls, fmtK(n)); e.dataset.n = Math.round(n); return e; };const median = (xs) => {if (!xs.length) return 0;const s = [...xs].sort((a, b) => a - b);@@ -210,12 +212,37 @@function morph(old, neu) {if (old.nodeName !== neu.nodeName || (old.nodeType !== 1 && old.nodeType !== 3)) { old.replaceWith(neu); return neu; }if (old.nodeType === 3) { if (old.data !== neu.data) old.data = neu.data; return old; }+ // a count (data-n) is counted on from what it said to the new one+ const from = old._at ?? (old.dataset?.n ? +old.dataset.n : undefined);for (const a of [...old.attributes]) if (!neu.hasAttribute(a.name)) old.removeAttribute(a.name);for (const a of neu.attributes) if (old.getAttribute(a.name) !== a.value) old.setAttribute(a.name, a.value);for (const h of HANDLERS) if (old[h] !== neu[h]) old[h] = neu[h];morphKids(old, [...neu.childNodes]);+ if (neu.dataset?.n) roll(old, from, +neu.dataset.n, fmtK, calm());return old;}+ // roll counts node's text from one number to another as the map's tiles+ // glide, in their time (flohoeller's map counts up as its window fills);+ // fmt says a number. quiet, or with nothing to count from, it says the+ // new one at once+ function roll(node, from, to, fmt, quiet) {+ cancelAnimationFrame(node._raf);+ if (quiet || from === undefined || from === to || !node.isConnected) {+ delete node._at;+ if (node.textContent !== fmt(to)) node.textContent = fmt(to);+ return;+ }+ const t0 = performance.now();+ const step = (now) => {+ // a frame's time can be before t0 (it is when the frame began)+ const k = Math.min(1, Math.max(0, (now - t0) / 620));+ node._at = from + (to - from) * (1 - Math.pow(1 - k, 4));+ node.textContent = fmt(node._at);+ if (k < 1) node._raf = requestAnimationFrame(step);+ else delete node._at;+ };+ step(t0);+ }function morphKids(box, kids) {const old = [...box.childNodes];kids.forEach((k, i) => { if (i < old.length) morph(old[i], k); else box.append(k); });@@ -461,6 +488,18 @@}placeTip(n);};+ // the tip told again as its tile grows, and kept over it as it glides+ const followTip = (n) => {+ if (!n.isConnected || n.classList.contains("gone")) { tip.hidden = true; return; }+ showMapTip(n);+ const t0 = performance.now();+ const go = (now) => {+ if (tip.hidden || !n.classList.contains("on")) return;+ placeTip(n);+ if (now - t0 < 660) requestAnimationFrame(go);+ };+ requestAnimationFrame(go);+ };const tileAt = (e) => {const n = e.target.closest?.(".ctx-tile");return cur && n && n.parentElement === map && n._tile && !n.classList.contains("gone") ? n : null;@@ -508,16 +547,28 @@n._tile = tl;const cls = "ctx-tile " + (tl.free ? "free" : "k-" + tl.kind) + (tl.w < 54 || tl.h < 30 ? " bare" : tl.h < 46 ? " low" : "") + (n.classList.contains("on") ? " on" : "");if (n.className !== cls) n.className = cls;- let name, v;- if (tl.free) { name = t("Free space"); v = fmtK(tl.tokens) + " · " + pct(tl.tokens / Math.max(window, p.tokens, 1)); }+ // the value counts on to its tokens as the tile glides (roll)+ let name, v = (x) => fmtK(x) + " · " + partName(tl.kind);+ if (tl.free) { name = t("Free space"); v = (x) => fmtK(x) + " · " + pct(x / Math.max(window, p.tokens, 1)); }else if (tl.it) {name = itemName(tl.it);if (tl.kind === "files" || tl.kind === "memory") name = name.slice(name.lastIndexOf("/", name.length - 2) + 1) || name;- v = fmtK(tl.tokens) + " · " + partName(tl.kind);- } else if (tl.key === tl.kind) { name = partName(tl.kind); v = fmtK(tl.tokens); }- else { name = t("{n} more", { n: tl.its.length }); v = fmtK(tl.tokens) + " · " + partName(tl.kind); }+ // a tool's results gathered, how many: "web__run ×20"+ if (tl.it.n > 1 && tl.it.tag !== "turns" && tl.it.tag !== "more") name += " ×" + tl.it.n;+ } else if (tl.key === tl.kind) { name = partName(tl.kind); v = fmtK; }+ else {+ // the small files gathered: their folder, when they share one+ // ("src/api/ · 12 files"), as the reader would name them+ const dirs = new Set(tl.its.map((it) => it.name.slice(0, it.name.lastIndexOf("/") + 1)));+ const [dir] = dirs;+ if (tl.kind === "files" && dirs.size === 1 && dir) {+ name = dir.slice(dir.lastIndexOf("/", dir.length - 2) + 1);+ v = (x) => fmtK(x) + " · " + t("{n} files", { n: tl.its.length });+ } else name = t("{n} more", { n: tl.its.length });+ }if (n.firstChild.textContent !== name) n.firstChild.textContent = name;- if (n.lastChild.textContent !== v) n.lastChild.textContent = v;+ roll(n.lastChild, fresh ? undefined : n.lastChild._at ?? n.lastChild._n, tl.tokens, v, quiet || enter);+ n.lastChild._n = tl.tokens;// a gap of 3px between tiles: each 1.5px in from its rectconst pc = (a, b) => +((a / b) * 100).toFixed(3);n.style.left = `calc(${pc(tl.x, W)}% + 1.5px)`;@@ -682,7 +733,9 @@: "Estimated from what the agent sent: the vendor didn't say how many tokens it read");head.append(title);if (opts.foldable) {- head.append(el("span", "ctx-short", fmtK(p.tokens) + (window ? " / " + fmtK(window) + " · " + pct(full) : "")));+ const short = el("span", "ctx-short");+ short.append(num("span", "", p.tokens), window ? " / " + fmtK(window) + " · " + pct(full) : "");+ head.append(short);// folded, a thin bar of what fills the window, a part each; it is// morphed with the head, so a live request moves its widths onlyconst bar = el("span", "ctx-stack");@@ -713,7 +766,7 @@k.append(h);}const big = el("div", "ctx-big");- big.append(el("b", "", fmtK(p.tokens)));+ big.append(num("b", "", p.tokens));big.append(el("span", "", window ? "/ " + fmtK(window) + " " + t("tokens") : t("tokens")));const sub = el("div", "ctx-sub");if (window) {@@ -775,9 +828,12 @@else if (e.dataset.it !== String(c.item)) e.dataset.it = c.item;});cur = { p, window, cells, partOf };- if (!tip.hidden) tip.hidden = true;+ // a tile pointed at keeps its tip through a live request's draws+ const over = !tip.hidden && map.dataset.f === "tile" ? [...tiles.values()].find((n) => n.classList.contains("on")) : null;+ if (!tip.hidden && !over) tip.hidden = true;map.setAttribute("aria-label", grid.getAttribute("aria-label"));drawMap(false);+ if (over) followTip(over);// the legend: a part hovered lights its cellsconst legend = el("div", "ctx-legend");@@ -786,7 +842,7 @@if (!part || part.tokens <= 0) continue;const li = el("span", "ctx-leg");li.title = t(PART_NOTES[kind]);- li.append(el("i", "dot k-" + kind), el("span", "n", partName(kind)), el("span", "v", fmtK(part.tokens)));+ li.append(el("i", "dot k-" + kind), el("span", "n", partName(kind)), num("span", "v", part.tokens));clickable(li, () => openCtxText(rid, kind));li.onpointerenter = () => focusOn(kind);li.onpointerleave = unfocus;@@ -794,7 +850,7 @@}if (window && window > p.tokens) {const li = el("span", "ctx-leg");- li.append(el("i", "dot free"), el("span", "n", t("Free space")), el("span", "v", fmtK(window - p.tokens)));+ li.append(el("i", "dot free"), el("span", "n", t("Free space")), num("span", "v", window - p.tokens));li.onpointerenter = () => focusOn("free");li.onpointerleave = unfocus;legend.append(li);diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.jsindex da9eff0db..4e8fb9ba2 100644--- a/internal/gui/assets/i18n.js+++ b/internal/gui/assets/i18n.js@@ -168,6 +168,7 @@ const I18N = {"Turn {n}": "第 {n} 轮","{n} earlier turns": "更早的 {n} 轮","{n} more": "另外 {n} 项",+ "{n} files": "{n} 个文件","Healthy": "健康","Filling up": "渐满","Near full": "将满",@@ -4155,6 +4156,7 @@ const I18N = {"Turn {n}": "第 {n} 輪","{n} earlier turns": "更早的 {n} 輪","{n} more": "另外 {n} 項",+ "{n} files": "{n} 個檔案","Healthy": "健康","Filling up": "漸滿","Near full": "將滿",@@ -8089,6 +8091,7 @@ const I18N = {"Turn {n}": "ターン {n}","{n} earlier turns": "それ以前の {n} ターン","{n} more": "ほか {n} 件",+ "{n} files": "{n} ファイル","Healthy": "良好","Filling up": "埋まりつつある","Near full": "ほぼ満杯",@@ -12044,6 +12047,7 @@ const I18N = {"Turn {n}": "Runde {n}","{n} earlier turns": "{n} frühere Runden","{n} more": "{n} weitere",+ "{n} files": "{n} Dateien","Healthy": "Gesund","Filling up": "Füllt sich","Near full": "Fast voll",diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.goindex 58e192df9..82b721032 100644--- a/internal/gui/core_budget_test.go+++ b/internal/gui/core_budget_test.go@@ -16,7 +16,7 @@ import (// raises them and says why in its commit.const (appScriptBudget = 1_322_537 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25)- coreScriptBudget = 1_530_631 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25)+ coreScriptBudget = 1_533_445 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25))func TestCoreScriptBudget(t *testing.T) {diff --git a/internal/gui/tests/context-map-live.test.cjs b/internal/gui/tests/context-map-live.test.cjsnew file mode 100644index 000000000..0208e2afd--- /dev/null+++ b/internal/gui/tests/context-map-live.test.cjs@@ -0,0 +1,179 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// The context map as a live request grows (after flohoeller's context map+// on X): the counts count on to their new values as the tiles glide, a+// tile pointed at keeps its tip, told again with what it holds now, a+// tool's gathered results say how many, and the small files gathered say+// the folder they share. With motion reduced the counts are simply there.+// In every language, at a desk and a phone's width.+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 now = Date.now();+const ago = (m) => new Date(now - m * 60000).toISOString();++const tiny = ["auth.ts", "billing.ts", "refund.ts", "users.ts", "orders.ts", "carts.ts"]+ .map((f) => ({ name: "/work/app/src/api/" + f, tag: "read", tokens: 60 }));+const prompt = (grow) => ({+ window: 60000, tokens: 40000 + grow, counted: !grow,+ parts: [+ { kind: "system", tokens: 6000, items: [{ name: "prompt", tokens: 6000 }] },+ { kind: "tools", tokens: 8000, items: [{ name: "exec_command", tokens: 8000 }] },+ { kind: "files", tokens: 14000 + grow, items: [{ name: "/work/app/payment.ts", tag: "read", tokens: 9000 + grow }, { name: "/work/app/checkout.spec.ts", tag: "read", tokens: 4640 }, ...tiny] },+ { kind: "results", tokens: 9000, items: [{ name: "exec_command", tag: "result", n: 20, tokens: 9000 }] },+ { kind: "chat", tokens: 3000, items: [{ name: "turn", tag: "turns", n: 6, tokens: 3000 }] },+ ],+});+const context = (days) => ({+ days,+ agents: [{ agent: "codex", requests: 1, sessions: 1, errors: 0, calls: 1, median: 40000, p90: 40000, baseline: 20000, window: 60000, cache: 0.5, growth: 0, peakFill: 0.2, compacts: 0,+ shares: { system: 0.15, tools: 0.2, files: 0.35, results: 0.22, chat: 0.08 }, mcp: 0, score: 80,+ scores: [{ key: "cache", points: 20, most: 35 }], tags: [], models: ["gpt-5.6"], latestId: 19, latestTime: ago(4) }],+ sessions: [{ agent: "codex", key: "01a117b1-aecd-76e2-9b2f-3c1d", title: "Fix checkout", model: "gpt-5.6", first: ago(12), last: ago(4), requests: 1, peak: 40000, window: 60000,+ latest: prompt(0), latestId: 19, points: [{ id: 19, time: ago(4), tokens: 40000 }] }],+});++function serve(lang) {+ const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light" } };+ 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(state);+ if (url.pathname === "/api/context") return json(context(+url.searchParams.get("days")));+ if (url.pathname === "/api/gateway/trace") {+ if (url.searchParams.get("wait")) return new Promise(() => {});+ return json({ mine: true, now: new Date().toISOString(), seq: 0, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });+ }+ 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 === "/api/usage/quotas") return json([]);+ if (url.pathname === "/api/groups") return json({ groups: [], models: [] });+ if (url.pathname === "/api/plugins") return json({ plugins: [] });+ 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).catch(() => ""), contentType, status: 200 });+ };+}++const words = {+ en: { files: "6 files" },+ zh: { files: "6 个文件" },+ "zh-TW": { files: "6 個檔案" },+ ja: { files: "6 ファイル" },+ de: { files: "6 Dateien" },+};++async function open(browser, lang, width, reduced) {+ const page = await (await browser.newContext({ viewport: { width, height: 1600 }, reducedMotion: reduced ? "reduce" : "no-preference" })).newPage();+ page.setDefaultTimeout(5000);+ const errors = [];+ page.on("pageerror", (e) => errors.push(e.message));+ await page.route("**/*", serve(lang));+ await page.addInitScript(() => { try { localStorage.clear(); localStorage.setItem("magpie.usageTab", "context"); } catch {} });+ await page.goto("http://magpie.test/?view=usage");+ const row = page.locator(".ctx-sess-row", { hasText: "Fix checkout" });+ await row.waitFor();+ await row.click();+ const card = page.locator(".ctx-sess.open .ctx-card");+ await card.locator(".ctx-map .ctx-tile.free").waitFor();+ // the tiles in and the card open before anything is pointed at+ await page.waitForFunction(() => !document.getAnimations().some((a) => a.playState === "running" && a.effect?.target?.closest?.(".ctx-sess.open")));+ return { page, card, errors };+}++// still waits for a tile to stop moving (the list's scroll, the tiles in)+const still = (loc) => loc.evaluate((n) => new Promise((done) => {+ let last = "", same = 0;+ const go = () => {+ const r = n.getBoundingClientRect(), at = [r.left, r.top, r.width, r.height].map(Math.round).join();+ same = at === last ? same + 1 : 0;+ last = at;+ if (same >= 10) done();+ else requestAnimationFrame(go);+ };+ go();+}));++// grow draws the same request further on, live: payment.ts read again+const grow = (page, by) => page.evaluate((by) => {+ const c = document.querySelector(".ctx-sess.open .ctx-card");+ window.__seen = [];+ const b = c.querySelector(".ctx-big b");+ const look = () => { window.__seen.push(b.textContent); if (window.__seen.length < 90) requestAnimationFrame(look); };+ c.ctxUpdate({ id: 19, agent: "codex", done: false, prompt: window.__prompt(by) }, {});+ look();+}, by);++for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {+ for (const lang of Object.keys(words)) {+ for (const width of [1100, 420]) {+ test(`${engine} ${lang} ${width}px: the map as a live request grows`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ const { page, card, errors } = await open(browser, lang, width);+ await page.evaluate(`window.__prompt = ${prompt.toString().replace("tiny", JSON.stringify(tiny))}`);+ const map = card.locator(".ctx-map");++ // a tool's results gathered say how many; the small files their+ // folder, where the map has room for the files one by one (a phone's+ // narrow map draws them as one tile)+ assert.match(await map.locator(".ctx-tile.k-results .n").innerText(), /exec_command ×20/);+ const apart = (await map.locator(".ctx-tile.k-files").count()) > 1;+ if (apart) {+ const folder = map.locator(".ctx-tile.k-files", { hasText: "api/" });+ assert.equal(await folder.count(), 1, "the small files don't name their folder");+ assert.match(await folder.locator(".v").textContent(), new RegExp(words[lang].files));+ }++ // payment.ts pointed at, and read again while the tip is open+ const tile = map.locator(apart ? ".ctx-tile.k-files:has-text('payment.ts')" : ".ctx-tile.k-files");+ await tile.scrollIntoViewIfNeeded();+ await still(tile);+ await tile.hover();+ const tip = card.locator(".ctx-tip");+ await tip.waitFor({ state: "visible" });+ assert.match(await tip.innerText(), apart ? /9K/ : /14K/);+ // the list above can still settle once the tip is open: pointed at again+ await still(tile);+ await tile.hover();+ await still(tile);+ await grow(page, 8000);+ // the count counts on: past values between 40K and 48K, ending there+ await page.waitForFunction(() => window.__seen.length >= 90);+ const seen = await page.evaluate(() => window.__seen);+ const k = seen.map((s) => parseFloat(s));+ assert.equal(seen.at(-1), "48K");+ assert.ok(new Set(seen).size >= 4, `the count jumped: ${[...new Set(seen)]}`);+ assert.ok(k.every((x, i) => x >= 40 && x <= 48 && (i === 0 || x >= k[i - 1])), `the count went back or out: ${seen}`);+ // the tip stayed open, saying what the tile holds now, over it+ assert.ok(await tip.isVisible(), "the tip closed as the request grew");+ // the narrow map's Files tile can part as payment.ts grows: the tip+ // is then the tile's under the pointer+ assert.match(await tip.innerText(), apart ? /17K/ : /17K|22K/);+ if (apart) {+ assert.match(await tile.locator(".v").textContent(), /^17K/);+ const [tb, pb] = [await tip.boundingBox(), await tile.boundingBox()];+ assert.ok(tb.x < pb.x + pb.width && tb.x + tb.width > pb.x, "the tip was left behind its tile");+ }+ assert.deepEqual(errors, []);+ });+ }+ }++ test(`${engine}: with motion reduced the counts are simply there`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ const { page, card, errors } = await open(browser, "en", 1100, true);+ await page.evaluate(`window.__prompt = ${prompt.toString().replace("tiny", JSON.stringify(tiny))}`);+ await grow(page, 8000);+ await page.waitForFunction(() => window.__seen.length >= 90);+ assert.deepEqual([...new Set(await page.evaluate(() => window.__seen))], ["48K"]);+ assert.equal(await card.locator(".ctx-map .ctx-tile.k-files", { hasText: "payment.ts" }).locator(".v").textContent(), "17K · Files");+ assert.deepEqual(errors, []);+ });+}