Compare commits

...

8 Commits

Author SHA1 Message Date
dante01yoon
7e169ebf0f test: update selection toolbox linux snapshot 2026-04-12 15:40:41 +09:00
dante01yoon
9777ac4857 test: add repo-native seed widget tab-switch coverage 2026-04-12 14:42:36 +09:00
github-actions
c322810a28 [automated] Update test expectations 2026-04-12 01:48:23 +00:00
dante01yoon
574c11be28 test: cover remaining branches for codecov/patch
- groupNode: no-prefix path and non-object config[1] fallback
- useIntWidget: string control_after_generate passed as default type
2026-04-12 08:41:50 +09:00
dante01yoon
db43803e3b fix: preserve grouped control_after_generate modes 2026-04-12 08:39:55 +09:00
dante01yoon
4b35c984fb fix: update screenshot expectation for seed widget without control
The DevToolsNodeWithSeedInput node no longer has a control_after_generate
widget, so the screenshot now shows only the seed number widget.
2026-04-12 00:02:16 +09:00
dante01yoon
4167a25ac8 fix: remove name-based fallback for seed control_after_generate
Remove name-based inference in useIntWidget.ts and groupNode.ts that
auto-added control_after_generate for any INT input named "seed" or
"noise_seed". Now only adds the control widget when control_after_generate
is explicitly set by the backend.

All core backend nodes already set control_after_generate explicitly.
Custom nodes like WAS_Text_Random_Line that use "seed" as a plain INT
were incorrectly getting a randomize control widget that reset on every
tab switch (since the control widget has serialize: false).

Update test fixture and remove stale screenshot expectation for the
DevToolsNodeWithSeedInput test node, which correctly has no
control_after_generate.

Fixes #7468
2026-04-11 23:41:44 +09:00
dante01yoon
30b4e83fcb test: add failing test for seed control_after_generate name inference
Adds test asserting that a plain INT input named "seed" without
control_after_generate should NOT get a control widget. Currently
fails because useIntWidget infers control_after_generate from the
input name, causing custom nodes like WAS_Text_Random_Line to get
an unwanted randomize control that resets on tab switch.

Refs #7468
2026-04-11 23:36:58 +09:00
8 changed files with 292 additions and 15 deletions

View File

@@ -15,7 +15,7 @@
"properties": {
"Node name for S&R": "DevToolsNodeWithSeedInput"
},
"widgets_values": [0, "randomize"]
"widgets_values": [0]
}
],
"links": [],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -33,6 +33,20 @@ async function getWidgetValueSnapshot(
})
}
async function getWidgetSnapshotForFirstNode(
comfyPage: ComfyPage
): Promise<Array<{ name: string; value: unknown }>> {
return await comfyPage.page.evaluate(() => {
const firstNode = window.app!.graph.nodes[0]
return (
firstNode?.widgets?.map((widget) => ({
name: widget.name,
value: widget.value
})) ?? []
)
})
}
async function getLinkCount(comfyPage: ComfyPage): Promise<number> {
return await comfyPage.page.evaluate(() => {
return window.app!.graph.links
@@ -191,6 +205,82 @@ test.describe('Workflow Persistence', () => {
.toEqual(widgetValuesBefore)
})
test('Plain seed INT inputs do not gain control widgets across workflow tab switches', async ({
comfyPage
}) => {
test.info().annotations.push({
type: 'regression',
description:
'Issue #7468 — plain INT inputs named seed should not get control_after_generate widgets'
})
const tab = comfyPage.menu.workflowsTab
await tab.open()
await comfyPage.workflow.loadWorkflow('widgets/seed_widget')
await comfyPage.workflow.waitForWorkflowIdle()
await comfyPage.nextFrame()
await comfyPage.menu.topbar.saveWorkflow('plain-seed-widget-test')
await expect
.poll(() => getWidgetSnapshotForFirstNode(comfyPage))
.toEqual([{ name: 'seed', value: 0 }])
await comfyPage.command.executeCommand('Comfy.NewBlankWorkflow')
await comfyPage.workflow.waitForWorkflowIdle()
await tab.switchToWorkflow('plain-seed-widget-test')
await comfyPage.workflow.waitForWorkflowIdle()
await expect
.poll(() => getWidgetSnapshotForFirstNode(comfyPage))
.toEqual([{ name: 'seed', value: 0 }])
})
test('Core seed widgets keep explicit control widgets across workflow tab switches', async ({
comfyPage
}) => {
test.info().annotations.push({
type: 'regression',
description:
'Issue #7468 — nodes that explicitly opt into control_after_generate should keep that widget'
})
const tab = comfyPage.menu.workflowsTab
await tab.open()
await comfyPage.workflow.loadWorkflow('nodes/single_ksampler')
await comfyPage.workflow.waitForWorkflowIdle()
await comfyPage.nextFrame()
await comfyPage.menu.topbar.saveWorkflow('ksampler-control-widget-test')
await expect
.poll(() => getWidgetSnapshotForFirstNode(comfyPage))
.toEqual(
expect.arrayContaining([
{ name: 'seed', value: 156680208700286 },
{ name: 'control_after_generate', value: 'randomize' }
])
)
await comfyPage.command.executeCommand('Comfy.NewBlankWorkflow')
await comfyPage.workflow.waitForWorkflowIdle()
await tab.switchToWorkflow('ksampler-control-widget-test')
await comfyPage.workflow.waitForWorkflowIdle()
await expect
.poll(() => getWidgetSnapshotForFirstNode(comfyPage))
.toEqual(
expect.arrayContaining([
{ name: 'seed', value: 156680208700286 },
{ name: 'control_after_generate', value: 'randomize' }
])
)
})
test('API format workflow with missing node types partially loads', async ({
comfyPage
}) => {

View File

@@ -0,0 +1,102 @@
import { describe, expect, it, vi } from 'vitest'
import type { GroupNodeWorkflowData } from '@/lib/litegraph/src/LGraph'
const mockRegisterExtension = vi.hoisted(() => vi.fn())
vi.mock('@/scripts/app', () => ({
app: {
registerExtension: mockRegisterExtension
}
}))
import { GroupNodeConfig } from '@/extensions/core/groupNode'
const createGroupNodeConfig = () =>
new GroupNodeConfig('Test Group', {
external: [],
links: [],
nodes: []
} satisfies GroupNodeWorkflowData)
describe('GroupNodeConfig.getInputConfig', () => {
it('does not infer control_after_generate from seed-like input names', () => {
const groupNodeConfig = createGroupNodeConfig()
const node: Parameters<GroupNodeConfig['getInputConfig']>[0] = {
index: 0,
type: 'KSampler',
inputs: [{ name: 'seed' }]
}
const config: Parameters<GroupNodeConfig['getInputConfig']>[3] = [
'INT',
{ min: 0 }
]
const result = groupNodeConfig.getInputConfig(node, 'seed', {}, config)
expect(result.config).toEqual(['INT', { min: 0 }])
})
it('does not add control_prefix when there is no prefix', () => {
const groupNodeConfig = createGroupNodeConfig()
const node: Parameters<GroupNodeConfig['getInputConfig']>[0] = {
index: 0,
type: 'KSampler',
inputs: [{ name: 'seed' }]
}
const config: Parameters<GroupNodeConfig['getInputConfig']>[3] = [
'INT',
{ control_after_generate: true, min: 0 }
]
const result = groupNodeConfig.getInputConfig(node, 'seed', {}, config)
expect(result.config).toEqual([
'INT',
{ control_after_generate: true, min: 0 }
])
})
it('falls back to empty object when config[1] is not an object', () => {
const groupNodeConfig = createGroupNodeConfig()
const node: Parameters<GroupNodeConfig['getInputConfig']>[0] = {
index: 0,
type: 'KSampler'
}
const config: Parameters<GroupNodeConfig['getInputConfig']>[3] = ['INT']
const result = groupNodeConfig.getInputConfig(node, 'steps', {}, config)
expect(result.config).toEqual(['INT'])
expect(result.name).toBe('steps')
})
it('preserves explicit control_after_generate modes for grouped inputs', () => {
const groupNodeConfig = createGroupNodeConfig()
const node: Parameters<GroupNodeConfig['getInputConfig']>[0] = {
index: 0,
type: 'KSampler',
inputs: [{ name: 'seed' }]
}
const config: Parameters<GroupNodeConfig['getInputConfig']>[3] = [
'INT',
{ control_after_generate: 'increment' }
]
const result = groupNodeConfig.getInputConfig(
node,
'seed',
{ seed: 1 },
config
)
expect(result.name).toBe('KSampler seed')
expect(result.config).toEqual([
'INT',
{
control_after_generate: 'increment',
control_prefix: 'KSampler'
}
])
})
})

View File

@@ -544,15 +544,21 @@ export class GroupNodeConfig {
}
seenInputs[key] = (seenInputs[key] ?? 1) + 1
if (inputName === 'seed' || inputName === 'noise_seed') {
if (!extra) extra = {}
extra.control_after_generate = `${prefix}control_after_generate`
const configOptions =
typeof config[1] === 'object' && config[1] !== null ? config[1] : {}
if (
'control_after_generate' in configOptions &&
configOptions.control_after_generate
) {
const controlPrefix = prefix.trimEnd()
if (controlPrefix) {
if (!extra) extra = {}
extra.control_prefix = controlPrefix
}
}
if (config[0] === 'IMAGEUPLOAD') {
if (!extra) extra = {}
const nodeIndex = node.index ?? -1
const configOptions =
typeof config[1] === 'object' && config[1] !== null ? config[1] : {}
const widgetKey =
'widget' in configOptions && typeof configOptions.widget === 'string'
? configOptions.widget
@@ -561,9 +567,7 @@ export class GroupNodeConfig {
}
if (extra) {
const configObj =
typeof config[1] === 'object' && config[1] ? config[1] : {}
config = [config[0], { ...configObj, ...extra }]
config = [config[0], { ...configOptions, ...extra }]
}
return { name, config, customConfig }

View File

@@ -1,19 +1,32 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { INumericWidget } from '@/lib/litegraph/src/types/widgets'
import { _for_testing } from '@/renderer/extensions/vueNodes/widgets/composables/useIntWidget'
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
const mockAddValueControlWidget = vi.fn()
vi.mock('@/scripts/widgets', () => ({
addValueControlWidget: (...args: unknown[]) =>
mockAddValueControlWidget(...args),
addValueControlWidgets: vi.fn()
}))
vi.mock('@/platform/settings/settingStore', () => ({
useSettingStore: () => ({
settings: {}
get: () => false
})
}))
const { onValueChange } = _for_testing
vi.mock('@/schemas/nodeDef/migration', () => ({
transformInputSpecV2ToV1: (spec: unknown) => spec
}))
const {
_for_testing: { onValueChange },
useIntWidget
} =
await import('@/renderer/extensions/vueNodes/widgets/composables/useIntWidget')
describe('useIntWidget', () => {
describe('onValueChange', () => {
@@ -73,4 +86,74 @@ describe('useIntWidget', () => {
expect(widget.value).toBe(6)
})
})
describe('control_after_generate', () => {
function createMockNode(): LGraphNode {
return {
addWidget: vi.fn((_type, _name, _value, _callback, _options) => ({
type: _type,
name: _name,
value: _value,
options: _options ?? {},
linkedWidgets: undefined
}))
} as unknown as LGraphNode
}
beforeEach(() => {
mockAddValueControlWidget.mockReset()
mockAddValueControlWidget.mockReturnValue({ type: 'combo' })
})
it('should not add control widget for INT named "seed" without control_after_generate', () => {
const node = createMockNode()
const inputSpec: InputSpec = {
type: 'INT',
name: 'seed',
default: 0
}
const constructor = useIntWidget()
constructor(node, inputSpec)
expect(mockAddValueControlWidget).not.toHaveBeenCalled()
})
it('should add control widget when control_after_generate is explicitly true', () => {
const node = createMockNode()
const inputSpec: InputSpec = {
type: 'INT',
name: 'seed',
default: 0,
control_after_generate: true
}
const constructor = useIntWidget()
constructor(node, inputSpec)
expect(mockAddValueControlWidget).toHaveBeenCalled()
})
it('should pass string control_after_generate as the default type', () => {
const node = createMockNode()
const inputSpec: InputSpec = {
type: 'INT',
name: 'seed',
default: 0,
control_after_generate: 'increment'
}
const constructor = useIntWidget()
constructor(node, inputSpec)
expect(mockAddValueControlWidget).toHaveBeenCalledWith(
node,
expect.anything(),
'increment',
undefined,
undefined,
expect.anything()
)
})
})
})

View File

@@ -67,9 +67,7 @@ export const useIntWidget = () => {
}
)
const controlAfterGenerate =
inputSpec.control_after_generate ??
['seed', 'noise_seed'].includes(inputSpec.name)
const controlAfterGenerate = inputSpec.control_after_generate ?? false
if (controlAfterGenerate) {
const defaultType =