Skip to content

[FEATURE]: Show OpenCode Go plan usage in the TUI prompt bar #42776

Description

@Tonlex

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

The TUI already shows tokens (context %) · $cost (session-local) in the prompt bar. Go plan subscribers have no way to see their account-wide plan usage from the CLI — the only place it's visible is the web dashboard, so users find out they're near a limit when the gateway starts throttling.

Proposal: append the Go plan's monthly usage percentage next to the existing cost indicator, e.g.:

123K (62%) · $0.15 · Go 4%

The percentage comes from the official endpoint added in #16513 (GET https://opencode.ai/zen/go/v1/usage, Bearer key auth), so no dashboard scraping or hardcoded limits. Only rendered when an opencode-go key is configured; degrades silently otherwise.

Proposed design

Server (~100 lines, packages/opencode)

  • New endpoint that looks up the stored opencode-go API key (existing Auth service), calls /zen/go/v1/usage, returns the monthlyUsage.percent value.
  • 60s TTL cache with background refresh: renders return the stale value instantly while the fetch happens async. (60s, not 5min — usage can move fast on expensive models; community Claude statuslines converge on 30s–2min for quota displays.)

TUI (~20 lines, packages/tui/src/component/prompt/index.tsx)

  • Extend the existing usage memo (line ~266) and its render (line ~1665): append · Go N% when data is available.
  • Between fetches, estimate the delta locally: each completed message on an opencode-go model already carries token usage, and per-model cost rates are known — so show Go ~4.5% (tilde = estimated) that ticks up as you work, snapping to the authoritative value on the next fetch. No extra API calls.

Mockup

┌─────────────────────────────────────────────────────────────┐
│ Ask anything... "refactor this to use Effect"                │
│ Build · opencode-go/deepseek-v4-flash · opencode             │
└─────────────────────────────────────────────────────────────┘
             123K (62%) · $0.15 · Go 4%   ⌘K commands   ⌘I agents

Note: $0.15 is session cost; Go 4% is account-wide (all sessions/machines using the key) — the Go label carries that distinction.

Out of scope for this issue (follow-ups)

  • User-configurable refresh interval / visibility toggle
  • USD amounts ($2.40/$60) — blocked on exposing limits in the API (see [FEATURE]: Expose balance and monetary usage data via the official usage API #41981)
  • Rolling 5h / weekly windows — data is free from the same endpoint; display is a trivial extension
  • Gateway-provided rate-limit headers on ordinary responses (Claude Code-style, zero polling) — cheaper long-term than client polling

Related

Metadata

Metadata

Assignees

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