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`.
This commit is contained in:
Dallin Romney 2026-03-24 13:05:10 -07:00 • committed by GitHub
parent ced1e3c86b
commit 92c4d19813
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 3 deletions

View file

@ -606,6 +606,7 @@ export class ConfigHandler {
}
async loadConfig(): Promise<ConfigResult<ContinueConfig>> {
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,
);

View file

@ -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,
},

View file

@ -64,7 +64,7 @@ function ParallelListeners() {
if (isInitial && hasDoneInitialConfigLoad.current) {
return;
}
if (configResult.configLoadInterrupted) {
if (configResult.configLoadInterrupted || !configResult.config) {
return;
}
hasDoneInitialConfigLoad.current = true;