From 2d3de22150cac4ba35bfba16f9b157b9d93b572f Mon Sep 17 00:00:00 2001 From: Comfy Org PR Bot Date: Sun, 15 Mar 2026 04:17:48 +0900 Subject: [PATCH] [backport core/1.41] fix: clear stale widget slotMetadata on link disconnect (#9919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of #9885 to `core/1.41` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9919-backport-core-1-41-fix-clear-stale-widget-slotMetadata-on-link-disconnect-3236d73d365081028353cbabd935e7a0) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne --- .../graph/useGraphNodeManager.test.ts | 26 +++++++++++++++++++ src/composables/graph/useGraphNodeManager.ts | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/composables/graph/useGraphNodeManager.test.ts b/src/composables/graph/useGraphNodeManager.test.ts index 39a25b2352..d441a9c529 100644 --- a/src/composables/graph/useGraphNodeManager.test.ts +++ b/src/composables/graph/useGraphNodeManager.test.ts @@ -238,6 +238,32 @@ describe('Widget slotMetadata reactivity on link disconnect', () => { expect(widgetData?.slotMetadata?.linked).toBe(false) }) + + it('clears stale slotMetadata when input no longer matches widget', async () => { + const { graph, node } = createWidgetInputGraph() + const { vueNodeData } = useGraphNodeManager(graph) + + const nodeData = vueNodeData.get(String(node.id))! + const widgetData = nodeData.widgets!.find((w) => w.name === 'prompt')! + + expect(widgetData.slotMetadata?.linked).toBe(true) + + node.inputs[0].name = 'other' + node.inputs[0].widget = { name: 'other' } + node.inputs[0].link = null + + graph.trigger('node:slot-links:changed', { + nodeId: node.id, + slotType: NodeSlotType.INPUT, + slotIndex: 0, + connected: false, + linkId: 42 + }) + + await nextTick() + + expect(widgetData.slotMetadata).toBeUndefined() + }) }) describe('Subgraph Promoted Pseudo Widgets', () => { diff --git a/src/composables/graph/useGraphNodeManager.ts b/src/composables/graph/useGraphNodeManager.ts index a5b346790f..f366c41dc3 100644 --- a/src/composables/graph/useGraphNodeManager.ts +++ b/src/composables/graph/useGraphNodeManager.ts @@ -467,8 +467,7 @@ export function useGraphNodeManager(graph: LGraph): GraphNodeManager { // Update only widgets with new slot metadata, keeping other widget data intact for (const widget of currentData.widgets ?? []) { - const slotInfo = slotMetadata.get(widget.slotName ?? widget.name) - if (slotInfo) widget.slotMetadata = slotInfo + widget.slotMetadata = slotMetadata.get(widget.slotName ?? widget.name) } }