fix(quota): show "not in plan" instead of misleading 100%, map code 2056 (#173)#174
fix(quota): show "not in plan" instead of misleading 100%, map code 2056 (#173)#174kapelame wants to merge 2 commits into
Conversation
- types: add 4 optional fields (interval_status, weekly_status, boost_permille x 2) - render: prepend 'xN' to model name when boost_permille > 1000 - tests: add 2 cases (with boost, without boost) PR #166 missed these fields. status is not separately rendered since percent already conveys the state (1=partial, 3=full). boost informs the user about their 2x subscription multiplier.
…056 (#173) A Token Plan that does not bundle a model (e.g. video) makes the server return that model's row as 0/0 with remaining_percent=100, marked current_*_status=3. The table trusted the percent and rendered a misleading "100%", while `video generate` was rejected by the server with code 2056 — a contradiction reported in #173. - quota-table: when current_interval_status / current_weekly_status is 3, render "not in plan" / "不在当前套餐中" instead of the bar+percent. Status is the only reliable signal: in-plan time-based rows are also 0/0 but report status=1. - errors/api: fold code 2056 into the existing quota branch so the user gets a QUOTA exit code with a check-usage / upgrade hint. Builds on #168, which already added the current_*_status fields to QuotaModelRemain; this change consumes them.
|
dummy |
AI Review — #${PR_NUMBER}Summary: Handles two UX issues with the quota table display: (1) models not bundled in a plan show misleading 100% bars for 0/0 counts, now replaced with an explicit "not in plan" label; (2) models with a boost multiplier display the Checks
Note on lint: The 2 errors ( Changes by file
No blocking issuesThe PR is focused, type-safe, and well-tested. No CLI-breaking changes. ✅ Approve |
What
Fixes #173 —
mmx quota showreports a video quota of 100% whilemmx video generateis rejected with code 2056, a self-contradiction.Root cause
When a Token Plan does not bundle a model, the server returns that model's quota row as
0/0withremaining_percent: 100, markedcurrent_interval_status: 3/current_weekly_status: 3. The table trustedremaining_percentand rendered a misleading 100%, even though the model is unusable (generate →2056).statusis the only reliable discriminator: legitimate time-based in-plan rows are also0/0, but reportstatus: 1. A count-based heuristic (total==0) would wrongly flag those.Changes (this PR's own commit)
src/output/quota-table.ts— whencurrent_interval_status/current_weekly_statusis3, rendernot in plan/不在当前套餐中instead of a bar + percent.src/errors/api.ts— fold code2056into the existing1028 || 1030quota branch →QUOTAexit code + check-usage / upgrade hint (matches how same-class codes are already grouped).This builds on #168 (
feat(quota): align types with coding-plan API, show boost multiplier), which adds thecurrent_*_statusfields toQuotaModelRemain. My commit only consumes them.Because #168 is on a fork, GitHub won't let me target it as the base, so this PR is opened against
mainand currently contains #168's commit as well (it sits directly onmain). Once #168 merges, this PR's diff collapses to just my 4-file change automatically — no rebase needed. Please merge #168 first.My change alone (vs the #168 tip):
Verification
bun test— 359 pass / 0 failtsc --noEmitclean; eslint clean on touched filescurrent_*_status(=1 for in-plan rows), andvideo generatedebits quota normally for an in-plan model — confirming the fix is inert for users whose plan includes the model.Rendered result for a no-video plan:
(the in-plan
通用row still shows its real percent)