usage: a narrow Requests list says each request's first token under its duration
Requests has a TTFT column (#2522), but it is the first column a narrow window leaves out (tight2), and then the value was only in the row's details. unscientific9 asked to see it in the list itself. Now, while that column is left out, each duration cell gets a second, small, muted line: "首字 5.5 秒" / "TTFT 5.5 s" (the core's "TTFT {ms}" string, "≈" for a time told from a session file). app.css draws it from a data-ttft attribute with ::after. That keeps it out of the cell's text, so readers of td.duration's textContent are unchanged. A row with no first token (a failure, or a reply not streamed) gets nothing. A wide window shows only the column, as before. The narrow hint now names only what is left in the details ("Sent, Effort and the cache"). The old "…the first token…" string is gone from all four languages. Run on mote, at this tree: - usage-ledger-ttft, usage-speed, usage-ledger-detail, session-identity, usage-ledger-bytes and i18n-keys, BROWSER=chromium and webkit: all pass except i18n-keys "a plugin's words are its own". That test is red on origin/main for "View routing" and "No session ID" (#5332, #5426), strings this change does not touch. - usage-ledger-ttft runs every language (en, zh, zh-TW, ja, de) at 1600, 760 and 420 wide. At 1600 nothing is under the duration. At 760 the line is the details' first token, "≈" for the Codex row, empty for a failure and for a reply not streamed, smaller than the duration, muted, and the page doesn't scroll sideways. At 420 the same holds. - The 79 usage-*/led* GUI files in both engines (see the next commit). - Broken by hand: with the data-ttft line skipped, usage-ledger-ttft goes red in every language ("expected 'TTFT 5.5 s', actual ''"). Not tried: the real app's WebKitGTK on Linux, and the Windows webview. Reported-by: unscientific9
This commit is contained in:
@@ -1552,6 +1552,8 @@ body.masked :hover > .acct-eye, body.masked .pq-card:hover .acct-eye, body.maske
|
||||
.led.tight .model, .led.tight .where { max-width: 160px; }
|
||||
.led.tight th, .led.tight td { padding-left: 6px; padding-right: 6px; }
|
||||
.led.tighter .price-reference, .led.tight2 .lc-opt2 { display: none; }
|
||||
/* the first token, under the duration while its own column is left out */
|
||||
.led.tight2 td.duration[data-ttft]::after { content: attr(data-ttft); display: block; margin-top: 1px; font-size: 10.5px; font-weight: 400; color: var(--muted); }
|
||||
/* the account's name is cut at 110px, but its column keeps room for the
|
||||
source badges under it, which don't wrap: capped at 110px the cell cut
|
||||
off the second English one ("Subscription") */
|
||||
|
||||
@@ -222,7 +222,6 @@ magpie.strings({
|
||||
"first token in {ms} on average": "首字平均 {ms}",
|
||||
"no streamed replies timed": "没有可计时的流式回复",
|
||||
"Sent, Effort and the cache are in each row's details": "窗口较窄:发送模型、推理强度和缓存在每行的详情里",
|
||||
"Sent, Effort, the first token and the cache are in each row's details": "窗口较窄:发送模型、推理强度、首字和缓存在每行的详情里",
|
||||
"{n} output tokens in {ms} after the first": "首字后 {ms} 输出 {n} 个 token",
|
||||
"At least: {n} output tokens in {ms}, from the line that asked for it to its last. The session file has no first token, so the wait for it is counted too": "下限:从发出请求的那一行到最后一行,{ms} 输出 {n} 个 token。会话文件没有首字时间,等首字的时间也算在里面",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. The session file has no first text, so reasoning after the first token is counted too": "下限:首字后 {ms} 输出 {n} 个正文 token,{r} 个推理 token 不计。会话文件没有首个正文的时间,首字后的推理时间也算在里面",
|
||||
@@ -463,7 +462,6 @@ magpie.strings({
|
||||
"first token in {ms} on average": "首字平均 {ms}",
|
||||
"no streamed replies timed": "沒有可計時的流式回覆",
|
||||
"Sent, Effort and the cache are in each row's details": "視窗較窄:傳送模型、推理強度和快取在每行的詳情裡",
|
||||
"Sent, Effort, the first token and the cache are in each row's details": "視窗較窄:傳送模型、推理強度、首字和快取在每行的詳情裡",
|
||||
"{n} output tokens in {ms} after the first": "首字後 {ms} 輸出 {n} 個 token",
|
||||
"At least: {n} output tokens in {ms}, from the line that asked for it to its last. The session file has no first token, so the wait for it is counted too": "下限:從發出請求的那一行到最後一行,{ms} 輸出 {n} 個 token。會話檔案沒有首字時間,等首字的時間也算在裡面",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. The session file has no first text, so reasoning after the first token is counted too": "下限:首字後 {ms} 輸出 {n} 個正文 token,{r} 個推理 token 不計。會話檔案沒有首個正文的時間,首字後的推理時間也算在裡面",
|
||||
@@ -704,7 +702,6 @@ magpie.strings({
|
||||
"first token in {ms} on average": "最初のトークンまで平均 {ms}",
|
||||
"no streamed replies timed": "計測できたストリーミング応答なし",
|
||||
"Sent, Effort and the cache are in each row's details": "ウィンドウが狭いため、送信したモデル・推論レベル・キャッシュは各行の詳細にあります",
|
||||
"Sent, Effort, the first token and the cache are in each row's details": "ウィンドウが狭いため、送信したモデル・推論レベル・最初のトークン・キャッシュは各行の詳細にあります",
|
||||
"{n} output tokens in {ms} after the first": "最初のトークン後 {ms} で {n} トークンを出力",
|
||||
"At least: {n} output tokens in {ms}, from the line that asked for it to its last. The session file has no first token, so the wait for it is counted too": "下限:要求した行から最後の行まで {ms} で {n} トークンを出力。セッションファイルには最初のトークンの時刻がないため、それを待つ時間も含まれます",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. The session file has no first text, so reasoning after the first token is counted too": "下限:最初のトークン後 {ms} で回答 {n} トークン(推論 {r} トークンは含めず)。セッションファイルには最初の本文の時刻がないため、最初のトークン後の推論の時間も含まれます",
|
||||
@@ -945,7 +942,6 @@ magpie.strings({
|
||||
"first token in {ms} on average": "erstes Token im Schnitt nach {ms}",
|
||||
"no streamed replies timed": "keine gestreamte Antwort gemessen",
|
||||
"Sent, Effort and the cache are in each row's details": "Schmales Fenster: Gesendet, Effort und Cache stehen in den Details jeder Zeile",
|
||||
"Sent, Effort, the first token and the cache are in each row's details": "Schmales Fenster: Gesendet, Effort, erstes Token und Cache stehen in den Details jeder Zeile",
|
||||
"{n} output tokens in {ms} after the first": "{n} Ausgabe-Token in {ms} nach dem ersten",
|
||||
"At least: {n} output tokens in {ms}, from the line that asked for it to its last. The session file has no first token, so the wait for it is counted too": "Mindestens: {n} Ausgabe-Token in {ms}, von der Zeile, die sie anforderte, bis zu ihrer letzten. Die Sitzungsdatei hat kein erstes Token, also zählt das Warten darauf mit",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. The session file has no first text, so reasoning after the first token is counted too": "Mindestens: {n} Antwort-Token in {ms} nach dem ersten Token, ohne die {r} Reasoning-Token. Die Sitzungsdatei hat keinen ersten Text, also zählt Reasoning nach dem ersten Token mit",
|
||||
|
||||
@@ -2189,8 +2189,8 @@ function ledFit() {
|
||||
// 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), and only
|
||||
// then what follows
|
||||
// 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");
|
||||
if (tight && over()) table.classList.add("tighter");
|
||||
if (!hint) {
|
||||
@@ -2198,7 +2198,8 @@ function ledFit() {
|
||||
hint.id = "ledTight";
|
||||
$("#ledSum").after(hint);
|
||||
}
|
||||
hint.textContent = hint.title = table.classList.contains("tight2") ? t("Sent, Effort, the first token and the cache are in each row's details") : t("Sent, Effort and the cache are in each row's details");
|
||||
// the first token's column, left out, reads under each duration
|
||||
hint.textContent = hint.title = t("Sent, Effort and the cache are in each row's details");
|
||||
hint.hidden = !tight;
|
||||
}
|
||||
|
||||
@@ -2605,8 +2606,13 @@ function renderLedger() {
|
||||
td(r.ttft_ms > 0 ? (timed ? "≈" : "") + ledTook(r.ttft_ms) : "—", "n ttft" + (r.ttft_ms > 0 ? "" : " faint"),
|
||||
r.ttft_ms > 0 ? [t("{n} ms", { n: ledNum(r.ttft_ms) }), timed ? t("About: told from the session file's times, a little more or less than it took") : ""].filter(Boolean).join(" · ") : "");
|
||||
const durationBand = untimed ? "" : r.ms <= 10000 ? "fast" : r.ms <= 30000 ? "slow" : "long";
|
||||
td(untimed ? "—" : (timed ? "≈" : "") + ledTook(r.ms), "n duration " + (untimed ? "faint" : "duration-" + durationBand),
|
||||
const dur = td(untimed ? "—" : (timed ? "≈" : "") + ledTook(r.ms), "n duration " + (untimed ? "faint" : "duration-" + durationBand),
|
||||
[!untimed ? t("{n} ms", { n: ledNum(r.ms) }) : "", !untimed ? t("Duration colors: ≤10 s green · 10–30 s amber · >30 s red") : "", timed && !untimed ? t("About: told from the session file's times, a little more or less than it took") : "", r.ttft_ms ? t("TTFT {ms}", { ms: ledTook(r.ttft_ms) }) : ""].filter(Boolean).join(" · "));
|
||||
// where a narrow window leaves the first token's column out, it reads
|
||||
// under the duration it is part of, small, rather than only in the
|
||||
// details (unscientific9 on Discord); a row with none has no line.
|
||||
// Drawn by app.css from the attribute, out of the cell's text
|
||||
if (r.ttft_ms > 0) dur.dataset.ttft = t("TTFT {ms}", { ms: (timed ? "≈" : "") + ledTook(r.ttft_ms) });
|
||||
// how fast it wrote once it began, as CC Switch's log has it (#860)
|
||||
const v = ledRowSpeed(r), floor = ledFloorSpeed(r), f = ledFloor_(r);
|
||||
const ttft = r.ttft_ms > 0 ? " · " + t("TTFT {ms}", { ms: ledTook(r.ttft_ms) }) : "";
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
// 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, its value still in the details, and the hint
|
||||
// says so. Every language, both engines; no backend, the API is faked.
|
||||
// Sent, Effort and the cache, and then it 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.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -50,11 +52,11 @@ function server(lang) {
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: { head: "TTFT", detail: "First token", duration: "Duration", hint: "Sent, Effort, the first token and the cache are in each row's details" },
|
||||
zh: { head: "首字耗时", detail: "首字耗时", duration: "耗时", hint: "窗口较窄:发送模型、推理强度、首字和缓存在每行的详情里" },
|
||||
"zh-TW": { head: "首字耗時", detail: "首字耗時", duration: "耗時", hint: "視窗較窄:傳送模型、推理強度、首字和快取在每行的詳情裡" },
|
||||
ja: { head: "TTFT", detail: "最初のトークン", duration: "所要時間", hint: "ウィンドウが狭いため、送信したモデル・推論レベル・最初のトークン・キャッシュは各行の詳細にあります" },
|
||||
de: { head: "TTFT", detail: "Erstes Token", duration: "Dauer", hint: "Schmales Fenster: Gesendet, Effort, erstes Token und Cache stehen in den Details jeder Zeile" },
|
||||
en: { head: "TTFT", detail: "First token", duration: "Duration", hint: "Sent, Effort and the cache are in each row's details", under: "TTFT " },
|
||||
zh: { head: "首字耗时", detail: "首字耗时", duration: "耗时", hint: "窗口较窄:发送模型、推理强度和缓存在每行的详情里", under: "首字 " },
|
||||
"zh-TW": { head: "首字耗時", detail: "首字耗時", duration: "耗時", hint: "視窗較窄:傳送模型、推理強度和快取在每行的詳情裡", under: "首字 " },
|
||||
ja: { head: "TTFT", detail: "最初のトークン", duration: "所要時間", hint: "ウィンドウが狭いため、送信したモデル・推論レベル・キャッシュは各行の詳細にあります", under: "TTFT " },
|
||||
de: { head: "TTFT", detail: "Erstes Token", duration: "Dauer", hint: "Schmales Fenster: Gesendet, Effort und Cache stehen in den Details jeder Zeile", under: "TTFT " },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
@@ -105,16 +107,45 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(await cell(3).evaluate((c) => c.classList.contains("faint")), "a dash reads faint, as the others' do");
|
||||
// numbers line up as the duration's do
|
||||
assert.deepEqual(await cell(0).evaluate((c) => getComputedStyle(c).textAlign), await rows.nth(0).locator("td.duration").evaluate((c) => getComputedStyle(c).textAlign));
|
||||
// what reads under each duration: nothing while the column is there
|
||||
const under = (i) => rows.nth(i).locator("td.duration").evaluate((c) => {
|
||||
const a = getComputedStyle(c, "::after");
|
||||
return a.content === "none" || a.content === "normal" || a.display === "none" ? "" : JSON.parse(a.content);
|
||||
});
|
||||
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 narrow window: the column goes, the details keep it, the hint says so
|
||||
await p.setViewportSize({ width: 760, 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);
|
||||
// and says it under the duration, small and faint; a row with none, nothing
|
||||
assert.equal(await under(0), w.under + first);
|
||||
assert.equal(await under(1), w.under + "≈" + (await detail(1)), "about, from the session file's times");
|
||||
assert.equal(await under(2), "", "a failure before any token adds nothing");
|
||||
assert.equal(await under(3), "", "nor a reply not streamed");
|
||||
assert.equal(await rows.nth(0).locator("td.duration").textContent(), durText, "the cell's own text is the duration alone");
|
||||
const look = await rows.nth(0).locator("td.duration").evaluate((c) => {
|
||||
const a = getComputedStyle(c, "::after"), d = getComputedStyle(c);
|
||||
return { small: parseFloat(a.fontSize) < parseFloat(d.fontSize), block: a.display, color: a.color !== d.color };
|
||||
});
|
||||
assert.deepEqual(look, { small: true, block: "block", color: true }, "a small second line, muted");
|
||||
assert(await rows.nth(0).evaluate((r) => r.getBoundingClientRect().height) < 60, "the row stays a row");
|
||||
await reader.click(p, rows.nth(0).locator("td").nth(2));
|
||||
const shown = await p.locator(".led tbody tr.led-detail dt").evaluateAll((dts) => dts.filter((x) => x.offsetParent).map((x) => x.textContent));
|
||||
assert(shown.includes(w.detail), "the details still say it: " + shown.join(", "));
|
||||
assert.equal(await p.locator("#view-usage").evaluate((v) => v.scrollWidth <= v.clientWidth + 1), true, "the page doesn't scroll sideways");
|
||||
await reader.click(p, rows.nth(0).locator("td").nth(2));
|
||||
|
||||
// a phone-narrow window: still under the duration, the page not sideways
|
||||
await p.setViewportSize({ width: 420, height: 800 });
|
||||
await p.waitForTimeout(300);
|
||||
if (await rows.nth(0).locator("td.duration").isVisible()) {
|
||||
assert.equal(await under(0), w.under + first, "still under the duration at 420");
|
||||
assert.equal(await under(3), "");
|
||||
}
|
||||
assert.equal(await p.locator("#view-usage").evaluate((v) => v.scrollWidth <= v.clientWidth + 1), true, "the page doesn't scroll sideways at 420");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ function server(lang) {
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: { speed: "Speed", kpi: "Output speed", fast: "75 tok/s", slow: "10 tok/s", all: "72 tok/s", first: "first token in 600 ms on average · 28 timed replies", sent: "Sent", hint: "Sent, Effort, the first token and the cache are in each row's details" },
|
||||
zh: { speed: "速度", kpi: "输出速度", fast: "75 token/秒", slow: "10 token/秒", all: "72 token/秒", first: "首字平均 600 毫秒 · 28 次计时", sent: "发送模型", hint: "窗口较窄:发送模型、推理强度、首字和缓存在每行的详情里" },
|
||||
en: { speed: "Speed", kpi: "Output speed", fast: "75 tok/s", slow: "10 tok/s", all: "72 tok/s", first: "first token in 600 ms on average · 28 timed replies", sent: "Sent", hint: "Sent, Effort and the cache are in each row's details" },
|
||||
zh: { speed: "速度", kpi: "输出速度", fast: "75 token/秒", slow: "10 token/秒", all: "72 token/秒", first: "首字平均 600 毫秒 · 28 次计时", sent: "发送模型", hint: "窗口较窄:发送模型、推理强度和缓存在每行的详情里" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
@@ -137,7 +137,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal((await cell(7).textContent()).trim(), lang === "en" ? "50 tok/s" : "50 token/秒");
|
||||
|
||||
// the table fits the window; what it leaves out is in the details,
|
||||
// the first token's column (#2522) among them at this width
|
||||
// the first token's column (#2522) under each duration at this width
|
||||
const wrap = p.locator("#ledWrap");
|
||||
assert(await wrap.evaluate((e) => e.scrollWidth <= e.clientWidth + 1), "the table fits: " + JSON.stringify(await wrap.evaluate((e) => [e.scrollWidth, e.clientWidth])));
|
||||
assert.equal(await p.locator("#ledHScroll").isVisible(), false, "no sideways scrollbar");
|
||||
|
||||
Reference in New Issue
Block a user