From 738ede4a70887ffaa0ff152ca87111a175b2c0eb Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 17 Nov 2026 18:29:21 +0800 Subject: [PATCH] agents: Speed beside Model and Effort, with what decides it (Tengs999 on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An agent whose model has a fast mode now shows Speed next to Model and Effort: in the window's Details and in the tray panel's opened row. It reads Usual, Fast (one bolt) or Ultrafast (two), and its menu (the app's openProtoMenu, never a native select) offers Default, Fast and, where the model has it, Ultrafast. It sets the very pick the model's bolt in the picker sets: POST /api/agent-fast {for, ref, fast, ultra}; no new state. A refused post puts the old pick back. What decides the speed is said as the gateway decides it (speedNow): the agent's own pick, else the model's own tier (ModelTiers) -> "Fast · model setting", else for Codex its service tier in Settings -> "Fast · Codex setting", or "As Codex asks" when that tier is unset. The tooltip says it in a sentence, and Default's note in the menu says what Default gives. Words in en, zh, zh-TW, ja and de. speedNow and speedField live in agentspeed.js, imported when such a row draws, and before a fast model's Details first slides open so it measures the line. What is left in app.js (two helpers and three call sites) is 499 bytes; both script budgets go up by that, with the reason written. Run (mote/mica, at this head): - internal/gui/tests/agent-speed.test.cjs: Chromium and WebKit, en zh zh-TW ja de, window 1100px and panel 440px, all green. Broken by hand: dropping the model-tier line in speedNow turns it red ("Fast · model setting" expected, "Usual" actual); the panel's lazy line not taking a .field's place was found by it (0 Speed fields) and fixed. - go test ./internal/gui/: ok (TestCoreScriptBudget included). gofmt -l clean. - GUI files that reach the agent rows and the guards (agent-menu-label, fast-pick, fast-ultra, desktop-tiers, i18n-keys, kimi-subagent-pool and more) at this change and at origin/main 074614077, and agent-details-ready and old-webkit again at this head and origin/main 7c3e68908 (the same tests red with the same numbers, e.g. 823.98 -> 903.92): the same reds on both, each filed: agent-details-ready #6373/#6369, agent-menu-label (WebKit) #6371, aside-native #6212, codex-memories-settings #6372, desktop-tiers #6475, fast-pick/fast-ultra #6201, found-skill-pick-remove #5013/#4097, grip-inset #6293, i18n-keys ", with an image" #6877, old-webkit headerpresets.js #6030 and app.css :has() #5919. Not tried: the whole GUI suite and go test ./... (both boxes were busy with other sessions' suites); the real app, and Linux WebKitGTK. --- internal/gui/assets/agentspeed.js | 84 +++++++++++++ internal/gui/assets/app.css | 8 ++ internal/gui/assets/app.js | 15 ++- internal/gui/assets/i18n.js | 48 +++++++ internal/gui/core_budget_test.go | 4 +- internal/gui/tests/agent-speed.test.cjs | 159 ++++++++++++++++++++++++ internal/gui/tests/old-webkit.test.cjs | 3 +- 7 files changed, 315 insertions(+), 6 deletions(-) create mode 100644 internal/gui/assets/agentspeed.js create mode 100644 internal/gui/tests/agent-speed.test.cjs diff --git a/internal/gui/assets/agentspeed.js b/internal/gui/assets/agentspeed.js new file mode 100644 index 000000000..1887ec804 --- /dev/null +++ b/internal/gui/assets/agentspeed.js @@ -0,0 +1,84 @@ +// Speed beside Model and Effort (Tengs999 on X): a line of an agent's +// opened row, in the tray panel and under the window's New sessions, for a +// model with a fast mode. app.js imports this the first time the line shows +// (speedLazy, and Details before it measures), so it weighs nothing on the +// core. +// speedNow: the speed agent a's requests for the model option o go at, and +// what decides it, as the gateway decides it: the agent's own fast pick +// first (fastPick, which goes over Codex's Standard), else the model's own +// speed (its Model settings, ModelTiers), else, for Codex, its service tier +// in Settings (codexTiered), which an Ultrafast ask also keeps over a Fast +// pick (withFast). from: "agent", "model", "codex", "ask" (as Codex's /fast +// asks) or "" (the usual speed) +function speedNow(a, o) { + const s = prefs || state.settings || {}; + let tier = o.fast ? (o.ultra ? "ultrafast" : "priority") : "", from = o.fast ? "agent" : ""; + const own = !tier && s.modelTiers?.[o.ref]; + if (own === "priority" || own === "ultrafast") tier = own, from = "model"; + if (kindOf(a) === "codex") { + const ct = s.codexServiceTier || ""; + if (ct === "ultrafast" && !o.ultraOk && !tier) tier = "priority", from = "codex"; + else if (ct === "ultrafast" && o.ultraOk && tier !== "ultrafast") tier = "ultrafast", from = "codex"; + else if (ct === "priority" && !tier) tier = "priority", from = "codex"; + else if (!ct && !tier) from = "ask"; + } + return { tier, from }; +} +const SPEED_NAME = { "": "Usual", priority: "Fast", ultrafast: "Ultrafast" }; + +// speedField: the Speed beside Model and Effort (Tengs999 on X), for a +// model with a fast mode: the speed the requests go at now, what decides +// it, and the app's menu that sets the agent's own fast pick, the very +// switch the model's bolt in the picker is (#954, #1954) +window.speedField = function (a) { + const f = a.fields.find((x) => x.key === "model"); + const o = f?.value && optionFor(f, f.value); + if (!o?.fastFor || !o.ref) return null; + const now = speedNow(a, o), name = o.label || o.value, ag = { agent: a.name, model: name }; + const b = el("button", "field ag-speed" + (now.tier ? " set" : "")); + b.type = "button"; + b.dataset.key = "\0speed"; + b.setAttribute("aria-haspopup", "menu"); + const v = el("span", "v" + (now.tier ? "" : " empty")); + if (now.tier) v.append(boltIcon(now.tier === "ultrafast", 11)); + v.append(t(now.from === "ask" ? "As Codex asks" : SPEED_NAME[now.tier])); + if (now.from === "model" || now.from === "codex") v.append(el("span", "ag-speed-by", " · " + t(now.from === "model" ? "model setting" : "Codex setting"))); + b.append(el("span", "k", t("Speed")), v, el("span", "chev", svg(CHEV, 11, 1.7))); + const tierName = t(SPEED_NAME[now.tier]); + b.title = t("{label}: {value}", { label: t("Speed"), value: now.from === "ask" ? t("As Codex asks") + " (" + t("/fast in Codex") + ")" : tierName }) + + (now.from === "model" ? "\n" + t("{model}'s own speed, in its Model settings, sends it {tier} for every agent with no pick of its own", { ...ag, tier: tierName }) + : now.from === "codex" ? "\n" + t("Codex's service tier in Settings sends every Codex request {tier}, over this pick", { tier: tierName }) + : ""); + b.setAttribute("aria-label", b.title); + b.onclick = (ev) => { + ev.stopPropagation(); + if (b.classList.contains("open")) return closeProtoMenu(); + // the default as the gateway goes on without a pick of the agent's own + const bare = speedNow(a, { ...o, fast: false, ultra: false }); + const dflt = bare.from === "model" ? t("{tier}, as the model is set for every agent", { tier: t(SPEED_NAME[bare.tier]) }) + : bare.from === "codex" ? t("{tier}, as Codex's service tier is set in Settings", { tier: t(SPEED_NAME[bare.tier]) }) + : bare.from === "ask" ? t("/fast in Codex") : t("the usual speed"); + const opts = [ + { v: "", name: "Default", note: dflt }, + { v: "priority", name: "Fast", note: o.ownFast ? "asked of your provider, where it serves it" : "quicker, at a higher price" }, + ...(o.ultraOk ? [{ v: "ultrafast", name: "Ultrafast", note: "where the account offers it, Fast where it doesn't" }] : []), + ]; + const cur = o.fast ? (o.ultra ? "ultrafast" : "priority") : ""; + openProtoMenu(b, opts, cur, async (v) => { + if (v === cur) return; + const was = { fast: !!o.fast, ultra: !!(o.fast && o.ultra) }; + setFast(o, !!v, v === "ultrafast"); + renderAgents(); + try { + await api("agent-fast", { for: o.fastFor, ref: o.ref, fast: !!v, ...(v === "ultrafast" ? { ultra: true } : {}) }); + status(!v && bare.tier ? t("{label}: {value}", { label: t("Speed for {agent}", ag), value: dflt }) + : t(v === "ultrafast" ? "{model} is sent Ultrafast for {agent}" : v ? "{model} is sent fast for {agent}" : "{model} is sent at the usual speed for {agent}", ag), "ok"); + } catch (e) { + setFast(o, was.fast, was.ultra); + renderAgents(); + statusErr(e); + } + }, t("Speed for {agent}", ag), "", "left"); + }; + return b; +}; diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 3c22075d3..314b7b8fc 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -5650,3 +5650,11 @@ body.linux .action-confirm::backdrop { -webkit-backdrop-filter: none; backdrop-f .sync-preview .sync-item { display: flex; justify-content: space-between; gap: 12px; min-width: 0; } .sync-preview .sync-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .sync-preview .sync-item .sub, .sync-preview .sync-items > .sub, .sync-preview .lib-confirm.sub { color: var(--muted); } + +/* Speed beside Model and Effort (Tengs999 on X): the bolt and what decides it */ +.field.ag-speed .v { display: inline-flex; align-items: center; gap: 3px; } +.field.ag-speed .v svg, .field.ag-speed .v .bolts { flex: none; color: var(--accent); } +.field.ag-speed .v path { fill: currentColor; } +.field.ag-speed .v .bolts { display: inline-flex; } +.field.ag-speed .v .bolts svg + svg { margin-left: -5px; } +.field.ag-speed .ag-speed-by { color: var(--faint); font-weight: 400; white-space: pre; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index a3c467a00..c9c858c84 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -562,6 +562,8 @@ function renderAgents() { const launchOnly = !!a.launch && !a.fields.length && !a.import; if (a.launch && !launchOnly) extras.append(launchButton(a)); // the panel's settings open in a sheet (connectPanel) + // the speed its model goes at, a line of the opened row after Effort + if (mode === "panel") fields.append(speedLazy(a)); if (mode === "panel" && agentPrefsOf(a)) fields.append(agentPrefsButton(a)); if (extras.childNodes.length) fields.append(extras); // an app taking magpie by a link (Cindy): its row opens it @@ -1494,13 +1496,13 @@ function expandLink(a) { const own = want && agentPrefsOf(a); const compact = own && own.includes("fullContextRow") && !window.agentCompactFill; // and Kimi Code's Subagents line (kimisub.js) is there to measure - const kim = want && kimiSub(a) && !window.kimiSubLine; + const kim = want && kimiSub(a) && !window.kimiSubLine, spd = want && speedOf(a) && !window.speedField; // sheet measures once: its settings are read first (#5360, chiperman) - if ((own && (!prefs || compact)) || kim) { + if ((own && (!prefs || compact)) || kim || spd) { const label = [...b.childNodes]; b.disabled = true; saving(b, t("Loading…")); - try { await Promise.all([own && !prefs && loadSettings(), compact && import("./agentcompact.js"), kim && import("./kimisub.js")]); } + try { await Promise.all([own && !prefs && loadSettings(), compact && import("./agentcompact.js"), kim && import("./kimisub.js"), spd && import("./agentspeed.js")]); } catch (e) { if (request === agentExpandRequest && b.isConnected) statusErr(e); return; } finally { b.disabled = false; doneSaving(b); b.replaceChildren(...label); } if (request !== agentExpandRequest || !b.isConnected || view !== "agents") return; @@ -1609,6 +1611,8 @@ function connectRow(a, row, who, { fields, extras, fieldBtn, sw, kind }) { } else row.append(el("span", "ag-cant", t("Can't connect"))); if (kind === "ok" && a.wired && agentExpanded === a.id) { row.classList.add("expanded"); + // the speed its model goes at, beside Effort under New sessions + fields.append(speedLazy(a)); row.append(connectPanel(a, { fields: fields.querySelector(".field") ? fields : null, extras, fieldBtn })); } } @@ -5531,6 +5535,11 @@ function fastToggle(o) { }; return b; } +// speedLazy: the Speed beside Model and Effort (agentspeed.js), for an +// agent whose model has a fast mode; Details imports it before it measures +const speedOf = (a, f = a.fields.find((f) => f.key == "model")) => f && optionFor(f, f.value)?.fastFor; +const speedLazy = (a, at = el("span", "field")) => !speedOf(a) ? "" : window.speedField ? speedField(a) || "" : (at.hidden = 1, import("./agentspeed.js").then(() => at.replaceWith(speedField(a) || ""), () => {}), at); + // boltIcon: Fast's bolt, or Ultrafast's two function boltIcon(ultra, size) { if (!ultra) return svg(BOLT, size, 1.4); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 36f4d2076..13db5daab 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -3599,6 +3599,18 @@ const I18N = { "{model} is sent Ultrafast for {agent}": "{agent} 用 {model} 时走极速", "Ultrafast": "极速", "{model} is sent at the usual speed for {agent}": "{agent} 用 {model} 时走标准速度", + "Usual": "标准", + "model setting": "模型设置", + "Codex setting": "Codex 设置", + "{model}'s own speed, in its Model settings, sends it {tier} for every agent with no pick of its own": "{model} 在模型设置里设了速度:所有没单独设置的 Agent 都走{tier}", + "Codex's service tier in Settings sends every Codex request {tier}, over this pick": "设置里的 Codex 服务等级让 Codex 的每个请求都走{tier},优先于这里的选择", + "{tier}, as the model is set for every agent": "{tier},按模型对所有 Agent 的设置", + "{tier}, as Codex's service tier is set in Settings": "{tier},按设置里的 Codex 服务等级", + "the usual speed": "标准速度", + "asked of your provider, where it serves it": "向你的服务商请求,服务商支持时生效", + "quicker, at a higher price": "更快,价格更高", + "where the account offers it, Fast where it doesn't": "账号支持时走极速,不支持则走快速", + "Speed for {agent}": "{agent} 的速度", "Add a provider, or sign in to Codex or Copilot; their models show up here for every agent.": "添加供应商,或登录 Codex / Copilot;其模型会列在这里,供所有 Agent 使用。", "Use this model in the snippets": "在示例中使用此模型", "Recent calls": "最近调用", @@ -8963,6 +8975,18 @@ const I18N = { "{model} is sent Ultrafast for {agent}": "{agent} 用 {model} 時走極速", "Ultrafast": "極速", "{model} is sent at the usual speed for {agent}": "{agent} 用 {model} 時走標準速度", + "Usual": "標準", + "model setting": "模型設定", + "Codex setting": "Codex 設定", + "{model}'s own speed, in its Model settings, sends it {tier} for every agent with no pick of its own": "{model} 在模型設定裡設了速度:所有沒單獨設定的 Agent 都走{tier}", + "Codex's service tier in Settings sends every Codex request {tier}, over this pick": "設定裡的 Codex 服務等級讓 Codex 的每個請求都走{tier},優先於這裡的選擇", + "{tier}, as the model is set for every agent": "{tier},依模型對所有 Agent 的設定", + "{tier}, as Codex's service tier is set in Settings": "{tier},依設定裡的 Codex 服務等級", + "the usual speed": "標準速度", + "asked of your provider, where it serves it": "向你的服務商請求,服務商支援時生效", + "quicker, at a higher price": "更快,價格更高", + "where the account offers it, Fast where it doesn't": "帳號支援時走極速,不支援則走快速", + "Speed for {agent}": "{agent} 的速度", "Add a provider, or sign in to Codex or Copilot; their models show up here for every agent.": "新增供應商,或登入 Codex / Copilot;其模型會列在這裡,供所有 Agent 使用。", "Use this model in the snippets": "在範例中使用此模型", "Recent calls": "最近呼叫", @@ -14328,6 +14352,18 @@ const I18N = { "{model} is sent Ultrafast for {agent}": "{agent} の {model} は超高速で送ります", "Ultrafast": "超高速", "{model} is sent at the usual speed for {agent}": "{agent} の {model} は標準速度で送ります", + "Usual": "標準", + "model setting": "モデル設定", + "Codex setting": "Codex 設定", + "{model}'s own speed, in its Model settings, sends it {tier} for every agent with no pick of its own": "{model} はモデル設定で速度が決められています:個別の指定がないエージェントはすべて{tier}で送ります", + "Codex's service tier in Settings sends every Codex request {tier}, over this pick": "設定の Codex サービスティアにより、Codex のリクエストはすべて{tier}で送ります(ここの選択より優先)", + "{tier}, as the model is set for every agent": "{tier}(モデルの全エージェント向け設定)", + "{tier}, as Codex's service tier is set in Settings": "{tier}(設定の Codex サービスティア)", + "the usual speed": "標準速度", + "asked of your provider, where it serves it": "プロバイダーに求めます(対応していれば有効)", + "quicker, at a higher price": "速く、料金は高め", + "where the account offers it, Fast where it doesn't": "アカウントが対応していれば超高速、なければ高速", + "Speed for {agent}": "{agent} の速度", "Add a provider, or sign in to Codex or Copilot; their models show up here for every agent.": "プロバイダを追加するか、Codex または Copilot にサインインしてください。そのモデルがここに表示され、すべてのエージェントで使えます。", "Use this model in the snippets": "このモデルをスニペットで使う", "Recent calls": "最近の呼び出し", @@ -19702,6 +19738,18 @@ const I18N = { "{model} is sent Ultrafast for {agent}": "{model} geht für {agent} als Ultrafast", "Ultrafast": "Ultrafast", "{model} is sent at the usual speed for {agent}": "{model} geht für {agent} mit normaler Geschwindigkeit", + "Usual": "Normal", + "model setting": "Modelleinstellung", + "Codex setting": "Codex-Einstellung", + "{model}'s own speed, in its Model settings, sends it {tier} for every agent with no pick of its own": "{model} hat in seinen Modelleinstellungen ein eigenes Tempo: {tier} für jeden Agenten ohne eigene Wahl", + "Codex's service tier in Settings sends every Codex request {tier}, over this pick": "Codex' Service-Tier in den Einstellungen schickt jede Codex-Anfrage {tier}, über diese Wahl hinweg", + "{tier}, as the model is set for every agent": "{tier}, wie das Modell für alle Agenten eingestellt ist", + "{tier}, as Codex's service tier is set in Settings": "{tier}, wie Codex' Service-Tier in den Einstellungen steht", + "the usual speed": "normales Tempo", + "asked of your provider, where it serves it": "beim eigenen Anbieter angefragt, wo er es anbietet", + "quicker, at a higher price": "schneller, zu einem höheren Preis", + "where the account offers it, Fast where it doesn't": "Ultrafast, wo das Konto es anbietet, sonst Schnell", + "Speed for {agent}": "Tempo für {agent}", "Add a provider, or sign in to Codex or Copilot; their models show up here for every agent.": "Fügen Sie einen Anbieter hinzu oder melden Sie sich bei Codex oder Copilot an; deren Modelle erscheinen hier für jeden Agenten.", "Use this model in the snippets": "Dieses Modell in den Snippets verwenden", "Recent calls": "Letzte Aufrufe", diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 21680f9a0..16475a431 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -17,8 +17,8 @@ import ( // never what pays for a change (#5918); the history of each number is in // `git log -L` of this file. const ( - appScriptBudget = 1_089_123 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to - coreScriptBudget = 1_273_402 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to + appScriptBudget = 1_089_622 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to + coreScriptBudget = 1_273_901 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to ) // codeBytes is how many bytes of b are code: its blank lines, its lines diff --git a/internal/gui/tests/agent-speed.test.cjs b/internal/gui/tests/agent-speed.test.cjs new file mode 100644 index 000000000..59b795e33 --- /dev/null +++ b/internal/gui/tests/agent-speed.test.cjs @@ -0,0 +1,159 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Speed beside Model and Effort (Tengs999 on X): an agent whose model has a +// fast mode has a Speed line in its opened row, in the tray panel and under +// the window's New sessions. It says the speed the requests go at now and +// what decides it: the agent's own fast pick, else the model's own speed +// (its Model settings), else for Codex its service tier in Settings, or as +// Codex's /fast asks. Its menu is the app's, and sets the agent's own fast +// pick through /api/agent-fast, the switch the model's bolt in the picker +// is; a refusal puts it back. A model with no fast mode has no Speed. Window +// and 440px tray panel, en zh zh-TW ja de, Chromium and WebKit. +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"); + +function fixtures(c) { + const options = [ + { value: "magpie/codex/gpt-5.5", ref: "codex/gpt-5.5", label: "GPT-5.5", group: "ChatGPT", fastFor: c.agent, fast: !!c.pick, ultra: c.pick === "ultrafast", ultraOk: true }, + { value: "magpie/zai/glm-5", ref: "zai/glm-5", label: "GLM-5", group: "Z.ai" }, + ]; + const effort = { key: "effort", label: "effort", value: "high", options: ["low", "medium", "high"].map((v) => ({ value: v, label: v })) }; + const name = c.agent === "codex" ? "Codex" : "OpenCode"; + return [{ id: c.agent, name, path: "/test/" + c.agent, wired: true, fields: [{ key: "model", label: "model", value: c.model || "magpie/codex/gpt-5.5", options }, effort] }]; +} + +function server(lang, c, posts, refuse) { + const agents = fixtures(c); + const settings = { lang, theme: "light", modelTiers: c.modelTier ? { "codex/gpt-5.5": c.modelTier } : undefined, codexServiceTier: c.codexTier || "" }; + return async (route) => { + const req = route.request(); + const url = new URL(req.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:true};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (req.method() === "POST" && url.pathname.startsWith("/api/") && !url.pathname.startsWith("/api/window/")) { + if (url.pathname === "/api/agent-fast") { + posts.push(req.postDataJSON()); + if (refuse()) return route.fulfill({ status: 500, contentType: "text/plain", body: "no fast mode" }); + return json({ fast: req.postDataJSON().fast }); + } + return json({}); + } + if (url.pathname === "/api/state") return json({ agents, profiles: [], settings }); + if (url.pathname === "/api/settings") return json(settings); + if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } }); + if (url.pathname === "/api/usage/quotas") return json([]); + if (url.pathname === "/api/groups") return json({ groups: [] }); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false }); + 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 said = { + en: { usual: "Usual", fast: "Fast", ultra: "Ultrafast", ask: "As Codex asks", model: "model setting", codex: "Codex setting", dflt: "Default" }, + zh: { usual: "标准", fast: "快速", ultra: "极速", ask: "按 Codex 的请求", model: "模型设置", codex: "Codex 设置", dflt: "默认" }, + "zh-TW": { usual: "標準", fast: "快速", ultra: "極速", ask: "依 Codex 的請求", model: "模型設定", codex: "Codex 設定", dflt: "預設" }, + ja: { usual: "標準", fast: "高速", ultra: "超高速", ask: "Codex の指定どおり", model: "モデル設定", codex: "Codex 設定", dflt: "デフォルト" }, + de: { usual: "Normal", fast: "Schnell", ultra: "Ultrafast", ask: "Wie Codex es anfragt", model: "Modelleinstellung", codex: "Codex-Einstellung", dflt: "Standard" }, +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": Speed beside Model and Effort", async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const errors = []; + t.after(() => browser.close()); + for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const panel of [false, true]) { + await t.test(`${lang} ${panel ? "tray panel 440px" : "window"}`, async () => { + const w = said[lang]; + const open = async (c, posts = [], refuse = () => false) => { + const page = await (await browser.newContext({ viewport: panel ? { width: 440, height: 640 } : { width: 1100, height: 760 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang, c, posts, refuse)); + await page.goto("http://magpie.test/" + (panel ? "?mode=panel" : "?view=agents")); + const row = `.row.agent[data-id="${c.agent}"]`; + await page.locator(row).waitFor(); + if (panel) await page.locator(`${row} .ag-sum`).click(); + else await page.locator(`${row} .ag-link`).click(); + await page.locator(`${row} ${panel ? ".ag-open" : ".ag-exp"} .field[data-key="effort"], ${row} .ag-open .effort-control`).first().waitFor(); + await page.waitForTimeout(400); + return { page, speed: page.locator(`${row} .field.ag-speed`) }; + }; + const value = (speed) => speed.locator(".v").evaluate((v) => v.textContent.trim()); + + // the agent's own pick: off, then Fast from the app's menu + { + const posts = []; + let refusing = false; + const { page, speed } = await open({ agent: "codex", codexTier: "default" }, posts, () => refusing); + assert.equal(await speed.count(), 1, "a model with a fast mode has Speed"); + assert(await speed.isVisible()); + assert.equal(await value(speed), w.usual); + assert.equal(await speed.locator(".bolts, .v > svg").count(), 0); + // it sits with Model and Effort, inside its row's width + const fits = await speed.evaluate((b) => { const r = b.getBoundingClientRect(), p = b.closest(".row").getBoundingClientRect(); return r.width > 0 && r.left >= p.left - 0.5 && r.right <= p.right + 0.5; }); + assert(fits, "Speed fits in its row"); + await speed.click(); + const menu = page.locator(".proto-menu"); + await menu.waitFor(); + const names = await menu.locator(".pm-name").allTextContents(); + assert.deepEqual(names, [w.dflt, w.fast, w.ultra]); + await menu.locator(".pm-item").nth(1).click(); + await page.waitForTimeout(200); + assert.deepEqual(posts, [{ for: "codex", ref: "codex/gpt-5.5", fast: true }]); + assert.equal(await value(speed), w.fast); + assert.equal(await speed.locator(".v > svg").count(), 1, "a bolt for Fast"); + // a refusal puts it back + refusing = true; + await speed.click(); + await menu.locator(".pm-item").nth(2).click(); + await page.waitForTimeout(200); + assert.deepEqual(posts[1], { for: "codex", ref: "codex/gpt-5.5", fast: true, ultra: true }); + assert.equal(await value(speed), w.fast, "refused: still Fast"); + await page.context().close(); + } + // the model's own speed, with no pick of the agent's + { + const { page, speed } = await open({ agent: "opencode", modelTier: "priority" }); + assert.equal(await value(speed), `${w.fast} · ${w.model}`); + assert.match(await speed.getAttribute("title"), /\n/, "the title says what decides it"); + await page.context().close(); + } + // Codex's service tier in Settings over no pick, and as Codex asks + { + const { page, speed } = await open({ agent: "codex", codexTier: "priority" }); + assert.equal(await value(speed), `${w.fast} · ${w.codex}`); + await page.context().close(); + } + { + const { page, speed } = await open({ agent: "codex", codexTier: "" }); + assert.equal(await value(speed), w.ask); + await page.context().close(); + } + // the agent's Ultrafast pick, and Codex's Standard doesn't slow it + { + const { page, speed } = await open({ agent: "codex", codexTier: "default", pick: "ultrafast" }); + assert.equal(await value(speed), w.ultra); + assert.equal(await speed.locator(".v .bolts svg").count(), 2); + await page.context().close(); + } + // a model with no fast mode: no Speed + { + const { page, speed } = await open({ agent: "codex", model: "magpie/zai/glm-5" }); + assert.equal(await speed.count(), 0); + await page.context().close(); + } + }); + } + assert.deepEqual(errors, []); + }); +} diff --git a/internal/gui/tests/old-webkit.test.cjs b/internal/gui/tests/old-webkit.test.cjs index b17d51f70..edc421922 100644 --- a/internal/gui/tests/old-webkit.test.cjs +++ b/internal/gui/tests/old-webkit.test.cjs @@ -181,6 +181,7 @@ test("compat.js is the first of the page's own scripts", async () => { // rotfig.js when a routing's In turn is first shown; // ompadvisor.js when an omp's settings first show; // kimisub.js when a Kimi Code row's Subagents line first shows; + // agentspeed.js when an agent row on a fast model draws its Speed; // claudemagpie.js when Claude Desktop's twin button or Advanced fold first shows; // keyrates.js when a provider with two or more keys opens; // maximages.js when the provider editor draws Max output; @@ -188,7 +189,7 @@ test("compat.js is the first of the page's own scripts", async () => { // navorder.js once a page order is kept, or Settings › Sidebar pages draws; // the checks above // still read them - for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "kimisub.js", "claudemagpie.js", "keyrates.js", "maximages.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js", "navorder.js", "instancename.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); + for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "kimisub.js", "agentspeed.js", "claudemagpie.js", "keyrates.js", "maximages.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js", "navorder.js", "instancename.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); }); test("the styles hold up in Safari 15.0", async () => {