Skip to content

Commit

Permalink
New menu/workflows fixes (comfyanonymous#3900)
Browse files Browse the repository at this point in the history
* Fix auto queue

* Detect added nodes via search

* Fix loading workflows

* Add button click style
  • Loading branch information
pythongosssss authored Jun 28, 2024
1 parent 264caca commit 0d9009c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
12 changes: 11 additions & 1 deletion web/scripts/changeTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { api } from "./api.js";
import { clone } from "./utils.js";


export class ChangeTracker {
static MAX_HISTORY = 50;
#app;
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions web/scripts/ui/menu/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions web/scripts/ui/menu/queueButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions web/scripts/workflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit 0d9009c

Please sign in to comment.