diff --git a/src/composables/graph/useGraphNodeManager.ts b/src/composables/graph/useGraphNodeManager.ts index 7a7a5900f7..0c2feb93fd 100644 --- a/src/composables/graph/useGraphNodeManager.ts +++ b/src/composables/graph/useGraphNodeManager.ts @@ -324,7 +324,8 @@ function safeWidgetMapper( } : (extractWidgetDisplayOptions(effectiveWidget) ?? options), slotMetadata: slotInfo, - slotName: name !== widget.name ? widget.name : undefined + slotName: name !== widget.name ? widget.name : undefined, + tooltip: widget.tooltip } } catch (error) { return { diff --git a/src/core/graph/widgets/dynamicWidgets.test.ts b/src/core/graph/widgets/dynamicWidgets.test.ts index 0252691d13..41b34b4fa9 100644 --- a/src/core/graph/widgets/dynamicWidgets.test.ts +++ b/src/core/graph/widgets/dynamicWidgets.test.ts @@ -27,7 +27,7 @@ function addDynamicCombo(node: LGraphNode, inputs: DynamicInputs) { `${namePrefix}.${depth}.${inputIndex}`, Array.isArray(input) ? ['COMFY_DYNAMICCOMBO_V3', { options: getSpec(input, depth + 1) }] - : [input, {}] + : [input, { tooltip: `${groupIndex}` }] ]) return { key: `${groupIndex}`, @@ -106,6 +106,13 @@ describe('Dynamic Combos', () => { expect(node.inputs[1].name).toBe('0.0.0.0') expect(node.inputs[3].name).toBe('2.2.0.0') }) + test('Dynamically added widgets have tooltips', () => { + const node = testNode() + addDynamicCombo(node, [['INT'], ['STRING']]) + expect.soft(node.widgets[1].tooltip).toBe('0') + node.widgets[0].value = '1' + expect.soft(node.widgets[1].tooltip).toBe('1') + }) }) describe('Autogrow', () => { const inputsSpec = { required: { image: ['IMAGE', {}] } } diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 92205ab442..0ad11d54af 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -216,14 +216,18 @@ export const useLitegraphService = () => { */ function addNodeInput(node: LGraphNode, inputSpec: InputSpec) { addInputSocket(node, inputSpec) - addInputWidget(node, inputSpec) + addInputWidget(node, inputSpec, { dynamic: true }) } /** * @internal Add a widget to the node. For both primitive types and custom widgets * (unless `socketless`), an input socket is also added. */ - function addInputWidget(node: LGraphNode, inputSpec: InputSpec) { + function addInputWidget( + node: LGraphNode, + inputSpec: InputSpec, + { dynamic }: { dynamic?: boolean } = {} + ) { const widgetInputSpec = { ...inputSpec } if (inputSpec.widgetType) { widgetInputSpec.type = inputSpec.widgetType @@ -254,6 +258,7 @@ export const useLitegraphService = () => { advanced: inputSpec.advanced, hidden: inputSpec.hidden }) + if (dynamic) widget.tooltip = inputSpec.tooltip } if (!widget?.options?.socketless) { diff --git a/src/types/simplifiedWidget.ts b/src/types/simplifiedWidget.ts index 4e0f486662..10ba258ce9 100644 --- a/src/types/simplifiedWidget.ts +++ b/src/types/simplifiedWidget.ts @@ -74,6 +74,8 @@ export interface SimplifiedWidget< /** Optional input specification backing this widget */ spec?: InputSpecV2 + tooltip?: string + controlWidget?: SafeControlWidget }