fix(provider): ollama provider fix (#246)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
Haze
2026-03-01 17:40:07 +08:00
committed by GitHub
Unverified
parent a8f61d5a61
commit 7d0621dcc2
4 changed files with 48 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ import {
PROVIDER_TYPE_INFO,
type ProviderType,
getProviderIconUrl,
resolveProviderApiKeyForSave,
shouldInvertInDark,
} from '@/lib/providers';
import { cn } from '@/lib/utils';
@@ -66,6 +67,7 @@ export function ProvidersSettings() {
// Only custom supports multiple instances.
// Built-in providers remain singleton by type.
const id = type === 'custom' ? `custom-${crypto.randomUUID()}` : type;
const effectiveApiKey = resolveProviderApiKeyForSave(type, apiKey);
try {
await addProvider(
{
@@ -76,7 +78,7 @@ export function ProvidersSettings() {
model: options?.model,
enabled: true,
},
apiKey.trim() || undefined
effectiveApiKey
);
// Auto-set as default if no default is currently configured
@@ -261,6 +263,12 @@ function ProviderCard({
}
}
// Keep Ollama key optional in UI, but persist a placeholder when
// editing legacy configs that have no stored key.
if (provider.type === 'ollama' && !provider.hasKey && !payload.newApiKey) {
payload.newApiKey = resolveProviderApiKeyForSave(provider.type, '') as string;
}
if (!payload.newApiKey && !payload.updates) {
onCancelEdit();
setSaving(false);