Skip to content

fix: select newly added model after saving in settings#594

Closed
tongshu2023 wants to merge 1 commit into
THU-MAIC:mainfrom
tongshu2023:fix/model-selection-on-add-542
Closed

fix: select newly added model after saving in settings#594
tongshu2023 wants to merge 1 commit into
THU-MAIC:mainfrom
tongshu2023:fix/model-selection-on-add-542

Conversation

@tongshu2023
Copy link
Copy Markdown
Contributor

Summary

Fixes #542 — After configuring a new provider (e.g. DeepSeek) and adding a model, the landing page still shows "Set up model" and prevents entering the classroom.

Root Cause

When a user adds a custom model in settings via handleSaveModel, the setProviderConfig action calls resolveLLMSelection. If the provider has models but no API key yet, it's classified as State A (not usable), leaving both providerId and modelId empty. Subsequent API key configuration correctly resolves the provider but selects the first built-in model instead of the user's custom model. This can cause confusion and a perceived broken state.

Changes

1 file: components/settings/index.tsx (+2 lines of logic, +5 lines of comment)

  • Added setModel hook import in SettingsDialog
  • In handleSaveModel, after writing models to the store, explicitly call setModel(providerId, modelId) to select the newly added/edited model
  • This preserves the user's explicit model choice regardless of credential state

Test Plan

  1. Fresh install, open settings, select DeepSeek provider
  2. Add a custom model (e.g. deepseek-chat) WITHOUT entering API key first
  3. Enter API key, close settings
  4. Landing page should show model selector with the custom model selected
  5. Enter a requirement and click Enter Classroom — should navigate to generation preview
  6. Also verify editing an existing model works correctly

When a user adds a custom model (e.g. deepseek-chat) in settings,
the global store's resolveLLMSelection may leave modelId empty if
the provider has no credentials yet. This causes the landing page
to show "Set up model" even after the API key is configured.

Changes:
- Add setModel hook import in SettingsDialog
- After handleSaveModel writes models to the store, explicitly call
  setModel to select the newly added/edited model
- This keeps the intent unambiguous regardless of credential state

Impact: 1 file, components/settings/index.tsx (+2 lines)
@wyuc
Copy link
Copy Markdown
Contributor

wyuc commented May 26, 2026

Thanks @tongshu2023. Closing this.

The reported #542 symptom (the "Please select a model" toast + forced settings reopen) was already fixed by #581 on 2026-05-18. Verified on main: after adding a custom DeepSeek model + API key, Enter Classroom is enabled and navigates to /generation-preview cleanly.

The remaining behavior this PR addresses (picker not auto-switching to the newly-added model) is a deliberate UX choice on our side, not a bug. Adding a model is a configuration action; choosing which model to use is a separate explicit picker action. Auto-switching would also introduce a regression in the common case where another provider is still active and usable, and the user is just adding a model to a side provider for later.

Sorry for the round-trip and thanks for the careful root-cause writeup. #542 is already closed.

@wyuc wyuc closed this May 26, 2026
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.

[Bug]: Cannot enter classroom after configuring DeepSeek API

2 participants