feat(minimax): Add multi-service usage support#605
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c41b88c3fd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let payload = try MiniMaxUsageParser.decodePayload(data: data) | ||
| self.logCodingPlanStatus(payload: payload) | ||
| return try MiniMaxUsageParser.parseCodingPlanRemains(payload: payload, now: now) | ||
| let snapshot = try MiniMaxUsageParser.parseCodingPlanRemains(payload: payload, now: now) |
There was a problem hiding this comment.
Parse multi-service JSON in remains fallback path
The remains-web fallback still decodes JSON with decodePayload(data:) (legacy model_remains schema) before parsing, while multi-service support was added only in parseCodingPlanRemains(data:). If this endpoint returns the new data.services response, decoding fails immediately and the fallback fetch errors out instead of producing usage. This branch should go through the data-based parser (or try multi-service decode first) to keep fallback compatible.
Useful? React with 👍 / 👎.
Implementation: - Add MiniMaxServiceUsage struct for multi-service tracking - Support Text Generation, TTS, Image, Video, and Music services - Parse API responses with service type mapping - Implement window type detection (5 hours, Today) - Add localization support (English/Chinese) - Three-window UI mapping (primary/secondary/tertiary) - Backward compatibility for legacy single-service mode Bug Fixes: - Fix minimaxAuthMode() call signature - Remove duplicate MiniMaxProviderSettings definition - Remove unused variables in MiniMaxUsageFetcher Verification: ✓ No compiler warnings ✓ Follows Swift Testing framework conventions ✓ Complies with docs/provider.md architecture
- Remains-web fallback now uses parseCodingPlanRemains(data:) to support multi-service JSON responses, maintaining backward compatibility with single-service format - Settings snapshot now accepts tokenOverride parameter, enabling per-account credential injection for multi-account refresh - Remove unused logCodingPlanStatus call in fallback path Fixes code review comments for remains-web fallback and token account settings snapshot.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80c7123b74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public var tertiaryService: MiniMaxServiceUsage? { | ||
| // Return third service for RateWindow.tertiary if exists | ||
| guard let services = self.services, services.count >= 3 else { return nil } | ||
| return services[2] |
There was a problem hiding this comment.
Select tertiary service from remaining non-primary services
When Text Generation is not in slot 0, primaryService is reordered but tertiaryService still returns services[2] unconditionally. With three services (for example [Image, Text Generation, Speech]), this can make tertiary duplicate primary and hide one real service in downstream UsageSnapshot consumers. Tertiary should be chosen after excluding whichever service was promoted to primary/secondary.
Useful? React with 👍 / 👎.
| if lowerWindow == "today" { | ||
| let components = timeRange.split(separator: "-", maxSplits: 1) |
There was a problem hiding this comment.
Parse localized "today" window types in reset-time extraction
The multi-service reset parser only treats window_type equal to "today" as a daily window, so localized values like "今日" from China-region responses are skipped and resetsAt remains nil. In that case the UI falls back to raw text instead of a countdown/reset timestamp even though the time range is present.
Useful? React with 👍 / 👎.
Summary
Add comprehensive multi-service usage support for MiniMax Provider.
What's New
Multi-Service Support
Features
Testing
27 tests across 5 suites (existing test infrastructure):
Screenshots
Menu View
Shows three services with usage stats:

Settings View
Provider configuration and region selection:

Verification