Skip to content

Commit 22be124

Browse files
committed
Refactor Kimi usage snapshot to prioritize rate limit as primary window
1 parent 69a5550 commit 22be124

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

Sources/CodexBarCore/Providers/Kimi/KimiUsageSnapshot.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ extension KimiUsageSnapshot {
7373
loginMethod: nil)
7474

7575
return UsageSnapshot(
76-
primary: rateLimitWindow ?? weeklyWindow,
77-
secondary: rateLimitWindow != nil ? weeklyWindow : nil,
76+
primary: rateLimitWindow,
77+
secondary: weeklyWindow,
7878
tertiary: nil,
7979
providerCost: nil,
8080
updatedAt: self.updatedAt,

Tests/CodexBarTests/KimiProviderTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ struct KimiUsageSnapshotConversionTests {
222222

223223
let usageSnapshot = snapshot.toUsageSnapshot()
224224

225-
#expect(usageSnapshot.primary != nil)
225+
#expect(usageSnapshot.primary == nil)
226+
#expect(usageSnapshot.secondary != nil)
226227
let weeklyExpected = 375.0 / 2048.0 * 100.0
227-
#expect(abs((usageSnapshot.primary?.usedPercent ?? 0.0) - weeklyExpected) < 0.01)
228-
#expect(usageSnapshot.secondary == nil)
228+
#expect(abs((usageSnapshot.secondary?.usedPercent ?? 0.0) - weeklyExpected) < 0.01)
229229
#expect(usageSnapshot.tertiary == nil)
230230
}
231231

@@ -244,7 +244,7 @@ struct KimiUsageSnapshotConversionTests {
244244
updatedAt: now)
245245

246246
let usageSnapshot = snapshot.toUsageSnapshot()
247-
#expect(usageSnapshot.primary?.usedPercent == 0.0)
247+
#expect(usageSnapshot.secondary?.usedPercent == 0.0)
248248
}
249249

250250
@Test
@@ -262,7 +262,7 @@ struct KimiUsageSnapshotConversionTests {
262262
updatedAt: now)
263263

264264
let usageSnapshot = snapshot.toUsageSnapshot()
265-
#expect(usageSnapshot.primary?.usedPercent == 100.0)
265+
#expect(usageSnapshot.secondary?.usedPercent == 100.0)
266266
}
267267
}
268268

Tests/CodexBarTests/UsageStoreHighestUsageTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct UsageStoreHighestUsageTests {
8080
}
8181

8282
@Test
83-
func `automatic metric uses secondary for kimi when ranking highest usage`() {
83+
func `automatic metric uses primary for kimi when ranking highest usage`() {
8484
let settings = SettingsStore(
8585
configStore: testConfigStore(suiteName: "UsageStoreHighestUsageTests-kimi-automatic"),
8686
zaiTokenStore: NoopZaiTokenStore(),

0 commit comments

Comments
 (0)