From 8f4081bb75b696c81d4dce692a1d1b980eb2b968 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 11 May 2026 16:26:25 -0700 Subject: [PATCH 01/14] Remove special case for curve widgets This will never be used now that interpolation information is included and should have been applied as a `serializeValue` function --- src/utils/executionUtil.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/executionUtil.ts b/src/utils/executionUtil.ts index a57d60822f7..e3f4ce9880d 100644 --- a/src/utils/executionUtil.ts +++ b/src/utils/executionUtil.ts @@ -108,9 +108,7 @@ export const graphToPrompt = async ( // The backend automatically unwraps the object to an array during // execution. inputs[widget.name] = Array.isArray(widgetValue) - ? widget.type === 'curve' - ? { __type__: 'CURVE', __value__: widgetValue } - : { __value__: widgetValue } + ? { __value__: widgetValue } : widgetValue } } From 960cf20cbe40d2f732e0ad89b33dc387e179df2a Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 11 May 2026 16:52:14 -0700 Subject: [PATCH 02/14] Use original spec verbatim for widgetconfig --- src/services/litegraphService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 617a8c2ca7a..6f4e5ca8404 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -305,7 +305,7 @@ export const useLitegraphService = () => { } if (!widget?.options?.socketless) { - const inputSpecV1 = transformInputSpecV2ToV1(widgetInputSpec) + const inputSpecV1 = transformInputSpecV2ToV1(inputSpec) node.addInput(inputName, inputSpec.type, { shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined, localized_name: st(nameKey, inputName), From aaa9498fb404adf33a9d76509f2170738d9e7244 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 11 May 2026 16:54:44 -0700 Subject: [PATCH 03/14] Add resolveVirtualValue method --- src/lib/litegraph/src/LGraphNode.ts | 6 ++++++ src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 934239cc7dc..6eac1c7cf6a 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -1222,6 +1222,12 @@ export class LGraphNode slot: number ): { node: LGraphNode; slot: number } | undefined + /** + * Resolves the value of an to be sent from an output slot + * Ensures virtual nodes can apply state to socketless widgets + */ + resolveVirtualValue?(slot: number): unknown + /** * Returns the link info in the connection of an input slot * @returns object or null diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts index 6ea8e0ca74b..6b2b644f259 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts @@ -307,6 +307,15 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { return inputNodeDto.resolveOutput(virtualSource.slot, type, visited) } + if (this.node.resolveVirtualValue) { + return { + node: this, + origin_id: this.id, + origin_slot: -1, + widgetInfo: { value: this.node.resolveVirtualValue(slot) } + } + } + const virtualLink = this.node.getInputLink(slot) if (virtualLink) { const { inputNode } = virtualLink.resolve(this.graph) From 57aa435ae278da29fd9f429915395e811b2b37ad Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 11 May 2026 17:53:23 -0700 Subject: [PATCH 04/14] Implement resolveVirtualValue for primitives --- src/extensions/core/widgetInputs.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index d78b2857259..0ccf9d3d537 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -412,6 +412,14 @@ export class PrimitiveNode extends LGraphNode { this._removeWidgets() } + + override resolveVirtualValue() { + const w = this.widgets?.[0] + let value = w?.serializeValue ? w.serializeValue(this, 0) : w?.value + return value && this.properties[replacePropertyName] && this.graph + ? applyTextReplacements(this.graph, String(value)) + : value + } } export function getWidgetConfig( From 52197934afa3026f647f54caa631cf2875e0f90b Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 12 May 2026 15:00:49 -0700 Subject: [PATCH 05/14] Add test --- browser_tests/tests/primitiveNode.spec.ts | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index a1eb77042f3..f4a74432328 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -75,4 +75,46 @@ test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { ) await expect(errorOverlay).toBeVisible() }) + + test('Can serialize to forced inputs @vue-nodes', async ({ comfyPage }) => { + await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top') + await comfyPage.settings.setSetting( + 'Comfy.NodeSearchBoxImpl', + 'v1 (legacy)' + ) + + await test.step('Add nodes', async () => { + await comfyPage.menu.topbar.newWorkflowButton.click() + await comfyPage.nextFrame() + + await comfyPage.page.mouse.dblclick(250, 500, { delay: 5 }) + await comfyPage.searchBox.fillAndSelectFirstNode('Primitive') + await expect(comfyPage.searchBox.input).toBeHidden() + await comfyPage.page.mouse.dblclick(600, 500, { delay: 5 }) + await comfyPage.searchBox.fillAndSelectFirstNode('Node With Force Input') + }) + + const primitive = await comfyPage.vueNodes.getFixtureByTitle('Primitive') + const node = await comfyPage.vueNodes.getFixtureByTitle( + 'Node With Force Input' + ) + + await test.step('Link nodes', async () => { + await primitive.getSlot('').dragTo(node.getSlot('int_input').first()) + await expect + .poll(() => comfyPage.vueNodes.isSlotConnected(primitive.getSlot(''))) + .toBe(true) + }) + + const { input } = comfyPage.vueNodes.getInputNumberControls( + await comfyPage.vueNodes.getWidgetByName('Primitive', 'value') + ) + await input.fill('5') + await input.blur() + const serializedValue = await comfyPage.page.evaluate(async () => { + const { output } = await app!.graphToPrompt() + return output[2].inputs.int_input + }) + expect(serializedValue, 'Serialized prompt has primitive value').toBe(5) + }) }) From 1f59708dcb8ee5f2c730b03469337b81d38d7e8b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 9 Nov 2026 22:36:57 +0000 Subject: [PATCH 06/14] [automated] Apply ESLint and Oxfmt fixes --- src/extensions/core/widgetInputs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index 84685f34ed8..7304ebf337b 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -482,7 +482,7 @@ export class PrimitiveNode extends LGraphNode { override resolveVirtualValue() { const w = this.widgets?.[0] - let value = w?.serializeValue ? w.serializeValue(this, 0) : w?.value + const value = w?.serializeValue ? w.serializeValue(this, 0) : w?.value return value && this.properties[replacePropertyName] && this.graph ? applyTextReplacements(this.graph, String(value)) : value From ab89994e3b94d7d52067cdccd415b294508724e2 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 02:34:17 +0000 Subject: [PATCH 07/14] fix: send primitive values only to inputs without a widget Widget inputs already receive the primitive value through applyToGraph, so sending it again over the link overwrote the target widget's serializeValue (dynamic prompts, %date% replacements, curve wrapping). The virtual value now only fills inputs with no widget, and an undefined value no longer erases the target. PrimitiveNode shares its text replacement between both paths. --- src/extensions/core/widgetInputs.test.ts | 58 +++++++++++++++++++ src/extensions/core/widgetInputs.ts | 33 ++++++----- src/lib/litegraph/src/LGraphNode.ts | 4 +- .../src/subgraph/ExecutableNodeDTO.ts | 34 +++++++---- 4 files changed, 100 insertions(+), 29 deletions(-) diff --git a/src/extensions/core/widgetInputs.test.ts b/src/extensions/core/widgetInputs.test.ts index 408e6d7e8b0..239b56692e5 100644 --- a/src/extensions/core/widgetInputs.test.ts +++ b/src/extensions/core/widgetInputs.test.ts @@ -39,6 +39,7 @@ beforeEach(() => { }) const { rerouteNodeExtension } = await import('./rerouteNode') +const { graphToPrompt } = await import('@/utils/executionUtil') /** * Applies the extension's `beforeRegisterNodeDef` to a throwaway node class. @@ -402,6 +403,63 @@ describe('PrimitiveNode', () => { expect(primitive.widgets?.[0].value).toBe(111) }) + + function stringTargetFixture() { + const graph = new LGraph() + const source = new LGraphNode('Source') + graph.add(source) + source.addWidget('text', 'subject', 'cat', () => {}) + const target = new LGraphNode('Target') + target.comfyClass = 'Target' + graph.add(target) + target.addInput('text', 'STRING') + const primitive = new PrimitiveNode('Primitive') + graph.add(primitive) + return { graph, primitive, target } + } + + it.for([ + { + label: 'sends its value', + replace: false, + value: 'a photo of %Source.subject%', + expected: 'a photo of %Source.subject%' + }, + { + label: 'applies text replacements to its value', + replace: true, + value: 'a photo of %Source.subject%', + expected: 'a photo of cat' + } + ])( + '$label to a forceInput without a widget', + async ({ replace, value, expected }) => { + const { graph, primitive, target } = stringTargetFixture() + primitive.connect(0, target, 0) + primitive.properties['Run widget replace on values'] = replace + primitive.widgets![0].value = value + + const { output } = await graphToPrompt(graph) + + expect(output[String(target.id)].inputs.text).toBe(expected) + } + ) + + it("keeps the target widget's serialized value on a widget input", async () => { + const { graph, primitive, target } = stringTargetFixture() + target.inputs[0].widget = { + name: 'text', + [GET_CONFIG]: () => ['STRING', {}] + } + const widget = target.addWidget('text', 'text', '', () => {}) + widget.serializeValue = () => String(widget.value).toUpperCase() + primitive.connect(0, target, 0) + primitive.widgets![0].value = 'a photo of cat' + + const { output } = await graphToPrompt(graph) + + expect(output[String(target.id)].inputs.text).toBe('A PHOTO OF CAT') + }) }) describe('getWidgetConfig', () => { diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index 7304ebf337b..8501344b4df 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -53,15 +53,24 @@ export class PrimitiveNode extends LGraphNode { } override applyToGraph(extraLinks: LLink[] = []) { - const sourceWidget = this.widgets?.[0] - const graph = this.graph - if (!sourceWidget || !graph) return + applyFirstWidgetValueToGraph(this, extraLinks, (value) => + this._applyTextReplacements(value) + ) + } - let v = sourceWidget.value - if (v && this.properties[replacePropertyName]) { - v = applyTextReplacements(graph, v as string) - } - applyFirstWidgetValueToGraph(this, extraLinks, () => v) + // fallow-ignore-next-line unused-class-member + override resolveVirtualValue() { + const widget = this.widgets?.[0] + if (!widget) return + return this._applyTextReplacements( + widget.serializeValue ? widget.serializeValue(this, 0) : widget.value + ) + } + + private _applyTextReplacements(value: T): T | string { + return value && this.properties[replacePropertyName] && this.graph + ? applyTextReplacements(this.graph, String(value)) + : value } override refreshComboInNode(defs?: Record): void { @@ -479,14 +488,6 @@ export class PrimitiveNode extends LGraphNode { this._removeWidgets() } - - override resolveVirtualValue() { - const w = this.widgets?.[0] - const value = w?.serializeValue ? w.serializeValue(this, 0) : w?.value - return value && this.properties[replacePropertyName] && this.graph - ? applyTextReplacements(this.graph, String(value)) - : value - } } export function getWidgetConfig( diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 5e597f1a8ec..4011faab5e1 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -1682,8 +1682,8 @@ export class LGraphNode ): { node: LGraphNode; slot: number } | undefined /** - * Resolves the value of an to be sent from an output slot - * Ensures virtual nodes can apply state to socketless widgets + * Returns the prompt value a virtual node sends from output {@link slot} + * to an input that has no widget to receive it. */ resolveVirtualValue?(slot: number): unknown diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts index b2a7f6823d8..5337315315b 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts @@ -1,6 +1,7 @@ import type { LGraph, LGraphNode, + LLink, Subgraph, SubgraphNode } from '@comfyorg/graph-model/entityRegistry' @@ -232,10 +233,19 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { } // Not part of a subgraph; use the original link + return this._resolveGraphLink(link, input, visited, type) + } + + private _resolveGraphLink( + link: LLink, + input: ExecutableNodeDTO['inputs'][number], + visited: Set, + type?: ISlotType + ): ResolvedInput | undefined { const outputNode = this.graph.getNodeById(link.origin_id) if (!outputNode) throw new InvalidLinkError( - `No input node found for id [${this.id}] slot [${slot}] ${input.name}` + `No input node found for id [${this.id}] slot [${link.target_slot}] ${input.name}` ) const outputNodeExecutionId: ExecutionId = [ @@ -248,11 +258,22 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { `No output node DTO found for id [${outputNodeExecutionId}]` ) - return outputNodeDto.resolveOutput( + const resolved = outputNodeDto.resolveOutput( link.origin_slot, type ?? input.type, visited ) + // Widget inputs already received the value through applyToGraph + if (resolved || this.node.inputs[link.target_slot]?.widget) return resolved + + const value = outputNode.resolveVirtualValue?.(link.origin_slot) + if (value === undefined) return + return { + node: outputNodeDto, + origin_id: outputNodeDto.id, + origin_slot: -1, + widgetInfo: { value } + } } /** @@ -320,15 +341,6 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { return inputNodeDto.resolveOutput(virtualSource.slot, type, visited) } - if (this.node.resolveVirtualValue) { - return { - node: this, - origin_id: this.id, - origin_slot: -1, - widgetInfo: { value: this.node.resolveVirtualValue(slot) } - } - } - const virtualLink = this.node.getInputLink(slot) if (virtualLink) { const { inputNode } = virtualLink.resolve(this.graph) From 9819ea005a2c54296e7923532e04add19639c8d2 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 02:35:01 +0000 Subject: [PATCH 08/14] fix: keep the widgetType spec in widget input GET_CONFIG PrimitiveNode builds its widget from GET_CONFIG, so passing the original multi-type spec gave a FLOAT,INT input a float,int custom widget instead of a number widget, and dropped its saved value on load. --- src/services/litegraphService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 12027f308d1..b22edf3fb4e 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -357,7 +357,7 @@ export const useLitegraphService = () => { if (dynamic) widget.tooltip = inputSpec.tooltip if (!widget.options.socketless) { - const inputSpecV1 = transformInputSpecV2ToV1(inputSpec) + const inputSpecV1 = transformInputSpecV2ToV1(widgetInputSpec) node.addInput(inputName, inputSpec.type, { shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined, localized_name: resolveLabel(inputName), From 8ae0c43eef78671b4663b883a3841456281d48aa Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 02:35:35 +0000 Subject: [PATCH 09/14] test: start the forced input primitive test with the Top menu The file-level Disabled menu setting starts the app in focus mode, which hides the new workflow button, so the test timed out. The test now has its own describe with startup settings, opens a blank workflow through the command, and reads the prompt through getExportedWorkflow. --- browser_tests/tests/primitiveNode.spec.ts | 83 +++++++++++++---------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index aa82eefd964..6f82bba91b1 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -149,46 +149,57 @@ test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { await expect(errorOverlay).toBeVisible() }) }) +}) - test('Can serialize to forced inputs @vue-nodes', async ({ comfyPage }) => { - await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top') - await comfyPage.settings.setSetting( - 'Comfy.NodeSearchBoxImpl', - 'v1 (legacy)' - ) +test.describe( + 'Primitive Node forced inputs', + { tag: ['@node', '@vue-nodes'] }, + () => { + test.use({ + initialSettings: { + 'Comfy.UseNewMenu': 'Top', + 'Comfy.NodeSearchBoxImpl': 'v1 (legacy)' + } + }) - await test.step('Add nodes', async () => { - await comfyPage.menu.topbar.newWorkflowButton.click() - await comfyPage.nextFrame() + test('Can serialize to forced inputs', async ({ comfyPage }) => { + await test.step('Add nodes', async () => { + await comfyPage.workflow.newBlankWorkflow() - await comfyPage.page.mouse.dblclick(250, 500, { delay: 5 }) - await comfyPage.searchBox.fillAndSelectFirstNode('Primitive') - await expect(comfyPage.searchBox.input).toBeHidden() - await comfyPage.page.mouse.dblclick(600, 500, { delay: 5 }) - await comfyPage.searchBox.fillAndSelectFirstNode('Node With Force Input') - }) + await comfyPage.page.mouse.dblclick(250, 500, { delay: 5 }) + await comfyPage.searchBox.fillAndSelectFirstNode('Primitive') + await expect(comfyPage.searchBox.input).toBeHidden() + await comfyPage.page.mouse.dblclick(600, 500, { delay: 5 }) + await comfyPage.searchBox.fillAndSelectFirstNode( + 'Node With Force Input' + ) + }) - const primitive = await comfyPage.vueNodes.getFixtureByTitle('Primitive') - const node = await comfyPage.vueNodes.getFixtureByTitle( - 'Node With Force Input' - ) + const primitive = await comfyPage.vueNodes.getFixtureByTitle('Primitive') + const node = await comfyPage.vueNodes.getFixtureByTitle( + 'Node With Force Input' + ) - await test.step('Link nodes', async () => { - await primitive.getSlot('').dragTo(node.getSlot('int_input').first()) - await expect - .poll(() => comfyPage.vueNodes.isSlotConnected(primitive.getSlot(''))) - .toBe(true) - }) + await test.step('Link nodes', async () => { + await primitive.getSlot('').dragTo(node.getSlot('int_input').first()) + await expect + .poll(() => comfyPage.vueNodes.isSlotConnected(primitive.getSlot(''))) + .toBe(true) + }) - const { input } = comfyPage.vueNodes.getInputNumberControls( - await comfyPage.vueNodes.getWidgetByName('Primitive', 'value') - ) - await input.fill('5') - await input.blur() - const serializedValue = await comfyPage.page.evaluate(async () => { - const { output } = await app!.graphToPrompt() - return output[2].inputs.int_input + const { input } = comfyPage.vueNodes.getInputNumberControls( + comfyPage.vueNodes.getWidgetByName('Primitive', 'value') + ) + await input.fill('5') + await input.blur() + const prompt = await comfyPage.workflow.getExportedWorkflow({ api: true }) + const forceInputNode = Object.values(prompt).find( + (entry) => entry.class_type === 'DevToolsNodeWithForceInput' + ) + expect( + forceInputNode?.inputs.int_input, + 'Serialized prompt has primitive value' + ).toBe(5) }) - expect(serializedValue, 'Serialized prompt has primitive value').toBe(5) - }) -}) + } +) From 0aaa9137aef6bc8317b93477a45c63cdf966866c Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 19:07:42 +0000 Subject: [PATCH 10/14] fix: skip muted and bypassed primitives for inputs without a widget resolveOutput treats muted and bypassed nodes as producing no output, but the widgetless fallback still asked the primitive for its value, so a muted primitive fed its value to a forceInput. The fallback now has its own named method and follows the same mode rule. --- src/extensions/core/widgetInputs.test.ts | 13 +++++++++- .../src/subgraph/ExecutableNodeDTO.ts | 25 ++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/extensions/core/widgetInputs.test.ts b/src/extensions/core/widgetInputs.test.ts index 239b56692e5..884b09bc1de 100644 --- a/src/extensions/core/widgetInputs.test.ts +++ b/src/extensions/core/widgetInputs.test.ts @@ -3,6 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { LGraph, + LGraphEventMode, LGraphNode, LiteGraph, LLink @@ -421,21 +422,31 @@ describe('PrimitiveNode', () => { it.for([ { label: 'sends its value', + mode: LGraphEventMode.ALWAYS, replace: false, value: 'a photo of %Source.subject%', expected: 'a photo of %Source.subject%' }, { label: 'applies text replacements to its value', + mode: LGraphEventMode.ALWAYS, replace: true, value: 'a photo of %Source.subject%', expected: 'a photo of cat' + }, + { + label: 'sends nothing while muted', + mode: LGraphEventMode.NEVER, + replace: false, + value: 'a photo of cat', + expected: undefined } ])( '$label to a forceInput without a widget', - async ({ replace, value, expected }) => { + async ({ mode, replace, value, expected }) => { const { graph, primitive, target } = stringTargetFixture() primitive.connect(0, target, 0) + primitive.mode = mode primitive.properties['Run widget replace on values'] = replace primitive.widgets![0].value = value diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts index 78bdd020abd..c28f143433f 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts @@ -257,13 +257,26 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { `No output node DTO found for id [${outputNodeExecutionId}]` ) - const resolved = outputNodeDto.resolveOutput( - link.origin_slot, - type ?? input.type, - visited + return ( + outputNodeDto.resolveOutput( + link.origin_slot, + type ?? input.type, + visited + ) ?? this._resolveWidgetlessVirtualValue(link, outputNode, outputNodeDto) + ) + } + + private _resolveWidgetlessVirtualValue( + link: LLink, + outputNode: LGraphNode, + outputNodeDto: ExecutableLGraphNode + ): ResolvedInput | undefined { + if (this.node.inputs[link.target_slot]?.widget) return + if ( + outputNodeDto.mode === LGraphEventMode.NEVER || + outputNodeDto.mode === LGraphEventMode.BYPASS ) - // Widget inputs already received the value through applyToGraph - if (resolved || this.node.inputs[link.target_slot]?.widget) return resolved + return const value = outputNode.resolveVirtualValue?.(link.origin_slot) if (value === undefined) return From 7bc87cf0ec05ccf83d8bd0a1081adf160c762cd0 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 19:08:09 +0000 Subject: [PATCH 11/14] test: load the forced input primitive test from a workflow asset The primitive widget is a spinbutton labelled value, so locating an input inside getWidgetByName found nothing and the test timed out. Building the graph through the search box was also flaky. The test now loads a primitive already linked to the forceInput and fills the spinbutton by role. --- .../primitive/primitive_node_force_input.json | 68 +++++++++++++++++++ browser_tests/tests/primitiveNode.spec.ts | 39 ++--------- 2 files changed, 75 insertions(+), 32 deletions(-) create mode 100644 browser_tests/assets/primitive/primitive_node_force_input.json diff --git a/browser_tests/assets/primitive/primitive_node_force_input.json b/browser_tests/assets/primitive/primitive_node_force_input.json new file mode 100644 index 00000000000..05411e22188 --- /dev/null +++ b/browser_tests/assets/primitive/primitive_node_force_input.json @@ -0,0 +1,68 @@ +{ + "last_node_id": 2, + "last_link_id": 1, + "nodes": [ + { + "id": 1, + "type": "PrimitiveNode", + "pos": [50, 50], + "size": [300, 110], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "INT", + "type": "INT", + "links": [1], + "slot_index": 0, + "widget": { + "name": "int_input" + } + } + ], + "properties": { + "Run widget replace on values": false + }, + "widgets_values": [3, "fixed"] + }, + { + "id": 2, + "type": "DevToolsNodeWithForceInput", + "pos": [450, 50], + "size": [315, 110], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "name": "int_input", + "type": "INT", + "link": 1 + }, + { + "name": "float_input", + "type": "FLOAT", + "link": null, + "shape": 7 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "DevToolsNodeWithForceInput" + }, + "widgets_values": [1] + } + ], + "links": [[1, 1, 0, 2, 0, "INT"]], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 1, + "offset": [0, 0] + } + }, + "version": 0.4 +} diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index 6f82bba91b1..2aee9e7b62c 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -155,43 +155,18 @@ test.describe( 'Primitive Node forced inputs', { tag: ['@node', '@vue-nodes'] }, () => { - test.use({ - initialSettings: { - 'Comfy.UseNewMenu': 'Top', - 'Comfy.NodeSearchBoxImpl': 'v1 (legacy)' - } - }) - test('Can serialize to forced inputs', async ({ comfyPage }) => { - await test.step('Add nodes', async () => { - await comfyPage.workflow.newBlankWorkflow() - - await comfyPage.page.mouse.dblclick(250, 500, { delay: 5 }) - await comfyPage.searchBox.fillAndSelectFirstNode('Primitive') - await expect(comfyPage.searchBox.input).toBeHidden() - await comfyPage.page.mouse.dblclick(600, 500, { delay: 5 }) - await comfyPage.searchBox.fillAndSelectFirstNode( - 'Node With Force Input' - ) - }) - - const primitive = await comfyPage.vueNodes.getFixtureByTitle('Primitive') - const node = await comfyPage.vueNodes.getFixtureByTitle( - 'Node With Force Input' + await comfyPage.workflow.loadWorkflow( + 'primitive/primitive_node_force_input' ) + const input = comfyPage.vueNodes + .getNodeByTitle('Primitive') + .getByRole('spinbutton', { name: 'value', exact: true }) + await expect(input).toHaveValue('3') - await test.step('Link nodes', async () => { - await primitive.getSlot('').dragTo(node.getSlot('int_input').first()) - await expect - .poll(() => comfyPage.vueNodes.isSlotConnected(primitive.getSlot(''))) - .toBe(true) - }) - - const { input } = comfyPage.vueNodes.getInputNumberControls( - comfyPage.vueNodes.getWidgetByName('Primitive', 'value') - ) await input.fill('5') await input.blur() + const prompt = await comfyPage.workflow.getExportedWorkflow({ api: true }) const forceInputNode = Object.values(prompt).find( (entry) => entry.class_type === 'DevToolsNodeWithForceInput' From 9eaa21f3636b3ebed921918e36fc2d16997b3bf0 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 19:24:59 +0000 Subject: [PATCH 12/14] fix: declare resolveVirtualValue used in Fallow config instead of inline ExecutableNodeDTO calls the hook through the entity-registry LGraphNode interface, which Fallow does not link to subclass overrides. A scoped usedClassMembers rule replaces the fallow-ignore comment. Text replacement now only runs on string values, so a numeric primitive is no longer stringified. --- .fallowrc.jsonc | 6 ++++++ src/extensions/core/widgetInputs.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc index 6d258e6c429..91b721e9ec5 100644 --- a/.fallowrc.jsonc +++ b/.fallowrc.jsonc @@ -212,6 +212,12 @@ "dupesBaseline": ".fallow-baselines/dupes.json" }, + "usedClassMembers": [ + // ExecutableNodeDTO calls this hook through the entity-registry + // LGraphNode interface, which Fallow does not link to subclass overrides. + { "extends": "LGraphNode", "members": ["resolveVirtualValue"] } + ], + "rules": { "boundary-violation": "warn", "dev-dependencies-in-production": "error" diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index 8501344b4df..fbbc3a7aa5b 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -58,7 +58,6 @@ export class PrimitiveNode extends LGraphNode { ) } - // fallow-ignore-next-line unused-class-member override resolveVirtualValue() { const widget = this.widgets?.[0] if (!widget) return @@ -68,8 +67,10 @@ export class PrimitiveNode extends LGraphNode { } private _applyTextReplacements(value: T): T | string { - return value && this.properties[replacePropertyName] && this.graph - ? applyTextReplacements(this.graph, String(value)) + return typeof value === 'string' && + this.properties[replacePropertyName] && + this.graph + ? applyTextReplacements(this.graph, value) : value } From 54249f6df37d17bf333b763a1a59b9124f87c82f Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 19:25:27 +0000 Subject: [PATCH 13/14] test: cover bypassed primitives and poll the exported prompt The bypass guard had no failing row; the muted row only exercises resolveOutput's early return. The spec now polls the exported prompt after editing the widget instead of reading it once. --- browser_tests/tests/primitiveNode.spec.ts | 18 ++++++++++-------- src/extensions/core/widgetInputs.test.ts | 7 +++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index 2aee9e7b62c..c539be93c29 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -167,14 +167,16 @@ test.describe( await input.fill('5') await input.blur() - const prompt = await comfyPage.workflow.getExportedWorkflow({ api: true }) - const forceInputNode = Object.values(prompt).find( - (entry) => entry.class_type === 'DevToolsNodeWithForceInput' - ) - expect( - forceInputNode?.inputs.int_input, - 'Serialized prompt has primitive value' - ).toBe(5) + await expect + .poll( + async () => + Object.values( + await comfyPage.workflow.getExportedWorkflow({ api: true }) + ).find((entry) => entry.class_type === 'DevToolsNodeWithForceInput') + ?.inputs.int_input, + { message: 'Serialized prompt has primitive value' } + ) + .toBe(5) }) } ) diff --git a/src/extensions/core/widgetInputs.test.ts b/src/extensions/core/widgetInputs.test.ts index 884b09bc1de..13c4bea839d 100644 --- a/src/extensions/core/widgetInputs.test.ts +++ b/src/extensions/core/widgetInputs.test.ts @@ -440,6 +440,13 @@ describe('PrimitiveNode', () => { replace: false, value: 'a photo of cat', expected: undefined + }, + { + label: 'sends nothing while bypassed', + mode: LGraphEventMode.BYPASS, + replace: false, + value: 'a photo of cat', + expected: undefined } ])( '$label to a forceInput without a widget', From 1ce7d0f6936c1eba33caa3253cb9682a1ae5f387 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 16 Nov 2026 15:47:04 -0800 Subject: [PATCH 14/14] fix: keep widget inputs from taking a primitive value through a bypassed node (#23359) ## Summary Stacked on #12201. If a primitive is linked to a bypassed node's forceInput, and that node's output feeds a widget input, the primitive's raw value reached the widget input and skipped the widget's own `serializeValue` (dynamic prompts, `%date%`, curve wrapping). A legacy Reroute without a widget took the same path. Now a widget input discards a primitive's value no matter which hop resolved it, and inputs without a widget, including ones behind a bypass, still receive it. The primitive's resolution is marked with `virtualValue: true`, and the receiving input decides whether to accept it. I didn't pass the final target input down through every `resolveInput`/`resolveOutput` call, because that would change both public signatures. A node-type check couldn't do the job either: subgraph widget values also resolve with a virtual node. ## Verification - A new unit test runs a primitive through a bypassed node into a widget input and a forceInput. - It fails on #12201's head, where the widget input receives the raw value. - It also fails on an over-broad fix that drops every forwarded primitive value. - The affected suites pass (`widgetInputs`, the litegraph subgraph tests, `executionUtil`, `litegraphService`, `customWidgets`, `openOnCloud`), and so do `pnpm typecheck`, oxlint, oxfmt and `fallow audit`. --- src/extensions/core/widgetInputs.test.ts | 30 +++++++++++++++++++ .../src/subgraph/ExecutableNodeDTO.ts | 21 ++++++++----- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/extensions/core/widgetInputs.test.ts b/src/extensions/core/widgetInputs.test.ts index 13c4bea839d..ce4f308ce19 100644 --- a/src/extensions/core/widgetInputs.test.ts +++ b/src/extensions/core/widgetInputs.test.ts @@ -478,6 +478,36 @@ describe('PrimitiveNode', () => { expect(output[String(target.id)].inputs.text).toBe('A PHOTO OF CAT') }) + + it('sends its value through a bypassed node only to inputs without a widget', async () => { + const { graph, primitive, target } = stringTargetFixture() + target.inputs[0].widget = { + name: 'text', + [GET_CONFIG]: () => ['STRING', {}] + } + const widget = target.addWidget('text', 'text', 'own', () => {}) + widget.serializeValue = () => String(widget.value).toUpperCase() + const forceInputTarget = new LGraphNode('ForceInputTarget') + forceInputTarget.comfyClass = 'ForceInputTarget' + graph.add(forceInputTarget) + forceInputTarget.addInput('text', 'STRING') + const bypassed = new LGraphNode('Bypassed') + graph.add(bypassed) + bypassed.addInput('text', 'STRING') + bypassed.addOutput('text', 'STRING') + bypassed.mode = LGraphEventMode.BYPASS + primitive.connect(0, bypassed, 0) + bypassed.connect(0, target, 0) + bypassed.connect(0, forceInputTarget, 0) + primitive.widgets![0].value = 'a photo of cat' + + const { output } = await graphToPrompt(graph) + + expect([ + output[String(target.id)].inputs.text, + output[String(forceInputTarget.id)].inputs.text + ]).toEqual(['OWN', 'a photo of cat']) + }) }) describe('getWidgetConfig', () => { diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts index c28f143433f..84b92060b19 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts @@ -42,6 +42,8 @@ type ResolvedInput = { origin_slot: number /** Boxed widget value (e.g. for widgets). If this box is `undefined`, then an input link is connected, and widget values from the subgraph node are ignored. */ widgetInfo?: { value: unknown } + /** `true` when {@link widgetInfo} is a virtual node's value, which only inputs without a widget accept. */ + virtualValue?: true } /** @@ -257,12 +259,17 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { `No output node DTO found for id [${outputNodeExecutionId}]` ) + const resolved = outputNodeDto.resolveOutput( + link.origin_slot, + type ?? input.type, + visited + ) + if (this.node.inputs[link.target_slot]?.widget) + return resolved?.virtualValue ? undefined : resolved + return ( - outputNodeDto.resolveOutput( - link.origin_slot, - type ?? input.type, - visited - ) ?? this._resolveWidgetlessVirtualValue(link, outputNode, outputNodeDto) + resolved ?? + this._resolveWidgetlessVirtualValue(link, outputNode, outputNodeDto) ) } @@ -271,7 +278,6 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { outputNode: LGraphNode, outputNodeDto: ExecutableLGraphNode ): ResolvedInput | undefined { - if (this.node.inputs[link.target_slot]?.widget) return if ( outputNodeDto.mode === LGraphEventMode.NEVER || outputNodeDto.mode === LGraphEventMode.BYPASS @@ -284,7 +290,8 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { node: outputNodeDto, origin_id: outputNodeDto.id, origin_slot: -1, - widgetInfo: { value } + widgetInfo: { value }, + virtualValue: true } }