Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/ContextPanelCore/FastModeForecast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public extension Sequence where Element == MainLimitSummary {
return FastModeCapacityForecast(
limitID: summary.id,
accountName: "\(summary.provider.displayName) \(summary.window.displayName) pool",
providerLimits: summary.limits,
providerLimits: summary.liveLimits,
now: now,
standardBurnRate: standardRate.map { BurnRate(mode: .standard, unitsPerHour: $0) },
fastBurnRate: standardRate.map { BurnRate(mode: .fast, unitsPerHour: $0 * fastModeMultiplier) },
Expand Down
2 changes: 1 addition & 1 deletion Sources/ContextPanelPreview/ContextPanelPreviewApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ struct MainLimitDetail: View {
return FastModeCapacityForecast(
limitID: summary.id,
accountName: limit.accountName,
providerLimits: summary.limits,
providerLimits: summary.liveLimits,
now: Date(),
standardBurnRate: standardBurnRate.map {
BurnRate(mode: .standard, unitsPerHour: $0)
Expand Down
41 changes: 41 additions & 0 deletions Tests/ContextPanelCoreTests/FastModeForecastTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,47 @@ private let now = Date(timeIntervalSinceReferenceDate: 900_000_000)
#expect(portfolio.detailCopy.contains("5h guardrail:"))
}

@Test func openAIFastModeForecastIgnoresFiveHourBucketsBlockedByWeeklyLimit() throws {
let activeReset = now.addingTimeInterval(5 * 3_600)
let weeklyReset = now.addingTimeInterval(7 * 24 * 3_600)
let current = storedOpenAIFiveHourWithWeeklyGate(
savedAt: now,
activeUsed: 100,
fullUsed: 10,
activeWeeklyUsed: 20,
fullWeeklyUsed: 100,
activeReset: activeReset,
weeklyReset: weeklyReset
).snapshot

let portfolio = current.mainLimitSummaries.openAIFastModeCapacityForecast(
now: now,
observedBurnRates: [
"openai:fiveHour": ObservedBurnRate(
limitID: "openai:fiveHour",
unitsPerHour: 2,
observedDurationHours: 2,
sampleCount: 3
),
"openai:weekly": ObservedBurnRate(
limitID: "openai:weekly",
unitsPerHour: 2,
observedDurationHours: 2,
sampleCount: 3
),
],
defaultStandardBurnRateUnitsPerHour: 2,
fastModeMultiplier: 1,
reserveUnits: 6,
minimumSafeHours: 1
)
let fiveHour = try #require(portfolio.forecasts.first { $0.window == .fiveHour })

#expect(fiveHour.remainingUnits == 0)
#expect(fiveHour.recommendation == .limited)
#expect(portfolio.detailCopy.contains("5h guardrail:"))
}

@Test func observedBurnRateAllowsConsistentlyUnknownResets() throws {
let reset = now.addingTimeInterval(96 * 3_600)
let history = [
Expand Down