feat(tui): show per-message input/output token counts#24434
Open
kunalkohli wants to merge 1 commit intoanomalyco:devfrom
Open
feat(tui): show per-message input/output token counts#24434kunalkohli wants to merge 1 commit intoanomalyco:devfrom
kunalkohli wants to merge 1 commit intoanomalyco:devfrom
Conversation
Add input/output token counts to two locations: 1. The per-message metadata footer (▣ line) after each assistant response, displayed as '12.3K↓ 1.2K↑' alongside mode, model, and duration. 2. The sidebar context panel, showing last message's input/output breakdown. Input tokens include cache reads (input + cache.read). Output tokens include reasoning (output + reasoning). Only shown when the message has non-zero token data. Closes anomalyco#24433
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.
Issue for this PR
Closes #24433
Relates to #13003, #17449, #17056
Type of change
What does this PR do?
Adds per-message input/output token counts to two places in the TUI:
1. The metadata footer under each assistant response
Before:
After:
Where ↓ = input tokens (including cache reads), ↑ = output tokens (including reasoning).
2. The sidebar context panel
Adds a new line showing last message's input/output breakdown:
Design decisions:
tokens.input + tokens.cache.read(total tokens sent to the model)tokens.output + tokens.reasoning(total tokens generated by the model)Locale.number()formatter for compact K/M suffixestheme.textMutedstyle for consistencyFiles changed:
routes/session/index.tsx— add token display to the metadata footerfeature-plugins/sidebar/context.tsx— add input/output line to sidebarHow did you verify your code works?
bun run --filter opencode typecheckexits 0 (no type errors)Checklist