Skip to content

feat: Add used or remaining usage percentage preference - #8308

Closed
mmarabel wants to merge 1 commit into
stablyai:mainfrom
mmarabel:gatsby74/used-remaining
Closed

mmarabel wants to merge 1 commit into
stablyai:mainfrom
mmarabel:gatsby74/used-remaining

Conversation

@mmarabel

@mmarabel mmarabel commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a Usage percentages segmented setting under Appearance → Window & Sidebar → Status Bar so users can choose Used or Remaining.
  • Persist the choice through the existing UI settings pipeline and normalize legacy or invalid values to the current Used behavior.
  • Apply the preference to status-bar labels, provider detail panels, inactive-account previews, and Claude Fable usage across Claude, Codex, Gemini, Antigravity, OpenCode Go, Kimi, MiniMax, and Grok.
  • Keep meter fill and color consumption-based in both modes, so empty/green still means little quota consumed and full/red means near the limit.

The previous quota-display update made % used permanent to remove ambiguous meter semantics. That resolved the immediate mismatch with provider harnesses but removed the earlier remaining-capacity view. This restores user choice while keeping the newer meter direction and explicit labels.

Fixes #7551

Fixes #8304

Screen Recording

trimmed.used.remaining.mov

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — Node 24.18.0: 2,696 files passed, 28,331 tests passed, 6 files / 40 tests skipped
  • pnpm build — desktop, web, relay, CLI, and native macOS targets
  • Added high-quality regression tests for percentage normalization, used/remaining formatting, preference persistence and hydration, settings search and interaction, Claude Fable/inactive-account rows, provider panel copy, and all eight current usage providers

AI Review Report

Reviewed the full diff after rebasing the feature onto current upstream/main, including persistence, renderer/web hydration, settings placement, provider rendering, localization, and regression coverage.

  • Correctness: verified invalid persisted values default to Used, displayed percentages are finite and bounded, Remaining is the complement of provider-reported usage, and bar fill/color continue to represent consumption. The review caught that settings search needed to match “remaining” explicitly and that test translation mocks needed interpolation support; both were corrected and regression-tested.
  • Current provider coverage: traced the shared provider menu/panel path for Claude, Codex, Gemini, Antigravity, OpenCode Go, Kimi, MiniMax, and Grok, plus Claude Fable and inactive-account preview rows.
  • Cross-platform: explicitly checked macOS, Linux, and Windows. This is platform-neutral UI/persistence logic and introduces no shortcuts, shortcut labels, path handling, shell behavior, or Electron platform branches.
  • Local/remote/SSH/web: the preference uses the existing client UI state RPC and web-state merge path. It changes presentation only and makes no local-host assumption, so remote and SSH-backed usage data follows the same renderer behavior.
  • UI quality: uses the existing SettingsRow and SettingsSegmentedControl primitives, documented tokens, localized full labels, and the redesigned Appearance status-bar section. The search catalog was split into a focused module to stay within repository size rules.
  • Performance: adds a small store selector and pure clamp/complement formatter to already-rendering usage surfaces; no polling, provider fetches, subscriptions, or unbounded state were added.

No blocking review issue remains.

Security Audit

  • The new persisted value is a two-value enum validated by the existing UI RPC schema and normalized again when read or merged.
  • Provider percentages are treated as external data and checked for finiteness, clamped to 0–100, and rounded before display.
  • The change adds no command execution, shell input, filesystem/path handling, network request, authentication flow, credential or secret handling, dependency, or new IPC channel.
  • Persistence continues through the existing client UI settings boundary; no provider account data or execution-host configuration is changed.

No new security risk or follow-up was identified.

Notes

  • Used remains the default so existing users retain the quota behavior introduced by the latest release; Remaining is opt-in.
  • Meter direction does not reverse in Remaining mode. Only the number and explicit used / left copy change.
  • Verified in the macOS dev app. Linux and Windows use the same platform-neutral renderer and persistence paths and are covered by the full test, typecheck, and production-build checks.

@mmarabel mmarabel changed the title Add used or remaining usage percentage preference feat: Add used or remaining usage percentage preference Jul 11, 2026
@mmarabel
mmarabel marked this pull request as ready for review July 11, 2026 17:59
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a persisted usagePercentageDisplay preference with used and remaining modes. The preference is normalized across shared state, persistence, hydration, web merging, and RPC validation. Appearance settings expose a searchable segmented control for selecting the mode. Status-bar inline usage bars, provider segments, and provider panels format labels according to the selection while preserving consumption-based bar widths. Tests cover normalization, persistence, settings interaction, label formatting, and status-bar rendering across localized UI strings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the requested used/remaining toggle, default to Used, persist it, and apply it across the listed usage views.
Out of Scope Changes check ✅ Passed No clear out-of-scope changes are evident; the diff stays focused on the usage percentage preference and related UI/persistence work.
Title check ✅ Passed The title clearly summarizes the main change: adding a used/remaining usage percentage preference.
Description check ✅ Passed The description includes summary, screen recording, testing, AI review, security audit, and notes, matching the template well enough.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmethystLiang

Copy link
Copy Markdown
Contributor

Thanks @gatsby74 for the thorough current-main implementation. Its persistence, provider-coverage, and test hardening were incorporated into #7574, and the merged commit retains you as a co-author while preserving @suiramdev as the original primary contributor. Closing this as superseded by the merged #7574.

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.

[Feature]: Show amount 'left' per account, not amount 'used' [Feature]: Toggle to show Session Usage as "used" instead of "remaining"

2 participants