feat(sidebar): display input/cache tokens with cache percentage in context panel#1356
Open
walker83 wants to merge 1 commit into
Open
feat(sidebar): display input/cache tokens with cache percentage in context panel#1356walker83 wants to merge 1 commit into
walker83 wants to merge 1 commit into
Conversation
…ntext panel Show breakdown of non-cached input tokens vs cached tokens in the right-side Context panel. The cache percentage (cache / total input) helps users instantly gauge how much their API calls benefit from cache pricing. Works on both MiMo-Code and OpenCode.
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
Enhance the right-side Context panel to display a breakdown of non-cached input tokens vs cached tokens, along with the cache hit percentage.
Before:
After:
Why
Cache read pricing is 1/5 to 1/10 of regular input pricing (e.g. Anthropic: $0.30/M vs $3.00/M tokens). Users need immediate visibility into their cache hit ratio to optimize costs.
How
context.tsxsidebar plugin to extractinput,cache(read + write), andcachePercentfrom the last assistant message tokensLocale.number()compact format (1K/1.5M)cachePercentisMath.round(cache / totalInput * 100)with denominator guard (totalInput > 0)input > 0 || cache > 0Compatibility
This feature works on both MiMo-Code and OpenCode — the change is in the shared TUI sidebar plugin (
packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx) and uses only the existingAssistantMessage.tokensdata model which is identical across both codebases.