Skip to content

Bug: mmx quota show (text mode) displays 0 / 0 with empty progress bar for time-based Token Plans, ignoring current_interval_remaining_percent #165

Description

@Whale-Zhang

Environment

  • mmx-cli 1.0.15 (/usr/local/lib/node_modules/mmx-cli)
  • Plan: Token Plan (time-based, not count-based)
  • Region: cn (also reproducible in global)

Summary

mmx quota show in text mode renders the panel from current_interval_usage_count / current_interval_total_count only. For Token Plans that are time-window based (the common case), the API returns current_interval_total_count = 0 and current_interval_usage_count = 0, but also returns current_interval_remaining_percent, current_weekly_remaining_percent, remains_time, and weekly_remains_time. The CLI ignores these percent/time fields, so the table shows 0 / 0, a 0% filled bar, and the wrong reset time.

Steps to reproduce

mmx auth login            # Token Plan, any time-window model
mmx quota show --output text

Actual output (text mode, region = cn)

+--------------------------------------------------------------------+
| MINIMAX  TokenPlan 配额面板          周期: 2026-05-31 — 2026-06-07 |
+--------------------------------------------------------------------+
| general            0 / 0  [................]   0%                  |
|   └ 每周 0 / 0                                        重置于 4h 9m |
+--------------------------------------------------------------------+
| video              0 / 0  [................]   0%                  |
|   └ 每周 0 / 0                                        重置于 8h 9m |
+--------------------------------------------------------------------+

Expected output

The same API response actually contains:

{
  "model_name": "general",
  "current_interval_remaining_percent": 99,
  "current_weekly_remaining_percent": 99,
  "remains_time": 14998196,
  "weekly_remains_time": 547798196
}

So the panel should render something like:

| general          99% 剩余  [................]   1%                  |
|   └ 每周 99% 剩余                                    重置于 152h 5m |

Root cause

dist/mmx.mjs, the Jt(t, n) render function (around the for(let v of t){...} block):

let{current_interval_usage_count:S,current_interval_total_count:R}=v,
T=R>0?Math.round(S/R*100):0,                                    // 0 when R===0
B=v.current_weekly_usage_count,
Q=v.current_weekly_total_count,
X=gm(v.remains_time,i.now),
Z=v.model_name.padEnd(r),
N=`${S.toLocaleString()} / ${R.toLocaleString()}`,              // always "0 / 0"
...
let qt=`└ ${i.weekly} ${B.toLocaleString()} / ${Q.toLocaleString()}`,
Kt=`${i.resetsIn} ${X}`                                          // uses current-interval
                                                                // reset, not weekly

Three problems:

  1. T (the bar) is computed from counts only, so it is 0 for time-based plans.
  2. N always shows count-style used / total, which is meaningless when both are 0.
  3. The weekly row's "重置于" / "Resets in" uses remains_time (current-interval reset) instead of weekly_remains_time, so it always shows the wrong window.

Suggested fix

When current_interval_total_count === 0 (the time-based plan case), fall back to the percent / time fields the API already provides. Pseudocode for the Jt body:

let{
  current_interval_usage_count: S,
  current_interval_total_count: R,
  current_interval_remaining_percent: Sp = 0,
  current_weekly_remaining_percent: Wp = 0,
} = v;

const hasCount  = R > 0;
const T         = hasCount
  ? Math.round(S / R * 100)
  : Math.max(0, Math.min(100, 100 - Sp));          // used %

const N = hasCount
  ? `${S.toLocaleString()} / ${R.toLocaleString()}`
  : `${Sp}% ${i.remaining}`;                       // e.g. "99% remaining"

const B = v.current_weekly_usage_count;
const Q = v.current_weekly_total_count;
const hasWeekly = Q > 0;
const Wline = hasWeekly
  ? `${B.toLocaleString()} / ${Q.toLocaleString()}`
  : `${Wp}% ${i.remaining}`;

const weeklyX = gm(v.weekly_remains_time, i.now);  // not v.remains_time

Add a new i18n key remaining ("remaining" / "剩余") alongside the existing dashboard, week, weekly, resetsIn, noData, now strings.

Result after the patch (verified locally)

| general          99% 剩余  [................]   1%                  |
|   └ 每周 99% 剩余                                    重置于 152h 4m |
| video           100% 剩余  [................]   0%                  |
|   └ 每周 100% 剩余                                   重置于 152h 4m |

Backward compatibility

  • When current_interval_total_count > 0 (a true count-based plan), the new code takes the hasCount branch and the output is byte-identical to today.
  • The --output json path is unaffected (it just dumps the raw API response).
  • Only text mode is touched.

Related

Reproduction environment

  • macOS 25.3.0
  • mmx 1.0.15 (mmx --version)
  • API endpoint: GET /v1/token_plan/remains

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions