From 92c4d1981376fd6e459e96159f6a5d3c2b95d69f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 24 Mar 2026 13:05:10 -0700 Subject: [PATCH] fix: "No chat model selected" error on startup (#11672) * fix: resolve "No chat model selected" error and GUI/core model mismatch Three fixes for the model selection bugs reported in #11656 and 12+ related issues: 1. Fix loadConfig() init ordering: await isInitialized before checking currentProfile, consistent with getSerializedConfig(). Prevents returning config: undefined during initialization race. 2. Avoid full config reload on model selection: The config/updateSelectedModel handler now updates the model in the cached config in-place instead of doing a full reloadConfig(). This eliminates the window where selectedModelByRole.chat is null during reload, and prevents the configUpdate from core overwriting the GUI's optimistic selection. 3. Guard against undefined config in GUI: handleConfigUpdate now also checks !configResult.config alongside configLoadInterrupted, preventing EMPTY_CONFIG (with chat: null) from being applied. * fix: resolve "No chat model selected" error on startup Two fixes for the "No chat model selected" error reported in #11656 and 12+ related issues across all providers: 1. Fix loadConfig() init ordering (ConfigHandler.ts): Move `await this.isInitialized` before the `!this.currentProfile` check, matching the pattern already used in getSerializedConfig(). Without this, loadConfig() called during initialization returns config: undefined because currentProfile hasn't been set yet. 2. Guard against undefined config in GUI (ParallelListeners.tsx): handleConfigUpdate now also checks `!configResult.config` alongside configLoadInterrupted, preventing EMPTY_CONFIG (with selectedModelByRole.chat: null) from being applied. * fix: provide valid mock config to fix GUI test failures The added `!configResult.config` guard in ParallelListeners caused tests to bail early since MockIdeMessenger returned `config: undefined`. --- core/config/ConfigHandler.ts | 2 +- gui/src/context/MockIdeMessenger.ts | 29 ++++++++++++++++++++++++++++- gui/src/hooks/ParallelListeners.tsx | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index bd934777b..336c4b40b 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -606,6 +606,7 @@ export class ConfigHandler { } async loadConfig(): Promise> { + await this.isInitialized; if (!this.currentProfile) { return { config: undefined, @@ -613,7 +614,6 @@ export class ConfigHandler { configLoadInterrupted: true, }; } - await this.isInitialized; const config = await this.currentProfile.loadConfig( this.additionalContextProviders, ); diff --git a/gui/src/context/MockIdeMessenger.ts b/gui/src/context/MockIdeMessenger.ts index e7f78252d..58f6cc905 100644 --- a/gui/src/context/MockIdeMessenger.ts +++ b/gui/src/context/MockIdeMessenger.ts @@ -81,7 +81,34 @@ const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = { ], profileId: "local", result: { - config: undefined, + config: { + tools: [], + slashCommands: [], + contextProviders: [], + mcpServerStatuses: [], + usePlatform: true, + modelsByRole: { + chat: [], + apply: [], + edit: [], + summarize: [], + autocomplete: [], + rerank: [], + embed: [], + subagent: [], + }, + selectedModelByRole: { + chat: null, + apply: null, + edit: null, + summarize: null, + autocomplete: null, + rerank: null, + embed: null, + subagent: null, + }, + rules: [], + }, errors: [], configLoadInterrupted: false, }, diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index e8cb96a95..2d50c702e 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -64,7 +64,7 @@ function ParallelListeners() { if (isInitial && hasDoneInitialConfigLoad.current) { return; } - if (configResult.configLoadInterrupted) { + if (configResult.configLoadInterrupted || !configResult.config) { return; } hasDoneInitialConfigLoad.current = true;