Compare commits

...

1 Commits

Author SHA1 Message Date
Claude
603883d48a fix: set widget.serialize directly instead of in options
widget.options.serialize does nothing - it is never read. The actual
serialization control is widget.serialize on the widget object. This
fixes all locations where serialize was incorrectly being set in the
options object.

https://claude.ai/code/session_013SWpHhSgJNxg3XeGY6a4TQ
2026-02-22 22:14:08 +00:00
12 changed files with 49 additions and 44 deletions

View File

@@ -244,8 +244,9 @@ app.registerExtension({
inputName,
'',
openFileSelection,
{ serialize: false, canvasOnly: true }
{ canvasOnly: true }
)
uploadWidget.serialize = false
uploadWidget.label = t('g.choose_file_to_upload')
useNodeDragAndDrop(node, {
@@ -401,8 +402,9 @@ app.registerExtension({
mediaRecorder.stop()
}
},
{ serialize: false, canvasOnly: false }
{ canvasOnly: false }
)
recordWidget.serialize = false
recordWidget.label = t('g.startRecording')
// Override the type for Vue rendering while keeping 'button' for LiteGraph

View File

@@ -55,10 +55,10 @@ export const useBoundingBoxWidget = (): ComfyWidgetConstructorV2 => {
}
},
{
serialize: true,
canvasOnly: false
}
)
rawWidget.serialize = true
if (!isBoundingBoxLikeWidget(rawWidget)) {
throw new Error(`Unexpected widget type: ${rawWidget.type}`)
@@ -82,10 +82,10 @@ export const useBoundingBoxWidget = (): ComfyWidgetConstructorV2 => {
step: 10,
step2: 1,
precision: 0,
serialize: false,
canvasOnly: true
}
)
subWidget.serialize = false
if (!isNumericWidget(subWidget)) {
throw new Error(`Unexpected widget type: ${subWidget.type}`)

View File

@@ -1,5 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { IChartWidget } from '@/lib/litegraph/src/types/widgets'
import type {
IChartWidget,
IWidgetOptions
} from '@/lib/litegraph/src/types/widgets'
import { isChartInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
import type {
ChartInputSpec,
@@ -18,10 +21,10 @@ export const useChartWidget = (): ComfyWidgetConstructorV2 => {
const chartType = options.type || 'line'
const widget = node.addWidget('chart', name, options.data || {}, () => {}, {
serialize: true,
type: chartType,
...options
}) as IChartWidget
} as IWidgetOptions) as IChartWidget
widget.serialize = true
return widget
}

View File

@@ -11,9 +11,13 @@ export const useColorWidget = (): ComfyWidgetConstructorV2 => {
const { name, options } = inputSpec as ColorInputSpec
const defaultValue = options?.default || '#000000'
const widget = node.addWidget('color', name, defaultValue, () => {}, {
serialize: true
}) as IColorWidget
const widget = node.addWidget(
'color',
name,
defaultValue,
() => {}
) as IColorWidget
widget.serialize = true
return widget
}

View File

@@ -1,5 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { IGalleriaWidget } from '@/lib/litegraph/src/types/widgets'
import type {
IGalleriaWidget,
IWidgetOptions
} from '@/lib/litegraph/src/types/widgets'
import type {
GalleriaInputSpec,
InputSpec as InputSpecV2
@@ -15,11 +18,9 @@ export const useGalleriaWidget = (): ComfyWidgetConstructorV2 => {
name,
options.images || [],
() => {},
{
serialize: true,
...options
}
{ ...options } as IWidgetOptions
) as IGalleriaWidget
widget.serialize = true
return widget
}

View File

@@ -10,13 +10,13 @@ export const useImageCompareWidget = (): ComfyWidgetConstructorV2 => {
return (node: LGraphNode, inputSpec: InputSpecV2): IImageCompareWidget => {
const { name, options = {} } = inputSpec as ImageCompareInputSpec
const widget = node.addWidget('imagecompare', name, ['', ''], () => {}, {
serialize: true,
...options
}) as IImageCompareWidget
// widget.serialize controls workflow persistence; widget.options.serialize
// controls prompt (API) serialization — only disable the former.
const widget = node.addWidget(
'imagecompare',
name,
['', ''],
() => {},
options
) as IImageCompareWidget
widget.serialize = false
return widget

View File

@@ -368,7 +368,6 @@ export const useImagePreviewWidget = () => {
) => {
return node.addCustomWidget(
new ImagePreviewWidget(node, inputSpec.name, {
serialize: false,
canvasOnly: true
})
)

View File

@@ -95,10 +95,10 @@ export const useImageUploadWidget = () => {
'image',
() => openFileSelection(),
{
serialize: false,
canvasOnly: true
}
)
uploadWidget.serialize = false
uploadWidget.label = t('g.choose_file_to_upload')
// Add our own callback to the combo widget to render an image when it changes

View File

@@ -593,7 +593,7 @@ describe('useRemoteWidget', () => {
describe('auto-refresh on task completion', () => {
it('should add auto-refresh toggle widget', () => {
const mockNode = createMockLGraphNode({
addWidget: vi.fn(),
addWidget: vi.fn(() => createMockWidget()),
widgets: []
})
const mockWidget = createMockWidget({
@@ -612,10 +612,7 @@ describe('useRemoteWidget', () => {
'toggle',
'Auto-refresh after generation',
false,
expect.any(Function),
{
serialize: false
}
expect.any(Function)
)
})
@@ -623,7 +620,7 @@ describe('useRemoteWidget', () => {
const addEventListenerSpy = vi.spyOn(api, 'addEventListener')
const mockNode = createMockLGraphNode({
addWidget: vi.fn(),
addWidget: vi.fn(() => createMockWidget()),
widgets: []
})
const mockWidget = createMockWidget({
@@ -654,7 +651,7 @@ describe('useRemoteWidget', () => {
})
const mockNode = createMockLGraphNode({
addWidget: vi.fn(),
addWidget: vi.fn(() => createMockWidget()),
widgets: []
})
const mockWidget = createMockWidget({})
@@ -692,7 +689,7 @@ describe('useRemoteWidget', () => {
})
const mockNode = createMockLGraphNode({
addWidget: vi.fn(),
addWidget: vi.fn(() => createMockWidget()),
widgets: []
})
const mockWidget = createMockWidget({})
@@ -726,7 +723,7 @@ describe('useRemoteWidget', () => {
const removeEventListenerSpy = vi.spyOn(api, 'removeEventListener')
const mockNode = createMockLGraphNode({
addWidget: vi.fn(),
addWidget: vi.fn(() => createMockWidget()),
widgets: [],
onRemoved: undefined
})

View File

@@ -266,11 +266,9 @@ export function useRemoteWidget<
false,
(value: boolean) => {
autoRefreshEnabled = value
},
{
serialize: false
}
)
autoRefreshWidget.serialize = false
// Register event listener
api.addEventListener('execution_success', handleExecutionSuccess)

View File

@@ -1,5 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { ITextareaWidget } from '@/lib/litegraph/src/types/widgets'
import type {
ITextareaWidget,
IWidgetOptions
} from '@/lib/litegraph/src/types/widgets'
import type {
InputSpec as InputSpecV2,
TextareaInputSpec
@@ -16,12 +19,12 @@ export const useTextareaWidget = (): ComfyWidgetConstructorV2 => {
options.default || '',
() => {},
{
serialize: true,
rows: options.rows || 5,
cols: options.cols || 50,
...options
}
} as IWidgetOptions
) as ITextareaWidget
widget.serialize = true
return widget
}

View File

@@ -131,10 +131,10 @@ export function addValueControlWidgets(
function () {},
{
values: ['fixed', 'increment', 'decrement', 'randomize'],
serialize: false, // Don't include this in prompt.
canvasOnly: true
}
) as IComboWidget
valueControl.serialize = false // Don't include this in prompt.
valueControl.tooltip =
'Allows the linked widget to be changed automatically, for example randomizing the noise seed.'
@@ -156,11 +156,9 @@ export function addValueControlWidgets(
'string',
getName('control_filter_list', 'controlFilterListName'),
'',
function () {},
{
serialize: false // Don't include this in prompt.
}
function () {}
) as IStringWidget
comboFilter.serialize = false // Don't include this in prompt.
updateControlWidgetLabel(comboFilter)
comboFilter.tooltip =
"Allows for filtering the list of values when changing the value via the control generate mode. Allows for RegEx matches in the format /abc/ to only filter to values containing 'abc'."