feat: opt-in usage tracker β persistent rate-limit logging to JSONL - #546
Open
tobiasstrebitzer wants to merge 1 commit into
Open
feat: opt-in usage tracker β persistent rate-limit logging to JSONL#546tobiasstrebitzer wants to merge 1 commit into
tobiasstrebitzer wants to merge 1 commit into
Conversation
Appends every distinct rate-limit observation (stdin rate_limits and usage API responses) to a JSONL log so subscription-limit utilization can be analyzed later. Off by default, configured via a new Usage Tracker TUI screen. - payloads are logged verbatim (pre-validation), so unknown buckets survive schema drift - value-based dedup via a small state file; heartbeat records make gaps unambiguous; size-based rotation bounds growth - api records hook the cache-refresh path, so N concurrent sessions produce one record per 180s window by construction - all logging IO is best-effort and can never break rendering
tobiasstrebitzer
marked this pull request as ready for review
August 6, 2026 02:43
Author
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.

What
An opt-in, off-by-default recorder that appends every distinct rate-limit observation to a JSONL file, so subscription-limit utilization can be analyzed later (e.g. correlated against token usage from Claude Code's session logs).
ccstatusline already fetches this data every 180s across all sessions; this optionally appends it to a log file instead of throwing it away after rendering.
How it works
Two write paths, one log (
$XDG_DATA_HOME/ccstatusline/usage-log.jsonlor~/.local/share/ccstatusline/usage-log.jsonl):rate_limitsobject from the status payload is logged when its value changed. Captured from the raw pre-zod parse, so buckets not yet inStatusJSONSchemasurvive verbatim.fetchUsageData()at the cache-write point, the full/api/oauth/usageresponse body is logged when it changed. Because only the one process that performs the live fetch reaches that point, N concurrent sessions produce ~1 record per 180s window with no extra coordination.Plus:
.1.jsonlfile bounds growth.Config / UI
New
usageTrackersettings section (additive, defaulted β no settings version bump) and aπ Usage TrackerTUI screen: enable toggle, API logging toggle, heartbeat interval, rotation size, and the resolved log path. When API logging would introduce polling for a user with no usage widgets configured, the screen says so explicitly.Users who only want the free stdin signal can turn API logging off and never cause an API call they weren't already making.
What it does NOT do
Testing
bun run lint,bun test(1919 tests, including ~50 new ones covering canonicalization/signatures, dedup, heartbeats, rotation, corrupt state, unwritable dirs, and the prefetch gate),bun run buildall green.