Default notifications for workflows
This commit is contained in:
@@ -667,6 +667,13 @@ const ALL_ATTRIBUTES: AttributesSpecList = [
|
||||
location: "workflow",
|
||||
editable: true,
|
||||
defaultValue: true
|
||||
},
|
||||
{
|
||||
name: "showDefaultNotifications",
|
||||
type: "boolean",
|
||||
location: "workflow",
|
||||
editable: true,
|
||||
defaultValue: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import type { Progress, SerializedPromptInputsAll, SerializedPromptOutputs, Work
|
||||
import type { ComfyExecutionResult } from "$lib/nodes/ComfyWidgetNodes";
|
||||
import notify from "$lib/notify";
|
||||
import { get, writable, type Writable } from "svelte/store";
|
||||
import workflowState from "./workflowState";
|
||||
import { playSound } from "$lib/utils";
|
||||
|
||||
export type QueueEntryStatus = "success" | "error" | "interrupted" | "all_cached" | "unknown";
|
||||
|
||||
@@ -267,6 +269,11 @@ function executingUpdated(promptID: PromptID, runningNodeID: ComfyNodeID | null)
|
||||
moveToCompleted(index, queue, "all_cached", "(Execution was cached)");
|
||||
}
|
||||
else if (entry.nodesRan.size >= totalNodesInPrompt) {
|
||||
const workflow = workflowState.getWorkflow(entry.extraData.workflowID);
|
||||
if (workflow?.attrs.showDefaultNotifications) {
|
||||
notify("Prompt finished!", { type: "success" });
|
||||
playSound("notification.mp3")
|
||||
}
|
||||
moveToCompleted(index, queue, "success")
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -54,6 +54,13 @@ export type WorkflowAttributes = {
|
||||
* Comfy.QueueEvents node.
|
||||
*/
|
||||
queuePromptButtonRunWorkflow: boolean,
|
||||
|
||||
/*
|
||||
* If true, notifications will be shown when a prompt is queued and
|
||||
* completed. Set to false if you need more detailed control over the
|
||||
* notification type/contents, and use the `ComfyNotifyAction` node instead.
|
||||
*/
|
||||
showDefaultNotifications: boolean,
|
||||
}
|
||||
|
||||
export class ComfyBoxWorkflow {
|
||||
@@ -217,7 +224,7 @@ export class ComfyBoxWorkflow {
|
||||
// this.#invokeExtensions("loadedGraphNode", node);
|
||||
}
|
||||
|
||||
this.attrs = data.attrs;
|
||||
this.attrs = { ...defaultWorkflowAttributes, ...data.attrs };
|
||||
|
||||
// Now restore the layout
|
||||
// Subsequent added nodes will add the UI data to layoutState
|
||||
|
||||
Reference in New Issue
Block a user