Skip to content

Commit 60aeb30

Browse files
Fix usage parsing to use "all models" weekly stat
The usage parser was matching the first "Current week" line it found, which could be model-specific (e.g., Opus 4.5 only). Update both the expect script and Swift parsing to specifically look for the "Current week (all models)" line to get combined usage across all models.
1 parent b2e91a7 commit 60aeb30

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

clive/UsageManager.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class UsageManager {
9090
send "\\r"
9191
exp_continue
9292
}
93-
-re "Current week.*\\n.*\\d+%" {
94-
# Got the data we need
93+
-re "Current week \\(all models\\).*\\n.*\\d+%" {
94+
# Got the data we need (all models stat)
9595
}
9696
timeout {
9797
exit 1
@@ -226,10 +226,11 @@ func parseUsageOutput(_ output: String) -> UsageInfo? {
226226
}
227227
}
228228

229-
if let lastWeeklyRange = output.range(of: "Current week", options: .backwards) {
230-
let afterWeekly = output[lastWeeklyRange.upperBound...]
231-
if let match = afterWeekly.range(of: #"\d+%"#, options: .regularExpression) {
232-
weeklyPercent = String(afterWeekly[match])
229+
// Look specifically for "Current week (all models)" to get the combined usage across all models
230+
if let allModelsRange = output.range(of: "Current week (all models)", options: .backwards) {
231+
let afterAllModels = output[allModelsRange.upperBound...]
232+
if let match = afterAllModels.range(of: #"\d+%"#, options: .regularExpression) {
233+
weeklyPercent = String(afterAllModels[match])
233234
}
234235
}
235236

0 commit comments

Comments
 (0)