In newer versions of ComfyUI Desktop, `app.extensionManager.setting.get()`
may return empty values even when settings are properly configured via
the API. This causes the dynamic field widgets (including image upload
buttons) to fail to load when entering an aiToolsId.
This adds a fallback that fetches settings from the server API
(`/api/settings`) when the frontend settings return empty, ensuring
the dynamic fields load correctly across all ComfyUI versions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Problem: The previous implementation defined 99 optional inputs in Python
and tried to hide/show them in frontend, which didn't work reliably on
ComfyUI Windows version - fields like fieldValue_99 remained visible.
Solution: Complete refactor to dynamically generate widgets:
Backend (TA_AITools.py):
- Remove INPUT_LIM and 99 pre-defined optional inputs
- Add single 'fieldData' STRING field to store serialized field values
- process() parses JSON from fieldData to build fieldInputs
Frontend (ta_aitools.js):
- Remove complex widget hiding logic
- When aiToolsId changes, fetch workflow fields from API
- Dynamically create widgets using node.addWidget()
- Serialize field values to fieldData on each change
- Clean up old widgets when switching workflows
Benefits:
- No more hidden widgets taking up space
- Works reliably on both native and Windows versions
- Cleaner code (304 lines removed, 192 added)
- Node size automatically adjusts to actual field count
Instead of calling toggleWidget which may have complex logic, directly set:
- widget.type = HIDDEN_TAG (to hide the widget)
- widget.computeSize = () => [0, -4] (to collapse its height)
This is a more direct approach to ensure all dynamic fields including
fieldValue_99 are properly hidden on Windows version of ComfyUI.
Instead of using handleWidgetVisibility which looks up widgets by name,
directly iterate through node.widgets array to find and hide all dynamic
fields matching the pattern (fieldValue_*, fieldName_*, nodeId_*).
This ensures that all 99 fields are properly hidden, including fieldValue_99
which was not being hidden due to potential lookup issues in Windows version.
- Increase setTimeout from 100ms to 500ms for Windows version
- Add debug console.log to track resetAIToolsNode execution
- Add setDirtyCanvas call to force refresh after hiding widgets
This helps diagnose why fieldValue_99 is not being hidden on Windows.
1. Add handleInputsVisibility calls in resetAIToolsNode to hide input slots
(left side connectors), not just widgets (right side inputs). This fixes
the issue where node height remained at 99 fields tall.
2. Add null check for aiToolsName widget to prevent potential errors.
3. Move createLogic(node) call into setTimeout to ensure widgets are fully
initialized before hiding, especially important for ComfyUI Windows version
where timing may differ.
TA_AIToolsNode fields (fieldValue_*, fieldName_*, nodeId_*) are defined as
optional inputs in Python, so doesInputWithNameExist() returns true and
prevents them from being hidden. Add special handling to skip this check
for these dynamic fields so they can be properly hidden/shown based on
the aiToolsId response.
This fixes the issue where all 99 fields were displayed and filled the UI,
especially in ComfyUI Windows version.
The ComfyButtonGroup import from buttonGroup.js is deprecated in ComfyUI.
Since the actual usage was already commented out, simply comment out the
import statement to eliminate the deprecation warning.