Skip to content

fix(quota): normalize ambiguous usage count semantics - #245

Merged
SaladDay merged 1 commit into
mainfrom
fix/quota-count-semantics
Aug 28, 2026
Merged

fix(quota): normalize ambiguous usage count semantics#245
SaladDay merged 1 commit into
mainfrom
fix/quota-count-semantics

Conversation

@SaladDay

@SaladDay SaladDay commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • normalize the ambiguous *_usage_count fields against the server-provided *_remaining_percent
  • support both legacy responses where the reported count means remaining and newer responses where it means consumed
  • fall back to the authoritative percentage when neither count interpretation agrees
  • make quiet output use the same normalization as the text dashboard
  • keep --output json and SDK responses raw and unchanged

Why

The quota API has returned both of these shapes over time:

  • total=3, usage_count=3, remaining_percent=100 (reported count behaves as remaining)
  • total=5, usage_count=0, remaining_percent=100 (reported count behaves as consumed)

The text renderer treated the field as remaining while quiet mode treated it as consumed, so the same payload could produce contradictory output. This change uses the explicit remaining percentage to disambiguate the count and avoids presenting a count when the fields cannot be reconciled.

Validation

  • npx bun test test/utils/quota.test.ts test/output/quota-table.test.ts test/commands/quota/show.test.ts (19 passed)
  • MMX_CONFIG_DIR=<isolated> npx bun test (411 passed)
  • tsc --noEmit
  • ESLint on changed files
  • npx bun run build:dev

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@SaladDay
SaladDay merged commit 906a57b into main Aug 28, 2026
5 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