fix(settings): restore the Other Models master toggle state on load

updateOtherModelsControls() synced the sub-type checkboxes and default-root
selects but never set the master toggle's checked state, and the
setting_toggle macro renders no checked attribute, so after a page refresh
the toggle always appeared off regardless of the saved setting.
This commit is contained in:
Will Miao
2026-09-17 10:08:58 +08:00
parent ef7fa7d3dd
commit b9a516c9f8
2 changed files with 21 additions and 0 deletions
+5
View File
@@ -2432,6 +2432,11 @@ export class SettingsManager {
|| ['vae', 'upscaler', 'text_encoder']
);
const masterToggle = document.getElementById('enableOtherModels');
if (masterToggle) {
masterToggle.checked = enableOtherModels;
}
document.querySelectorAll('[data-other-subtype-toggle]').forEach((input) => {
input.checked = enabledSubTypes.has(input.value);
input.disabled = !enableOtherModels;
@@ -665,6 +665,22 @@ describe('SettingsManager other-model root selects', () => {
expect(container.classList.contains('is-disabled')).toBe(false);
});
it('restores the master toggle checked state from settings', () => {
const manager = createManager();
const masterToggle = document.createElement('input');
masterToggle.type = 'checkbox';
masterToggle.id = 'enableOtherModels';
document.body.appendChild(masterToggle);
state.global.settings = { enable_other_models: true };
manager.updateOtherModelsControls();
expect(masterToggle.checked).toBe(true);
state.global.settings = { enable_other_models: false };
manager.updateOtherModelsControls();
expect(masterToggle.checked).toBe(false);
});
it('persists the checked sub_types as the whole allow-list', async () => {
const manager = createManager();
appendToggles('vae', 'upscaler', 'controlnet');