Merge pull request #112 from space-nuko/bughunt

Some issues fixing
This commit is contained in:
space-nuko
2023-06-02 11:03:58 -05:00
committed by GitHub
14 changed files with 262 additions and 114 deletions

View File

@@ -25,7 +25,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
activeErrors?: ComfyGraphErrors = null; activeErrors?: ComfyGraphErrors = null;
blinkError: ComfyGraphErrorLocation | null = null; blinkError: ComfyGraphErrorLocation | null = null;
blinkErrorTime: number = 0; blinkErrorTime: number = 0;
highlightNodeAndInput: [LGraphNode, number] | null = null; highlightNodeAndInput: [LGraphNode, number | null] | null = null;
get comfyGraph(): ComfyGraph | null { get comfyGraph(): ComfyGraph | null {
return this.graph as ComfyGraph; return this.graph as ComfyGraph;
@@ -104,7 +104,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
let state = get(queueState); let state = get(queueState);
let ss = get(selectionState); let ss = get(selectionState);
const isRunningNode = node.id == state.runningNodeID const isExecuting = state.executingNodes.has(node.id);
const nodeErrors = this.activeErrors?.errorsByID[node.id]; const nodeErrors = this.activeErrors?.errorsByID[node.id];
const isHighlightedNode = this.highlightNodeAndInput && this.highlightNodeAndInput[0].id === node.id; const isHighlightedNode = this.highlightNodeAndInput && this.highlightNodeAndInput[0].id === node.id;
@@ -133,11 +133,20 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
else if (isHighlightedNode) { else if (isHighlightedNode) {
color = "cyan"; color = "cyan";
thickness = 2 thickness = 2
// Blink node if no input highlighted
if (this.highlightNodeAndInput[1] == null) {
if (this.blinkErrorTime > 0) {
if ((Math.floor(this.blinkErrorTime / 2)) % 2 === 0) {
color = null;
}
}
}
} }
else if (ss.currentHoveredNodes.has(node.id)) { else if (ss.currentHoveredNodes.has(node.id)) {
color = "lightblue"; color = "lightblue";
} }
else if (isRunningNode) { else if (isExecuting) {
color = "#0f0"; color = "#0f0";
} }
@@ -153,7 +162,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
this.drawNodeOutline(node, ctx, size, mouseOver, fgColor, bgColor, color, thickness) this.drawNodeOutline(node, ctx, size, mouseOver, fgColor, bgColor, color, thickness)
} }
if (isRunningNode && state.progress) { if (isExecuting && state.progress) {
ctx.fillStyle = "green"; ctx.fillStyle = "green";
ctx.fillRect(0, 0, size[0] * (state.progress.value / state.progress.max), 6); ctx.fillRect(0, 0, size[0] * (state.progress.value / state.progress.max), 6);
ctx.fillStyle = bgColor; ctx.fillStyle = bgColor;
@@ -172,12 +181,14 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
} }
if (draw) { if (draw) {
const [node, inputSlot] = this.highlightNodeAndInput; const [node, inputSlot] = this.highlightNodeAndInput;
if (inputSlot != null) {
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.strokeStyle = color; ctx.strokeStyle = color;
this.highlightNodeInput(node, inputSlot, ctx); this.highlightNodeInput(node, inputSlot, ctx);
} }
} }
} }
}
private drawFailedValidationInputs(node: LGraphNode, errors: ComfyGraphErrorLocation[], color: string, ctx: CanvasRenderingContext2D) { private drawFailedValidationInputs(node: LGraphNode, errors: ComfyGraphErrorLocation[], color: string, ctx: CanvasRenderingContext2D) {
ctx.lineWidth = 2; ctx.lineWidth = 2;
@@ -733,7 +744,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
this.selectNode(node); this.selectNode(node);
} }
jumpToNodeAndInput(node: LGraphNode, slotIndex: number) { jumpToNodeAndInput(node: LGraphNode, slotIndex: number | null) {
this.jumpToNode(node); this.jumpToNode(node);
this.highlightNodeAndInput = [node, slotIndex]; this.highlightNodeAndInput = [node, slotIndex];
this.blinkErrorTime = 20; this.blinkErrorTime = 20;

View File

@@ -165,7 +165,6 @@ export class ImageViewer {
let urls = ImageViewer.get_gallery_urls(galleryElem) let urls = ImageViewer.get_gallery_urls(galleryElem)
const [_currentButton, index] = ImageViewer.selected_gallery_button(galleryElem) const [_currentButton, index] = ImageViewer.selected_gallery_button(galleryElem)
console.warn("Gallery!", index, urls, galleryElem)
this.showModal(urls, index, galleryElem) this.showModal(urls, index, galleryElem)
} }

View File

@@ -45,7 +45,8 @@ export type ComfyAPIHistoryItem = [
] ]
export type ComfyAPIPromptSuccessResponse = { export type ComfyAPIPromptSuccessResponse = {
promptID: PromptID promptID: PromptID,
number: number
} }
export type ComfyAPIPromptResponse = ComfyAPIPromptSuccessResponse | ComfyAPIPromptErrorResponse export type ComfyAPIPromptResponse = ComfyAPIPromptSuccessResponse | ComfyAPIPromptErrorResponse
@@ -295,7 +296,7 @@ export default class ComfyAPI {
} }
return res.json() return res.json()
}) })
.then(raw => { return { promptID: raw.prompt_id } }) .then(raw => { return { promptID: raw.prompt_id, number: raw.number } })
.catch(error => { return error }) .catch(error => { return error })
} }

View File

@@ -728,11 +728,13 @@ export default class ComfyApp {
} }
private requestPermissions() { private requestPermissions() {
if (Notification.permission === "default") { if (window.Notification != null) {
Notification.requestPermission() if (window.Notification.permission === "default") {
window.Notification.requestPermission()
.then((result) => console.log("Notification status:", result)); .then((result) => console.log("Notification status:", result));
} }
} }
}
private setupColorScheme() { private setupColorScheme() {
const setColor = (type: any, color: string) => { const setColor = (type: any, color: string) => {
@@ -939,7 +941,11 @@ export default class ComfyApp {
if (workflow.attrs.queuePromptButtonRunWorkflow) { if (workflow.attrs.queuePromptButtonRunWorkflow) {
// Hold control to queue at the front // Hold control to queue at the front
const num = this.ctrlDown ? -1 : 0; const num = this.ctrlDown ? -1 : 0;
this.queuePrompt(workflow, num, 1); let tag = null;
if (workflow.attrs.queuePromptButtonDefaultWorkflow) {
tag = workflow.attrs.queuePromptButtonDefaultWorkflow
}
this.queuePrompt(workflow, num, 1, tag);
} }
} }
@@ -1037,11 +1043,11 @@ export default class ComfyApp {
const p = this.graphToPrompt(workflow, tag); const p = this.graphToPrompt(workflow, tag);
const wf = this.serialize(workflow) const wf = this.serialize(workflow)
console.debug(graphToGraphVis(workflow.graph)) // console.debug(graphToGraphVis(workflow.graph))
console.debug(promptToGraphVis(p)) // console.debug(promptToGraphVis(p))
const stdPrompt = this.stdPromptSerializer.serialize(p); const stdPrompt = this.stdPromptSerializer.serialize(p);
console.warn("STD", stdPrompt); // console.warn("STD", stdPrompt);
const extraData: ComfyBoxPromptExtraData = { const extraData: ComfyBoxPromptExtraData = {
extra_pnginfo: { extra_pnginfo: {
@@ -1074,8 +1080,8 @@ export default class ComfyApp {
workflowState.promptError(workflow.id, errorPromptID) workflowState.promptError(workflow.id, errorPromptID)
} }
else { else {
queueState.afterQueued(workflow.id, response.promptID, num, p.output, extraData) queueState.afterQueued(workflow.id, response.promptID, response.number, p.output, extraData)
workflowState.afterQueued(workflow.id, response.promptID, p, extraData) workflowState.afterQueued(workflow.id, response.promptID)
} }
} catch (err) { } catch (err) {
errorMes = err?.toString(); errorMes = err?.toString();

View File

@@ -1,5 +1,11 @@
<script context="module" lang="ts"> <script context="module" lang="ts">
export const WORKFLOWS_VIEW: any = {} // workaround a vite HMR bug
// shouts out to @rixo
// https://github.com/sveltejs/svelte/issues/8655
export const WORKFLOWS_VIEW = import.meta.hot?.data?.WORKFLOWS_VIEW || {}
if (import.meta.hot?.data) {
import.meta.hot.data.WORKFLOWS_VIEW = WORKFLOWS_VIEW
}
</script> </script>
<script lang="ts"> <script lang="ts">

View File

@@ -4,16 +4,36 @@
import Accordion from "./gradio/app/Accordion.svelte"; import Accordion from "./gradio/app/Accordion.svelte";
import uiState from '$lib/stores/uiState'; import uiState from '$lib/stores/uiState';
import type { ComfyNodeDefInputType } from "$lib/ComfyNodeDef"; import type { ComfyNodeDefInputType } from "$lib/ComfyNodeDef";
import type { INodeInputSlot, LGraphNode, Subgraph } from "@litegraph-ts/core"; import type { INodeInputSlot, LGraphNode, LLink, Subgraph } from "@litegraph-ts/core";
import { UpstreamNodeLocator } from "./ComfyPromptSerializer"; import { UpstreamNodeLocator, getUpstreamLink, nodeHasTag } from "./ComfyPromptSerializer";
import JsonView from "./JsonView.svelte"; import JsonView from "./JsonView.svelte";
export let app: ComfyApp; export let app: ComfyApp;
export let errors: ComfyGraphErrors; export let errors: ComfyGraphErrors;
let missingTag = null;
let nodeToJumpTo = null;
let inputSlotToHighlight = null;
let _errors = null
$: if (_errors != errors) {
_errors = errors;
if (errors.errors[0]) {
jumpToError(errors.errors[0])
}
}
function closeList() { function closeList() {
app.lCanvas.clearErrors(); app.lCanvas.clearErrors();
$uiState.activeError = null; $uiState.activeError = null;
clearState()
}
function clearState() {
_errors = null;
missingTag = null;
nodeToJumpTo = null;
inputSlotToHighlight = null;
} }
function getParentNode(error: ComfyGraphErrorLocation): Subgraph | null { function getParentNode(error: ComfyGraphErrorLocation): Subgraph | null {
@@ -24,18 +44,26 @@
return node.graph._subgraph_node return node.graph._subgraph_node
} }
function canJumpToDisconnectedInput(error: ComfyGraphErrorLocation): boolean { function jumpToFoundNode() {
return error.errorType === ComfyNodeErrorType.RequiredInputMissing && error.input != null; if (nodeToJumpTo == null) {
return
} }
function jumpToDisconnectedInput(error: ComfyGraphErrorLocation) { app.lCanvas.jumpToNodeAndInput(nodeToJumpTo, inputSlotToHighlight);
}
function detectDisconnected(error: ComfyGraphErrorLocation) {
missingTag = null;
nodeToJumpTo = null;
inputSlotToHighlight = null;
if (error.errorType !== ComfyNodeErrorType.RequiredInputMissing || error.input == null) { if (error.errorType !== ComfyNodeErrorType.RequiredInputMissing || error.input == null) {
return return
} }
const node = app.lCanvas.graph.getNodeByIdRecursive(error.nodeID); const node = app.lCanvas.graph.getNodeByIdRecursive(error.nodeID);
const inputIndex =node.findInputSlotIndexByName(error.input.name); const inputIndex = node.findInputSlotIndexByName(error.input.name);
if (inputIndex === -1) { if (inputIndex === -1) {
return return
} }
@@ -43,17 +71,33 @@
// TODO multiple tags? // TODO multiple tags?
const tag: string | null = error.queueEntry.extraData.extra_pnginfo.comfyBoxPrompt.subgraphs[0]; const tag: string | null = error.queueEntry.extraData.extra_pnginfo.comfyBoxPrompt.subgraphs[0];
const test = (node: LGraphNode) => (node as any).isBackendNode const test = (node: LGraphNode, currentLink: LLink) => {
if (!nodeHasTag(node, tag, true))
return true;
const [nextGraph, nextLink, nextInputSlot, nextNode] = getUpstreamLink(node, currentLink)
return nextLink == null;
};
const nodeLocator = new UpstreamNodeLocator(test) const nodeLocator = new UpstreamNodeLocator(test)
const [_, foundLink, foundInputSlot, foundPrevNode] = nodeLocator.locateUpstream(node, inputIndex, tag); const [foundNode, foundLink, foundInputSlot, foundPrevNode] = nodeLocator.locateUpstream(node, inputIndex, null);
if (foundInputSlot != null && foundPrevNode != null) { if (foundInputSlot != null && foundPrevNode != null) {
app.lCanvas.jumpToNodeAndInput(foundPrevNode, foundInputSlot); if (!nodeHasTag(foundNode, tag, true)) {
nodeToJumpTo = foundNode
missingTag = tag;
inputSlotToHighlight = null;
}
else {
nodeToJumpTo = foundPrevNode;
inputSlotToHighlight = foundInputSlot;
}
} }
} }
function jumpToError(error: ComfyGraphErrorLocation) { function jumpToError(error: ComfyGraphErrorLocation) {
app.lCanvas.jumpToError(error); app.lCanvas.jumpToError(error);
detectDisconnected(error);
} }
function getInputTypeName(type: ComfyNodeDefInputType) { function getInputTypeName(type: ComfyNodeDefInputType) {
@@ -88,26 +132,37 @@
<div class="error-details"> <div class="error-details">
<button class="jump-to-error" class:execution-error={isExecutionError} on:click={() => jumpToError(error)}><span></span></button> <button class="jump-to-error" class:execution-error={isExecutionError} on:click={() => jumpToError(error)}><span></span></button>
<div class="error-details-wrapper"> <div class="error-details-wrapper">
{#if missingTag && nodeToJumpTo}
<div class="error-input">
<div><span class="error-message">Node "{nodeToJumpTo.title}" was missing tag used in workflow:</span><span style:padding-left="0.2rem"><b>{missingTag}</b></span></div>
<div>Tags on node: <b>{(nodeToJumpTo?.properties?.tags || []).join(", ")}</b></div>
</div>
{:else}
<span class="error-message" class:execution-error={isExecutionError}>{error.message}</span> <span class="error-message" class:execution-error={isExecutionError}>{error.message}</span>
{/if}
{#if error.exceptionType} {#if error.exceptionType}
<span>({error.exceptionType})</span> <span>({error.exceptionType})</span>
{/if} {/if}
{#if error.exceptionMessage && !isExecutionError} {#if error.exceptionMessage && !isExecutionError}
<div style:text-decoration="underline">{error.exceptionMessage}</div> <div style:text-decoration="underline">{error.exceptionMessage}</div>
{/if} {/if}
{#if error.input} {#if nodeToJumpTo != null}
<div style:display="flex" style:flex-direction="row">
<button class="jump-to-error locate" on:click={jumpToFoundNode}><span></span></button>
{#if missingTag}
<span>Jump to node: {nodeToJumpTo.title}</span>
{:else}
<span>Find disconnected input</span>
{/if}
</div>
{/if}
{#if error.input && !missingTag}
<div class="error-input"> <div class="error-input">
<span>Input: <b>{error.input.name}</b></span> <span>Input: <b>{error.input.name}</b></span>
{#if error.input.config} {#if error.input.config}
<span>({getInputTypeName(error.input.config[0])})</span> <span>({getInputTypeName(error.input.config[0])})</span>
{/if} {/if}
</div> </div>
{#if canJumpToDisconnectedInput(error)}
<div style:display="flex" style:flex-direction="row">
<button class="jump-to-error locate" on:click={() => jumpToDisconnectedInput(error)}><span></span></button>
<span>Find disconnected input</span>
</div>
{/if}
{#if error.input.receivedValue} {#if error.input.receivedValue}
<div> <div>

View File

@@ -71,13 +71,9 @@ export function isActiveBackendNode(node: LGraphNode, tag: string | null = null)
return true; return true;
} }
type UpstreamResult = [LGraph | null, LLink | null, number | null, LGraphNode | null]; export type UpstreamResult = [LGraph | null, LLink | null, number | null, LGraphNode | null];
export class UpstreamNodeLocator { function followSubgraph(subgraph: Subgraph, link: LLink): UpstreamResult {
constructor(private isTheTargetNode: (node: LGraphNode) => boolean) {
}
private followSubgraph(subgraph: Subgraph, link: LLink): UpstreamResult {
if (link.origin_id != subgraph.id) if (link.origin_id != subgraph.id)
throw new Error("Invalid link and graph output!") throw new Error("Invalid link and graph output!")
@@ -87,9 +83,9 @@ export class UpstreamNodeLocator {
const nextLink = innerGraphOutput.getInputLink(0) const nextLink = innerGraphOutput.getInputLink(0)
return [innerGraphOutput.graph, nextLink, 0, innerGraphOutput]; return [innerGraphOutput.graph, nextLink, 0, innerGraphOutput];
} }
private followGraphInput(graphInput: GraphInput, link: LLink): UpstreamResult { function followGraphInput(graphInput: GraphInput, link: LLink): UpstreamResult {
if (link.origin_id != graphInput.id) if (link.origin_id != graphInput.id)
throw new Error("Invalid link and graph input!") throw new Error("Invalid link and graph input!")
@@ -98,21 +94,21 @@ export class UpstreamNodeLocator {
throw new Error("No outer subgraph!") throw new Error("No outer subgraph!")
const outerInputIndex = outerSubgraph.inputs.findIndex(i => i.name === graphInput.nameInGraph) const outerInputIndex = outerSubgraph.inputs.findIndex(i => i.name === graphInput.nameInGraph)
if (outerInputIndex == null) if (outerInputIndex === -1)
throw new Error("No outer input slot!") throw new Error("No outer input slot!")
const nextLink = outerSubgraph.getInputLink(outerInputIndex) const nextLink = outerSubgraph.getInputLink(outerInputIndex)
return [outerSubgraph.graph, nextLink, outerInputIndex, outerSubgraph]; return [outerSubgraph.graph, nextLink, outerInputIndex, outerSubgraph];
} }
private getUpstreamLink(parent: LGraphNode, currentLink: LLink): UpstreamResult { export function getUpstreamLink(parent: LGraphNode, currentLink: LLink): UpstreamResult {
if (parent.is(Subgraph)) { if (parent.is(Subgraph)) {
console.debug("FollowSubgraph") console.debug("FollowSubgraph")
return this.followSubgraph(parent, currentLink); return followSubgraph(parent, currentLink);
} }
else if (parent.is(GraphInput)) { else if (parent.is(GraphInput)) {
console.debug("FollowGraphInput") console.debug("FollowGraphInput")
return this.followGraphInput(parent, currentLink); return followGraphInput(parent, currentLink);
} }
else if ("getUpstreamLink" in parent) { else if ("getUpstreamLink" in parent) {
const link = (parent as ComfyGraphNode).getUpstreamLink(); const link = (parent as ComfyGraphNode).getUpstreamLink();
@@ -127,6 +123,10 @@ export class UpstreamNodeLocator {
} }
console.warn("[graphToPrompt] Frontend node does not support getUpstreamLink", parent.type) console.warn("[graphToPrompt] Frontend node does not support getUpstreamLink", parent.type)
return [null, null, null, null]; return [null, null, null, null];
}
export class UpstreamNodeLocator {
constructor(private isTheTargetNode: (node: LGraphNode, currentLink: LLink) => boolean) {
} }
/* /*
@@ -146,8 +146,8 @@ export class UpstreamNodeLocator {
let currentInputSlot = inputIndex; let currentInputSlot = inputIndex;
let currentNode = fromNode; let currentNode = fromNode;
const shouldFollowParent = (parent: LGraphNode) => { const shouldFollowParent = (parent: LGraphNode, currentLink: LLink) => {
return isActiveNode(parent, tag) && !this.isTheTargetNode(parent); return isActiveNode(parent, tag) && !this.isTheTargetNode(parent, currentLink);
} }
// If there are non-target nodes between us and another // If there are non-target nodes between us and another
@@ -156,8 +156,8 @@ export class UpstreamNodeLocator {
// will simply follow their single input, while branching // will simply follow their single input, while branching
// nodes have conditional logic that determines which link // nodes have conditional logic that determines which link
// to follow backwards. // to follow backwards.
while (shouldFollowParent(parent)) { while (shouldFollowParent(parent, currentLink)) {
const [nextGraph, nextLink, nextInputSlot, nextNode] = this.getUpstreamLink(parent, currentLink); const [nextGraph, nextLink, nextInputSlot, nextNode] = getUpstreamLink(parent, currentLink);
currentInputSlot = nextInputSlot; currentInputSlot = nextInputSlot;
currentNode = nextNode; currentNode = nextNode;
@@ -183,7 +183,7 @@ export class UpstreamNodeLocator {
} }
} }
if (!isActiveNode(parent, tag) || !this.isTheTargetNode(parent) || currentLink == null) if (!isActiveNode(parent, tag) || !this.isTheTargetNode(parent, currentLink) || currentLink == null)
return [null, currentLink, currentInputSlot, currentNode]; return [null, currentLink, currentInputSlot, currentNode];
return [parent, currentLink, currentInputSlot, currentNode] return [parent, currentLink, currentInputSlot, currentNode]

View File

@@ -15,7 +15,7 @@
export let label: string; export let label: string;
export let root: string = ""; export let root: string = "";
export let root_url: null | string = null; export let root_url: null | string = null;
export let scrollOnUpdate = false; export let focusOnScroll = false;
export let value: Array<string> | Array<FileData> | null = null; export let value: Array<string> | Array<FileData> | null = null;
export let style: Styles = { export let style: Styles = {
grid_cols: [2], grid_cols: [2],
@@ -121,10 +121,10 @@
let container: HTMLDivElement; let container: HTMLDivElement;
async function scroll_to_img(index: number | null) { async function scroll_to_img(index: number | null) {
if (!scrollOnUpdate) return;
if (typeof index !== "number") return; if (typeof index !== "number") return;
await tick(); await tick();
if (focusOnScroll)
el[index].focus(); el[index].focus();
const { left: container_left, width: container_width } = const { left: container_left, width: container_width } =

View File

@@ -3,7 +3,7 @@ import ComfyGraphNode, { type ComfyGraphNodeProperties } from "./ComfyGraphNode"
import { Watch } from "@litegraph-ts/nodes-basic"; import { Watch } from "@litegraph-ts/nodes-basic";
import { nextLetter } from "$lib/utils"; import { nextLetter } from "$lib/utils";
export type PickFirstMode = "anyActiveLink" | "truthy" | "dataNonNull" export type PickFirstMode = "anyActiveLink" | "dataTruthy" | "dataNonNull"
export interface ComfyPickFirstNodeProperties extends ComfyGraphNodeProperties { export interface ComfyPickFirstNodeProperties extends ComfyGraphNodeProperties {
mode: PickFirstMode mode: PickFirstMode
@@ -12,7 +12,7 @@ export interface ComfyPickFirstNodeProperties extends ComfyGraphNodeProperties {
export default class ComfyPickFirstNode extends ComfyGraphNode { export default class ComfyPickFirstNode extends ComfyGraphNode {
override properties: ComfyPickFirstNodeProperties = { override properties: ComfyPickFirstNodeProperties = {
tags: [], tags: [],
mode: "dataNonNull" mode: "anyActiveLink"
} }
static slotLayout: SlotLayout = { static slotLayout: SlotLayout = {
@@ -36,21 +36,39 @@ export default class ComfyPickFirstNode extends ComfyGraphNode {
super(title); super(title);
this.displayWidget = this.addWidget("text", "Value", "") this.displayWidget = this.addWidget("text", "Value", "")
this.displayWidget.disabled = true; this.displayWidget.disabled = true;
this.modeWidget = this.addWidget("combo", "Mode", this.properties.mode, null, { property: "mode", values: ["anyActiveLink", "truthy", "dataNonNull"] }) this.modeWidget = this.addWidget("combo", "Mode", this.properties.mode, null, { property: "mode", values: ["anyActiveLink", "dataTruthy", "dataNonNull"] })
} }
override onDrawBackground(ctx: CanvasRenderingContext2D) { override onDrawBackground(ctx: CanvasRenderingContext2D) {
if (this.flags.collapsed || this.selected === -1) { if (this.flags.collapsed) {
return; return;
} }
if (this.selected === -1) {
// Draw an X indicating nothing matched the selection criteria
const y = LiteGraph.NODE_SLOT_HEIGHT + 6;
ctx.lineWidth = 5;
ctx.strokeStyle = "red";
ctx.beginPath();
ctx.moveTo(50 - 15, y - 15);
ctx.lineTo(50 + 15, y + 15);
ctx.stroke();
ctx.moveTo(50 + 15, y - 15);
ctx.lineTo(50 - 15, y + 15);
ctx.stroke();
}
else {
// Draw an arrow pointing to the selected input
ctx.fillStyle = "#AFB"; ctx.fillStyle = "#AFB";
var y = (this.selected) * LiteGraph.NODE_SLOT_HEIGHT + 6; const y = (this.selected) * LiteGraph.NODE_SLOT_HEIGHT + 6;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(50, y); ctx.moveTo(50, y);
ctx.lineTo(50, y + LiteGraph.NODE_SLOT_HEIGHT); ctx.lineTo(50, y + LiteGraph.NODE_SLOT_HEIGHT);
ctx.lineTo(34, y + LiteGraph.NODE_SLOT_HEIGHT * 0.5); ctx.lineTo(34, y + LiteGraph.NODE_SLOT_HEIGHT * 0.5);
ctx.fill(); ctx.fill();
}
}; };
override onConnectionsChange( override onConnectionsChange(
@@ -113,7 +131,7 @@ export default class ComfyPickFirstNode extends ComfyGraphNode {
else { else {
if (this.properties.mode === "dataNonNull") if (this.properties.mode === "dataNonNull")
return link.data != null; return link.data != null;
else if (this.properties.mode === "truthy") else if (this.properties.mode === "dataTruthy")
return Boolean(link.data) return Boolean(link.data)
else // anyActiveLink else // anyActiveLink
return true; return true;

View File

@@ -92,6 +92,11 @@ function notifyToast(text: string, options: NotifyOptions) {
} }
function notifyNative(text: string, options: NotifyOptions) { function notifyNative(text: string, options: NotifyOptions) {
if (window.Notification == null) {
console.warn("[notify] No Notification available on window")
return
}
if (document.hasFocus()) if (document.hasFocus())
return; return;

View File

@@ -681,6 +681,13 @@ const ALL_ATTRIBUTES: AttributesSpecList = [
editable: true, editable: true,
defaultValue: true defaultValue: true
}, },
{
name: "queuePromptButtonDefaultWorkflow",
type: "string",
location: "workflow",
editable: true,
defaultValue: ""
},
{ {
name: "showDefaultNotifications", name: "showDefaultNotifications",
type: "boolean", type: "boolean",

View File

@@ -9,6 +9,7 @@ import { v4 as uuidv4 } from "uuid";
import workflowState, { type WorkflowError, type WorkflowExecutionError, type WorkflowInstID, type WorkflowValidationError } from "./workflowState"; import workflowState, { type WorkflowError, type WorkflowExecutionError, type WorkflowInstID, type WorkflowValidationError } from "./workflowState";
import configState from "./configState"; import configState from "./configState";
import uiQueueState from "./uiQueueState"; import uiQueueState from "./uiQueueState";
import type { NodeID } from "@litegraph-ts/core";
export type QueueEntryStatus = "success" | "validation_failed" | "error" | "interrupted" | "all_cached" | "unknown"; export type QueueEntryStatus = "success" | "validation_failed" | "error" | "interrupted" | "all_cached" | "unknown";
@@ -81,7 +82,21 @@ export type QueueState = {
queuePending: Writable<QueueEntry[]>, queuePending: Writable<QueueEntry[]>,
queueCompleted: Writable<CompletedQueueEntry[]>, queueCompleted: Writable<CompletedQueueEntry[]>,
queueRemaining: number | "X" | null; queueRemaining: number | "X" | null;
/*
* Currently executing node if any
*/
runningNodeID: ComfyNodeID | null; runningNodeID: ComfyNodeID | null;
/*
* Nodes which should be rendered as "executing" in the frontend (green border).
* This includes the running node and all its parent subgraphs
*/
executingNodes: Set<NodeID>;
/*
* Progress for the current node reported by the frontend
*/
progress: Progress | null, progress: Progress | null,
/** /**
* If true, user pressed the "Interrupt" button in the frontend. Disable the * If true, user pressed the "Interrupt" button in the frontend. Disable the
@@ -98,6 +113,7 @@ const store: Writable<QueueState> = writable({
queueCompleted: writable([]), queueCompleted: writable([]),
queueRemaining: null, queueRemaining: null,
runningNodeID: null, runningNodeID: null,
executingNodes: new Set(),
progress: null, progress: null,
isInterrupting: false isInterrupting: false
}) })
@@ -272,6 +288,7 @@ function executingUpdated(promptID: PromptID, runningNodeID: ComfyNodeID | null)
store.update((s) => { store.update((s) => {
s.progress = null; s.progress = null;
s.executingNodes.clear();
const [index, entry, queue] = findEntryInPending(promptID); const [index, entry, queue] = findEntryInPending(promptID);
if (runningNodeID != null) { if (runningNodeID != null) {
@@ -279,6 +296,17 @@ function executingUpdated(promptID: PromptID, runningNodeID: ComfyNodeID | null)
entry.nodesRan.add(runningNodeID) entry.nodesRan.add(runningNodeID)
} }
s.runningNodeID = runningNodeID; s.runningNodeID = runningNodeID;
if (entry?.extraData?.workflowID) {
const workflow = workflowState.getWorkflow(entry.extraData.workflowID);
if (workflow != null) {
let node = workflow.graph.getNodeByIdRecursive(s.runningNodeID);
while (node != null) {
s.executingNodes.add(node.id);
node = node.graph?._subgraph_node;
}
}
}
} }
else { else {
// Prompt finished executing. // Prompt finished executing.
@@ -310,6 +338,7 @@ function executingUpdated(promptID: PromptID, runningNodeID: ComfyNodeID | null)
} }
s.progress = null; s.progress = null;
s.runningNodeID = null; s.runningNodeID = null;
s.executingNodes.clear();
} }
entry_ = entry; entry_ = entry;
return s return s
@@ -334,6 +363,7 @@ function executionCached(promptID: PromptID, nodes: ComfyNodeID[]) {
s.isInterrupting = false; // TODO move to start s.isInterrupting = false; // TODO move to start
s.progress = null; s.progress = null;
s.runningNodeID = null; s.runningNodeID = null;
s.executingNodes.clear();
return s return s
}) })
} }
@@ -351,6 +381,7 @@ function executionError(error: ComfyExecutionError): CompletedQueueEntry | null
} }
s.progress = null; s.progress = null;
s.runningNodeID = null; s.runningNodeID = null;
s.executingNodes.clear();
return s return s
}) })
return entry_; return entry_;
@@ -384,6 +415,8 @@ function executionStart(promptID: PromptID) {
moveToRunning(index, queue) moveToRunning(index, queue)
} }
s.isInterrupting = false; s.isInterrupting = false;
s.runningNodeID = null;
s.executingNodes.clear();
return s return s
}) })
} }
@@ -448,6 +481,7 @@ function queueCleared(type: QueueItemType) {
s.queueRemaining = 0; s.queueRemaining = 0;
s.runningNodeID = null; s.runningNodeID = null;
s.progress = null; s.progress = null;
s.executingNodes.clear();
} }
else { else {
s.queueCompleted.set([]) s.queueCompleted.set([])

View File

@@ -57,6 +57,12 @@ export type WorkflowAttributes = {
*/ */
queuePromptButtonRunWorkflow: boolean, queuePromptButtonRunWorkflow: boolean,
/*
* Default subgraph to run if `queuePromptButtonRunWorkflow` is `true`. Set
* to blank to run the default subgraph (tagless).
*/
queuePromptButtonDefaultWorkflow: string,
/* /*
* If true, notifications will be shown when a prompt is queued and * If true, notifications will be shown when a prompt is queued and
* completed. Set to false if you need more detailed control over the * completed. Set to false if you need more detailed control over the

View File

@@ -8,7 +8,7 @@
import { type WidgetLayout } from "$lib/stores/layoutStates"; import { type WidgetLayout } from "$lib/stores/layoutStates";
import { get, writable, type Writable } from "svelte/store"; import { get, writable, type Writable } from "svelte/store";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
import { getSafetensorsMetadata } from '$lib/utils'; import { clamp, getSafetensorsMetadata } from '$lib/utils';
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
export let isMobile: boolean = false; export let isMobile: boolean = false;
let node: ComfyComboNode | null = null; let node: ComfyComboNode | null = null;
@@ -174,7 +174,7 @@
itemCount={filteredItems.length} itemCount={filteredItems.length}
{itemSize} {itemSize}
overscanCount={5} overscanCount={5}
scrollToIndex={hoverItemIndex}> scrollToIndex={activeIndex != null ? clamp(activeIndex + itemsToShow - 1, 0, filteredItems.length-1) : hoverItemIndex}>
<div slot="item" <div slot="item"
class="comfy-select-item" class="comfy-select-item"
class:mobile={isMobile} class:mobile={isMobile}