diff --git a/src/lib/ComfyGraphCanvas.ts b/src/lib/ComfyGraphCanvas.ts index 220d85e..c6ae720 100644 --- a/src/lib/ComfyGraphCanvas.ts +++ b/src/lib/ComfyGraphCanvas.ts @@ -25,7 +25,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas { activeErrors?: ComfyGraphErrors = null; blinkError: ComfyGraphErrorLocation | null = null; blinkErrorTime: number = 0; - highlightNodeAndInput: [LGraphNode, number] | null = null; + highlightNodeAndInput: [LGraphNode, number | null] | null = null; get comfyGraph(): ComfyGraph | null { return this.graph as ComfyGraph; @@ -104,7 +104,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas { let state = get(queueState); 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 isHighlightedNode = this.highlightNodeAndInput && this.highlightNodeAndInput[0].id === node.id; @@ -133,11 +133,20 @@ export default class ComfyGraphCanvas extends LGraphCanvas { else if (isHighlightedNode) { color = "cyan"; 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)) { color = "lightblue"; } - else if (isRunningNode) { + else if (isExecuting) { color = "#0f0"; } @@ -153,7 +162,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas { this.drawNodeOutline(node, ctx, size, mouseOver, fgColor, bgColor, color, thickness) } - if (isRunningNode && state.progress) { + if (isExecuting && state.progress) { ctx.fillStyle = "green"; ctx.fillRect(0, 0, size[0] * (state.progress.value / state.progress.max), 6); ctx.fillStyle = bgColor; @@ -172,9 +181,11 @@ export default class ComfyGraphCanvas extends LGraphCanvas { } if (draw) { const [node, inputSlot] = this.highlightNodeAndInput; - ctx.lineWidth = 2; - ctx.strokeStyle = color; - this.highlightNodeInput(node, inputSlot, ctx); + if (inputSlot != null) { + ctx.lineWidth = 2; + ctx.strokeStyle = color; + this.highlightNodeInput(node, inputSlot, ctx); + } } } } @@ -733,7 +744,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas { this.selectNode(node); } - jumpToNodeAndInput(node: LGraphNode, slotIndex: number) { + jumpToNodeAndInput(node: LGraphNode, slotIndex: number | null) { this.jumpToNode(node); this.highlightNodeAndInput = [node, slotIndex]; this.blinkErrorTime = 20; diff --git a/src/lib/ImageViewer.ts b/src/lib/ImageViewer.ts index 9b56cf7..21ec44e 100644 --- a/src/lib/ImageViewer.ts +++ b/src/lib/ImageViewer.ts @@ -165,7 +165,6 @@ export class ImageViewer { let urls = ImageViewer.get_gallery_urls(galleryElem) const [_currentButton, index] = ImageViewer.selected_gallery_button(galleryElem) - console.warn("Gallery!", index, urls, galleryElem) this.showModal(urls, index, galleryElem) } diff --git a/src/lib/api.ts b/src/lib/api.ts index dc8765b..ff25b4b 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -45,7 +45,8 @@ export type ComfyAPIHistoryItem = [ ] export type ComfyAPIPromptSuccessResponse = { - promptID: PromptID + promptID: PromptID, + number: number } export type ComfyAPIPromptResponse = ComfyAPIPromptSuccessResponse | ComfyAPIPromptErrorResponse @@ -295,7 +296,7 @@ export default class ComfyAPI { } return res.json() }) - .then(raw => { return { promptID: raw.prompt_id } }) + .then(raw => { return { promptID: raw.prompt_id, number: raw.number } }) .catch(error => { return error }) } diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index 2c77775..fcd02d8 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -728,9 +728,11 @@ export default class ComfyApp { } private requestPermissions() { - if (Notification.permission === "default") { - Notification.requestPermission() - .then((result) => console.log("Notification status:", result)); + if (window.Notification != null) { + if (window.Notification.permission === "default") { + window.Notification.requestPermission() + .then((result) => console.log("Notification status:", result)); + } } } @@ -939,7 +941,11 @@ export default class ComfyApp { if (workflow.attrs.queuePromptButtonRunWorkflow) { // Hold control to queue at the front 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 wf = this.serialize(workflow) - console.debug(graphToGraphVis(workflow.graph)) - console.debug(promptToGraphVis(p)) + // console.debug(graphToGraphVis(workflow.graph)) + // console.debug(promptToGraphVis(p)) const stdPrompt = this.stdPromptSerializer.serialize(p); - console.warn("STD", stdPrompt); + // console.warn("STD", stdPrompt); const extraData: ComfyBoxPromptExtraData = { extra_pnginfo: { @@ -1074,8 +1080,8 @@ export default class ComfyApp { workflowState.promptError(workflow.id, errorPromptID) } else { - queueState.afterQueued(workflow.id, response.promptID, num, p.output, extraData) - workflowState.afterQueued(workflow.id, response.promptID, p, extraData) + queueState.afterQueued(workflow.id, response.promptID, response.number, p.output, extraData) + workflowState.afterQueued(workflow.id, response.promptID) } } catch (err) { errorMes = err?.toString(); diff --git a/src/lib/components/ComfyBoxWorkflowsView.svelte b/src/lib/components/ComfyBoxWorkflowsView.svelte index d0eff8d..4fd5430 100644 --- a/src/lib/components/ComfyBoxWorkflowsView.svelte +++ b/src/lib/components/ComfyBoxWorkflowsView.svelte @@ -1,5 +1,11 @@