gui: the tray panel's fit() is back under app.js's budget

2a8a17746 was rebased onto 703437866 after its run, and that base had
lowered app.js's budget to its own size (1,321,336), so main's
TestCoreScriptBudget went red by 140 bytes (app.js 1,321,476). The
measure is written shorter here, same steps; no budget raised.

Run at this tree (482eee47f, on origin/main 20d63621d): go test
-tags nogui -timeout 45m ./internal/usage ./internal/gui ok, with
TestCoreScriptBudget (app.js 1,321,332 of 1,321,336). GUI files panel*,
tray*, i18n-keys, routing-sessions, routing-zcode-blocked,
codex-subagent-model (29 files, chromium and webkit): 360 pass, 0 fail.
gofmt clean.
This commit is contained in:
yetone
2026-10-25 00:17:42 +08:00
parent 20d63621d1
commit aa3112f4e8
+8 -10
View File
@@ -3980,21 +3980,19 @@ if (mode === "window") {
// glide moves the panel's edge there over time instead of at once.
// The panel is as tall as its tallest tab, not the one showing, so it keeps
// its height as the tabs change and a shorter tab leaves room below (#124).
// Each tab counts its view's padding and margins too (sections alone left
// a scrollbar), all laid out at once: hiding the open tab ends its motion.
// Margins count; tabs lay out at once (hiding one ends its motion).
function fit(extra = 0, glide) {
if (mode !== "panel") return;
const body = document.body, view = $("#view-agents"), tab = body.dataset.ptab, vs = getComputedStyle(view);
const body = document.body, v = $("#view-agents"), tab = body.dataset.ptab, f = parseFloat, vs = getComputedStyle(v);
delete body.dataset.ptab;
const need = { agents: extra, usage: 0, stats: 0, routing: 0 };
for (const c of view.children) {
const cs = getComputedStyle(c), px = cs.display === "none" ? 0 : c.offsetHeight + parseFloat(cs.marginTop) + parseFloat(cs.marginBottom);
const only = { agentsLead: "agents", agents: "agents", panelQuota: "usage", panelUsage: "stats", panelRouting: "routing" }[c.id];
for (const t in need) if (!only || only === t) need[t] += px;
const n = { agents: extra, usage: 0, stats: 0, routing: 0 };
for (const c of v.children) {
const cs = getComputedStyle(c), px = cs.display == "none" ? 0 : c.offsetHeight + f(cs.marginTop) + f(cs.marginBottom);
const o = { agentsLead: "agents", agents: "agents", panelQuota: "usage", panelUsage: "stats", panelRouting: "routing" }[c.id];
for (const t in n) if (!o || o == t) n[t] += px;
}
let h = body.clientHeight - view.offsetHeight + parseFloat(vs.paddingTop) + parseFloat(vs.paddingBottom) + Math.max(...Object.values(need));
const h = Math.ceil(body.clientHeight - v.offsetHeight + f(vs.paddingTop) + f(vs.paddingBottom) + Math.max(...Object.values(n)));
if (tab) body.dataset.ptab = tab;
h = Math.ceil(h);
if (h === fit.last) return;
fit.last = h;
const still = !glide || calm();