Skip to content

feat: live quota windows for Gemini, Copilot, Antigravity (local-credential, no cookies) + settings toggles everywhere #1112

Closed

Description

@iamtoruk

Live quota coverage: Gemini, Copilot, Antigravity (Kimi audited, not duplicated)

Context

The desktop app already polls live vendor quota for Claude and Codex (app/electron/quota/{claude,codex}.ts): borrow the credential already on disk (Claude Code OAuth from keychain / Codex auth), call the vendor's own usage endpoint, render windows (5-hour / weekly / plan label) in the app's Live quota panel, Settings "Detected" rows, and the menubar surfaces. 5-minute politeness floor, 429 backoff persisted to ~/.codeburn/quota-backoff.json, sanitizeError, per-provider tests. Derived windows (computed from the local ledger vs plan config, src/quota.ts) fill anything live doesn't report; live wins per window on merge.

Extend LIVE quota to three more providers, following the existing pattern exactly.

Providers to add

  1. Gemini — credential: Gemini CLI OAuth creds on disk (~/.gemini/oauth_creds.json or current location — verify against installed Gemini CLI). Endpoint: the OAuth-backed quota API the Gemini CLI itself uses (steipete/CodexBar docs/gemini.md documents this approach as prior art; derive endpoint from the CLI's own source/traffic, cite it in a comment). Windows: whatever the API reports (daily request quota etc.).
  2. Copilot — credential: local GitHub Copilot token (~/.config/github-copilot/hosts.json / apps.json). Endpoint: Copilot internal usage API (CodexBar docs/copilot.md = prior art). Report plan label + premium-request usage windows as exposed. Mark clearly in code comments that this is an internal API that may drift; failures must degrade to transientFailure/terminalFailure honestly, never crash the panel.
  3. Antigravity — LOCAL ONLY: language-server probe / agy CLI if present (CodexBar docs/antigravity.md = prior art, marked experimental there). No Google OAuth fallback in v1. If the local probe isn't available, show disconnected with the existing ConnectAffordance pattern.

Kimi — audit, do not duplicate

KimiCode quota already surfaces (e.g. "99% of quota used" banner). FIRST map where it comes from (live fetch somewhere, or derived plan-usage). Report the finding. Only if it is purely derived AND a local kimi-auth credential (JWT) is available, add a live provider for it in the same pattern; otherwise leave untouched.

Required changes (map before editing)

  • app/electron/quota/types.ts: widen provider union; keep QuotaWindow shape unchanged (payload add-only).
  • app/electron/quota/index.ts: register fetchers; each gets the same politeness floor + backoff treatment; deps injectable for tests like the existing ones.
  • New app/electron/quota/{gemini,copilot,antigravity}.ts + matching .test.ts (mock fetch/fs; NEVER hit live endpoints in tests; mirror claude.test.ts/codex.test.ts structure and coverage: happy path, missing credential, expired token, 429 backoff, malformed response).
  • app/renderer/sections/Settings.tsx:331: DetectedRow hardcodes the Claude/Codex display names — replace with a provider→name map. Extend the existing per-provider enable/disable mechanism to the new providers (find how claude/codex polling is toggled today; if quota polls everything detected with no toggle, add a per-provider toggle persisted in the app settings store, default ON for detected credentials, and honor it in the electron main poller).
  • app/renderer/sections/Plans.tsx Live quota panel: verify it renders N providers generically (it maps over the array — confirm nothing else hardcodes two providers).
  • app/renderer/components/ProviderLogo.tsx: ensure logos exist for the three providers (they exist for usage display; verify the quota code path uses the same component).
  • Menubar surface: find how the menubar consumes quota (same electron process or payload) and confirm new providers flow through without menubar-side hardcoding; if the macOS menubar app hardcodes providers, list the exact spots in the report instead of hacking around them.

Hard constraints

  • Privacy: reuse credentials already on disk only. NO browser-cookie scraping, no password prompts, no new credential storage. Document every endpoint called in a comment block at the top of each provider file.
  • Payloads add-only (CLI-app contract). No changes to src/ CLI parsing/pricing code paths.
  • All fetch errors sanitized (sanitizeError) — no tokens in logs ever. Test that explicitly per provider (claude.test.ts has the pattern).
  • Failures degrade per the existing connection states; the panel must render fine with any subset of providers failing.
  • Style: match existing code exactly. No new dependencies. Comments only where the WHY is non-obvious (endpoint provenance counts as non-obvious).
  • Tests: cd app && npx vitest run electron/quota green, plus the app suite you touched. Typecheck green.

Deliverables

Working code on the current branch (do not create branches, do not commit — the reviewer handles git), plus REPORT.md at repo root: kimi audit finding, endpoint provenance per provider, toggle mechanism found/added, menubar findings, test results.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions