Skip to content

feat(tui): surface pay-per-use credits in the account list and details - #62

Merged
xjoker merged 2 commits into
devfrom
cursor/tui-credits-column-5a91
Aug 26, 2026
Merged

feat(tui): surface pay-per-use credits in the account list and details#62
xjoker merged 2 commits into
devfrom
cursor/tui-credits-column-5a91

Conversation

@xjoker

@xjoker xjoker commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Problem / intended behavior

The TUI never gave pay-per-use credits a stable home, even though the data (UsageInfo.credits_balance / unlimited_credits) is already parsed, cached, and shown in the CLI (print_usage_line) and JSON output. Two gaps:

  1. The account list table had no credits column.
  2. The Enter → Account details popup only showed credits as a conditional dim line inside usage_meta, and only when a balance existed — so subscription accounts (e.g. Team, which have no credits_balance) had no credits slot at all.

This adds a Credits column to the list and a dedicated Credits field to the details popup.

Implementation boundary

src/tui/ui.rs, src/tui/menu.rs, src/tui/app.rs — rendering only, no data-flow changes.

  • List column (ui.rs): new Credits header + per-row cell after Cards. Helpers credits_table_text / credits_table_color:
    • Text mirrors the CLI wording: unlimited / $x.xx / -- (the last for accounts without the credits system, consistent with the CLI hiding $0.00).
    • Color reuses the color::credits low-balance thresholds (≥10 green, ≥2 yellow, else red) mapped to the TUI palette. It intentionally does not call color::credits, which emits ANSI escapes that would corrupt ratatui output.
    • Idle/Error--, Loading..., matching neighboring columns.
    • Widened the fixed-column budget in table_text_widths 64 → 75 for the extra width-10 column + gap.
  • Details popup (menu.rs): an always-present Credits line under Quota pools, styled like the Reset cards field, showing $x.xx / unlimited / not available. Color shared via credits_table_color (now pub(super)).
  • Dedup (app.rs): removed the old conditional credits entry from usage_meta so the balance isn't shown twice.

Out of scope: a credits line in the bottom render_usage_gauges detail panel, and a credits sort mode.

Tests

  • credits_column_text_and_color_track_the_balance_state — wording + green/yellow/red/dim thresholds.
  • account_table_renders_the_credits_column — renders the real table via TestBackend, asserts the Credits header and a $15.50 balance.
  • account_details_show_a_dedicated_credits_field — renders the popup, asserts the Credits field with $15.50 (green) and the not available placeholder for no-credits accounts.
  • Verified existing table_text_widths tests still hold under the 64→75 change.

Verification (Linux)

cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all — all pass, 0 failed.

Live run with a real logged-in account (Team plan, no pay-per-use credits) using the installed release binary:

List column:

│   Alias Emai Plan Status 5h     7d     5h Reset     7d Reset     Cards   Credits │
│*  oai07 oai0 Team OK     100%   100%   19:20        09-01 14:20  1       --      │

Enter → Account details (new field under Quota pools):

 Quota pools
 Main
 5h  ░░┃░░░░░░░░░░░░░░░░░░░  100% left · reset 4h35m (19:20)
 7d  ┃░░░░░░░░░░░░░░░░░░░░░  100% left · reset 6d23h (09-01 14:20)
 Credits  not available
 Reset cards  1 available

Team accounts correctly read not available (no credits_balance); pay-per-use accounts render $x.xx / unlimited (covered by the render tests).

Unverified

  • macOS / Windows rendering (relies on the CI matrix).
  • Live $x.xx balance shown only via TestBackend/unit fixtures — the available real account is a Team plan without credits.
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 25, 2026 14:31
Show each account's pay-per-use credits balance in the TUI account
table, next to the reset Cards column. Reuses the CLI credits wording
("unlimited" / "$x.xx" / "--") and the color::credits low-balance
thresholds mapped to the TUI palette. Widen the fixed-column budget so
alias/email/plan still shrink correctly for the extra column.

Co-authored-by: xJoker <xjoker@users.noreply.github.com>
Enter-to-open account details only surfaced credits as a conditional
dim line inside usage_meta, and only when a balance existed — so
subscription accounts (e.g. Team) had no credits slot at all. Add an
always-present "Credits" field under Quota pools showing the balance,
"unlimited", or "not available", colored with the shared
credits_table_color thresholds. Drop the now-redundant usage_meta
credits line to avoid duplication.

Co-authored-by: xJoker <xjoker@users.noreply.github.com>
@cursor cursor Bot changed the title feat(tui): add Credits column to the account list feat(tui): surface pay-per-use credits in the account list and details Aug 25, 2026
@xjoker
xjoker marked this pull request as ready for review August 25, 2026 23:43
@xjoker
xjoker merged commit acf2460 into dev Aug 26, 2026
3 of 4 checks passed
@cursor
cursor Bot deleted the cursor/tui-credits-column-5a91 branch August 26, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants