Skip to content

Add opt-in Vercel personal AI Gateway budget - #961

Merged
Finesssee merged 4 commits into
mainfrom
feat/vercel-gateway-budget
Oct 21, 2026
Merged

Finesssee merged 4 commits into
mainfrom
feat/vercel-gateway-budget

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Ports upstream CodexBar 0.79 opt-in Vercel personal AI Gateway budget (steipete#4623 / steipete#4650) into the Rust Vercel provider.

  • Default behavior is unchanged. With no Vercel access token configured, /v1/credits (team credit balance and lifetime spend) is fetched exactly as before.
  • Opt-in personal budget: once a Vercel access token is entered (Settings > Providers > Vercel, or VERCEL_ACCESS_TOKEN) and a Team ID is set (Settings > Providers > Vercel, or VERCEL_TEAM_ID), the provider reads the personal AI Gateway budget and shows Spend / Limit / Remaining under a "Personal budget" section.
  • Team ID is stored per provider in the workspace slot and validated at save time. A missing Team ID while a token is set returns a ProviderError::Other message (not NotInstalled).
  • Access token uses the existing management-token slot (DPAPI-protected settings, redacted in config dumps, validate_single_line_secret / MAX_API_KEY_LEN). It is never logged.
  • Origin separation: the access token is only sent to api.vercel.com; the AI Gateway key is only sent to ai-gateway.vercel.sh. A test asserts the gateway key never reaches api.vercel.com.
  • Budget period resets are computed in UTC. Budget matching follows the upstream rules (ambiguity handling, pagination cap). See docs/PROVIDERS.md > "Vercel AI Gateway".
  • Settings UI: new VercelAccessTokenCreds section (token set/remove, configured state) and a Team ID field in OpenAiExtras. Seven new i18n keys in all 10 locales (check-locale passes, 1837 keys).
  • Proof: vercel added to the proof catalog with a fixture (Spend $42.00 / Limit $100.00 / Remaining $58.00, "Personal budget"). Two scenarios: flyout-vercel-budget and settings-vercel-budget.
  • Docs: docs/PROVIDERS.md section, README Vercel row.

Windows differences from the Mac port:

  • Token storage uses the Windows DPAPI-protected settings slot instead of the macOS Keychain.
  • Team ID is a per-provider setting (not shared with the credits path), with env var fallback.
  • Settings UI for token and Team ID is added (the upstream Swift app used its own UI).

Commits on feat/vercel-gateway-budget:

  • 36edf0151 Add opt-in Vercel personal AI Gateway budget
  • 97fb8e865 Add Vercel access token commands and Team ID validation
  • 98e56304b Add Vercel personal budget settings fields
  • a4a7970fb Document the opt-in Vercel personal budget

Not changed: CHANGELOG.md.

Proof

Label: Chromium, mocked IPC (pnpm proof:check, 33/33 scenarios). Settings and flyout screenshots were checked visually. Full CUA desktop proof was not run in this lane; the change is covered by the proof harness scenarios above. Reviewers should run the CUA retest loop if a real-desktop check is required.

Commands run

  • cargo fmt --all -- --check (rust and tauri manifests): clean
  • cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: clean
  • cargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings: clean
  • cargo test --manifest-path rust/Cargo.toml: 5108 passed, 0 failed, 2 ignored (vercel: 37 tests; provider_workspace: 9 tests)
  • cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml: 755 passed
  • pnpm install --frozen-lockfile (apps/desktop-tauri): ok
  • pnpm exec tsc --noEmit: ok
  • pnpm test: 156 files, 1492 tests passed
  • pnpm lint: 0 errors (16 pre-existing warnings, none in touched files)
  • pnpm run check-locale: ok (1837 keys match)
  • pnpm run check:anti-slop: ok
  • pnpm proof:check: 33/33 passed

No new dependencies. No deletions.

Factory Agent added 4 commits October 21, 2026 12:17
With a Vercel access token configured, the Vercel provider reads the
token user's AI Gateway budget from api.vercel.com instead of the team
credits endpoint. Without a token the credits path is unchanged.

- Identify the user with /v2/user, then page through
  /ai-gateway/budgets/list (scopeType=user, at most 20 pages).
- Match the native user ID or its usr_ form; a custom budget wins over
  an inherited default; two applicable budgets fail the refresh.
- Daily, weekly and monthly budgets reset at UTC boundaries; none is
  cumulative with no reset.
- The access token is read from the provider's stored secret, else
  VERCEL_ACCESS_TOKEN, and is only sent to api.vercel.com. The Team ID
  comes from the provider's Team ID setting, else VERCEL_TEAM_ID.
- Store the optional Vercel personal-budget access token in the
  provider's management token slot, the same DPAPI-protected settings
  field OpenRouter uses. Add has, set and remove Tauri commands.
  The token is never returned to the UI.
- Validate a Vercel Team ID when it is saved, using the same shape rule
  the budget request enforces, so an invalid ID is rejected up front.
Settings > Providers > Vercel gains an access-token field and a Team ID
field. Both are optional: without a token the card keeps showing team
credits. Strings are added to every locale, and new proof scenarios
cover the budget card and the settings pane with synthetic data.
Describe the Vercel access token and Team ID setup, the budget requests
and matching rules, UTC reset boundaries, and the host each secret is
sent to. Update the README provider row.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 52561c98-5c11-4200-a48f-bd31a169c4b6
📥 Commits

Reviewing files that changed from the base of the PR and between 9ec2780 and a4a7970.

📒 Files selected for processing: 28
  • README.md
  • apps/desktop-tauri/scripts/proof-scenarios.json
  • apps/desktop-tauri/src-tauri/src/commands/provider_settings.rs
  • apps/desktop-tauri/src-tauri/src/main.rs
  • apps/desktop-tauri/src/i18n/keyGroups/shell.ts
  • apps/desktop-tauri/src/lib/tauri.ts
  • apps/desktop-tauri/src/proof/fixtures/common.ts
  • apps/desktop-tauri/src/proof/fixtures/scenarios.ts
  • apps/desktop-tauri/src/proof/router.ts
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/CredentialsDispatcher.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/credentials/OpenAiExtras.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/credentials/VercelAccessTokenCreds.tsx
  • docs/PROVIDERS.md
  • rust/src/locale.rs
  • rust/src/locale/en-US.ftl
  • rust/src/locale/es-MX.ftl
  • rust/src/locale/ja-JP.ftl
  • rust/src/locale/ko-KR.ftl
  • rust/src/locale/pt-BR.ftl
  • rust/src/locale/ru-RU.ftl
  • rust/src/locale/tr-TR.ftl
  • rust/src/locale/uk-UA.ftl
  • rust/src/locale/zh-CN.ftl
  • rust/src/locale/zh-TW.ftl
  • rust/src/providers/vercel/budget.rs
  • rust/src/providers/vercel/budget_tests.rs
  • rust/src/providers/vercel/mod.rs
  • rust/src/settings/provider_workspace.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee merged commit a465d26 into main Oct 21, 2026
4 checks passed
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