Fix widget bugs for subgraph node connected to BV Control Center widget
This commit is contained in:
@@ -243,6 +243,7 @@ Here is an example if, for example, Only Preview is active
|
||||
|
||||
|
||||
### CHANGE LOG
|
||||
* 2026-01-01 - v0.0.15: Fix renaming bug for subgraph node connected to `BV Control Center` widget.
|
||||
* 2026-01-01 - v0.0.14: Fix widget bugs for subgraph node connected to `BV Control Center` widget.
|
||||
* 2025-12-31 - v0.0.13: Fix inverting error for label from `BV Control Center` widget.
|
||||
* 2025-12-31 - v0.0.12: Fix input error by node `BV Control Center`.
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "bv_nodepack"
|
||||
version = "0.0.14"
|
||||
version = "0.0.15"
|
||||
description = "A ComfyUI node pack providing advanced utility and workflow nodes, including a config-driven Control Center for muting and bypassing node groups, a flexible Pipe system, and Subgraph-friendly UI nodes (Heading, Spacer, Divider) with dynamic JavaScript rendering."
|
||||
authors = [
|
||||
{name = "BlackVortex", email = "blackvortexx@proton.me"}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {getApp} from "../../appHelper.js";
|
||||
import {BVControlConfig, BVControlEntry, readConfig} from "../../util/control/configHandler";
|
||||
import {IBaseWidget, LGraphNode, SubgraphNode} from "../../types/comfyui-frontend-types.augment";
|
||||
import {IBaseWidget, LGraphNode, Subgraph, SubgraphNode} from "../../types/comfyui-frontend-types.augment";
|
||||
import {
|
||||
bypassGroupsByTitle,
|
||||
muteGroupsByTitle,
|
||||
@@ -14,8 +14,7 @@ import {
|
||||
showErrorToast
|
||||
} from "../../util/control/controlHelper";
|
||||
import {
|
||||
ensureSubgraphContainerPatchedFromInnerNodeRetry,
|
||||
findAllSubgraphContainers, getOuterNode,
|
||||
ensureSubgraphContainerPatchedFromInnerNodeRetry, findAllSubgraphContainers, getOuterNode,
|
||||
patchSubgraphContainerPrototype,
|
||||
renameSubGraphInputSlot
|
||||
} from "../../util/control/subgraphHandler";
|
||||
@@ -180,11 +179,38 @@ function updateSingleControlNode(node: any, config: BVControlConfig, savedValues
|
||||
// @ts-ignore
|
||||
node.inputs[i]._widget = w;
|
||||
}
|
||||
|
||||
|
||||
const ccNode = getNodeHelper(node.id, node.graph)
|
||||
if(ccNode){
|
||||
const ccInput = ccNode.inputs[i]
|
||||
const ccLink = ccNode.getInputLink(i)
|
||||
if(ccLink && ccNode.graph){
|
||||
setTimeout(() => {
|
||||
const graphNode = getOuterNode(ccNode)
|
||||
if(graphNode) {
|
||||
const graphWidgets = graphNode.widgets
|
||||
if(graphWidgets){
|
||||
const graphWidget = graphWidgets[ccLink.origin_slot]
|
||||
if(graphWidget){
|
||||
graphWidget.label = label
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}, 50)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const gNode = getNodeHelper(node.id, node.graph)
|
||||
|
||||
if (gNode) {
|
||||
let success = false
|
||||
success = renameSubGraphInputSlot(node, i, label)
|
||||
|
||||
success = renameSubGraphInputSlot(node, i, label)
|
||||
|
||||
if (!success) {
|
||||
allSlotsRenamed = false;
|
||||
@@ -539,6 +565,7 @@ function patchAllSubgraphs(): number {
|
||||
|
||||
let patched = 0;
|
||||
for (const s of subs) {
|
||||
console.log("patching", s.title)
|
||||
const didPatch = patchSubgraphContainerPrototype(s, hookSubgraphWidgetChanged, executeChange);
|
||||
if (didPatch) patched++;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getApp } from "../../appHelper.js";
|
||||
import {
|
||||
ExposedWidget,
|
||||
ExposedWidget, IBaseWidget,
|
||||
LGraphNode,
|
||||
Subgraph,
|
||||
SubgraphInput,
|
||||
@@ -63,6 +63,27 @@ export function findAllSubgraphContainers(graph: any): any[] {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getInnerNodeFromOuterNode(
|
||||
outerNode: LGraphNode,
|
||||
match?: ((n: LGraphNode) => boolean) | string
|
||||
): LGraphNode | undefined {
|
||||
if (!outerNode?.isSubgraphNode?.()) return undefined;
|
||||
|
||||
const innerGraph: any = (outerNode as any).subgraph;
|
||||
if (!innerGraph) return undefined;
|
||||
|
||||
const nodes: LGraphNode[] = innerGraph._nodes ?? innerGraph.nodes ?? [];
|
||||
|
||||
const predicate =
|
||||
typeof match === "function"
|
||||
? match
|
||||
: typeof match === "string"
|
||||
? (n: any) => n?.type === match || n?.comfyClass === match || n?.title === match
|
||||
: () => true; // first node (fallback)
|
||||
|
||||
return nodes.find(predicate);
|
||||
}
|
||||
|
||||
export function getOuterNode(innerNode: LGraphNode) {
|
||||
if (innerNode.graph?.subgraphs) {
|
||||
const subgraph = innerNode.graph as Subgraph;
|
||||
@@ -116,10 +137,19 @@ export function patchSubgraphContainerPrototype(subgraphNode: any, hookSubgraphW
|
||||
|
||||
const graph = getApp()?.rootGraph;
|
||||
const node = getNodeHelper(this.id, graph, true) as SubgraphNode
|
||||
if (node) {
|
||||
|
||||
const sWidget = widget as IBaseWidget
|
||||
const iNode = getInnerNodeFromOuterNode(node, "BV Control Center")
|
||||
if (node && iNode) {
|
||||
console.debug("Subgraph container widget changed", name, value, old_value, widget, node, widget.label)
|
||||
// hookSubgraphWidgetChanged(node, name)
|
||||
widget.label = widget.label.split(" - ")[0] + " - " + (value ? ACTIVE : MUTE)
|
||||
|
||||
iNode.widgets?.forEach((w) => {
|
||||
if(w.name == sWidget.name){
|
||||
w.label = widget.label
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (widget?.label) {
|
||||
|
||||
Reference in New Issue
Block a user