Files
magpie/internal/gui/assets/plugins/usage
yetone 792f0f2860 usage: Requests opened again on the same rows aren't drawn or fit again, and new rows wait for the sidebar to settle (#4064, xisdumpling)
xisdumpling (Discord dumplings04605) sees frames drop when switching into
Usage > Requests at 7 days (~1,670 requests): the ledger's redraw and
ledFit's reflows land inside the sidebar's 460ms navSubEnter move.

Two causes, both fixed in internal/gui/assets/plugins/usage/page.js:
- Coming back, open() -> loadUsage(true) -> loadLedger read the same page
  again and redrew 100 rows even when nothing changed. The ledger now
  remembers the ledParams it was read with; on open with the same params
  it is read quietly ("open"), and same rows keep the table shown.
- #ledWrap's ResizeObserver refit the table at width 0 when the view was
  hidden and again when shown. It now skips a fit while the wrap has no
  width, so the table keeps the fit it had.
- Rows that did change on open are drawn after the sidebar settles
  (navSettled: rAF until navTop.raf and .nav-sub.moving are gone, capped
  at 700ms), and dropped if the reader moved on meanwhile.
No layout change: the table keeps its class (led tight) and the page its
scroll position in every run.

Measured with a harness (1,670 requests, 100 rows shown, 1280x800,
Gateway -> Usage click; Chromium trace counting full-tree style recalcs
(>1000 elements) and layouts (>1000 objects) within 480ms of the click):
- Chromium on mote, same rows, 4x CPU throttle: full restyles/layouts in
  the move 8/5 -> 2/1, longest task 194 -> 108ms, style 280 -> 126ms,
  layout 112 -> 46ms. Unthrottled: 8/5 -> 2/1, style 73 -> 37ms.
- Chromium, changed rows, 4x: 8/5 -> 2/1, longest frame gap in the move
  167 -> 100ms, longest task in it 147 -> 67ms, busy 464 -> 230ms.
  Unthrottled: in-move gap 33 both, longest task 40 -> 32ms; the gap
  after the move is 33 -> 50ms, since the redraw now comes after it.
- WebKitGTK on WSL (software rendering, noisy): changed rows max gap
  522 -> 339ms, in-move gap 222 -> 188ms; same rows 561 -> 490ms,
  211 -> 195ms.

New test usage-ledger-open-settled.test.cjs (Chromium and WebKit): same
rows keep the table, draw nothing, refit 0; changed rows draw once with
the sidebar at rest, newest first, same fit, no scroll move.
Broken by hand: old page.js is red in both engines ("the table shown is
kept"); without the "open" wait red ("once, with the sidebar at rest");
without the width guard red ("nor fit again at the width it had").

Run at this head (rebased on bfe1f9a2b):
- The new test, click-scroll and i18n-keys, Chromium on mote: new test
  ok; click-scroll red twice in a 3-file run at load 30-80 (.rt-days
  timeouts), then 12/12 alone both at bfe1f9a2b and here.
- go test -run 'Budget|Asset|I18n|Script' ./internal/gui on Windows: ok.
At aad6546cd (the rebase's previous base; origin/main since changed
app.js, not page.js or the nav motion):
- GUI files that reach the change (*usage*, *led*, view-open*,
  click-scroll*, nav-sub*, nav-top*, *period*) in Chromium on Windows:
  765 tests, 69 red, the same 22 red subtests at base and here, in
  tray-usages, usage-agents-hide, usage-ledger-ttft, usage-ledger,
  usage-speed (#4124).
- The same set in WebKit on Windows: 586 tests, 25 red. Run head to
  head with bfe1f9a2b: 26 red here, 28 at main, here a subset of main.
  currency and usage-accounts filed as #4204; gateway-caller-keys
  #3797, usage-focus-steady #3501, the rest #4124. view-open-wheel
  WebKit: 51/80 red at base and here.
- go test ./internal/gui on Windows: 9 reds, all on #4115, #1827, #4177
  or #4195 (TestUsageLedgerRoutes/DayRoutes red at base alone).
- Whole GUI suite in WebKit on WSL: still running at push, 3051 ok and
  82 red through routing-*; no red in a usage or ledger file, 17 red
  files not on #4120/#4121 are being run at main to file.
No Go file changed, so gofmt and vet have nothing new.

Not tried: macOS WebKit (mote's Playwright WebKit doesn't launch), the
whole Chromium GUI suite (mote at load 180-350 crashed browsers; run
abandoned), the reporter's own machine.
2026-10-29 15:59:45 +08:00
..