fix(ui): billing-shape-aware quota chip and modal #43

Merged
alee merged 1 commits from fix/quota-ui-billing-shape-clarity into main 2026-09-06 21:26:41 +00:00
Owner

What this PR does

Follow-up UI polish on #40: the admin quota chip and modal plus the TUI quota panel now tell two separate, honest stories instead of one flattened and misleading dollar headline.

Chip

  • Always shows the kWh subscription story: XX.X% · N.NN kWh plan. No more alternating between a dollar balance and a percentage depending on provider state.

Modal — "Provider accounts" section

  • kWh plan hero unchanged (Plan / Metered since reset / Fraction / Reset).
  • One row per provider from quota.by_provider, labeled by billing shape via balance_source: $X credits (N min old) for polled/prepaid providers (OpenRouter), $X overage allowance for telemetry providers (NeuralWatt), account balance not configured otherwise.
  • Staleness suffix computed from balance_at so a stalled poller is visible.

Signed small-balance rendering

  • Genuinely negative tiny balances render as ~$0.00 (slight overage) (NeuralWatt's normal -$0.004 overage reading keeps its sign — overage vs under-credit remain distinguishable).
  • Positive tiny balances render as <$0.01. Exact zero renders as $0.00.
  • JS (index.html) and Python (tui.py) implementations are byte-equivalent; covered by pinned assertions in both test suites.

TUI mirrors the same shape: kWh plan rows up top, labeled per-provider rows below; the total_balance_usd headline is gone.

Out of scope / deliberately untouched

  • No backend changes (metrics/poller/routing/dispatcher/config all untouched).
  • No navbar changes — that block belongs to #41 (already merged).
  • /metrics shape unchanged since #40.

Verification

  • python -m pytest -q in the worktree: 1463 passed, 0 failures.
  • Throwaway-port QA (8081, temp dir + seeded DB): /metrics and /admin/api/snapshot carry both providers with correct balance_source values; served admin HTML contains all new rendering strings; TUI renders the new strings against live data. Pre-existing user TUI processes were left running (read-only from them; nothing killed on 8080).

Post-merge action

Restart the production dispatcher to serve the new admin HTML: systemctl --user restart llm-router.service.

## What this PR does Follow-up UI polish on #40: the admin quota chip and modal plus the TUI quota panel now tell two separate, honest stories instead of one flattened and misleading dollar headline. ### Chip - Always shows the kWh subscription story: `XX.X% · N.NN kWh plan`. No more alternating between a dollar balance and a percentage depending on provider state. ### Modal — "Provider accounts" section - kWh plan hero unchanged (Plan / Metered since reset / Fraction / Reset). - One row per provider from `quota.by_provider`, labeled by billing shape via `balance_source`: `$X credits (N min old)` for polled/prepaid providers (OpenRouter), `$X overage allowance` for telemetry providers (NeuralWatt), `account balance not configured` otherwise. - Staleness suffix computed from `balance_at` so a stalled poller is visible. ### Signed small-balance rendering - Genuinely negative tiny balances render as `~$0.00 (slight overage)` (NeuralWatt's normal -$0.004 overage reading keeps its sign — overage vs under-credit remain distinguishable). - Positive tiny balances render as `<$0.01`. Exact zero renders as `$0.00`. - JS (index.html) and Python (tui.py) implementations are byte-equivalent; covered by pinned assertions in both test suites. TUI mirrors the same shape: kWh plan rows up top, labeled per-provider rows below; the `total_balance_usd` headline is gone. ## Out of scope / deliberately untouched - No backend changes (metrics/poller/routing/dispatcher/config all untouched). - No navbar changes — that block belongs to #41 (already merged). - `/metrics` shape unchanged since #40. ## Verification - `python -m pytest -q` in the worktree: 1463 passed, 0 failures. - Throwaway-port QA (8081, temp dir + seeded DB): `/metrics` and `/admin/api/snapshot` carry both providers with correct `balance_source` values; served admin HTML contains all new rendering strings; TUI renders the new strings against live data. Pre-existing user TUI processes were left running (read-only from them; nothing killed on 8080). ## Post-merge action Restart the production dispatcher to serve the new admin HTML: `systemctl --user restart llm-router.service`.
alee added 1 commit 2026-09-06 21:23:26 +00:00
alee merged commit 84359f6fe3 into main 2026-09-06 21:26:41 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alee/6krrt#43