Add Asset Widget (#5475)

* [feat] carve out path to call asset browser in combo widget

* Add Asset Widget

* [feat] add fallback "Select model" label

---------

Co-authored-by: Arjan Singh <arjan@comfy.org>
This commit is contained in:
AustinMroz
2025-09-11 12:00:34 -07:00
committed by GitHub
parent 08fe2829d4
commit 3bc25b7aeb
5 changed files with 139 additions and 24 deletions

View File

@@ -69,19 +69,15 @@ const addComboWidget = (
)
if (isUsingAssetAPI && isEligible) {
// Create button widget for Asset Browser
// Get the default value for the button text (currently selected model)
const currentValue = getDefaultValue(inputSpec)
const displayLabel = currentValue ?? t('widgets.selectModel')
const widget = node.addWidget(
'button',
inputSpec.name,
t('widgets.selectModel'),
() => {
console.log(
`Asset Browser would open here for:\nNode: ${node.type}\nWidget: ${inputSpec.name}\nCurrent Value:${currentValue}`
)
}
)
const widget = node.addWidget('asset', inputSpec.name, displayLabel, () => {
console.log(
`Asset Browser would open here for:\nNode: ${node.type}\nWidget: ${inputSpec.name}\nCurrent Value:${currentValue}`
)
})
return widget
}
@@ -129,7 +125,7 @@ const addComboWidget = (
)
}
return widget
return widget as IBaseWidget
}
export const useComboWidget = () => {