gui: a long Claude Code reply read from its session file shows the least it wrote at (≥98 tok/s), and a short one no longer says it wasn't streamed (Fallmonkey on Discord)
Claude Code's session file has no first token, only when the line that
asked for a reply and its last line were written, so every Claude Code and
Claude Desktop call that didn't go through the gateway showed no speed,
with "Not streamed" though it was streamed. A reply of 1,000 output tokens
or more over a second or more now shows its tokens over that whole time as
a floor (ledFloorSpeed, "≥" in the cell, "At least: …" in its tooltip and
the row's details); the wait for the first token is inside it, so the
speed after the first token is never under it. Gateway rows and timed
session rows are unchanged, and the period's speed counts timed calls only.
Only Claude Code's and Claude Desktop's rows tell one. The contributed
version gave every session-file row a floor; a Codex call in a turn of
several is timed from the last tool output before its token count, and in
a month of real rollouts (4,588 multi-call calls) 2,968 were timed from the
output of a tool that same call asked for, written before its count, so
the window begins inside the call and a floor from it could read high.
Those rows keep "—" with "The session file has no first token". OpenCode's
created→completed time isn't checked against real sessions, so it tells
none either.
Checked against the shape of real Claude Code files (read-only, 30 days,
~198k messages, 2,011 files incl. subagents): block lines are stamped at
each block's end (single-line 1,000+ token text replies read a median 110
tok/s, not the thousands a start stamp would give); no sidechain lines in
main files; no assistant line out of clock order; a message's later lines
keep the time its first was asked (Began), so the 15,779 tool results
written between one message's blocks don't shorten it. Floors shown: 23,518,
p50 102, p99 141, max 156 tok/s for claude-opus-5-5.
Run: usage-session-speed.test.cjs (now also a Codex multi-call row, a
Claude Desktop row, and a 560px window) in Chromium and WebKit, en and zh;
red with the agent check taken out ('≥500 tok/s' !== '—'). The related
suites (gui-de/ja/zh-tw, i18n-keys, ledger-*, usage-ledger*, usage-speed,
reasoning-speed, routing-burst-speed, usage-ttft-rounding,
usage-computers): 146/146 in both engines. go test -tags nogui ./...,
gofmt, and go vet for darwin/linux/windows on internal/gui.
Co-authored-by: Ted Li <tl2493@columbia.edu>
This commit is contained in:
@@ -294,6 +294,24 @@ write, and that time isn't seen. History is read the same way, as it keeps the
|
||||
reasoning, the first text and the flow; a record from before the flow was kept
|
||||
is told by its reasoning's pace alone.
|
||||
|
||||
A call read from an agent's session file rather than seen by the gateway has
|
||||
no first token: Claude Code's file has only when the line that asked for a
|
||||
reply and the reply's last line were written. Such a row on the Requests tab
|
||||
shows the least its reply wrote at instead (`≥98 tok/s`): its output tokens
|
||||
over that whole time, the wait for the first token in it, so the speed after
|
||||
the first token is never under it. Only a reply of 1,000 tokens or more
|
||||
written over a second or more shows one; a shorter reply's wait is too much
|
||||
of its time to tell anything. Only Claude Code's and Claude Desktop's rows
|
||||
show one: their line that asked for a reply is written before it is sent. A
|
||||
Codex call in a turn of several is timed from the last tool output before
|
||||
its token count, and Codex can write the output of a tool that call itself
|
||||
asked for before the count, so its time can begin inside the call and a
|
||||
floor from it could read high; it shows none.
|
||||
A call whose session file timed it (a Codex
|
||||
turn of one call) shows its own speed as before. The floor is the row's
|
||||
alone: the period's output speed, the Speed trend and `magpie usage` count
|
||||
timed calls only.
|
||||
|
||||
It lists **accounts** too: each Codex, Claude or other subscription account's
|
||||
tokens and cost, by the account that actually answered — the one that took
|
||||
over after a failover, the one `X-Magpie-Account` pinned. The account is named
|
||||
|
||||
@@ -16196,6 +16196,7 @@ function ledDetail(r, cols) {
|
||||
opt("Effort", r.effort);
|
||||
if (r.cache_write || r.cache_read) opt("Cache", t("{w} written · {r} read", { w: ledNum(r.cache_write || 0), r: ledNum(r.cache_read || 0) }) + cacheTTLs(r, ledNum));
|
||||
if (ledRowSpeed(r)) add("Speed", t("{n} tok/s", { n: ledNum(Math.round(ledRowSpeed(r))) }));
|
||||
else if (ledFloorSpeed(r)) add("Speed", "≥" + t("{n} tok/s", { n: ledNum(Math.round(ledFloorSpeed(r))) }));
|
||||
add("Request ID", r.rid);
|
||||
add("Endpoint", r.ep);
|
||||
const protos = ledProtos(r);
|
||||
@@ -17006,6 +17007,28 @@ const ledDecode = (r) => {
|
||||
};
|
||||
// how fast a reply wrote, in tokens a second: 0 when it can't tell
|
||||
const ledRowSpeed = (r) => { const d = ledDecode(r); return d ? d.n / (d.w / 1000) : 0; };
|
||||
// the least a reply read from a session file wrote at, in tokens a second:
|
||||
// the file has no first token, only when the line that asked for it and its
|
||||
// last line were written (Claude Code's are each block's end), so its tokens
|
||||
// over that whole time, the wait for the first one in it, are a floor the
|
||||
// speed after the first token can't be under. Against Claude Code's own
|
||||
// stream it read 2–5% under for a reply of 1,400 tokens or more, 11–33% for
|
||||
// a shorter one or one asked with a tool's result, so only a reply of 1,000
|
||||
// or more is told. 0 when it tells none, and a call magpie timed tells its
|
||||
// own (ledDecode). Only the row's: the period's speed counts timed calls.
|
||||
// Claude Code's and Claude Desktop's files only: a call's time is from the
|
||||
// line that asked it, which is written before it is sent. Codex's call in a
|
||||
// turn of several is timed from the last tool output before its token count,
|
||||
// and Codex writes the output of a tool the call itself asked for before
|
||||
// that count (2,968 of 4,588 calls in a month of real rollouts), so its time
|
||||
// can begin inside the call and its tokens over it read high. OpenCode's
|
||||
// isn't checked against real sessions. They tell none.
|
||||
const LED_FLOOR_AGENTS = new Set(["claude", "claude-desktop"]);
|
||||
const ledFloorSpeed = (r) => {
|
||||
if (r.source !== "log" || !LED_FLOOR_AGENTS.has(r.agent) || ledFailed_(r) || ledRowSpeed(r)) return 0;
|
||||
if (!(r.out >= 1000 && r.ms >= 1000 && r.out * 1000 <= 10000 * r.ms)) return 0;
|
||||
return r.out / (r.ms / 1000);
|
||||
};
|
||||
|
||||
// the table as wide as the window, when leaving out what the row's details
|
||||
// say anyway makes it so: else it scrolls sideways (#799)
|
||||
@@ -17271,11 +17294,12 @@ function renderLedger() {
|
||||
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(" · "));
|
||||
// how fast it wrote once it began, as CC Switch's log has it (#860)
|
||||
const v = ledRowSpeed(r);
|
||||
td(v ? t("{n} tok/s", { n: ledNum(Math.round(v)) }) : "—", "n speed" + (v ? "" : " faint"),
|
||||
const v = ledRowSpeed(r), floor = ledFloorSpeed(r);
|
||||
td(v ? t("{n} tok/s", { n: ledNum(Math.round(v)) }) : floor ? "≥" + t("{n} tok/s", { n: ledNum(Math.round(floor)) }) : "—", "n speed" + (v || floor ? "" : " faint"),
|
||||
v ? (r.reasoning > 0 ? t("{n} answer tokens in {ms} after the first text, the {r} reasoning tokens before it left out", { n: ledNum(ledDecode(r).n), ms: ledTook(ledDecode(r).w), r: ledNum(r.reasoning) })
|
||||
: t("{n} output tokens in {ms} after the first", { n: ledNum(r.out), ms: ledTook(r.ms - r.ttft_ms) })) + " · " + t("TTFT {ms}", { ms: ledTook(r.ttft_ms) })
|
||||
: r.ttft_ms || untimed || ledFailed_(r) ? "" : t("Not streamed: no first token to time a speed from"));
|
||||
: floor ? t("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", { n: ledNum(r.out), ms: ledTook(r.ms) })
|
||||
: r.ttft_ms || untimed || ledFailed_(r) ? "" : timed ? t("The session file has no first token to time a speed from") : t("Not streamed: no first token to time a speed from"));
|
||||
const st = el("span", "st");
|
||||
// a status when the gateway logged the call; a session file has none,
|
||||
// and says only whether it went well
|
||||
|
||||
@@ -3443,6 +3443,8 @@ const I18N = {
|
||||
"No streamed replies timed in this period": "这段时间没有可计时的流式回复",
|
||||
"Sent, Effort 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。会话文件没有首字时间,等首字的时间也算在里面",
|
||||
"The session file has no first token to time a speed from": "会话文件没有首字时间,算不出速度",
|
||||
"A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it": "有推理的回复只算正文部分,从首个正文起计:推理在流里出现前就已写完",
|
||||
"{n} answer tokens in {ms} after the first text, the {r} reasoning tokens before it left out": "首个正文后 {ms} 输出 {n} 个正文 token,之前的 {r} 个推理 token 不计",
|
||||
"Not streamed: no first token to time a speed from": "非流式:没有首字时间,算不出速度",
|
||||
@@ -7629,6 +7631,8 @@ const I18N = {
|
||||
"No streamed replies timed in this period": "這段時間沒有可計時的流式回覆",
|
||||
"Sent, Effort 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。會話檔案沒有首字時間,等首字的時間也算在裡面",
|
||||
"The session file has no first token to time a speed from": "會話檔案沒有首字時間,算不出速度",
|
||||
"A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it": "有推理的回覆只算正文部分,從首個正文起計:推理在流裡出現前就已寫完",
|
||||
"{n} answer tokens in {ms} after the first text, the {r} reasoning tokens before it left out": "首個正文後 {ms} 輸出 {n} 個正文 token,之前的 {r} 個推理 token 不計",
|
||||
"Not streamed: no first token to time a speed from": "非流式:沒有首字時間,算不出速度",
|
||||
@@ -11829,6 +11833,8 @@ const I18N = {
|
||||
"No streamed replies timed in this period": "この期間に計測できたストリーミング応答はありません",
|
||||
"Sent, Effort 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} トークンを出力。セッションファイルには最初のトークンの時刻がないため、それを待つ時間も含まれます",
|
||||
"The session file has no first token to time a speed from": "セッションファイルには、速度を計れる最初のトークンの時刻がありません",
|
||||
"A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it": "推論した応答は、最初の本文からの回答部分のみ数えます。推論はストリームに出る前に書き終わっています",
|
||||
"{n} answer tokens in {ms} after the first text, the {r} reasoning tokens before it left out": "最初の本文後 {ms} で回答 {n} トークン(その前の推論 {r} トークンは含めず)",
|
||||
"Not streamed: no first token to time a speed from": "ストリーミングではないため、速度を計れる最初のトークンの時刻がありません",
|
||||
@@ -16032,6 +16038,8 @@ const I18N = {
|
||||
"No streamed replies timed in this period": "In diesem Zeitraum wurde 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",
|
||||
"{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",
|
||||
"The session file has no first token to time a speed from": "Die Sitzungsdatei hat kein erstes Token, an dem sich ein Tempo messen ließe",
|
||||
"A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it": "Eine Antwort mit Reasoning zählt nur ihre Antwort ab dem ersten Text: Das Reasoning entstand, bevor der Stream es zeigte",
|
||||
"{n} answer tokens in {ms} after the first text, the {r} reasoning tokens before it left out": "{n} Antwort-Token in {ms} nach dem ersten Text, ohne die {r} Reasoning-Token davor",
|
||||
"Not streamed: no first token to time a speed from": "Nicht gestreamt: kein erstes Token, an dem sich ein Tempo messen ließe",
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The speed of a call read from a session file, on the Usage page's Requests
|
||||
// tab. Claude Code's session file has no first token, only when the line that
|
||||
// asked for a reply and the reply's last line were written, so its rows had
|
||||
// no speed at all, and each said "Not streamed", though the replies were
|
||||
// streamed. A long one now tells the least it wrote at, its tokens over that
|
||||
// whole time ("≥98 tok/s"); a short one says the file has no first token; a
|
||||
// call magpie timed keeps its own speed. Only Claude Code's and Claude
|
||||
// Desktop's files tell one: a Codex call in a turn of several is timed from
|
||||
// a tool output Codex can write before that call's own token count, so it tells
|
||||
// none. A narrow window shows it as a wide one does. The rows are real ledger rows read
|
||||
// from Claude Code's session files of claude-opus-5-5 replies; the first,
|
||||
// 2,558 tokens in 25,987 ms, measured 100.6 tok/s on Claude Code's own stream
|
||||
// (--include-partial-messages) from its first thinking event to its end.
|
||||
// English and Chinese; no backend, the API is faked.
|
||||
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 reader = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const now = Date.now();
|
||||
const at = (i) => new Date(now - (i + 1) * 60e3).toISOString();
|
||||
|
||||
const LOG = {
|
||||
agent: "claude", provider: "session-unknown", model: "claude-opus-5-5", req: "claude-opus-5-5", served: "claude-opus-5-5",
|
||||
in: 2, cache_read: 12380, cache_write: 20122, effort: "medium", status: 0, session: "57956f49-8830-4769-a6c3-93ff87b1fe16",
|
||||
cost: 0, priced: false, source: "log", agentName: "Claude Code", icon: "claudecode-color", providerName: "Local session",
|
||||
};
|
||||
const GATEWAY = {
|
||||
route_id: 900, agent: "claude", agentName: "Claude Code", icon: "claudecode-color", provider: "zai", providerName: "Z.ai Coding Plan",
|
||||
host: "me@example.com", req: "claude-opus-4-1-20250805", model: "glm-fast", served: "glm-fast", in: 1200, cache_read: 0, cache_write: 0,
|
||||
status: 200, rid: "req_900", ep: "/v1/messages", cost: 0.01, priced: true,
|
||||
};
|
||||
const ROWS = [
|
||||
// 0: a long reply from a session file: at least 2558 / 25.987 s
|
||||
{ ...LOG, t: at(0), out: 2558, ms: 25987 },
|
||||
// 1: a short one: its tokens over the wait tell too little
|
||||
{ ...LOG, t: at(1), out: 462, ms: 5340 },
|
||||
// 2: a call magpie timed keeps its own speed: 135 tokens in 1.8 s after its first
|
||||
{ ...GATEWAY, t: at(2), out: 135, ms: 2400, ttft_ms: 600 },
|
||||
// 3: a gateway call not streamed is still told so
|
||||
{ ...GATEWAY, route_id: 901, rid: "req_901", t: at(3), out: 1500, ms: 3000 },
|
||||
// 4: a session file that timed its turn (Codex's, one call) tells its own: 1200 tokens in 8 s
|
||||
{ ...LOG, agent: "codex", agentName: "Codex", icon: "codex-color", model: "gpt-6-astra", t: at(4), out: 1200, ms: 10000, ttft_ms: 2000 },
|
||||
// 5: a failed call tells none
|
||||
{ ...LOG, t: at(5), out: 1500, ms: 9000, err_type: "overloaded_error", err: "Overloaded" },
|
||||
// 6: a long reply in under a second (lines written together) tells none
|
||||
{ ...LOG, t: at(6), out: 5000, ms: 300 },
|
||||
// 7: a Codex call in a turn of several: timed from the tool output before
|
||||
// it, which Codex can write before that call's own token count, so none is told
|
||||
{ ...LOG, agent: "codex", agentName: "Codex", icon: "codex-color", model: "gpt-6-astra", t: at(7), out: 1500, ms: 3000 },
|
||||
// 8: Claude Desktop's Code tab writes Claude Code's file: at least 1500 / 12 s
|
||||
{ ...LOG, agent: "claude-desktop", agentName: "Claude Desktop", icon: "claude-color", t: at(8), out: 1500, ms: 12000 },
|
||||
];
|
||||
|
||||
function ledger(period) {
|
||||
return {
|
||||
period, rows: ROWS, offset: 0, total: ROWS.length, calls: ROWS.length, errors: 1,
|
||||
input: 1, output: 12355, cache_read: 0, cache_write: 0, cost: 0.02, unpriced: 5,
|
||||
// only what magpie timed: 135 tokens in 1.8 s and 1200 in 8 s
|
||||
timed: 2, ttft_ms: 2600, decode_ms: 9800, decode_out: 1335,
|
||||
by: { model: [] }, bucket: "hour", series: [],
|
||||
agents: [{ id: "claude", name: "Claude Code", icon: "claudecode-color" }, { id: "codex", name: "Codex", icon: "codex-color" }, { id: "claude-desktop", name: "Claude Desktop", icon: "claude-color" }],
|
||||
};
|
||||
}
|
||||
|
||||
const STATE = (lang) => ({
|
||||
agents: [
|
||||
{ id: "claude", name: "Claude Code", path: "/t/c.json", icon: "claudecode-color", wired: true, fields: [] },
|
||||
{ id: "codex", name: "Codex", path: "/t/c.toml", icon: "codex-color", wired: true, fields: [] },
|
||||
],
|
||||
profiles: [], settings: { lang, theme: "light" }, fx: { rate: 7.2, at: new Date().toISOString() },
|
||||
});
|
||||
|
||||
function server(lang) {
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(STATE(lang));
|
||||
if (url.pathname === "/api/usage/requests") return json(ledger(url.searchParams.get("period")));
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/usage") return json({ calls: 0, errors: 0, input: 0, output: 0, reasoning: 0, unpriced: 0, cost: 0, bucket: "day", series: [], agents: [], models: [], path: "" });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], models: [], gateway: { running: false } });
|
||||
if (url.pathname === "/api/sessions") return json({ sessions: [], dirs: [] });
|
||||
if (url.pathname === "/api/sessions/stats") return json({ from: "", to: "", days: [], agents: {} });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: {
|
||||
speed: "Speed", floor: "≥98 tok/s", desktop: "≥125 tok/s", timed: "75 tok/s", codex: "150 tok/s",
|
||||
floorTip: "At least: 2,558 output tokens in 26 s, 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",
|
||||
noFirst: "The session file has no first token to time a speed from", notStreamed: "Not streamed: no first token to time a speed from",
|
||||
},
|
||||
zh: {
|
||||
speed: "速度", floor: "≥98 token/秒", desktop: "≥125 token/秒", timed: "75 token/秒", codex: "150 token/秒",
|
||||
floorTip: "下限:从发出请求的那一行到最后一行,26 秒 输出 2,558 个 token。会话文件没有首字时间,等首字的时间也算在里面",
|
||||
noFirst: "会话文件没有首字时间,算不出速度", notStreamed: "非流式:没有首字时间,算不出速度",
|
||||
},
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": the speed of a call read from a session file", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
// a wide window, and one narrow enough that the table scrolls sideways
|
||||
for (const [lang, width] of [["en", 1400], ["zh", 1400], ["en", 560], ["zh", 560]]) {
|
||||
const w = L[lang];
|
||||
await t.test(lang + " " + width, async () => {
|
||||
const errors = [];
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||||
const p = await ctx.newPage();
|
||||
p.setDefaultTimeout(5000);
|
||||
p.on("pageerror", (e) => errors.push(e.message));
|
||||
await p.route("**/*", server(lang));
|
||||
await p.goto("http://magpie.test/");
|
||||
await p.locator('[data-view="usage"]').first().click();
|
||||
await p.locator("#usageTab .opt").nth(1).click();
|
||||
await p.locator("#ledWrap .led tbody tr").first().waitFor();
|
||||
|
||||
const heads = await p.locator(".led thead th").evaluateAll((ths) => ths.filter((th) => th.offsetParent).map((th) => th.textContent));
|
||||
assert(heads.includes(w.speed), "a Speed column: " + heads.join(", "));
|
||||
const cell = (i) => p.locator(".led tbody tr.led-row").nth(i).locator("td.speed");
|
||||
const text = async (i) => (await cell(i).textContent()).trim();
|
||||
const tip = (i) => cell(i).getAttribute("title");
|
||||
|
||||
// a long reply from a session file: the least it wrote at, and why
|
||||
assert.equal(await text(0), w.floor);
|
||||
assert.equal(await tip(0), w.floorTip);
|
||||
assert(!(await cell(0).getAttribute("class")).includes("faint"), "a floor isn't faint");
|
||||
// a short one: no speed, and not called "not streamed"
|
||||
assert.equal(await text(1), "—");
|
||||
assert.equal(await tip(1), w.noFirst);
|
||||
// what magpie timed is as it was
|
||||
assert.equal(await text(2), w.timed);
|
||||
assert.equal(await text(3), "—");
|
||||
assert.equal(await tip(3), w.notStreamed);
|
||||
// a session file's own timing wins over the floor
|
||||
assert.equal(await text(4), w.codex);
|
||||
// a failed call, and a reply in under a second, tell none
|
||||
assert.equal(await text(5), "—");
|
||||
assert.equal(await text(6), "—");
|
||||
// a Codex call timed from inside a turn tells none, and isn't called unstreamed
|
||||
assert.equal(await text(7), "—");
|
||||
assert.equal(await tip(7), w.noFirst);
|
||||
// Claude Desktop's file is Claude Code's
|
||||
assert.equal(await text(8), w.desktop);
|
||||
// the floor is read whole, at either width
|
||||
const clipped = await cell(0).evaluate((td) => td.scrollWidth > td.clientWidth + 1);
|
||||
assert(!clipped, "the floor fits its cell");
|
||||
|
||||
// the row's details say it too
|
||||
// the first cell, not the time's link: at a narrow window the row is brought into sight first
|
||||
await reader.click(p, p.locator(".led tbody tr.led-row").first().locator("td").nth(1));
|
||||
const detail = p.locator(".led tbody tr.led-detail").first();
|
||||
await detail.waitFor();
|
||||
const pairs = await detail.locator("dt").evaluateAll((dts) => dts.map((dt) => [dt.textContent, dt.nextElementSibling?.textContent]));
|
||||
assert.deepEqual(pairs.find(([k]) => k === w.speed), [w.speed, w.floor], JSON.stringify(pairs));
|
||||
|
||||
assert.deepEqual(errors, []);
|
||||
await ctx.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user