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
| 17 | 17 | ||
| 18 | 18 | out = {} | |
| 19 | 19 | 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 | |
| 20 | 32 | for win, used, reset in (("five_hour", used_5h, resets_5h), | |
| 21 | 33 | ("seven_day", used_7d, resets_7d)): | |
| 22 | 34 | prev = store.get(win) if isinstance(store.get(win), dict) else {} | |
| 23 | 35 | pu, pr = _coerce(prev.get("used")), _coerce(prev.get("resets_at")) | |
| 24 | 36 | po = _coerce(prev.get("observed_at")) | |
| 25 | 37 | 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) | |
| 27 | 39 | prev_ok = pu is not None and _reset_plausible(win, pr, now) | |
| 28 | 40 | # Stored reading is "unconfirmed" when nothing has re-observed it | |
| 29 | 41 | # within the grace period (legacy stores without observed_at count |
The check that tells the two apart
fail→pass·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
- 2026-08-02_relay_host
- 2026-07-10record_projection_snapshot
- 2026-07-09run_forever
- 2026-07-03verdict
- 2026-07-02line_text