agents: Speed beside Model and Effort, with what decides it (Tengs999 on X)
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.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
@@ -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; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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, []);
|
||||
});
|
||||
}
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user