Skip to content

Commit 59736c6

Browse files
authored
feat: create toggle command for AssetAPI (#5918)
## Summary Taking inspiration from VueNodes to make testing easier ## Changes 1. Add a toggle to enable/disable AssetAPI 2. If you have the Model Browser bound, it will prompt to enable the AssetAPI if you try to use it. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5918-feat-create-toggle-command-for-AssetAPI-2826d73d365081539aeaf3951928fdc1) by [Unito](https://www.unito.io)
1 parent 84e6e99 commit 59736c6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/composables/useCoreCommands.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,23 @@ export function useCoreCommands(): ComfyCommand[] {
10681068
{
10691069
id: 'Comfy.BrowseModelAssets',
10701070
icon: 'pi pi-folder-open',
1071-
label: 'Browse Model Assets',
1071+
label: 'Experimental: Browse Model Assets',
10721072
versionAdded: '1.28.3',
10731073
function: async () => {
1074+
if (!useSettingStore().get('Comfy.Assets.UseAssetAPI')) {
1075+
const confirmed = await dialogService.confirm({
1076+
title: 'Enable Asset API',
1077+
message:
1078+
'The Asset API is currently disabled. Would you like to enable it?',
1079+
type: 'default'
1080+
})
1081+
1082+
if (!confirmed) return
1083+
1084+
const settingStore = useSettingStore()
1085+
await settingStore.set('Comfy.Assets.UseAssetAPI', true)
1086+
await workflowService.reloadCurrentWorkflow()
1087+
}
10741088
const assetBrowserDialog = useAssetBrowserDialog()
10751089
await assetBrowserDialog.browse({
10761090
assetType: 'models',
@@ -1088,6 +1102,22 @@ export function useCoreCommands(): ComfyCommand[] {
10881102
}
10891103
})
10901104
}
1105+
},
1106+
{
1107+
id: 'Comfy.ToggleAssetAPI',
1108+
icon: 'pi pi-database',
1109+
label: () =>
1110+
`Experimental: ${
1111+
useSettingStore().get('Comfy.Assets.UseAssetAPI')
1112+
? 'Disable'
1113+
: 'Enable'
1114+
} AssetAPI`,
1115+
function: async () => {
1116+
const settingStore = useSettingStore()
1117+
const current = settingStore.get('Comfy.Assets.UseAssetAPI') ?? false
1118+
await settingStore.set('Comfy.Assets.UseAssetAPI', !current)
1119+
await useWorkflowService().reloadCurrentWorkflow() // ensure changes take effect immediately
1120+
}
10911121
}
10921122
]
10931123

0 commit comments

Comments
 (0)