From fe81715c79627fdc2c01be9e5a32332d14fd6ed4 Mon Sep 17 00:00:00 2001 From: Abhijay007 Date: Sat, 13 Dec 2025 16:48:05 +0000 Subject: [PATCH 1/2] fix :preserve provider engine type when editing custom providers Signed-off-by: Abhijay007 --- .../settings/providers/ProviderGrid.tsx | 2 +- .../forms/CustomProviderForm.tsx | 20 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/ui/desktop/src/components/settings/providers/ProviderGrid.tsx b/ui/desktop/src/components/settings/providers/ProviderGrid.tsx index fe5700259fe3..70c4fa63b0da 100644 --- a/ui/desktop/src/components/settings/providers/ProviderGrid.tsx +++ b/ui/desktop/src/components/settings/providers/ProviderGrid.tsx @@ -198,7 +198,7 @@ function ProviderCards({ }, [providers, isOnboarding, configureProviderViaModal, handleProviderLaunchWithModelSelection]); const initialData = editingProvider && { - engine: editingProvider.config.engine.toLowerCase(), + engine: editingProvider.config.engine, display_name: editingProvider.config.display_name, api_url: editingProvider.config.base_url, api_key: '', diff --git a/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx b/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx index be57a3ec9918..710378e06662 100644 --- a/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx +++ b/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx @@ -19,7 +19,7 @@ export default function CustomProviderForm({ initialData, isEditable, }: CustomProviderFormProps) { - const [engine, setEngine] = useState('openai_compatible'); + const [engine, setEngine] = useState('openai'); const [displayName, setDisplayName] = useState(''); const [apiUrl, setApiUrl] = useState(''); const [apiKey, setApiKey] = useState(''); @@ -30,13 +30,7 @@ export default function CustomProviderForm({ useEffect(() => { if (initialData) { - const engineMap: Record = { - openai: 'openai_compatible', - anthropic: 'anthropic_compatible', - ollama: 'ollama_compatible', - }; - - setEngine(engineMap[initialData.engine.toLowerCase()] || 'openai_compatible'); + setEngine(initialData.engine); setDisplayName(initialData.display_name); setApiUrl(initialData.api_url); setModels(initialData.models.join(', ')); @@ -99,16 +93,16 @@ export default function CustomProviderForm({ aria-invalid={!!validationErrors.providerType} aria-describedby={validationErrors.providerType ? 'provider-select-error' : undefined} options={[ - { value: 'openai_compatible', label: 'OpenAI Compatible' }, - { value: 'anthropic_compatible', label: 'Anthropic Compatible' }, - { value: 'ollama_compatible', label: 'Ollama Compatible' }, + { value: 'openai', label: 'OpenAI Compatible' }, + { value: 'anthropic', label: 'Anthropic Compatible' }, + { value: 'ollama', label: 'Ollama Compatible' }, ]} value={{ value: engine, label: - engine === 'openai_compatible' + engine === 'openai' ? 'OpenAI Compatible' - : engine === 'anthropic_compatible' + : engine === 'anthropic' ? 'Anthropic Compatible' : 'Ollama Compatible', }} From ce9b16d0338bffcee6993cc12dc1c3a13366881d Mon Sep 17 00:00:00 2001 From: Abhijay007 Date: Sat, 13 Dec 2025 17:20:21 +0000 Subject: [PATCH 2/2] refactor: addressed requested suggestions Signed-off-by: Abhijay007 --- .../forms/CustomProviderForm.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx b/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx index 710378e06662..28c8b4a13191 100644 --- a/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx +++ b/ui/desktop/src/components/settings/providers/modal/subcomponents/forms/CustomProviderForm.tsx @@ -19,7 +19,7 @@ export default function CustomProviderForm({ initialData, isEditable, }: CustomProviderFormProps) { - const [engine, setEngine] = useState('openai'); + const [engine, setEngine] = useState('openai_compatible'); const [displayName, setDisplayName] = useState(''); const [apiUrl, setApiUrl] = useState(''); const [apiKey, setApiKey] = useState(''); @@ -30,7 +30,12 @@ export default function CustomProviderForm({ useEffect(() => { if (initialData) { - setEngine(initialData.engine); + const engineMap: Record = { + openai: 'openai_compatible', + anthropic: 'anthropic_compatible', + ollama: 'ollama_compatible', + }; + setEngine(engineMap[initialData.engine] || 'openai_compatible'); setDisplayName(initialData.display_name); setApiUrl(initialData.api_url); setModels(initialData.models.join(', ')); @@ -93,16 +98,16 @@ export default function CustomProviderForm({ aria-invalid={!!validationErrors.providerType} aria-describedby={validationErrors.providerType ? 'provider-select-error' : undefined} options={[ - { value: 'openai', label: 'OpenAI Compatible' }, - { value: 'anthropic', label: 'Anthropic Compatible' }, - { value: 'ollama', label: 'Ollama Compatible' }, + { value: 'openai_compatible', label: 'OpenAI Compatible' }, + { value: 'anthropic_compatible', label: 'Anthropic Compatible' }, + { value: 'ollama_compatible', label: 'Ollama Compatible' }, ]} value={{ value: engine, label: - engine === 'openai' + engine === 'openai_compatible' ? 'OpenAI Compatible' - : engine === 'anthropic' + : engine === 'anthropic_compatible' ? 'Anthropic Compatible' : 'Ollama Compatible', }}