New menu/workflows fixes (#3900)

* Fix auto queue

* Detect added nodes via search

* Fix loading workflows

* Add button click style
This commit is contained in:
pythongosssss 2024-06-28 06:07:19 +01:00 committed by GitHub
parent 264caca20e
commit 0d9009c96e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 5 deletions

View File

@ -3,7 +3,6 @@
import { api } from "./api.js"; import { api } from "./api.js";
import { clone } from "./utils.js"; import { clone } from "./utils.js";
export class ChangeTracker { export class ChangeTracker {
static MAX_HISTORY = 50; static MAX_HISTORY = 50;
#app; #app;
@ -170,6 +169,17 @@ export class ChangeTracker {
return v; 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 // Store node outputs
api.addEventListener("executed", ({ detail }) => { api.addEventListener("executed", ({ detail }) => {
const prompt = app.workflowManager.queuedPrompts[detail.prompt_id]; const prompt = app.workflowManager.queuedPrompts[detail.prompt_id];

View File

@ -19,8 +19,12 @@
padding: 4px 8px; padding: 4px 8px;
box-sizing: border-box; box-sizing: border-box;
margin: 0; 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 { .comfyui-button:disabled {
opacity: 0.5; opacity: 0.5;
cursor: not-allowed; cursor: not-allowed;

View File

@ -13,8 +13,8 @@ export class ComfyQueueButton {
queuePrompt = async (e) => { queuePrompt = async (e) => {
this.#internalQueueSize += this.queueOptions.batchCount; this.#internalQueueSize += this.queueOptions.batchCount;
// Hold shift to queue front // Hold shift to queue front, event is undefined when auto-queue is enabled
await this.app.queuePrompt(-e.shiftKey, this.queueOptions.batchCount); await this.app.queuePrompt(e?.shiftKey ? -1 : 0, this.queueOptions.batchCount);
}; };
constructor(app) { constructor(app) {

View File

@ -301,11 +301,11 @@ export class ComfyWorkflow {
load = async () => { load = async () => {
if (this.isOpen) { 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 { } else {
const data = await this.getWorkflowData(); const data = await this.getWorkflowData();
if (!data) return; if (!data) return;
await this.manager.app.loadGraphData(data, true, this); await this.manager.app.loadGraphData(data, true, true, this);
} }
}; };