A window shown again hears visibilitychange and focus together, and each
called load(true): two reads of /api/state (every agent's config), with
loadCLIs, loadInstalls, the providers and the Usage refresh after each.
Under focus-follows-mouse every pointer crossing into the window was one
more. loadBack now joins a return to the read asked under a second ago;
a return while an older read is still out gets one read after it, however
many came meanwhile.
Numbers (sandbox HOME, 16 agents, 1230 catalog models, dev build):
/api/state is 2.28 MB and ~55 ms of CPU per read (20 reads: 1.11 s).
Reads per window return: before 2, after 1.
The core's scripts were 1,446,845 bytes, 155 under their budget; loadBack
adds 523. Every page needs it, so it is the core's own: coreScriptBudget
goes to the new total, 1,447,368, plus 1.5% (1,469,000), as the budget's
own rule says.
Test: internal/gui/tests/window-back-once.test.cjs counts /api/state
reads for a return, a later return, and returns during a held read.
On the old app.js: 8 of 8 red, "shown again ... actual 2, expected 1".
Run at this head (load average ~500, nine sessions' suites at once):
node --test window-back-once.test.cjs, Chromium and WebKit, en and zh,
window and panel: 8 of 8 ok. TestCoreScriptBudget ok.
GUI files that fire focus or visibility (15 files, both engines): 194 of
196 ok. claude-usage-asked webkit en passes 9 of 9 alone.
tray-cell-click webkit zh is red alone 3 of 3, on 1a3b92688's own app.js
too: #2686, output added there.
go test -p 4 ./... -timeout 45m (HOME a sandbox): 59 packages ok, and:
- internal/gui: TestCoreScriptBudget red, fixed here (budget above);
TestSetAnswersWhileDevinAndProvidersHang red (13.8s sets), ok alone
(12.6s) and the whole package ok alone (391s): #1375, output added.
- internal/plugin: TestGatewayHookMixedPiPackage red ("starting plugins:
context deadline exceeded"), ok alone (110.8s): #2865, output added.
- internal/agent, internal/library, internal/gateway: timed out at 45m.
agent timed out alone too (2701.5s): #2544, output added. library is
#2853 and gateway #2870. Neither was rerun alone, to keep load off
the machine.
go vet on darwin, linux (nogui) and windows: clean. gofmt -l: clean.