Skip to content

fix: handle null response after claude reset#13

Open
rasyid7 wants to merge 2 commits intoeddmann:mainfrom
rasyid7:fix-after-reset
Open

fix: handle null response after claude reset#13
rasyid7 wants to merge 2 commits intoeddmann:mainfrom
rasyid7:fix-after-reset

Conversation

@rasyid7
Copy link
Copy Markdown

@rasyid7 rasyid7 commented Apr 3, 2026

Fix: Server returned invalid response #10

Summary of Changes

Modified ClaudeMeter to handle a specific API response case when the Claude session has been reset.

Problem

When Claude's session resets, the API returns resets_at: null for five_hour:

{
    "five_hour": {
        "utilization": 0.0,
        "resets_at": null
    },
    ...
}

Previously, this caused an error: MappingError.missingCriticalField(field: "fiveHour.resetsAt")
Solution

  1. UsageLimit.swift - Made resetAt optional
    • Changed resetAt: Date → resetAt: Date?
    • resetDescription now returns "Starts when a message is sent" when nil
    • Updated isResetting and isAtRisk to handle nil safely
  2. UsageAPIResponse.swift - Handle null reset dates
    • Session usage with resets_at: null → utilization forced to 0%
    • Same handling for optional sevenDaySonnet
  3. UsageCardView.swift - Updated UI text
    • When resetAt is nil: shows "Starts when a message is sent"
    • When resetAt exists: shows "Resets in X hours"
  4. NotificationServiceProtocol.swift & NotificationService.swift - Updated for optional dates
    • Changed resetTime: Date → resetTime: Date?
    • Notification body handles nil reset time gracefully
  5. Test spy updated to match new protocol signature
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant