Repository navigation
fix(usage): handle accounts without a 5-hour session limit - #38
Open
codingogre wants to merge 1 commit into
Open
codingogre wants to merge 1 commit into
codingogre wants to merge 1 commit into
Conversation
claude.ai's usage endpoint now returns `"five_hour": null` for accounts that have no 5-hour session limit. `five_hour` was decoded as non-optional, so every refresh failed with "Failed to parse server response" and the popover kept showing stale numbers. - Make the 5-hour limit optional; hide its popover card when absent - Menu bar icon and notifications follow the weekly limit when there is no 5-hour limit, and notification text names the limit - Dual Bar icon shows a single weekly bar instead of weekly twice - Reset notification flags when the tracked limit changes, so a stale session flag can't suppress a weekly warning or trigger a false reset - Accept reset timestamps without fractional seconds - Omit `session_usage` from usage.json when absent; update README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
smb0209
pushed a commit
to smb0209/ClaudeMeter
that referenced
this pull request
Nov 6, 2026
claude.ai's usage endpoint now returns `"five_hour": null` for accounts that have no 5-hour session limit. `five_hour` was decoded as non-optional, so every refresh failed with "Failed to parse server response" and the popover kept showing stale numbers. - Make the 5-hour limit optional; hide its popover card when absent - Menu bar icon and notifications follow the weekly limit when there is no 5-hour limit, and notification text names the limit - Dual Bar icon shows a single weekly bar instead of weekly twice - Reset notification flags when the tracked limit changes, so a stale session flag can't suppress a weekly warning or trigger a false reset - Accept reset timestamps without fractional seconds - Omit `session_usage` from usage.json when absent; update README Cherry-picked from eddmann#38.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For accounts with no 5-hour session limit,
GET /api/organizations/{id}/usagenow returns"five_hour": null.UsageAPIResponse.fiveHourwas non-optional, so decoding failed on every refresh. The popover showed "Failed to parse server response" above stale numbers from the last successful fetch.I saw this on a Max account that was actively using Claude Code:
five_hourstayednull, and the newlimitsarray listed only weekly limits. Trimmed response:{ "five_hour": null, "seven_day": { "utilization": 4.0, "resets_at": "2026-11-05T01:00:00.343133+00:00", ... }, "seven_day_sonnet": null, "limits": [ { "kind": "weekly_all", "percent": 4, "resets_at": "2026-11-05T01:00:00.343133+00:00", ... }, { "kind": "weekly_scoped", "percent": 0, "resets_at": "2026-11-05T01:00:00+00:00", "scope": { "model": { "display_name": "Fable" } }, ... } ] }The same response also contains a
resets_atwithout fractional seconds, which the old.withFractionalSeconds-only parser would reject.Changes
UsageAPIResponse.fiveHourandUsageData.sessionUsageare optional. The 5-hour card is hidden when there is no 5-hour limit.UsageData.primaryUsage(session, falling back to weekly) andprimaryLimitName. The menu bar icon, status colour and threshold notifications use these, so accounts without a 5-hour limit still get a working meter and alerts. Notification text names the limit ("…of your weekly limit").hasSessionLimitis part of the icon cache key.NotificationStaterecords which limit it tracks (tracked_limit; existing saved state decodes as the 5-hour session). When the limit changes, the warning/critical flags and last percentage reset. This stops a stale session flag from suppressing a weekly warning and stops a false "reset" notification.usage.jsonomitssession_usagewhen absent. The README now documents this, and the statusline example falls back toweekly_usage.Accounts that still have a 5-hour limit see no change.
Testing
five_hour: null), timestamps without fractional seconds, weekly-limit warning text, and the two notification-state switch cases.xcodebuild test: 56 passed. The 8MenuBarIconSnapshotTestsfail on my machine (macOS 26 / Xcode 27.2) on unmodifiedmaintoo, so it's a rendering-environment difference, not this change.Possible follow-up (not in this PR)
The reset notification title and the "Notify on Session Reset" setting still say "Session". They're accurate for accounts with a 5-hour limit and slightly off for weekly-only accounts.
🤖 Generated with Claude Code