-
Notifications
You must be signed in to change notification settings - Fork 2k
bug: Selected model from /model command not persisted to settings.json #1222
Copy link
Copy link
Closed
Description
What happened?
When users select a model via the /model command in the multi-model support feature, the selection is only stored in-memory for the current session. When the CLI is restarted, the selected model is lost and defaults back to the hardcoded settings.model?.name from settings.json.
Current Behavior
Flow:
- User runs
/modelcommand - ModelDialog displays available models
- User selects a model →
config.setModel(model)is called (in-memory only) - Model is used for current session ✓
- CLI is closed/restarted
- Selected model is lost ✗ - defaults back to old hardcoded model or environment variables
Code Location: packages/cli/src/ui/components/ModelDialog.tsx (lines 119-129)
const handleSelect = useCallback(
(model: string) => {
if (config) {
config.setModel(model); // ✓ Updates in-memory config only
const event = new ModelSlashCommandEvent(model);
logModelSlashCommand(config, event); // ✓ Logs telemetry
// ✗ MISSING: settings.setValue() to persist to settings.json
}
onClose();
},
[config, onClose],
);Expected Behavior
The selected model should be persisted to ~/.qwen/settings.json so that:
- User's latest model selection is remembered across sessions
- Next time CLI starts, it uses the last selected model
- Consistent with how other settings (theme, approval mode, editor) work
Solution
Update ModelDialog.tsx handleSelect function to persist the selected model to settings:
const handleSelect = useCallback(
(model: string) => {
if (config) {
config.setModel(model);
const event = new ModelSlashCommandEvent(model);
logModelSlashCommand(config, event);
// Add this: Persist the selected model to settings.json
if (loadedSettings) {
const scope = isWorkspaceSettings ? SettingScope.Workspace : SettingScope.User;
await loadedSettings.setValue(scope, 'model.name', model);
}
}
onClose();
},
[config, loadedSettings, isWorkspaceSettings, onClose],
);Files to Update
-
packages/cli/src/ui/components/ModelDialog.tsx- Update
handleSelectcallback to callsettings.setValue() - Add LoadedSettings to component props/context if needed
- Handle async save operation
- Update
-
Settings Schema (if needed)
- Verify
model.nameis properly defined in settings schema - Ensure migration path for existing settings
- Verify
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels