GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Display token usage information in the TUI · Issue #13003 · anomalyco/opencode

[FEATURE]: Display token usage information in the TUI #13003

New issue
Copy link
New issue
Copy link
Closed
Closed
[FEATURE]: Display token usage information in the TUI#13003
Copy link
Assignees
kitlangton

Description

@xixiaofinland
xixiaofinland
opened on Feb 10, 2026
Issue body actions

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request 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:

  • Monitor costs in real-time during conversations
  • Understand context window consumption
  • Track usage against budget limits
  • Make informed decisions about when to compact sessions

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):

┌─────────────────────────────────────────────────┐
│ [Build Mode]  Tokens: 19.9K/1M (980K remaining) │
└─────────────────────────────────────────────────┘

Option 2: New /usage or /tokens Command
Add a slash command that displays detailed token usage:

/usage

Current Session:
  Input tokens:     12,450
  Output tokens:     7,477
  Cached tokens:     5,200
  Total:            19,927 / 1,000,000
  Remaining:       980,073 (98%)
  
Estimated cost: $0.05 (using claude-sonnet-4-5)

Option 3: Toggle-able Detail View
Add a keybind (e.g., ctrl+x t for tokens) to toggle token usage display in the conversation view, showing per-message token counts.

Option 4: Combination Approach

  • Lightweight display in status bar for at-a-glance monitoring
  • Detailed /usage command for comprehensive breakdown
  • Optional per-message display via toggle

Benefits

  1. Cost Awareness: Users can monitor spending in real-time, especially important for pay-as-you-go models
  2. Budget Management: Helps users stay within monthly limits (especially relevant for OpenCode Zen users with spending caps)
  3. Context Window Management: Users can see when they're approaching token limits and need to compact
  4. Transparency: Makes the AI interaction more transparent and understandable
  5. Educational: Helps users learn which operations consume more tokens

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

  • Ties into the existing /compact command by helping users understand when compaction is needed
  • Complements OpenCode Zen's monthly usage limits feature
  • Could integrate with the auto-compaction feature (compaction.auto config)

Suggested Configuration

Allow users to customize this via config:

{
  "tui": {
    "show_token_usage": true,
    "token_display_format": "compact"
  }
}
Reacted by Alejandro Fernández, Paulo, Matias Paradela, Rohit Gohri, Magnus Källman, Christoph Klingspor, tgwfc1012-cyber, Alexander Kim, Ryan, Alexander Tkachev and 45 more

Activity

  1. xixiaofinland
    added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Feb 10, 2026
  2. github-actions
    assigned
    thdxr
    on Feb 10, 2026
  3. github-actions commented on Feb 10, 2026

    @github-actions
    github-actionsBot
    on Feb 10, 2026 – with GitHub Actions
    Contributor
    More actions

    This 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 t toggle), also check the pinned keybinds documentation: #4997

  4. chimon2000 commented on Mar 12, 2026

    @chimon2000
    chimon2000
    on Mar 12, 2026
    More actions

    I would find Option 4 extremely useful.

    Reacted by MrSanchez, Tom Clabault, Haltarys and Oxygen
  5. ke7in-zz commented on Mar 15, 2026

    @ke7in-zz
    ke7in-zz
    on Mar 15, 2026
    More actions

    Make the cli status customizable like claude code

  6. andrewdunndev
    added a commit that references this issue on Mar 25, 2026

    feat(tui): add persistent token usage display in session footer

    7cb34ff
  7. ForceConstant commented on Apr 6, 2026

    @ForceConstant
    ForceConstant
    on Apr 6, 2026
    More actions

    I would agree, option 4 would be great.

    Reacted by MrSanchez and Christian Paniagua
  8. ThomasCarca commented on Apr 14, 2026

    @ThomasCarca
    ThomasCarca
    on Apr 14, 2026
    More actions

    This should probably rely on OTEL which is a feature being asked/discussed within the community and has yet to be fully supported.

  9. eduardosanzb commented on Apr 15, 2026

    @eduardosanzb
    eduardosanzb
    on Apr 15, 2026
    More actions

    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 )

  10. thdxr
    assigned
    kitlangton
    and unassigned
    thdxr
    on Apr 26, 2026
  11. thdxr
    removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  12. zhumengzhu commented on Jun 10, 2026

    @zhumengzhu
    zhumengzhu
    on Jun 10, 2026
    More actions

    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.

  13. VictorVow commented on Jul 7, 2026

    @VictorVow
    VictorVow
    on Jul 7, 2026
    More actions

    Seems to be implemented now as a Status Bar Display:

    Image
  14. Xyz00777 commented on Jul 9, 2026

    @Xyz00777
    Xyz00777
    on Jul 9, 2026
    More actions

    no this shows only the current context size and when known the cost amount

    Reacted by James M. Kerfoot
  15. liudongyan13701205717-source commented on Aug 9, 2026

    @liudongyan13701205717-source
    liudongyan13701205717-source
    on Aug 9, 2026
    More actions

    Free-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.

  16. Xyz00777 commented on Aug 9, 2026

    @Xyz00777
    Xyz00777
    on Aug 9, 2026
    More actions

    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.

  17. liudongyan13701205717-source commented on Aug 15, 2026

    @liudongyan13701205717-source
    liudongyan13701205717-source
    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 pmaasz
  18. angeloper86 commented on Sep 10, 2026

    @angeloper86
    angeloper86
    on Sep 10, 2026
    More actions

    hi! 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!

  19. Blaze147 commented on Sep 23, 2026

    @Blaze147
    Blaze147
    on Sep 23, 2026
    More actions

    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.

    GIF:
    image

  20. neriousy commented on Oct 1, 2026

    @neriousy
    neriousy
    on Oct 1, 2026
    Member
    More actions

    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
  21. neriousy
    closed this as completedon Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kitlangton
    kitlangton

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.