mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 11:11:26 -03:00
feat(ui): improve /activefilters discoverability on loras nodes
Mirror the /noautocomplete discoverability pattern for the loras\nactive-filters search toggle:\n\n- autocomplete.js: extend the slash-command-list footer and the\n one-time first-run hint to loras nodes, advertising\n /activefilters and /noactivefilters\n- lora_loader.js: add an 'Active Filters Search: ON/OFF' entry to the\n right-click menu of all loras-autocomplete node classes\n- settings.js: broadcast a 'lora-manager:setting-toggled' window event\n on every setLoraManagerSettingValue write\n- AutocompleteTextWidget.vue: add a persistent filter indicator chip\n (loras mode only) that reflects and toggles the setting and stays in\n sync via the setting-toggled event\n- tests: footer/hint/event coverage, context-menu tests for all four\n node classes, widget indicator tests; rebuild vue-widgets bundle
This commit is contained in:
@@ -175,23 +175,42 @@ const getPromptTagAutocompletePreference = (() => {
|
||||
/**
|
||||
* Persist a LoRA Manager setting through ComfyUI's setting API.
|
||||
* Returns true when the setting was written successfully.
|
||||
*
|
||||
* Every successful write broadcasts a "lora-manager:setting-toggled" window
|
||||
* event (see SETTING_TOGGLED_EVENT_NAME) so widgets mirroring the setting
|
||||
* (e.g. the active-filters indicator in the autocomplete text widget) stay in
|
||||
* sync with slash-command / context-menu toggles.
|
||||
*/
|
||||
const SETTING_TOGGLED_EVENT_NAME = "lora-manager:setting-toggled";
|
||||
|
||||
const setLoraManagerSettingValue = async (settingId, value) => {
|
||||
const settingManager = app?.extensionManager?.setting;
|
||||
if (settingManager && typeof settingManager.set === "function") {
|
||||
await settingManager.set(settingId, value);
|
||||
_notifySettingToggled(settingId, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
const setting = app?.ui?.settings?.settingsById?.[settingId];
|
||||
if (setting) {
|
||||
app.ui.settings.setSettingValue(settingId, value);
|
||||
_notifySettingToggled(settingId, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const _notifySettingToggled = (settingId, value) => {
|
||||
try {
|
||||
window.dispatchEvent(new CustomEvent(SETTING_TOGGLED_EVENT_NAME, {
|
||||
detail: { settingId, value },
|
||||
}));
|
||||
} catch (error) {
|
||||
// Best-effort notification; ignore non-browser environments
|
||||
}
|
||||
};
|
||||
|
||||
const getAutocompleteAppendCommaPreference = (() => {
|
||||
let settingsUnavailableLogged = false;
|
||||
|
||||
@@ -597,6 +616,8 @@ app.registerExtension({
|
||||
|
||||
export {
|
||||
PROMPT_TAG_AUTOCOMPLETE_SETTING_ID,
|
||||
LORA_ACTIVE_FILTERS_AUTOCOMPLETE_SETTING_ID,
|
||||
SETTING_TOGGLED_EVENT_NAME,
|
||||
getWheelSensitivity,
|
||||
getAutoPathCorrectionPreference,
|
||||
getAutocompleteAppendCommaPreference,
|
||||
|
||||
Reference in New Issue
Block a user