Skip to content

MiniMax: fix remains-to-used mapping and add quota-style usage cards with weekly text window#970

Merged
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:fix/minimax-token-plan-quota-cards
May 16, 2026
Merged

MiniMax: fix remains-to-used mapping and add quota-style usage cards with weekly text window#970
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:fix/minimax-token-plan-quota-cards

Conversation

@Yuxin-Qiao
Copy link
Copy Markdown
Contributor

Summary

This PR improves MiniMax token plan usage presentation and fixes remains-field semantics.

What changed

  • Corrected MiniMax remains semantics:

    • current_interval_usage_count is treated as interval remaining
    • current_weekly_usage_count is treated as weekly remaining
    • used is computed as max(0, total - remaining)
    • progress percent is computed from used / total
  • Added text-generation dual window support:

    • Show both 5h and Weekly entries when weekly quota is valid.
    • Hide weekly entry when weekly total is missing/zero.
  • Filtered invalid placeholder rows:

    • Skip quota rows with invalid totals (total <= 0) so 0/0 placeholders do not render.
  • Updated MiniMax menu metric presentation within the existing SwiftUI menu layout:

    • Usage: used / total
    • Used xx%
    • progress bar
    • time range and reset text
    • lightweight card-style row background
  • Expanded MiniMax service display-name normalization for common service labels.

Scope and safety

  • No changes to MiniMax auth flow, endpoint selection, polling cadence, or provider registration.
  • No new dependencies.
  • No behavior changes intended for non-MiniMax providers.

Tests

Ran and passed:

  • swift build
  • swift test --filter MiniMax

MiniMax-related tests now cover:

  1. Text Generation with both 5-hour and weekly quotas.
  2. Legacy/no-weekly case hides weekly row.
  3. current_interval_usage_count / current_weekly_usage_count handled as remaining.
  4. used = total - remaining calculation.
  5. Invalid zero-total rows ignored.
  6. MiniMax menu metric copy/card assertions.

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: 7e2d0832b4

ℹ️ 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".

let usageLabel = "Usage: \(used.formatted()) / \(service.limit.formatted())"
let usedLabel = "Used \(String(format: "%.0f%%", displayPercent))"
let title = if service.displayName == "Text Generation", textGenerationCount > 1 {
"Text Generation · \(service.windowType == "Weekly" ? "Weekly" : "5h")"
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 Derive text-generation subtitle from actual window type

The title logic hard-codes every non-weekly Text Generation row to · 5h, so any plan whose interval window is not 5 hours (for example Today or other hour lengths produced by parseWindowInfo) will be mislabeled in the menu. This is a user-visible regression introduced by the new dual-window labeling, and it should use the real service.windowType (or a deliberate mapping) instead of forcing 5h.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed both Codex Review P2 comments with minimal-scope fixes in follow-up commit 9c61d87:

  1. Text Generation badge now derives from the actual windowType instead of hardcoding every non-weekly row as 5h.
  2. Weekly rows now format timeRange as a date-based UTC+8 range instead of HH:mm-only output.

Also added regression coverage for both cases and re-ran:

  • swift build
  • swift test --filter MiniMax
  • git diff --check

Comment on lines +1233 to +1234
var (windowType, timeRange) = self.parseWindowInfo(startTime: startTime, endTime: endTime, now: now)
if let windowTypeOverride { windowType = windowTypeOverride }
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 Format weekly time ranges with dates, not HH:mm-HH:mm

Weekly service rows only override windowType but keep timeRange from parseWindowInfo, which always formats as HH:mm-HH:mm(UTC+8). Because the new MiniMax card now displays service.timeRange directly, weekly windows can render as misleading same-time ranges (e.g., 10:00-10:00(UTC+8)) instead of a 7-day span, making the quota window look effectively zero-length.

Useful? React with 👍 / 👎.

@steipete steipete force-pushed the fix/minimax-token-plan-quota-cards branch from 9c61d87 to aaa3576 Compare May 16, 2026 17:46
@steipete steipete merged commit 645ca83 into steipete:main May 16, 2026
1 check passed
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: aaa3576fe1

ℹ️ 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".

let weeklyService = self.makeServiceUsage(
ServiceUsageInput(
serviceType: serviceTypeIdentifier,
windowTypeOverride: "Weekly",
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 Keep weekly windows parseable as 10080-minute lanes

Setting windowTypeOverride to the literal "Weekly" creates MiniMax weekly rows that cannot be converted into a duration by MiniMaxUsageSnapshot.windowMinutes(for:) (it only recognizes today or numeric unit strings), so the resulting RateWindow gets windowMinutes == nil. That breaks downstream weekly-lane consumers that key off 10080 minutes (for example UsageStore+PlanUtilization only records weekly samples when window.windowMinutes == 10080), so MiniMax weekly history/reset tracking features silently stop working even though a weekly card is shown.

Useful? React with 👍 / 👎.

remainsTime: item.weeklyRemainsTime),
now: now)
{
services.append(weeklyService)
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 Ensure weekly MiniMax lane is always emitted as secondary

Appending weekly services inline per model_remains item makes the lane order depend on API array order, and MiniMaxUsageSnapshot.secondaryService treats secondary as the weekly slot for many downstream paths (quota warnings/widgets). If a non-text model appears before the text model, the produced order becomes non-text first, text weekly later, so the weekly lane is pushed to tertiary and the app reports the wrong window as weekly in those flows.

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.

2 participants