Skip to content

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

Description

@andrewdunndev

I'd like to see token usage in the session footer as a persistent display rather than relying on toast notifications from plugins. The footer already shows directory, LSP count, MCP count, and permissions. Token usage fits naturally here.

What I'm imagining:

~/project                                    142 tok/s · 4.5M in · 19K out · • 2 LSP · ⊙ 1 MCP

Three data points:

  • tok/s -- live tokens-per-second during streaming (fades or shows last value when idle)
  • in -- cumulative input tokens for the session (compact: K/M suffix)
  • out -- cumulative output tokens for the session

The data is already available in the message store (message.data.tokens has input, output, reasoning, cache breakdowns). The footer component (packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx) would subscribe to message events and accumulate the totals.

For the tok/s calculation: track output tokens and elapsed time during the streaming phase of each assistant turn. Display the rate while streaming, show the final rate for a few seconds after completion, then hide or show "idle".

This is useful for understanding context consumption during long sessions and for comparing model performance across providers.

Happy to submit a PR.

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions