fix: node deletion handling in vue nodes when switching from litegrap… (#5909)

## Summary

Fix node deletion when switching from litegraph -> vue node mode. 

## Background:
 
There is a race condition where we have [2 watch() functions that are
both tracking
shouldRenderVueNodes.value](f58365b20b/src/composables/graph/useVueNodeLifecycle.ts (L85)):
  - For vue node lifecycle
  - For slot/link sync lifecycle

Each watch() separately sets graph.onNodeRemoved to its own cleanup
handler. But without flush: 'sync', the slot sync watch runs AFTER vue
nodes and overwrites the callback. So when deletion happens,
graph.onNodeRemoved points to the slot handler (or undefined) instead of
the vue cleanup handler, and the vue node never gets removed from the
DOM.

## Review Focus
We are making use of the watch() option "fush: sync" in the link and
slot watch() so maybe there is side effects from firing this when
dependencies change synchronously.

## Screenshots (if applicable)


https://github.com/user-attachments/assets/6951fa50-61d5-4c63-88e9-e113f603ff77


┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5909-fix-node-deletion-handling-in-vue-nodes-when-switching-from-litegrap-2826d73d365081bdba35c3d8728d6251)
by [Unito](https://www.unito.io)

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Simula_r
2025-10-06 23:51:20 -07:00
committed by GitHub
parent 338cbd4eed
commit 893621265c
3 changed files with 1 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

@@ -116,7 +116,7 @@ function useVueNodeLifecycleIndividual() {
slotSyncManager.attemptStart(canvas as LGraphCanvas)
}
},
{ immediate: true }
{ immediate: true, flush: 'sync' }
)
// Handle case where Vue nodes are enabled but graph starts empty