usage: a narrow Requests list makes the rest tighter before it leaves the first token's column out
unscientific9 saw Requests' 首字耗时 column on one Windows machine and not
on another, with the same settings and version. The column is left out
when the table doesn't fit the window (ledFit), and that width is each
machine's own: the saved window size (660 by default), Windows' display
scaling and the text size. It was the first thing to go after Sent,
Effort and the cache, before names were cut shorter, headers wrapped and
the price reference line dropped (tighter). Now tighter comes first, and
the column goes (tight2, its value under the duration since 07fd06b4b)
only if the table still doesn't fit. ledGrow's "nothing left to leave
out" check follows it to tight2.
Measured with usage-ledger-ttft's rows: the column now stays down to
~650px in zh (was 760) and ~770px in en (was 870), in Chromium and
WebKit on mote; on the Windows box the old order dropped it at 720 (zh)
and 800 (en).
Run on mote, at this tree:
- usage-ledger-ttft, usage-speed, usage-ledger-detail, usage-ledger-bytes,
BROWSER=chromium and webkit: 43 of 43 each.
- usage-ledger-ttft on xiaomi-gpu (win-run, chromium): 6 of 6.
- usage-ledger-ttft now steps from 1600 to 600 wide in every language and
checks the column is out exactly while tight2 is on, tight2 only after
tighter, and some width keeps the column with tighter on.
- Broken by hand: with the old order (tight2 before tighter) it goes red
in every language ("the column goes only after the rest is made
tighter, at 760").
- The wider run (every usage-*/led* file and the other ledger files,
i18n-keys, both engines) was still going when this was pushed.
Not tried: the real WebView2 app on Windows, WebKitGTK on Linux, the
reporter's own window size and rows.
Reported-by: unscientific9 (Discord)
This commit is contained in:
@@ -2063,7 +2063,7 @@ const ledGrow = new ResizeObserver(() => {
|
||||
ledGrowFrame = requestAnimationFrame(() => {
|
||||
ledGrowFrame = 0;
|
||||
const wrap = $("#ledWrap"), table = wrap.querySelector("table.led");
|
||||
if (table && !table.classList.contains("tighter") && wrap.clientWidth && wrap.scrollWidth > wrap.clientWidth + 1) ledFit();
|
||||
if (table && !table.classList.contains("tight2") && wrap.clientWidth && wrap.scrollWidth > wrap.clientWidth + 1) ledFit();
|
||||
ledHScroll();
|
||||
});
|
||||
});
|
||||
@@ -2192,11 +2192,13 @@ function ledFit() {
|
||||
table.classList.toggle("tight", tight);
|
||||
// still too wide (#860: a Windows window at 175%, its wider fonts): the
|
||||
// price reference line goes too, in the cost's tooltip and the details
|
||||
// as well, and names are cut shorter, whole in their tooltips
|
||||
// still too wide: the first token's column goes (#2522), its value
|
||||
// under the duration, and only then what follows
|
||||
if (tight && over()) table.classList.add("tight2");
|
||||
// as well, names are cut shorter, whole in their tooltips, and headers
|
||||
// wrap. Only when that is still too wide does the first token's column
|
||||
// go (#2522), its value under the duration: a column is the larger loss,
|
||||
// and two Windows windows a little apart in width showed it on one and
|
||||
// not the other (unscientific9 on Discord)
|
||||
if (tight && over()) table.classList.add("tighter");
|
||||
if (tight && over()) table.classList.add("tight2");
|
||||
if (!hint) {
|
||||
hint = el("span", "led-tight");
|
||||
hint.id = "ledTight";
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
// writing after it, so a list of durations can't tell a vendor slow to
|
||||
// start from one slow to write. The column says the row details' "First
|
||||
// token", "≈" for one told from a session file's times, and a dash for one
|
||||
// with none (failed, or not streamed). A narrow window leaves it out with
|
||||
// Sent, Effort and the cache, and then it reads small under each duration
|
||||
// instead (unscientific9 on Discord), a row with none adding nothing; the
|
||||
// with none (failed, or not streamed). A narrow window leaves Sent, Effort
|
||||
// and the cache out, then cuts names and wraps headers, and only then the
|
||||
// column too, which then reads small under each duration instead
|
||||
// (unscientific9 on Discord), a row with none adding nothing; the
|
||||
// hint names only what is in the details alone. Every language, both
|
||||
// engines, three widths; no backend, the API is faked.
|
||||
// engines, from wide to narrow; no backend, the API is faked.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -115,8 +116,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const durText = await rows.nth(0).locator("td.duration").textContent();
|
||||
for (let i = 0; i < 4; i++) assert.equal(await under(i), "", "a wide window adds nothing under the duration");
|
||||
|
||||
// a narrowing window shortens names, wraps headers and drops the
|
||||
// price reference before it leaves the column out: a column is the
|
||||
// larger loss, and two Windows windows a little apart in width
|
||||
// showed it on one and not the other (unscientific9 on Discord)
|
||||
const fits = [];
|
||||
for (let vw = 1600; vw >= 600; vw -= 20) {
|
||||
await p.setViewportSize({ width: vw, height: 800 });
|
||||
await p.waitForTimeout(40);
|
||||
fits.push([vw, await p.locator("table.led").evaluate((tb) => [...tb.classList].filter((c) => c !== "led").join(" ")), await cell(0).isVisible()]);
|
||||
}
|
||||
const said = fits.map((f) => f.join(":")).join(", ");
|
||||
for (const [vw, cls, shown] of fits) {
|
||||
assert.equal(shown, !cls.includes("tight2"), "the column is out exactly while tight2 is on, at " + vw + ": " + said);
|
||||
if (cls.includes("tight2")) assert(cls.includes("tighter"), "the column goes only after the rest is made tighter, at " + vw + ": " + said);
|
||||
}
|
||||
assert(fits.some(([, cls, shown]) => cls.includes("tighter") && shown), "some width keeps the column with the rest made tighter: " + said);
|
||||
|
||||
// a narrow window: the column goes, the details keep it, the hint says so
|
||||
await p.setViewportSize({ width: 760, height: 800 });
|
||||
await p.setViewportSize({ width: 600, height: 800 });
|
||||
await p.waitForTimeout(300);
|
||||
assert.equal(await cell(0).isVisible(), false, "a narrow window leaves it out");
|
||||
assert.equal((await p.locator("#ledTight").textContent()).trim(), w.hint);
|
||||
|
||||
Reference in New Issue
Block a user