import { X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import ProviderLoginModal from '../../provider-auth/view/ProviderLoginModal'; import { Button } from '../../../shared/view/ui'; import SettingsSidebar from '../view/SettingsSidebar'; import AgentsSettingsTab from '../view/tabs/agents-settings/AgentsSettingsTab'; import AppearanceSettingsTab from '../view/tabs/AppearanceSettingsTab'; import CredentialsSettingsTab from '../view/tabs/api-settings/CredentialsSettingsTab'; import GitSettingsTab from '../view/tabs/git-settings/GitSettingsTab'; import BrowserUseSettingsTab from '../view/tabs/browser-use-settings/BrowserUseSettingsTab'; import NotificationsSettingsTab from '../view/tabs/NotificationsSettingsTab'; import TasksSettingsTab from '../view/tabs/tasks-settings/TasksSettingsTab'; import PluginSettingsTab from '../../plugins/view/PluginSettingsTab'; import AboutTab from '../view/tabs/AboutTab'; import { useSettingsController } from '../hooks/useSettingsController'; import { useWebPush } from '../../../hooks/useWebPush'; import type { SettingsProps } from '../types/types'; function Settings({ isOpen, onClose, projects = [], initialTab = 'agents' }: SettingsProps) { const { t } = useTranslation('settings'); const { activeTab, setActiveTab, saveStatus, projectSortOrder, setProjectSortOrder, codeEditorSettings, updateCodeEditorSetting, claudePermissions, setClaudePermissions, notificationPreferences, setNotificationPreferences, cursorPermissions, setCursorPermissions, codexPermissionMode, setCodexPermissionMode, providerAuthStatus, geminiPermissionMode, setGeminiPermissionMode, openLoginForProvider, showLoginModal, setShowLoginModal, loginProvider, handleLoginComplete, } = useSettingsController({ isOpen, initialTab }); const { permission: pushPermission, isSubscribed: isPushSubscribed, isLoading: isPushLoading, subscribe: pushSubscribe, unsubscribe: pushUnsubscribe, } = useWebPush(); const handleEnablePush = async () => { await pushSubscribe(); // Server sets webPush: true in preferences on subscribe; sync local state setNotificationPreferences({ ...notificationPreferences, channels: { ...notificationPreferences.channels, webPush: true }, }); }; const handleDisablePush = async () => { await pushUnsubscribe(); // Server sets webPush: false in preferences on unsubscribe; sync local state setNotificationPreferences({ ...notificationPreferences, channels: { ...notificationPreferences.channels, webPush: false }, }); }; if (!isOpen) { return null; } const isAuthenticated = Boolean(loginProvider && providerAuthStatus[loginProvider].authenticated); return (
{/* Header */}

{t('title')}

{saveStatus === 'success' && ( {t('saveStatus.success')} )}
{/* Body: sidebar + content */}
{/* Content */}
{activeTab === 'appearance' && ( updateCodeEditorSetting('theme', value)} onCodeEditorWordWrapChange={(value) => updateCodeEditorSetting('wordWrap', value)} onCodeEditorShowMinimapChange={(value) => updateCodeEditorSetting('showMinimap', value)} onCodeEditorLineNumbersChange={(value) => updateCodeEditorSetting('lineNumbers', value)} onCodeEditorFontSizeChange={(value) => updateCodeEditorSetting('fontSize', value)} /> )} {activeTab === 'git' && } {activeTab === 'agents' && ( )} {activeTab === 'tasks' && } {activeTab === 'browser' && } {activeTab === 'notifications' && ( )} {activeTab === 'api' && } {activeTab === 'plugins' && } {activeTab === 'about' && }
setShowLoginModal(false)} provider={loginProvider || 'claude'} onComplete={handleLoginComplete} isAuthenticated={isAuthenticated} />
); } export default Settings;