Skip to content

feat(cli): status line should degrade gracefully when ctx/token usage is unavailable #3371

Description

@me2seeks

Context

The TUI status line already implements a token/context segment (#1067): ctx used/window pct% (yellow >80%, red >95%), plus $cost and cache % in renderMakaPiStatusLine (packages/cli/src/pi-transcript.ts).

However, the segment is silently absent unless ALL of these hold:

  • the connection's selected model has a resolvable contextWindow (declared via relay profile, connection model list, or static metadata), and
  • the provider reports per-step input tokens so the runtime can emit contextRemaining in token_usage (ai-sdk-backend.ts), and
  • at least one turn has completed.

Observed on an opencode-go connection: Maka · Full access · muse-spark-1.2-contributor · opencode-go · ~/project/maka-agent — no ctx, no cost. The user cannot tell whether the connection doesn't report usage, the model lacks a declared context window, or just no turn has finished yet.

Reference: pi's footer design (badlogic/pi-mono)

pi's interactive footer (packages/coding-agent/src/modes/interactive/components/footer.ts) always renders a context segment and degrades explicitly:

  • pct%/window with color thresholds (warning >70%, error >90%)
  • fallback ?/200k when usage is unknown but the window is known
  • cumulative ↑in ↓out R/W CH% $cost stats alongside

Proposal

  1. When modelContextWindow is known but contextRemaining is not yet available (fresh session / provider doesn't report usage), render ctx ?/<window> (dim) instead of nothing.
  2. When neither is known, keep the segment hidden (current behavior) — no window to anchor a fallback.
  3. Follow-up: verify whether the opencode-go relay reports per-step input tokens; if it does but contextRemaining still isn't emitted, fix that path.

Acceptance criteria

  • A session on a connection with a known context window shows ctx ?/<window> before the first completed turn, and ctx used/window pct% after.
  • Existing color thresholds and the omit-when-unknown-window behavior are unchanged.

Metadata

Metadata

Assignees

No one assigned

    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