mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 19:51:54 +00:00
## Summary Fix subgraph promoted widget identity/rendering so on-node widgets stay correct through configure/hydration churn, duplicate names, and linked+independent coexistence. ## Changes - **Subgraph promotion reconciliation**: stabilize linked-entry identity by subgraph slot id, preserve deterministic linked representative selection, and prune stale alias/fallback entries without dropping legitimate independent promotions. - **Promoted view resolution**: bind slot mapping by promoted view object identity (`getSlotFromWidget` / `getWidgetFromSlot`) to avoid same-name collisions. - **On-node widget rendering**: harden `NodeWidgets` identity and dedup to avoid visual aliasing, prefer visible duplicates over hidden stale entries, include type/source execution identity, and avoid collapsing transient unresolved entries. - **Mapping correctness**: update `useGraphNodeManager` promoted source mapping to resolve by input target only when the promoted view is actually bound to that input. - **Subgraph input uniqueness**: ensure empty-slot promotion creates unique input names (`seed`, `seed_1`, etc.) for same-name multi-source promotions. - **Safety fix**: guard against undefined canvas in slot-link interaction. - **Tests/fixtures**: add focused regressions for fixture path `subgraph_complex_promotion_1`, linked+independent same-name cases, duplicate-name identity mapping, dedup behavior, and input-name uniqueness. ## Review Focus Validate behavior around transient configure/hydration states (`-1` id to concrete id), duplicate-name promotions, linked representative recovery, and that dedup never hides legitimate widgets while still removing true duplicates. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9896-fix-stabilize-subgraph-promoted-widget-identity-and-rendering-3226d73d365081c8a1e8d0a5a22e826d) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
30 lines
951 B
TypeScript
30 lines
951 B
TypeScript
import type { ISlotType } from './litegraph'
|
|
|
|
export function parseSlotTypes(type: ISlotType): string[] {
|
|
return type == '' || type == '0'
|
|
? ['*']
|
|
: String(type).toLowerCase().split(',')
|
|
}
|
|
|
|
/**
|
|
* Creates a unique name by appending an underscore and a number to the end of the name
|
|
* if it already exists.
|
|
* @param name The name to make unique
|
|
* @param existingNames The names that already exist. Default: an empty array
|
|
* @returns The name, or a unique name if it already exists.
|
|
* @remark Used by SubgraphInputNode to deduplicate input names when promoting
|
|
* the same widget name from multiple node instances (e.g. `seed` → `seed_1`).
|
|
* Extensions matching by slot name should account for the `_N` suffix.
|
|
*/
|
|
export function nextUniqueName(
|
|
name: string,
|
|
existingNames: string[] = []
|
|
): string {
|
|
let i = 1
|
|
const baseName = name
|
|
while (existingNames.includes(name)) {
|
|
name = `${baseName}_${i++}`
|
|
}
|
|
return name
|
|
}
|