feat(desktop): add API-billed usage profiles

Closed
IA
2mo ago
+637-171

What & why

Fixes #6966.

The Usage page can already discover several Claude Code and Codex subscription profiles and switch the default profile with one click. API-billed profiles previously required separate workspace or agent configuration, so they could not participate in that account-card workflow.

This change:

  • adds Subscription and API billing modes to each provider's existing Add account dialog;
  • discovers completed API-billed profiles and labels their cards API billing;
  • routes Make default through the existing profile-selection mechanism;
  • keeps API credentials inside the provider CLI rather than sending them through Superset's renderer or host API;
  • identifies successful API logins with a metadata marker, so Superset does not open or parse stored API credentials.

Claude uses the CLI's Console/API-billing login mode. Codex prompts in the terminal with echo disabled and passes the key to codex login --with-api-key over stdin.

Screenshots

Claude Code API billing

Claude Code API billing dialog

Codex API billing

Codex API billing dialog

How I tested it

  • bun run lint — passes (6,728 files)
  • bun run typecheck — passes (38/38 tasks)
  • bun run --cwd packages/i18n check — passes; all shipping locales have zero missing messages
  • Focused profile/command tests — 15 pass, 0 fail
  • Drove the development desktop app through the real Settings → Usage flow for both providers and verified the API-billing tabs and generated commands
  • Confirmed the generated Codex command hides terminal input and contains no API key

I did not complete a real provider login because that would require submitting a live API key.

bun run test reaches two unrelated existing OpenCode wrapper failures in packages/agent-setup/src/agent-wrappers.test.ts caused by missing generated temporary modules when the tests run together. This branch does not modify that package; both failing tests pass individually.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass
  • "Allow edits from maintainers" is checked on the fork PR

Summary by CodeRabbit

  • New Features
    • Added support for API-billed Claude and Codex accounts alongside subscription accounts.
    • Account settings now show an “API billing” badge and explain when quota information is unavailable.
    • Added credential-type selection when adding accounts, with billing mode preserved when switching profiles.
    • Provider sections now load independently and display clearer empty states.
  • Bug Fixes
    • Improved detection and handling of API-billed profiles during sign-in and usage reporting.
  • Documentation
    • Updated English, Japanese, and Chinese translations for API billing and profile terminology.