mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
Backport of #9896 to `cloud/1.41`. Conflict resolution notes: - Resolved expected conflicts in `useGraphNodeManager.test.ts`, `SubgraphNode.ts`, and `NodeWidgets.vue`. - Kept core promoted-widget identity/rendering fixes from #9896. - Dropped missing-model/source-execution specific test/runtime additions not available on `cloud/1.41` APIs. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9929-backport-cloud-1-41-fix-stabilize-subgraph-promoted-widget-identity-and-rendering-3236d73d36508189b968de3cdc6c2c48) by [Unito](https://www.unito.io) Co-authored-by: Amp <amp@ampcode.com>
18 lines
574 B
TypeScript
18 lines
574 B
TypeScript
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
|
|
|
import { isPromotedWidgetView } from '@/core/graph/subgraph/promotedWidgetTypes'
|
|
|
|
const widgetRenderKeys = new WeakMap<IBaseWidget, string>()
|
|
let nextWidgetRenderKeyId = 0
|
|
|
|
export function getStableWidgetRenderKey(widget: IBaseWidget): string {
|
|
const cachedKey = widgetRenderKeys.get(widget)
|
|
if (cachedKey) return cachedKey
|
|
|
|
const prefix = isPromotedWidgetView(widget) ? 'promoted' : 'widget'
|
|
const key = `${prefix}:${nextWidgetRenderKeyId++}`
|
|
|
|
widgetRenderKeys.set(widget, key)
|
|
return key
|
|
}
|