From cecd34f38924259e186925292893e4fbc1ae0d8e Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 17 Sep 2026 09:10:53 -0400 Subject: [PATCH] fix(web): legacy plugin-system toggles no longer count as a General save auto_discover, auto_load_enabled and development_mode have left the General form, so a post carrying only one of them is not a general-settings save and must not treat web_display_autostart and auto_update as unchecked. The plugin_system block itself is left as on main for the branch that reworks it. Co-Authored-By: Claude Opus 5 --- test/test_api_v3_partial_main_save.py | 21 ++++++++++++++++----- web_interface/blueprints/api_v3/config.py | 5 ++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/test/test_api_v3_partial_main_save.py b/test/test_api_v3_partial_main_save.py index 3a8315bc..7515acc0 100644 --- a/test/test_api_v3_partial_main_save.py +++ b/test/test_api_v3_partial_main_save.py @@ -92,12 +92,23 @@ class TestJsonPartialSaves: assert config['web_display_autostart'] is True assert config['auto_update'] == {'enabled': True} - def test_location_only_keeps_plugin_system_toggles(self, api_v3_client, saved): - resp = _post_json(api_v3_client, {'city': 'Paris', 'plugins_directory': 'plugin-repos'}) + def test_location_only_keeps_autostart_and_auto_update(self, api_v3_client, saved): + resp = _post_json(api_v3_client, {'city': 'Paris', 'country': 'FR'}) assert resp.status_code == 200, resp.get_json() - assert saved['config']['plugin_system'] == { - 'auto_discover': True, 'auto_load_enabled': True, - 'development_mode': True, 'plugins_directory': 'plugin-repos'} + config = saved['config'] + assert config['location'] == {'city': 'Paris', 'country': 'FR'} + assert config['web_display_autostart'] is True + assert config['auto_update'] == {'enabled': True} + + @pytest.mark.parametrize('key', ['auto_discover', 'auto_load_enabled', 'development_mode']) + def test_a_legacy_plugin_system_toggle_is_not_a_general_save(self, api_v3_client, saved, key): + # These left the General form; a client still sending one must not + # have the general-settings checkboxes treated as unchecked. + resp = api_v3_client.post('/api/v3/config/main', data={key: 'on'}, + content_type='application/x-www-form-urlencoded') + assert resp.status_code == 200, resp.get_json() + assert saved['config']['web_display_autostart'] is True + assert saved['config']['auto_update'] == {'enabled': True} def test_vegas_speed_only_keeps_vegas_toggles(self, api_v3_client, saved): resp = _post_json(api_v3_client, {'vegas_scroll_speed': 80}) diff --git a/web_interface/blueprints/api_v3/config.py b/web_interface/blueprints/api_v3/config.py index 896c6bd9..ad65ed12 100644 --- a/web_interface/blueprints/api_v3/config.py +++ b/web_interface/blueprints/api_v3/config.py @@ -496,8 +496,7 @@ def save_main_config(): # Note: Checkboxes don't send data when unchecked, so we need to check if we're updating general settings # If any general setting is present, we're updating the general tab is_general_update = any(k in data for k in ['timezone', 'city', 'state', 'country', 'web_display_autostart', - 'auto_discover', 'auto_load_enabled', 'development_mode', 'plugins_directory', - 'auto_update_enabled']) + 'plugins_directory', 'auto_update_enabled']) if is_general_update: # For checkbox: if not present in data during a general *form* @@ -560,7 +559,7 @@ def save_main_config(): # Handle plugin system checkboxes - always set to handle unchecked state # HTML checkboxes omit the key when unchecked, so missing key = unchecked = False for checkbox in ['auto_discover', 'auto_load_enabled', 'development_mode']: - _set_checkbox(current_config['plugin_system'], checkbox, checkbox) + current_config['plugin_system'][checkbox] = _coerce_to_bool(data.get(checkbox)) # Handle plugins_directory if 'plugins_directory' in data: