Fixes for tag scoping
This commit is contained in:
@@ -968,7 +968,7 @@ export default class ComfyApp {
|
|||||||
|
|
||||||
const thumbnails = []
|
const thumbnails = []
|
||||||
for (const node of workflow.graph.iterateNodesInOrderRecursive()) {
|
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;
|
continue;
|
||||||
|
|
||||||
if ("getPromptThumbnails" in node) {
|
if ("getPromptThumbnails" in node) {
|
||||||
|
|||||||
@@ -15,18 +15,17 @@ function isGraphInputOutput(node: LGraphNode): boolean {
|
|||||||
return node.is(GraphInput) || node.is(GraphOutput)
|
return node.is(GraphInput) || node.is(GraphOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function nodeHasTag(node: LGraphNode, tag: string): boolean {
|
export function nodeHasTag(node: LGraphNode, tag: string, checkParents: boolean): 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;
|
|
||||||
|
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if ("tags" in node.properties) {
|
if ("tags" in node.properties) {
|
||||||
if (node.properties.tags.indexOf(tag) !== -1)
|
if (node.properties.tags.indexOf(tag) !== -1)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkParents) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Count parent subgraphs having the tag also.
|
// Count parent subgraphs having the tag also.
|
||||||
node = node.graph?._subgraph_node;
|
node = node.graph?._subgraph_node;
|
||||||
}
|
}
|
||||||
@@ -38,8 +37,10 @@ export function isActiveNode(node: LGraphNode, tag: string | null = null): boole
|
|||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check tags but not on graph inputs/outputs
|
// Ignore tags on reroutes since they're just movable wires and it defeats
|
||||||
if (!isGraphInputOutput(node) && (tag && !nodeHasTag(node, tag))) {
|
// 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)
|
console.debug("Skipping tagged node", tag, node.properties.tags, node)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default class ComfySetNodeModeAction extends ComfyGraphNode {
|
|||||||
for (const node of this.graph._nodes) {
|
for (const node of this.graph._nodes) {
|
||||||
if ("tags" in node.properties) {
|
if ("tags" in node.properties) {
|
||||||
const comfyNode = node as ComfyGraphNode;
|
const comfyNode = node as ComfyGraphNode;
|
||||||
const hasTag = tags.some(t => nodeHasTag(comfyNode, t));
|
const hasTag = tags.some(t => nodeHasTag(comfyNode, t, false));
|
||||||
if (hasTag) {
|
if (hasTag) {
|
||||||
let newMode: NodeMode;
|
let newMode: NodeMode;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
|
|||||||
for (const node of this.graph.iterateNodesInOrderRecursive()) {
|
for (const node of this.graph.iterateNodesInOrderRecursive()) {
|
||||||
if ("tags" in node.properties) {
|
if ("tags" in node.properties) {
|
||||||
const comfyNode = node as ComfyGraphNode;
|
const comfyNode = node as ComfyGraphNode;
|
||||||
const hasTag = nodeHasTag(comfyNode, action.tag);
|
const hasTag = nodeHasTag(comfyNode, action.tag, false);
|
||||||
|
|
||||||
if (hasTag) {
|
if (hasTag) {
|
||||||
let newMode: NodeMode;
|
let newMode: NodeMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user