mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
fix(ui): remove per-node active-filters chip from loras widgets
The indicator chip added for /activefilters discoverability was broken by design of its import path: AutocompleteTextWidget.vue imported web/comfyui/settings.js into the vue-widgets bundle, and settings.js's "../../scripts/app.js" import resolved at build time to the repo-root test shim (scripts/app.js, an in-memory settings store). The chip therefore read and wrote an orphaned in-memory Map: clicking it flipped only its own visual state and never touched the real ComfyUI setting that autocomplete.js consults (use_active_filters query param). Beyond the defect, a persistent per-node control for a global persisted setting misleads users and needs cross-instance sync machinery, which the footer hint, slash commands, right-click menu entry and settings dialog already cover. - AutocompleteTextWidget.vue: remove the chip button, its state/handlers, the settings.js import (the shim-inlining pathway) and all chip styles - AutocompleteTextWidget.test.ts: drop the chip indicator describe block and the settings.js module mock; beforeEach import no longer needed - settings.js: drop the lora-manager:setting-toggled window broadcast and its export — the chip was its only consumer, so every setLoraManagerSettingValue write no longer dispatches a dead event - autocomplete.activeFilters.test.js: drop the broadcast assertion test - loraLoader.activeFiltersMenu.test.js: drop SETTING_TOGGLED_EVENT_NAME from the settings.js mock Discoverability of /activefilters // /noactivefilters is unchanged: command-list footer, first-run hint, node context menu, settings dialog.
This commit is contained in:
@@ -253,37 +253,4 @@ describe('AutoComplete active-filters flag', () => {
|
||||
|
||||
expect(autoComplete.dropdown.querySelector('.lm-autocomplete-first-run-hint')).toBeNull();
|
||||
});
|
||||
|
||||
it('broadcasts a setting-toggled window event when /activefilters is accepted', async () => {
|
||||
const events = [];
|
||||
const listener = (event) => events.push(event.detail);
|
||||
window.addEventListener('lora-manager:setting-toggled', listener);
|
||||
try {
|
||||
const input = document.createElement('textarea');
|
||||
input.value = '/activefilters';
|
||||
input.selectionStart = input.value.length;
|
||||
input.focus = vi.fn();
|
||||
input.setSelectionRange = vi.fn();
|
||||
document.body.append(input);
|
||||
|
||||
caretHelperInstance.getBeforeCursor.mockReturnValue('/activefilters');
|
||||
|
||||
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||
const autoComplete = new AutoComplete(input, 'loras', { showPreview: false, minChars: 1 });
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
|
||||
// The command token is cleared after acceptance; simulate the caret
|
||||
// helper seeing the cleared input so the synthetic input event does
|
||||
// not re-trigger command parsing (same pattern as behavior tests).
|
||||
caretHelperInstance.getBeforeCursor.mockReturnValue('');
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
expect(events).toContainEqual({
|
||||
settingId: 'loramanager.lora_active_filters_autocomplete',
|
||||
value: true,
|
||||
});
|
||||
} finally {
|
||||
window.removeEventListener('lora-manager:setting-toggled', listener);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +54,6 @@ const setSettingValueMock = vi.fn();
|
||||
vi.mock(SETTINGS_MODULE, () => ({
|
||||
LORA_ACTIVE_FILTERS_AUTOCOMPLETE_SETTING_ID:
|
||||
"loramanager.lora_active_filters_autocomplete",
|
||||
SETTING_TOGGLED_EVENT_NAME: "lora-manager:setting-toggled",
|
||||
getLoraActiveFiltersAutocompletePreference: getActiveFiltersPreferenceMock,
|
||||
setLoraManagerSettingValue: setSettingValueMock,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user