fix(web): remove the General-tab plugin system toggles that did nothing

plugin_system.auto_discover, auto_load_enabled and development_mode had
General-tab toggles whose help tips promised dormant plugins and verbose
logging, but nothing reads them: every enabled plugin is discovered and
loaded regardless. Remove the three toggles.

The keys stay tolerated in stored configs. The save handler now stores
a flag only when a client sends it; treating a missing key as an
unchecked box would otherwise rewrite all three to false on every
General-tab save, which still posts plugins_directory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-09-17 08:52:40 -04:00
co-authored by Claude Opus 5
parent 9096d1dfd3
commit 9e1ebd9c17
3 changed files with 82 additions and 42 deletions
+70
View File
@@ -0,0 +1,70 @@
"""plugin_system.auto_discover / auto_load_enabled / development_mode.
The General tab offered three toggles for these, with help tips promising
"plugins installed but dormant" and "verbose logging". Nothing in src/,
web_interface/ or scripts/ reads them: every enabled plugin is discovered and
loaded regardless. The toggles are gone; the keys stay tolerated in stored
configs, and saving the General tab must not rewrite them.
"""
import copy
import json
import sys
from pathlib import Path
import pytest
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT))
from test._api_v3_test_helpers import api_v3_client, api_v3_module # noqa: F401,E402
from test.test_web_settings_ui import REALISTIC_CONFIG, client # noqa: F401,E402
LEGACY_FLAGS = ('auto_discover', 'auto_load_enabled', 'development_mode')
def test_the_general_tab_no_longer_offers_the_toggles(client):
body = client.get('/v3/partials/general').get_data(as_text=True)
for flag in LEGACY_FLAGS:
assert f'name="{flag}"' not in body, flag
assert f'setting-general-{flag}' not in body, flag
# The setting that does work stays.
assert 'name="plugins_directory"' in body
@pytest.fixture
def saved(api_v3_module, monkeypatch):
captured = {}
stored = copy.deepcopy(REALISTIC_CONFIG)
stored['plugin_system'].update(
auto_discover=True, auto_load_enabled=True, development_mode=True)
api_v3_module.api_v3.config_manager.load_config.return_value = stored
def fake_save(_manager, config, **_kwargs):
captured['config'] = config
return True, ''
monkeypatch.setattr(api_v3_module, '_save_config_atomic', fake_save)
return captured
def test_saving_the_general_form_leaves_stored_flags_alone(api_v3_client, saved):
# What the General form posts now: no checkbox fields for the flags.
resp = api_v3_client.post('/api/v3/config/main', data={
'timezone': 'America/Chicago', 'city': 'Dallas', 'state': 'Texas',
'country': 'US', 'plugins_directory': 'plugin-repos',
})
assert resp.status_code == 200, resp.get_json()
plugin_system = saved['config']['plugin_system']
# Missing used to mean "unchecked" and saved all three as false.
assert all(plugin_system[flag] is True for flag in LEGACY_FLAGS), plugin_system
assert plugin_system['plugins_directory'] == 'plugin-repos'
def test_an_api_client_can_still_store_a_flag(api_v3_client, saved):
resp = api_v3_client.post('/api/v3/config/main', data=json.dumps({
'timezone': 'America/Chicago', 'development_mode': False,
}), content_type='application/json')
assert resp.status_code == 200, resp.get_json()
plugin_system = saved['config']['plugin_system']
assert plugin_system['development_mode'] is False
assert plugin_system['auto_discover'] is True
+8 -4
View File
@@ -520,10 +520,14 @@ def save_main_config():
if 'plugin_system' not in current_config: if 'plugin_system' not in current_config:
current_config['plugin_system'] = {} current_config['plugin_system'] = {}
# Handle plugin system checkboxes - always set to handle unchecked state # auto_discover / auto_load_enabled / development_mode are read by
# HTML checkboxes omit the key when unchecked, so missing key = unchecked = False # nothing and no longer have General-tab toggles. The form still
for checkbox in ['auto_discover', 'auto_load_enabled', 'development_mode']: # posts plugins_directory, so treating a missing key as an
current_config['plugin_system'][checkbox] = _coerce_to_bool(data.get(checkbox)) # unchecked box would rewrite stored values to false on every
# save; only store what a client actually sends.
for legacy_flag in ['auto_discover', 'auto_load_enabled', 'development_mode']:
if legacy_flag in data:
current_config['plugin_system'][legacy_flag] = _coerce_to_bool(data.get(legacy_flag))
# Handle plugins_directory # Handle plugins_directory
if 'plugins_directory' in data: if 'plugins_directory' in data:
@@ -166,44 +166,10 @@
<p class="text-sm text-gray-600 mb-4">Configure the core plugin system behavior.</p> <p class="text-sm text-gray-600 mb-4">Configure the core plugin system behavior.</p>
<div class="space-y-4"> <div class="space-y-4">
<!-- Auto Discover --> <!-- plugin_system.auto_discover, auto_load_enabled and
<div class="form-group" id="setting-general-auto_discover" data-setting-key="plugin_system.auto_discover"> development_mode used to be toggles here. Nothing reads
<label class="flex items-center"> them: plugins are always discovered and every enabled
<input type="checkbox" plugin is loaded. Stored values are left alone. -->
name="auto_discover"
value="true"
{% if main_config.get('plugin_system', {}).get('auto_discover', True) %}checked{% endif %}
class="form-control h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<span class="ml-2 text-sm font-medium text-gray-900">Auto Discover Plugins</span>
{{ ui.help_tip('Scan the plugins directory for installed plugins each time the service starts.\nDefault: on. Leave on unless you manage plugins manually.', 'Auto Discover Plugins') }}
</label>
</div>
<!-- Auto Load Enabled -->
<div class="form-group" id="setting-general-auto_load_enabled" data-setting-key="plugin_system.auto_load_enabled">
<label class="flex items-center">
<input type="checkbox"
name="auto_load_enabled"
value="true"
{% if main_config.get('plugin_system', {}).get('auto_load_enabled', True) %}checked{% endif %}
class="form-control h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<span class="ml-2 text-sm font-medium text-gray-900">Auto Load Enabled Plugins</span>
{{ ui.help_tip('Load every plugin marked enabled in the configuration at startup.\nDefault: on. Turn off to keep plugins installed but dormant.', 'Auto Load Enabled Plugins') }}
</label>
</div>
<!-- Development Mode -->
<div class="form-group" id="setting-general-development_mode" data-setting-key="plugin_system.development_mode">
<label class="flex items-center">
<input type="checkbox"
name="development_mode"
value="true"
{% if main_config.get('plugin_system', {}).get('development_mode', False) %}checked{% endif %}
class="form-control h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<span class="ml-2 text-sm font-medium text-gray-900">Development Mode</span>
{{ ui.help_tip('Enable verbose logging and developer features for plugin debugging.\nDefault: off. Keep off for normal use — it increases log volume.', 'Development Mode') }}
</label>
</div>
<!-- Plugins Directory --> <!-- Plugins Directory -->
<div class="form-group" id="setting-general-plugins_directory" data-setting-key="plugin_system.plugins_directory"> <div class="form-group" id="setting-general-plugins_directory" data-setting-key="plugin_system.plugins_directory">