@@ -12,7 +12,7 @@ import { useConfigStore } from '@/features/settings/config.store';
1212import { Card , CardContent , CardDescription , CardHeader , CardTitle } from '@/shared/components/ui/card' ;
1313import { Button } from '@/shared/components/ui/button' ;
1414import { Label } from '@/shared/components/ui/label' ;
15- import { Sun , Moon , Monitor , LogOut , Globe , Server , FolderOpen , Play , Square , CheckCircle2 , BarChart3 , Loader2 } from 'lucide-react' ;
15+ import { Sun , Moon , Monitor , LogOut , Globe , Server , FolderOpen , Play , Square , CheckCircle2 , BarChart3 , Loader2 , FileText } from 'lucide-react' ;
1616import { toast } from 'sonner' ;
1717
1818export function SettingsPage ( ) {
@@ -21,7 +21,7 @@ export function SettingsPage() {
2121 const { language, setLanguage } = useLanguageStore ( ) ;
2222 const { logout, connectionStatus } = useAuthStore ( ) ;
2323 const { exePath, autoStart, runInBackground, isServerRunning, setAutoStart, setRunInBackground, browseForExe, startServer, stopServer } = useCliProxyStore ( ) ;
24- const { config, fetchConfig, updateUsageStatistics, updatingUsageStats } = useConfigStore ( ) ;
24+ const { config, fetchConfig, updateUsageStatistics, updatingUsageStats, updateLoggingToFile , updatingLogging } = useConfigStore ( ) ;
2525
2626 useEffect ( ( ) => {
2727 if ( connectionStatus === 'connected' && ! config ) {
@@ -39,6 +39,16 @@ export function SettingsPage() {
3939 }
4040 } ;
4141
42+ const loggingToFileEnabled = Boolean ( config ?. [ 'logging-to-file' ] ?? false ) ;
43+
44+ const handleToggleLogging = async ( ) => {
45+ try {
46+ await updateLoggingToFile ( ! loggingToFileEnabled ) ;
47+ } catch {
48+ toast . error ( t ( 'logging.error' ) ) ;
49+ }
50+ } ;
51+
4252 const themeOptions = [
4353 { value : 'light' , label : t ( 'settings.light' ) , icon : Sun } ,
4454 { value : 'dark' , label : t ( 'settings.dark' ) , icon : Moon } ,
@@ -206,6 +216,47 @@ export function SettingsPage() {
206216 </ CardContent >
207217 </ Card >
208218
219+ { /* Logging Settings */ }
220+ < Card >
221+ < CardHeader >
222+ < CardTitle className = "flex items-center gap-2" >
223+ < FileText className = "h-5 w-5" />
224+ { t ( 'logging.title' ) }
225+ </ CardTitle >
226+ < CardDescription > { t ( 'logging.description' ) } </ CardDescription >
227+ </ CardHeader >
228+ < CardContent >
229+ < div className = "flex items-center justify-between" >
230+ < div className = "space-y-0.5" >
231+ < Label > { t ( 'logging.enabled' ) } </ Label >
232+ < p className = "text-xs text-muted-foreground" >
233+ { t ( 'logging.enabledDesc' ) }
234+ </ p >
235+ </ div >
236+ < button
237+ type = "button"
238+ role = "switch"
239+ aria-checked = { loggingToFileEnabled }
240+ onClick = { handleToggleLogging }
241+ disabled = { updatingLogging || connectionStatus !== 'connected' }
242+ className = { `relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${
243+ loggingToFileEnabled ? 'bg-primary' : 'bg-muted'
244+ } `}
245+ >
246+ { updatingLogging ? (
247+ < Loader2 className = "h-4 w-4 animate-spin mx-auto text-muted-foreground" />
248+ ) : (
249+ < span
250+ className = { `inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${
251+ loggingToFileEnabled ? 'translate-x-6' : 'translate-x-1'
252+ } `}
253+ />
254+ ) }
255+ </ button >
256+ </ div >
257+ </ CardContent >
258+ </ Card >
259+
209260 { /* Theme Settings */ }
210261 < Card >
211262 < CardHeader >
0 commit comments