fix(dashboard): show missing Minimax usage rows and weekly windows#1347
Conversation
The Minimax usage panel only rendered one model row. The primary `general` model meters quota purely via `current_interval_remaining_percent` (its `current_interval_total_count` is 0), so the count-based `total > 0` visibility filter dropped it entirely. The percent was also derived from count fields rather than the authoritative `*_remaining_percent` field. fetchMinimaxUsage now builds windows via a helper that prefers `*_remaining_percent` (count-based fallback when absent) and skips a window only when no quota signal exists. Each model's separate weekly quota window is now surfaced as its own indicator alongside the interval window. Verified against the live coding_plan/remains endpoint: 2 models (general, video) now produce 4 windows (interval + weekly each) instead of 1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR fixes the Minimax provider usage panel missing the ChangesMinimax Usage Panel Quota-Signal Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Greptile SummaryFixes the Minimax usage panel dropping the
Confidence Score: 4/5Safe to merge; the change is localised to the Minimax usage fetcher and is well-covered by a new regression test that mirrors the real API response. The No files require special attention; Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[model_remains entry] --> B{Has current_interval_remaining_percent?}
B -- Yes, finite number --> C[percentLeft = remaining_percent]
B -- No --> D{totalCount > 0?}
D -- Yes --> E[percentLeft = 100 - used/total × 100]
D -- No --> F[return null — skip window]
C --> G[clamp 0–100, build UsageWindow]
E --> G
G --> H[push interval window]
A --> I{Has current_weekly_remaining_percent?}
I -- Yes, finite number --> J[percentLeft = weekly_remaining_percent]
I -- No --> K{weekly_totalCount > 0?}
K -- Yes --> L[percentLeft = 100 - weekly_used/total × 100]
K -- No --> M[return null — skip weekly]
J --> N[clamp 0–100, build UsageWindow label + weekly]
L --> N
N --> O[push weekly window]
|
| if (typeof remainingPercent === "number" && Number.isFinite(remainingPercent)) { | ||
| percentLeft = remainingPercent; | ||
| } else if (totalCount > 0) { | ||
| const used = Math.max(0, totalCount - remainingCount); | ||
| percentLeft = 100 - (used / totalCount) * 100; | ||
| } else { | ||
| // No quota signal at all — skip (unused model type / window). | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Weekly window shows when API emits
0 as default for models without weekly plans
buildWindow now renders a window whenever remainingPercent is a finite number — including 0. If the Minimax API returns current_weekly_remaining_percent: 0 as a default value for models that don't have weekly quotas (rather than omitting the field), those models would render a fully-depleted "X (weekly)" window in the UI even though no weekly plan exists. This risk is speculative since the real-API test data (general, video) both carry genuine weekly fields, but a guard like remainingPercent !== 0 || totalCount > 0 for the weekly window could future-proof the branch.
Problem
The Minimax provider in the usage panel showed only one model row; several were missing.
Root cause
fetchMinimaxUsage(packages/dashboard/src/usage.ts) keyed window visibility offcurrent_interval_total_countvia anif (total > 0)filter. The primarygeneralmodel meters quota purely throughcurrent_interval_remaining_percent(91%) while itstotal_countis0, so it was filtered out. Percent was also derived from count fields rather than the authoritative*_remaining_percent. The per-model weekly quota was never rendered at all.Reproduced by
curl-ing the livecoding_plan/remainsendpoint: 2 models (general,video), each with an interval + weekly quota → 4 windows expected, but only 1 rendered.Fix
*_remaining_percentas the source of truth (count-based fallback when absent).current_weekly_remaining_percent,weekly_*timing) as its own indicator alongside the interval window.Verification
general(count 0 + percent-only) +videopayload and asserts 4 windows; confirmed it fails (length 1) without the fix.usage.test.tssuite: no new failures (3 pre-existing Codex/HOME-fallback failures are unrelated and present on the baseline).🤖 Generated with Claude Code
Summary by CodeRabbit