sean_80289 on Discord: in the TUI the remaining-usage panel didn't show
new numbers; only refreshing each account on its own page did. The page
read the quotas once per TUI start, unasked, so it showed what was kept
and never what a read under way brought.
It now does what the GUI's Usage page does (#959):
- Opening the page more than 30s after the last ask (quotasOpenGap, the
GUI's QUOTAS_OPEN_GAP) is an asked read (provider.Asked,
AskClaudeUsage); within 30s it reads what is kept.
- While provider.SubscriptionUsageReading() says a read is under way, it
reads again every 1.5s, at most 20 times, as the GUI does on
X-Magpie-Reading; it stops when the page is left.
- "r" asks again. An answer to an earlier load is dropped (qgen).
Run on mote at a8d6a861a, one commit (internal/proc only) before the
pushed head: go test ./internal/tui ok; go vet
internal/tui internal/cli for darwin, linux (-tags nogui) and windows;
gofmt -l clean. go test ./internal/cli: TestEveryRouteHasACommandOrIsNamed
is red on origin/main too (POST /api/usage/checkin-account, #4826), not
this change.
At the pushed head after the rebase: go build ./... ok, go test
./internal/tui ./internal/proc ok.
Broken by hand: with the re-read in gotQuotas taken out and goTo back
to reading only once, TestUsagePageAsksAgainWhileReading,
TestUsagePageReadsAgainOnReturn and TestUsagePageAsksAgainAtMostTries
went red.
Not tried: a real TUI session against signed-in accounts; the tests
drive the model with a fake read.