From cd8ea3f964a1c04ee42aa371d63ead785f5776de Mon Sep 17 00:00:00 2001 From: Judd Date: Fri, 21 Aug 2026 07:56:58 -0700 Subject: [PATCH] feat: show the final prompt (with triggers and LoRA list) on the encoder after each run Co-Authored-By: Claude Fable 5 --- js/bawk_nodes.js | 30 ++++++++++++++++++++++++++++++ nodes/flux_wildcard_encode.py | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/js/bawk_nodes.js b/js/bawk_nodes.js index d59dfac..67fa595 100644 --- a/js/bawk_nodes.js +++ b/js/bawk_nodes.js @@ -1,4 +1,5 @@ import { app } from "../../scripts/app.js"; +import { ComfyWidgets } from "../../scripts/widgets.js"; const NODE_COLORS = { DiffusionModelLoader: ["#1a2332", "#4a90e2"], @@ -11,6 +12,19 @@ const NODE_COLORS = { BawkBatchProcessor: ["#1a2a32", "#16a085"], }; +const PREVIEW_WIDGET = "final_prompt_preview"; + +function ensurePreviewWidget(node) { + let widget = node.widgets?.find((w) => w.name === PREVIEW_WIDGET); + if (widget) return widget; + widget = ComfyWidgets.STRING(node, PREVIEW_WIDGET, ["STRING", { multiline: true }], app).widget; + widget.inputEl.readOnly = true; + widget.inputEl.style.opacity = 0.7; + widget.inputEl.placeholder = "Final prompt appears here after the node runs"; + widget.serializeValue = async () => ""; + return widget; +} + app.registerExtension({ name: "bawk.nodes", beforeRegisterNodeDef(nodeType, nodeData) { @@ -27,7 +41,23 @@ app.registerExtension({ widget.inputEl.placeholder = "Prompt... use {option1|option2} for wildcards"; } } + if (nodeData.name === "FluxWildcardEncode") { + ensurePreviewWidget(this); + } return result; }; + + if (nodeData.name === "FluxWildcardEncode") { + const onExecuted = nodeType.prototype.onExecuted; + nodeType.prototype.onExecuted = function (message) { + onExecuted?.apply(this, arguments); + const text = message?.text; + if (!text) return; + const widget = ensurePreviewWidget(this); + widget.value = Array.isArray(text) ? text.join("\n") : String(text); + this.setSize([this.size[0], Math.max(this.size[1], this.computeSize()[1])]); + this.setDirtyCanvas(true, true); + }; + } }, }); diff --git a/nodes/flux_wildcard_encode.py b/nodes/flux_wildcard_encode.py index 1fb5b10..fadf6df 100644 --- a/nodes/flux_wildcard_encode.py +++ b/nodes/flux_wildcard_encode.py @@ -80,4 +80,6 @@ class FluxWildcardEncode: final_prompt = process_wildcards(add_triggers(prompt, stack["triggers"], trigger_words), wildcard_seed) tokens = clip.tokenize(final_prompt) conditioning = clip.encode_from_tokens_scheduled(tokens) - return (model, clip, conditioning, final_prompt, stack_info(stack)) + info = stack_info(stack) + preview = final_prompt if not info else f"{final_prompt}\n\n[LoRAs] {info}" + return {"ui": {"text": [preview]}, "result": (model, clip, conditioning, final_prompt, info)}