Add optional Copilot budget extras#1273
Conversation
- Import optional GitHub web budget windows for Copilot - Add settings for budget extras, cookies, and icon selection - Cover the new resolver, fetcher, and settings persistence
- Default Copilot budget cookie import to Chrome only - Surface budget fetch and decode failures consistently - Cover cookie defaults and invalid budget JSON
- Ignore stale manual cookies when budget cookies are auto - Cover Copilot budget cookie source routing
- Default budget extras off unless explicitly enabled - Harden budget web fetch and manual cookie refresh - Document budget cookie and reset heuristics
- Forward the budget extras setting into provider previews - Cover Copilot preview budget visibility
- Centralize UsageSnapshot extra-window copying - Clear Copilot reset baselines consistently - Remove dead Copilot budget overloads - Log when budget pagination hits the page cap
|
Codex review: needs maintainer review before merge. Reviewed June 2, 2026, 5:14 AM ET / 09:14 UTC. Summary Reproducibility: not applicable. this is an opt-in feature PR rather than a bug report with a failing current-main path. Source and screenshots show the new behavior path, but there is no current-main failure to reproduce. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge only after a maintainer explicitly accepts the opt-in GitHub billing-cookie surface and the branch is refreshed or checked against current main. Do we have a high-confidence way to reproduce the issue? Not applicable; this is an opt-in feature PR rather than a bug report with a failing current-main path. Source and screenshots show the new behavior path, but there is no current-main failure to reproduce. Is this the best way to solve the issue? Mostly yes at the implementation level: the fetch is opt-in, best-effort, Chrome-only by default, and account-bound. It still needs maintainer product/security approval because the chosen solution relies on GitHub web billing cookies. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against dc4e4835bc6e. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
- Thread selected Copilot account identity into settings - Reject budget cookie sessions for a different GitHub account - Cover the matching and mismatched account flows in tests
- Resolve GitHub identity from the active token before cookie checks - Cover stale selected account identifiers in budget tests
- Treat missing budget identity metadata as invalid response - Reuse compiled meta parsing regexes and tighten test stubs
- Clear mismatched cached budget cookies before browser fallback - Treat missing GitHub identity as an unknown account mismatch - Cover cached mismatch and missing-identity fallback behavior
Findings
Proof Added
Validation
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
This PR adds an opt-in Copilot budget extras feature. When enabled, CodexBar keeps the existing Copilot usage fetch via the GitHub Copilot internal API, then best-effort fetches the user's configured GitHub billing budgets from the logged-in GitHub web billing endpoint and renders matching Copilot budgets as extra menu bars.
The feature is disabled by default. If the budget fetch fails, is unauthenticated, or returns no positive Copilot-related budgets, the normal Copilot usage bars remain unchanged.
Note: I cannot test organization-based budgets, therefore I have not implemented them. These would be more easily fetched via the documented API endpoints, without requiring web-based cookie auth. Leaving this note here in case anyone cares to implement it in a follow-up.
Motivation
Budgets play an increasing crucial role now, with the coming (now present) changes to Github Copilot billing, becoming token-usage based, as it'll become much easier to hit the plan's included usage and trigger configured budgets.
What Changed
CopilotBudgetWebFetcher, which fetcheshttps://github.com/settings/billing/budgets?page=<page>&page_size=10&scope=customerusing github.com web cookies and maps positive Copilot-related budgets intoextraRateWindows.payload.budgets,uuid,pricingTargetId,pricingTargetType,targetName,targetAmount, andcurrentAmount.Budget - <budget type>, for exampleBudget - All Premium Request SKUs.Budget extras, disabled by default.Menu bar secondary metric, allowing the icon's second meter to use Chat or a specific budget bar.docs/copilot.md.Safety And Fallbacks
invalidResponseerror.Tests
Validated during the review/assessment pass:
swift test --filter CopilotBudgetWebFetcherTestsswift test --filter CopilotBudgetCookieRoutingTestsswift test --filter BrowserCookieOrderStatusStringTestsswift test --filter ProviderSettingsDescriptorTestsswift test --filter ProvidersPaneCoverageTestsswift test --filter MenuCardModelTestsmake checkswift testFinal full-suite rerun passed with 3,235 tests in 386 suites.
Review Notes
Main agent was GPT-5.5 on high reasoning with user oversight.
Code was assessed with CodeRabbit, Codex review, and LGTM (Copilot Code Review + Gemini 3.1 Pro Preview + Claude Sonnet 4.6 + Claude Opus 4.8 + Raptor mini). Review fixes landed for cookie import defaults, cookie routing, fetch error handling, malformed amount parsing, manual-cookie refresh UX, budget extras default state, docs, settings preview behavior, centralized
UsageSnapshotextra-window copying, reset-baseline cleanup, pagination cap logging, and dead overload removal. The final Codex review reported no remaining findings.Proof