Conversation
Add Chutes as a new quota-based provider with the following features: - Supports 300/2000/5000 daily quota tiers - Resets at 00:00 UTC daily - Fetches quota usage from https://api.chutes.ai/users/me/quotas - Uses API key from auth.json (chutes.key field) - Implements proper error handling and logging - Adds menu items showing daily usage and tier information Files changed: - Created ChutesProvider.swift with full implementation - Added .chutes to ProviderIdentifier enum with display name and icon - Registered ChutesProvider in ProviderManager - Added getChutesAPIKey() to TokenManager with auth.json support - Added Chutes case to ProviderMenuBuilder for menu items
Use quota and used fields directly from API response: - Remove complex tier detection logic (not needed) - Use quota field directly as total limit - Calculate remaining percentage from quota - used - Add validation for quota > 0 - Simplify planType display to show quota/day This makes the provider more robust and accurate by relying on the actual API response instead of inferring values.
ChutesProvider now fetches data from two endpoints: 1. GET /users/me/quotas - Gets quota and payment refresh date 2. GET /users/me/quota_usage/* - Gets actual usage (quota + used) Combines both responses to show: - Total quota (e.g., 300/day) - Used amount (e.g., 191) - Remaining amount - Subscription/payment refresh date when available - Shows reset time based on payment_refresh_date field This provides accurate real-time usage data from Chutes API.
Updated ChutesProvider to show: - Primary: Usage percentage (used/quota * 100) - Plan: Tier name based on quota (Free/Pro/Enterprise) - Credits: Prepared in menu but requires additional API endpoint Changes: - Added getPlanTier() function to map quota to tier name - Updated menu to show 'Primary: X%' like Codex - Shows Plan tier name in menu - Credits field ready in menu when API is found TODO: Find and implement Chutes credits/balance API endpoint
ChutesProvider now calls 4 API endpoints:
1. GET /users/me - Gets user_id, username, payment_address
2. GET /users/{user_id}/balance - Gets credits balance (with graceful fallback)
3. GET /users/me/quotas - Gets quota limits
4. GET /users/me/quota_usage/* - Gets usage stats
Features:
- Fetches user profile to get user_id for balance endpoint
- Fetches balance/credits with permission error handling
- Gracefully handles 401/403 from balance endpoint (returns nil)
- Shows Credits in menu when available
- Logs all API interactions for debugging
Removed admin-only /users/{user_id}/balance endpoint call.
Balance is now fetched from /users/me response which includes:
- username, user_id, payment_address
- balance (credits)
- permissions, hotkey, coldkey
Simplified to 3 API calls:
1. GET /users/me - User profile + balance
2. GET /users/me/quotas - Quota limits
3. GET /users/me/quota_usage/* - Usage stats
Tested with real API key - all endpoints work correctly.
The wildcard '*' returns 0 usage, but 'A' returns the actual usage. Tested with real API key: - Before: quota_usage/* → used: 0.0 - After: quota_usage/A → used: 250.0 This correctly shows the actual quota usage for the account.
The 300/day tier is called 'Base', not 'Free'.
- 300/day → Base - 2000/day → Plus (was Pro) - 5000/day → Pro (was Enterprise)
0318a00 to
e149fc7
Compare
- Add ChutesProvider.swift to CLI/Providers for CLI target compilation - Update project.pbxproj to include ChutesProvider in build sources - Update entitlements for proper app capabilities This fixes the build error where ProviderProtocol and TokenManager referenced Chutes but the provider file wasn't included in the CLI target.
The file was duplicated in CLI/Providers/ but the Xcode project already references the one in CopilotMonitor/Providers/ for both targets. This was causing potential duplicate symbol errors during linking.
ChutesProvider.swift was incorrectly placed in the CLI Providers group instead of the main Providers group. This caused build failures because the file wasn't in the expected location. Changes: - Moved ChutesProvider.swift reference from CLI Providers to main Providers - Both targets (app and CLI) still compile the file via 'Sources' phase
- ChutesProvider was only in CLI target, missing from main app target - Also removed from test target (was causing duplicate symbols) - Now properly added to both main app and CLI build phases
The PBXFileReference for ChutesProvider.swift was missing 'includeInIndex = 1' which is required for Xcode to properly index and compile the file. Other providers have this flag set.
6862393 to
3d32476
Compare
|
Can someone help me? Thx! |
- Fix DetailedUsage argument order (creditsBalance before planType) - Add chutes property to TokenManager OpenCodeAuth struct - Add .chutes case to all exhaustive switches across codebase: * SubscriptionSettings.presets(for:) * ModernStatusBarIconView.iconName(for:) * MultiProviderStatusBarIconView.drawProviderAlert() * StatusBarController.iconForProvider() - Build now succeeds with all Chutes integration complete
|
@Daltonganger Thank you sir, Can you add an icon image? |
|
@opgginc/op-gg-ai-devops |
✅ AI Code Review CompletedChutes provider added, looks ok but needs tests and doc updates. Also flagged a potential entitlements issue.
Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Yo, I checked your PR. Chutes provider looks mostly fine, but I have some concerns.
🚨 Critical Stuff
- Entitlements: You wiped
com.apple.security.network.clientfromCopilotMonitor.entitlements. I knowENABLE_OUTGOING_NETWORK_CONNECTIONSis in the project file, but are you 100% sure Xcode injects it properly for the sandboxed app? If not, network calls will fail. Verify this on a release build.
📄 Documentation
- README.md: You didn't update the supported providers list. Add Chutes to the table. I tried to do it for you but your fork is locked down.
🧪 Tests
- Where are the tests? You added a whole new provider and zero tests. Add a
ChutesProviderTests.swiftor something. "Tested with real API key" is not a unit test.
💡 Suggestions
- Hardcoded URLs:
https://api.chutes.aiis everywhere. Maybe extract it? - Date Parsing:
calculateNextUTCResetis creating a new Calendar every time. A bit wasteful but whatever.
| <key>com.apple.security.network.client</key> | ||
| <true/> | ||
| </dict> | ||
| <dict/> |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| /// Calculates the next 00:00 UTC reset time | ||
| private static func calculateNextUTCReset() -> Date { | ||
| var calendar = Calendar.current | ||
| calendar.timeZone = TimeZone(identifier: "UTC") ?? TimeZone.current |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
|
||
| /// Fetches quota information from /users/me/quotas | ||
| private func fetchQuotas(apiKey: String) async throws -> [ChutesQuotaItem] { | ||
| guard let url = URL(string: "https://api.chutes.ai/users/me/quotas") else { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
How do you need it? I will make it for you. |
✅ AI Code Review CompletedReview finished. Critical issues found regarding Entitlements and URL changes. Documentation updated. Todo List
Reviewed with |
|
|
||
| /// Fetches usage from /users/me/quota_usage/* | ||
| private func fetchQuotaUsage(apiKey: String) async throws -> ChutesQuotaUsage { | ||
| guard let url = URL(string: "https://api.chutes.ai/users/me/quota_usage/A") else { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
You can name it everything, except "*" that they dont accept. A is just placeholder for the API.
| async let quotasTask = fetchQuotas(apiKey: apiKey) | ||
| async let usageTask = fetchQuotaUsage(apiKey: apiKey) | ||
|
|
||
| let quotaItems = try await quotasTask | ||
| let usage = try await usageTask |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
🚨 Additional Critical Issues
I detected the following critical issues but was unable to leave inline comments for them:
-
Entitlements Removed (
CopilotMonitor.entitlements):
The file content was replaced with an empty<dict/>. This removes thecom.apple.security.network.cliententitlement, which is CRITICAL for a sandboxed app to make network requests. Please restore it:<dict> <key>com.apple.security.network.client</key> <true/> </dict>
-
Repository URLs Changed (
StatusBarController.swift):
Lines 1191, 1304, and 1332 show the repository URL changed fromopgginc/opencode-bartokargnas/opencode-bar. Please revert these to the upstream URL unless this is an intentional fork transition.
✅ AI Code Review CompletedTodo List
Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Yo, reviewing this new Chutes provider integration. Looks solid overall, just a few nits.
Summary
- Added Chutes provider (quota-based).
- Updated
TokenManager,StatusBarController, andMenuBuilder. - Fixed a repo URL in
StatusBarController(nice catch). - I updated
README.mdto include Chutes in the supported providers list for you.
CI/CD Status
⚠️ Manual Build Check: I couldn't run the full build pipeline (Linux environment), but the Swift code looks syntactically correct.project.pbxprojhas a weirdLastUpgradeCheckvalue.
Security
- ✅ No API keys committed (reads from
auth.json). - ✅ Network requests use HTTPS.
Notes
ProviderProtocol.iconNamefor Chutes returns "chutes". This isn't a standard SF Symbol. WhileStatusBarControllermanually handles it with "c.circle", having "chutes" here might break other views that rely oniconName(likeMultiProviderStatusBarIconViewif it falls back to this). I seeMultiProvider...also hardcodes "c.circle", so it's safe for now, but better to be consistent.project.pbxprojchange toLastUpgradeCheckseems like a typo/bug from a beta Xcode or future time travel.
Solid work otherwise. Merging implies you've tested it runs locally.
| case .zaiCodingPlan: | ||
| return "globe" | ||
| case .chutes: | ||
| return "chutes" |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| BuildIndependentTargetsInParallel = 1; | ||
| LastSwiftUpdateCheck = 1500; | ||
| LastUpgradeCheck = 1500; | ||
| LastUpgradeCheck = 2620; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
✅ AI Code Review CompletedReview finished. Check the PR for inline comments. 📋 View Logs | 🤖 Model: |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Yo, checked the Chutes provider integration. The provider logic looks solid, but we got a major issue with the project settings.
🚨 Critical Issues
- App Sandbox Enabled: You turned on
ENABLE_APP_SANDBOX. This is gonna strictly block the app from reading~/.local/share/opencode/auth.jsonor~/.config/opencode/unless you got entitlements and user permission. Existing users are gonna be locked out of their auth files. Revert this unless you have a migration plan.
⚠️ Concerns
- Project File Churn: The
project.pbxprojhas massive ID changes (CLI...). Looks like some tool or manual edit messed it up. It makes the diff ugly and prone to conflicts. Try to keep it clean next time.
💡 Suggestions
- Use
TokenManagerfor the auth path display instead of hardcoding the fallback.
Fix the Sandbox thing and we are good.
| CURRENT_PROJECT_VERSION = 3; | ||
| DEAD_CODE_STRIPPING = YES; | ||
| DEVELOPMENT_TEAM = ""; | ||
| ENABLE_APP_SANDBOX = YES; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
✅ AI Code Review CompletedThe review has been posted successfully with feedback on Review Status
Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Good work adding Chutes support! The implementation follows the provider pattern well and CI checks are passing.
I've noticed a few opportunities to improve maintainability regarding magic numbers and design tokens. Also, since this is a new provider, please remember to update README.md to list "Chutes" in the supported providers table (Quota-based).
CI/CD Status
All checks passed successfully. ✅
CopilotMonitor/CopilotMonitor/Helpers/ProviderMenuBuilder.swift
Outdated
Show resolved
Hide resolved
✅ AI Code Review Completed
Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
- Chutes provider wired into provider list, icons, menu. New quota fetch/usage logic plus entitlements tweak.
- CI: build/lint green; Test workflow still running at review time.
Issues
- Division by zero risk:
ChutesProvider.fetch()dividesused/quotawithout guardingquota <= 0, so a zero/absent quota will crash convertingDouble.infinitytoIntbefore buildingProviderUsage. Add a guard fallback (e.g., treat 0 quota as 0% used and skip percentage math). - Chutes submenu renders reset info twice and hardcodes indent
18, violatingMenuDesignTokenno-magic-number rule. The case adds aResets:row and the shared reset row adds another; remove the duplicate and use a spacing token. - Docs: README supported providers table still misses Chutes; update per AGENTS doc requirement.
- Tests: no coverage for Chutes parsing/error paths; add a basic fetch decoding test or stub to avoid regressions.
Push new commits to re-run full review automatically, or mention @opgginc/op-gg-ai-devops for another pass (e.g., @opgginc/op-gg-ai-devops recheck chutes math, @opgginc/op-gg-ai-devops add docs for chutes, @opgginc/op-gg-ai-devops verify menu token usage).
|
Thanks for the hard work, I will review soon! |
Merge main into feature/Chutes-toevoeging, resolving conflict in TokenManager.swift by: - Keeping getChutesAPIKey() function from PR opgginc#43 - Using updated comment style from main (NoeFabris/opencode-antigravity-auth reference) Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- ProviderMenuBuilder: 'Primary: X%' → 'Used: X/Y (Z%)' (PR opgginc#54)
- Add ChutesIcon.imageset with chutes-icon.pdf - Replace SF Symbol 'c.circle' with custom Chutes logo - Icon is template-rendered for proper dark/light mode support Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
✅ AI Code Review CompletedReview completed and comments posted. CI checks are still running; local build couldn’t run because Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Summary
- Reviewed Chutes provider integration across data fetch, menu rendering, and project wiring.
- Found two issues that affect usage math and user-facing labels.
CI/CD Status
- Lint: ✅ success
- CI / Build / Test: ⏳ in progress at review time (checked via
gh run list)
Smoke Test
xcodebuild -versionfailed on this runner (xcodebuildnot installed), so I couldn't run a local build here.
Review Notes
- MCP websearch failed with HTTP 402, so no external docs were validated for Chutes API in this pass.
CopilotMonitor/CopilotMonitor/Helpers/ProviderMenuBuilder.swift
Outdated
Show resolved
Hide resolved
✅ AI Code Review CompletedChanges reviewed. Chutes AI provider added correctly and docs updated. Missing unit tests for the new provider. Reviewed with Todo List
|
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
Summary
Changes look solid, dude. You added the Chutes AI provider and updated the docs properly. I see you followed the new Quota Display Rules and Auth Source Labeling requirements from AGENTS-design-decisions.md strictly. Nice.
However, I don't see any unit tests for ChutesProvider. You can't just drop a new provider without verifying it works, especially with the plan tier logic and API parsing. Fix that.
CI/CD Status
- Lint: ✅ Passed
- CI / Build / Test: ⏳ In Progress (Wait for them to pass before merging)
Feedback
- Missing Tests:
ChutesProviderTests.swiftis missing. Create it and test thefetch()logic, error handling, andgetPlanTier. - Strict Compliance: Good job on using
MenuDesignTokenandcreateDisabledLabelViewcorrectly inProviderMenuBuilder.
| /// Provider for Chutes AI API usage tracking | ||
| /// Uses quota-based model with daily limits (300/2000/5000 per day) | ||
| /// Combines data from /users/me/quotas and /users/me/quota_usage/* endpoints | ||
| final class ChutesProvider: ProviderProtocol { |
There was a problem hiding this comment.
Add ChutesProviderTests.swift to cover this class. You need to verify:
- API Response decoding (QuotaItem, QuotaUsage, UserProfile)
getPlanTierlogic (300 -> Base, etc.)- Error handling (401, network errors)
calculateNextUTCResetfallback logic

My first time editing this way. So hopefully all oke!