ModelSelector conditional elements

This commit is contained in:
Alex Gleason committed 2025-08-28 17:17:05 -05:00
1 parent 2b95959361
commit 7fe8236611
1 file changed
+13 -11
+13 -11
View File
@@ -29,7 +29,7 @@ export function ModelSelector({
const [isCustomInput, setIsCustomInput] = useState(false); const [isCustomInput, setIsCustomInput] = useState(false);
const [customValue, setCustomValue] = useState(''); const [customValue, setCustomValue] = useState('');
const [settingsOpen, setSettingsOpen] = useState(false); const [settingsOpen, setSettingsOpen] = useState(false);
const { settings, addRecentlyUsedModel } = useAISettings(); const { settings, addRecentlyUsedModel, isConfigured } = useAISettings();
const { models, isLoading, error, refetch } = useProviderModels(); const { models, isLoading, error, refetch } = useProviderModels();
const recentlyUsedModels = useMemo(() => settings.recentlyUsedModels || [], [settings.recentlyUsedModels]); const recentlyUsedModels = useMemo(() => settings.recentlyUsedModels || [], [settings.recentlyUsedModels]);
@@ -137,18 +137,20 @@ export function ModelSelector({
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-80 p-0" align="end"> <PopoverContent className="w-80 p-0" align="end">
<Command> <Command>
<CommandInput placeholder="Search models..." className="h-9" /> {isConfigured && <CommandInput placeholder="Search models..." className="h-9" />}
<CommandList className="max-h-[300px]"> <CommandList className="max-h-[300px]">
{/* Custom model option and manage providers - always visible at the top */} {/* Custom model option and manage providers */}
<CommandGroup> <CommandGroup>
<CommandItem {isConfigured && (
value="__custom_model_option__" <CommandItem
onSelect={() => handleSelect('__custom__')} value="__custom_model_option__"
className="cursor-pointer" onSelect={() => handleSelect('__custom__')}
> className="cursor-pointer"
<Edit3 className="mr-2 h-4 w-4" /> >
Enter custom model... <Edit3 className="mr-2 h-4 w-4" />
</CommandItem> Enter custom model...
</CommandItem>
)}
<CommandItem <CommandItem
value="__manage_providers_option__" value="__manage_providers_option__"
onSelect={() => handleSelect('__manage_providers__')} onSelect={() => handleSelect('__manage_providers__')}