Skip to content

Commit 8c40f83

Browse files
authored
Properly update vue app's node defs on refresh (#493)
1 parent 5ba524f commit 8c40f83

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

src/scripts/app.ts

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,37 @@ export class ComfyApp {
19551955
this.canvas?.draw(true, true)
19561956
}
19571957

1958+
updateVueAppNodeDefs(defs: Record<string, ComfyNodeDef>) {
1959+
// Frontend only nodes registered by custom nodes.
1960+
// Example: https://github.com/rgthree/rgthree-comfy/blob/dd534e5384be8cf0c0fa35865afe2126ba75ac55/src_web/comfyui/fast_groups_bypasser.ts#L10
1961+
const rawDefs = Object.fromEntries(
1962+
Object.entries(LiteGraph.registered_node_types).map(([name, _]) => [
1963+
name,
1964+
{
1965+
name,
1966+
display_name: name,
1967+
category: '__frontend_only__',
1968+
input: { required: {}, optional: {} },
1969+
output: [],
1970+
output_name: [],
1971+
output_is_list: [],
1972+
python_module: 'custom_nodes.frontend_only',
1973+
description: `Frontend only node for ${name}`
1974+
}
1975+
])
1976+
)
1977+
1978+
const allNodeDefs = {
1979+
...rawDefs,
1980+
...defs,
1981+
...SYSTEM_NODE_DEFS
1982+
}
1983+
1984+
const nodeDefStore = useNodeDefStore()
1985+
nodeDefStore.updateNodeDefs(Object.values(allNodeDefs))
1986+
nodeDefStore.updateWidgets(this.widgets)
1987+
}
1988+
19581989
/**
19591990
* Registers nodes with the graph
19601991
*/
@@ -1964,34 +1995,7 @@ export class ComfyApp {
19641995
await this.registerNodesFromDefs(defs)
19651996
await this.#invokeExtensionsAsync('registerCustomNodes')
19661997
if (this.vueAppReady) {
1967-
// Frontend only nodes registered by custom nodes.
1968-
// Example: https://github.com/rgthree/rgthree-comfy/blob/dd534e5384be8cf0c0fa35865afe2126ba75ac55/src_web/comfyui/fast_groups_bypasser.ts#L10
1969-
const rawDefs = Object.fromEntries(
1970-
Object.entries(LiteGraph.registered_node_types).map(([name, _]) => [
1971-
name,
1972-
{
1973-
name,
1974-
display_name: name,
1975-
category: '__frontend_only__',
1976-
input: { required: {}, optional: {} },
1977-
output: [],
1978-
output_name: [],
1979-
output_is_list: [],
1980-
python_module: 'custom_nodes.frontend_only',
1981-
description: `Frontend only node for ${name}`
1982-
}
1983-
])
1984-
)
1985-
1986-
const allNodeDefs = {
1987-
...rawDefs,
1988-
...defs,
1989-
...SYSTEM_NODE_DEFS
1990-
}
1991-
1992-
const nodeDefStore = useNodeDefStore()
1993-
nodeDefStore.updateNodeDefs(Object.values(allNodeDefs))
1994-
nodeDefStore.updateWidgets(this.widgets)
1998+
this.updateVueAppNodeDefs(defs)
19951999
}
19962000
}
19972001

@@ -2899,6 +2903,7 @@ export class ComfyApp {
28992903
await this.#invokeExtensionsAsync('refreshComboInNodes', defs)
29002904

29012905
if (this.vueAppReady) {
2906+
this.updateVueAppNodeDefs(defs)
29022907
useToastStore().remove(requestToastMessage)
29032908
useToastStore().add({
29042909
severity: 'success',

0 commit comments

Comments
 (0)