Merge pull request #73 from space-nuko/fix-graph-input-output-tags

Fixes for tag scoping
This commit is contained in:
space-nuko
2023-05-25 22:18:17 -05:00
committed by GitHub
5 changed files with 5261 additions and 5260 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -968,7 +968,7 @@ export default class ComfyApp {
const thumbnails = []
for (const node of workflow.graph.iterateNodesInOrderRecursive()) {
if (node.mode !== NodeMode.ALWAYS || (tag != null && !nodeHasTag(node, tag)))
if (node.mode !== NodeMode.ALWAYS || (tag != null && !nodeHasTag(node, tag, true)))
continue;
if ("getPromptThumbnails" in node) {

View File

@@ -15,18 +15,17 @@ function isGraphInputOutput(node: LGraphNode): boolean {
return node.is(GraphInput) || node.is(GraphOutput)
}
export function nodeHasTag(node: LGraphNode, tag: string): boolean {
// Ignore tags on reroutes since they're just movable wires and it defeats
// the convenience gains to have to set tags for all them
if (isReroute(node))
return true;
export function nodeHasTag(node: LGraphNode, tag: string, checkParents: boolean): boolean {
while (node != null) {
if ("tags" in node.properties) {
if (node.properties.tags.indexOf(tag) !== -1)
return true;
}
if (!checkParents) {
return false;
}
// Count parent subgraphs having the tag also.
node = node.graph?._subgraph_node;
}
@@ -38,8 +37,10 @@ export function isActiveNode(node: LGraphNode, tag: string | null = null): boole
if (!node)
return false;
// Check tags but not on graph inputs/outputs
if (!isGraphInputOutput(node) && (tag && !nodeHasTag(node, tag))) {
// Ignore tags on reroutes since they're just movable wires and it defeats
// the convenience gains to have to set tags for all them
// Also ignore graph inputs/outputs
if (!isReroute(node) && !isGraphInputOutput(node) && (tag && !nodeHasTag(node, tag, true))) {
console.debug("Skipping tagged node", tag, node.properties.tags, node)
return false;
}

View File

@@ -53,7 +53,7 @@ export default class ComfySetNodeModeAction extends ComfyGraphNode {
for (const node of this.graph._nodes) {
if ("tags" in node.properties) {
const comfyNode = node as ComfyGraphNode;
const hasTag = tags.some(t => nodeHasTag(comfyNode, t));
const hasTag = tags.some(t => nodeHasTag(comfyNode, t, false));
if (hasTag) {
let newMode: NodeMode;
if (enabled) {

View File

@@ -69,7 +69,7 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
for (const node of this.graph.iterateNodesInOrderRecursive()) {
if ("tags" in node.properties) {
const comfyNode = node as ComfyGraphNode;
const hasTag = nodeHasTag(comfyNode, action.tag);
const hasTag = nodeHasTag(comfyNode, action.tag, false);
if (hasTag) {
let newMode: NodeMode;