Skip to content

tui: show the cost estimate in the mini/run footer #60653

Open

Description

@augustovicente

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.
  • No change when the experiment is off.

Activity

  1. opencodejr commented on Oct 30, 2026

    @opencodejr
    Contributor

    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.

    Related issues:

  2. nifl2000 commented on Nov 21, 2026

    @nifl2000

    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:

    const money = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" })
    const cost = createMemo(() => (usage()?.cost ? money.format(usage()!.cost!) : ""))

    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:

    1. 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.
    2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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