"use client"; import { useState, useEffect } from "react"; import { X, Download, Loader2 } from "lucide-react"; interface ModelPullDialogProps { isOpen: boolean; onClose: () => void; modelName: string; onConfirmPull: (modelName: string) => Promise; } interface PullProgress { status: string; digest?: string; total?: number; completed?: number; error?: string; } export function ModelPullDialog({ isOpen, onClose, modelName, onConfirmPull, }: ModelPullDialogProps) { const [isPulling, setIsPulling] = useState(false); const [progress, setProgress] = useState(null); const [error, setError] = useState(null); useEffect(() => { if (!isOpen) { setIsPulling(false); setProgress(null); setError(null); } }, [isOpen]); const handleConfirm = async () => { setIsPulling(true); setError(null); try { await onConfirmPull(modelName); onClose(); } catch (err) { setError(err instanceof Error ? err.message : "Failed to pull model"); } finally { setIsPulling(false); } }; if (!isOpen) return null; return (

Install Model

Install {modelName}?

This will download the model to your local Ollama installation.

{progress && (
Downloading... {progress.total && progress.completed ? `${Math.round( (progress.completed / progress.total) * 100, )}%` : "0%"}
{progress.digest && (

{progress.digest.slice(0, 12)}...

)}
)} {error && (

{error}

)}
); }