Make seed randomize widget run before queued

This commit is contained in:
Filipe 2023-09-23 01:57:33 -03:00
parent 29ccf9f471
commit 578097e907
2 changed files with 16 additions and 1 deletions

View File

@ -1581,6 +1581,21 @@ export class ComfyApp {
({ number, batchCount } = this.#queueItems.pop()); ({ number, batchCount } = this.#queueItems.pop());
for (let i = 0; i < batchCount; i++) { for (let i = 0; i < batchCount; i++) {
const pBefore = await this.graphToPrompt();
for (const n of pBefore.workflow.nodes) {
const node = graph.getNodeById(n.id);
if (node.widgets) {
for (const widget of node.widgets) {
// Allow widgets to run callbacks after a prompt has been queued
// e.g. random seed after every gen
if (widget.beforeQueued) {
widget.beforeQueued();
}
}
}
}
const p = await this.graphToPrompt(); const p = await this.graphToPrompt();
try { try {

View File

@ -27,7 +27,7 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
values: ["fixed", "increment", "decrement", "randomize"], values: ["fixed", "increment", "decrement", "randomize"],
serialize: false, // Don't include this in prompt. serialize: false, // Don't include this in prompt.
}); });
valueControl.afterQueued = () => { valueControl.beforeQueued = () => {
var v = valueControl.value; var v = valueControl.value;