Clear DOM widgets instead of trying to manage refs

This commit is contained in:
filtered
2025-05-15 13:28:32 +10:00
parent 7f6d0b3c47
commit f862afafb4
3 changed files with 40 additions and 21 deletions

View File

@@ -5,7 +5,7 @@ import {
LGraphNode,
LiteGraph
} from '@comfyorg/litegraph'
import type { Subgraph, Vector2 } from '@comfyorg/litegraph'
import type { Vector2 } from '@comfyorg/litegraph'
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
import _ from 'lodash'
import type { ToastMessageOptions } from 'primevue/toast'
@@ -69,8 +69,6 @@ import { deserialiseAndCreate } from '@/utils/vintageClipboard'
import { type ComfyApi, PromptExecutionError, api } from './api'
import { defaultGraph } from './defaultGraph'
import type { BaseDOMWidget } from './domWidget'
import { pruneWidgets } from './domWidget'
import { importA1111 } from './pnginfo'
import { $el, ComfyUI } from './ui'
import { ComfyAppMenu } from './ui/menu/index'
@@ -724,11 +722,6 @@ export class ComfyApp {
node.onAfterGraphConfigured?.()
}
graph.canvasAction((c) => {
const nodes = c.subgraph?.nodes ?? graph.nodes
pruneWidgets(nodes)
})
return r
}
}
@@ -798,14 +791,14 @@ export class ComfyApp {
// Assertions: UnwrapRef
for (const { widget } of widgetStore.widgetStates.values()) {
if (!nodeSet.has(widget.node as LGraphNode)) {
widgetStore.unregisterWidget(widget.id)
if (!nodeSet.has(widget.node)) {
widgetStore.deactivateWidget(widget.id)
}
}
for (const { widget } of widgetStore.inactiveWidgetStates.values()) {
if (nodeSet.has(widget.node as LGraphNode)) {
widgetStore.registerWidget(widget as BaseDOMWidget)
for (const { widget } of widgetStore.inactiveWidgetStates) {
if (nodeSet.has(widget.node)) {
widgetStore.activateWidget(widget.id)
}
}
}
@@ -1569,6 +1562,8 @@ export class ComfyApp {
const executionStore = useExecutionStore()
executionStore.lastNodeErrors = null
executionStore.lastExecutionError = null
useDomWidgetStore().clear()
}
clientPosToCanvasPos(pos: Vector2): Vector2 {