From aa3112f4e81c6058c42a3fd2f9c4d000c13e2e64 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Oct 2026 00:06:53 +0800 Subject: [PATCH] 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. --- internal/gui/assets/app.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 2332f8e02..af679dc5b 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -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();