feat: consolidate ComfyUI settings and add custom words autocomplete toggle

Create unified settings.js extension to centralize all Lora Manager ComfyUI
settings registration, eliminating code duplication across multiple files.

Add new setting "Enable Custom Words Autocomplete in Prompt Nodes" (enabled
by default) to control custom words autocomplete in prompt node text widgets.
When disabled, only 'emb:' prefix triggers embeddings autocomplete.

Changes:
- Create web/comfyui/settings.js with all three settings:
  * Trigger Word Wheel Sensitivity (existing)
  * Auto path correction (existing)
  * Enable Custom Words Autocomplete in Prompt Nodes (new)
- Refactor autocomplete.js to respect the new setting
- Update trigger_word_toggle.js to import from settings.js
- Update usage_stats.js to import from settings.js
This commit is contained in:
Will Miao
2026-01-25 12:53:41 +08:00
parent d5a2bd1e24
commit 6142b3dc0c
4 changed files with 151 additions and 89 deletions

View File

@@ -1,6 +1,7 @@
import { api } from "../../scripts/api.js";
import { app } from "../../scripts/app.js";
import { TextAreaCaretHelper } from "./textarea_caret_helper.js";
import { getPromptCustomWordsAutocompletePreference } from "./settings.js";
function parseUsageTipNumber(value) {
if (typeof value === 'number' && Number.isFinite(value)) {
@@ -420,15 +421,19 @@ class AutoComplete {
if (this.modelType === 'prompt') {
const match = rawSearchTerm.match(/^emb:(.*)$/i);
if (match) {
// User typed "emb:" prefix - search embeddings
// User typed "emb:" prefix - always allow embeddings search
endpoint = '/lm/embeddings/relative-paths';
searchTerm = (match[1] || '').trim();
this.searchType = 'embeddings';
} else {
// No prefix - search custom words
} else if (getPromptCustomWordsAutocompletePreference()) {
// Setting enabled - allow custom words search
endpoint = '/lm/custom-words/search';
searchTerm = rawSearchTerm;
this.searchType = 'custom_words';
} else {
// Setting disabled - no autocomplete for non-emb: terms
this.hide();
return;
}
}