usage, gui: keep refreshed cards and distinguish deferred readings (#1630)

A card refresh and a whole-page quota read could replace each other's
entire snapshots. An older GET arriving after a successful refresh put
the old number back on screen; two card refreshes could undo each other.
Apply each POST's requested card alone and retain completed card readings
against whole-page requests that began before them. Later reads can still
update or remove cards. Failed refreshes do not block background results.

A saved Claude account not asked for, or allowances held by When I ask,
could also show "couldn't be read just now" without making a request.
Carry readDeferred through the cached card and CLI/gateway report, and
give that state a separate translated notice. Keep original read times,
network-failure notices and authentication errors. Automatic saved-account
reads and the existing 30-second floor are unchanged.

Verification (macOS arm64, Go 1.27.2, Bun 1.4.3; isolated homes/API fixtures):
- On base 2c5db1c6, quota-refresh-order.test.cjs fails three cases:
  old whole-page replies restore 0 over 32; crossed card replies restore
  0 over the other card's 61. With the fix, 4/4 pass.
- TestQuotaDeferredReadIsNotFailure fails the three deliberate-skip cases
  on the base, passes here; checks real read failures and auth refusals too.
- Original assets fail the new browser case with "a request not made was
  described as failed". Related frontend checks pass 71/71, including the
  real card button in Chromium and WebKit across en/zh/zh-TW/ja/de. The
  extra locale/i18n checks pass 12/12. The full GUI suite was not run.
- Provider tests for deferred/kept/saved readings pass -race -count=20.
- gofmt and git diff --check clean. Full vet on darwin, linux nogui and
  windows; darwin build, linux nogui build and windows build pass.
- go test -tags nogui ./... completed: every tested package passed except
  internal/plugin's TestPluginSOCKSProxy. HTTPS through a dead SOCKS proxy
  produces "proxyconnect tcp: 502 Bad Gateway: socks connect ... refused",
  while the test expects an HTTP 502 response. Reproduced unchanged on
  freshly fetched upstream 68552188 in an independent worktree; already
  reported in #1630. The full suite is not green; no proxy change here.

Not tried: the patched native app with a real Claude account. The response
ordering is injected in tests, not captured from the reported incident;
this does not establish that every intermittent refresh failure is fixed.
This commit is contained in:
hhh2210
2026-10-14 21:54:12 +08:00
committed by yetone
parent 2c18c697c2
commit 86cc7ac56d
10 changed files with 284 additions and 10 deletions
+14
View File
@@ -33,6 +33,20 @@ three.
## Constraints and failure behavior
### Allowance card refreshes
A card refresh applies only the requested account from the API's full
card list. A whole-page read begun before that refresh completed keeps
the newer card when its older response arrives; other cards still update,
and a later whole-page read can replace or remove the card. This also
keeps two different card refreshes from undoing each other's results.
`keepRefreshedQuotas` and `quotaRefresh` in
[`app.js`](../../internal/gui/assets/app.js) own this publication order;
`quota-refresh-order.test.cjs` covers held responses and failures, and
`usage-card-refresh.test.cjs` checks the real button in both browser
engines and all five languages. A cached `readDeferred` card says no
refresh was requested this time; a failed read retains its failure notice.
### Streamed output speed
Usage rows and aggregates use `Record.Decode` and `DecodeOf` in
+9
View File
@@ -133,6 +133,15 @@ listed models keep their `Available` names unchanged
## Constraints and failure behavior
An allowance deliberately not requested (a saved Claude account outside
its card refresh, or allowances set to *When I ask*) can use the last
reading with `readDeferred: true`. `AsOf` and `ReadAt` still date that
snapshot; the GUI says it was not refreshed this time rather than that a
request failed. Network failures, unavailable `/usage` and account refusals
are not deferred reads. The flag also reaches `magpie quota --json` and
the gateway report. [`quota_last.go`](../../internal/provider/quota_last.go),
`TestQuotaDeferredReadIsNotFailure`.
Allowance readings are kept by provider, lowercased account and window in
`quota-history.json` ([`quota_history.go`](../../internal/provider/quota_history.go)),
for up to 45 days and 6000 points per window. Failed or stale readings add
+34 -6
View File
@@ -14368,17 +14368,23 @@ function quotasOpened() {
// landed, so the tray panel, opened, shows what the window does without a
// refresh by hand (#959). An answer the same as the last isn't drawn again.
let quotasLoading = null, quotasLater = 0, quotasTries = 0;
let quotaRefreshVersion = 0;
const quotaRefreshVersions = new Map();
function loadQuotas(asked, again) {
if (quotasLoading && (!asked || quotasLoading.asked)) return quotasLoading;
if (asked) quotasAskedAt = performance.now();
if (!again) quotasTries = 0;
let reading = false, same = false;
let reading = false, same = false, began;
const p = Promise.resolve(quotasLoading).catch(() => {})
.then(() => Promise.all([api("usage/quotas" + (asked ? "?asked=1" : ""), undefined, (h) => { reading = h.get("X-Magpie-Reading") === "1"; }), api("usage/quotas/history?days=45").catch(() => null)]))
.then(() => {
began = quotaRefreshVersion;
return Promise.all([api("usage/quotas" + (asked ? "?asked=1" : ""), undefined, (h) => { reading = h.get("X-Magpie-Reading") === "1"; }), api("usage/quotas/history?days=45").catch(() => null)]);
})
.then(([q, h]) => {
// an answer that isn't a list of cards is a read that failed: what
// was read before stays, as it does when the read is refused
if (q != null && !Array.isArray(q)) { quotas = quotas || []; reading = false; return; }
q = keepRefreshedQuotas(q || [], began);
same =!!again && !!quotas && JSON.stringify(q || []) === JSON.stringify(quotas) && (!h || JSON.stringify(h) === JSON.stringify(quotaHist));
quotas = q || []; quotasAt = Date.now(); if (h) quotaHist = h;
}, () => { quotas = quotas || []; reading = false; })
@@ -14393,6 +14399,20 @@ function loadQuotas(asked, again) {
return p;
}
// A whole-page reply can have left the backend before a card's refresh
// completed. Keep each card refreshed since this read began, including a
// card the older reply did not yet contain. A later read may replace it.
function keepRefreshedQuotas(next, began) {
for (const [key, version] of quotaRefreshVersions) if (version <= began) quotaRefreshVersions.delete(key);
const kept = new Map((quotas || []).filter(q => quotaRefreshVersions.has(usageAcctKey(q))).map(q => [usageAcctKey(q), q]));
const out = next.map(q => {
const key = usageAcctKey(q), newer = kept.get(key);
kept.delete(key);
return newer || q;
});
return out.concat([...kept.values()]);
}
// the period picker, in the page's head, for the Overview and Requests
function renderPeriod(loading) {
const seg = $("#period");
@@ -16373,11 +16393,11 @@ async function hidePanelUsage(key, hide) {
}
}
// asOfText: an allowance standing in for one that couldn't be read just
// now (a vendor rate limiting its usage endpoint) says when it was read.
// asOfText dates a cached allowance and distinguishes a deliberate skip
// from a failed read (such as the vendor rate limiting its usage endpoint).
function asOfText(q, short = false) {
const text = short ? t("As of {when}", { when: stamp(q.asOf) })
: t("As of {when} — couldn't be read just now", { when: new Date(q.asOf).toLocaleString(intlLang()) });
: t(q.readDeferred ? "As of {when} — not refreshed this time" : "As of {when} — couldn't be read just now", { when: new Date(q.asOf).toLocaleString(intlLang()) });
return q.windows?.some((w) => w.resetsAt && new Date(w.resetsAt).getTime() <= Date.now())
? text + " · " + t("A cached window has expired; current allowance is unknown") : text;
}
@@ -17101,7 +17121,15 @@ function quotaRefresh(q) {
b.classList.add("busy");
try {
const qs = await api("usage/quotas/refresh?provider=" + encodeURIComponent(q.provider) + (q.user ? "&user=" + encodeURIComponent(q.user) : ""), {});
if (Array.isArray(qs)) { quotas = qs; quotasAt = Date.now(); }
const fresh = Array.isArray(qs) && qs.find(x => usageAcctKey(x) === key);
if (fresh) {
quotaRefreshVersions.set(key, ++quotaRefreshVersion);
// The reply includes every card, but only this one was refreshed.
// Another card may have completed its own refresh in the meantime.
const kept = quotas || [];
quotas = kept.some(x => usageAcctKey(x) === key) ? kept.map(x => usageAcctKey(x) === key ? fresh : x) : [...kept, fresh];
quotasAt = Date.now();
}
} catch (err) {
status(err.message, "err");
} finally {
+4
View File
@@ -2850,6 +2850,7 @@ const I18N = {
"Spend this cycle": "本周期花费",
"ClinePass limits couldn't be read — hover for why": "ClinePass 额度没能读到 — 悬停查看原因",
"As of {when} — couldn't be read just now": "截至 {when},暂时无法获取最新额度",
"As of {when} — not refreshed this time": "截至 {when},本次未主动刷新",
"A cached window has expired; current allowance is unknown": "缓存中有窗口已过期,其当前额度未知",
"As of {when}": "截至 {when}",
"Reset time passed": "重置时间已过",
@@ -7043,6 +7044,7 @@ const I18N = {
"Spend this cycle": "本週期花費",
"ClinePass limits couldn't be read — hover for why": "ClinePass 額度沒能讀到 — 懸停查看原因",
"As of {when} — couldn't be read just now": "截至 {when},暫時無法取得最新額度",
"As of {when} — not refreshed this time": "截至 {when},本次未主動重新整理",
"A cached window has expired; current allowance is unknown": "快取中有時段已過期,其目前額度未知",
"As of {when}": "截至 {when}",
"Reset time passed": "重置時間已過",
@@ -11239,6 +11241,7 @@ const I18N = {
"Spend this cycle": "この周期の費用",
"ClinePass limits couldn't be read — hover for why": "ClinePass の上限を読み取れませんでした — ホバーで理由を表示",
"As of {when} — couldn't be read just now": "{when} 時点 — 現在は読み取れません",
"As of {when} — not refreshed this time": "{when} 時点 — 今回は更新を要求していません",
"A cached window has expired; current allowance is unknown": "キャッシュされた期間が期限切れです。現在の利用枠は不明です",
"As of {when}": "{when} 時点",
"Reset time passed": "リセット時刻を過ぎました",
@@ -15444,6 +15447,7 @@ const I18N = {
"Spend this cycle": "Ausgaben in diesem Zyklus",
"ClinePass limits couldn't be read — hover for why": "ClinePass-Limits konnten nicht gelesen werden — für den Grund darüberfahren",
"As of {when} — couldn't be read just now": "Stand {when} — konnte gerade nicht gelesen werden",
"As of {when} — not refreshed this time": "Stand {when} — diesmal nicht neu abgefragt",
"A cached window has expired; current allowance is unknown": "Ein zwischengespeichertes Zeitfenster ist abgelaufen; das aktuelle Kontingent ist unbekannt",
"As of {when}": "Stand {when}",
"Reset time passed": "Rücksetzzeitpunkt überschritten",
@@ -0,0 +1,90 @@
// Drive the shipped callbacks with held API replies. A background read and
// two different card refreshes may finish in any order (#1630).
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const vm = require("node:vm");
const { test } = require("node:test");
const source = fs.readFileSync(process.env.MAGPIE_APP_JS || path.resolve(__dirname, "../assets/app.js"), "utf8").replace(/\r\n/g, "\n");
function section(start, end) {
const a = source.indexOf(start), b = source.indexOf(end, a);
assert(a >= 0 && b > a, `missing ${start}`);
return source.slice(a, b);
}
const plain = (x) => JSON.parse(JSON.stringify(x));
const card = (user, used) => ({ provider: "claude", user, windows: [{ name: "7 days", used }] });
function page() {
const context = vm.createContext({ Date, performance, setTimeout });
vm.runInContext(`
let quotas = [], quotasAt = 0, quotaHist = [], quotasAskedAt = 0, view = "usage";
const requests = [], errors = [];
const usageAcctKey = q => q.provider + "\\n" + (q.user || "").toLowerCase();
const t = x => x;
const el = () => ({ classList: { add() {} }, setAttribute() {} });
function renderQuotas() {}
function loadUpstream() {}
function status(x) { errors.push(x); }
function api(path) {
if (path.includes("history")) return Promise.resolve([]);
return new Promise((resolve, reject) => requests.push({ path, resolve, reject }));
}
${section("let quotasLoading =", "// the period picker, in the page's head")}
${section("const quotaRefreshing =", "// familyQuota:")}
globalThis.p = {
requests, errors,
seed: x => { quotas = x; },
cards: () => quotas,
load: () => loadQuotas(),
refresh: q => quotaRefresh(q).onclick({ stopPropagation() {} }),
answer: (i, x) => requests[i].resolve(x),
fail: i => requests[i].reject(new Error("offline")),
};
`, context);
return context.p;
}
const tick = () => new Promise(setImmediate);
for (const when of ["before", "during"]) {
test(`a background read started ${when} a card refresh cannot undo its result`, async () => {
const p = page(), old = card("a@x.com", 0), fresh = card("a@x.com", 32);
p.seed([old]);
let loading, refreshing;
if (when === "before") {
loading = p.load(); await tick(); refreshing = p.refresh(old);
} else {
refreshing = p.refresh(old); loading = p.load(); await tick();
}
const post = p.requests.findIndex(r => r.path.includes("/refresh?"));
const get = p.requests.findIndex(r => r.path === "usage/quotas");
assert(post >= 0 && get >= 0);
p.answer(post, [fresh]); await refreshing;
assert.equal(p.cards()[0].windows[0].used, 32);
p.answer(get, [old]); await loading;
assert.equal(p.cards()[0].windows[0].used, 32, "an older whole-page reply overwrote the refreshed card");
// A later whole-page reading remains authoritative, including removals.
const later = p.load(); await tick();
p.answer(p.requests.length - 1, []); await later;
assert.deepEqual(plain(p.cards()), []);
});
}
test("refreshing two cards keeps both results when their full-list replies cross", async () => {
const p = page(), a = card("a@x.com", 0), b = card("b@x.com", 0);
p.seed([a, b]);
const first = p.refresh(a), second = p.refresh(b);
p.answer(1, [a, card("b@x.com", 61)]); await second;
p.answer(0, [card("a@x.com", 32), b]); await first;
assert.deepEqual(plain(p.cards()).map(q => q.windows[0].used), [32, 61], "one card's reply undid another card's completed refresh");
});
test("a failed card refresh leaves background readings usable", async () => {
const p = page(), old = card("a@x.com", 0);
p.seed([old]);
const refresh = p.refresh(old), loading = p.load(); await tick();
p.fail(0); await refresh;
p.answer(1, [card("a@x.com", 32)]); await loading;
assert.equal(p.cards()[0].windows[0].used, 32);
assert.deepEqual(plain(p.errors), ["offline"]);
});
+57 -3
View File
@@ -5,14 +5,15 @@
// at rest the line starts where the card's others do. A click reads that card alone
// (POST /api/usage/quotas/refresh?provider=&user=), turns while it does, and
// draws what came back; no other card is asked, and the page doesn't scroll.
// English and Chinese; no backend, the API is faked here.
// Button controls in English and Chinese; refresh ordering and deferred
// readings in all five languages. No backend: the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const assets = process.env.MAGPIE_QUOTA_ASSETS || path.resolve(__dirname, "../assets");
const H = 3600e3, M = 60e3;
const iso = (ms) => new Date(ms).toISOString();
@@ -38,7 +39,12 @@ function serve(lang, state) {
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings });
if (url.pathname === "/api/settings") return json(settings);
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
if (url.pathname === "/api/usage/quotas") { state.gets++; return json(state.quotas); }
if (url.pathname === "/api/usage/quotas") {
state.gets++;
const snapshot = JSON.parse(JSON.stringify(state.quotas));
if (state.readGate) { state.readStarted(); await state.readGate; }
return json(snapshot);
}
if (url.pathname === "/api/usage/quotas/refresh") {
assert.equal(route.request().method(), "POST");
state.refreshes.push(url.search);
@@ -46,6 +52,7 @@ function serve(lang, state) {
const q = state.quotas.find((x) => x.provider === url.searchParams.get("provider") && (x.user || "") === (url.searchParams.get("user") || ""));
if (q?.windows?.length) { q.windows[0].used = 61; q.readAt = iso(Date.now()); }
if (q?.error) { delete q.error; q.windows = [{ name: "Week", used: 10 }]; q.readAt = iso(Date.now()); }
if (q) { delete q.asOf; delete q.readDeferred; }
return json(state.quotas);
}
if (url.pathname === "/api/usage/quotas/history") return json([]);
@@ -59,6 +66,53 @@ function serve(lang, state) {
};
}
const deferredWords = {
en: "not refreshed this time",
zh: "本次未主动刷新",
"zh-TW": "本次未主動重新整理",
ja: "今回は更新を要求していません",
de: "diesmal nicht neu abgefragt",
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(deferredWords)) {
test(`${engine} ${lang}: a deferred card is not a failure, and a late background reply cannot undo its refresh`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await browser.newPage({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" });
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", e => errors.push(e.message));
const state = { quotas: fixtures(Date.now()), gets: 0, refreshes: [] };
state.quotas[0].asOf = state.quotas[0].readAt;
state.quotas[0].readDeferred = true;
await page.route("**/*", serve(lang, state));
await page.goto("http://magpie.test/?view=usage");
const claude = page.locator(".subscription-card", { hasText: "Claude Code" });
const read = claude.locator(".quota-read");
await read.waitFor();
assert.ok((await read.textContent()).includes(deferredWords[lang]), "a request not made was described as failed");
let release, readStarted;
const started = new Promise(r => { readStarted = r; });
state.readStarted = readStarted;
state.readGate = new Promise(r => { release = r; });
t.after(() => release());
// Hold an old whole-page response, then click the real card button.
await page.evaluate(() => { void loadQuotas(); });
await started;
await claude.hover();
await claude.locator(".quota-refresh").click();
await claude.locator(".quota-n", { hasText: "61%" }).waitFor();
release();
await page.evaluate(() => quotasLoading);
assert.match(await claude.locator(".quota-n").textContent(), /61%/, "an older reply undid the click");
assert.equal(await read.evaluate(e => e.classList.contains("stale")), false);
assert.deepEqual(state.refreshes, ["?provider=claude&user=a%40x.com"]);
assert.deepEqual(errors, []);
});
}
}
const words = {
en: { updated: "Updated 40 minutes ago", label: "Refresh this card", now: /^Updated (just now|\d+ seconds? ago)$/ },
zh: { updated: "40分钟前更新", label: "刷新这张卡片", now: /^(刚刚|\d+秒前)更新$/ },
+67
View File
@@ -0,0 +1,67 @@
package provider
import (
"encoding/json"
"testing"
"time"
)
// An account deliberately not read has an older reading, not a failed
// request. Keep that distinction in both the GUI card and CLI report.
func TestQuotaDeferredReadIsNotFailure(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
clear := func() {
lastQuotas.Lock()
lastQuotas.m, lastQuotas.loaded = nil, false
lastQuotas.Unlock()
}
clear()
t.Cleanup(clear)
at := time.Now().Add(-time.Hour).Truncate(time.Second)
good := SubscriptionQuota{Provider: "claude", User: "saved@example.com", ReadAt: &at,
Windows: []QuotaWindow{{Name: "7 days", Used: 32}}}
keepLast(good, "")
clear() // as after an app restart
deferred := func(v any) bool {
b, err := json.Marshal(v)
if err != nil {
t.Fatal(err)
}
var obj map[string]any
if err := json.Unmarshal(b, &obj); err != nil {
t.Fatal(err)
}
return obj["readDeferred"] == true
}
for _, tc := range []struct {
name, err string
want bool
}{
{"saved", errClaudeSaved.Error(), true},
{"not asked", errClaudeNotAsked.Error(), true},
{"manual only", errNotAsked.Error(), true},
{"rate limited", "HTTP 429 Too Many Requests", false},
{"unavailable", errClaudeUsageUnavailable.Error(), false},
{"network", "connection refused", false},
} {
t.Run(tc.name, func(t *testing.T) {
q := keepLast(SubscriptionQuota{Provider: good.Provider, User: good.User, Error: tc.err}, "")
if q.Error != "" || q.AsOf == nil || q.ReadAt == nil || !q.ReadAt.Equal(at) || len(q.Windows) != 1 || q.Windows[0].Used != 32 {
t.Fatalf("cached reading lost its values or time: %+v", q)
}
if got := deferred(q); got != tc.want {
t.Errorf("readDeferred = %v, want %v for %q", got, tc.want, tc.err)
}
report := quotaReport([]SubscriptionQuota{q}, nil, nil, time.Now())
if len(report) != 1 || deferred(report[0]) != tc.want {
t.Errorf("CLI/gateway report lost readDeferred: %+v", report)
}
})
}
if q := keepLast(SubscriptionQuota{Provider: good.Provider, User: good.User, Error: "401 unauthorized"}, ""); q.Error == "" || deferred(q) {
t.Fatalf("an account refusal was hidden as a deferred read: %+v", q)
}
if q := keepLast(good, ""); q.AsOf != nil || deferred(q) {
t.Fatalf("a successful reading is still deferred: %+v", q)
}
}
+3
View File
@@ -85,6 +85,7 @@ func keepLast(q SubscriptionQuota, user string) SubscriptionQuota {
}
e.Q.Error = ""
e.Q.AsOf = nil
e.Q.ReadDeferred = false
if c.m == nil {
c.m = map[string]lastQuota{}
}
@@ -110,6 +111,8 @@ func keepLast(q SubscriptionQuota, user string) SubscriptionQuota {
if !ok {
return q
}
out.ReadDeferred = q.Error == errNotAsked.Error() || q.Provider == "claude" &&
(q.Error == errClaudeNotAsked.Error() || q.Error == errClaudeSaved.Error())
out.Name, out.Icon, out.User = q.Name, q.Icon, q.User
if out.Name == "" {
out.Name, out.Icon = c.m[key].Q.Name, c.m[key].Q.Icon
+3 -1
View File
@@ -61,6 +61,8 @@ type Quota struct {
Balance string `json:"balance,omitempty"`
Error string `json:"error,omitempty"`
AsOf *time.Time `json:"asOf,omitempty"` // the cached reading's time, nil for a new one
// ReadDeferred says no request was made this time, rather than one failed.
ReadDeferred bool `json:"readDeferred,omitempty"`
// ReadAt is when the windows or balance shown were read, nil when not
// known; a Claude account's can be well before now (claudeReadAt).
ReadAt *time.Time `json:"readAt,omitempty"`
@@ -136,7 +138,7 @@ func quotaReport(subs, plans, balances []SubscriptionQuota, now time.Time) []Quo
qs []SubscriptionQuota
}{{"subscription", subs}, {"plan", plans}, {"balance", balances}} {
for _, q := range g.qs {
r := Quota{Provider: q.Provider, Name: q.Name, Kind: g.kind, Plan: q.Plan, User: q.User, AsOf: q.AsOf, ReadAt: q.ReadAt,
r := Quota{Provider: q.Provider, Name: q.Name, Kind: g.kind, Plan: q.Plan, User: q.User, AsOf: q.AsOf, ReadAt: q.ReadAt, ReadDeferred: q.ReadDeferred,
Windows: []QuotaSpan{}, Balance: q.Balance, Error: q.Error, Until: q.Until, Renew: q.Renew, Resets: q.Resets, ResetsUsed: q.ResetsUsed, From: q.From, Alias: q.Alias, Seat: q.Seat}
// a pool's own windows stand in for the models' drawing on it,
// as the usage page shows them
+3
View File
@@ -129,6 +129,9 @@ type SubscriptionQuota struct {
// AsOf is when an allowance shown in place of one that couldn't be
// read was read (see keepLast); nil for a reading just made.
AsOf *time.Time `json:"asOf,omitempty"`
// ReadDeferred distinguishes a reading deliberately not requested from
// a request that failed. AsOf and ReadAt still date the cached values.
ReadDeferred bool `json:"readDeferred,omitempty"`
// ReadAt is when what is shown was read: a key's balance, kept a
// minute (KeyBalances), or an account's allowance, which a cache (a
// minute's, or a Claude account's until Claude Code tells it again)