Repository navigation
Conversation
The builtin rate_limits branch rewrote the usage cache with a minimal JSON on every render. That refreshed the cache mtime each time, so the 60s staleness check never fired and /api/oauth/usage was never fetched again after the first call. extra_usage stayed frozen until the session was restarted, and all other fields of the API response were dropped. The API refresh already runs regardless of builtin data and keeps the cache current, so the cache write is removed. The fallback path for all-zero builtin data keeps working with the real API cache. Fixes daniel3303#50
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.
Fixes #50.
Problem
When Claude Code provides
rate_limitson stdin (the normal case), the builtin branch rewrote the usage cache with a minimal synthesized JSON on every render. This refreshed the cache file's mtime each time, so the 60s staleness check never fired again. As a result,/api/oauth/usagewas only fetched once per cache lifetime:extra_usagefroze at its first value and only updated after restarting the session, which is exactly what extra usage stat is not working #50 describesFix
Remove the per-render cache write in the builtin branch (
statusline.shandstatusline.ps1). The API refresh already runs regardless of builtin data (it exists precisely becauseextra_usageis only available from the API) and keeps the cache current. The all-zero fallback from b3abb7c keeps working: it now reads the real API cache, which is at most 60s old.Testing
statusline.shon macOS: with the patch, the cache mtime stays unchanged across renders and the API is refetched after 60s. Onmain, every render bumps the mtime. I could not teststatusline.ps1because I don't have PowerShell available; that change is the same deletion of the equivalent block.