Skip to content

feat: better authentication UX — proactive key check & key discovery#2796

Open
ibetitsmike wants to merge 1 commit intomainfrom
fix/better-auth-ux
Open

feat: better authentication UX — proactive key check & key discovery#2796
ibetitsmike wants to merge 1 commit intomainfrom
fix/better-auth-ux

Conversation

@ibetitsmike
Copy link
Contributor

Summary

Implements both parts of #1:

Part 1: Ask for key before message

Shows an inline warning banner in the chat input area when the active workspace's model requires an unconfigured or disabled provider — before the user tries to send a message and gets an error.

  • Banner appears immediately on workspace select / model change
  • Shows "API key required for {provider}" or "Provider is disabled"
  • "Providers" button opens Settings → Providers for the relevant provider
  • Gateway-aware: suppressed when the model is routed through Mux Gateway

New files:

  • ProviderNotConfiguredBanner.tsx — banner component
  • ProviderNotConfiguredBanner.test.tsx — 15 tests

Part 2: Authentication stealing (key discovery)

New backend service scans known AI tool config locations for API keys and offers to import them during onboarding with explicit user consent.

Sources scanned:

  • Claude Code (~/.claude.json, ~/.config/claude/settings.json, ~/.claude/.env)
  • Codex CLI (~/.codex/config.json, ~/.codex/auth.json)
  • aider (~/.aider.conf.yml)
  • Continue.dev (~/.continue/config.json)
  • Shell RC files (.bashrc, .zshrc, .profile, .bash_profile)

Security:

  • Full keys never cross the IPC boundary — only masked previews
  • Import re-reads the source at import time (no caching of raw keys)
  • Config writes use existing Config.saveProvidersConfig() with mode: 0o600
  • Clear consent message shown before import

New files:

  • keyDiscoveryService.ts — backend scanner + import logic
  • keyDiscoveryService.test.ts — 27 tests

Modified files:

  • schemas/api.tsDiscoveredKeySchema, keyDiscovery.discover/import schemas
  • schemas.ts — barrel re-export
  • router.ts — oRPC handler implementations
  • OnboardingWizardSplash.tsx — conditional wizard step with checkboxes + consent
  • ChatInput/index.tsx — renders ProviderNotConfiguredBanner

Validation

  • tsc --noEmit — 0 errors
  • eslint — 0 errors
  • 50 tests pass (15 + 27 + 8 existing)

Closes #1

Implements both parts of #1:

1. Proactive auth check on workspace select: Shows an inline warning
   banner in the chat input when the active model's provider is not
   configured or is disabled, before the user tries to send a message.
   Gateway-aware — suppressed when the model is routed through Mux
   Gateway.

2. Key discovery from other AI tools: New backend service scans known
   config locations (Claude Code, Codex CLI, aider, Continue.dev,
   shell RC files) for API keys and offers to import them during
   onboarding. Full keys never cross the IPC boundary — only masked
   previews. Import requires explicit user consent.

Closes #1
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fab410599

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +283 to +287
const pattern = new RegExp(
`^\\s*export\\s+${mapping.envVar}\\s*=\\s*["']?([^"'\\s#]+)["']?`,
"m"
);
const match = pattern.exec(content);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse the effective shell export value

The shell RC scanner calls pattern.exec(content) once per env var, so it always captures the first matching export line. In shell startup files, later assignments override earlier ones; when users rotate keys by appending a new export, discovery will import the stale value and the provider will still fail authentication after onboarding.

Useful? React with 👍 / 👎.

Comment on lines +557 to +558
// Pre-select all discovered keys
setSelectedKeys(new Set(keys.map((k) => `${k.provider}:${k.source}`)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require explicit choice for duplicate provider keys

This pre-selects every discovered key, including multiple entries for the same provider, and handleImportKeys then imports all selected entries in order. If two sources contain different keys for one provider, the later import silently overwrites the earlier one, so users can end up with an unintended/stale credential unless they manually detect and uncheck duplicates.

Useful? React with 👍 / 👎.

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.

Better authentication UX

1 participant