feat(statusline): show context-token usage below the buddy - #123
Open
skpalan wants to merge 1 commit into
Open
Conversation
Capture the Claude Code status JSON from stdin (previously drained to /dev/null), read the latest usage block from the session transcript, and render a centered "<tokens> <pct>%" line under the buddy name, e.g. "77.3k 7%". - Sums input_tokens + cache_read_input_tokens + cache_creation_input_tokens to approximate the current context size. - Detects 1M-context models (id contains "1m"/"[1m]") for the percentage denominator; defaults to 200k otherwise. - Degrades silently: no transcript / no usage / empty stdin yields no line, so existing behaviour is unchanged when the data is absent.
Owner
|
Hey @skpalan — thanks for this fix! The only thing blocking it from getting CI + review is the DCO check: the commit(s) are missing a Quick fix from your branch: git commit --amend -s --no-edit # single commit
# or, for multiple commits:
git rebase --signoff origin/main
git push --force-with-leaseOnce DCO goes green we can run CI and get this reviewed — it's a small, wanted change. 🤖 Created with the help of AI (Claude Fable 5). |
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
Adds a small context-token readout under the buddy in the status line, e.g.:
How
The status line script already received Claude Code's status JSON on stdin but discarded it (
cat > /dev/null). This captures it instead and:transcript_path+model.idfrom the status JSON.usageblock in the transcript JSONL and sumsinput_tokens + cache_read_input_tokens + cache_creation_input_tokensto approximate the live context size.1m/[1m]→ 1,000,000, otherwise 200,000 — and renders<tokens> <pct>%, centered under the name.Safety / compatibility
usageblock, or empty stdin → no line is added, so behaviour is unchanged when the data isn't there.bash -nclean; verified rendering against a synthetic transcript on both 1M and 200k models.Open question for maintainers
It's currently always-on. Happy to gate it behind a
showTokensflag inconfig.json(and a/buddy statusline tokens on|offtoggle) if you'd prefer it opt-in — let me know and I'll add it.