Skip to content

Conversation

@xqliu
Copy link
Contributor

@xqliu xqliu commented Nov 2, 2025

Summary

This PR fixes the "模型不存在" (Model does not exist) error that occurs when users try to save an existing AI model configuration.

Issue

Fixes #245

Root Cause

The handleSaveModelConfig function in AITradersPage.tsx was validating the model ID only against supportedModels, which caused the validation to fail when:

  • Users edit an existing model configuration
  • The model ID format is {user_id}_{provider} (e.g., admin_deepseek)
  • This ID doesn't exist in supportedModels which uses format {provider} (e.g., deepseek)

Changes

Before

const modelToUpdate = supportedModels?.find(m => m.id === modelId);
if (!modelToUpdate) {
  alert(t('modelNotExist', language));
  return;
}

const existingModel = allModels?.find(m => m.id === modelId);

After

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;
}

Testing

Test Results

$ npm test -- AITradersPage.test.tsx
✓ src/components/AITradersPage.test.tsx (8 tests) 233ms
  Test Files  1 passed (1)
       Tests  8 passed (8)

Related


🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

… 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 NoFxAiOS#245

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants