Skip to content

Fix z.ai multi-limit quota handling and menu bar selection#662

Merged
ratulsarna merged 7 commits intomainfrom
codex/pr-632-audit
Apr 8, 2026
Merged

Fix z.ai multi-limit quota handling and menu bar selection#662
ratulsarna merged 7 commits intomainfrom
codex/pr-632-audit

Conversation

@ratulsarna
Copy link
Copy Markdown
Collaborator

Supersedes #632.

Summary

  • preserve both z.ai token lanes when the API returns weekly and 5-hour TOKENS_LIMIT entries
  • teach the menu bar metric pipeline and provider settings to surface and select the 5-hour lane correctly
  • keep the 2-limit response shape unchanged for accounts without the weekly quota

Validation

  • pnpm check
  • ./Scripts/compile_and_run.sh

Credit to @takumi3488 for the original fix and investigation, and thank you for the detailed payloads and follow-up context.

takumi3488 and others added 6 commits April 8, 2026 12:20
The z.ai API can return two TOKENS_LIMIT entries — one for the 5-hour
window (unit:3/number:5) and one for the weekly window (unit:6/number:1).
Previously the second entry silently overwrote the first, discarding the
5-hour quota entirely.

Changes:
- Add ZaiLimitUnit.weeks (rawValue 6) with windowMinutes = n×7×24×60
- Add ZaiUsageSnapshot.sessionTokenLimit for the shorter-window entry
- Rewrite parseUsageSnapshot to collect all TOKENS_LIMIT entries and
  sort by windowMinutes: shorter → sessionTokenLimit (tertiary), longer
  → tokenLimit (primary), preserving the existing display unchanged for
  APIs that return only one TOKENS_LIMIT
- Map sessionTokenLimit to UsageSnapshot.tertiary in toUsageSnapshot()
- Enable supportsOpus + opusLabel "5-hour" in ZaiProviderDescriptor so
  MenuCardView/MenuDescriptor/CLIRenderer render the new tertiary row
- Wire zaiSessionDetail text into the tertiary card metric
- Add ZaiThreeLimitTests covering 3-entry parsing, unit:6 enum, and
  backward-compatible 2-entry fallback
@ratulsarna ratulsarna merged commit 9bb4174 into main Apr 8, 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.

2 participants