chiperman's patch (df288db, #2397), landed here since external PRs are collaborators only. The card redraw replaced its refresh button on a background reading and again when the click finished, restarting its rotation and hover reveal and moving the Updated text; a fast reply also stopped the spin partway through a turn. Each account's control and its animation are kept through redraws, the reply is shown at once and the current 800ms turn finishes (at least one), Reduce Motion skips it, and the glyph sits on the text baseline in an inline grid instead of a pixel offset. Changed in landing: main had since given the tray panel's Allowances the same quotaRefresh (#panelQuota, #840). A kept button is reused only when its redraw took it out of the page, so a refresh started on the Usage page is never moved out of the panel (or back); the other place's copy of a turning control gets busy+spun and turns by itself until done() clears it. The panel's hover rule (.pq-card:hover) reveals it as the Usage card's does. quota-refresh-order's vm harness gets a document stub for that. app.js's budget goes from 1,250,000 to 1,269,000: with four comments shortened it is 1,250,904 here, the core's own code since the tray panel draws the same control, plus 1.5% as the budget's comment asks. Every core script together is still under coreScriptBudget, which is unchanged. Run, sandbox HOME, pinned GOMODCACHE/GOCACHE, load ~110-360 from other sessions' suites: - Full suite on81313b912+ this change: set -o pipefail; go test -timeout 45m ./...: 64 packages ok; gateway and gui red in 3 tests: - TestCoreScriptBudget (app.js 47 bytes over; this change, fixed above) - TestPluginModelServiceTiersListed: ENOSPC, disk full; -count=3 ok - TestMainWindowCorners: killed at its deadline, red alone on main too (#1936) - At this head: - go test ./internal/gui/: only TestMainWindowCorners red (#1936) - TestCoreScriptBudget: ok - gofmt -l: clean - go vet -tags nogui for darwin, linux and windows: ok (./... on81313b912+ this change; ./internal/gui/... at the rebase) - node --check app.js: clean - GUI, Chromium and WebKit, ate085d6e92+ this change: usage-card-refresh, quota-refresh-order, panel-quota-refresh, gui-zh-tw, gui-ja, gui-de: 84 pass, 0 fail. At this head usage-card-refresh, quota-refresh-order and panel-quota-refresh: 75 pass, 0 fail. - Broken by hand: the new tests against the old app.js/app.css fail 26 of 46 in usage-card-refresh ("a background reading replaced the spinning control", "the refresh icon and the first text line must share a vertical center": 253.875 vs 252.375). - Whole GUI suite (789 files) on81313b912+ this change, per file, 3 at a time. Every red file was rerun alone and checked against plain main where it stayed red. None is from this change: - Red on main as well, already filed: codex-predictions (#2624), lightweight (#2638), segs-glide (#2683), sidebar (#2684), login-import, routing-keys-fold, routing-bodies (#2658), usage-agents-hide (#2276), quota-count-wrap, quota-name-translated (#2228, #2399), routing-model-rest (#2115), rest-try-now (#2564), routing-request-metrics (#2571), s3-sync (#2448), usage-checkin (#2549), usage-refresh (#2184), quota-curve (load). - Load reds filed now, red on main too: tray-cell-click (#2686), usage-ledger-abort (#2700), sessions-paging (#2703). - The rest were launch or goto timeouts in the parallel run and pass alone (about 30 files, among them provider-max-output and plugin-agent). Co-authored-by: chiperman <chipermanju@gmail.com>
53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
package gui
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
"regexp"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
// What the window's core may weigh, in bytes of script: everything
|
||
// index.html loads that isn't a plugin's (assets/plugins/<id>/) and isn't
|
||
// the words (i18n.js). A page belongs in a plugin. Each page moved out
|
||
// lowers these to what is left, with about 1.5% room for the core's own work,
|
||
// so a page can't quietly grow back into the core; a change that needs more
|
||
// raises them and says why in its commit.
|
||
const (
|
||
appScriptBudget = 1_269_000 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397)
|
||
coreScriptBudget = 1_447_000 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612)
|
||
)
|
||
|
||
func TestCoreScriptBudget(t *testing.T) {
|
||
page, err := os.ReadFile("assets/index.html")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
total, n := 0, 0
|
||
for _, m := range regexp.MustCompile(`<script src="([^"?]+)`).FindAllStringSubmatch(string(page), -1) {
|
||
name := m[1]
|
||
if strings.HasPrefix(name, "plugins/") || name == "i18n.js" {
|
||
continue
|
||
}
|
||
b, err := os.ReadFile(filepath.Join("assets", name))
|
||
if os.IsNotExist(err) {
|
||
continue // made by the server as it serves the page (boot.js)
|
||
}
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if name == "app.js" && len(b) > appScriptBudget {
|
||
t.Errorf("app.js is %d bytes, over its budget of %d: put the page's code in its plugin, or raise the budget and say why", len(b), appScriptBudget)
|
||
}
|
||
total += len(b)
|
||
n++
|
||
}
|
||
if n < 5 {
|
||
t.Fatalf("found only %d core scripts in index.html", n)
|
||
}
|
||
if total > coreScriptBudget {
|
||
t.Errorf("the core's scripts are %d bytes, over their budget of %d: put the page's code in its plugin, or raise the budget and say why", total, coreScriptBudget)
|
||
}
|
||
}
|