From f5020e081fe414fb73ddf3e32f0df0f64006d7ce Mon Sep 17 00:00:00 2001 From: Will Miao Date: Sat, 22 Nov 2025 20:55:20 +0800 Subject: [PATCH] feat(autocomplete): restrict embeddings autocomplete to explicit prefix Only trigger autocomplete for embeddings when the current token starts with "emb:" prefix. This prevents interrupting normal prompt typing while maintaining quick manual access to embeddings suggestions. --- web/comfyui/autocomplete.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/web/comfyui/autocomplete.js b/web/comfyui/autocomplete.js index 574cd037..c388beb7 100644 --- a/web/comfyui/autocomplete.js +++ b/web/comfyui/autocomplete.js @@ -300,10 +300,23 @@ class AutoComplete { if (this.debounceTimer) { clearTimeout(this.debounceTimer); } - - // Get the search term (text after last comma) - const searchTerm = this.getSearchTerm(value); - + + // Get the search term (text after last comma / '>') + const rawSearchTerm = this.getSearchTerm(value); + let searchTerm = rawSearchTerm; + + // For embeddings, only trigger autocomplete when the current token + // starts with the explicit "emb:" prefix. This avoids interrupting + // normal prompt typing while still allowing quick manual triggering. + if (this.modelType === 'embeddings') { + const match = rawSearchTerm.match(/^emb:(.*)$/i); + if (!match) { + this.hide(); + return; + } + searchTerm = (match[1] || '').trim(); + } + if (searchTerm.length < this.options.minChars) { this.hide(); return;