Fix caching issues with text nodes when working with the UI

This commit is contained in:
doctorpangloss 2024-09-17 16:09:47 -07:00
parent 83b2f0174c
commit d30f15ed09
2 changed files with 7 additions and 13 deletions

View File

@ -33,8 +33,8 @@ class TokenProgressHandler {
}
this.nodeOutputs[nodeId].tokens += detail.output.next_token;
this.updateTokenWidget(nodeId, this.nodeOutputs[nodeId].tokens);
app.graph.setDirtyCanvas(true, false);
}
app.graph.setDirtyCanvas(true, false);
});
}
@ -44,12 +44,12 @@ class TokenProgressHandler {
let widget = node.widgets.find((w) => w.name === tokenPreviewWidgetName);
if (!widget) {
widget = ComfyWidgets["STRING"](node, tokenPreviewWidgetName, ["STRING", { multiline: true }], app).widget;
widget = ComfyWidgets.STRING(node, tokenPreviewWidgetName, ["STRING", { multiline: true }], app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.opacity = 0.7;
}
widget.serializeValue = async () => {};
widget.value = tokens;
app.graph.setDirtyCanvas(true, false);
}
}
}

View File

@ -36,22 +36,16 @@ app.registerExtension({
onExecuted?.apply(this, arguments);
if (this.widgets) {
const index = this.widgets.findIndex((w) => w.name === "output");
let widget = this.widgets.find((w) => w.name === "output");
if (index !== -1) {
for (let i = index; i < this.widgets.length; i++) {
this.widgets[i].onRemove?.();
}
this.widgets.length = index;
if (!widget) {
widget = ComfyWidgets.STRING(this, "output", ["STRING", { multiline: true }], app).widget;
}
const options = ["STRING", { multiline: true }];
const widget = ComfyWidgets["STRING"](this, "output", options, app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.opacity = 0.7;
widget.value = string;
widget.serializeValue = async () => {};
}
};
}