Skip to content

fix(quota): render weekly boost (150%) and unlimited (status=3) quota#177

Merged
RyanLee-Dev merged 1 commit into
mainfrom
fix/quota-weekly-boost-and-unlimited
Jun 9, 2026
Merged

fix(quota): render weekly boost (150%) and unlimited (status=3) quota#177
RyanLee-Dev merged 1 commit into
mainfrom
fix/quota-weekly-boost-and-unlimited

Conversation

@RyanLee-Dev

Copy link
Copy Markdown
Collaborator

Summary

Fixes two rendering bugs in mmx quota show against the /v1/token_plan/remains endpoint.

The endpoint exposes signals the renderer previously ignored:

  • weekly_boost_permille (千分制, e.g. 1500 ⇒ ×1.5 ⇒ display up to 150%)
  • current_weekly_status === 3 ⇒ weekly quota is unlimited

Before:

  • A 1.5× boost plan (general) was rendered as 周剩余 [██████████] 100% instead of 150%
  • An unlimited weekly plan was rendered as 100%, visually identical to a normal 100% account

After:

  • 周剩余 [██████████] 150% for boost plans
  • 周剩余 [██████████] 无限 / Wk left [██████████] unlimited for status=3 plans (CN/EN region aware)

Changes

  • src/types/api.ts: add weekly_boost_permille?, current_interval_status?, current_weekly_status? to QuotaModelRemain
  • src/output/quota-table.ts: multiply weekly percent by boost_permille/1000; render "无限"/"unlimited" for status=3; raise MAX_DISPLAY_PCT to 200 to accommodate boosted values
  • test/output/quota-table.test.ts: cover 150% boost, 200% clamp, unlimited (CN + EN)

Verification

  • bun test test/output/quota-table.test.ts → 6/6 pass
  • bunx tsc --noEmit → clean
  • bun run builddist/mmx.mjs 150KB, dist/sdk.mjs 53KB
  • Live verified against both accounts on the CN endpoint:
    • 1.5× boost key: 周剩余 [██████████] 150%
    • unlimited key: 周剩余 [██████████] 无限

The /v1/token_plan/remains endpoint returns two signals the renderer
ignored:

  - weekly_boost_permille (千分制, e.g. 1500 ⇒ ×1.5 ⇒ display up to 150%)
  - current_weekly_status === 3 ⇒ weekly quota is unlimited

Previously, the weekly row always used the raw remaining percent, so
a 1.5x boost plan showed 100% instead of 150%, and an unlimited plan
was visually indistinguishable from a normal 100% account.

Changes:
  - api.ts: add weekly_boost_permille?, current_interval_status?,
    current_weekly_status? to QuotaModelRemain
  - quota-table.ts: multiply weekly percent by boost_permille/1000,
    render '无限' / 'unlimited' for status=3, raise display ceiling to
    200% to accommodate boosted values
  - quota-table.test.ts: cover 150% boost, 200% clamp, unlimited CN/EN
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review: render weekly boost (150%) and unlimited (status=3) quota

PR #177 — Adds rendering of weekly_boost_permille (up to 150% display) and current_weekly_status: 3 (unlimited) to the quota table, with CN/global i18n labels.

Checks

Command Result Note
bun run typecheck ✅ Pass No TS errors
bun test ✅ Pass 360 tests, 0 failures
bun run lint ⚠️ Pre-existing 2 errors + 12 warnings, all in unrelated pre-existing test files (test/auth/oauth.test.ts, test/sdk/*.test.ts); the 3 files this PR touches are lint-clean
Build (bun run build:dev) ✅ Pass dist/mmx.mjs produced
Live smoke (mmx quota) ✅ Pass Quota table renders correctly with live API; optional weekly_boost_permille field gracefully defaults when absent

Changes by file

src/output/quota-table.ts

  • MAX_DISPLAY_PCT = 200 — caps boosted percentage so bars stay readable
  • boostFactor() / remainingPct() — applies weekly_boost_permille permille multiplier to the base percent
  • isUnlimited() — checks current_weekly_status === 3
  • renderMetric() — shows ∞/unlimited/无限 bar when status is unlimited; applies boost to normal rendering
  • Bar ratio now uses Math.min(1, pct / 100) so values >100% fill the bar fully without overflow

src/types/api.ts

  • current_interval_status?: number — 1=normal, 2=exhausted, 3=unlimited
  • current_weekly_status?: number — same enum for weekly interval
  • weekly_boost_permille?: number — permille multiplier (e.g. 1500 → display up to 150%)

test/output/quota-table.test.ts

  • 4 new test cases: boost rendering, boost clamping at 200%, unlimited (CN), unlimited (global)

Observations (non-blocking)

  • The lint errors are all pre-existing in test/sdk/*.test.ts (unused imports + any types) — not introduced by this PR.
  • current_interval_status is defined but never consumed in renderQuotaTable(); it may be intended for future use, which is fine.
  • The unlimitedLabel fallback logic (unlimitedLabel ?? UNLIMITED_SYMBOL) will never fall through to the symbol since callers always pass a string — minor, but harmless.

Verdict

Approve — all required checks green, smoke test passes, code is clean.

@RyanLee-Dev RyanLee-Dev merged commit a0c1b30 into main Jun 9, 2026
3 checks passed
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