Skip to content

fix(dashboard): show missing Minimax usage rows and weekly windows#1347

Merged
gsxdsm merged 1 commit into
mainfrom
gsxdsm/activitydebug
Jun 3, 2026
Merged

fix(dashboard): show missing Minimax usage rows and weekly windows#1347
gsxdsm merged 1 commit into
mainfrom
gsxdsm/activitydebug

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

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 off current_interval_total_count via an if (total > 0) filter. The primary general model meters quota purely through current_interval_remaining_percent (91%) while its total_count is 0, 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 live coding_plan/remains endpoint: 2 models (general, video), each with an interval + weekly quota → 4 windows expected, but only 1 rendered.

Fix

  • Prefer *_remaining_percent as the source of truth (count-based fallback when absent).
  • Render a window only when a model exposes any quota signal — no longer count-only.
  • Surface each model's weekly window (current_weekly_remaining_percent, weekly_* timing) as its own indicator alongside the interval window.

Verification

  • New regression test mirrors the real general (count 0 + percent-only) + video payload and asserts 4 windows; confirmed it fails (length 1) without the fix.
  • Re-verified the fix logic against the live API → all 4 windows render.
  • Full usage.test.ts suite: no new failures (3 pre-existing Codex/HOME-fallback failures are unrelated and present on the baseline).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Minimax provider usage panel not displaying the primary model in quota information.
    • Added weekly quota tracking with separate timing indicators alongside interval quotas.
    • Improved quota calculation logic with better fallback support for quota signals.

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>
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 319f0441-9980-48cc-8afc-eb755d2816eb

📥 Commits

Reviewing files that changed from the base of the PR and between 59cd9ea and 6f37806.

📒 Files selected for processing (3)
  • .changeset/minimax-usage-missing-rows.md
  • packages/dashboard/src/__tests__/usage.test.ts
  • packages/dashboard/src/usage.ts

📝 Walkthrough

Walkthrough

The PR fixes the Minimax provider usage panel missing the general model by updating quota-window parsing to prefer percent-based quota signals (*_remaining_percent fields) with count-based fallback, and generating both interval and weekly windows per model instead of only interval windows when counts are nonzero.

Changes

Minimax Usage Panel Quota-Signal Fix

Layer / File(s) Summary
Minimax usage window parsing with percent-based quota signals
packages/dashboard/src/usage.ts
Updated Minimax parsing to introduce a buildWindow helper that constructs quota windows from authoritative *_remaining_percent fields, falls back to count-derived calculations, and skips entries with no quota signal. Now generates both interval and weekly windows per model using appropriate timing fields, replacing the prior logic that only emitted interval windows when current_interval_total_count > 0.
Usage window parsing test validation
packages/dashboard/src/__tests__/usage.test.ts
New test case verifies the parser correctly handles percent-only model_remains responses with zero interval counts, asserting 4 total windows (interval plus weekly per model), correct percentUsed/percentLeft derivation from remaining-percent, and presence of both general and video weekly windows.
Changeset documentation
.changeset/minimax-usage-missing-rows.md
Patch release entry documents the Minimax usage panel fix: quota-signal-based rendering that prefers *_remaining_percent fields, renders only when quota signals exist, and adds separate weekly indicators and timing alongside interval quota windows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through quota fields so bright,
Where remaining_percent shines with might,
No more missing general in the view,
Weekly windows join the interval crew! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary fix: showing missing Minimax usage rows and weekly windows in the dashboard.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gsxdsm/activitydebug

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 and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes the Minimax usage panel dropping the general model entirely because the old filter required current_interval_total_count > 0, while general signals quota exclusively via current_interval_remaining_percent. The PR also surfaces each model's weekly quota as a separate window.

  • Root-cause fix: buildWindow now prefers *_remaining_percent as the source of truth and falls back to count-based math only when the percent field is absent; a window is skipped only when neither signal exists.
  • Weekly windows: A second independent buildWindow call per model emits a "<model> (weekly)" window using current_weekly_* fields, growing the expected render count from 1 to 4 for the real coding_plan payload.
  • Test coverage: New regression test mirrors the live API response (2 models × interval + weekly = 4 windows) and confirms the fix; the existing "skips models with zero quota" test continues to pass unchanged.

Confidence Score: 4/5

Safe 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 buildWindow refactor is clean and the core fix (prefer percent over count) is correct. The two observations are speculative: one is a stale comment in a test, and the other is a theoretical scenario where the Minimax API emits 0 as a default weekly-percent for models without weekly plans, which would surface phantom depleted windows. Neither represents a confirmed defect.

No files require special attention; usage.ts is well-reasoned and the new test in usage.test.ts exercises the exact real-world payload described in the PR.

Important Files Changed

Filename Overview
packages/dashboard/src/usage.ts Replaces the old count-only visibility filter with a buildWindow helper that prefers *_remaining_percent (with count-based fallback), and adds a second independent call per model for the weekly quota window. Logic and clamping are correct; minor speculative concern around API returning 0 as a weekly-plan default.
packages/dashboard/src/tests/usage.test.ts Adds a regression test mirroring the real coding_plan/remains payload (2 models × interval + weekly = 4 windows); asserts general's percent-only interval window and both weekly windows appear. One stale test comment in the pre-existing "skips models with zero quota" case.
.changeset/minimax-usage-missing-rows.md Changeset entry accurately describes both the root cause (count-only filter dropping general) and the fix (percent-preferred, weekly windows); no issues.

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]
Loading

Comments Outside Diff (1)

  1. packages/dashboard/src/__tests__/usage.test.ts, line 2749-2750 (link)

    P2 Stale comment no longer describes the skip criterion

    The comment says unused-model has total=0 so skipped, but the new logic skips a window only when both remaining_percent is absent/non-numeric and totalCount === 0. A model with total=0 but an explicit remaining_percent (even 0) would now be shown. The comment will mislead the next reader about why the model is filtered out.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix(dashboard): show missing Minimax usa..." | Re-trigger Greptile

Comment on lines +1479 to +1487
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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@gsxdsm
gsxdsm merged commit 04a5cd1 into main Jun 3, 2026
8 checks passed
@gsxdsm
gsxdsm deleted the gsxdsm/activitydebug branch June 3, 2026 15:09
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.

1 participant