Skip to content
13 changes: 12 additions & 1 deletion src/components/rightSidePanel/parameters/SectionWidgets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ function isWidgetShownOnParents(
})
}

function getWidgetRenderKey(
widgetNode: LGraphNode,
widget: IBaseWidget
): string {
if (isPromotedWidgetView(widget)) {
return `${String(widgetNode.id)}:${widget.sourceNodeId}:${widget.sourceWidgetName}:${widget.name}:${widget.type}`
}

return `${String(widgetNode.id)}:${widget.name}:${widget.type}`
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

const isEmpty = computed(() => widgets.value.length === 0)

const displayLabel = computed(
Expand Down Expand Up @@ -272,7 +283,7 @@ defineExpose({
<TransitionGroup name="list-scale">
<WidgetItem
v-for="{ widget, node } in widgets"
:key="`${node.id}-${widget.name}-${widget.type}`"
:key="getWidgetRenderKey(node, widget)"
:widget="widget"
:node="node"
:is-draggable="isDraggable"
Expand Down
50 changes: 50 additions & 0 deletions src/composables/graph/useGraphNodeManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,56 @@ describe('Nested promoted widget mapping', () => {
`${subgraphNodeB.subgraph.id}:${innerNode.id}`
)
})

it('keeps linked and independent same-name promotions as distinct sources', () => {
const subgraph = createTestSubgraph({
inputs: [{ name: 'string_a', type: '*' }]
})

const linkedNode = new LGraphNode('LinkedNode')
const linkedInput = linkedNode.addInput('string_a', '*')
linkedNode.addWidget('text', 'string_a', 'linked', () => undefined, {})
linkedInput.widget = { name: 'string_a' }
subgraph.add(linkedNode)
subgraph.inputNode.slots[0].connect(linkedInput, linkedNode)

const independentNode = new LGraphNode('IndependentNode')
independentNode.addWidget(
'text',
'string_a',
'independent',
() => undefined,
{}
)
subgraph.add(independentNode)

const subgraphNode = createTestSubgraphNode(subgraph, { id: 109 })
const graph = subgraphNode.graph as LGraph
graph.add(subgraphNode)

usePromotionStore().promote(
subgraphNode.rootGraph.id,
subgraphNode.id,
String(independentNode.id),
'string_a'
)

const { vueNodeData } = useGraphNodeManager(graph)
const nodeData = vueNodeData.get(String(subgraphNode.id))
const promotedWidgets = nodeData?.widgets?.filter(
(widget) => widget.name === 'string_a'
)

expect(promotedWidgets).toHaveLength(2)
expect(
new Set(promotedWidgets?.map((widget) => widget.storeNodeId))
).toEqual(
new Set([
`${subgraph.id}:${linkedNode.id}`,
`${subgraph.id}:${independentNode.id}`
])
)
})
})

describe('Promoted widget sourceExecutionId', () => {
Expand Down
19 changes: 13 additions & 6 deletions src/composables/graph/useGraphNodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,23 @@ function safeWidgetMapper(
}
}

const promotedInputName = node.inputs?.find((input) => {
const matchedInput = node.inputs?.find((input) => {
if (input.name === widget.name) return true
if (input._widget === widget) return true
return false
})?.name
})
const promotedInputName = matchedInput?.name
const displayName = promotedInputName ?? widget.name
const promotedSource = resolvePromotedSourceByInputName(displayName) ?? {
sourceNodeId: widget.sourceNodeId,
sourceWidgetName: widget.sourceWidgetName
}
const promotedSource =
matchedInput?._widget === widget
? (resolvePromotedSourceByInputName(displayName) ?? {
sourceNodeId: widget.sourceNodeId,
sourceWidgetName: widget.sourceWidgetName
})
: {
sourceNodeId: widget.sourceNodeId,
sourceWidgetName: widget.sourceWidgetName
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

return {
displayName,
Expand Down
Loading
Loading