You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(cli): status line should degrade gracefully when ctx/token usage is unavailable #3371
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
When modelContextWindow is known but contextRemaining is not yet available (fresh session / provider doesn't report usage), render ctx ?/<window> (dim) instead of nothing.
When neither is known, keep the segment hidden (current behavior) — no window to anchor a fallback.
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.
Activity
me2seeks commentedon Aug 21, 2026
I'm working on this issue.
feat(cli): degrade status-line ctx segment to ?/window when usage is …
feat(cli): degrade status-line ctx segment to ?/window when usage is …
fix(runtime): persist contextRemaining on the stored TokenUsageMessage (
chore(nsh): sync upstream through a901baa2e (0.7.2)
chore(nsh): sync upstream through a901baa2e (0.7.2) (#7325)