From 70aaf538f7f528d70db7e4d4c720de613bf5e53c Mon Sep 17 00:00:00 2001 From: BlackVortexAI Date: Sun, 21 Dec 2025 11:25:19 +0100 Subject: [PATCH] fix: correctly resolve BV Pipe Config through direct-mapped subgraphs --- js/bv_pipe_shared.js | 44 ++++++++++++++++++++++++++++++++++++-------- pyproject.toml | 4 ++-- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/js/bv_pipe_shared.js b/js/bv_pipe_shared.js index afd2b45..c134acd 100644 --- a/js/bv_pipe_shared.js +++ b/js/bv_pipe_shared.js @@ -358,6 +358,27 @@ function jumpFromParentToSubgraphOutputOrigin(parentNode, parentSlotIndex) { return null; } +function fallbackDirectMappedCfgFromInnerGraph(parentNode) { + const innerGraph = getInnerGraphFromNode(parentNode); + if (!innerGraph) return null; + + const nodes = getAllNodes(innerGraph); + + // Your observed case: subgraph contains ONLY the BV Pipe Config node + if (nodes.length === 1 && nodes[0]?.comfyClass === "BV Pipe Config") { + return { node: nodes[0], graph: innerGraph }; + } + + // Slightly more permissive fallback: if there is exactly one config node inside, use it + const cfgNodes = nodes.filter(n => n?.comfyClass === "BV Pipe Config"); + if (cfgNodes.length === 1) { + return { node: cfgNodes[0], graph: innerGraph }; + } + + return null; +} + + // ---------- config resolution ---------- export function resolveCfgByPipeLinksNoCache(node, visited = new Set()) { @@ -384,17 +405,24 @@ export function resolveCfgByPipeLinksNoCache(node, visited = new Set()) { } if (up.originNode) { - // If originNode is a Subgraph, jump into it to find the source of the config - const inner = getInnerGraphFromNode(up.originNode); - if (inner) { - const jumped = jumpFromParentToSubgraphOutputOrigin(up.originNode, up.originSlot); - if (jumped) { - return resolveCfgByPipeLinksNoCache(jumped.node, visited); - } + // If originNode is a Subgraph/container, jump into it to find the source of the config + const inner = getInnerGraphFromNode(up.originNode); + if (inner) { + const jumped = jumpFromParentToSubgraphOutputOrigin(up.originNode, up.originSlot); + if (jumped) { + return resolveCfgByPipeLinksNoCache(jumped.node, visited); + } + + // ✅ Fallback for "direct mapped" subgraphs (like your 1-node BV Pipe Config subgraph) + const direct = fallbackDirectMappedCfgFromInnerGraph(up.originNode); + if (direct) { + return resolveCfgByPipeLinksNoCache(direct.node, visited); } - return resolveCfgByPipeLinksNoCache(up.originNode, visited); } + return resolveCfgByPipeLinksNoCache(up.originNode, visited); +} + // subgraph graph-input case (origin_id negative -> no originNode) const jumped = jumpFromSubgraphGraphInputToParentOrigin(up.graph, up.originSlot); if (!jumped) { diff --git a/pyproject.toml b/pyproject.toml index c5ee2c4..ae0550c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "bv_nodepack" -version = "0.0.4" -description = "Collection of supply nodes (pipes, etc.) for better workflow management." +version = "0.0.5" +description = "A ComfyUI node pack providing a growing set of utility and workflow nodes, including a flexible config-driven Pipe system." authors = [ {name = "BlackVortex", email = "blackvortexx@proton.me"} ]