Skip to content

Cost tracking is dead for all non-DeepSeek models — pricing table needs expansion #3066

@Hmbown

Description

@Hmbown

Problem

crates/tui/src/pricing.rs pricing_for_model returns None for everything except deepseek* and Xiaomi MiMo. The turn/session cost line, cache-savings readout, and background cost accrual are all dead when running Kimi, Qwen, GLM, MiniMax, OpenAI, Arcee, or any OpenRouter-curated model.

The sidebar always renders a cost line even when no pricing exists — it shows cost: <$0.0001 (misleading "free") because format_cost_amount floors at <$0.0001.

Current state

  • crates/tui/src/pricing.rs:109-137pricing_for_model matches xiaomi/mimo* and contains("deepseek"), returns None otherwise.
  • crates/tui/src/pricing.rs:279-288format_cost_amount renders <$0.0001 for zero-cost, which looks like "free" rather than "no data".
  • Cache telemetry is already normalized: crates/tui/src/client.rs:1403-1410 maps OpenAI-style cached_tokens into Usage.prompt_cache_hit_tokens, so the math works for any provider once a table row exists.
  • Catalog precedent: known_context_window_for_model in crates/tui/src/models.rs:250-279 is the static curated-model match-table pattern to copy.

Proposed fix

  1. Change ModelPricing.cny to Option<CurrencyPricing> (DeepSeek/MiMo keep Some, new USD-only rows use None).
  2. Extend pricing_for_model_at with a static match table covering the curated catalog: kimi-k2.6, z-ai/glm-5.1, minimax/minimax-m3, qwen/qwen3.6-plus, trinity-large-thinking, gpt-5.5, etc. Source prices from OpenRouter API; if unverifiable, omit the row.
  3. Add pub fn has_pricing_for_model(model: &str) -> bool.
  4. Sidebar fallback: when has_pricing_for_model is false AND session total is 0.0, render cost: n/a (no pricing data for <model>) instead of <$0.0001.
  5. CNY fallback: when cost_currency is CNY but estimate has usd > 0.0 and cny == 0.0, display USD amount.

Acceptance criteria

  • pricing_for_model returns Some for at least: kimi-k2.6, z-ai/glm-5.1, qwen/qwen3.6-plus, trinity-large-thinking, gpt-5.5
  • Sidebar shows cost: n/a (no pricing data for <model>) for unpriced models with zero accrued cost
  • With cost_currency = cny and a USD-only model, cost line shows $ not <¥0.0001
  • All existing DeepSeek/MiMo pricing tests still pass

Verification

cargo test -p codewhale-tui pricing
cargo test -p codewhale-tui cost

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmodel-labModel Lab open-model discovery, evaluation, routing, and export workflowstuiTerminal UI behavior, rendering, or interactionv0.8.61Targeted for CodeWhale v0.8.61

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions