Skip to content

Commit a1eac3a

Browse files
[fix] Prevent incorrect 'frontend_only' badges in subgraphs (#4571)
1 parent 562ddf0 commit a1eac3a

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

src/scripts/app.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -855,26 +855,33 @@ export class ComfyApp {
855855
private updateVueAppNodeDefs(defs: Record<string, ComfyNodeDefV1>) {
856856
// Frontend only nodes registered by custom nodes.
857857
// Example: https://github.com/rgthree/rgthree-comfy/blob/dd534e5384be8cf0c0fa35865afe2126ba75ac55/src_web/comfyui/fast_groups_bypasser.ts#L10
858-
const rawDefs: Record<string, ComfyNodeDefV1> = Object.fromEntries(
859-
Object.entries(LiteGraph.registered_node_types).map(([name, node]) => [
858+
859+
// Only create frontend_only definitions for nodes that don't have backend definitions
860+
const frontendOnlyDefs: Record<string, ComfyNodeDefV1> = {}
861+
for (const [name, node] of Object.entries(
862+
LiteGraph.registered_node_types
863+
)) {
864+
// Skip if we already have a backend definition or system definition
865+
if (name in defs || name in SYSTEM_NODE_DEFS) {
866+
continue
867+
}
868+
869+
frontendOnlyDefs[name] = {
860870
name,
861-
{
862-
name,
863-
display_name: name,
864-
category: node.category || '__frontend_only__',
865-
input: { required: {}, optional: {} },
866-
output: [],
867-
output_name: [],
868-
output_is_list: [],
869-
output_node: false,
870-
python_module: 'custom_nodes.frontend_only',
871-
description: `Frontend only node for ${name}`
872-
} as ComfyNodeDefV1
873-
])
874-
)
871+
display_name: name,
872+
category: node.category || '__frontend_only__',
873+
input: { required: {}, optional: {} },
874+
output: [],
875+
output_name: [],
876+
output_is_list: [],
877+
output_node: false,
878+
python_module: 'custom_nodes.frontend_only',
879+
description: `Frontend only node for ${name}`
880+
} as ComfyNodeDefV1
881+
}
875882

876883
const allNodeDefs = {
877-
...rawDefs,
884+
...frontendOnlyDefs,
878885
...defs,
879886
...SYSTEM_NODE_DEFS
880887
}

src/stores/nodeDefStore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ export const useNodeDefStore = defineStore('nodeDef', () => {
334334
}
335335
function fromLGraphNode(node: LGraphNode): ComfyNodeDefImpl | null {
336336
// Frontend-only nodes don't have nodeDef
337-
// @ts-expect-error Optional chaining used in index
338-
return nodeDefsByName.value[node.constructor?.nodeData?.name] ?? null
337+
const nodeTypeName = node.constructor?.nodeData?.name
338+
if (!nodeTypeName) return null
339+
const nodeDef = nodeDefsByName.value[nodeTypeName] ?? null
340+
return nodeDef
339341
}
340342

341343
/**

0 commit comments

Comments
 (0)