Fix Claude weekly usage display

This commit is contained in:
Ryan Hughes
2026-06-09 18:11:47 -04:00
parent 7d30407a23
commit 29c4a20a86
2 changed files with 28 additions and 22 deletions
+10 -2
View File
@@ -170,8 +170,16 @@ BarWidget {
return ""
}
function rateLimitLabelIsWeekly(label) {
var text = String(label || "").toLowerCase()
return text.indexOf("week") >= 0 || text.indexOf("7-day") >= 0 || text.indexOf("seven_day") >= 0
}
function usagePercent(provider) {
if (!provider) return -1
var weekly = weeklyUsage(provider)
if (weekly.percent >= 0) return weekly.percent
var values = []
if (provider.rateLimitPercent >= 0) values.push(provider.rateLimitPercent)
if (provider.secondaryRateLimitPercent >= 0) values.push(provider.secondaryRateLimitPercent)
@@ -186,9 +194,9 @@ BarWidget {
function weeklyUsage(provider) {
if (!provider) return ({ percent: -1, resetAt: "", label: "" })
if (String(provider.rateLimitLabel || "").toLowerCase().indexOf("week") >= 0)
if (root.rateLimitLabelIsWeekly(provider.rateLimitLabel))
return { percent: provider.rateLimitPercent, resetAt: provider.rateLimitResetAt, label: provider.rateLimitLabel }
if (String(provider.secondaryRateLimitLabel || "").toLowerCase().indexOf("week") >= 0)
if (root.rateLimitLabelIsWeekly(provider.secondaryRateLimitLabel))
return { percent: provider.secondaryRateLimitPercent, resetAt: provider.secondaryRateLimitResetAt, label: provider.secondaryRateLimitLabel }
return ({ percent: -1, resetAt: "", label: "" })
}
+18 -20
View File
@@ -16,10 +16,10 @@ Item {
property string usageStatusText: ""
property real rateLimitPercent: -1
property string rateLimitLabel: "Weekly (7-day)"
property string rateLimitLabel: "Session (5-hour)"
property string rateLimitResetAt: ""
property real secondaryRateLimitPercent: -1
property string secondaryRateLimitLabel: "Session (5-hour)"
property string secondaryRateLimitLabel: "Weekly (7-day)"
property string secondaryRateLimitResetAt: ""
property int todayPrompts: 0
@@ -284,10 +284,10 @@ Item {
function clearAuthoritativeRateLimits() {
root.hasAuthoritativeRateLimit = false;
root.rateLimitPercent = -1;
root.rateLimitLabel = "Weekly (7-day)";
root.rateLimitLabel = "Session (5-hour)";
root.rateLimitResetAt = "";
root.secondaryRateLimitPercent = -1;
root.secondaryRateLimitLabel = "Session (5-hour)";
root.secondaryRateLimitLabel = "Weekly (7-day)";
root.secondaryRateLimitResetAt = "";
}
@@ -360,29 +360,27 @@ Item {
root.hasAuthoritativeRateLimit = true;
root.rateLimitPercent = -1;
root.rateLimitLabel = "Weekly (7-day)";
root.rateLimitLabel = "Session (5-hour)";
root.rateLimitResetAt = "";
root.secondaryRateLimitPercent = -1;
root.secondaryRateLimitLabel = "Session (5-hour)";
root.secondaryRateLimitLabel = "Weekly (7-day)";
root.secondaryRateLimitResetAt = "";
if (weeklyNorm >= 0)
root.rateLimitPercent = weeklyNorm;
if (sessionNorm >= 0)
root.secondaryRateLimitPercent = sessionNorm;
if (weeklyReset !== null && weeklyReset !== undefined)
root.rateLimitResetAt = root.normalizeResetAt(weeklyReset);
if (sessionReset !== null && sessionReset !== undefined)
root.secondaryRateLimitResetAt = root.normalizeResetAt(sessionReset);
if (root.rateLimitPercent < 0 && sessionNorm >= 0) {
root.rateLimitPercent = sessionNorm;
root.rateLimitLabel = root.secondaryRateLimitLabel;
root.rateLimitResetAt = root.secondaryRateLimitResetAt;
}
if (weeklyNorm >= 0)
root.secondaryRateLimitPercent = weeklyNorm;
if (sessionReset !== null && sessionReset !== undefined)
root.rateLimitResetAt = root.normalizeResetAt(sessionReset);
if (weeklyReset !== null && weeklyReset !== undefined)
root.secondaryRateLimitResetAt = root.normalizeResetAt(weeklyReset);
if (sourceLabel)
root.rateLimitLabel = root.rateLimitLabel + " (" + sourceLabel + ")";
if (sourceLabel) {
if (root.secondaryRateLimitPercent >= 0)
root.secondaryRateLimitLabel = root.secondaryRateLimitLabel + " (" + sourceLabel + ")";
else if (root.rateLimitPercent >= 0)
root.rateLimitLabel = root.rateLimitLabel + " (" + sourceLabel + ")";
}
return true;
}