import { ExternalLink, KeyRound, X } from 'lucide-react'; import StandaloneShell from '../../standalone-shell/view/StandaloneShell'; import { IS_PLATFORM } from '../../../constants/config'; import type { CliProvider } from '../types'; type LoginModalProject = { name?: string; displayName?: string; fullPath?: string; path?: string; [key: string]: unknown; }; type ProviderLoginModalProps = { isOpen: boolean; onClose: () => void; provider?: CliProvider; project?: LoginModalProject | null; onComplete?: (exitCode: number) => void; customCommand?: string; isAuthenticated?: boolean; }; const getProviderCommand = ({ provider, customCommand, isAuthenticated: _isAuthenticated, }: { provider: CliProvider; customCommand?: string; isAuthenticated: boolean; }) => { if (customCommand) { return customCommand; } if (provider === 'claude') { return 'claude --dangerously-skip-permissions /login'; } if (provider === 'cursor') { return 'cursor-agent login'; } if (provider === 'codex') { return IS_PLATFORM ? 'codex login --device-auth' : 'codex login'; } return 'gemini status'; }; const getProviderTitle = (provider: CliProvider) => { if (provider === 'claude') return 'Claude CLI Login'; if (provider === 'cursor') return 'Cursor CLI Login'; if (provider === 'codex') return 'Codex CLI Login'; return 'Gemini CLI Configuration'; }; const normalizeProject = (project?: LoginModalProject | null) => { const normalizedName = project?.name || 'default'; const normalizedFullPath = project?.fullPath ?? project?.path ?? (IS_PLATFORM ? '/workspace' : ''); return { name: normalizedName, displayName: project?.displayName || normalizedName, fullPath: normalizedFullPath, path: project?.path ?? normalizedFullPath, }; }; export default function ProviderLoginModal({ isOpen, onClose, provider = 'claude', project = null, onComplete, customCommand, isAuthenticated = false, }: ProviderLoginModalProps) { if (!isOpen) { return null; } const command = getProviderCommand({ provider, customCommand, isAuthenticated }); const title = getProviderTitle(provider); const shellProject = normalizeProject(project); const handleComplete = (exitCode: number) => { onComplete?.(exitCode); // Keep the modal open so users can read terminal output before closing. }; return (

{title}

{provider === 'gemini' ? (

Setup Gemini API Access

The Gemini CLI requires an API key to function. Configure it in your terminal first.

  1. 1

    Get your API key

    Google AI Studio
  2. 2

    Run configuration

    Open your terminal and run:

    gemini config set api_key YOUR_KEY
) : ( )}
); }