Skip to content

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

usage: the Sessions bars are rows of their own, not a subgrid (#3955)

yetone0c973cd9a4e6
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css
index 932fe892b..bf1916be4 100644
--- a/internal/gui/assets/app.css
+++ b/internal/gui/assets/app.css
@@ -1582,13 +1582,16 @@ details.cx-part[open] > summary .cx-h { margin-bottom: 2px; }
.sess-card-foot .grow { flex: 1; }
.sess-none { color: var(--faint); font-size: 12px; padding: 18px 0; text-align: center; margin: auto 0; }
.sess-more { font-size: 11px; color: var(--faint); padding: 4px 2px 0; }
-/* a card of bars is one grid: its names take the width the longest needs
- and the bars what is left, every row's bar starting at the same place;
- a window too narrow for that shortens the names, never a bar past 5em */
-.sess-bars { display: grid; grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto 4.2em; column-gap: 10px; row-gap: 1px; }
-.sess-bars.tools { grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto auto 2.8em; }
-.sess-bars > * { grid-column: 1 / -1; }
-.sess-bar { display: grid; grid-template-columns: subgrid; align-items: center; gap: 10px; height: 26px; padding: 0 6px; margin: 0 -6px; border: 0; border-radius: 6px; background: none; color: var(--fg-2); font: inherit; font-size: 12px; text-align: left; cursor: default; }
+/* every row of a card of bars has the same columns: its names take the width
+ the longest needs and the bars what is left, every row's bar starting at
+ the same place; a window too narrow for that shortens the names, never a
+ bar past 5em. Each row is a grid of its own, its columns measured from the
+ widest (sessLineUp); the rows were a subgrid of the card once, the way
+ Safari 16 crashed sizing (#3731, #3955) */
+.sess-bars { display: flex; flex-direction: column; gap: 1px; }
+.sess-bar { display: grid; grid-template-columns: minmax(0, var(--sb0, max-content)) minmax(5em, 1fr) var(--sb2, auto) 4.2em; align-items: center; gap: 10px; height: 26px; padding: 0 6px; margin: 0 -6px; border: 0; border-radius: 6px; background: none; color: var(--fg-2); font: inherit; font-size: 12px; text-align: left; cursor: default; }
+.sess-bars.tools > .sess-bar { grid-template-columns: minmax(0, var(--sb0, max-content)) minmax(5em, 1fr) var(--sb2, auto) var(--sb3, auto) 2.8em; }
+.sess-bars.fit > .sess-bar, .sess-skills.fit .line { width: max-content; }
.sess-bar:hover { background: var(--pill); }
.sess-bar.on { background: var(--pill); color: var(--fg); font-weight: 550; }
.sess-bar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -1634,20 +1637,10 @@ details.cx-part[open] > summary .cx-h { margin-bottom: 2px; }
.sess-weeks .stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 3px; overflow: hidden; }
.sess-weeks .stack i { min-height: 1px; }
.sess-weeks-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); }
-.sess-skills { display: grid; grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto; column-gap: 10px; row-gap: 2px; }
-.sess-skills > * { grid-column: 1 / -1; }
-.sess-skill { display: grid; grid-template-columns: subgrid; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; min-width: 0; }
+.sess-skills { display: flex; flex-direction: column; gap: 2px; }
+.sess-skill { padding: 4px 6px; margin: 0 -6px; border-radius: 6px; min-width: 0; }
.sess-skill:hover { background: var(--pill); }
-.sess-skill .line, .sess-skill .sub { grid-column: 1 / -1; }
-.sess-skill .line { display: grid; grid-template-columns: subgrid; align-items: center; gap: 10px; font-size: 12px; }
-/* before subgrid (Safari 16) each row is a grid of its own, its name as
- wide as it needs and its bar at least 5em */
-@supports not (grid-template-columns: subgrid) {
- .sess-bar { grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto 4.2em; }
- .sess-bar.tool { grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto auto 2.8em; }
- .sess-skill { display: block; }
- .sess-skill .line { grid-template-columns: minmax(0, max-content) minmax(5em, 1fr) auto; }
-}
+.sess-skill .line { display: grid; grid-template-columns: minmax(0, var(--sb0, max-content)) minmax(5em, 1fr) var(--sb2, auto); align-items: center; gap: 10px; font-size: 12px; }
.sess-skill .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); font-weight: 550; }
.sess-skill .track { height: 6px; border-radius: 3px; background: var(--pill); overflow: hidden; }
.sess-skill:hover .track { background: var(--card); }
diff --git a/internal/gui/assets/plugins/usage/page.js b/internal/gui/assets/plugins/usage/page.js
index b1908b92f..6dc4cf90f 100644
--- a/internal/gui/assets/plugins/usage/page.js
+++ b/internal/gui/assets/plugins/usage/page.js
@@ -3417,6 +3417,7 @@ function renderSessTools() {
top.append(r);
}
cols.append(top);
+ queueMicrotask(() => sessLineUp(top));
const side = el("div", "sess-tools-side");
// by kind: one bar of every call, and each kind's count
@@ -3500,6 +3501,25 @@ function renderSessSkills() {
}
if (su.count > su.top.length) body.append(el("div", "sess-more", t("+{n} more", { n: su.count - su.top.length })));
box.append(body);
+ sessLineUp(body);
+}
+
+// sessLineUp gives every row of a card of bars the columns of the widest:
+// each row is a grid of its own (#3955), so each column's width is read
+// with the rows at their natural width and set on the card as --sb<i>. The
+// widths don't change with the window's, so a card is measured once, when
+// it is first shown
+const sessSeen = new ResizeObserver((es) => es.forEach((e) => { if (e.contentRect.width) { sessSeen.unobserve(e.target); sessLineUp(e.target); } }));
+function sessLineUp(box) {
+ if (!box.isConnected) return;
+ if (!box.offsetWidth) return sessSeen.observe(box);
+ const rows = [...box.querySelectorAll(box.classList.contains("sess-skills") ? ":scope > .sess-skill > .line" : ":scope > .sess-bar")];
+ for (const p of [...box.style]) if (p.startsWith("--sb")) box.style.removeProperty(p);
+ box.classList.add("fit");
+ const w = [];
+ for (const r of rows) [...r.children].forEach((c, i) => { w[i] = Math.max(w[i] || 0, c.getBoundingClientRect().width); });
+ box.classList.remove("fit");
+ w.forEach((x, i) => box.style.setProperty("--sb" + i, Math.ceil(x) + "px"));
}
// sessBars is a card of folders or models as bars of the tokens each took;
@@ -3529,6 +3549,7 @@ function sessBars(box, title, items, cur, choose, name) {
if (!items.length) body.append(el("div", "sess-none", t("Nothing in this range.")));
if (items.length > shown.length) body.append(el("div", "sess-more", t("+{n} more", { n: items.length - shown.length })));
box.append(body);
+ sessLineUp(body);
}
// sessSpent is a session's tokens and cost, as the two right-hand columns
diff --git a/internal/gui/tests/sessions-bar-names.test.cjs b/internal/gui/tests/sessions-bar-names.test.cjs
index 91f3fde7d..b6fe3afc9 100644
--- a/internal/gui/tests/sessions-bar-names.test.cjs
+++ b/internal/gui/tests/sessions-bar-names.test.cjs
@@ -5,13 +5,17 @@
// Now a card's names take the width the longest needs and the bars what is
// left, every row's bar starting at the same place; narrow, the names are
// shortened and a bar is never under 5em.
+// Each row is a grid of its own, not a subgrid of its card (#3955: a
+// subgrid crashed Safari 16's WebKit sizing it, #3731), so no rule of the
+// bars says subgrid, and every row's bar still starts and ends at one x,
+// wide and narrow, in every language.
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 assets = path.resolve(__dirname, process.env.MAGPIE_SESS_ASSETS || "../assets");
const iso = (d) => [d.getFullYear(), d.getMonth() + 1, d.getDate()].map((n) => String(n).padStart(2, "0")).join("-");
const to = new Date(2026, 8, 28);
const back = (i) => { const d = new Date(to); d.setDate(d.getDate() - i); return d; };
@@ -65,12 +69,32 @@ function serve(lang) {
};
}
+test("no rule of the sessions bars says subgrid", async () => {
+ const css = await fs.readFile(path.join(assets, "app.css"), "utf8");
+ const bad = [];
+ for (const m of css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
+ if (/\.sess-(bars?|skills?)\b/.test(m[1]) && /subgrid/.test(m[2])) bad.push(m[1].trim());
+ }
+ assert.deepEqual(bad, []);
+});
+
+// every row of a card starts its bar at one x and ends it at one x
+function lined(rs) {
+ for (const card of new Set(rs.map((r) => r.card))) {
+ const of = rs.filter((r) => r.card === card);
+ for (const k of ["left", "right"]) {
+ const xs = of.map((r) => Math.round(r[k]));
+ assert.equal(new Set(xs).size, 1, `${card} bars' ${k} at ${xs}`);
+ }
+ }
+}
+
// each bar row of the four cards: its name's full and shown widths, its bar's
const rows = (page) => page.evaluate(() => {
const out = [];
const pick = (sel, name, track) => document.querySelectorAll(sel).forEach((r) => {
const n = r.querySelector(name), b = r.querySelector(track).getBoundingClientRect();
- out.push({ sel, text: n.textContent, full: n.scrollWidth, shown: n.clientWidth, bar: b.width, left: b.left, card: r.closest(".sess-card").id });
+ out.push({ sel, text: n.textContent, full: n.scrollWidth, shown: n.clientWidth, bar: b.width, left: b.left, right: b.right, card: r.closest(".sess-card").id });
});
pick("#sessProjects .sess-bar", ".n", ".track");
pick("#sessModels .sess-bar", ".n", ".track");
@@ -80,7 +104,7 @@ const rows = (page) => page.evaluate(() => {
});
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
- for (const lang of ["en", "zh"]) {
+ for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
test(`${engine} ${lang}: the sessions bars' names take the width they need`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const context = await browser.newContext({ viewport: { width: 1600, height: 900 }, reducedMotion: "reduce", timezoneId: "Asia/Shanghai" });
@@ -108,10 +132,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.ok(r.full <= r.shown + 0.5, `${r.sel} "${r.text}" cut short: ${r.full} > ${r.shown}`);
assert.ok(r.bar >= 60, `${r.sel} "${r.text}" bar ${r.bar}`);
}
- for (const card of new Set(rs.map((r) => r.card))) {
- const lefts = rs.filter((r) => r.card === card).map((r) => Math.round(r.left));
- assert.equal(new Set(lefts).size, 1, `${card} bars start at ${lefts}`);
- }
+ lined(rs);
assert.ok(rs.some((r) => r.text === LONG_DIR.split("/").pop()) && rs.some((r) => r.text === LONG_MODEL));
});
@@ -120,6 +141,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForTimeout(100);
const rs = await rows(page);
for (const r of rs) assert.ok(r.bar >= 59, `${r.sel} "${r.text}" bar ${r.bar}`);
+ lined(rs);
assert.ok(rs.some((r) => r.full > r.shown), "a long name should be shortened at 420 wide");
// nothing past its card
const over = await page.evaluate(() => [...document.querySelectorAll("#sessGrid .sess-card")].filter((c) => c.scrollWidth > c.clientWidth + 1).map((c) => c.id));
@@ -129,7 +151,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await t.test("wide again", async () => {
await page.setViewportSize({ width: 1600, height: 900 });
await page.waitForTimeout(100);
- for (const r of await rows(page)) assert.ok(r.full <= r.shown + 0.5, `${r.sel} "${r.text}" cut short`);
+ const rs = await rows(page);
+ for (const r of rs) assert.ok(r.full <= r.shown + 0.5, `${r.sel} "${r.text}" cut short`);
+ lined(rs);
});
assert.deepEqual(errors, []);
});