What happened?
When the CLI app is already running and you manually edit settings.json to add new models to the modelProvider configuration, then use the /model slash command inside the CLI to switch models, all the newly added models are silently removed from settings.json without any warning or notice.
Steps to reproduce:
- Launch the CLI app (
qwen)
- While the app is running, manually edit your
settings.json file to add new model entries under the modelProvider config
- Inside the running CLI, use the
/model command to switch to a different model
- Check
settings.json — the manually added models are gone
Why this happens:
The /model command calls setValue() on the in-memory LoadedSettings, which only tracks the specific key being changed (model.name). When it saves back to disk via saveSettings(), it passes the incomplete in-memory originalSettings object to updateSettingsFilePreservingFormat(). The applyUpdates() merge function then overwrites sections of the file with this incomplete data, silently dropping any entries that were added to the file after the app loaded its settings into memory.
What did you expect to happen?
The /model command should only update the model.name key in settings.json and preserve all other settings, including any models manually added to the modelProvider config while the app was running.
Client information
Client Information
To be filled in.
Anything else we need to know?
Relevant code paths:
packages/cli/src/config/settings.ts — setValue() (line ~309) and saveSettings() (line ~710)
packages/cli/src/utils/commentJson.ts — applyUpdates() (line ~43) where data is lost
packages/cli/src/ui/components/ModelDialog.tsx — persistModelSelection() triggers the save
What happened?
When the CLI app is already running and you manually edit
settings.jsonto add new models to themodelProviderconfiguration, then use the/modelslash command inside the CLI to switch models, all the newly added models are silently removed fromsettings.jsonwithout any warning or notice.Steps to reproduce:
qwen)settings.jsonfile to add new model entries under themodelProviderconfig/modelcommand to switch to a different modelsettings.json— the manually added models are goneWhy this happens:
The
/modelcommand callssetValue()on the in-memoryLoadedSettings, which only tracks the specific key being changed (model.name). When it saves back to disk viasaveSettings(), it passes the incomplete in-memoryoriginalSettingsobject toupdateSettingsFilePreservingFormat(). TheapplyUpdates()merge function then overwrites sections of the file with this incomplete data, silently dropping any entries that were added to the file after the app loaded its settings into memory.What did you expect to happen?
The
/modelcommand should only update themodel.namekey insettings.jsonand preserve all other settings, including any models manually added to themodelProviderconfig while the app was running.Client information
Client Information
To be filled in.
Anything else we need to know?
Relevant code paths:
packages/cli/src/config/settings.ts—setValue()(line ~309) andsaveSettings()(line ~710)packages/cli/src/utils/commentJson.ts—applyUpdates()(line ~43) where data is lostpackages/cli/src/ui/components/ModelDialog.tsx—persistModelSelection()triggers the save