import { useState, useEffect } from 'react'; import { Stack, Text, Group, TextInput, Button, rem, Switch, } from '@mantine/core'; import { Folder, FolderOpen } from 'lucide-react'; export const GeneralTab = () => { const [installDir, setInstallDir] = useState(''); const [minimizeToTray, setMinimizeToTray] = useState(false); const [platform] = useState(() => navigator.platform.toLowerCase()); useEffect(() => { loadCurrentInstallDir(); loadMinimizeToTray(); }, []); const loadCurrentInstallDir = async () => { try { const currentDir = await window.electronAPI.kobold.getCurrentInstallDir(); setInstallDir(currentDir); } catch (error) { window.electronAPI.logs.logError( 'Failed to load install directory:', error as Error ); } }; const loadMinimizeToTray = async () => { try { const setting = await window.electronAPI.config.get('minimizeToTray'); setMinimizeToTray(setting === true); } catch (error) { window.electronAPI.logs.logError( 'Failed to load minimize to tray setting:', error as Error ); } }; const handleMinimizeToTrayChange = async (checked: boolean) => { try { await window.electronAPI.config.set('minimizeToTray', checked); setMinimizeToTray(checked); } catch (error) { window.electronAPI.logs.logError( 'Failed to save minimize to tray setting:', error as Error ); } }; const handleSelectInstallDir = async () => { try { const selectedDir = await window.electronAPI.kobold.selectInstallDirectory(); if (selectedDir) { setInstallDir(selectedDir); } } catch (error) { window.electronAPI.logs.logError( 'Failed to select install directory:', error as Error ); } }; return (
Installation Directory Choose where application files will be downloaded and stored } />
{!platform.includes('mac') && (
Window Behavior handleMinimizeToTrayChange(event.currentTarget.checked) } label="Minimize to system tray" description="When enabled, minimizing the window will hide it to the system tray instead of the taskbar" />
)}
); };