fix: render extra usage segment + adopt clone-based install#27
Merged
Conversation
Claude Code's statusline JSON input exposes five_hour and seven_day rate limits but never extra_usage. The previous logic gated the OAuth usage API fetch behind !effective_builtin, so once Claude Code began supplying rate_limits (common case) the API was never called and the extra segment never rendered. - Always refresh the API cache when stale (still 60s-throttled); builtin rate_limits take precedence for 5h/7d rendering. - Share extra_usage rendering across builtin and API-fallback branches via render_extra_usage / Format-ExtraUsage helpers. - Preserve extra_usage inside the builtin branch's cache snapshot so a freshly fetched value is not clobbered on the next tick. - Clean up the empty stampede-sentinel cache file on failed fetch so a transient API error does not suppress retries for a full cache window. - Wrap the PowerShell helper in try/catch since it is now also called from the builtin branch, which has no outer catch.
Paste-install leaves users stranded on whatever version they pasted and makes updates a manual chore. Leading with a git-clone of the repo turns updates into a single `git pull` and gives users a stable, authoritative source. - New INSTALL.md: step-by-step install guide written for Claude Code to execute when the user says "clone this repo and use it as my status bar", covering OS detection, clone location, settings.json per shell, restart, update, and uninstall. - README: install section now leads with the clone flow and links to INSTALL.md for details; paste-install kept as a fallback for environments without git. - README: updated cache path to reflect the per-config-dir hash suffix and noted that update notifications also cache for 24h.
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
extrasegment never rendering once Claude Code began supplyingrate_limitsin the statusline stdin JSON (the common path).INSTALL.mdso Claude has an authoritative step-by-step; paste-install stays as a fallback.Code changes
statusline.sh+statusline.ps1effective_builtingate on the usage-API fetch. Claude Code's stdinrate_limitsonly exposesfive_hour/seven_day—extra_usagestill has to come fromhttps://api.anthropic.com/api/oauth/usage.render_extra_usage/Format-ExtraUsage) used by both the builtin and API-fallback branches..extra_usageinside the builtin branch's cache snapshot so a freshly fetched value is not clobbered on the next tick.README.mdgit pullpath.INSTALL.md(new)settings.jsonsnippets, restart, update, uninstall, requirements.How to test
Fix verification (macOS / Linux)
rm -f /tmp/claude/statusline-usage-cache-*.jsonextra_usage.is_enabled=trueto simulate a Pro/Max account with extra credits enabled:rate_limits(the builtin path):| extra $12.34/$100.00segment. Before this PR, the segment was silently dropped.Empty-sentinel cleanup
rm -f /tmp/claude/statusline-usage-cache-*.jsonCLAUDE_CODE_OAUTH_TOKEN=nope echo '{"model":{"display_name":"C"}}' | bash statusline.shInstall docs
INSTALL.mdand confirm thesettings.jsonsnippets match the shell the user is running Claude Code in.--dry-runstyle check:git ls-remote https://github.com/daniel3303/ClaudeCodeStatusLineshould respond.Notes
/api/oauth/usageper minute perCLAUDE_CONFIG_DIR(previously zero). The endpoint is designed for this cadence and the cache is shared across tmux panes via mtime-based stampede locking.1.3.0— bump and tag a release separately when you want users to see the update-available banner.