fix: model config settings lost after scope change (fixes #1518)#1603
fix: model config settings lost after scope change (fixes #1518)#1603revworxai wants to merge 1 commit into
Conversation
v2: watch scope identifiers (projectName, agentProfileKey) instead of
the deep config object. v1 used $watch('config', ...) which fired on
every keystroke in the kwargs textarea (because _kwargs_text lives on
config.chat_model), causing initConfigFields to revert user edits.
b1356fb to
2e3e345
Compare
Update — v2 of the fixForce-pushed a corrected version. The original commit had a regression that I caught during further testing on a real instance. What changed: The first version added Fix: Watch the scope identifiers (primitives) instead of the deep config object. $watch('context.projectName', () => $store.modelConfig.initConfigFields(config));
$watch('context.agentProfileKey', () => $store.modelConfig.initConfigFields(config)); |
Problem
When changing the Project/Agent Profile scope in Settings → Model Configuration, user edits are silently discarded. The scoped
config.jsonfile is created at the correct path, but it contains the unchanged fallback/global config instead of the user's modifications.For example: selecting Project + Agent Profile, changing Main Model from Opus → Sonnet, and clicking Save results in a config file that still shows Opus.
Fixes #1518
Root Cause
In
plugins/_model_config/webui/config.html, each model section captures a static reference at render time:x-data="{ model: config[section.key], ... }"When the user changes scope (Project/Agent Profile),
plugin-settings-store.jscallsloadSettings()which replacescontext.settingswith a new object:The
modelvariable in the childx-datascope still references the old object. User edits viax-model="model.name"modify the stale object, whilesave()serializes the new (unmodified) object.A secondary issue:
initConfigFields(config)only runs once inx-init, so_kwargs_textfields are never re-initialized after a scope change.Fix
Two changes to
plugins/_model_config/webui/config.html:modelalways resolves from the currentconfigobject:$watchto re-initialize kwargs text fields when config changes after scope switch:$store.modelConfig.installSettingsHooks(context, config); + $watch('config', (val) => $store.modelConfig.initConfigFields(val));Testing
Also verified: