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
tui: show the cost estimate in the mini/run footer #60653
Follow-up to #59864 (which closes #59861). The experimental["cost-estimate"] experiment currently covers the main TUI sidebar and prompt footer only. In mini/run mode a provider that reports $0 still shows no spend at all.
Current behavior
packages/tui/src/mini/footer.view.tsx renders spend from props.state().usage.cost, which is populated per step from session.step.ended in stream-v2.transport.ts (event.data.cost || undefined). A reported zero is therefore indistinguishable from "cost not reported" and the line disappears.
What it needs
Expose the experiment to mini: RunTuiConfig in mini/types.ts picks a fixed set of config fields and does not include experimental.
Session-level totals: state.usage is per-step, not accumulated. The estimate needs the session's tokens/model (an SDK session.get, which the runtime already performs for resume and subagent discovery).
Tiered models: per-call tier surcharges need the loaded assistant steps, like costEstimate in packages/tui/src/util/session.ts does for the main footer.
Decide scope: the current session only, or the root family like the main TUI. The family needs listing children; the main TUI gets that for free from the client store.
Acceptance criteria
With experimental["cost-estimate"] = true and a provider reporting cost: 0, the mini footer shows ≈ $X from catalog prices.
Positive reported costs keep precedence.
Sub-cent spend renders as ≈ <$0.01.
Sessions without catalog pricing omit the estimate instead of under-reporting.
Thanks for the detailed follow-up! You're asking for the opt-in experimental["cost-estimate"] catalog-price estimate to work in the mini/run footer too, so that providers reporting $0 still show ≈ $X there, the same as the main TUI sidebar and prompt footer.
This depends on #59864, which adds the experiment and hasn't been merged yet. The maintainers will consider it, including your open question of whether to show only the current session or the whole root session family.
Coming from the positive-cost side of the same code path. This is not covered by the $0 case above, and #60659 would not fix it either.
Environment: opencode v2.3.2 (macOS arm64), model deepseek/deepseek-flash.
Symptom: the mini status line shows $0.00 for the entire session, while the main TUI sidebar shows $0.02 for the same session.
Measured data (session with 23 assistant steps):
value
session cost (session_v2.cost)
$0.015228
largest single step cost
$0.002878
steps with cost >= $0.005
0 of 23
The per-step costs are positive, so the total > 0 || event.data.cost guard passes and the segment is rendered — unlike the $0 case discussed above. But footer.view.tsx formats it with the 2-decimal money formatter:
money.format(0.0004) is "$0.00". On cheap models (DeepSeek here: ~$0.0003–$0.0029 per step) every step rounds to zero, so the line is permanently stuck at $0.00 and no sub-cent value can ever be represented.
Two related details from the same path:
state.usage is only written on session.step.ended; session.usage.updated is not handled by the mini transport, so mini never has the session total — only the last step.
On resume, state.usage starts undefined, so the cost segment is missing until the next step finishes.
Why #60659 doesn't cover this: that PR deliberately keeps the step-reported figure when the provider reports a positive cost ("a provider that reports a cost keeps showing that step's reported figure"); sessionSpend is only used while the recorded session cost is zero. Positive sub-cent costs therefore stay $0.00.
Suggestions, using code that already exists:
Format with formatDollars() from packages/tui/src/util/usage-limits.ts, which already renders <$0.01 for positive amounts below one cent (exactly the acceptance criterion listed above), or at least add the same guard to the mini formatter.
For the positive path, prefer the session total (session.usage.updated, or the session.get the runtime already performs on resume) over event.data.cost — or accumulate the step costs.
Happy to provide the raw DB rows or a repro session export if useful.
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the detailed follow-up! You're asking for the opt-in
experimental["cost-estimate"]catalog-price estimate to work in the mini/run footer too, so that providers reporting$0still show≈ $Xthere, the same as the main TUI sidebar and prompt footer.This depends on #59864, which adds the experiment and hasn't been merged yet. The maintainers will consider it, including your open question of whether to show only the current session or the whole root session family.
Related issues:
/usagecost reportnifl2000 commentedon Nov 21, 2026
Coming from the positive-cost side of the same code path. This is not covered by the
$0case above, and #60659 would not fix it either.Environment: opencode v2.3.2 (macOS arm64), model
deepseek/deepseek-flash.Symptom: the mini status line shows
$0.00for the entire session, while the main TUI sidebar shows$0.02for the same session.Measured data (session with 23 assistant steps):
session_v2.cost)$0.015228$0.002878$0.005The per-step costs are positive, so the
total > 0 || event.data.costguard passes and the segment is rendered — unlike the$0case discussed above. Butfooter.view.tsxformats it with the 2-decimalmoneyformatter:money.format(0.0004)is"$0.00". On cheap models (DeepSeek here: ~$0.0003–$0.0029 per step) every step rounds to zero, so the line is permanently stuck at$0.00and no sub-cent value can ever be represented.Two related details from the same path:
state.usageis only written onsession.step.ended;session.usage.updatedis not handled by the mini transport, so mini never has the session total — only the last step.state.usagestartsundefined, so the cost segment is missing until the next step finishes.Why #60659 doesn't cover this: that PR deliberately keeps the step-reported figure when the provider reports a positive cost ("a provider that reports a cost keeps showing that step's reported figure");
sessionSpendis only used while the recorded session cost is zero. Positive sub-cent costs therefore stay$0.00.Suggestions, using code that already exists:
formatDollars()frompackages/tui/src/util/usage-limits.ts, which already renders<$0.01for positive amounts below one cent (exactly the acceptance criterion listed above), or at least add the same guard to the mini formatter.session.usage.updated, or thesession.getthe runtime already performs on resume) overevent.data.cost— or accumulate the step costs.Happy to provide the raw DB rows or a repro session export if useful.