Skip to content

fix: update Chutes quota usage display#3

Open
Daltonganger wants to merge 2 commits intomainfrom
fix/chutes-hybrid-usage
Open

fix: update Chutes quota usage display#3
Daltonganger wants to merge 2 commits intomainfrom
fix/chutes-hybrid-usage

Conversation

@Daltonganger
Copy link
Copy Markdown
Owner

Summary

  • update Chutes to track both daily request usage and the newer monthly 5× subscription value cap
  • show Chutes as dual quota percentages in the menu while using monthly value usage for status-bar priority
  • add Chutes parsing and percentage tests to cover the new usage model

Verification

  • xcodebuild build -project "CopilotMonitor/CopilotMonitor.xcodeproj" -scheme "CopilotMonitor" -configuration Debug -destination 'platform=macOS' -clonedSourcePackagesDirPath "/Users/rubenbeuker/Library/Developer/Xcode/DerivedData/CopilotMonitor-aggycqisuzewkzczboobrrtuajll/SourcePackages"
  • xcodebuild test -project "CopilotMonitor/CopilotMonitor.xcodeproj" -scheme "CopilotMonitor" -destination 'platform=macOS' -clonedSourcePackagesDirPath "/Users/rubenbeuker/Library/Developer/Xcode/DerivedData/CopilotMonitor-aggycqisuzewkzczboobrrtuajll/SourcePackages" -only-testing:CopilotMonitorTests/ProviderUsageTests
  • launch the Debug app and inspect subsystem logs via /usr/bin/log show

return min(max((usedUSD / capUSD) * 100.0, 0), 999)
}

static func extractMonthlyValueUsedUSD(from json: Any) -> Double? {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 The Roast: This function uses local timezone (TimeZone.current) to calculate date ranges, but the Chutes API likely uses UTC. A user in PST asking for "March 2024" would get March 1st 08:00 local instead of March 1st 00:00 UTC — their query would silently return partial data.

🩹 The Fix: Use UTC timezone to match the API's expected format:

calendar.timeZone = TimeZone(identifier: "UTC") ?? TimeZone.current

📏 Severity: warning

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Mar 23, 2026

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 0
🤏 nitpick 0

🏆 Best part: The dual quota tracking implementation is thorough. The extractMonthlyValueUsedUSD function gracefully handles multiple API response formats (aggregate fields, nested summary objects, item arrays), and the fallback logic from API → balance calculation is robust. The new tests cover edge cases nicely.

💀 Previous issue resolved: The TimeZone concern from the prior review has been addressed — currentMonthDateRangeStrings() now properly uses UTC with TimeZone(identifier: "UTC") ?? TimeZone.current, and there's even a unit test (testChutesCurrentMonthDateRangeUsesUTCMonthBoundaries) verifying it works correctly across timezones.

📊 Overall: Like finding out the bar actually restocked the good stuff — I came in ready to roast, but the code is solid. This PR adds meaningful functionality (monthly value cap tracking for Chutes) without introducing tech debt. Solid work.

Files Reviewed (5 files)
  • CopilotMonitor/CopilotMonitor/Providers/ChutesProvider.swift - 0 issues
  • CopilotMonitor/CopilotMonitor/App/StatusBarController.swift - 0 issues
  • CopilotMonitor/CopilotMonitor/Helpers/ProviderMenuBuilder.swift - 0 issues
  • CopilotMonitor/CopilotMonitor/Models/ProviderResult.swift - 0 issues
  • CopilotMonitor/CopilotMonitorTests/ProviderUsageTests.swift - 0 issues

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