diff --git a/src/core/graph/widgets/dynamicGroupWidget.test.ts b/src/core/graph/widgets/dynamicGroupWidget.test.ts index 7a0fd1417da..fec0992e797 100644 --- a/src/core/graph/widgets/dynamicGroupWidget.test.ts +++ b/src/core/graph/widgets/dynamicGroupWidget.test.ts @@ -379,7 +379,7 @@ describe('DynamicGroup widgets', () => { ).toBe(true) const outerInput = outerHost.inputs[0] expect(promotedInputWidget(outerInput)?.label).toBe('LoRA #2 strength') - return { widget, innerHost, outerHost, outerSubgraph, outerInput } + return { node, widget, innerHost, outerHost, outerSubgraph, outerInput } } it.for([ @@ -472,6 +472,78 @@ describe('DynamicGroup widgets', () => { await vi.waitFor(() => expect(promotedInputWidget(outerInput)).toBeNull()) }) + it('disconnects the deleted row at the outer host while keeping the next row connected', async () => { + const { node, widget, innerHost, outerHost, outerInput } = + setupTwiceDeepPromotion() + const graph = innerHost.subgraph.rootGraph + widget('loras').value = 3 + widget('loras.2.lora_name').value = 'C' + widget('loras.2.strength').value = 0.37 + expect( + promoteValueWidgetViaSubgraphInput( + innerHost, + node, + widget('loras.2.strength') + ).ok + ).toBe(true) + const innerPromoted = promotedInputWidget(innerHost.inputs[1]) + assert.exists(innerPromoted) + expect( + promoteValueWidgetViaSubgraphInput(outerHost, innerHost, innerPromoted).ok + ).toBe(true) + const survivingInput = outerHost.inputs[1] + const otherHost = createTestSubgraphNode(outerHost.subgraph) + graph.add(otherHost) + const source = new LGraphNode('Strength source') + source.addOutput('strength', 'FLOAT') + graph.add(source) + const removed = source.connect(0, outerHost, 0) + const otherRemoved = source.connect(0, otherHost, 0) + const retained = source.connect(0, outerHost, 1) + assert.exists(removed) + assert.exists(otherRemoved) + assert.exists(retained) + + widget('loras.1').callback?.(undefined) + + await vi.waitFor(() => expect(promotedInputWidget(outerInput)).toBeNull()) + expect(graph.getLink(removed.id)).toBeUndefined() + expect(graph.getLink(otherRemoved.id)).toBeUndefined() + expect(outerInput.link).toBeNull() + expect(otherHost.inputs[0].link).toBeNull() + assert.exists(survivingInput.link) + expect(graph.getLink(survivingInput.link)).toBe(retained) + expect(promotedInputWidget(survivingInput)?.value).toBe(0.37) + expect(promotedInputWidget(survivingInput)?.label).toBe('LoRA #2 strength') + expect(widget('loras.1.lora_name').value).toBe('C') + expect(widget('loras.1.strength').value).toBe(0.37) + }) + + it('keeps the outer connection when another node still consumes the promoted input', () => { + const { widget, innerHost, outerHost, outerInput } = + setupTwiceDeepPromotion() + const graph = innerHost.subgraph.rootGraph + const other = new LGraphNode('Another strength consumer') + const input = other.addInput('strength', 'FLOAT') + innerHost.subgraph.add(other) + const internal = innerHost.subgraph.inputNode.slots[0].connect(input, other) + const source = new LGraphNode('Strength source') + source.addOutput('strength', 'FLOAT') + graph.add(source) + const external = source.connect(0, outerHost, 0) + assert.exists(internal) + assert.exists(external) + + widget('loras.1').callback?.(undefined) + + assert.exists(outerInput.link) + assert.exists(input.link) + expect(graph.getLink(outerInput.link)).toBe(external) + expect(innerHost.subgraph.getLink(input.link)).toBe(internal) + expect(innerHost.subgraph.inputs[0].linkIds).toEqual([internal.id]) + expect(widget('loras').value).toBe(1) + }) + it.for([ { label: 'LoRA #2 strength', expected: 'LoRA 1행 strength' }, { label: 'My strength', expected: 'My strength' } diff --git a/src/core/graph/widgets/dynamicGroupWidget.ts b/src/core/graph/widgets/dynamicGroupWidget.ts index afe7ab3a221..46a34295646 100644 --- a/src/core/graph/widgets/dynamicGroupWidget.ts +++ b/src/core/graph/widgets/dynamicGroupWidget.ts @@ -418,9 +418,10 @@ function disconnectOrphanedPromotion( if (!isSubgraph(graph) || graph.inputs[slot]?.linkIds.length) return for (const host of hosts(graph)) { const link = host.graph && inputLink(host.graph, host.id, slot) - if (link?.origin_id !== SUBGRAPH_INPUT_ID) continue + if (!link) continue host.disconnectInput(slot) - disconnectOrphanedPromotion(host.graph, link.origin_slot, hosts) + if (link.origin_id === SUBGRAPH_INPUT_ID) + disconnectOrphanedPromotion(host.graph, link.origin_slot, hosts) } }