Skip to content

feat(minimax): Add multi-service usage support#605

Open
XWind18 wants to merge 1 commit intosteipete:mainfrom
XWind18:feature/minimax
Open

feat(minimax): Add multi-service usage support#605
XWind18 wants to merge 1 commit intosteipete:mainfrom
XWind18:feature/minimax

Conversation

@XWind18
Copy link

@XWind18 XWind18 commented Mar 26, 2026

Summary

Add comprehensive multi-service usage support for MiniMax Provider.

What's New

Multi-Service Support

  • Text Generation: 5-hour and daily window tracking (10/1500)
  • Text to Speech: Daily quota monitoring (0/4000)
  • Image Generation: Daily quota monitoring (0/50)
  • Video & Music: Full service coverage

Features

  • ✅ Automatic service type detection from model names
  • ✅ Three-window UI display (primary/secondary/tertiary)
  • ✅ Localization support (English/Chinese)
  • ✅ Backward compatibility with single-service mode
  • ✅ Region selection (Global .io / China .com)

Testing

27 tests across 5 suites (existing test infrastructure):

  • ✅ Multi-service API response parsing
  • ✅ Service type auto-detection
  • ✅ Usage calculation & percentage clamping
  • ✅ Window type & timezone handling
  • ✅ UsageSnapshot conversion
  • ✅ Localization tests

Screenshots

Menu View

Shows three services with usage stats:
menu

Settings View

Provider configuration and region selection:
setting

Verification

# Build
swift build
# Run tests
swift test --filter MiniMax
# Package
./Scripts/package_app.sh
Results:
- ✅ Build successful
- ✅ No compiler warnings
- ✅ All 27 MiniMax tests pass
Checklist
- [x] Code follows project conventions
- [x] No compiler warnings
- [x] Clean git history (single commit)
- [x] Backward compatibility maintained
- [x] Follows docs/provider.md architecture
- [x] UI screenshots included (separate files)
Related
Implements multi-service usage tracking as discussed in provider architecture docs.

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
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +56 to 60
func minimaxSettingsSnapshot() -> ProviderSettingsSnapshot.MiniMaxProviderSettings {
ProviderSettingsSnapshot.MiniMaxProviderSettings(
cookieSource: self.minimaxSnapshotCookieSource(tokenOverride: tokenOverride),
manualCookieHeader: self.minimaxSnapshotCookieHeader(tokenOverride: tokenOverride),
cookieSource: self.minimaxCookieSource,
manualCookieHeader: self.minimaxCookieHeader,
apiRegion: self.minimaxAPIRegion)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve token-account overrides in MiniMax settings snapshot

UsageStore.refreshTokenAccounts relies on ProviderRegistry.makeSettingsSnapshot(..., tokenOverride:) to fetch each account with its own credentials, but this snapshot now always returns minimaxCookieSource and minimaxCookieHeader from global settings. Because MiniMax token accounts use cookie-header injection (not env injection), per-account refreshes will all use the same cookie (and may stay on .auto), so account switching and multi-account menu snapshots can no longer show distinct account usage.

Useful? React with 👍 / 👎.

Comment on lines 223 to +225
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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