context: a slim tile in the context map keeps its gap to the tile beside it
noahhrreion on Discord (11-06): in the context map the system prompt and tool tiles sat right against the large "N more" tile beside them, and sometimes ran over it. A tile is its rect less a 3px gap, but its 7px/9px padding stayed on when the tile was too slim for labels (.bare). A box can't be narrower than its padding, so a tile laid at 16px (TILE_SIDE) was drawn 18px wide and ran 2px into its neighbour. A bare tile now has no padding (its labels are hidden already), so every tile stays inside its rect and the 3px gap holds at every width. Nothing else in the layout changes. Test: context-map.test.cjs "slim tiles keep their gap at every width" lays a system prompt, tools and 110 turns (the reporter's shape) and checks every pair of tiles is at least 2.5px apart at 13 widths from 1100px to 360px, in Chromium and WebKit, in all five languages. Run on mote (mote-run): - context-map.test.cjs: 36 of 36 passed (Chromium + WebKit, en/zh/zh-TW/ ja/de, 1100 and 420px, the new test included). - Broken by hand: on the old context.css the new test fails in all 10 runs: '980px: "ctx-tile k-chat bare" and "ctx-tile k-chat" are -2.25px apart'. - Screenshots, dark theme, zh, 980px, the old CSS and the new one: the old one has the slim column touching "另外 98 项", as in the report. The new one has the 3px gap. - context-map-live, context-scroll-end, context-text, ctx-route, context-scripts, context-window, ctx-head-narrow, routing-ctx-fold, routing-ctx-still, routing-context-fold, routing-ctx-sessions, routing-live-patch, routing-return-cost: 319 of 320. The red was context-window "chromium en 420px: the Context tab": browserContext.newPage said the browser had closed (load ~150). It passed 3 of 3 alone. Filed as #5460. Not run: the whole GUI suite, and the native apps. CSS only, so no Go build or tests. Reported-by: noahhrreion
This commit is contained in:
@@ -392,6 +392,9 @@ i.dot.free { background: var(--k-free); box-shadow: inset 0 0 0 1px color-mix(in
|
||||
.ctx-tile.low { padding-top: 5px; padding-bottom: 5px; }
|
||||
.ctx-tile.low .v { display: none; }
|
||||
.ctx-tile.bare > * { visibility: hidden; }
|
||||
/* a bare tile can be slimmer than its padding: none, so it keeps to its place
|
||||
and the gap beside it (noahhrreion on Discord) */
|
||||
.ctx-tile.bare { padding: 0; }
|
||||
.ctx-tile:hover, .ctx-tile.on {
|
||||
background: color-mix(in srgb, var(--k) 19%, var(--card));
|
||||
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 48%, transparent);
|
||||
|
||||
@@ -300,6 +300,51 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
});
|
||||
}
|
||||
|
||||
// two small parts beside a large one are laid as slim tiles, and every
|
||||
// tile keeps the map's gap to its neighbours at every width: a tile's
|
||||
// padding made one too slim for it wider than its place, so it touched
|
||||
// or ran over the next (noahhrreion on Discord, 11-06: the system
|
||||
// prompt and tools leaning on "N more" beside them)
|
||||
for (const lang of Object.keys(words)) {
|
||||
test(`${engine} ${lang}: slim tiles keep their gap at every width`, 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: 1100, height: 900 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const turns = Array.from({ length: 110 }, (_, i) => ({ name: String(i + 1), tag: "turn", tokens: 1300 + (i % 7) * 40 }));
|
||||
const chat = turns.reduce((s, it) => s + it.tokens, 0);
|
||||
const { errors, card } = await open(page, lang, 1100, {
|
||||
window: 200000, tokens: 2300 + 2800 + chat, counted: true, turns: turns.length,
|
||||
parts: [
|
||||
{ kind: "system", tokens: 2300, items: [{ name: "prompt", tokens: 2300 }] },
|
||||
{ kind: "tools", tokens: 2800, items: [{ name: "bash", tokens: 1500 }, { name: "read", tokens: 1300 }] },
|
||||
{ kind: "chat", tokens: chat, items: turns },
|
||||
],
|
||||
});
|
||||
const map = card.locator(".ctx-map");
|
||||
await map.locator(".ctx-tile.k-system").waitFor();
|
||||
let slim = 0;
|
||||
for (const width of [1100, 980, 860, 760, 680, 600, 560, 520, 480, 440, 420, 390, 360]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.waitForFunction(() => { const m = document.querySelector(".ctx-sess.open .ctx-map"); return m && m.dataset.size === m.clientWidth + "x" + m.clientHeight; });
|
||||
const rects = await map.evaluate((m) => [...m.querySelectorAll(".ctx-tile:not(.gone)")].map((n) => {
|
||||
const r = n.getBoundingClientRect();
|
||||
return { k: n.className, l: r.left, t: r.top, r: r.right, b: r.bottom };
|
||||
}));
|
||||
for (const [i, a] of rects.entries()) {
|
||||
if (a.r - a.l < 24) slim++;
|
||||
for (const b of rects.slice(i + 1)) {
|
||||
const gap = Math.max(b.l - a.r, a.l - b.r, b.t - a.b, a.t - b.b);
|
||||
assert.ok(gap >= 2.5, `${width}px: "${a.k}" and "${b.k}" are ${gap.toFixed(2)}px apart: ${JSON.stringify([a, b])}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.ok(slim > 0, "no width laid a slim tile, so the gap beside one was never looked at");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
// with motion reduced the tiles are simply there
|
||||
test(`${engine}: the map holds still with motion reduced`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
|
||||
Reference in New Issue
Block a user