From 58f8cb0bd3f56a64f8623b9a4f7d9e3bf34eb8a3 Mon Sep 17 00:00:00 2001 From: Augustin Date: Wed, 22 Apr 2026 20:56:04 +0200 Subject: [PATCH] fix(config): per-provider form state to avoid field cross-talk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - providerForm is now keyed by provider name - Each provider (minimax/glm/claude) has isolated form data - Validation and save target the specific provider being edited 💘 Generated with Crush Assisted-by: MiniMax-M2.7 via Crush --- web/src/components/Config.jsx | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/web/src/components/Config.jsx b/web/src/components/Config.jsx index 2b2d735..baf6ce0 100644 --- a/web/src/components/Config.jsx +++ b/web/src/components/Config.jsx @@ -6,7 +6,6 @@ import { getLayoutList } from '../i18n/keyboards' const PANELS = [ { id: 'profile', icon: User }, { id: 'providers', icon: Brain }, - { id: 'terminal', icon: Monitor }, { id: 'updates', icon: RefreshCw }, { id: 'locale', icon: Globe }, { id: 'skills', icon: Wrench }, @@ -26,7 +25,7 @@ export default function Config({ api }) { const [editProfile, setEditProfile] = useState(false) const [editProvider, setEditProvider] = useState(null) const [profileForm, setProfileForm] = useState({}) - const [providerForm, setProviderForm] = useState({}) + const [providerForm, setProviderForm] = useState({}) // keyed by provider name const [toast, setToast] = useState(null) @@ -108,9 +107,11 @@ export default function Config({ api }) { } } - const handleSaveProvider = async () => { + const handleSaveProvider = async (name) => { + const form = providerForm[name] + if (!form) return try { - await api.saveProvider(providerForm) + await api.saveProvider({ name, ...form }) setEditProvider(null) loadData() showToast(t('config.saved')) @@ -120,12 +121,15 @@ export default function Config({ api }) { } const openProviderEdit = (p) => { - setProviderForm({ - name: p.name, - api_key: p.apiKey || '', - model: p.model || '', - base_url: p.baseURL || '', - }) + setProviderForm(prev => ({ + ...prev, + [p.name]: { + name: p.name, + api_key: p.apiKey || '', + model: p.model || '', + base_url: p.baseURL || '', + }, + })) setEditProvider(p.name) } @@ -303,23 +307,26 @@ function PanelProviders({ providers, editProvider, providerForm, setProviderForm className="config-form-input" type="password" placeholder={t('config.tokenPlaceholder')} - value={isEditing ? providerForm.api_key : ''} + value={isEditing ? (providerForm[p.name]?.api_key || '') : ''} onChange={e => { if (!isEditing) openProviderEdit(p) - setProviderForm(f => ({ ...f, api_key: e.target.value })) + setProviderForm(prev => ({ + ...prev, + [p.name]: { ...(prev[p.name] || {}), api_key: e.target.value }, + })) }} />
{isValidationTarget && validationStatus?.valid && ( - + )}