'use client'; import { useState, useEffect } from 'react'; import { invoke } from '@tauri-apps/api/core'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Switch } from '@/components/ui/switch'; import { Label } from '@/components/ui/label'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { useToast } from '@/hooks/use-toast'; import { Loader2, Save, Search, Shield } from 'lucide-react'; interface SearchConfig { region: string; safe_search: string; max_results: number; enabled: boolean; log_search_content: boolean; retention_days: number; } export function SearchSettingsPanel() { const { toast } = useToast(); const [config, setConfig] = useState(null); const [isLoading, setIsLoading] = useState(false); const [isSaving, setIsSaving] = useState(false); useEffect(() => { loadConfig(); }, []); const loadConfig = async () => { setIsLoading(true); try { const loadedConfig = await invoke('load_search_config_command'); setConfig(loadedConfig); } catch (error) { console.error('Failed to load Search config:', error); toast({ title: 'Error loading configuration', description: String(error), variant: 'destructive', }); } finally { setIsLoading(false); } }; const handleSave = async () => { if (!config) return; setIsSaving(true); try { await invoke('save_search_config_command', { config }); toast({ title: 'Configuration saved', description: 'Search settings have been updated successfully.', }); } catch (error) { console.error('Failed to save Search config:', error); toast({ title: 'Error saving configuration', description: String(error), variant: 'destructive', }); } finally { setIsSaving(false); } }; if (isLoading) { return (
); } if (!config) { return (
Failed to load configuration.
); } return (
DuckDuckGo Search Integration Configure anonymous web search settings provided by DuckDuckGo.
setConfig({ ...config, enabled: checked })} id="search-enabled" />
setConfig({ ...config, max_results: parseInt(e.target.value) || 10 })} min={1} max={50} />
setConfig({ ...config, retention_days: parseInt(e.target.value) || 30 })} min={1} max={365} />

Privacy

Store query text in local history

setConfig({ ...config, log_search_content: checked })} />
); }