Repository navigation
feat(status-bar): choose used or remaining usage - #7574
Conversation
📝 WalkthroughWalkthroughThis PR adds a persisted UI setting, Changes
Sequence Diagram(s)sequenceDiagram
participant StatusBarInner
participant AppStore
participant ProviderSegment
participant WindowLabel
StatusBarInner->>AppStore: setUsageShowUsed(!usageShowUsed)
AppStore-->>ProviderSegment: usageShowUsed
ProviderSegment->>WindowLabel: showUsed prop
WindowLabel-->>ProviderSegment: shown percentage (used or left)
Related issues: None identified. Related PRs: None identified. Suggested labels: enhancement, ui, i18n Suggested reviewers: Not determinable from provided context. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/renderer/src/components/status-bar/StatusBar.tsx (2)
911-946: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract repeated left/shown computation into a helper.
The session/weekly/fableWeekly blocks each repeat the same
left/shownformula. Addingshowndoubled the duplicated logic; a small helper keeps the three call sites in sync if the formula changes again.♻️ Proposed refactor
+function computeUsageWindow( + key: string, + w: RateLimitWindow | null | undefined, + showUsed: boolean, + label: string +): { key: string; left: number; shown: number; label: string } | null { + if (!w) return null + const left = Math.max(0, Math.round(100 - w.usedPercent)) + const shown = showUsed ? Math.min(100, Math.max(0, Math.round(w.usedPercent))) : left + return { key, left, shown, label } +} + const usageWindows = [ - limits.session - ? { - key: 'session', - left: Math.max(0, Math.round(100 - limits.session.usedPercent)), - shown: showUsed - ? Math.min(100, Math.max(0, Math.round(limits.session.usedPercent))) - : Math.max(0, Math.round(100 - limits.session.usedPercent)), - label: translate('auto.components.status.bar.StatusBar.d79c3362c4', '% 5h') - } - : null, - limits.weekly - ? { - key: 'weekly', - left: Math.max(0, Math.round(100 - limits.weekly.usedPercent)), - shown: showUsed - ? Math.min(100, Math.max(0, Math.round(limits.weekly.usedPercent))) - : Math.max(0, Math.round(100 - limits.weekly.usedPercent)), - label: translate('auto.components.status.bar.StatusBar.5c938d39ac', '% wk') - } - : null, - limits.fableWeekly - ? { - key: 'fableWeekly', - left: Math.max(0, Math.round(100 - limits.fableWeekly.usedPercent)), - shown: showUsed - ? Math.min(100, Math.max(0, Math.round(limits.fableWeekly.usedPercent))) - : Math.max(0, Math.round(100 - limits.fableWeekly.usedPercent)), - label: translate('auto.components.status.bar.StatusBar.54e8d6bb2d', '% Fable') - } - : null + computeUsageWindow( + 'session', + limits.session, + showUsed, + translate('auto.components.status.bar.StatusBar.d79c3362c4', '% 5h') + ), + computeUsageWindow( + 'weekly', + limits.weekly, + showUsed, + translate('auto.components.status.bar.StatusBar.5c938d39ac', '% wk') + ), + computeUsageWindow( + 'fableWeekly', + limits.fableWeekly, + showUsed, + translate('auto.components.status.bar.StatusBar.54e8d6bb2d', '% Fable') + ) ].filter( (window): window is { key: string; left: number; shown: number; label: string } => window !== null )
2204-2213: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNew toggle skips
recordFeatureInteraction.Every other checkbox item in this menu (Claude, Codex, Gemini, OpenCode Go, Kimi, MiniMax, SSH, Resource Manager, Ports) calls
recordFeatureInteractionon change. This new item doesn't, so usage-toggle interactions won't be tracked consistently.🔧 Proposed fix
<DropdownMenuCheckboxItem checked={usageShowUsed} - onCheckedChange={() => setUsageShowUsed(!usageShowUsed)} + onCheckedChange={() => { + recordFeatureInteraction('usage-tracking') + setUsageShowUsed(!usageShowUsed) + }} >src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx (1)
164-176: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUsage toggle skips feature-interaction recording used by sibling toggles.
Every other status-bar toggle in this list calls
recordStatusBarToggleInteraction(toggle.id, recordFeatureInteraction)before mutating state; the new usage-display switch callssetUsageShowUsed(!usageShowUsed)directly with no interaction tracking. If usage/adoption of this toggle needs to be observable like the others, consider recording it too.♻️ Optional: record the interaction like sibling toggles
<SettingsSwitchRow label={usageDisplayTitle} description={usageDisplayDescription} checked={usageShowUsed} - onChange={() => setUsageShowUsed(!usageShowUsed)} + onChange={() => { + recordFeatureInteraction('usageShowUsed') + setUsageShowUsed(!usageShowUsed) + }} ariaLabel={usageDisplayTitle} />
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 353c96bd-a657-4b38-97ed-bb3008f4efb4
📥 Commits
Reviewing files that changed from the base of the PR and between 9d9ebe6 and 81dedc0b5b0430c28b2e9774f06f729a82b1982a.
📒 Files selected for processing (14)
src/main/runtime/rpc/methods/client-ui.tssrc/renderer/src/components/right-sidebar/source-control-manual-review-url.tssrc/renderer/src/components/settings/AppearanceWindowSidebarSection.tsxsrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/inline-usage-bars.test.tsxsrc/renderer/src/components/status-bar/tooltip.test.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/ui.tssrc/shared/types.ts
|
I’ve also tested it. I just updated the PR description to include screenshots of the output. |
81dedc0 to
97e5b6c
Compare
|
Really thoughtful PR — thank you for shipping this. Your framing of the problem def inspired us to fix the display. We ended up using a hard-coded session usage to % used everywhere in #8167, with the bar fill/color and labels aligned the same way. Closing this as superseded by #8167 / the hard-coded flip. Please keep the PRs coming — thank you so much for this one and we'll get your next one in! |
Add a persisted Appearance setting that switches provider usage labels between percent used and percent remaining while keeping meter fill consumption-based. Cover desktop and web persistence, current providers, settings search, localized copy, and regression tests. Co-authored-by: gatsby74 <[email protected]>
|
@suiramdev I’ve revived this so we can land your original contribution with you as the primary author. I have the current-main implementation fully reviewed and validated, but GitHub is rejecting the branch update because Allow edits from maintainers is currently disabled on this PR. Could you enable that checkbox? Once enabled, I’ll push the update, run CI, and merge it. Thanks again for starting this. |
97e5b6c to
75f304a
Compare
AmethystLiang
left a comment
There was a problem hiding this comment.
Thanks @suiramdev — revived and updated on current main with you retained as the primary author. This now uses an explicit Used/Remaining preference, covers desktop/web persistence and current providers, keeps meter direction consumption-based, and includes localized regression coverage. I incorporated the hardening from #8308 with @gatsby74 retained as a commit co-author. Full tests, lint, typecheck, build, and live Electron validation all passed locally.
* fix: work-item naming, usage % rounding, and terminal/delete copy Address prod-release-scan P2s: - #8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N) and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved. - #7574: getDisplayedUsagePercentage now rounds the used value before taking the `remaining` complement, so the compact status bar (raw usedPercent) and tooltip (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction. clampUsedPercent moves to the shared module as the single rounding source. - #7459: mixed remote+local batch delete confirm no longer claims the whole batch is a permanent "remote host" delete — it now states remote items are permanent while local items move to the Trash/Recycle Bin. - #8322: right-click-to-paste settings copy is platform-aware — "Control-click" on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate. Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift). * Fix NaN% usage bar and label for non-finite provider values Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
Add a persisted Appearance setting that switches provider usage labels between percent used and percent remaining while keeping meter fill consumption-based. Cover desktop and web persistence, current providers, settings search, localized copy, and regression tests. Co-authored-by: gatsby74 <[email protected]>
* fix: work-item naming, usage % rounding, and terminal/delete copy Address prod-release-scan P2s: - stablyai#8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N) and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved. - stablyai#7574: getDisplayedUsagePercentage now rounds the used value before taking the `remaining` complement, so the compact status bar (raw usedPercent) and tooltip (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction. clampUsedPercent moves to the shared module as the single rounding source. - stablyai#7459: mixed remote+local batch delete confirm no longer claims the whole batch is a permanent "remote host" delete — it now states remote items are permanent while local items move to the Trash/Recycle Bin. - stablyai#8322: right-click-to-paste settings copy is platform-aware — "Control-click" on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate. Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift). * Fix NaN% usage bar and label for non-finite provider values Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
Summary
This revives the original proposal and implementation by @suiramdev on current
main. It incorporates the persistence, provider-coverage, and test hardening from #8308 by @gatsby74, who is retained as a commit co-author.Addresses #7551.
Fixes #8304.
Screen recording
trimmed.used.remaining.mov
Testing
pnpm lintpnpm typecheckpnpm test— 2,695 files passed; 28,339 tests passed; 7 files / 42 tests skippedpnpm build— desktop, web, relay, CLI, and native macOS targetsReview notes
Security audit
0–100, and rounded before display.