feat(tui): surface pay-per-use credits in the account list and details - #62
Merged
Conversation
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>
xjoker
marked this pull request as ready for review
August 25, 2026 23:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:usage_meta, and only when a balance existed — so subscription accounts (e.g. Team, which have nocredits_balance) had no credits slot at all.This adds a
Creditscolumn to the list and a dedicatedCreditsfield to the details popup.Implementation boundary
src/tui/ui.rs,src/tui/menu.rs,src/tui/app.rs— rendering only, no data-flow changes.ui.rs): newCreditsheader + per-row cell afterCards. Helperscredits_table_text/credits_table_color:unlimited/$x.xx/--(the last for accounts without the credits system, consistent with the CLI hiding$0.00).color::creditslow-balance thresholds (≥10 green, ≥2 yellow, else red) mapped to the TUI palette. It intentionally does not callcolor::credits, which emits ANSI escapes that would corrupt ratatui output.Idle/Error→--,Loading→..., matching neighboring columns.table_text_widths64 → 75 for the extra width-10 column + gap.menu.rs): an always-presentCreditsline underQuota pools, styled like theReset cardsfield, showing$x.xx/unlimited/not available. Color shared viacredits_table_color(nowpub(super)).app.rs): removed the old conditional credits entry fromusage_metaso the balance isn't shown twice.Out of scope: a credits line in the bottom
render_usage_gaugesdetail 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 viaTestBackend, asserts theCreditsheader and a$15.50balance.account_details_show_a_dedicated_credits_field— renders the popup, asserts theCreditsfield with$15.50(green) and thenot availableplaceholder for no-credits accounts.table_text_widthstests 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:
Enter → Account details (new field under Quota pools):
Team accounts correctly read
not available(nocredits_balance); pay-per-use accounts render$x.xx/unlimited(covered by the render tests).Unverified
$x.xxbalance shown only viaTestBackend/unit fixtures — the available real account is a Team plan without credits.