Title a model-scoped limit the way the flat ones title themselves

A scoped window read as "Fable weekly" beside "Session" and "Weekly", so
the one row that names a model was also the one row in lowercase.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-08-11 12:43:03 +02:00
co-authored by Claude Opus 5
parent 0ad64a59df
commit efe805387e
2 changed files with 9 additions and 8 deletions
+5 -4
View File
@@ -653,15 +653,16 @@ def usage_bucket(payload: dict[str, Any], key: str) -> dict[str, Any] | None:
# ("weekly_scoped", "five_hour_scoped"). The panel reads a window out of free # ("weekly_scoped", "five_hour_scoped"). The panel reads a window out of free
# text, which cannot survive a model name like "Opus 5 (1M context)" — the # text, which cannot survive a model name like "Opus 5 (1M context)" — the
# "1M" reads as a one-minute window — so the window is settled here instead # "1M" reads as a one-minute window — so the window is settled here instead
# and travels as an explicit title. # and travels as an explicit title. It is capitalized the way the flat windows
# title themselves, so "Fable Weekly" sits beside "Weekly" rather than under it.
def scoped_window(kind: str) -> str: def scoped_window(kind: str) -> str:
text = kind.lower() text = kind.lower()
if "month" in text: if "month" in text:
return "monthly" return "Monthly"
if "week" in text or "day" in text: if "week" in text or "day" in text:
return "weekly" return "Weekly"
if "hour" in text or "session" in text: if "hour" in text or "session" in text:
return "session" return "Session"
return "" return ""
@@ -44,7 +44,7 @@ limits=$(read_limits '{
] ]
}') }')
expected='[{"label":"Session (5-hour)","percent":0.78,"resetsAt":""},{"label":"Weekly (7-day)","percent":0.12,"resetsAt":""},{"label":"Fable weekly","title":"Fable weekly","percent":0.17,"resetsAt":"2026-08-15T03:00:00+00:00"},{"label":"Fable session","title":"Fable session","percent":0.95,"resetsAt":""},{"label":"claude-opus-5 weekly","title":"claude-opus-5 weekly","percent":0.42,"resetsAt":""}]' expected='[{"label":"Session (5-hour)","percent":0.78,"resetsAt":""},{"label":"Weekly (7-day)","percent":0.12,"resetsAt":""},{"label":"Fable Weekly","title":"Fable Weekly","percent":0.17,"resetsAt":"2026-08-15T03:00:00+00:00"},{"label":"Fable Session","title":"Fable Session","percent":0.95,"resetsAt":""},{"label":"claude-opus-5 Weekly","title":"claude-opus-5 Weekly","percent":0.42,"resetsAt":""}]'
[[ $(jq -c '.limits' <<<"$limits") == "$expected" ]] || [[ $(jq -c '.limits' <<<"$limits") == "$expected" ]] ||
fail "Claude collector reads every model-scoped window once and drops unusable entries" "$limits" fail "Claude collector reads every model-scoped window once and drops unusable entries" "$limits"
pass "Claude collector reads every model-scoped window once and drops unusable entries" pass "Claude collector reads every model-scoped window once and drops unusable entries"
@@ -67,7 +67,7 @@ pass "Claude collector reads scoped percentages on the payload's own scale"
# the array, both keep the session and weekly windows they always had. # the array, both keep the session and weekly windows they always had.
for payload in '{"five_hour":{"utilization":78.0},"limits":[{"kind":"session","percent":78,"scope":null}]}' \ for payload in '{"five_hour":{"utilization":78.0},"limits":[{"kind":"session","percent":78,"scope":null}]}' \
'{"five_hour":{"utilization":78.0},"seven_day":{"utilization":12.0}}'; do '{"five_hour":{"utilization":78.0},"seven_day":{"utilization":12.0}}'; do
[[ $(jq -c '[.limits[].label]' <<<"$(read_limits "$payload")") != *" weekly"* ]] || [[ $(jq -c '[.limits[].label]' <<<"$(read_limits "$payload")") != *" Weekly"* ]] ||
fail "Claude collector adds no limit when the payload scopes none" "$payload" fail "Claude collector adds no limit when the payload scopes none" "$payload"
done done
pass "Claude collector adds no limit when the payload scopes none" pass "Claude collector adds no limit when the payload scopes none"
@@ -86,11 +86,11 @@ eval(source.slice(start, end))
assertDeepEqual( assertDeepEqual(
limitWindows({ limits: [ limitWindows({ limits: [
{ label: 'Session (5-hour)', percent: 0.78, resetsAt: '' }, { label: 'Session (5-hour)', percent: 0.78, resetsAt: '' },
{ label: 'Opus 5 (1M context) weekly', title: 'Opus 5 (1M context) weekly', percent: 0.42, resetsAt: '' } { label: 'Opus 5 (1M context) Weekly', title: 'Opus 5 (1M context) Weekly', percent: 0.42, resetsAt: '' }
] }), ] }),
[ [
{ title: 'Session', percent: 0.78, resetAt: '' }, { title: 'Session', percent: 0.78, resetAt: '' },
{ title: 'Opus 5 (1M context) weekly', percent: 0.42, resetAt: '' } { title: 'Opus 5 (1M context) Weekly', percent: 0.42, resetAt: '' }
], ],
'agents panel titles a limit off the collector when it states one' 'agents panel titles a limit off the collector when it states one'
) )