mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
filter unserialized widgets values
This commit is contained in:
@@ -8,6 +8,7 @@ import type { ExecutedWsMessage } from '@/schemas/apiSchema'
|
||||
import type { ComfyWorkflowJSON } from '@/schemas/comfyWorkflowSchema'
|
||||
import { useExecutionStore } from '@/stores/executionStore'
|
||||
import { ComfyWorkflow, useWorkflowStore } from '@/stores/workflowStore'
|
||||
import { filterSerializedWidgetValues } from '@/utils/litegraphUtil'
|
||||
|
||||
import { api } from './api'
|
||||
import type { ComfyApp } from './app'
|
||||
@@ -385,7 +386,10 @@ export class ChangeTracker {
|
||||
if (
|
||||
!_.isEqualWith(a.nodes, b.nodes, (arrA, arrB) => {
|
||||
if (Array.isArray(arrA) && Array.isArray(arrB)) {
|
||||
return _.isEqual(new Set(arrA), new Set(arrB))
|
||||
// Filter non-serializable widget values before comparison
|
||||
const filteredArrA = filterSerializedWidgetValues(arrA, app.graph)
|
||||
const filteredArrB = filterSerializedWidgetValues(arrB, app.graph)
|
||||
return _.isEqual(new Set(filteredArrA), new Set(filteredArrB))
|
||||
}
|
||||
})
|
||||
) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { ColorOption } from '@comfyorg/litegraph'
|
||||
import type { ColorOption, LGraph } from '@comfyorg/litegraph'
|
||||
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
|
||||
import type { IComboWidget } from '@comfyorg/litegraph/dist/types/widgets'
|
||||
import _ from 'lodash'
|
||||
|
||||
import type { ComfyNode } from '@/schemas/comfyWorkflowSchema'
|
||||
|
||||
type ImageNode = LGraphNode & { imgs: HTMLImageElement[] | undefined }
|
||||
type VideoNode = LGraphNode & {
|
||||
videoContainer: HTMLElement | undefined
|
||||
@@ -70,3 +72,40 @@ export function executeWidgetsCallback(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the nodes with non-serialized widget values removed
|
||||
*/
|
||||
export function filterSerializedWidgetValues(
|
||||
nodes: ComfyNode[],
|
||||
graph: LGraph
|
||||
): ComfyNode[] {
|
||||
if (!graph) return nodes
|
||||
|
||||
return nodes.map((node) => {
|
||||
if (!node.widgets_values) return node
|
||||
|
||||
const graphNode = graph.getNodeById(node.id)
|
||||
if (!graphNode?.widgets) return node
|
||||
|
||||
const filteredNode = { ...node }
|
||||
const serializedValues = []
|
||||
|
||||
for (let i = 0; i < graphNode.widgets.length; i++) {
|
||||
const widget = graphNode.widgets[i]
|
||||
|
||||
// Skip if widget is not serialized
|
||||
if (!widget.options || widget.options.serialize !== false) {
|
||||
const value = Array.isArray(node.widgets_values)
|
||||
? node.widgets_values[i]
|
||||
: node.widgets_values[widget.name || i.toString()]
|
||||
serializedValues.push(
|
||||
typeof value === 'object' && value !== null ? value.value : value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
filteredNode.widgets_values = serializedValues
|
||||
return filteredNode
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user