'use client';
import React, { useState } from 'react';
import { Label } from '@/components/ui/label';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import {
CheckCircle2,
Zap,
RotateCcw,
AlertCircle,
Info,
Loader2
} from 'lucide-react';
import { cn } from '@/lib/utils';
import { ModelInfo } from '@/lib/api';
import { ModelSelectionIndicator, AutoSelectionStatus } from './model-selection-indicator';
interface EnhancedModelSelectProps {
modelType: string;
label: string;
description?: string;
value: string | null;
availableModels: ModelInfo[];
isAutoSelected: boolean;
isUserOverride: boolean;
isLoading?: boolean;
onValueChange: (value: string) => void;
onSetUserOverride: (value: string) => void;
onClearOverride: () => void;
onRevertToAuto?: () => void;
placeholder?: string;
className?: string;
disabled?: boolean;
}
export function EnhancedModelSelect({
modelType,
label,
description,
value,
availableModels,
isAutoSelected,
isUserOverride,
isLoading = false,
onValueChange,
onSetUserOverride,
onClearOverride,
onRevertToAuto,
placeholder = "Select a model...",
className,
disabled = false,
}: EnhancedModelSelectProps) {
const [isOpen, setIsOpen] = useState(false);
const selectedModel = value ? availableModels.find(m => m.name === value) : null;
const isLoaded = selectedModel?.loaded || false;
const handleValueChange = (newValue: string) => {
if (newValue !== value) {
onValueChange(newValue);
onSetUserOverride(newValue);
}
};
const handleClearOverride = () => {
onClearOverride();
};
const handleRevertToAuto = () => {
if (onRevertToAuto) {
onRevertToAuto();
}
};
const getModelIcon = (type: string) => {
switch (type.toLowerCase()) {
case 'vae':
return
{description}
)}No {modelType} models found. Please add {modelType} models to your models directory.
{description}
)}