diff --git a/app/src/components/ServerSettings/CudaDownloadSection.tsx b/app/src/components/ServerSettings/CudaDownloadSection.tsx deleted file mode 100644 index d6c22207..00000000 --- a/app/src/components/ServerSettings/CudaDownloadSection.tsx +++ /dev/null @@ -1,173 +0,0 @@ -import { useState, useEffect } from 'react'; -import { useQuery } from '@tanstack/react-query'; -import { Loader2, RefreshCw, CheckCircle, AlertCircle } from 'lucide-react'; -import { relaunch } from '@tauri-apps/plugin-process'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Button } from '@/components/ui/button'; -import { Badge } from '@/components/ui/badge'; -import { Alert, AlertDescription } from '@/components/ui/alert'; -import { ModelProgress } from './ModelProgress'; -import { apiClient } from '@/lib/api/client'; -import { useServerStore } from '@/stores/serverStore'; -import { toast } from '@/components/ui/use-toast'; -import { usePlatform } from '@/platform/PlatformContext'; -import { useServerHealth } from '@/lib/hooks/useServer'; - -export function CudaDownloadSection() { - const platform = usePlatform(); - const serverUrl = useServerStore((state) => state.serverUrl); - const { data: health } = useServerHealth(); - const [downloadingCuda, setDownloadingCuda] = useState(false); - const [downloadError, setDownloadError] = useState(null); - - // Platform checks - const isWindows = navigator.userAgent.includes('Windows'); - const gpuAvailable = health?.gpu_available ?? false; - - // Only show this section on Windows + Tauri + GPU available - if (!platform.metadata.isTauri || !isWindows || !gpuAvailable) { - return null; - } - - // Query CUDA status - const { data: cudaStatus, refetch } = useQuery({ - queryKey: ['cudaStatus'], - queryFn: () => apiClient.getCudaStatus(), - enabled: isWindows && platform.metadata.isTauri && gpuAvailable, - retry: false, - }); - - // Handle download trigger - const handleDownload = async () => { - try { - setDownloadError(null); - await apiClient.triggerCudaDownload(); - setDownloadingCuda(true); - } catch (error) { - setDownloadError(error instanceof Error ? error.message : 'Failed to start download'); - } - }; - - // Handle retry - const handleRetry = () => { - setDownloadError(null); - handleDownload(); - }; - - // Monitor download progress and auto-restart on completion - useEffect(() => { - if (!downloadingCuda || !serverUrl) return; - - const eventSource = new EventSource(`${serverUrl}/models/progress/cuda-binary`); - - eventSource.onmessage = (event) => { - try { - const data = JSON.parse(event.data); - - if (data.status === 'complete' && data.progress >= 100) { - eventSource.close(); - setDownloadingCuda(false); - - // Show restart toast - toast({ - title: 'CUDA Downloaded', - description: 'Restarting app to enable GPU acceleration...', - }); - - // Restart after 2 seconds - setTimeout(async () => { - await relaunch(); - }, 2000); - } - - if (data.status === 'error') { - eventSource.close(); - setDownloadingCuda(false); - setDownloadError(data.error || 'Download failed'); - } - } catch (error) { - console.error('Error parsing CUDA download progress:', error); - } - }; - - eventSource.onerror = () => { - eventSource.close(); - setDownloadingCuda(false); - setDownloadError('Connection to server lost'); - }; - - return () => eventSource.close(); - }, [downloadingCuda, serverUrl]); - - if (!cudaStatus) { - return null; - } - - const { cuda_available, cuda_active, cuda_binary_size_mb } = cudaStatus; - - return ( - - - GPU Acceleration - - - {/* Status badges */} -
- - Mode: {cuda_active ? 'CUDA' : 'CPU'} - - - GPU: {gpuAvailable ? 'Available' : 'Not Available'} - -
- - {/* Already downloaded status */} - {cuda_available && !downloadingCuda && ( - - - - CUDA support is active. GPU acceleration enabled. - - - )} - - {/* Download section - only show if not already downloaded */} - {!cuda_available && !downloadError && !downloadingCuda && ( -
-

- Download CUDA support for 4-5x faster inference with your NVIDIA GPU -

- -
- )} - - {/* Progress display */} - {downloadingCuda && ( -
- -
- )} - - {/* Error with retry button */} - {downloadError && ( -
- - - {downloadError} - - -
- )} -
-
- ); -}