MiniMax: Token Plan recharge credits and web session enrichment#1981
MiniMax: Token Plan recharge credits and web session enrichment#1981Yuxin-Qiao wants to merge 3 commits into
Conversation
Add token_plan_credit enrichment for cookie-backed refreshes, MiniMax Agent desktop cookie import, API-token web enrichment resolver, and menu credit display. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Codex review: needs changes before merge. Reviewed July 8, 2026, 12:36 AM ET / 04:36 UTC. Summary Reproducibility: yes. The review blockers are source-reproducible on the current PR head by inspecting the token-cost path, MiniMax enrichment paths, Keychain access path, tests/docs, and unchanged review-commented code. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Land a narrowed branch that fixes the source blockers, keeps release notes out of CHANGELOG.md, and has explicit maintainer sign-off for automatic MiniMax Agent/web-session enrichment. Do we have a high-confidence way to reproduce the issue? Yes. The review blockers are source-reproducible on the current PR head by inspecting the token-cost path, MiniMax enrichment paths, Keychain access path, tests/docs, and unchanged review-commented code. Is this the best way to solve the issue? No. The feature direction is useful and backed by linked proof, but the current branch needs targeted repairs and maintainer sign-off on the credential boundary before it is the narrowest maintainable solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against aa401f1d8b74. Label changesLabel justifications:
Evidence reviewedSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (2 earlier review cycles)
|
There was a problem hiding this comment.
💡 Codex Review
When Codex has no credits snapshot and no credits error yet (for example at startup before the optional credits refresh completes), this fallback now returns the generic creditsHint as creditsText because the Codex-specific nil guard was removed. That makes the menu show “Credits unavailable; keep Codex running to refresh.” as an active credits row even though there is no failure or balance to report; keep suppressing the Codex no-data case until credits or error is present.
ℹ️ 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".
| tokenCost: ProviderTokenCostConfig( | ||
| supportsTokenCost: false, | ||
| noDataMessage: { "MiniMax cost summary is not supported." }), | ||
| supportsTokenCost: true, |
There was a problem hiding this comment.
Keep MiniMax token cost disabled until fetch is wired
When MiniMax is enabled and the global token-cost history setting is on, setting supportsTokenCost to true sends the provider through UsageStore.refreshTokenUsage (Sources/CodexBar/UsageStore.swift:1495) instead of being ignored. I checked the token-cost paths: MiniMax is not projected from the provider snapshot in UsageStore+TokenCost.swift, and CostUsageFetcher.loadTokenSnapshot currently only allows Codex, Claude, Vertex AI, and Bedrock before throwing unsupportedProvider (Sources/CodexBarCore/CostUsageFetcher.swift:119). As a result, users will see/log “Cost summary is not supported for minimax” rather than a MiniMax usage summary; keep this false or add the MiniMax loader in the same change.
Useful? React with 👍 / 👎.
| @@ -0,0 +1,182 @@ | |||
| import CommonCrypto | |||
There was a problem hiding this comment.
In non-macOS SwiftPM test builds this import is parsed before the #if os(macOS) around the test type, and CommonCrypto is not available as a module there, so the whole CodexBarTests target fails to compile even though these tests are meant to be skipped. Put the platform/canImport guard around the imports as well as the struct.
Useful? React with 👍 / 👎.
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4232e48791
ℹ️ 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".
| return try await self.attachingTokenPlanCreditIfAvailable( | ||
| to: enrichedSnapshot, | ||
| context: context, | ||
| groupID: groupID) |
There was a problem hiding this comment.
Fetch MiniMax usage summary before returning
In the MiniMax web fetch path, especially when includeBillingHistory == false, this now returns immediately after credit enrichment; no code ever calls MiniMaxAPIRegion.tokenPlanUsageSummaryURL. Fresh evidence beyond the existing token-cost finding is the new MiniMaxProviderTests assertion for /backend/account/token_plan/usage_summary, which this path cannot satisfy, so make check fails and no usage summary is collected for users. Add that fetch before returning, or stop expecting/advertising it.
Useful? React with 👍 / 👎.
| region: context.region, | ||
| environment: context.environment, | ||
| transport: context.transport) | ||
| return snapshot.withPointsBalanceIfMissing(credit.balance, expiresAt: credit.expiresAt) |
There was a problem hiding this comment.
Use the fetched MiniMax credit balance
When the coding-plan/remains payload already contains a pointsBalance but no expiry, this path still fetches the dedicated token_plan_credit endpoint, then calls withPointsBalanceIfMissing, which preserves the older balance and only fills the expiry. That means the production web-session path does not actually replace a stale or fallback balance with the dedicated recharge-credit value, despite the new helper/test implying the dedicated endpoint should win.
Useful? React with 👍 / 👎.
| if let resolvedGroupID, | ||
| !credit.groupIDs.isEmpty, | ||
| credit.groupIDs.contains(resolvedGroupID) | ||
| { | ||
| enriched = enriched.withPointsBalanceFromDedicatedEndpoint( | ||
| credit.balance, | ||
| expiresAt: credit.expiresAt) | ||
| receivedWebData = true |
There was a problem hiding this comment.
Accept group-less MiniMax credit payloads
For API-token enrichment, a valid token_plan_credit response that has a balance but omits credit_packages_details never enters either branch because credit.groupIDs is empty, so the balance is dropped and the web session is later reported as unavailable. This affects explicit/manual or desktop cookies when the endpoint returns one of the parser-supported balance fallback shapes; apply the balance when no group IDs are supplied, or otherwise mark the response as unverifiable instead of ignoring it.
Useful? React with 👍 / 👎.
Keep optional credits hidden when Codex has no credits snapshot so Buy Credits remains available without rendering an error-only credits section. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Split from #1821 (PR A).
token_plan_creditrecharge balance when a web session cookie is availableMiniMaxWebEnrichmentResolverfor API-token refreshespointsBalancediagnostics, and reset-time parsing fixesdocs/minimax.mdTest plan
make checkswift test --filter MiniMaxTokenPlanCreditswift test --filter MiniMaxWebEnrichmentswift test --filter MiniMaxDesktopCookieStack
feat/minimax-usage-dashboardfeat/minimax-quota-utilizationMade with Cursor