Skip to content

fix(quota): surface "not in plan" for 0/0 + status=3 models#181

Open
MeloMei wants to merge 1 commit into
MiniMax-AI:mainfrom
MeloMei:fix/quota-not-in-plan
Open

fix(quota): surface "not in plan" for 0/0 + status=3 models#181
MeloMei wants to merge 1 commit into
MiniMax-AI:mainfrom
MeloMei:fix/quota-not-in-plan

Conversation

@MeloMei

@MeloMei MeloMei commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Fix mmx quota show rendering "100% unlimited" for models that are not actually in the user's plan (e.g. video on Token Plan Plus).

Closes #173.

Motivation

The quota API returns total_count: 0, status: 3 for two semantically different states:

  • "no allowance bucket" — the model is not bundled in the user's plan
  • "unlimited" — the model has unlimited quota

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_generation with (0/0 used) — the exact contradiction filed in #173.

Changes

  • New isNotInPlan(total, status) helper detecting the total === 0 && status === 3 "no bucket" state.
  • isUnweekly(status, total) tightened to require total > 0.
  • renderMetric gains a notInPlan branch (empty bar + label), applied to both the Left (interval) and Wk left (weekly) columns.
  • Labels: not in plan (en) / 不在套餐中 (cn).

No public API changes. No README changes required.

Tests

test/output/quota-table.test.ts now has 16 passing tests:

  • 4 unchanged regression tests
  • 2 updated assertions that previously encoded the bug behaviour (asserted unlimited / 无限 for total=0)
  • 3 new render-table tests covering the new "not in plan" path (interval column, weekly CN, weekly global) plus a regression test for the genuine unlimited path (total > 0 + status=3)
  • 8 unit tests covering isNotInPlan and isUnweekly

Local verification:

  • bun test test/output/quota-table.test.ts → 16 pass
  • bun test → 370 pass / 2 fail. The 2 failures are pre-existing Windows-only /dev/null issues unrelated to this change (see test: avoid /dev/null in command tests #161).
  • bun run typecheck → clean
  • bunx eslint src/output/quota-table.ts test/output/quota-table.test.ts → clean

Notes

  • isUnweekly was previously not exported; the second totalCount parameter is additive. No existing call sites outside quota-table.ts.
  • The decision to keep "unlimited" (when total > 0) is documented in source comments; future maintainers will see the rationale alongside the helper definitions.

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
Copilot AI review requested due to automatic review settings June 16, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 isNotInPlan and refine weekly “unlimited” detection to require total_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, collecting lines, and restoring in finally is 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 thread src/output/quota-table.ts
Comment on lines +87 to +92
export function isUnweekly(
status: number | undefined | null,
totalCount: number,
): boolean {
return status === 3 && totalCount > 0;
}
Comment thread src/output/quota-table.ts
Comment on lines +99 to 104
export function isNotInPlan(
totalCount: number,
status: number | undefined | null,
): boolean {
return totalCount === 0 && status === 3;
}
Comment thread src/output/quota-table.ts
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 thread src/output/quota-table.ts
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).
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.

mmx quota show reports 100% remaining for video, but mmx video generate rejects with 0/0 used

2 participants