feat: show the final prompt (with triggers and LoRA list) on the encoder after each run

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Judd
2026-08-21 07:56:58 -07:00
co-authored by Claude Fable 5
parent 10372c07fd
commit cd8ea3f964
2 changed files with 33 additions and 1 deletions
+30
View File
@@ -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);
};
}
},
});
+3 -1
View File
@@ -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)}