One function

reconcile_account in leeguooooo/claude-code-usage-bar

The author described this change as fix(predict): 闲置窗口回放过期 rate_limits blob(5h reset 已过期)不再覆盖/确认共享读数,修复 7d 卡旧值. It counts as a record because the check below fails on the code as it stood at 337c98119 and passes on b05e491a4, with nothing else changed between the two runs.

Fix saved2026-06-10
Sharing licenceMIT · LICENSE
Change size+13 1

What the code was meant to do, written into the code itself as a docstring

Merge this window's per-session reading into the shared account-global store and return the freshest (u5, r5, u7, r7). Makes every window converge to the same numbers within one render tick. Never raises — on any I/O error it just returns the inputs (degrades to per-session behaviour).

The change

1717
1818 out = {}
1919 changed = False
20+ # Both windows come from the same API response headers, so one
21+ # implausible resets_at dates the WHOLE blob: a five_hour reset in the
22+ # past means these headers are hours old (a fresh response always has
23+ # a future 5h reset), even though the seven_day reset may still look
24+ # plausible. Idle-but-open Claude Code windows replay such frozen
25+ # blobs every render — they must neither write the store nor count as
26+ # confirmations (or a pre-rebaseline pct never heals).
27+ blob_fresh = True
28+ for win, reset in (("five_hour", resets_5h), ("seven_day", resets_7d)):
29+ r = _coerce(reset)
30+ if r is not None and not _reset_plausible(win, r, now):
31+ blob_fresh = False
2032 for win, used, reset in (("five_hour", used_5h, resets_5h),
2133 ("seven_day", used_7d, resets_7d)):
2234 prev = store.get(win) if isinstance(store.get(win), dict) else {}
2335 pu, pr = _coerce(prev.get("used")), _coerce(prev.get("resets_at"))
2436 po = _coerce(prev.get("observed_at"))
2537 cu, cr = _coerce(used), _coerce(reset)
26- cur_ok = cu is not None and _reset_plausible(win, cr, now)
38+ cur_ok = cu is not None and blob_fresh and _reset_plausible(win, cr, now)
2739 prev_ok = pu is not None and _reset_plausible(win, pr, now)
2840 # Stored reading is "unconfirmed" when nothing has re-observed it
2941 # within the grace period (legacy stores without observed_at count

The check that tells the two apart

failpass·tests/test_predict.py::test_reconcile_stale_blob_cannot_confirm_or_upgrade

Check file tests/test_predict.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it337c98119eaa766142b9d13a348b54cf1f09b108
Broken version dated2026-06-10
Moduleclaude_statusbar.predict
Units changedreconcile_account
Fingerprint45c1639b06ab7d3f
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in leeguooooo/claude-code-usage-bar