import { useState } from 'react'; function Settings({ profiles, activeProfileId, onSaveProfiles, onChangeActiveProfile, onCloseSettings, onSaveSummarizationProfile, summarizationProfile }) { const [localProfiles, setLocalProfiles] = useState(profiles); const [localSummarizationProfile, setLocalSummarizationProfile] = useState(summarizationProfile || { id: 'default-summarization-profile', apiEndpoint: '', apiKey: '', model: 'DeepSeek-R1' }); const [editingProfileId, setEditingProfileId] = useState(activeProfileId); const [isHintExpanded, setIsHintExpanded] = useState(false); const editingProfile = localProfiles.find(p => p.id === editingProfileId) || localProfiles[0]; const editingSummarizationProfile = localSummarizationProfile; const handleProfileChange = (updatedProfile) => { setLocalProfiles(localProfiles.map(p => p.id === updatedProfile.id ? updatedProfile : p )); }; const handleSummarizationProfileChange = (updatedProfile) => { setLocalSummarizationProfile(updatedProfile); }; const handleAddProfile = () => { const newId = `profile-${Date.now()}`; const newProfile = { id: newId, name: `New Profile ${localProfiles.length + 1}`, apiEndpoint: '', apiKey: '', model: 'DeepSeek-R1' }; const updatedProfiles = [...localProfiles, newProfile]; setLocalProfiles(updatedProfiles); setEditingProfileId(newId); }; const handleDeleteProfile = (profileId) => { if (localProfiles.length <= 1) { alert("Cannot delete the last profile"); return; } const updatedProfiles = localProfiles.filter(p => p.id !== profileId); setLocalProfiles(updatedProfiles); if (editingProfileId === profileId) { setEditingProfileId(updatedProfiles[0].id); } }; const handleSubmit = (e) => { e.preventDefault(); onSaveProfiles(localProfiles); onSaveSummarizationProfile(localSummarizationProfile); onChangeActiveProfile(editingProfileId); onCloseSettings(); }; return (

Settings

Chat Profiles

{localProfiles.map(profile => (
setEditingProfileId(profile.id)} > {profile.name} {localProfiles.length > 1 && ( )}
))}
{editingProfile && (

Edit Chat Profile: {editingProfile.name}

handleProfileChange({ ...editingProfile, })} placeholder="Enter profile name" />
handleProfileChange({ ...editingProfile, apiEndpoint: e.target.value })} placeholder="Enter API endpoint" />

API Endpoint format examples:

  • Ends with / → /chat/completions will be appended
  • Ends with # → # will be removed
  • Other cases → /v1/chat/completions will be appended
handleProfileChange({ ...editingProfile, apiKey: e.target.value })} placeholder="Enter your API key" />
handleProfileChange({ ...editingProfile, model: e.target.value })} placeholder="Enter model name (e.g., DeepSeek-R1)" />
)}

Summarization Profile

handleSummarizationProfileChange({ ...localSummarizationProfile, apiEndpoint: e.target.value })} placeholder="Enter API endpoint" />
handleSummarizationProfileChange({ ...localSummarizationProfile, apiKey: e.target.value })} placeholder="Enter your API key" />
handleSummarizationProfileChange({ ...localSummarizationProfile, model: e.target.value })} placeholder="Enter model name (e.g., DeepSeek-R1)" />
); } export default Settings;