Skip to content

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

Merged
steipete merged 4 commits intosteipete:mainfrom
XWind18:feature/minimax
May 10, 2026
Merged

feat(minimax): Add multi-service usage support#605
steipete merged 4 commits intosteipete:mainfrom
XWind18:feature/minimax

Conversation

@XWind18
Copy link
Copy Markdown
Contributor

@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.

Copy link
Copy Markdown

@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 thread Sources/CodexBar/Providers/MiniMax/MiniMaxSettingsStore.swift Outdated
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)
Copy link
Copy Markdown

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

XWind18 and others added 3 commits May 10, 2026 05:16
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.
Copy link
Copy Markdown

@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: 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".

Comment on lines +41 to +44
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]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines +1132 to +1133
if lowerWindow == "today" {
let components = timeRange.split(separator: "-", maxSplits: 1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Owner

@steipete steipete left a comment

Choose a reason for hiding this comment

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

Thanks @XWind18. I fixed the used/remaining quota semantics, UTC+8 parsing, changelog, and added regression coverage; CI is green.

@steipete steipete merged commit 77b7367 into steipete:main May 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants