'use client'; import { useEffect, useState } from 'react'; import Link from 'next/link'; import { Header, AppLayout } from '@/components/layout'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { apiClient } from '@/lib/api'; import { ProtectedRoute } from '@/components/auth/protected-route'; import { useAuth } from '@/lib/auth-context'; import { ImagePlus, Image, Sparkles, Settings, Activity, ArrowRight, CheckCircle2, XCircle, User, LogOut } from 'lucide-react'; const features = [ { title: 'Text to Image', description: 'Generate stunning images from text descriptions using Stable Diffusion', icon: ImagePlus, href: '/text2img', color: 'text-blue-500', }, { title: 'Image to Image', description: 'Transform existing images with AI-powered modifications', icon: Image, href: '/img2img', color: 'text-purple-500', }, { title: 'Upscaler', description: 'Enhance and upscale your images for higher quality results', icon: Sparkles, href: '/upscaler', color: 'text-green-500', }, { title: 'Model Management', description: 'Load, unload, and manage your AI models efficiently', icon: Settings, href: '/models', color: 'text-orange-500', }, { title: 'Queue Monitor', description: 'Track and manage your generation jobs in real-time', icon: Activity, href: '/queue', color: 'text-pink-500', }, ]; export default function HomePage() { const { user, logout, isAuthenticated, isLoading, authEnabled } = useAuth(); const [health, setHealth] = useState<'checking' | 'healthy' | 'error'>('checking'); const [systemInfo, setSystemInfo] = useState<{ version?: string; cuda_available?: boolean } | null>(null); const checkHealth = async () => { try { await apiClient.getHealth(); setTimeout(() => setHealth('healthy'), 0); } catch (err) { console.error('Health check failed:', err); setTimeout(() => setHealth('error'), 0); } }; const loadSystemInfo = async () => { try { const info = await apiClient.getSystemInfo(); setTimeout(() => setSystemInfo(info), 0); } catch (err) { console.error('Failed to load system info:', err); } }; useEffect(() => { // Check health and system info regardless of authentication status checkHealth(); loadSystemInfo(); // Set up periodic health checks with proper cleanup const healthInterval = setInterval(checkHealth, 30000); // Check every 30 seconds const systemInfoInterval = setInterval(loadSystemInfo, 60000); // Check every minute return () => { clearInterval(healthInterval); clearInterval(systemInfoInterval); }; }, []); // Show loading state while checking authentication if (isLoading) { return (
Loading...
A modern, intuitive interface for Stable Diffusion image generation
Navigate to Model Management and load your preferred checkpoint
Select Text to Image, Image to Image, or Upscaler
Start generation and track progress in the Queue Monitor