gui: an unset Claude Code tier's effort reads "follows session"; a set one says it wins

lightwlh on X: Claude Code's Details shows an effort beside each tier
(Opus, Sonnet, Haiku, Fable) and another under New sessions, and asked
which one wins when they differ. A tier's effort is written into its
model id as <model>:<level> (tierWith in internal/agent/claude.go), and
the gateway asks that model at that level whatever Claude Code asked
(askedAt); the New sessions effort is Claude Code's own (effortLevel /
CLAUDE_CODE_EFFORT_LEVEL), which /effort changes, and reaches only the
tiers with none of their own. The page didn't say so: an unset tier's
effort read "default", like a level of its own.

- An unset tier's effort button reads "follows session" (跟随会话,
  跟隨會話, セッションに従う, wie Sitzung) instead of "default"; its
  title still names the effort Claude Code asks for.
- A set tier's title adds "Used whatever the session's effort or
  /effort is".
- New sessions' effort, while any tier has its own, adds "A tier with an
  effort of its own runs at that one" to its title; both follow a pick
  in the slider at once (the slider's field is a copy, so the check
  reads the picked value).
- No layout change: the same buttons and lines; the subagents' effort
  and the tray panel's tiers' square are unchanged.
- app.js +485 and the core +843 bytes of code, budgets raised with the
  reason: connectPanel and the effort slider draw every agent's Details,
  so there is no page to move it to; the words share one ownSaid.

Run (mote, at this tree rebased on de5fc6700):
- node --test tier-effort, claude-subagent-effort-row, wsl-claude-tiers,
  claude-effort, subagent-effort, panel-effort, agent-tweak-fold,
  i18n-keys, gui-ja, gui-zh-tw, i18n-en-no-cjk: 124 pass 0 fail
  (Chromium and WebKit; tier-effort's narrow 560px case now in all five
  languages, each tier's effort on its model's line, no sideways scroll).
- Broken by hand: tier-effort against origin/main's app.js, 4 of 4 of
  the pick tests red (no "follows session", no wins line).
- go test ./internal/gui: ok (TestCoreScriptBudget red before the raise).
Not run yet: the whole GUI suite (mote and mica each had another
session's full suite running); it runs after the push.
This commit is contained in:
yetone
2026-11-18 16:24:12 +08:00
parent de5fc6700e
commit 534b85bf99
4 changed files with 61 additions and 7 deletions
+19
View File
@@ -2231,6 +2231,7 @@ function connectPanel(a, { fields, fieldBtn }) {
const b = fieldBtn(off ? { ...e, value: "" } : e, "ag-eff");
b.disabled = !!off;
b.title = t("{label}: {value}", { label: t(e.label), value: off ? t("default") : e.value ? effortName(optionFor(e, e.value) || { value: e.value }) : t("the effort Claude Code asks for") }) + (off ? "\n" + t("Set a subagent model first") : "");
if (TIER_EFFORTS.includes(e.label)) tierSaid(b, e.value);
b.setAttribute("aria-label", b.title);
return b;
};
@@ -2321,6 +2322,7 @@ function connectPanel(a, { fields, fieldBtn }) {
for (const b of fields.querySelectorAll(":scope > .field")) {
const f = a.fields.find((x) => x.key === b.dataset.key);
if (f && !b.querySelector(":scope > .k")) b.prepend(el("span", "k", t(f.label)));
if (f?.key === "effort" && kindOf(a) === "claude") tierOwn(a, b);
}
// Cursor Private Inference's are magpie's own (#1003)
kv(t(a.id === "cursor-local" ? "Settings" : "New sessions"), line(fields));
@@ -4195,6 +4197,19 @@ function tierMenu(a) {
const DESKTOP_TIERS_FOOT = "Claude Desktop reads the tiers as it starts: restart it after a change.";
// Which effort a Claude Code tier runs at, said where both are picked
// (@lightwlh on X): unset, the session's (New sessions' effort, or /effort
// in it), so its button reads "follows session"; set, its own, whatever the
// session's is, and the session's effort's title says a tier with its own
// runs at that one. ownSaid puts line s in b's title, or takes it out;
// tierOwn reads f, a tier's effort just picked, as the slider's copy holds
// it, since the agent's own field still has the old value.
const ownSaid = (b, on, s) => b.title = b.title.replace(s = "\n" + t(s), "") + (on ? s : "");
const tierOwn = (a, b, f) => ownSaid(b, a.fields.some((x) => TIER_EFFORTS.includes(x.label) && (x.label === f?.label ? f.value : x.value)), "A tier with an effort of its own runs at that one");
function tierSaid(b, v) {
ownSaid(b, v, "Used whatever the session's effort or /effort is");
if (!v) b.querySelector(".v").textContent = t("follows session");
}
// levelUnset: what a role's level is when none is set
const levelUnset = (a) => ompAgent(a) ? t("the session's thinking level") : t("the effort Claude Code asks for");
@@ -5105,6 +5120,10 @@ function renderEffortPicker() {
// and light follow the level
if ((roleLevel(opened.field.label) || opened.field.label === SUB_EFFORT) && opened.anchor.classList.contains("ag-eff")) {
opened.anchor.title = t("{label}: {value}", { label: t(opened.field.label), value: option.value ? effortName(option) : levelUnset(opened.agent) });
if (TIER_EFFORTS.includes(opened.field.label)) {
tierSaid(opened.anchor, option.value);
for (const b of opened.anchor.closest(".row.agent").querySelectorAll('.field[data-key="effort"]')) tierOwn(opened.agent, b, opened.field);
}
opened.anchor.setAttribute("aria-label", opened.anchor.title);
} else if (roleLevel(opened.field.label)) {
const menu = tierMenu(opened.agent);
+12
View File
@@ -1129,6 +1129,9 @@ const I18N = {
"fable effort": "fable 推理强度",
"the effort Claude Code asks for": "跟随 Claude Code 请求的推理强度",
"Claude Desktop reads the tiers as it starts: restart it after a change.": "Claude Desktop 在启动时读取分档:改动后请重启它。",
"follows session": "跟随会话",
"Used whatever the session's effort or /effort is": "不受会话推理强度和 /effort 影响",
"A tier with an effort of its own runs at that one": "设了自己推理强度的档位按它自己的运行",
"Set a subagent model first": "先设置子代理模型",
"the session's effort, or the subagent model's own default": "跟随会话的推理强度,或子代理模型的默认强度",
"slow": "慢模型",
@@ -6620,6 +6623,9 @@ const I18N = {
"fable effort": "fable 推理強度",
"the effort Claude Code asks for": "跟隨 Claude Code 請求的推理強度",
"Claude Desktop reads the tiers as it starts: restart it after a change.": "Claude Desktop 在啟動時讀取分檔:改動後請重新啟動它。",
"follows session": "跟隨會話",
"Used whatever the session's effort or /effort is": "不受會話推理強度和 /effort 影響",
"A tier with an effort of its own runs at that one": "設了自己推理強度的檔位按它自己的執行",
"Set a subagent model first": "先設定子代理模型",
"the session's effort, or the subagent model's own default": "跟隨會話的推理強度,或子代理模型的預設強度",
"slow": "慢模型",
@@ -12071,6 +12077,9 @@ const I18N = {
"fable effort": "fable の推論レベル",
"the effort Claude Code asks for": "Claude Code が要求する推論レベル",
"Claude Desktop reads the tiers as it starts: restart it after a change.": "Claude Desktop は起動時に階層を読み込みます。変更したら再起動してください。",
"follows session": "セッションに従う",
"Used whatever the session's effort or /effort is": "セッションの推論レベルや /effort に関係なくこのレベルを使います",
"A tier with an effort of its own runs at that one": "独自の推論レベルを持つ階層はそのレベルで動きます",
"Set a subagent model first": "先にサブエージェントのモデルを設定してください",
"the session's effort, or the subagent model's own default": "セッションの推論レベル、またはサブエージェントのモデル自身のデフォルト",
"slow": "低速",
@@ -17542,6 +17551,9 @@ const I18N = {
"fable effort": "Reasoning-Effort fable",
"the effort Claude Code asks for": "der von Claude Code angeforderte Reasoning-Effort",
"Claude Desktop reads the tiers as it starts: restart it after a change.": "Claude Desktop liest die Stufen beim Start: nach einer Änderung neu starten.",
"follows session": "wie Sitzung",
"Used whatever the session's effort or /effort is": "Gilt unabhängig vom Reasoning-Effort der Sitzung und von /effort",
"A tier with an effort of its own runs at that one": "Eine Stufe mit eigenem Reasoning-Effort läuft mit diesem",
"Set a subagent model first": "Lege zuerst ein Modell für die Subagenten fest",
"the session's effort, or the subagent model's own default": "der Reasoning-Effort der Sitzung oder der Standard des Subagent-Modells",
"slow": "langsam",
File diff suppressed because one or more lines are too long
+28 -5
View File
@@ -1,8 +1,10 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Claude Code's tiers can each run at an effort of their own (#536), as its
// subagents can. In the window, connected, a tier's effort sits beside its
// model in the opened row's Tiers: unset it says the tier runs at the effort
// Claude Code asks for, a click opens the effort slider with Default as its
// model in the opened row's Tiers: unset it reads "follows session" and its
// title says the tier runs at the effort Claude Code asks for; set, its title
// says the session's effort and /effort don't change it, and New sessions'
// effort says a tier with its own runs at that one (@lightwlh on X). A click opens the effort slider with Default as its
// first stop, and a level picked is posted and named in its title. (The
// tray panel keeps them as entries under the models in the tiers' square.)
// The subagents' effort is on the Subagents row, as a tier's is. Before
@@ -62,10 +64,12 @@ function server(lang, sets) {
const W = {
en: {
asks: "the effort Claude Code asks for", effort: (tier) => tier + " effort", title: "haiku effort", def: "default", low: "low", high: "high",
follows: "follows session", wins: "Used whatever the session's effort or /effort is", own: "A tier with an effort of its own runs at that one",
sep: (l, v) => `${l}: ${v}`,
},
zh: {
asks: "跟随 Claude Code 请求的推理强度", effort: (tier) => tier + " 推理强度", title: "haiku 推理强度", def: "默认", low: "低", high: "高",
follows: "跟随会话", wins: "不受会话推理强度和 /effort 影响", own: "设了自己推理强度的档位按它自己的运行",
sep: (l, v) => `${l}:${v}`,
},
};
@@ -107,7 +111,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// each tier's row in the opened row: its model, then its effort
const effs = page.locator(`${cc} .ag-exp .field.ag-eff`);
assert.deepEqual(await effs.evaluateAll((es) => es.map((e) => e.dataset.key)), [...tiers.map((tier) => tier + "_effort"), "subagent_effort"]);
for (const tier of tiers) assert.equal(await page.locator(`${cc} .ag-exp .field.ag-eff[data-key="${tier}_effort"]`).getAttribute("aria-label"), t2(w, w.effort(tier), w.asks));
for (const tier of tiers) {
const b = page.locator(`${cc} .ag-exp .field.ag-eff[data-key="${tier}_effort"]`);
assert.equal(await b.getAttribute("aria-label"), t2(w, w.effort(tier), w.asks));
assert.equal(await b.locator(".v").textContent(), w.follows);
}
// no tier has an effort of its own yet: the session's says nothing of them
const session = page.locator(`${cc} .field[data-key="effort"]`);
assert.ok(!(await session.getAttribute("title")).includes(w.own));
assert.equal(await effs.locator(".effort-ic").count(), 5, "each effort shows the bars");
const haiku = page.locator(`${cc} .ag-exp .field.ag-eff[data-key="haiku_effort"]`);
const y = await page.evaluate(() => scrollY);
@@ -127,7 +138,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator("#effortValue").textContent(), w.low);
await page.waitForFunction(() => document.querySelector("#status")?.textContent);
assert.deepEqual(sets, [{ agent: "claude", field: "haiku_effort", value: "low" }]);
assert.equal(await haiku.getAttribute("aria-label"), t2(w, w.title, w.low));
assert.equal(await haiku.getAttribute("aria-label"), t2(w, w.title, w.low) + "\n" + w.wins);
assert.equal(await haiku.locator(".v").textContent(), w.low);
// drawn again from the state: the same words, and the session's effort
// now says a tier with its own runs at that one
await page.waitForFunction((own) => document.querySelector('.row.agent[data-id="claude"] .field[data-key="effort"]')?.title.includes(own), w.own);
assert.equal(await haiku.getAttribute("aria-label"), t2(w, w.title, w.low) + "\n" + w.wins);
assert.equal(await page.locator(`${cc} .ag-exp .field.ag-eff[data-key="opus_effort"] .v`).textContent(), w.follows);
assert.equal(await page.evaluate(() => scrollY), y, "a pick scrolled the page");
// the session's effort is untouched
assert.equal(await page.locator(`${cc} .field[data-key="effort"] .v`).textContent(), w.high);
@@ -137,7 +154,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
test(`${engine} ${lang}: Claude Code tier pickers keep one width in a narrow window`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await browser.newPage({ viewport: { width: 560, height: 700 } });
@@ -158,6 +175,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.ok(widths.every((width) => Math.abs(width - widths[0]) < 0.5), `picker widths: ${widths.join(", ")}`);
assert.equal(Math.round(widths[0]), 220);
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "narrow Agents view must not overflow horizontally");
// "follows session", in every language, stays on its tier's line
const lines = await page.locator(`${cc} .ag-exp .field.ag-eff`).evaluateAll((es) => es.map((e) => {
const p = e.parentElement.querySelector(".field.ag-pick").getBoundingClientRect(), r = e.getBoundingClientRect();
return Math.abs(r.top - p.top) < 2 && r.right <= innerWidth;
}));
assert.deepEqual(lines, lines.map(() => true));
assert.deepEqual(errors, []);
});
}