fix: Windows tray fallback overriding fresh quota, cache history scan#79
Merged
Conversation
…ry scan per tick The claude.json fallback snapshot was preferred whenever its fetchedAtMs looked newer than the hook's timestamp, even when the hook already had a complete, live statusLine payload for the current session — so the tray silently fell back to a stale/expired-session cache instead of showing the real quota. A complete hook payload now always wins. Also cache history_source_scan() results for 30s instead of re-stat'ing every Codex/Claude session JSONL on every tray refresh tick, which was the main source of UI jank. Excludes the local release-win/ build staging dir from ruff/mypy scans.
Non-numeric used_percentage values (e.g. malformed hook payloads) passed the "complete" check via `is not None`, skipping the .claude.json cache fallback even though _build_snapshot() would then silently turn them into None, blanking the quota display. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usage_client.py: a complete, fresh statusLine hook payload could be overridden by the.claude.jsoncache whenever the cache'sfetchedAtMslooked newer, even when it described a different/expired session — so the Windows tray sometimes showed stale or wrong quota instead of the live hook data. A complete hook payload now always wins.wintray.py:history_source_scan()was re-stat'ing every Codex/Claude session JSONL on every tray refresh tick; added a 30s cache to cut redundant disk scans (main source of reported UI jank).pyproject.toml: excluded the localrelease-win/build staging dir from ruff/mypy so it doesn't pollute lint/type-check runs.Test plan
uv run ruff checkuv run mypy .uv run pytest -v(754 passed, 2 skipped)usage.exe(PyInstaller), verified--doctorreportsusage v0.28.7fetch_once()returnsdata_source=hookwithcurrent_percentmatching the live hook file