mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(autocomplete): make /commands work even when tag autocomplete is disabled
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { api } from "../../scripts/api.js";
|
import { api } from "../../scripts/api.js";
|
||||||
import { app } from "../../scripts/app.js";
|
import { app } from "../../scripts/app.js";
|
||||||
import { TextAreaCaretHelper } from "./textarea_caret_helper.js";
|
import { TextAreaCaretHelper } from "./textarea_caret_helper.js";
|
||||||
import { getPromptCustomWordsAutocompletePreference } from "./settings.js";
|
import { getPromptTagAutocompletePreference } from "./settings.js";
|
||||||
|
|
||||||
// Command definitions for category filtering
|
// Command definitions for category filtering
|
||||||
const TAG_COMMANDS = {
|
const TAG_COMMANDS = {
|
||||||
@@ -461,7 +461,7 @@ class AutoComplete {
|
|||||||
searchTerm = (match[1] || '').trim();
|
searchTerm = (match[1] || '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For prompt model type, check if we're searching embeddings or custom words
|
// For prompt model type, check if we're searching embeddings, commands, or tags
|
||||||
if (this.modelType === 'prompt') {
|
if (this.modelType === 'prompt') {
|
||||||
const match = rawSearchTerm.match(/^emb:(.*)$/i);
|
const match = rawSearchTerm.match(/^emb:(.*)$/i);
|
||||||
if (match) {
|
if (match) {
|
||||||
@@ -471,8 +471,8 @@ class AutoComplete {
|
|||||||
this.searchType = 'embeddings';
|
this.searchType = 'embeddings';
|
||||||
this.activeCommand = null;
|
this.activeCommand = null;
|
||||||
this.showingCommands = false;
|
this.showingCommands = false;
|
||||||
} else if (getPromptCustomWordsAutocompletePreference()) {
|
} else {
|
||||||
// Setting enabled - check for command mode
|
// Check for command mode FIRST (always runs, regardless of setting)
|
||||||
const commandResult = this._parseCommandInput(rawSearchTerm);
|
const commandResult = this._parseCommandInput(rawSearchTerm);
|
||||||
|
|
||||||
if (commandResult.showCommands) {
|
if (commandResult.showCommands) {
|
||||||
@@ -498,18 +498,18 @@ class AutoComplete {
|
|||||||
endpoint = `/lm/custom-words/search?category=${categories}`;
|
endpoint = `/lm/custom-words/search?category=${categories}`;
|
||||||
this.searchType = 'custom_words';
|
this.searchType = 'custom_words';
|
||||||
}
|
}
|
||||||
} else {
|
} else if (getPromptTagAutocompletePreference()) {
|
||||||
// No command - regular custom words search with enriched results
|
// No command and setting enabled - regular tag search with enriched results
|
||||||
this.showingCommands = false;
|
this.showingCommands = false;
|
||||||
this.activeCommand = null;
|
this.activeCommand = null;
|
||||||
endpoint = '/lm/custom-words/search?enriched=true';
|
endpoint = '/lm/custom-words/search?enriched=true';
|
||||||
searchTerm = rawSearchTerm;
|
searchTerm = rawSearchTerm;
|
||||||
this.searchType = 'custom_words';
|
this.searchType = 'custom_words';
|
||||||
|
} else {
|
||||||
|
// No command and setting disabled - no autocomplete for direct typing
|
||||||
|
this.hide();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Setting disabled - no autocomplete for non-emb: terms
|
|
||||||
this.hide();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ const TRIGGER_WORD_WHEEL_SENSITIVITY_DEFAULT = 0.02;
|
|||||||
const AUTO_PATH_CORRECTION_SETTING_ID = "loramanager.auto_path_correction";
|
const AUTO_PATH_CORRECTION_SETTING_ID = "loramanager.auto_path_correction";
|
||||||
const AUTO_PATH_CORRECTION_DEFAULT = true;
|
const AUTO_PATH_CORRECTION_DEFAULT = true;
|
||||||
|
|
||||||
const PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_SETTING_ID = "loramanager.prompt_custom_words_autocomplete";
|
const PROMPT_TAG_AUTOCOMPLETE_SETTING_ID = "loramanager.prompt_tag_autocomplete";
|
||||||
const PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_DEFAULT = true;
|
const PROMPT_TAG_AUTOCOMPLETE_DEFAULT = true;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
@@ -69,28 +69,28 @@ const getAutoPathCorrectionPreference = (() => {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const getPromptCustomWordsAutocompletePreference = (() => {
|
const getPromptTagAutocompletePreference = (() => {
|
||||||
let settingsUnavailableLogged = false;
|
let settingsUnavailableLogged = false;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const settingManager = app?.extensionManager?.setting;
|
const settingManager = app?.extensionManager?.setting;
|
||||||
if (!settingManager || typeof settingManager.get !== "function") {
|
if (!settingManager || typeof settingManager.get !== "function") {
|
||||||
if (!settingsUnavailableLogged) {
|
if (!settingsUnavailableLogged) {
|
||||||
console.warn("LoRA Manager: settings API unavailable, using default custom words autocomplete setting.");
|
console.warn("LoRA Manager: settings API unavailable, using default tag autocomplete setting.");
|
||||||
settingsUnavailableLogged = true;
|
settingsUnavailableLogged = true;
|
||||||
}
|
}
|
||||||
return PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_DEFAULT;
|
return PROMPT_TAG_AUTOCOMPLETE_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const value = settingManager.get(PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_SETTING_ID);
|
const value = settingManager.get(PROMPT_TAG_AUTOCOMPLETE_SETTING_ID);
|
||||||
return value ?? PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_DEFAULT;
|
return value ?? PROMPT_TAG_AUTOCOMPLETE_DEFAULT;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!settingsUnavailableLogged) {
|
if (!settingsUnavailableLogged) {
|
||||||
console.warn("LoRA Manager: unable to read custom words autocomplete setting, using default.", error);
|
console.warn("LoRA Manager: unable to read tag autocomplete setting, using default.", error);
|
||||||
settingsUnavailableLogged = true;
|
settingsUnavailableLogged = true;
|
||||||
}
|
}
|
||||||
return PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_DEFAULT;
|
return PROMPT_TAG_AUTOCOMPLETE_DEFAULT;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
@@ -124,11 +124,11 @@ app.registerExtension({
|
|||||||
category: ["LoRA Manager", "Automation", "Auto path correction"],
|
category: ["LoRA Manager", "Automation", "Auto path correction"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_SETTING_ID,
|
id: PROMPT_TAG_AUTOCOMPLETE_SETTING_ID,
|
||||||
name: "Enable Custom Words Autocomplete in Prompt Nodes",
|
name: "Enable Tag Autocomplete in Prompt Nodes",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
defaultValue: PROMPT_CUSTOM_WORDS_AUTOCOMPLETE_DEFAULT,
|
defaultValue: PROMPT_TAG_AUTOCOMPLETE_DEFAULT,
|
||||||
tooltip: "When enabled, prompt nodes will autocomplete custom words. When disabled, only 'emb:' prefix will trigger embeddings autocomplete.",
|
tooltip: "When enabled, typing will trigger tag autocomplete suggestions. Commands (e.g., /character, /artist) always work regardless of this setting.",
|
||||||
category: ["LoRA Manager", "Autocomplete", "Prompt"],
|
category: ["LoRA Manager", "Autocomplete", "Prompt"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -138,4 +138,4 @@ app.registerExtension({
|
|||||||
// Exports
|
// Exports
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
export { getWheelSensitivity, getAutoPathCorrectionPreference, getPromptCustomWordsAutocompletePreference };
|
export { getWheelSensitivity, getAutoPathCorrectionPreference, getPromptTagAutocompletePreference };
|
||||||
|
|||||||
Reference in New Issue
Block a user