({
open,
config,
setConfig,
isTestingConnection,
connectionReport,
setupChecklist,
onSaveConfig,
onTestConnection,
onShutdownGateway,
onRestartLauncher,
onClose,
}: SettingsDialogProps)
| 58 | } |
| 59 | |
| 60 | export function SettingsDialog({ |
| 61 | open, |
| 62 | config, |
| 63 | setConfig, |
| 64 | isTestingConnection, |
| 65 | connectionReport, |
| 66 | setupChecklist, |
| 67 | onSaveConfig, |
| 68 | onTestConnection, |
| 69 | onShutdownGateway, |
| 70 | onRestartLauncher, |
| 71 | onClose, |
| 72 | }: SettingsDialogProps) { |
| 73 | const [settingsTab, setSettingsTab] = useState<SettingsTab>('Provider'); |
| 74 | const [saveState, setSaveState] = useState<'idle' | 'saving' | 'saved'>('idle'); |
| 75 | |
| 76 | useEffect(() => { |
| 77 | if (open) { |
| 78 | setSettingsTab('Provider'); |
| 79 | } |
| 80 | }, [open]); |
| 81 | |
| 82 | const currentPreset = |
| 83 | providerPresets.find( |
| 84 | preset => |
| 85 | preset.id !== 'custom' && |
| 86 | preset.upstreamBaseUrl === config.upstreamBaseUrl && |
| 87 | preset.upstreamModel === config.upstreamModel, |
| 88 | ) || null; |
| 89 | |
| 90 | if (!open) { |
| 91 | return null; |
| 92 | } |
| 93 | |
| 94 | function applyPreset(preset: ProviderPreset) { |
| 95 | setConfig(current => ({ |
| 96 | ...current, |
| 97 | upstreamBaseUrl: preset.upstreamBaseUrl, |
| 98 | upstreamModel: preset.upstreamModel, |
| 99 | clawModel: preset.clawModel, |
| 100 | textMode: preset.textMode, |
| 101 | })); |
| 102 | } |
| 103 | |
| 104 | async function pickDirectory(target: 'workspaceDir' | 'clawProjectDir') { |
| 105 | const nextPath = await window.clawDesktop?.pickDirectory?.(); |
| 106 | if (nextPath) { |
| 107 | setConfig(current => ({ |
| 108 | ...current, |
| 109 | [target]: nextPath, |
| 110 | })); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | async function pickBinaryPath() { |
| 115 | const nextPath = await window.clawDesktop?.pickFile?.([ |
| 116 | { name: 'Executable', extensions: ['exe', 'bin', 'cmd'] }, |
| 117 | { name: 'All Files', extensions: ['*'] }, |
nothing calls this directly
no test coverage detected