Skip to content

Agent Zero AI framework

Fix model config snapshot sync

Alessandroff601d08d044
diff --git a/plugins/_model_config/webui/config.html b/plugins/_model_config/webui/config.html
index 31e477ade..45def5ec5 100644
--- a/plugins/_model_config/webui/config.html
+++ b/plugins/_model_config/webui/config.html
@@ -11,8 +11,11 @@
x-effect="
if (config && config !== lastConfig) {
lastConfig = config;
+ const snapshotBeforeInit = typeof context !== 'undefined'
+ ? context._toComparableJson(config)
+ : null;
$store.modelConfig.initConfigFields(config);
- if (typeof context !== 'undefined') {
+ if (typeof context !== 'undefined' && context.settingsSnapshotJson === snapshotBeforeInit) {
context.settingsSnapshotJson = context._toComparableJson(config);
}
}
diff --git a/tests/test_model_config_api_keys.py b/tests/test_model_config_api_keys.py
index c5717dc11..d9fe9ec4c 100644
--- a/tests/test_model_config_api_keys.py
+++ b/tests/test_model_config_api_keys.py
@@ -118,6 +118,14 @@ def test_model_config_frontend_tracks_inline_api_key_edits():
assert "$store.modelConfig.resetApiKeyDrafts();" in modal_content
+def test_model_config_snapshot_sync_only_adjusts_clean_loaded_configs():
+ config_path = PROJECT_ROOT / "plugins" / "_model_config" / "webui" / "config.html"
+ config_content = config_path.read_text(encoding="utf-8")
+
+ assert "const snapshotBeforeInit" in config_content
+ assert "context.settingsSnapshotJson === snapshotBeforeInit" in config_content
+
+
def test_model_switcher_frontend_renders_custom_overrides():
switcher_path = PROJECT_ROOT / "plugins" / "_model_config" / "webui" / "switcher-mixin.js"
refresh_extension_path = (