import { useEffect, useCallback } from 'react' import { CheckCircle2, XCircle, Loader2, ExternalLink } from 'lucide-react' import { useSetupStatus, useHealthCheck } from '../hooks/useProjects' import { Button } from '@/components/ui/button' import { Card, CardContent } from '@/components/ui/card' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' interface SetupWizardProps { onComplete: () => void } export function SetupWizard({ onComplete }: SetupWizardProps) { const { data: setupStatus, isLoading: setupLoading, error: setupError } = useSetupStatus() const { data: health, error: healthError } = useHealthCheck() const isApiHealthy = health?.status === 'healthy' && !healthError const isReady = isApiHealthy && setupStatus?.claude_cli && setupStatus?.credentials // Memoize the completion check to avoid infinite loops const checkAndComplete = useCallback(() => { if (isReady) { onComplete() } }, [isReady, onComplete]) // Auto-complete if everything is ready useEffect(() => { checkAndComplete() }, [checkAndComplete]) return (

Setup Wizard

Let's make sure everything is ready to go

{/* API Health */} {/* Claude CLI */} {/* Credentials */} {/* Node.js */}
{/* Continue Button */} {isReady && ( )} {/* Error Message */} {(healthError || setupError) && ( Setup Error {healthError ? 'Cannot connect to the backend server. Make sure to run start_ui.py first.' : 'Failed to check setup status.'} )}
) } interface SetupItemProps { label: string description: string status: 'success' | 'error' | 'warning' | 'loading' helpLink?: string helpText?: string optional?: boolean } function SetupItem({ label, description, status, helpLink, helpText, optional, }: SetupItemProps) { return (
{/* Status Icon */}
{status === 'success' ? ( ) : status === 'error' ? ( ) : status === 'warning' ? ( ) : ( )}
{/* Content */}
{label} {optional && ( (optional) )}

{description}

{(status === 'error' || status === 'warning') && helpLink && ( {helpText} )}
) }