Skip to content

Commit a498556

Browse files
feat: add advanced parameter to Input classes for advanced widgets support (Comfy-Org#11939)
Add 'advanced' boolean parameter to Input and WidgetInput base classes and propagate to all typed Input subclasses (Boolean, Int, Float, String, Combo, MultiCombo, Webcam, MultiType, MatchType, ImageCompare). When set to True, the frontend will hide these inputs by default in a collapsible 'Advanced Inputs' section in the right side panel, reducing visual clutter for power-user options. This enables nodes to expose advanced configuration options (like encoding parameters, quality settings, etc.) without overwhelming typical users. Frontend support: ComfyUI_frontend PR Comfy-Org#7812
1 parent f7ca41f commit a498556

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

comfy_api/latest/_io.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Input(_IO_V3):
153153
'''
154154
Base class for a V3 Input.
155155
'''
156-
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None):
156+
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
157157
super().__init__()
158158
self.id = id
159159
self.display_name = display_name
@@ -162,6 +162,7 @@ def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str
162162
self.lazy = lazy
163163
self.extra_dict = extra_dict if extra_dict is not None else {}
164164
self.rawLink = raw_link
165+
self.advanced = advanced
165166

166167
def as_dict(self):
167168
return prune_dict({
@@ -170,6 +171,7 @@ def as_dict(self):
170171
"tooltip": self.tooltip,
171172
"lazy": self.lazy,
172173
"rawLink": self.rawLink,
174+
"advanced": self.advanced,
173175
}) | prune_dict(self.extra_dict)
174176

175177
def get_io_type(self):
@@ -184,8 +186,8 @@ class WidgetInput(Input):
184186
'''
185187
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
186188
default: Any=None,
187-
socketless: bool=None, widget_type: str=None, force_input: bool=None, extra_dict=None, raw_link: bool=None):
188-
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link)
189+
socketless: bool=None, widget_type: str=None, force_input: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
190+
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link, advanced)
189191
self.default = default
190192
self.socketless = socketless
191193
self.widget_type = widget_type
@@ -242,8 +244,8 @@ class Input(WidgetInput):
242244
'''Boolean input.'''
243245
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
244246
default: bool=None, label_on: str=None, label_off: str=None,
245-
socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None):
246-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link)
247+
socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
248+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link, advanced)
247249
self.label_on = label_on
248250
self.label_off = label_off
249251
self.default: bool
@@ -262,8 +264,8 @@ class Input(WidgetInput):
262264
'''Integer input.'''
263265
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
264266
default: int=None, min: int=None, max: int=None, step: int=None, control_after_generate: bool=None,
265-
display_mode: NumberDisplay=None, socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None):
266-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link)
267+
display_mode: NumberDisplay=None, socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
268+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link, advanced)
267269
self.min = min
268270
self.max = max
269271
self.step = step
@@ -288,8 +290,8 @@ class Input(WidgetInput):
288290
'''Float input.'''
289291
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
290292
default: float=None, min: float=None, max: float=None, step: float=None, round: float=None,
291-
display_mode: NumberDisplay=None, socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None):
292-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link)
293+
display_mode: NumberDisplay=None, socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
294+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link, advanced)
293295
self.min = min
294296
self.max = max
295297
self.step = step
@@ -314,8 +316,8 @@ class Input(WidgetInput):
314316
'''String input.'''
315317
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
316318
multiline=False, placeholder: str=None, default: str=None, dynamic_prompts: bool=None,
317-
socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None):
318-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link)
319+
socketless: bool=None, force_input: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
320+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, force_input, extra_dict, raw_link, advanced)
319321
self.multiline = multiline
320322
self.placeholder = placeholder
321323
self.dynamic_prompts = dynamic_prompts
@@ -350,12 +352,13 @@ def __init__(
350352
socketless: bool=None,
351353
extra_dict=None,
352354
raw_link: bool=None,
355+
advanced: bool=None,
353356
):
354357
if isinstance(options, type) and issubclass(options, Enum):
355358
options = [v.value for v in options]
356359
if isinstance(default, Enum):
357360
default = default.value
358-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, None, extra_dict, raw_link)
361+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, None, extra_dict, raw_link, advanced)
359362
self.multiselect = False
360363
self.options = options
361364
self.control_after_generate = control_after_generate
@@ -387,8 +390,8 @@ class MultiCombo(ComfyTypeI):
387390
class Input(Combo.Input):
388391
def __init__(self, id: str, options: list[str], display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
389392
default: list[str]=None, placeholder: str=None, chip: bool=None, control_after_generate: bool=None,
390-
socketless: bool=None, extra_dict=None, raw_link: bool=None):
391-
super().__init__(id, options, display_name, optional, tooltip, lazy, default, control_after_generate, socketless=socketless, extra_dict=extra_dict, raw_link=raw_link)
393+
socketless: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
394+
super().__init__(id, options, display_name, optional, tooltip, lazy, default, control_after_generate, socketless=socketless, extra_dict=extra_dict, raw_link=raw_link, advanced=advanced)
392395
self.multiselect = True
393396
self.placeholder = placeholder
394397
self.chip = chip
@@ -421,9 +424,9 @@ class Input(WidgetInput):
421424
Type = str
422425
def __init__(
423426
self, id: str, display_name: str=None, optional=False,
424-
tooltip: str=None, lazy: bool=None, default: str=None, socketless: bool=None, extra_dict=None, raw_link: bool=None
427+
tooltip: str=None, lazy: bool=None, default: str=None, socketless: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None
425428
):
426-
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, None, extra_dict, raw_link)
429+
super().__init__(id, display_name, optional, tooltip, lazy, default, socketless, None, None, extra_dict, raw_link, advanced)
427430

428431

429432
@comfytype(io_type="MASK")
@@ -776,7 +779,7 @@ class Input(Input):
776779
'''
777780
Input that permits more than one input type; if `id` is an instance of `ComfyType.Input`, then that input will be used to create a widget (if applicable) with overridden values.
778781
'''
779-
def __init__(self, id: str | Input, types: list[type[_ComfyType] | _ComfyType], display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None):
782+
def __init__(self, id: str | Input, types: list[type[_ComfyType] | _ComfyType], display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
780783
# if id is an Input, then use that Input with overridden values
781784
self.input_override = None
782785
if isinstance(id, Input):
@@ -789,7 +792,7 @@ def __init__(self, id: str | Input, types: list[type[_ComfyType] | _ComfyType],
789792
# if is a widget input, make sure widget_type is set appropriately
790793
if isinstance(self.input_override, WidgetInput):
791794
self.input_override.widget_type = self.input_override.get_io_type()
792-
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link)
795+
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link, advanced)
793796
self._io_types = types
794797

795798
@property
@@ -843,8 +846,8 @@ def as_dict(self):
843846

844847
class Input(Input):
845848
def __init__(self, id: str, template: MatchType.Template,
846-
display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None):
847-
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link)
849+
display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None, raw_link: bool=None, advanced: bool=None):
850+
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict, raw_link, advanced)
848851
self.template = template
849852

850853
def as_dict(self):
@@ -1119,8 +1122,8 @@ class ImageCompare(ComfyTypeI):
11191122

11201123
class Input(WidgetInput):
11211124
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None,
1122-
socketless: bool=True):
1123-
super().__init__(id, display_name, optional, tooltip, None, None, socketless)
1125+
socketless: bool=True, advanced: bool=None):
1126+
super().__init__(id, display_name, optional, tooltip, None, None, socketless, None, None, None, None, advanced)
11241127

11251128
def as_dict(self):
11261129
return super().as_dict()

0 commit comments

Comments
 (0)