diff --git a/browser_tests/assets/default_input.json b/browser_tests/assets/default_input.json new file mode 100644 index 0000000000..eff7b32361 --- /dev/null +++ b/browser_tests/assets/default_input.json @@ -0,0 +1,53 @@ +{ + "id": "9bcb9451-8319-492a-88d4-fb711d8c3d25", + "revision": 0, + "last_node_id": 6, + "last_link_id": 0, + "nodes": [ + { + "id": 6, + "type": "DevToolsNodeWithDefaultInput", + "pos": [ + 8.39722728729248, + 29.727279663085938 + ], + "size": [ + 315, + 82 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [ + { + "name": "float_input", + "shape": 7, + "type": "FLOAT", + "link": null + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "DevToolsNodeWithDefaultInput" + }, + "widgets_values": [ + 0, + 1, + 0 + ] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 2.1600300525920346, + "offset": [ + 63.071794466403446, + 75.18055335968394 + ] + } + }, + "version": 0.4 +} \ No newline at end of file diff --git a/browser_tests/tests/nodeDisplay.spec.ts b/browser_tests/tests/nodeDisplay.spec.ts index 8712d903c8..1fa1976501 100644 --- a/browser_tests/tests/nodeDisplay.spec.ts +++ b/browser_tests/tests/nodeDisplay.spec.ts @@ -25,6 +25,11 @@ test.describe('Optional input', () => { await expect(comfyPage.canvas).toHaveScreenshot('force_input.png') }) + test('Default input', async ({ comfyPage }) => { + await comfyPage.loadWorkflow('default_input') + await expect(comfyPage.canvas).toHaveScreenshot('default_input.png') + }) + test('Only optional inputs', async ({ comfyPage }) => { await comfyPage.loadWorkflow('only_optional_inputs') expect(await comfyPage.getGraphNodesCount()).toBe(1) diff --git a/browser_tests/tests/nodeDisplay.spec.ts-snapshots/default-input-chromium-linux.png b/browser_tests/tests/nodeDisplay.spec.ts-snapshots/default-input-chromium-linux.png new file mode 100644 index 0000000000..899c92e8fa Binary files /dev/null and b/browser_tests/tests/nodeDisplay.spec.ts-snapshots/default-input-chromium-linux.png differ diff --git a/src/stores/nodeDefStore.ts b/src/stores/nodeDefStore.ts index fec829e9d4..3541476a85 100644 --- a/src/stores/nodeDefStore.ts +++ b/src/stores/nodeDefStore.ts @@ -1,5 +1,6 @@ import type { LGraphNode } from '@comfyorg/litegraph' import axios from 'axios' +import _ from 'lodash' import { defineStore } from 'pinia' import { computed, ref } from 'vue' @@ -69,7 +70,41 @@ export class ComfyNodeDefImpl // ComfyNodeDefImpl fields readonly nodeSource: NodeSource - constructor(obj: ComfyNodeDefV1) { + /** + * @internal + * Migrate default input options to forceInput. + */ + static #migrateDefaultInput(nodeDef: ComfyNodeDefV1): ComfyNodeDefV1 { + const def = _.cloneDeep(nodeDef) + def.input ??= {} + // For required inputs, now we have the input socket always present. Specifying + // it now has no effect. + for (const [name, spec] of Object.entries(def.input.required ?? {})) { + const inputOptions = spec[1] + if (inputOptions && inputOptions.defaultInput) { + console.warn( + `Use of defaultInput on required input ${nodeDef.python_module}:${nodeDef.name}:${name} is deprecated. Please drop the defaultInput option.` + ) + } + } + // For optional inputs, defaultInput is used to distinguish the null state. + // We migrate it to forceInput. One example is the "seed_override" input usage. + // User can connect the socket to override the seed. + for (const [name, spec] of Object.entries(def.input.optional ?? {})) { + const inputOptions = spec[1] + if (inputOptions && inputOptions.defaultInput) { + console.warn( + `Use of defaultInput on optional input ${nodeDef.python_module}:${nodeDef.name}:${name} is deprecated. Please use forceInput instead.` + ) + inputOptions.forceInput = true + } + } + return def + } + + constructor(def: ComfyNodeDefV1) { + const obj = ComfyNodeDefImpl.#migrateDefaultInput(def) + /** * Assign extra fields to `this` for compatibility with group node feature. * TODO: Remove this once group node feature is removed. diff --git a/src/types/litegraph-augmentation.d.ts b/src/types/litegraph-augmentation.d.ts index e173c1b3de..c35f75bca2 100644 --- a/src/types/litegraph-augmentation.d.ts +++ b/src/types/litegraph-augmentation.d.ts @@ -26,13 +26,6 @@ declare module '@comfyorg/litegraph/dist/types/widgets' { * The minimum size of the node if the widget is present. */ minNodeSize?: Size - /** - * Whether the widget defaults to input state. Can still be converted back - * to widget state. - * @deprecated Widget to input conversion is no longer necessary, as they co-exist now. - * This option no longer has any effect. - */ - defaultInput?: boolean } interface IBaseWidget {