jsc9495 (Discord #help, 0.1.2950+, Claude Max): on one account at one
moment magpie's card said 5h 92% / 7d 99% left, another app 53% / 94%.
Claude Code 2.1.316's /usage panel draws the figures it saved on its last
read (cachedUsageUtilization in .claude.json, used up to an hour old,
keyed by accountUuid) at once, with "Refreshing…" under them, while it
asks Anthropic for today's. When that fails it keeps them and says
"Showing last-known usage as of 20m ago (rate limited until …)" or
"… (could not refresh)". The helper took any figures that stood still
for a second as the answer, so with a refresh slower than 1s, or a
rate-limited or failed one, each read told the figures of the read
before it (up to an hour old) stamped with the time now.
Now "Refreshing…" is waited past (up to commandWait). A panel that is
still refreshing at that point, or that shows last-known usage, is told as
"/usage couldn't load the plan's usage: …". claudeUsageUnknown already
matches that, so the card keeps its own last reading and that reading's
time. Figures Claude Code seeds from this session's own reply headers
("Partial usage data", "Per-model breakdown unavailable", "Could not
refresh usage data") are current and are still reported.
Fixtures are real bytes. Claude Code 2.1.316 ran on mote in a sandbox
CLAUDE_CONFIG_DIR with a made-up sign-in and saved figures 20 minutes
old (8% / 1%), and /usage was typed through a pty. It drew "Refreshing…"
and then "Showing last-known usage as of 20m ago (rate limited until
12:11am)". No real account was used, and no Keychain or live config was
touched.
Run (mote-run, at this tree on f280b12e5):
- go test ./internal/claudetui/ -count=1: ok.
- go test ./internal/provider/ -run Claude: ok.
- go test ./internal/gateway/ -run 'ClaudeUsage|ClaudeTUI': ok.
- GOOS=linux and GOOS=windows go vet ./internal/claudetui/: ok.
- gofmt -l: clean.
- win-run on xiaomi-gpu, TestShimWaitsPastSavedUsage and
TestShimWaitsForUsageFigures: ok.
Broken by hand: with HEAD's tui.go, TestShimWaitsPastSavedUsage is red in
both subtests. Each tells "Current session: 8% used", the saved figures,
as a success.
Not tried:
- A real account's refresh. The redraw after a successful refresh is the
earlier usage-2.1.316.bin capture on a cleared screen, not a captured
redraw.
- A panel still "Refreshing…" after 20s; it takes the same error path.
- Why the other app's 7d figure read lower on jsc9495's second account.
1 line
2.0 KiB
Plaintext
1 line
2.0 KiB
Plaintext
[H[38;5;174m▎[3G[38;5;246mblocks the rest.
|
|
[1B[38;5;174m▎[39m [38;5;246mhttps://code.claude.com/docs/en/permission-modes
|
|
[1B[38;5;153m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[181G[38;5;246m◐ medium · /effort[38;5;153m ▔
|
|
[1B[39m [38;5;153m[1mSettings[22m[39m Status Config [48;5;153m[38;5;16m[1m Usage [22m[39m[49m Stats
|
|
[2B [3G [1mSessi[10Gn[22m[K
|
|
[1B[K
|
|
[1B [3G [38;5;246mT[6Gtal[10Gcost: $0.0000
|
|
[1B[39m [3G [38;5;246mTotal duration (API): 0s[39m[K
|
|
[3C[1B[38;5;246mTotal duration (wall): 9s
|
|
[3C[1BTotal code changes: 0 lines added, 0 lines removed
|
|
[3C[1BUsage: 0 input, 0 output, 0 cache read, 0 cache write
|
|
[3C[2B[39m[1mCurrent session
|
|
[3C[1B[22m[48;5;102m[38;5;153m████ [55G[39m[49m8%[58Gused
|
|
[3C[1B[38;5;246mResets 2:10am (Asia/Shanghai)
|
|
[3C[2B[39m[1mCurrent week (all models)
|
|
[3C[1B[22m[48;5;102m[38;5;153m▌ [55G[39m[49m1%[58Gused
|
|
[3C[1B[38;5;246mResets Nov 8 at 11:10pm (Asia/Shanghai)
|
|
[3C[2B[39m[1mWhat's contributing to your usage?
|
|
[3C[1B[22m[38;5;246mApproximate · sessions on this machine only
|
|
[3C[2BScanning local sessions…
|
|
[3C[2BRefreshing…
|
|
[3C[2BEsc to cancel
|
|
[2C[13B[39m[K
|
|
[2C[1B[K
|
|
[2C[1B[K
|
|
[2C[1B[K
|
|
[2C[1B[K
|
|
[1B[K
|
|
[1B[K
|
|
[1B[K
|
|
[2C[1B[K[50;1H[4;32H[H
|
|
[3C[21B[38;5;246mRefreshing…[39m[K
|
|
[3C[1B[K
|
|
[3C[1B[38;5;246mEsc to cancel
|
|
[3C[1B[39m[K
|
|
[3C[2B[K
|
|
[3C[2B[K[50;1H[4;32H |