fix(quota): surface "not in plan" for 0/0 + status=3 models#181
Open
MeloMei wants to merge 1 commit into
Open
Conversation
When `current_*_total_count === 0` and `current_*_status === 3`, the API is signalling "not in your plan" (no allowance bucket), not "unlimited". The CLI previously rendered such rows as "100% unlimited" while `/v1/video_generation` immediately rejected the same request with `(0/0 used)` — the inconsistency reported in MiniMax-AI#173. Split the status=3 path into two cases: - total_count === 0 && status === 3 -> "not in plan" / "不在套餐中" - total_count > 0 && status === 3 -> unchanged: "unlimited" / "无限" Changes: - New `isNotInPlan(total, status)` helper (exported for testing). - `isUnweekly(status, total)` now requires `total > 0` (exported). - `renderMetric` gains a `notInPlan` branch rendered with an empty bar and the `not in plan` / `不在套餐中` label, applied to both interval and weekly columns. Tests: - Two existing assertions that asserted "unlimited" / "无限" with `total=0` were updated; they encoded the bug behaviour. - Added regression coverage for the genuine unlimited path (status=3 + total > 0) and for the interval column. - Added unit tests for `isNotInPlan` and `isUnweekly`. Closes MiniMax-AI#173
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adjusts quota table rendering to distinguish “not in plan” models from genuinely unlimited quotas when the API reports status=3 with a total_count of 0 (0/0 bucket), and updates tests accordingly.
Changes:
- Add
isNotInPlanand refine weekly “unlimited” detection to requiretotal_count > 0. - Render “not in plan / 不在套餐中” instead of “unlimited / 无限” for 0/0 buckets.
- Expand unit tests to cover the new behavior and helper functions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/output/quota-table.test.ts | Updates/extends tests to assert “not in plan” vs “unlimited” behavior and adds direct tests for new helpers. |
| src/output/quota-table.ts | Implements “not in plan” detection, adjusts unlimited logic, and updates metric rendering to display the new label. |
Comments suppressed due to low confidence (1)
test/output/quota-table.test.ts:212
- The pattern of overriding
console.log, collectinglines, and restoring infinallyis repeated across multiple tests in this file. Consider extracting a small helper (e.g.,captureConsoleLog(() => renderQuotaTable(...))) to reduce duplication and make tests easier to read and modify consistently.
const lines: string[] = [];
const originalLog = console.log;
console.log = (message?: unknown) => {
lines.push(String(message ?? ''));
};
try {
renderQuotaTable(
[
{
...createModel(),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+87
to
+92
| export function isUnweekly( | ||
| status: number | undefined | null, | ||
| totalCount: number, | ||
| ): boolean { | ||
| return status === 3 && totalCount > 0; | ||
| } |
Comment on lines
+99
to
104
| export function isNotInPlan( | ||
| totalCount: number, | ||
| status: number | undefined | null, | ||
| ): boolean { | ||
| return totalCount === 0 && status === 3; | ||
| } |
Comment on lines
149
to
160
| @@ -134,7 +155,18 @@ function renderMetric( | |||
| boostPermille?: number | null, | |||
| unlimited?: boolean, | |||
| unlimitedLabel?: string, | |||
| notInPlan?: boolean, | |||
| notInPlanLabel?: string, | |||
| ): string { | |||
Comment on lines
+83
to
+86
| // Caveat: when `total_count === 0 && status === 3` the model is not in the | ||
| // user's plan at all (the API conflates "no bucket" with "unlimited"). | ||
| // Callers must check `isNotInPlan` first; only treat status=3 as truly | ||
| // unlimited when there is a real allowance bucket (total > 0). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
mmx quota showrendering "100% unlimited" for models that are not actually in the user's plan (e.g.videoon Token Plan Plus).Closes #173.
Motivation
The quota API returns
total_count: 0, status: 3for two semantically different states:The CLI previously rendered both as "100% unlimited". A Token Plan Plus user would see
video — 100% remaining, then immediately get rejected by/v1/video_generationwith(0/0 used)— the exact contradiction filed in #173.Changes
isNotInPlan(total, status)helper detecting thetotal === 0 && status === 3"no bucket" state.isUnweekly(status, total)tightened to requiretotal > 0.renderMetricgains anotInPlanbranch (empty bar + label), applied to both theLeft(interval) andWk left(weekly) columns.not in plan(en) /不在套餐中(cn).No public API changes. No README changes required.
Tests
test/output/quota-table.test.tsnow has 16 passing tests:unlimited/无限fortotal=0)total > 0 + status=3)isNotInPlanandisUnweeklyLocal verification:
bun test test/output/quota-table.test.ts→ 16 passbun test→ 370 pass / 2 fail. The 2 failures are pre-existing Windows-only/dev/nullissues unrelated to this change (see test: avoid /dev/null in command tests #161).bun run typecheck→ cleanbunx eslint src/output/quota-table.ts test/output/quota-table.test.ts→ cleanNotes
isUnweeklywas previously not exported; the secondtotalCountparameter is additive. No existing call sites outsidequota-table.ts.total > 0) is documented in source comments; future maintainers will see the rationale alongside the helper definitions.