Skip to content

fix(usage): correct MiniMax token plan quota display - #1642

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.7.1from
CruxExperts:fix/minimax-token-plan-quota-display-pr
Apr 27, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.7.1from
CruxExperts:fix/minimax-token-plan-quota-display-pr

Conversation

@CruxExperts

Copy link
Copy Markdown
Contributor

Summary

  • Treat the newer MiniMax /v1/token_plan/remains endpoint as reporting used request counts, while preserving remaining-count behavior for the older /coding_plan/remains fallback endpoint.
  • Add a regression test for low MiniMax usage values like 13 / 15000 and 66 / 150000 so the dashboard shows roughly full remaining quota instead of near-zero remaining quota.
  • Round compact Provider Limits percentages before display to avoid floating point artifacts such as 0.044000000000000004%.

Context

The upstream MiniMax report MiniMax-AI/MiniMax-M2#99 documents the older /coding_plan/remains semantics as remaining counts. The newer /v1/token_plan/remains endpoint used first by OmniRoute returns used counts in the observed live response, so applying the old fallback semantics to the new endpoint reverses remaining quota.

No matching open OmniRoute issue or PR was found for this MiniMax-specific inversion. PR #1516 added the current MiniMax quota support.

Test plan

  • npx cross-env DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm --test tests/unit/usage-service-hardening.test.ts tests/unit/provider-limits-ui.test.ts
  • Pre-push hook with Node 24: full npm run test:unit, 3629 tests passed, 0 failed
  • Pre-commit hooks: Prettier, ESLint, docs sync, npm run check:any-budget:t11

diegosouzapw and others added 3 commits April 26, 2026 16:09
#1630)

Cherry-pick from PR #1630 by @rdself. Fixes Docker build failures caused by
lockfile peer dependency mismatch during npm ci.
…ailures

- Override plist to v4.0.0 which passes mandatory mimeType to DOMParser
- Add USERPROFILE sanitization on Windows to avoid EPERM on junction points
- Add NPM_CONFIG_LEGACY_PEER_DEPS to Electron workflow install step
Treat the newer MiniMax token-plan endpoint as reporting used counts while preserving fallback behavior for the older coding-plan endpoint, and round compact quota percentages for display.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a helper function to correctly calculate MiniMax usage quotas by determining whether the API response represents used or remaining units based on the request URL. It also includes a new unit test to verify this logic. Regarding the UI changes, rounding the remaining percentage to the nearest integer may cause misleading displays near the 0% and 100% thresholds; consider using a more precise rounding method or Math.floor to maintain accuracy for the user.

const remainingPercentageRaw = q.unlimited
? 100
: (q.remainingPercentage ?? calculatePercentage(q.used, q.total));
const remainingPercentage = Math.round(remainingPercentageRaw);

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.

medium

Rounding the remaining percentage to the nearest integer can lead to misleading displays at the extremes. For example, a quota with 99.6% remaining will be displayed as 100%, which might incorrectly suggest that no usage has occurred. Conversely, a quota with 0.4% remaining will show as 0%, suggesting it is completely exhausted.

Consider using a more precise rounding method (such as toFixed(1) for values near the boundaries) or using Math.floor for the remaining percentage to ensure that 100% is only shown when the quota is truly untouched, maintaining better accuracy for the user.

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.7.1 April 27, 2026 02:51
@diegosouzapw
diegosouzapw merged commit 4eef082 into cheaper-inference:release/v3.7.1 Apr 27, 2026
1 of 2 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @CruxExperts for this excellent fix! 🎉 Great catch on the used-vs-remaining semantics difference between the two MiniMax endpoints, and the Math.round() fix for floating-point display artifacts is a nice polish. Merged into release/v3.7.1 — will ship with the next release!

HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…ce#1642)

Integrated into release/v3.7.1 — fixes inverted MiniMax quota display for token_plan/remains endpoint and rounds floating-point percentages.
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…ce#1642)

Integrated into release/v3.7.1 — fixes inverted MiniMax quota display for token_plan/remains endpoint and rounds floating-point percentages.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ce#1642)

Integrated into release/v3.7.1 — fixes inverted MiniMax quota display for token_plan/remains endpoint and rounds floating-point percentages.
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.

2 participants