/* eslint-disable react-hooks/exhaustive-deps */ 'use client' import { useContext, useEffect, useState, useCallback, ChangeEvent, } from 'react' import { fs } from '@janhq/core' import { Switch, Button, Input } from '@janhq/uikit' import ShortcutModal from '@/containers/ShortcutModal' import { toaster } from '@/containers/Toast' import { FeatureToggleContext } from '@/context/FeatureToggle' import { useSettings } from '@/hooks/useSettings' import DataFolder from './DataFolder' const Advanced = () => { const { experimentalFeature, setExperimentalFeature, ignoreSSL, setIgnoreSSL, proxy, setProxy, } = useContext(FeatureToggleContext) const [partialProxy, setPartialProxy] = useState(proxy) const [gpuEnabled, setGpuEnabled] = useState(false) const { readSettings, saveSettings, validateSettings, setShowNotification } = useSettings() const onProxyChange = useCallback( (event: ChangeEvent) => { const value = event.target.value || '' setPartialProxy(value) if (value.trim().startsWith('http')) { setProxy(value.trim()) } else { setProxy('') } }, [setPartialProxy, setProxy] ) useEffect(() => { readSettings().then((settings) => { setGpuEnabled(settings.run_mode === 'gpu') }) }, []) const clearLogs = async () => { if (await fs.existsSync(`file://logs`)) { await fs.rmdirSync(`file://logs`, { recursive: true }) } toaster({ title: 'Logs cleared', description: 'All logs have been cleared.', }) } return (
{/* Keyboard shortcut */}
Keyboard Shortcuts

Shortcuts that you might find useful in Jan app.

{/* Experimental */}
Experimental Mode

Enable experimental features that may be unstable tested.

{ if (e === true) { setExperimentalFeature(true) } else { setExperimentalFeature(false) } }} />
{/* CPU / GPU switching */} {!isMac && (
NVidia GPU

Enable GPU acceleration for NVidia GPUs.

{ if (e === true) { saveSettings({ runMode: 'gpu' }) setGpuEnabled(true) setShowNotification(false) setTimeout(() => { validateSettings() }, 300) } else { saveSettings({ runMode: 'cpu' }) setGpuEnabled(false) } }} />
)} {/* Directory */} {/* Proxy */}
HTTPS Proxy

Specify the HTTPS proxy or leave blank (proxy auto-configuration and SOCKS not supported).

:@:'} value={partialProxy} onChange={onProxyChange} />
{/* Ignore SSL certificates */}
Ignore SSL certificates

Allow self-signed or unverified certificates - may be required for certain proxies.

{ if (e === true) { setIgnoreSSL(true) } else { setIgnoreSSL(false) } }} />
{/* Open app directory */} {window.electronAPI && (
Open App Directory

Open the directory where your app data, like conversation history and model configurations, is located.

)} {/* Claer log */}
Clear logs

Clear all logs from Jan app.

) } export default Advanced