Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
context: a part of a few tokens on the map is a tile one sees, not a strip under the gap (AIGCFREE on Discord)
yetonea4e929212f9b
diff --git a/internal/gui/assets/context.js b/internal/gui/assets/context.jsindex 6c31c8457..9cca13a4e 100644--- a/internal/gui/assets/context.js+++ b/internal/gui/assets/context.js@@ -304,7 +304,7 @@// to read goes in one tile with the part's other small ones; a part too// small for its items is one tile. Each tile: key (stays across draws),// kind, its item (it), the items it stands for (its), rect in px.- const TILE_MIN = 1500, TILE_MAX = 12, TILE_FLOOR = 700;+ const TILE_MIN = 1500, TILE_MAX = 12, TILE_FLOOR = 700, TILE_SIDE = 16;// the look switch's marks: tiles, and a grid of cellsconst LOOK_MAP = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><rect x="1.5" y="2" width="5.5" height="12" rx="1.6"/><rect x="8.5" y="2" width="6" height="6.5" rx="1.6"/><rect x="8.5" y="10" width="6" height="4" rx="1.4"/></svg>';const LOOK_GRID = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">' +@@ -328,7 +328,20 @@const lo = (sum * TILE_FLOOR) / Math.max(1, area);return vals.map((a) => ({ ...a, v: Math.max(a.v, lo) }));};- for (const r of squarify(floored(parts.map((x) => ({ v: x.tokens, x })), ur[2] * ur[3]), ...ur)) {+ // and a part's tile is TILE_SIDE px across both ways: the floor is an+ // area, and a part laid in a long row beside large ones met it as a+ // strip (49 tokens of memory beside 70K: 190×4px, under the tiles' 3px+ // gap, so it was hidden; AIGCFREE on Discord). One too thin has its+ // value raised by as much and the parts are laid again.+ const partVals = floored(parts.map((x) => ({ v: x.tokens, x })), ur[2] * ur[3]);+ let partRects = squarify(partVals, ...ur);+ for (let n = 0; n < 8; n++) {+ const thin = partRects.filter((r) => Math.min(r.w, r.h) < TILE_SIDE);+ if (!thin.length) break;+ for (const r of thin) r.a.v *= (TILE_SIDE / Math.max(1, Math.min(r.w, r.h))) * 1.05;+ partRects = squarify(partVals, ...ur);+ }+ for (const r of partRects) {const x = r.a.x;const items = (x.items || []).filter((it) => it.tokens > 0).sort((a, b) => b.tokens - a.tokens);const isum = items.reduce((s, it) => s + it.tokens, 0);diff --git a/internal/gui/tests/context-map.test.cjs b/internal/gui/tests/context-map.test.cjsindex 10a596f8f..7fe78e58d 100644--- a/internal/gui/tests/context-map.test.cjs+++ b/internal/gui/tests/context-map.test.cjs@@ -17,7 +17,7 @@ const assets = path.resolve(__dirname, "../assets");const now = Date.now();const ago = (m) => new Date(now - m * 60000).toISOString();-const latest = {+const LATEST = {window: 272000, tokens: 21400, counted: true, turns: 3,parts: [{ kind: "system", tokens: 5200, items: [{ name: "prompt", tokens: 4900 }, { name: "environment_context", tokens: 300 }] },@@ -29,7 +29,7 @@ const latest = {{ kind: "chat", tokens: 800, items: [{ name: "turn", tag: "turn", n: 3, tokens: 800 }] },],};-const context = (days) => ({+const context = (days, latest = LATEST) => ({days,agents: [{ agent: "codex", requests: 9, sessions: 1, errors: 0, calls: 9, median: 17700, p90: 21400, baseline: 13300, window: 272000, cache: 0.74, growth: 228, peakFill: 0.08, compacts: 0,@@ -47,7 +47,7 @@ const context = (days) => ({{ agent: "codex", key: "01a117b1-aecd-76e2-9b2f-3c1d", title: "Port the parser", model: "live/codex/gpt-5.6-luna", first: ago(12), last: ago(4), requests: 3, peak: 21400, window: 272000,latest, latestId: 19, points: [{ id: 17, time: ago(12), tokens: 13000, cache: 0 }, { id: 18, time: ago(8), tokens: 17700, cache: 12000 }, { id: 19, time: ago(4), tokens: 21400, cache: 20900 }] },{ agent: "claude", key: "ce0c93f6-1111-2222-3333-444444444444", model: "claude-sonnet-5", first: ago(30), last: ago(9), requests: 1, peak: 180000, window: 200000,- latest: { ...latest, window: 200000, tokens: 180000 }, latestId: 30, points: [{ id: 30, time: ago(9), tokens: 180000 }] },+ latest: { ...LATEST, window: 200000, tokens: 180000 }, latestId: 30, points: [{ id: 30, time: ago(9), tokens: 180000 }] },],});@@ -74,7 +74,7 @@ function text(url, r) {return r.fulfill({ json: { id: 19, kind, items, kept: 10 } });}-function serve(lang, asked) {+function serve(lang, asked, latest) {const state = { agents: [{ id: "claude", name: "Claude Code", path: "/test/claude", fields: [] }, { id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light" } };return async (r) => {const url = new URL(r.request().url());@@ -84,7 +84,7 @@ function serve(lang, asked) {if (url.pathname === "/api/state") return json(state);if (url.pathname === "/api/context") {asked.push(url.searchParams.get("days"));- return json(context(+url.searchParams.get("days")));+ return json(context(+url.searchParams.get("days"), latest));}// the text comes a moment after it is asked, as it does under load:// the dialog says "Reading…" first, and the test waits past it@@ -138,10 +138,10 @@ const words = {};-async function open(page, lang, width, still) {+async function open(page, lang, width, latest) {const errors = [];page.on("pageerror", (e) => errors.push(e.message));- await page.route("**/*", serve(lang, []));+ await page.route("**/*", serve(lang, [], latest));await page.addInitScript(() => { try { if (!sessionStorage.getItem("set")) { localStorage.clear(); localStorage.setItem("magpie.usageTab", "context"); sessionStorage.setItem("set", "1"); } } catch {} });await page.goto("http://magpie.test/?view=usage");const card = await openSession(page);@@ -264,6 +264,40 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",}}+ // a part of a few tokens beside parts of thousands is still a tile one+ // sees and points at: the memory's 49 tokens beside 72K, the window not+ // known, were laid as a strip thinner than the gap between tiles and+ // hidden (AIGCFREE on Discord)+ for (const width of [1100, 420]) {+ test(`${engine} ${width}px: a part of a few tokens is a tile one can point at`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ const page = await (await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" })).newPage();+ page.setDefaultTimeout(5000);+ const files = Array.from({ length: 16 }, (_, i) => ({ name: `/work/app/f${i}.rs`, tag: "shell", tokens: [2000, 1400, 1300, 830][i] || 530 }));+ const { errors, card } = await open(page, "en", width, {+ window: 0, tokens: 72100, counted: true, turns: 1,+ parts: [+ { kind: "system", tokens: 3100, items: [{ name: "prompt", tokens: 3100 }] },+ { kind: "tools", tokens: 3900, items: [{ name: "bash", tokens: 2400 }, { name: "read", tokens: 1500 }] },+ { kind: "memory", tokens: 49, items: [{ name: "system-reminder", tokens: 49 }] },+ { kind: "files", tokens: 11900, items: files },+ { kind: "results", tokens: 21600, items: [{ name: "bash", tag: "result", n: 21, tokens: 19400 }, { name: "read", tag: "result", tokens: 2200 }] },+ { kind: "chat", tokens: 31600, items: [{ name: "1", tag: "turn", tokens: 31600 }] },+ ],+ });+ const memory = card.locator(".ctx-map .ctx-tile.k-memory");+ await memory.waitFor();+ const box = await memory.boundingBox();+ assert.ok(box.width >= 12 && box.height >= 12, `the memory is a sliver: ${box.width}×${box.height}`);+ await wheelTo(page, memory);+ await memory.hover();+ await card.locator(".ctx-tip").waitFor({ state: "visible" });+ assert.match(await card.locator(".ctx-tip").innerText(), /Memory/);+ assert.deepEqual(errors, []);+ });+ }+// with motion reduced the tiles are simply theretest(`${engine}: the map holds still with motion reduced`, async (t) => {const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));