From 0d9009c96ea5a1922a1c187deef27c7f133ee946 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Fri, 28 Jun 2024 06:07:19 +0100 Subject: [PATCH] New menu/workflows fixes (#3900) * Fix auto queue * Detect added nodes via search * Fix loading workflows * Add button click style --- web/scripts/changeTracker.js | 12 +++++++++++- web/scripts/ui/menu/menu.css | 4 ++++ web/scripts/ui/menu/queueButton.js | 4 ++-- web/scripts/workflows.js | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web/scripts/changeTracker.js b/web/scripts/changeTracker.js index 59901d5fcd1..041c83122e0 100644 --- a/web/scripts/changeTracker.js +++ b/web/scripts/changeTracker.js @@ -3,7 +3,6 @@ import { api } from "./api.js"; import { clone } from "./utils.js"; - export class ChangeTracker { static MAX_HISTORY = 50; #app; @@ -170,6 +169,17 @@ export class ChangeTracker { return v; }; + // Detects nodes being added via the node search dialog + const onNodeAdded = LiteGraph.LGraph.prototype.onNodeAdded; + LiteGraph.LGraph.prototype.onNodeAdded = function () { + const v = onNodeAdded?.apply(this, arguments); + const ct = changeTracker(); + if (!ct.isOurLoad) { + ct.checkState(); + } + return v; + }; + // Store node outputs api.addEventListener("executed", ({ detail }) => { const prompt = app.workflowManager.queuedPrompts[detail.prompt_id]; diff --git a/web/scripts/ui/menu/menu.css b/web/scripts/ui/menu/menu.css index 20eeab2cf57..afaed3fb0fb 100644 --- a/web/scripts/ui/menu/menu.css +++ b/web/scripts/ui/menu/menu.css @@ -19,8 +19,12 @@ padding: 4px 8px; box-sizing: border-box; margin: 0; + transition: box-shadow 0.1s; } +.comfyui-button:active { + box-shadow: inset 1px 1px 10px rgba(0, 0, 0, 0.5); +} .comfyui-button:disabled { opacity: 0.5; cursor: not-allowed; diff --git a/web/scripts/ui/menu/queueButton.js b/web/scripts/ui/menu/queueButton.js index 3c29ab090c0..608f4cc9b00 100644 --- a/web/scripts/ui/menu/queueButton.js +++ b/web/scripts/ui/menu/queueButton.js @@ -13,8 +13,8 @@ export class ComfyQueueButton { queuePrompt = async (e) => { this.#internalQueueSize += this.queueOptions.batchCount; - // Hold shift to queue front - await this.app.queuePrompt(-e.shiftKey, this.queueOptions.batchCount); + // Hold shift to queue front, event is undefined when auto-queue is enabled + await this.app.queuePrompt(e?.shiftKey ? -1 : 0, this.queueOptions.batchCount); }; constructor(app) { diff --git a/web/scripts/workflows.js b/web/scripts/workflows.js index 16bbc997633..d38b6f5fc0a 100644 --- a/web/scripts/workflows.js +++ b/web/scripts/workflows.js @@ -301,11 +301,11 @@ export class ComfyWorkflow { load = async () => { if (this.isOpen) { - await this.manager.app.loadGraphData(this.changeTracker.activeState, true, this); + await this.manager.app.loadGraphData(this.changeTracker.activeState, true, true, this); } else { const data = await this.getWorkflowData(); if (!data) return; - await this.manager.app.loadGraphData(data, true, this); + await this.manager.app.loadGraphData(data, true, true, this); } };