-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Populate windowMinutes for MiMo and StepFun monthly windows (#2431) #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,9 +263,15 @@ public struct StepFunUsageSnapshot: Sendable { | |
| let creditUsedPercent = max(0, min(100, (1.0 - creditRate) * 100)) | ||
| let resetDate = self.creditResetTime ?? Date.distantFuture | ||
| let resetDescription = UsageFormatter.resetDescription(from: resetDate) | ||
| // Populate windowMinutes so the monthly credit pool feeds the plan-utilization | ||
| // history + pace forecast, matching the Codex/Claude windows. Only when the credit | ||
| // pool has a real monthly reset (otherwise the pace projection is meaningless). | ||
| let creditWindowMinutes = self.creditResetTime == nil | ||
| ? nil | ||
| : ProviderPaceCapability.monthlyWindowSentinelMinutes | ||
|
Comment on lines
+269
to
+271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a credit-plan response contains Useful? React with 👍 / 👎. |
||
| let creditWindow = RateWindow( | ||
| usedPercent: creditUsedPercent, | ||
| windowMinutes: nil, | ||
| windowMinutes: creditWindowMinutes, | ||
| resetsAt: resetDate, | ||
| resetDescription: resetDescription) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import Foundation | ||
| import Testing | ||
| @testable import CodexBarCore | ||
|
|
||
| struct MiMoWindowMinutesTests { | ||
| @Test | ||
| func `monthly token quota carries a monthly window for pace history`() { | ||
| // With a real period end, the monthly quota window carries a monthly windowMinutes so it | ||
| // feeds the plan-utilization history + pace forecast (parity with Codex/Claude). Without a | ||
| // period end there is nothing to reset against, so no window is claimed. | ||
| let withPeriod = MiMoUsageSnapshot( | ||
| balance: 0, | ||
| currency: "USD", | ||
| planPeriodEnd: Date(timeIntervalSince1970: 1_742_771_200), | ||
| tokenUsed: 10, | ||
| tokenLimit: 100, | ||
| tokenPercent: 0.1, | ||
| updatedAt: Date(timeIntervalSince1970: 1_742_000_000)) | ||
| #expect(withPeriod.toUsageSnapshot().primary?.windowMinutes == 30 * 24 * 60) | ||
|
|
||
| let noPeriod = MiMoUsageSnapshot( | ||
| balance: 0, | ||
| currency: "USD", | ||
| tokenUsed: 10, | ||
| tokenLimit: 100, | ||
| tokenPercent: 0.1, | ||
| updatedAt: Date(timeIntervalSince1970: 1_742_000_000)) | ||
| #expect(noPeriod.toUsageSnapshot().primary?.windowMinutes == nil) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the sentinel here (and in the analogous StepFun change) still does not enable either advertised card feature:
UsageStore.planUtilizationSeriesSamplesroutes generic providers only through exact 300/10080-minute session-equivalent windows, so a lone 43200-minute primary produces no history samples, while both provider descriptors retain the default.unsupportedpace capability, causingresetWindowPaceDetailto return nil. Add explicit monthly sampling and.calendarMonthResetWindowcapabilities for MiMo and StepFun, with a model-seam test that verifies the history and pace output rather than only the snapshot field.AGENTS.md reference: AGENTS.md:L25-L27
Useful? React with 👍 / 👎.