Repository navigation
[FEATURE]: Display token usage information in the TUI #13003
Description
Activity
- addeddiscussionUsed for feature requests, proposals, ideas, etc. Open discussionUsed for feature requests, proposals, ideas, etc. Open discussion
on Feb 10, 2026 github-actions commented
on Feb 10, 2026 on Feb 10, 2026 – with GitHub ActionsContributorMore actionsThis issue might be a duplicate of or closely related to existing feature requests. Please check these issues:
- Add /context command to display session token usage #10575: Add /context command to display session token usage
- [FEATURE]: Near-Real-Time Token and Cost Visibility #10354: Near-Real-Time Token and Cost Visibility
- [FEATURE]: Session context usage (similar to /context in Claude) #6152: Session context usage (similar to /context in Claude)
- [FEATURE] Add unified usage tracking via /usage (#9545) #9281: Add unified usage tracking via /usage
- [Feature Request] Implement /stats command for visual usage insights (similar to Claude Code) #6767: Implement /stats command for visual usage insights
These all propose similar solutions for displaying token usage and cost information, with some variation in approach (command-based vs. status bar vs. visual stats). You may want to review how these align with your proposal and consolidate efforts if appropriate.
For keybind-related aspects (like Option 3's suggested
ctrl+x ttoggle), also check the pinned keybinds documentation: #4997I would find Option 4 extremely useful.
Reacted by MrSanchez, Tom Clabault, Haltarys and OxygenMake the cli status customizable like claude code
- added a commit that references this issue
on Mar 25, 2026 I would agree, option 4 would be great.
Reacted by MrSanchez and Christian PaniaguaThis should probably rely on OTEL which is a feature being asked/discussed within the community and has yet to be fully supported.
I think also would be amazing to show an estimate in how many tokens the current message im about to send will be.
this is because sometimes i paste logs and i would like to change model if i know i will trigger compactation (e.g. to mimo )
- removeddiscussionUsed for feature requests, proposals, ideas, etc. Open discussionUsed for feature requests, proposals, ideas, etc. Open discussion
on May 3, 2026 Two sidebar plugins already cover most of these use cases today:
- opencode-visual-cache — main-session token breakdown (input/output/cache/system),
per-model pricing, slash commands for settings.
https://github.com/Hotakus/opencode-visual-cache - opencode-cache-hit — cache hit rate, token totals, cost in multiple currencies,
sub-agent rollup (child sessions), optional JSONL timeline export.
https://github.com/zhumengzhu/opencode-cache-hit
Both read from
api.state.session, so the data pipeline is already established —
no new tracking logic needed on the OpenCode side.- opencode-visual-cache — main-session token breakdown (input/output/cache/system),
no this shows only the current context size and when known the cost amount
Reacted by James M. Kerfootliudongyan13701205717-source commented
on Aug 9, 2026 More actionsFree-tier / pay-as-you-go users need this visibility most, especially to decide when to compact. I'd also settle for the /usage command (Option 2) as the MVP.
i think its easy to also provide than a toogle to also show it in the status bar or the bottom area. I think the hard part is to get the information in the first place from all the different provider.
But yeah i would also be happy if i could use /usage at lest and if it would than be exposed to some internal api at least, so i could let create a plugin to add it myself than.liudongyan13701205717-source commented
on Aug 15, 2026 More actions+1, displaying token usage in the TUI is very useful for cost tracking; still relevant.
Reacted by ultimatedirty, Ayan Roy and pmaaszhi! I built a small opencode TUI plugin: /context shows exactly how the built-in Context panel number is composed — input (no cache), output, reasoning, cache read/write, cache hit rate and cost — plus the session-wide total. When you delegate with task, it walks the child sessions and adds a Subagents block and a combined total (subagent usage is excluded from the parent's panel).
Zero runtime dependencies, never calls an LLM, exact numbers (no estimates). Install with opencode plugin opencode-context-usage (restart after). Repo: https://github.com/angeloper86/opencode-context-usage — feedback and issues welcome!I just finished building this into the Context tab of the desktop app UI (still needs localization) on my fork and I'd like to submit it as a PR soon, but I built it as a frontend calculation and I'm now realizing the devs may wish to build it into the client backend/core instead.
Regardless, dumping a short screen-recording of how I laid out the UI in case it helps. I should also note that I renamed the "Context" tab to "Stats" since that's a more accurate description now.
I essentially decided to have two sets of token stats... one for the context and a second for the entire session. I overwhelmingly rely on the session stats and I have no idea why anyone would care about more than just total tokens used in the context and percentage used... but I don't see any point in removing those stats either. Maybe someone cares about the other stuff.
The OpenCode v2 TUI shows token usage. The sidebar Context panel shows tokens, the percentage of the context window used, and cost. The prompt footer shows context usage too.
Added in #19347 and carried into v2 in #31049. A more detailed per-category breakdown (like Claude's
/context) is tracked in #6152.Closing as completed. If something doesn't work on v2, please open a new issue.
Reacted by Tsung-Han Yu, Alexandr and zhumengzhu


Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
Currently, token usage information (input tokens, output tokens, remaining budget) is tracked internally but not visible to users in the OpenCode TUI. This makes it difficult for users to:
Proposed Solution
Display token usage information in the OpenCode TUI interface. Possible implementation approaches:
Option 1: Status Bar Display
Add token usage to the bottom status bar (similar to how file path or mode is displayed):
Option 2: New
/usageor/tokensCommandAdd a slash command that displays detailed token usage:
Option 3: Toggle-able Detail View
Add a keybind (e.g.,
ctrl+x tfor tokens) to toggle token usage display in the conversation view, showing per-message token counts.Option 4: Combination Approach
/usagecommand for comprehensive breakdownBenefits
Additional Context
The token usage data is already being tracked (visible in system messages on the backend), so this feature would primarily involve exposing existing data to the UI rather than implementing new tracking logic.
Related Features
/compactcommand by helping users understand when compaction is neededcompaction.autoconfig)Suggested Configuration
Allow users to customize this via config:
{ "tui": { "show_token_usage": true, "token_display_format": "compact" } }