Skip to content

Commit 6afdb95

Browse files
authored
Fix: Vue-Litegraph conversion bug with Reroutes (#6330)
## Summary The private fields triggered an error in intitializing the linkLayoutSync. Turns out that wasn't necessary anymore. > [!NOTE] > Edit: Doing some more investigation, it looks like the slot sync can also be removed? ## Changes - **What**: Converts JS private fields to typescript private, adds some readonly declarations - **What**: Removes the useLinkLayoutSync usage in useVueNodeLifecycle - **What**: Removes the useSlotLayoutSync usage in useVueNodeLifecycle ## Review Focus Was the sync doing something that wouldn't be caught in normal usage/testing? ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6330-Fix-Vue-Litegraph-conversion-bug-with-Reroutes-2996d73d3650819ebb24e4aa2fc51c65) by [Unito](https://www.unito.io)
1 parent d1c9ce5 commit 6afdb95

File tree

9 files changed

+82
-637
lines changed

9 files changed

+82
-637
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.json text eol=lf
88
*.mjs text eol=lf
99
*.mts text eol=lf
10+
*.snap text eol=lf
1011
*.ts text eol=lf
1112
*.vue text eol=lf
1213
*.yaml text eol=lf

knip.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const config: KnipConfig = {
1414
},
1515
'apps/desktop-ui': {
1616
entry: ['src/main.ts', 'src/i18n.ts'],
17-
project: ['src/**/*.{js,ts,vue}', '*.{js,ts,mts}']
17+
project: ['src/**/*.{js,ts,vue}']
1818
},
1919
'packages/tailwind-utils': {
2020
project: ['src/**/*.{js,ts}']

src/composables/graph/useVueNodeLifecycle.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { shallowRef, watch } from 'vue'
44
import { useGraphNodeManager } from '@/composables/graph/useGraphNodeManager'
55
import type { GraphNodeManager } from '@/composables/graph/useGraphNodeManager'
66
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
7-
import type { LGraphCanvas, LGraphNode } from '@/lib/litegraph/src/litegraph'
7+
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
88
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
99
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
1010
import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
1111
import { useLayoutSync } from '@/renderer/core/layout/sync/useLayoutSync'
12-
import { useLinkLayoutSync } from '@/renderer/core/layout/sync/useLinkLayoutSync'
13-
import { useSlotLayoutSync } from '@/renderer/core/layout/sync/useSlotLayoutSync'
1412
import { app as comfyApp } from '@/scripts/app'
1513

1614
function useVueNodeLifecycleIndividual() {
@@ -21,8 +19,6 @@ function useVueNodeLifecycleIndividual() {
2119
const nodeManager = shallowRef<GraphNodeManager | null>(null)
2220

2321
const { startSync } = useLayoutSync()
24-
const linkSyncManager = useLinkLayoutSync()
25-
const slotSyncManager = useSlotLayoutSync()
2622

2723
const initializeNodeManager = () => {
2824
// Use canvas graph if available (handles subgraph contexts), fallback to app graph
@@ -62,10 +58,6 @@ function useVueNodeLifecycleIndividual() {
6258

6359
// Initialize layout sync (one-way: Layout Store → LiteGraph)
6460
startSync(canvasStore.canvas)
65-
66-
if (comfyApp.canvas) {
67-
linkSyncManager.start(comfyApp.canvas)
68-
}
6961
}
7062

7163
const disposeNodeManagerAndSyncs = () => {
@@ -77,8 +69,6 @@ function useVueNodeLifecycleIndividual() {
7769
/* empty */
7870
}
7971
nodeManager.value = null
80-
81-
linkSyncManager.stop()
8272
}
8373

8474
// Watch for Vue nodes enabled state changes
@@ -96,25 +86,14 @@ function useVueNodeLifecycleIndividual() {
9686

9787
// Consolidated watch for slot layout sync management
9888
watch(
99-
[() => canvasStore.canvas, () => shouldRenderVueNodes.value],
100-
([canvas, vueMode], [, oldVueMode]) => {
89+
() => shouldRenderVueNodes.value,
90+
(vueMode, oldVueMode) => {
10191
const modeChanged = vueMode !== oldVueMode
10292

10393
// Clear stale slot layouts when switching modes
10494
if (modeChanged) {
10595
layoutStore.clearAllSlotLayouts()
10696
}
107-
108-
// Switching to Vue
109-
if (vueMode) {
110-
slotSyncManager.stop()
111-
}
112-
113-
// Switching to LG
114-
const shouldRun = Boolean(canvas?.graph) && !vueMode
115-
if (shouldRun && canvas) {
116-
slotSyncManager.attemptStart(canvas as LGraphCanvas)
117-
}
11897
},
11998
{ immediate: true, flush: 'sync' }
12099
)
@@ -152,8 +131,6 @@ function useVueNodeLifecycleIndividual() {
152131
nodeManager.value.cleanup()
153132
nodeManager.value = null
154133
}
155-
slotSyncManager.stop()
156-
linkSyncManager.stop()
157134
}
158135

159136
return {

src/lib/litegraph/src/LGraph.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,15 @@ export class LGraph
223223
/** Internal only. Not required for serialisation; calculated on deserialise. */
224224
#lastFloatingLinkId: number = 0
225225

226-
#floatingLinks: Map<LinkId, LLink> = new Map()
226+
private readonly floatingLinksInternal: Map<LinkId, LLink> = new Map()
227227
get floatingLinks(): ReadonlyMap<LinkId, LLink> {
228-
return this.#floatingLinks
228+
return this.floatingLinksInternal
229229
}
230230

231-
#reroutes = new Map<RerouteId, Reroute>()
231+
private readonly reroutesInternal = new Map<RerouteId, Reroute>()
232232
/** All reroutes in this graph. */
233233
public get reroutes(): Map<RerouteId, Reroute> {
234-
return this.#reroutes
234+
return this.reroutesInternal
235235
}
236236

237237
get rootGraph(): LGraph {
@@ -340,7 +340,7 @@ export class LGraph
340340

341341
this._links.clear()
342342
this.reroutes.clear()
343-
this.#floatingLinks.clear()
343+
this.floatingLinksInternal.clear()
344344

345345
this.#lastFloatingLinkId = 0
346346

@@ -1268,7 +1268,7 @@ export class LGraph
12681268
if (link.id === -1) {
12691269
link.id = ++this.#lastFloatingLinkId
12701270
}
1271-
this.#floatingLinks.set(link.id, link)
1271+
this.floatingLinksInternal.set(link.id, link)
12721272

12731273
const slot =
12741274
link.target_id !== -1
@@ -1291,7 +1291,7 @@ export class LGraph
12911291
}
12921292

12931293
removeFloatingLink(link: LLink): void {
1294-
this.#floatingLinks.delete(link.id)
1294+
this.floatingLinksInternal.delete(link.id)
12951295

12961296
const slot =
12971297
link.target_id !== -1

0 commit comments

Comments
 (0)