From 6078de78f2a7e31ec141a49c057a8b4cb1a6d601 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Thu, 5 Mar 2026 12:36:39 +0800 Subject: [PATCH] fix(ui): use preset apiKeyPlaceholder when creating profiles Fixes profile creation for local providers (llamacpp, ollama) where apiKey is not required but server validation requires a truthy value. Changes: - Set apiKey to preset.apiKeyPlaceholder when selecting a preset - Use preset.apiKeyPlaceholder as fallback in onSubmit - Ensures sentinel values (e.g., "llamacpp", "ollama") are sent Fixes user-reported error when creating llamacpp profile via dashboard. --- ui/src/components/profiles/profile-create-dialog.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/src/components/profiles/profile-create-dialog.tsx b/ui/src/components/profiles/profile-create-dialog.tsx index 2c3d283a..10258033 100644 --- a/ui/src/components/profiles/profile-create-dialog.tsx +++ b/ui/src/components/profiles/profile-create-dialog.tsx @@ -146,6 +146,7 @@ export function ProfileCreateDialog({ setTimeout(() => { setValue('name', openrouterPreset.defaultProfileName); setValue('baseUrl', openrouterPreset.baseUrl); + setValue('apiKey', openrouterPreset.apiKeyPlaceholder || ''); }, 0); } } @@ -159,6 +160,7 @@ export function ProfileCreateDialog({ if (preset) { setValue('name', preset.defaultProfileName); setValue('baseUrl', preset.baseUrl); + setValue('apiKey', preset.apiKeyPlaceholder || ''); if (preset.defaultModel) { setValue('model', preset.defaultModel); setValue('opusModel', preset.defaultModel); @@ -169,6 +171,7 @@ export function ProfileCreateDialog({ // Custom setValue('name', ''); setValue('baseUrl', ''); + setValue('apiKey', ''); setValue('model', ''); } }; @@ -215,8 +218,8 @@ export function ProfileCreateDialog({ // Use user-provided baseUrl (allows customization of preset URLs) const finalData = { ...data, - // Use provided API key, or empty string if not provided (for optional auth providers) - apiKey: data.apiKey || '', + // Use provided API key, or preset placeholder, or empty string + apiKey: data.apiKey || currentPreset?.apiKeyPlaceholder || '', }; try { await createMutation.mutateAsync(finalData);