-
Notifications
You must be signed in to change notification settings - Fork 492
feat(cloud): add asset widget support for PrimitiveNode model selection #8439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
On Comfy Cloud, PrimitiveNode now creates asset widgets (opening Asset Browser) instead of combo widgets for model-eligible inputs like checkpoints, LoRAs, etc. - Add cloud asset widget creation in #createWidget() using isAssetBrowserEligible() - Add #createAssetWidget() helper following useComboWidget.ts pattern - Add #finalizeWidget() helper to DRY up widget sizing/callback setup - Pass target node's comfyClass to Asset Browser for correct model filtering Amp-Thread-ID: https://ampcode.com/threads/T-019c0839-bbdc-754a-9d3b-151417058ded Co-authored-by: Amp <amp@ampcode.com>
- Extract createAssetWidget factory to src/platform/assets/utils/ - Refactor useComboWidget.ts to use the shared factory - Simplify PrimitiveNode to use shared factory - Convert JS # privates to underscore convention - Add knip ignore for isAssetWidget (litegraph public API) Amp-Thread-ID: https://ampcode.com/threads/T-019c0839-bbdc-754a-9d3b-151417058ded Co-authored-by: Amp <amp@ampcode.com>
🎭 Playwright Tests:
|
📝 WalkthroughWalkthroughThis change introduces Cloud asset widget support for combo inputs in PrimitiveNode by refactoring existing private methods from hash-prefixed to underscore notation and adding new asset widget creation flows. A utility function for creating asset widgets is added alongside supporting export documentation to track usage by custom nodes. Changes
Sequence Diagram(s)sequenceDiagram
participant PN as PrimitiveNode
participant CAW as createAssetWidget
participant ABD as AssetBrowserDialog
participant Schema as AssetSchema
PN->>PN: _onFirstConnection (Cloud context,<br/>combo + eligible asset)
PN->>CAW: _createAssetWidget(node, widgetName,<br/>inputData)
CAW->>ABD: useAssetBrowserDialog opens modal
ABD->>ABD: User selects asset
ABD->>Schema: validateAsset(assetItem)
Schema-->>CAW: validation result
CAW->>Schema: getAssetFilename & validate
Schema-->>CAW: filename
CAW->>CAW: widget.value = filename
CAW->>PN: onValueChange callback
PN->>PN: _finalizeWidget(setup callbacks,<br/>adjust node size)
Possibly related PRs
Suggested reviewers
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 26 kB (baseline 26 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 974 kB (baseline 974 kB) • 🟢 -1 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 80.7 kB (baseline 80.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 471 kB (baseline 471 kB) • 🟢 -8 BConfiguration panels, inspectors, and settings screens
Status: 12 added / 12 removed User & Accounts — 3.94 kB (baseline 3.94 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 3 added / 3 removed Editors & Dialogs — 2.89 kB (baseline 2.89 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 33.7 kB (baseline 33.7 kB) • ⚪ 0 BReusable component library chunks
Status: 4 added / 4 removed Data & Services — 2.7 MB (baseline 2.7 MB) • 🔴 +251 BStores, services, APIs, and repositories
Status: 8 added / 8 removed Utilities & Hooks — 25.3 kB (baseline 25.3 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 7 added / 7 removed Vendor & Third-Party — 10.7 MB (baseline 10.7 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 7.1 MB (baseline 7.1 MB) • 🔴 +843 BBundles that do not match a named category
Status: 34 added / 34 removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/extensions/core/widgetInputs.ts`:
- Around line 235-245: The asset-widget early-return path skips copying the
existing target value into the new widget, so when you create an asset widget
via this._createAssetWidget(node, widgetName, inputData) you must sync its
initial value from the node/inputData like other widgets do (so PrimitiveNode
doesn't keep the placeholder). After creating widget (but before
this._finalizeWidget(widget, oldWidth, oldHeight, recreating)), copy the
existing value from the node/inputData target (the same source used by
COMBO/widget creation paths) into widget's value/state; then call
_finalizeWidget as before. Use the same field accessors that other widget paths
use to ensure parity with combo widgets (refer to node, inputData, widget,
_createAssetWidget, and _finalizeWidget).
- Around line 235-241: Import useSettingStore and read the
Comfy.Assets.UseAssetAPI flag (as isUsingAssetAPI) and include it in the
PrimitiveNode asset-widget creation branch so asset widgets are only created
when the toggle is enabled; specifically, update the COMBO handling around the
assetService.isAssetBrowserEligible(...) check in widgetInputs.ts to require
isUsingAssetAPI (match the pattern used in useComboWidget's `if (isUsingAssetAPI
&& isEligible)`) before proceeding with the PrimitiveNode asset widget creation.
| // Cloud: Use asset widget for model-eligible inputs | ||
| if (isCloud && type === 'COMBO') { | ||
| const isEligible = assetService.isAssetBrowserEligible( | ||
| node.comfyClass, | ||
| widgetName | ||
| ) | ||
| if (isEligible) { | ||
| widget = this._createAssetWidget(node, widgetName, inputData) | ||
| this._finalizeWidget(widget, oldWidth, oldHeight, recreating) | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sync existing target widget value for asset widgets.
The asset-widget early return skips the existing-value copy used for other widgets, so PrimitiveNode starts with the placeholder even when the target node already has a model selected. This breaks parity with combo widgets and can mislead users.
✅ Suggested fix
if (isEligible) {
widget = this._createAssetWidget(node, widgetName, inputData)
+ const theirWidget = node.widgets?.find((w) => w.name === widgetName)
+ if (theirWidget) widget.value = theirWidget.value
this._finalizeWidget(widget, oldWidth, oldHeight, recreating)
return
}🤖 Prompt for AI Agents
In `@src/extensions/core/widgetInputs.ts` around lines 235 - 245, The asset-widget
early-return path skips copying the existing target value into the new widget,
so when you create an asset widget via this._createAssetWidget(node, widgetName,
inputData) you must sync its initial value from the node/inputData like other
widgets do (so PrimitiveNode doesn't keep the placeholder). After creating
widget (but before this._finalizeWidget(widget, oldWidth, oldHeight,
recreating)), copy the existing value from the node/inputData target (the same
source used by COMBO/widget creation paths) into widget's value/state; then call
_finalizeWidget as before. Use the same field accessors that other widget paths
use to ensure parity with combo widgets (refer to node, inputData, widget,
_createAssetWidget, and _finalizeWidget).
| // Cloud: Use asset widget for model-eligible inputs | ||
| if (isCloud && type === 'COMBO') { | ||
| const isEligible = assetService.isAssetBrowserEligible( | ||
| node.comfyClass, | ||
| widgetName | ||
| ) | ||
| if (isEligible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
rg -n "Comfy\.Assets\.UseAssetAPI"Repository: Comfy-Org/ComfyUI_frontend
Length of output: 2200
🏁 Script executed:
cat -n src/extensions/core/widgetInputs.ts | sed -n '200,280p'Repository: Comfy-Org/ComfyUI_frontend
Length of output: 2879
🏁 Script executed:
rg -n "useComboWidget|PrimitiveNode" src/extensions/core/widgetInputs.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 421
🏁 Script executed:
cat -n src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.ts | sed -n '165,185p'Repository: Comfy-Org/ComfyUI_frontend
Length of output: 850
🏁 Script executed:
grep -n "_createAssetWidget" src/extensions/core/widgetInputs.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 177
🏁 Script executed:
cat -n src/extensions/core/widgetInputs.ts | sed -n '1,100p'Repository: Comfy-Org/ComfyUI_frontend
Length of output: 4093
🏁 Script executed:
cat -n src/extensions/core/widgetInputs.ts | sed -n '300,330p'Repository: Comfy-Org/ComfyUI_frontend
Length of output: 1139
🏁 Script executed:
grep -n "useSettingStore\|Comfy\.Assets\.UseAssetAPI" src/extensions/core/widgetInputs.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 52
🏁 Script executed:
cat -n src/extensions/core/widgetInputs.ts | sed -n '1,35p'Repository: Comfy-Org/ComfyUI_frontend
Length of output: 1667
🏁 Script executed:
grep -n "_createAssetWidget\|createAssetWidget" src/extensions/core/widgetInputs.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 293
🏁 Script executed:
rg -n "class.*Node.*extends\s+LGraphNode" src/extensions/core/widgetInputs.ts -A 5Repository: Comfy-Org/ComfyUI_frontend
Length of output: 271
Add Comfy.Assets.UseAssetAPI toggle check to PrimitiveNode asset widget creation.
useComboWidget respects this setting (line 179 in useComboWidget.ts: if (isUsingAssetAPI && isEligible)), but PrimitiveNode bypasses it entirely. Lines 236-245 create asset widgets without checking the toggle, causing inconsistent behavior when users disable the asset API. Import useSettingStore and add the toggle check before line 242.
🤖 Prompt for AI Agents
In `@src/extensions/core/widgetInputs.ts` around lines 235 - 241, Import
useSettingStore and read the Comfy.Assets.UseAssetAPI flag (as isUsingAssetAPI)
and include it in the PrimitiveNode asset-widget creation branch so asset
widgets are only created when the toggle is enabled; specifically, update the
COMBO handling around the assetService.isAssetBrowserEligible(...) check in
widgetInputs.ts to require isUsingAssetAPI (match the pattern used in
useComboWidget's `if (isUsingAssetAPI && isEligible)`) before proceeding with
the PrimitiveNode asset widget creation.
|
Replaced by #8454 |

Summary
On Comfy Cloud, PrimitiveNode now creates asset widgets (opening Asset Browser) instead of combo widgets for model-eligible inputs like checkpoints, LoRAs, etc.
Changes
createAssetWidgetfactory tosrc/platform/assets/utils/createAssetWidget.tsuseComboWidget.tsto use the shared factory (eliminates code duplication)PrimitiveNode._createWidget()usingisAssetBrowserEligible()comfyClassto Asset Browser for correct model filteringisAssetWidget(litegraph public API)Testing
Fixes model selection issue in PrimitiveNode on Comfy Cloud.
┆Issue is synchronized with this Notion page by Unito