anomalyco / anomalyco/opencode

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

Open
#42,776 3 comments 1 reaction 1 assignee View on GitHub

@MrMushrooooom is already working on this.

Since Aug 15, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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 #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
  • #16513 — merged usage endpoint this builds on
  • #16017 — original request for the usage API
  • #16036 — similar ask for Zen credits in TUI, closed not planned before the endpoint existed; this is scoped to Go plan windows via the official API
  • #41981 — monetary usage fields (follow-up dependency)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.