From a8d517108780c569e340275df64b274d264138ca Mon Sep 17 00:00:00 2001 From: Liu Xiang Qian Date: Sun, 2 Nov 2025 18:08:25 +0800 Subject: [PATCH] fix: Update model validation in handleSaveModelConfig to support both configured and supported models - Change validation to check allModels first, then supportedModels - This allows saving new model configurations without "model does not exist" error - Fixes issue where users couldn't save AI model config after selecting from dropdown Fixes #245 Co-Authored-By: tinkle-community --- web/src/components/AITradersPage.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/src/components/AITradersPage.tsx b/web/src/components/AITradersPage.tsx index 3a947df3..9361fc80 100644 --- a/web/src/components/AITradersPage.tsx +++ b/web/src/components/AITradersPage.tsx @@ -277,17 +277,17 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) { const handleSaveModelConfig = async (modelId: string, apiKey: string, customApiUrl?: string, customModelName?: string) => { try { - // 找到要配置的模型(从supportedModels中) - const modelToUpdate = supportedModels?.find(m => m.id === modelId); + // 创建或更新用户的模型配置 + const existingModel = allModels?.find(m => m.id === modelId); + let updatedModels; + + // 找到要配置的模型(优先从已配置列表,其次从支持列表) + const modelToUpdate = existingModel || supportedModels?.find(m => m.id === modelId); if (!modelToUpdate) { alert(t('modelNotExist', language)); return; } - // 创建或更新用户的模型配置 - const existingModel = allModels?.find(m => m.id === modelId); - let updatedModels; - if (existingModel) { // 更新现有配置 updatedModels = allModels?.map(m =>