From dc5d7ea1be372816dec6099f58d9ee822d5efa59 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Fri, 11 Apr 2025 12:19:22 -0400 Subject: [PATCH] [lint] Enforce @typescript-eslint/no-floating-promises (#3402) --- eslint.config.js | 19 +++++--- src/components/actionbar/ComfyActionbar.vue | 4 +- src/components/actionbar/ComfyQueueButton.vue | 4 +- .../tabs/terminal/CommandTerminal.vue | 6 +-- .../tabs/terminal/LogsTerminal.vue | 6 +-- src/components/common/EditableText.vue | 4 +- src/components/common/TreeExplorer.vue | 4 +- .../common/__tests__/UrlInput.test.ts | 14 +++--- .../dialog/content/MissingModelsWarning.vue | 7 ++- .../content/manager/ManagerDialogContent.vue | 14 +++--- .../content/setting/ColorPaletteMessage.vue | 2 +- .../content/setting/CurrentUserMessage.vue | 4 +- .../dialog/content/setting/ExtensionPanel.vue | 16 +++---- .../content/setting/FirstTimeUIMessage.vue | 4 +- .../content/setting/KeybindingPanel.vue | 12 ++--- .../content/setting/ServerConfigPanel.vue | 12 ++--- .../dialog/content/setting/SettingItem.vue | 4 +- .../dialog/footer/ManagerProgressFooter.vue | 4 +- src/components/graph/GraphCanvas.vue | 10 ++-- src/components/graph/GraphCanvasMenu.vue | 4 +- .../install/InstallLocationPicker.vue | 4 +- src/components/load3d/Load3DScene.vue | 4 +- src/components/searchbox/NodeSearchBox.vue | 8 ++-- src/components/sidebar/SidebarLogoutIcon.vue | 4 +- .../sidebar/SidebarThemeToggleIcon.vue | 4 +- .../sidebar/tabs/ModelLibrarySidebarTab.vue | 7 ++- .../sidebar/tabs/NodeLibrarySidebarTab.vue | 17 ++++--- .../sidebar/tabs/QueueSidebarTab.vue | 13 +++-- .../sidebar/tabs/WorkflowsSidebarTab.vue | 22 +++++---- .../tabs/modelLibrary/ModelTreeLeaf.vue | 8 ++-- .../nodeLibrary/NodeBookmarkTreeExplorer.vue | 30 +++++++----- .../sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue | 6 +-- .../toast/RerouteMigrationToast.vue | 4 +- src/components/topbar/WorkflowTab.vue | 4 +- src/components/topbar/WorkflowTabs.vue | 48 +++++++++---------- src/composables/node/useNodeDragAndDrop.ts | 4 +- src/composables/node/useNodePaste.ts | 4 +- src/composables/nodePack/useWorkflowPacks.ts | 2 +- src/composables/useCanvasDrop.ts | 4 +- src/composables/useCoreCommands.ts | 47 +++++++++--------- src/composables/useDownload.ts | 3 +- src/composables/useRefreshableSelection.ts | 2 +- src/composables/useServerLogs.ts | 14 +++--- src/composables/widgets/useRemoteWidget.ts | 20 ++++---- src/services/autoQueueService.ts | 7 +-- src/services/colorPaletteService.ts | 20 ++++---- src/services/extensionService.ts | 2 +- src/services/litegraphService.ts | 2 +- src/stores/comfyManagerStore.ts | 6 +-- src/stores/nodeBookmarkStore.ts | 46 +++++++++--------- src/stores/workflowStore.ts | 14 +++--- src/utils/linkFixer.ts | 2 +- src/views/DownloadGitView.vue | 4 +- src/views/GraphView.vue | 6 ++- src/views/InstallView.vue | 4 +- src/views/MetricsConsentView.vue | 2 +- src/views/NotSupportedView.vue | 4 +- src/views/UserSelectView.vue | 4 +- src/views/WelcomeView.vue | 4 +- .../tests/composables/useServerLogs.test.ts | 20 ++++---- 60 files changed, 305 insertions(+), 279 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 660f911d1..a43028f72 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -20,6 +20,13 @@ export default [ globals: { ...globals.browser, __COMFYUI_FRONTEND_VERSION__: 'readonly' + }, + parser: tseslint.parser, + parserOptions: { + project: './tsconfig.json', + ecmaVersion: 2020, + sourceType: 'module', + extraFileExtensions: ['.vue'] } } }, @@ -28,13 +35,10 @@ export default [ ...pluginVue.configs['flat/essential'], { files: ['src/**/*.vue'], - languageOptions: { parserOptions: { parser: tseslint.parser } } - }, - { - rules: { - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/prefer-as-const': 'off' + languageOptions: { + parserOptions: { + parser: tseslint.parser + } } }, { @@ -42,6 +46,7 @@ export default [ 'unused-imports': unusedImports }, rules: { + '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/prefer-as-const': 'off', diff --git a/src/components/actionbar/ComfyActionbar.vue b/src/components/actionbar/ComfyActionbar.vue index 8c150a32c..df57c0a22 100644 --- a/src/components/actionbar/ComfyActionbar.vue +++ b/src/components/actionbar/ComfyActionbar.vue @@ -89,9 +89,9 @@ const setInitialPosition = () => { } } onMounted(setInitialPosition) -watch(visible, (newVisible) => { +watch(visible, async (newVisible) => { if (newVisible) { - nextTick(setInitialPosition) + await nextTick(setInitialPosition) } }) diff --git a/src/components/actionbar/ComfyQueueButton.vue b/src/components/actionbar/ComfyQueueButton.vue index e23243c13..7e08892e5 100644 --- a/src/components/actionbar/ComfyQueueButton.vue +++ b/src/components/actionbar/ComfyQueueButton.vue @@ -135,12 +135,12 @@ const hasPendingTasks = computed( ) const commandStore = useCommandStore() -const queuePrompt = (e: Event) => { +const queuePrompt = async (e: Event) => { const commandId = 'shiftKey' in e && e.shiftKey ? 'Comfy.QueuePromptFront' : 'Comfy.QueuePrompt' - commandStore.execute(commandId) + await commandStore.execute(commandId) } diff --git a/src/components/bottomPanel/tabs/terminal/CommandTerminal.vue b/src/components/bottomPanel/tabs/terminal/CommandTerminal.vue index 6950ca892..c439750f9 100644 --- a/src/components/bottomPanel/tabs/terminal/CommandTerminal.vue +++ b/src/components/bottomPanel/tabs/terminal/CommandTerminal.vue @@ -24,17 +24,17 @@ const terminalCreated = ( root, autoRows: true, autoCols: true, - onResize: () => { + onResize: async () => { // If we aren't visible, don't resize if (!terminal.element?.offsetParent) return - terminalApi.resize(terminal.cols, terminal.rows) + await terminalApi.resize(terminal.cols, terminal.rows) } }) onMounted(async () => { offData = terminal.onData(async (message: string) => { - terminalApi.write(message) + await terminalApi.write(message) }) offOutput = terminalApi.onOutput((message) => { diff --git a/src/components/bottomPanel/tabs/terminal/LogsTerminal.vue b/src/components/bottomPanel/tabs/terminal/LogsTerminal.vue index 5d17ec326..8b499086d 100644 --- a/src/components/bottomPanel/tabs/terminal/LogsTerminal.vue +++ b/src/components/bottomPanel/tabs/terminal/LogsTerminal.vue @@ -57,7 +57,7 @@ const terminalCreated = ( if (!clientId.value) { await until(clientId).not.toBeNull() } - api.subscribeLogs(true) + await api.subscribeLogs(true) api.addEventListener('logs', logReceived) } @@ -76,9 +76,9 @@ const terminalCreated = ( loading.value = false }) - onUnmounted(() => { + onUnmounted(async () => { if (api.clientId) { - api.subscribeLogs(false) + await api.subscribeLogs(false) } api.removeEventListener('logs', logReceived) }) diff --git a/src/components/common/EditableText.vue b/src/components/common/EditableText.vue index 6513f8169..c4154ebeb 100644 --- a/src/components/common/EditableText.vue +++ b/src/components/common/EditableText.vue @@ -45,10 +45,10 @@ const finishEditing = () => { } watch( () => isEditing, - (newVal) => { + async (newVal) => { if (newVal) { inputValue.value = modelValue - nextTick(() => { + await nextTick(() => { if (!inputRef.value) return const fileName = inputValue.value.includes('.') ? inputValue.value.split('.').slice(0, -1).join('.') diff --git a/src/components/common/TreeExplorer.vue b/src/components/common/TreeExplorer.vue index 0dadfc5c0..caa1f4afe 100644 --- a/src/components/common/TreeExplorer.vue +++ b/src/components/common/TreeExplorer.vue @@ -186,9 +186,9 @@ const menuItems = computed(() => { label: t('g.delete'), icon: 'pi pi-trash', - command: () => { + command: async () => { if (menuTargetNode.value) { - deleteCommand(menuTargetNode.value) + await deleteCommand(menuTargetNode.value) } }, visible: menuTargetNode.value?.handleDelete !== undefined, diff --git a/src/components/common/__tests__/UrlInput.test.ts b/src/components/common/__tests__/UrlInput.test.ts index 9bbac4b71..4fda49643 100644 --- a/src/components/common/__tests__/UrlInput.test.ts +++ b/src/components/common/__tests__/UrlInput.test.ts @@ -60,7 +60,7 @@ describe('UrlInput', () => { }) }) - wrapper.setProps({ modelValue: 'https://test.com' }) + await wrapper.setProps({ modelValue: 'https://test.com' }) await nextTick() await nextTick() @@ -74,7 +74,7 @@ describe('UrlInput', () => { validateUrlFn: () => Promise.resolve(true) }) - wrapper.setProps({ modelValue: 'https://test.com' }) + await wrapper.setProps({ modelValue: 'https://test.com' }) await nextTick() await nextTick() @@ -88,7 +88,7 @@ describe('UrlInput', () => { validateUrlFn: () => Promise.resolve(false) }) - wrapper.setProps({ modelValue: 'https://test.com' }) + await wrapper.setProps({ modelValue: 'https://test.com' }) await nextTick() await nextTick() @@ -141,14 +141,14 @@ describe('UrlInput', () => { } }) - wrapper.setProps({ modelValue: 'https://test.com' }) + await wrapper.setProps({ modelValue: 'https://test.com' }) await nextTick() await nextTick() // Trigger multiple validations in quick succession - wrapper.find('.pi-spinner').trigger('click') - wrapper.find('.pi-spinner').trigger('click') - wrapper.find('.pi-spinner').trigger('click') + await wrapper.find('.pi-spinner').trigger('click') + await wrapper.find('.pi-spinner').trigger('click') + await wrapper.find('.pi-spinner').trigger('click') await nextTick() await nextTick() diff --git a/src/components/dialog/content/MissingModelsWarning.vue b/src/components/dialog/content/MissingModelsWarning.vue index c4f018c92..df1c7d470 100644 --- a/src/components/dialog/content/MissingModelsWarning.vue +++ b/src/components/dialog/content/MissingModelsWarning.vue @@ -129,9 +129,12 @@ const missingModels = computed(() => { }) }) -onBeforeUnmount(() => { +onBeforeUnmount(async () => { if (doNotAskAgain.value) { - useSettingStore().set('Comfy.Workflow.ShowMissingModelsWarning', false) + await useSettingStore().set( + 'Comfy.Workflow.ShowMissingModelsWarning', + false + ) } }) diff --git a/src/components/dialog/content/manager/ManagerDialogContent.vue b/src/components/dialog/content/manager/ManagerDialogContent.vue index e45920e43..cce3c3ba5 100644 --- a/src/components/dialog/content/manager/ManagerDialogContent.vue +++ b/src/components/dialog/content/manager/ManagerDialogContent.vue @@ -222,13 +222,13 @@ const filterOutdatedPacks = (packs: components['schemas']['Node'][]) => watch( [isUpdateAvailableTab, installedPacks], - () => { + async () => { if (!isUpdateAvailableTab.value) return if (!isEmptySearch.value) { displayPacks.value = filterOutdatedPacks(installedPacks.value) } else if (!installedPacks.value.length) { - startFetchInstalled() + await startFetchInstalled() } else { displayPacks.value = filterOutdatedPacks(installedPacks.value) } @@ -238,7 +238,7 @@ watch( watch( [isInstalledTab, installedPacks], - () => { + async () => { if (!isInstalledTab.value) return if (!isEmptySearch.value) { @@ -248,7 +248,7 @@ watch( !installedPacksReady.value && !isLoadingInstalled.value ) { - startFetchInstalled() + await startFetchInstalled() } else { displayPacks.value = installedPacks.value } @@ -258,7 +258,7 @@ watch( watch( [isMissingTab, isWorkflowTab, workflowPacks, installedPacks], - () => { + async () => { if (!isWorkflowTab.value && !isMissingTab.value) return if (!isEmptySearch.value) { @@ -270,9 +270,9 @@ watch( !isLoadingWorkflow.value && !workflowPacksReady.value ) { - startFetchWorkflowPacks() + await startFetchWorkflowPacks() if (isMissingTab.value) { - startFetchInstalled() + await startFetchInstalled() } } else { displayPacks.value = isMissingTab.value diff --git a/src/components/dialog/content/setting/ColorPaletteMessage.vue b/src/components/dialog/content/setting/ColorPaletteMessage.vue index 25d246e05..08c51c998 100644 --- a/src/components/dialog/content/setting/ColorPaletteMessage.vue +++ b/src/components/dialog/content/setting/ColorPaletteMessage.vue @@ -55,7 +55,7 @@ const { palettes, activePaletteId } = storeToRefs(colorPaletteStore) const importCustomPalette = async () => { const palette = await colorPaletteService.importColorPalette() if (palette) { - settingStore.set('Comfy.ColorPalette', palette.id) + await settingStore.set('Comfy.ColorPalette', palette.id) } } diff --git a/src/components/dialog/content/setting/CurrentUserMessage.vue b/src/components/dialog/content/setting/CurrentUserMessage.vue index 6c1487410..10e57446a 100644 --- a/src/components/dialog/content/setting/CurrentUserMessage.vue +++ b/src/components/dialog/content/setting/CurrentUserMessage.vue @@ -22,8 +22,8 @@ import Message from 'primevue/message' import { useUserStore } from '@/stores/userStore' const userStore = useUserStore() -const logout = () => { - userStore.logout() +const logout = async () => { + await userStore.logout() window.location.reload() } diff --git a/src/components/dialog/content/setting/ExtensionPanel.vue b/src/components/dialog/content/setting/ExtensionPanel.vue index 6d08d68a6..9c86df3fd 100644 --- a/src/components/dialog/content/setting/ExtensionPanel.vue +++ b/src/components/dialog/content/setting/ExtensionPanel.vue @@ -116,44 +116,44 @@ const hasChanges = computed(() => { return changedExtensions.value.length > 0 }) -const updateExtensionStatus = () => { +const updateExtensionStatus = async () => { const editingDisabledExtensionNames = Object.entries( editingEnabledExtensions.value ) .filter(([_, enabled]) => !enabled) .map(([name]) => name) - settingStore.set('Comfy.Extension.Disabled', [ + await settingStore.set('Comfy.Extension.Disabled', [ ...extensionStore.inactiveDisabledExtensionNames, ...editingDisabledExtensionNames ]) } -const enableAllExtensions = () => { +const enableAllExtensions = async () => { extensionStore.extensions.forEach((ext) => { if (extensionStore.isExtensionReadOnly(ext.name)) return editingEnabledExtensions.value[ext.name] = true }) - updateExtensionStatus() + await updateExtensionStatus() } -const disableAllExtensions = () => { +const disableAllExtensions = async () => { extensionStore.extensions.forEach((ext) => { if (extensionStore.isExtensionReadOnly(ext.name)) return editingEnabledExtensions.value[ext.name] = false }) - updateExtensionStatus() + await updateExtensionStatus() } -const disableThirdPartyExtensions = () => { +const disableThirdPartyExtensions = async () => { extensionStore.extensions.forEach((ext) => { if (extensionStore.isCoreExtension(ext.name)) return editingEnabledExtensions.value[ext.name] = false }) - updateExtensionStatus() + await updateExtensionStatus() } const applyChanges = () => { diff --git a/src/components/dialog/content/setting/FirstTimeUIMessage.vue b/src/components/dialog/content/setting/FirstTimeUIMessage.vue index fa2de09a4..82794923f 100644 --- a/src/components/dialog/content/setting/FirstTimeUIMessage.vue +++ b/src/components/dialog/content/setting/FirstTimeUIMessage.vue @@ -18,9 +18,9 @@ import { useSettingStore } from '@/stores/settingStore' const settingStore = useSettingStore() const show = computed(() => !settingStore.exists('Comfy.UseNewMenu')) -const handleClose = () => { +const handleClose = async () => { // Explicitly write the current value to the store. const currentValue = settingStore.get('Comfy.UseNewMenu') - settingStore.set('Comfy.UseNewMenu', currentValue) + await settingStore.set('Comfy.UseNewMenu', currentValue) } diff --git a/src/components/dialog/content/setting/KeybindingPanel.vue b/src/components/dialog/content/setting/KeybindingPanel.vue index f96cfab47..b7137fb8a 100644 --- a/src/components/dialog/content/setting/KeybindingPanel.vue +++ b/src/components/dialog/content/setting/KeybindingPanel.vue @@ -211,14 +211,14 @@ watchEffect(() => { } }) -function removeKeybinding(commandData: ICommandData) { +async function removeKeybinding(commandData: ICommandData) { if (commandData.keybinding) { keybindingStore.unsetKeybinding(commandData.keybinding) - keybindingService.persistUserKeybindings() + await keybindingService.persistUserKeybindings() } } -function captureKeybinding(event: KeyboardEvent) { +async function captureKeybinding(event: KeyboardEvent) { // Allow the use of keyboard shortcuts when adding keyboard shortcuts if (!event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) { switch (event.key) { @@ -226,7 +226,7 @@ function captureKeybinding(event: KeyboardEvent) { cancelEdit() return case 'Enter': - saveKeybinding() + await saveKeybinding() return } } @@ -240,7 +240,7 @@ function cancelEdit() { newBindingKeyCombo.value = null } -function saveKeybinding() { +async function saveKeybinding() { if (currentEditingCommand.value && newBindingKeyCombo.value) { const updated = keybindingStore.updateKeybindingOnCommand( new KeybindingImpl({ @@ -249,7 +249,7 @@ function saveKeybinding() { }) ) if (updated) { - keybindingService.persistUserKeybindings() + await keybindingService.persistUserKeybindings() } } cancelEdit() diff --git a/src/components/dialog/content/setting/ServerConfigPanel.vue b/src/components/dialog/content/setting/ServerConfigPanel.vue index 19067d60c..57fa46f80 100644 --- a/src/components/dialog/content/setting/ServerConfigPanel.vue +++ b/src/components/dialog/content/setting/ServerConfigPanel.vue @@ -97,16 +97,16 @@ const revertChanges = () => { serverConfigStore.revertChanges() } -const restartApp = () => { - electronAPI().restartApp() +const restartApp = async () => { + await electronAPI().restartApp() } -watch(launchArgs, (newVal) => { - settingStore.set('Comfy.Server.LaunchArgs', newVal) +watch(launchArgs, async (newVal) => { + await settingStore.set('Comfy.Server.LaunchArgs', newVal) }) -watch(serverConfigValues, (newVal) => { - settingStore.set('Comfy.Server.ServerConfigValues', newVal) +watch(serverConfigValues, async (newVal) => { + await settingStore.set('Comfy.Server.ServerConfigValues', newVal) }) const { copyToClipboard } = useCopyToClipboard() diff --git a/src/components/dialog/content/setting/SettingItem.vue b/src/components/dialog/content/setting/SettingItem.vue index c081f044c..30eb5c9b4 100644 --- a/src/components/dialog/content/setting/SettingItem.vue +++ b/src/components/dialog/content/setting/SettingItem.vue @@ -69,7 +69,7 @@ const formItem = computed(() => { const settingStore = useSettingStore() const settingValue = computed(() => settingStore.get(props.setting.id)) -const updateSettingValue = (value: any) => { - settingStore.set(props.setting.id, value) +const updateSettingValue = async (value: any) => { + await settingStore.set(props.setting.id, value) } diff --git a/src/components/dialog/footer/ManagerProgressFooter.vue b/src/components/dialog/footer/ManagerProgressFooter.vue index 62e860ac8..420645b62 100644 --- a/src/components/dialog/footer/ManagerProgressFooter.vue +++ b/src/components/dialog/footer/ManagerProgressFooter.vue @@ -99,8 +99,8 @@ const handleRestart = async () => { await useComfyManagerService().rebootComfyUI() closeDialog() - const onReconnect = () => { - useCommandStore().execute('Comfy.RefreshNodeDefinitions') + const onReconnect = async () => { + await useCommandStore().execute('Comfy.RefreshNodeDefinitions') comfyManagerStore.clearLogs() comfyManagerStore.setStale() } diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index e25dd44cd..6ad6c930a 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -150,16 +150,16 @@ const colorPaletteService = useColorPaletteService() const colorPaletteStore = useColorPaletteStore() watch( [() => canvasStore.canvas, () => settingStore.get('Comfy.ColorPalette')], - ([canvas, currentPaletteId]) => { + async ([canvas, currentPaletteId]) => { if (!canvas) return - colorPaletteService.loadColorPalette(currentPaletteId) + await colorPaletteService.loadColorPalette(currentPaletteId) } ) watch( () => colorPaletteStore.activePaletteId, - (newValue) => { - settingStore.set('Comfy.ColorPalette', newValue) + async (newValue) => { + await settingStore.set('Comfy.ColorPalette', newValue) } ) @@ -292,7 +292,7 @@ onMounted(async () => { () => settingStore.get('Comfy.Locale'), async () => { await useCommandStore().execute('Comfy.RefreshNodeDefinitions') - useWorkflowService().reloadCurrentWorkflow() + await useWorkflowService().reloadCurrentWorkflow() } ) diff --git a/src/components/graph/GraphCanvasMenu.vue b/src/components/graph/GraphCanvasMenu.vue index 060efb356..be31ed32c 100644 --- a/src/components/graph/GraphCanvasMenu.vue +++ b/src/components/graph/GraphCanvasMenu.vue @@ -80,10 +80,10 @@ const linkHidden = computed( ) let interval: number | null = null -const repeat = (command: string) => { +const repeat = async (command: string) => { if (interval) return const cmd = () => commandStore.execute(command) - cmd() + await cmd() interval = window.setInterval(cmd, 100) } const stopRepeat = () => { diff --git a/src/components/install/InstallLocationPicker.vue b/src/components/install/InstallLocationPicker.vue index 72ea7ac07..cbb981716 100644 --- a/src/components/install/InstallLocationPicker.vue +++ b/src/components/install/InstallLocationPicker.vue @@ -142,12 +142,12 @@ const browsePath = async () => { } } -const onFocus = () => { +const onFocus = async () => { if (!inputTouched.value) { inputTouched.value = true return } // Refresh validation on re-focus - validatePath(installPath.value) + await validatePath(installPath.value) } diff --git a/src/components/load3d/Load3DScene.vue b/src/components/load3d/Load3DScene.vue index 585aa53e7..556451c0d 100644 --- a/src/components/load3d/Load3DScene.vue +++ b/src/components/load3d/Load3DScene.vue @@ -71,7 +71,7 @@ const eventConfig = { textureLoadingEnd: () => loadingOverlayRef.value?.endLoading() } as const -watchEffect(() => { +watchEffect(async () => { if (load3d.value) { const rawLoad3d = toRaw(load3d.value) @@ -81,7 +81,7 @@ watchEffect(() => { rawLoad3d.setFOV(props.fov) rawLoad3d.toggleCamera(props.cameraType) rawLoad3d.togglePreview(props.showPreview) - rawLoad3d.setBackgroundImage(props.backgroundImage) + await rawLoad3d.setBackgroundImage(props.backgroundImage) rawLoad3d.setUpDirection(props.upDirection) } }) diff --git a/src/components/searchbox/NodeSearchBox.vue b/src/components/searchbox/NodeSearchBox.vue index d9dddeb1a..51d6ced8b 100644 --- a/src/components/searchbox/NodeSearchBox.vue +++ b/src/components/searchbox/NodeSearchBox.vue @@ -135,11 +135,11 @@ const search = (query: string) => { const emit = defineEmits(['addFilter', 'removeFilter', 'addNode']) let inputElement: HTMLInputElement | null = null -const reFocusInput = () => { +const reFocusInput = async () => { inputElement ??= document.getElementById(inputId) as HTMLInputElement if (inputElement) { inputElement.blur() - nextTick(() => inputElement?.focus()) + await nextTick(() => inputElement?.focus()) } } @@ -150,14 +150,14 @@ const onAddFilter = ( nodeSearchFilterVisible.value = false emit('addFilter', filterAndValue) } -const onRemoveFilter = ( +const onRemoveFilter = async ( event: Event, filterAndValue: FuseFilterWithValue ) => { event.stopPropagation() event.preventDefault() emit('removeFilter', filterAndValue) - reFocusInput() + await reFocusInput() } const setHoverSuggestion = (index: number) => { if (index === -1) { diff --git a/src/components/sidebar/SidebarLogoutIcon.vue b/src/components/sidebar/SidebarLogoutIcon.vue index 3c212a2d4..db89817a7 100644 --- a/src/components/sidebar/SidebarLogoutIcon.vue +++ b/src/components/sidebar/SidebarLogoutIcon.vue @@ -16,8 +16,8 @@ const userStore = useUserStore() const tooltip = computed( () => `${t('sideToolbar.logout')} (${userStore.currentUser?.username})` ) -const logout = () => { - userStore.logout() +const logout = async () => { + await userStore.logout() window.location.reload() } diff --git a/src/components/sidebar/SidebarThemeToggleIcon.vue b/src/components/sidebar/SidebarThemeToggleIcon.vue index c6bdb2f5b..73c133702 100644 --- a/src/components/sidebar/SidebarThemeToggleIcon.vue +++ b/src/components/sidebar/SidebarThemeToggleIcon.vue @@ -23,7 +23,7 @@ const icon = computed(() => ) const commandStore = useCommandStore() -const toggleTheme = () => { - commandStore.execute('Comfy.ToggleTheme') +const toggleTheme = async () => { + await commandStore.execute('Comfy.ToggleTheme') } diff --git a/src/components/sidebar/tabs/ModelLibrarySidebarTab.vue b/src/components/sidebar/tabs/ModelLibrarySidebarTab.vue index 915b930eb..fc4cba7ac 100644 --- a/src/components/sidebar/tabs/ModelLibrarySidebarTab.vue +++ b/src/components/sidebar/tabs/ModelLibrarySidebarTab.vue @@ -89,9 +89,8 @@ const handleSearch = async (query: string) => { return model.searchable.includes(search) }) - nextTick(() => { - expandNode(root.value) - }) + await nextTick() + expandNode(root.value) } type ModelOrFolder = ComfyModelDef | ModelFolder @@ -177,7 +176,7 @@ watch( const folderPath = key.split('/').slice(1).join('/') if (folderPath && !folderPath.includes('/')) { // Trigger (async) load of model data for this folder - modelStore.getLoadedModelFolder(folderPath) + void modelStore.getLoadedModelFolder(folderPath) } } }) diff --git a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue index 6fe36f7ff..357e5f0e0 100644 --- a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue +++ b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue @@ -153,7 +153,7 @@ const filteredRoot = computed(() => { const filters: Ref< (SearchFilter & { filter: FuseFilterWithValue })[] > = ref([]) -const handleSearch = (query: string) => { +const handleSearch = async (query: string) => { // Don't apply a min length filter because it does not make sense in // multi-byte languages like Chinese, Japanese, Korean, etc. if (query.length === 0 && !filters.value.length) { @@ -174,13 +174,12 @@ const handleSearch = (query: string) => { } ) - nextTick(() => { - // @ts-expect-error fixme ts strict error - expandNode(filteredRoot.value) - }) + await nextTick() + // @ts-expect-error fixme ts strict error + expandNode(filteredRoot.value) } -const onAddFilter = ( +const onAddFilter = async ( filterAndValue: FuseFilterWithValue ) => { filters.value.push({ @@ -191,15 +190,15 @@ const onAddFilter = ( id: +new Date() }) - handleSearch(searchQuery.value) + await handleSearch(searchQuery.value) } // @ts-expect-error fixme ts strict error -const onRemoveFilter = (filterAndValue) => { +const onRemoveFilter = async (filterAndValue) => { const index = filters.value.findIndex((f) => f === filterAndValue) if (index !== -1) { filters.value.splice(index, 1) } - handleSearch(searchQuery.value) + await handleSearch(searchQuery.value) } diff --git a/src/components/sidebar/tabs/QueueSidebarTab.vue b/src/components/sidebar/tabs/QueueSidebarTab.vue index 741e3a976..92620d6ec 100644 --- a/src/components/sidebar/tabs/QueueSidebarTab.vue +++ b/src/components/sidebar/tabs/QueueSidebarTab.vue @@ -157,11 +157,11 @@ const toggleExpanded = () => { isExpanded.value = !isExpanded.value } -const removeTask = (task: TaskItemImpl) => { +const removeTask = async (task: TaskItemImpl) => { if (task.isRunning) { - api.interrupt() + await api.interrupt() } - queueStore.delete(task) + await queueStore.delete(task) } const removeAllTasks = async () => { @@ -251,8 +251,11 @@ const exitFolderView = () => { folderTask.value = null } -const toggleImageFit = () => { - settingStore.set(IMAGE_FIT, imageFit.value === 'cover' ? 'contain' : 'cover') +const toggleImageFit = async () => { + await settingStore.set( + IMAGE_FIT, + imageFit.value === 'cover' ? 'contain' : 'cover' + ) } watch(allTasks, () => { diff --git a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue index 90ecfebf8..a224e4239 100644 --- a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue +++ b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue @@ -160,7 +160,7 @@ const filteredWorkflows = ref([]) const filteredRoot = computed(() => { return buildWorkflowTree(filteredWorkflows.value as ComfyWorkflow[]) }) -const handleSearch = (query: string) => { +const handleSearch = async (query: string) => { if (query.length === 0) { filteredWorkflows.value = [] expandedKeys.value = {} @@ -170,9 +170,8 @@ const handleSearch = (query: string) => { filteredWorkflows.value = workflowStore.workflows.filter((workflow) => { return workflow.path.toLocaleLowerCase().includes(lowerQuery) }) - nextTick(() => { - expandNode(filteredRoot.value) - }) + await nextTick() + expandNode(filteredRoot.value) } const workflowStore = useWorkflowStore() @@ -183,9 +182,9 @@ const expandedKeys = ref>({}) const { expandNode, toggleNodeOnEvent } = useTreeExpansion(expandedKeys) const dummyExpandedKeys = ref>({}) -const handleCloseWorkflow = (workflow?: ComfyWorkflow) => { +const handleCloseWorkflow = async (workflow?: ComfyWorkflow) => { if (workflow) { - workflowService.closeWorkflow(workflow, { + await workflowService.closeWorkflow(workflow, { warnIfUnsaved: !workspaceStore.shiftDown }) } @@ -225,9 +224,12 @@ const renderTreeNode = ( const workflow: ComfyWorkflow = node.data - function handleClick(this: TreeExplorerNode, e: MouseEvent) { + async function handleClick( + this: TreeExplorerNode, + e: MouseEvent + ) { if (this.leaf) { - workflowService.openWorkflow(workflow) + await workflowService.openWorkflow(workflow) } else { toggleNodeOnEvent(e, this) } @@ -254,9 +256,9 @@ const renderTreeNode = ( { label: t('g.insert'), icon: 'pi pi-file-export', - command: () => { + command: async () => { const workflow = node.data - workflowService.insertWorkflow(workflow) + await workflowService.insertWorkflow(workflow) } } ] diff --git a/src/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue b/src/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue index fdf1cc306..eb205b713 100644 --- a/src/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue +++ b/src/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue @@ -87,7 +87,7 @@ const handleModelHover = async () => { modelPreviewStyle.value.left = `${targetRect.left - 400}px` } - modelDef.value.load() + await modelDef.value.load() } const container = ref() @@ -111,17 +111,17 @@ const showPreview = computed(() => { const handleMouseEnter = async () => { isHovered.value = true await nextTick() - handleModelHover() + await handleModelHover() } const handleMouseLeave = () => { isHovered.value = false } -onMounted(() => { +onMounted(async () => { modelContentElement.value = container.value?.closest('.p-tree-node-content') ?? undefined modelContentElement.value?.addEventListener('mouseenter', handleMouseEnter) modelContentElement.value?.addEventListener('mouseleave', handleMouseLeave) - modelDef.value.load() + await modelDef.value.load() }) onUnmounted(() => { diff --git a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue index b93a57715..974b3bb84 100644 --- a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue +++ b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue @@ -82,9 +82,10 @@ const bookmarkedRoot = computed(() => { }) watch( () => props.filteredNodeDefs, - (newValue) => { + async (newValue) => { if (newValue.length) { - nextTick(() => expandNode(bookmarkedRoot.value)) + await nextTick() + expandNode(bookmarkedRoot.value) } } ) @@ -145,9 +146,9 @@ const renderedBookmarkedRoot = computed>( }, children: sortedChildren, draggable: node.leaf, - handleAddFolder(newName: string) { + async handleAddFolder(newName: string) { if (newName !== '') { - nodeBookmarkStore.addNewBookmarkFolder(this.data, newName) + await nodeBookmarkStore.addNewBookmarkFolder(this.data, newName) } }, renderDragPreview(container) { @@ -158,18 +159,18 @@ const renderedBookmarkedRoot = computed>( } }, droppable: !node.leaf, - handleDrop(data: TreeExplorerDragAndDropData) { + async handleDrop(data: TreeExplorerDragAndDropData) { const nodeDefToAdd = data.data.data // Remove bookmark if the source is the top level bookmarked node. // @ts-expect-error fixme ts strict error if (nodeBookmarkStore.isBookmarked(nodeDefToAdd)) { // @ts-expect-error fixme ts strict error - nodeBookmarkStore.toggleBookmark(nodeDefToAdd) + await nodeBookmarkStore.toggleBookmark(nodeDefToAdd) } const folderNodeDef = node.data as ComfyNodeDefImpl // @ts-expect-error fixme ts strict error const nodePath = folderNodeDef.category + '/' + nodeDefToAdd.name - nodeBookmarkStore.addBookmark(nodePath) + await nodeBookmarkStore.addBookmark(nodePath) }, handleClick(e: MouseEvent) { if (this.leaf) { @@ -183,14 +184,17 @@ const renderedBookmarkedRoot = computed>( ...(node.leaf ? {} : { - handleRename(newName: string) { + async handleRename(newName: string) { if (this.data && this.data.isDummyFolder) { - nodeBookmarkStore.renameBookmarkFolder(this.data, newName) + await nodeBookmarkStore.renameBookmarkFolder( + this.data, + newName + ) } }, - handleDelete() { + async handleDelete() { // @ts-expect-error fixme ts strict error - nodeBookmarkStore.deleteBookmarkFolder(this.data) + await nodeBookmarkStore.deleteBookmarkFolder(this.data) } }) } @@ -208,9 +212,9 @@ const showCustomizationDialog = ref(false) const initialIcon = ref(nodeBookmarkStore.defaultBookmarkIcon) const initialColor = ref(nodeBookmarkStore.defaultBookmarkColor) const customizationTargetNodePath = ref('') -const updateCustomization = (icon: string, color: string) => { +const updateCustomization = async (icon: string, color: string) => { if (customizationTargetNodePath.value) { - nodeBookmarkStore.updateBookmarkCustomization( + await nodeBookmarkStore.updateBookmarkCustomization( customizationTargetNodePath.value, { icon, color } ) diff --git a/src/components/sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue b/src/components/sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue index 8bc1a6ac6..78bb01e4c 100644 --- a/src/components/sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue +++ b/src/components/sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue @@ -67,8 +67,8 @@ const sidebarLocation = computed<'left' | 'right'>(() => settingStore.get('Comfy.Sidebar.Location') ) -const toggleBookmark = () => { - nodeBookmarkStore.toggleBookmark(nodeDef.value) +const toggleBookmark = async () => { + await nodeBookmarkStore.toggleBookmark(nodeDef.value) } const previewRef = ref | null>(null) @@ -104,7 +104,7 @@ const isHovered = ref(false) const handleMouseEnter = async () => { isHovered.value = true await nextTick() - handleNodeHover() + await handleNodeHover() } const handleMouseLeave = () => { isHovered.value = false diff --git a/src/components/toast/RerouteMigrationToast.vue b/src/components/toast/RerouteMigrationToast.vue index 4264945ee..916425342 100644 --- a/src/components/toast/RerouteMigrationToast.vue +++ b/src/components/toast/RerouteMigrationToast.vue @@ -32,10 +32,10 @@ const { t } = useI18n() const toast = useToast() const workflowStore = useWorkflowStore() -const migrateToLitegraphReroute = () => { +const migrateToLitegraphReroute = async () => { const workflowJSON = app.graph.serialize() as unknown as WorkflowJSON04 const migratedWorkflowJSON = migrateLegacyRerouteNodes(workflowJSON) - app.loadGraphData( + await app.loadGraphData( migratedWorkflowJSON, false, false, diff --git a/src/components/topbar/WorkflowTab.vue b/src/components/topbar/WorkflowTab.vue index dc0bfa929..fa51dc1db 100644 --- a/src/components/topbar/WorkflowTab.vue +++ b/src/components/topbar/WorkflowTab.vue @@ -89,8 +89,8 @@ const closeWorkflows = async (options: WorkflowOption[]) => { } } -const onCloseWorkflow = (option: WorkflowOption) => { - closeWorkflows([option]) +const onCloseWorkflow = async (option: WorkflowOption) => { + await closeWorkflows([option]) } const tabGetter = () => workflowTabRef.value as HTMLElement diff --git a/src/components/topbar/WorkflowTabs.vue b/src/components/topbar/WorkflowTabs.vue index 413d63a22..c4654153d 100644 --- a/src/components/topbar/WorkflowTabs.vue +++ b/src/components/topbar/WorkflowTabs.vue @@ -86,7 +86,7 @@ const selectedWorkflow = computed(() => ? workflowToOption(workflowStore.activeWorkflow as ComfyWorkflow) : null ) -const onWorkflowChange = (option: WorkflowOption) => { +const onWorkflowChange = async (option: WorkflowOption) => { // Prevent unselecting the current workflow if (!option) { return @@ -96,7 +96,7 @@ const onWorkflowChange = (option: WorkflowOption) => { return } - workflowService.openWorkflow(option.workflow) + await workflowService.openWorkflow(option.workflow) } const closeWorkflows = async (options: WorkflowOption[]) => { @@ -112,8 +112,8 @@ const closeWorkflows = async (options: WorkflowOption[]) => { } } -const onCloseWorkflow = (option: WorkflowOption) => { - closeWorkflows([option]) +const onCloseWorkflow = async (option: WorkflowOption) => { + await closeWorkflows([option]) } const showContextMenu = (event: MouseEvent, option: WorkflowOption) => { @@ -128,8 +128,8 @@ const contextMenuItems = computed(() => { return [ { label: t('tabMenu.duplicateTab'), - command: () => { - workflowService.duplicateWorkflow(tab.workflow) + command: async () => { + await workflowService.duplicateWorkflow(tab.workflow) } }, { @@ -181,30 +181,30 @@ const handleWheel = (event: WheelEvent) => { // Scroll to active offscreen tab when opened watch( () => workflowStore.activeWorkflow, - () => { + async () => { if (!selectedWorkflow.value) return - nextTick(() => { - const activeTabElement = document.querySelector('.p-togglebutton-checked') - if (!activeTabElement || !scrollPanelRef.value) return + await nextTick() - const container = scrollPanelRef.value.$el.querySelector( - '.p-scrollpanel-content' - ) - if (!container) return + const activeTabElement = document.querySelector('.p-togglebutton-checked') + if (!activeTabElement || !scrollPanelRef.value) return - const tabRect = activeTabElement.getBoundingClientRect() - const containerRect = container.getBoundingClientRect() + const container = scrollPanelRef.value.$el.querySelector( + '.p-scrollpanel-content' + ) + if (!container) return - const offsetLeft = tabRect.left - containerRect.left - const offsetRight = tabRect.right - containerRect.right + const tabRect = activeTabElement.getBoundingClientRect() + const containerRect = container.getBoundingClientRect() - if (offsetRight > 0) { - container.scrollBy({ left: offsetRight }) - } else if (offsetLeft < 0) { - container.scrollBy({ left: offsetLeft }) - } - }) + const offsetLeft = tabRect.left - containerRect.left + const offsetRight = tabRect.right - containerRect.right + + if (offsetRight > 0) { + container.scrollBy({ left: offsetRight }) + } else if (offsetLeft < 0) { + container.scrollBy({ left: offsetLeft }) + } }, { immediate: true } ) diff --git a/src/composables/node/useNodeDragAndDrop.ts b/src/composables/node/useNodeDragAndDrop.ts index 90562d816..cb603814c 100644 --- a/src/composables/node/useNodeDragAndDrop.ts +++ b/src/composables/node/useNodeDragAndDrop.ts @@ -41,9 +41,7 @@ export const useNodeDragAndDrop = ( if (!isDraggingValidFiles(e)) return false const files = filterFiles(e.dataTransfer!.files) - onDrop(files).then((results) => { - if (!results?.length) return - }) + void onDrop(files) return true } } diff --git a/src/composables/node/useNodePaste.ts b/src/composables/node/useNodePaste.ts index 2b5a9ab04..d198db926 100644 --- a/src/composables/node/useNodePaste.ts +++ b/src/composables/node/useNodePaste.ts @@ -23,9 +23,7 @@ export const useNodePaste = ( const paste = allow_batch ? filteredFiles : filteredFiles.slice(0, 1) - onPaste(paste).then((result) => { - if (!result) return - }) + void onPaste(paste) return true } } diff --git a/src/composables/nodePack/useWorkflowPacks.ts b/src/composables/nodePack/useWorkflowPacks.ts index f68614ac1..959b527a7 100644 --- a/src/composables/nodePack/useWorkflowPacks.ts +++ b/src/composables/nodePack/useWorkflowPacks.ts @@ -117,7 +117,7 @@ export const useWorkflowPacks = (options: UseNodePacksOptions = {}) => { workflowPacks: nodePacks, startFetchWorkflowPacks: async () => { await getWorkflowPacks() // Parse the packs from the workflow nodes - startFetch() // Fetch the packs infos from the registry + await startFetch() // Fetch the packs infos from the registry }, filterWorkflowPack } diff --git a/src/composables/useCanvasDrop.ts b/src/composables/useCanvasDrop.ts index efe187b4e..37925a5ff 100644 --- a/src/composables/useCanvasDrop.ts +++ b/src/composables/useCanvasDrop.ts @@ -21,7 +21,7 @@ export const useCanvasDrop = (canvasRef: Ref) => { usePragmaticDroppable(() => canvasRef.value, { getDropEffect: (args): Exclude => args.source.data.type === 'tree-explorer-node' ? 'copy' : 'move', - onDrop: (event) => { + onDrop: async (event) => { const loc = event.location.current.input const dndData = event.source.data @@ -79,7 +79,7 @@ export const useCanvasDrop = (canvasRef: Ref) => { loc.clientX, loc.clientY ]) - workflowService.insertWorkflow(workflow, { position }) + await workflowService.insertWorkflow(workflow, { position }) } } } diff --git a/src/composables/useCoreCommands.ts b/src/composables/useCoreCommands.ts index bf609386d..da0ddcc93 100644 --- a/src/composables/useCoreCommands.ts +++ b/src/composables/useCoreCommands.ts @@ -107,8 +107,8 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-download', label: 'Export Workflow', menubarLabel: 'Export', - function: () => { - workflowService.exportWorkflow('workflow', 'workflow') + function: async () => { + await workflowService.exportWorkflow('workflow', 'workflow') } }, { @@ -116,8 +116,8 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-download', label: 'Export Workflow (API Format)', menubarLabel: 'Export (API)', - function: () => { - workflowService.exportWorkflow('workflow_api', 'output') + function: async () => { + await workflowService.exportWorkflow('workflow_api', 'output') } }, { @@ -272,16 +272,19 @@ export function useCoreCommands(): ComfyCommand[] { const settingStore = useSettingStore() let lastLinksRenderMode = LiteGraph.SPLINE_LINK - return () => { + return async () => { const currentMode = settingStore.get('Comfy.LinkRenderMode') if (currentMode === LiteGraph.HIDDEN_LINK) { // If links are hidden, restore the last positive value or default to spline mode - settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode) + await settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode) } else { // If links are visible, store the current mode and hide links lastLinksRenderMode = currentMode - settingStore.set('Comfy.LinkRenderMode', LiteGraph.HIDDEN_LINK) + await settingStore.set( + 'Comfy.LinkRenderMode', + LiteGraph.HIDDEN_LINK + ) } } })() @@ -291,9 +294,9 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-play', label: 'Queue Prompt', versionAdded: '1.3.7', - function: () => { + function: async () => { const batchCount = useQueueSettingsStore().batchCount - app.queuePrompt(0, batchCount) + await app.queuePrompt(0, batchCount) } }, { @@ -301,9 +304,9 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-play', label: 'Queue Prompt (Front)', versionAdded: '1.3.7', - function: () => { + function: async () => { const batchCount = useQueueSettingsStore().batchCount - app.queuePrompt(-1, batchCount) + await app.queuePrompt(-1, batchCount) } }, { @@ -345,8 +348,8 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-step-forward', label: 'Next Opened Workflow', versionAdded: '1.3.9', - function: () => { - workflowService.loadNextOpenedWorkflow() + function: async () => { + await workflowService.loadNextOpenedWorkflow() } }, { @@ -354,8 +357,8 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-step-backward', label: 'Previous Opened Workflow', versionAdded: '1.3.9', - function: () => { - workflowService.loadPreviousOpenedWorkflow() + function: async () => { + await workflowService.loadPreviousOpenedWorkflow() } }, { @@ -438,15 +441,15 @@ export function useCoreCommands(): ComfyCommand[] { let previousDarkTheme: string = DEFAULT_DARK_COLOR_PALETTE.id let previousLightTheme: string = DEFAULT_LIGHT_COLOR_PALETTE.id - return () => { + return async () => { const settingStore = useSettingStore() const theme = colorPaletteStore.completedActivePalette if (theme.light_theme) { previousLightTheme = theme.id - settingStore.set('Comfy.ColorPalette', previousDarkTheme) + await settingStore.set('Comfy.ColorPalette', previousDarkTheme) } else { previousDarkTheme = theme.id - settingStore.set('Comfy.ColorPalette', previousLightTheme) + await settingStore.set('Comfy.ColorPalette', previousLightTheme) } } })() @@ -544,8 +547,8 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-clone', label: 'Duplicate Current Workflow', versionAdded: '1.6.15', - function: () => { - workflowService.duplicateWorkflow(workflowStore.activeWorkflow!) + function: async () => { + await workflowService.duplicateWorkflow(workflowStore.activeWorkflow!) } }, { @@ -553,9 +556,9 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'pi pi-times', label: 'Close Current Workflow', versionAdded: '1.7.3', - function: () => { + function: async () => { if (workflowStore.activeWorkflow) - workflowService.closeWorkflow(workflowStore.activeWorkflow) + await workflowService.closeWorkflow(workflowStore.activeWorkflow) } }, { diff --git a/src/composables/useDownload.ts b/src/composables/useDownload.ts index 87191dca0..2b1d8924a 100644 --- a/src/composables/useDownload.ts +++ b/src/composables/useDownload.ts @@ -55,7 +55,8 @@ export function useDownload(url: string, fileName?: string) { // Try falling back to normal fetch if using Civitai API fails whenever(civitaiErr, fetchFileSize, { once: true }) } else { - fetchFileSize() + // Fetch file size in the background + void fetchFileSize() } }) diff --git a/src/composables/useRefreshableSelection.ts b/src/composables/useRefreshableSelection.ts index 839402c97..26fa7366f 100644 --- a/src/composables/useRefreshableSelection.ts +++ b/src/composables/useRefreshableSelection.ts @@ -44,7 +44,7 @@ export const useRefreshableSelection = () => { if (!isRefreshable.value) return if (isAllNodesSelected.value) { - commandStore.execute('Comfy.RefreshNodeDefinitions') + await commandStore.execute('Comfy.RefreshNodeDefinitions') } else { await Promise.all(refreshableWidgets.value.map((item) => item.refresh())) } diff --git a/src/composables/useServerLogs.ts b/src/composables/useServerLogs.ts index 316ab0499..a802c7b8f 100644 --- a/src/composables/useServerLogs.ts +++ b/src/composables/useServerLogs.ts @@ -32,23 +32,23 @@ export const useServerLogs = (options: UseServerLogsOptions = {}) => { } } - const start = () => { - api.subscribeLogs(true) + const start = async () => { + await api.subscribeLogs(true) stop = useEventListener(api, LOGS_MESSAGE_TYPE, handleLogMessage) } - const stopListening = () => { + const stopListening = async () => { stop?.() stop = null - api.subscribeLogs(false) + await api.subscribeLogs(false) } if (immediate) { - start() + void start() } - onUnmounted(() => { - stopListening() + onUnmounted(async () => { + await stopListening() logs.value = [] }) diff --git a/src/composables/widgets/useRemoteWidget.ts b/src/composables/widgets/useRemoteWidget.ts index 0edfbde29..e06aa39b3 100644 --- a/src/composables/widgets/useRemoteWidget.ts +++ b/src/composables/widgets/useRemoteWidget.ts @@ -189,14 +189,18 @@ export function useRemoteWidget< * @returns the most recent value of the widget. */ function getValue(onFulfilled?: () => void) { - fetchValue().then((data) => { - if (isFirstLoad()) onFirstLoad(data) - if (refreshQueued && data !== defaultValue) { - onRefresh() - refreshQueued = false - } - onFulfilled?.() - }) + void fetchValue() + .then((data) => { + if (isFirstLoad()) onFirstLoad(data) + if (refreshQueued && data !== defaultValue) { + onRefresh() + refreshQueued = false + } + onFulfilled?.() + }) + .catch((err) => { + console.error(err) + }) return getCachedValue() ?? defaultValue } diff --git a/src/services/autoQueueService.ts b/src/services/autoQueueService.ts index 4f131edbd..ffbc5dede 100644 --- a/src/services/autoQueueService.ts +++ b/src/services/autoQueueService.ts @@ -17,14 +17,15 @@ export function setupAutoQueueHandler() { graphHasChanged = true } else { graphHasChanged = false - app.queuePrompt(0, queueSettingsStore.batchCount) + // Queue the prompt in the background + void app.queuePrompt(0, queueSettingsStore.batchCount) internalCount++ } } }) queueCountStore.$subscribe( - () => { + async () => { internalCount = queueCountStore.count if (!internalCount && !app.lastExecutionError) { if ( @@ -32,7 +33,7 @@ export function setupAutoQueueHandler() { (queueSettingsStore.mode === 'change' && graphHasChanged) ) { graphHasChanged = false - app.queuePrompt(0, queueSettingsStore.batchCount) + await app.queuePrompt(0, queueSettingsStore.batchCount) } } }, diff --git a/src/services/colorPaletteService.ts b/src/services/colorPaletteService.ts index e58f3c6fb..ea4acb605 100644 --- a/src/services/colorPaletteService.ts +++ b/src/services/colorPaletteService.ts @@ -36,8 +36,8 @@ export const useColorPaletteService = () => { throw new Error(`Invalid color palette against zod schema:\n${error}`) } - const persistCustomColorPalettes = () => { - settingStore.set( + const persistCustomColorPalettes = async () => { + await settingStore.set( 'Comfy.CustomColorPalettes', colorPaletteStore.customPalettes ) @@ -48,9 +48,9 @@ export const useColorPaletteService = () => { * * @param colorPaletteId - The ID of the color palette to delete. */ - const deleteCustomColorPalette = (colorPaletteId: string) => { + const deleteCustomColorPalette = async (colorPaletteId: string) => { colorPaletteStore.deleteCustomPalette(colorPaletteId) - persistCustomColorPalettes() + await persistCustomColorPalettes() } /** @@ -58,10 +58,10 @@ export const useColorPaletteService = () => { * * @param colorPalette - The palette to add. */ - const addCustomColorPalette = (colorPalette: Palette) => { + const addCustomColorPalette = async (colorPalette: Palette) => { validateColorPalette(colorPalette) colorPaletteStore.addCustomPalette(colorPalette) - persistCustomColorPalettes() + await persistCustomColorPalettes() } /** @@ -176,14 +176,16 @@ export const useColorPaletteService = () => { const file = await uploadFile('application/json') const text = await file.text() const palette = JSON.parse(text) - addCustomColorPalette(palette) + await addCustomColorPalette(palette) return palette } return { getActiveColorPalette: () => colorPaletteStore.completedActivePalette, - addCustomColorPalette: wrapWithErrorHandling(addCustomColorPalette), - deleteCustomColorPalette: wrapWithErrorHandling(deleteCustomColorPalette), + addCustomColorPalette: wrapWithErrorHandlingAsync(addCustomColorPalette), + deleteCustomColorPalette: wrapWithErrorHandlingAsync( + deleteCustomColorPalette + ), loadColorPalette: wrapWithErrorHandlingAsync(loadColorPalette), exportColorPalette: wrapWithErrorHandling(exportColorPalette), importColorPalette: wrapWithErrorHandlingAsync(importColorPalette) diff --git a/src/services/extensionService.ts b/src/services/extensionService.ts index 33c0b688c..1fd92b256 100644 --- a/src/services/extensionService.ts +++ b/src/services/extensionService.ts @@ -65,7 +65,7 @@ export const useExtensionService = () => { if (extension.getCustomWidgets) { // TODO(huchenlei): We should deprecate the async return value of // getCustomWidgets. - ;(async () => { + void (async () => { if (extension.getCustomWidgets) { const widgets = await extension.getCustomWidgets(app) useWidgetStore().registerCustomWidgets(widgets) diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 5754c4704..af6c881a9 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -79,7 +79,7 @@ export const useLitegraphService = () => { this.#addOutputs(ComfyNode.nodeData.outputs) this.#setInitialSize() this.serialize_widgets = true - extensionService.invokeExtensionsAsync('nodeCreated', this) + void extensionService.invokeExtensionsAsync('nodeCreated', this) } /** diff --git a/src/stores/comfyManagerStore.ts b/src/stores/comfyManagerStore.ts index f5ab3a7bd..06f4b40ca 100644 --- a/src/stores/comfyManagerStore.ts +++ b/src/stores/comfyManagerStore.ts @@ -122,12 +122,12 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { const loggedTask = async () => { taskLogs.value.push({ taskName, logs: logs.value }) - startListening() + await startListening() return task() } - const onComplete = () => { - stopListening() + const onComplete = async () => { + await stopListening() setStale() } diff --git a/src/stores/nodeBookmarkStore.ts b/src/stores/nodeBookmarkStore.ts index f629ecb42..2b4049c49 100644 --- a/src/stores/nodeBookmarkStore.ts +++ b/src/stores/nodeBookmarkStore.ts @@ -30,15 +30,15 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { const isBookmarked = (node: ComfyNodeDefImpl) => bookmarksSet.value.has(node.nodePath) || bookmarksSet.value.has(node.name) - const toggleBookmark = (node: ComfyNodeDefImpl) => { + const toggleBookmark = async (node: ComfyNodeDefImpl) => { if (isBookmarked(node)) { - deleteBookmark(node.nodePath) + await deleteBookmark(node.nodePath) // Delete the bookmark at the top level if it exists // This is used for clicking the bookmark button in the node library, i.e. // the node is inside original/standard node library tree node - deleteBookmark(node.name) + await deleteBookmark(node.name) } else { - addBookmark(node.name) + await addBookmark(node.name) } } @@ -62,28 +62,28 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { return buildNodeDefTree(bookmarkNodes) } - const addBookmark = (nodePath: string) => { - settingStore.set(BOOKMARK_SETTING_ID, [...bookmarks.value, nodePath]) + const addBookmark = async (nodePath: string) => { + await settingStore.set(BOOKMARK_SETTING_ID, [...bookmarks.value, nodePath]) } - const deleteBookmark = (nodePath: string) => { - settingStore.set( + const deleteBookmark = async (nodePath: string) => { + await settingStore.set( BOOKMARK_SETTING_ID, bookmarks.value.filter((b: string) => b !== nodePath) ) } - const addNewBookmarkFolder = ( + const addNewBookmarkFolder = async ( parent: ComfyNodeDefImpl | undefined, folderName: string ) => { const parentPath = parent ? parent.nodePath : '' const newFolderPath = parentPath + folderName + '/' - addBookmark(newFolderPath) + await addBookmark(newFolderPath) return newFolderPath } - const renameBookmarkFolder = ( + const renameBookmarkFolder = async ( folderNode: ComfyNodeDefImpl, newName: string ) => { @@ -107,7 +107,7 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { throw new Error(`Folder name "${newNodePath}" already exists`) } - settingStore.set( + await settingStore.set( BOOKMARK_SETTING_ID, bookmarks.value.map((b: string) => b.startsWith(folderNode.nodePath) @@ -115,28 +115,28 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { : b ) ) - renameBookmarkCustomization(folderNode.nodePath, newNodePath) + await renameBookmarkCustomization(folderNode.nodePath, newNodePath) } - const deleteBookmarkFolder = (folderNode: ComfyNodeDefImpl) => { + const deleteBookmarkFolder = async (folderNode: ComfyNodeDefImpl) => { if (!folderNode.isDummyFolder) { throw new Error('Cannot delete non-folder node') } - settingStore.set( + await settingStore.set( BOOKMARK_SETTING_ID, bookmarks.value.filter( (b: string) => b !== folderNode.nodePath && !b.startsWith(folderNode.nodePath) ) ) - deleteBookmarkCustomization(folderNode.nodePath) + await deleteBookmarkCustomization(folderNode.nodePath) } const bookmarksCustomization = computed< Record >(() => settingStore.get('Comfy.NodeLibrary.BookmarksCustomization')) - const updateBookmarkCustomization = ( + const updateBookmarkCustomization = async ( nodePath: string, customization: BookmarkCustomization ) => { @@ -153,23 +153,23 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { // If the customization is empty, remove it entirely if (Object.keys(newCustomization).length === 0) { - deleteBookmarkCustomization(nodePath) + await deleteBookmarkCustomization(nodePath) } else { - settingStore.set('Comfy.NodeLibrary.BookmarksCustomization', { + await settingStore.set('Comfy.NodeLibrary.BookmarksCustomization', { ...bookmarksCustomization.value, [nodePath]: newCustomization }) } } - const deleteBookmarkCustomization = (nodePath: string) => { - settingStore.set('Comfy.NodeLibrary.BookmarksCustomization', { + const deleteBookmarkCustomization = async (nodePath: string) => { + await settingStore.set('Comfy.NodeLibrary.BookmarksCustomization', { ...bookmarksCustomization.value, [nodePath]: undefined } as Record) } - const renameBookmarkCustomization = ( + const renameBookmarkCustomization = async ( oldNodePath: string, newNodePath: string ) => { @@ -178,7 +178,7 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => { updatedCustomization[newNodePath] = updatedCustomization[oldNodePath] delete updatedCustomization[oldNodePath] } - settingStore.set( + await settingStore.set( 'Comfy.NodeLibrary.BookmarksCustomization', updatedCustomization ) diff --git a/src/stores/workflowStore.ts b/src/stores/workflowStore.ts index 64747d446..2db34e228 100644 --- a/src/stores/workflowStore.ts +++ b/src/stores/workflowStore.ts @@ -378,8 +378,8 @@ export const useWorkflowStore = defineStore('workflow', () => { // Update bookmarks if (wasBookmarked) { - bookmarkStore.setBookmarked(oldPath, false) - bookmarkStore.setBookmarked(newPath, true) + await bookmarkStore.setBookmarked(oldPath, false) + await bookmarkStore.setBookmarked(newPath, true) } } finally { isBusy.value = false @@ -391,7 +391,7 @@ export const useWorkflowStore = defineStore('workflow', () => { try { await workflow.delete() if (bookmarkStore.isBookmarked(workflow.path)) { - bookmarkStore.setBookmarked(workflow.path, false) + await bookmarkStore.setBookmarked(workflow.path, false) } delete workflowLookup.value[workflow.path] } finally { @@ -462,18 +462,18 @@ export const useWorkflowBookmarkStore = defineStore('workflowBookmark', () => { }) } - const setBookmarked = (path: string, value: boolean) => { + const setBookmarked = async (path: string, value: boolean) => { if (bookmarks.value.has(path) === value) return if (value) { bookmarks.value.add(path) } else { bookmarks.value.delete(path) } - saveBookmarks() + await saveBookmarks() } - const toggleBookmarked = (path: string) => { - setBookmarked(path, !bookmarks.value.has(path)) + const toggleBookmarked = async (path: string) => { + await setBookmarked(path, !bookmarks.value.has(path)) } return { diff --git a/src/utils/linkFixer.ts b/src/utils/linkFixer.ts index 10dcec67e..218b1c962 100644 --- a/src/utils/linkFixer.ts +++ b/src/utils/linkFixer.ts @@ -114,7 +114,7 @@ export function fixBadLinks( /** * Internal patch node. We keep track of changes in patchedNodeSlots in case we're in a dry run. */ - async function patchNodeSlot( + function patchNodeSlot( node: ISerialisedNode | LGraphNode, ioDir: IoDirection, slot: number, diff --git a/src/views/DownloadGitView.vue b/src/views/DownloadGitView.vue index 347a12b29..705cbf7c7 100644 --- a/src/views/DownloadGitView.vue +++ b/src/views/DownloadGitView.vue @@ -51,9 +51,9 @@ const openGitDownloads = () => { window.open('https://git-scm.com/downloads/', '_blank') } -const skipGit = () => { +const skipGit = async () => { console.warn('pushing') const router = useRouter() - router.push('install') + await router.push('install') } diff --git a/src/views/GraphView.vue b/src/views/GraphView.vue index 29f60367a..27dbaf51f 100644 --- a/src/views/GraphView.vue +++ b/src/views/GraphView.vue @@ -230,10 +230,12 @@ const onGraphReady = () => { ) // Load model folders - wrapWithErrorHandlingAsync(useModelStore().loadModelFolders)() + void wrapWithErrorHandlingAsync(useModelStore().loadModelFolders)() // Non-blocking load of node frequencies - wrapWithErrorHandlingAsync(useNodeFrequencyStore().loadNodeFrequencies)() + void wrapWithErrorHandlingAsync( + useNodeFrequencyStore().loadNodeFrequencies + )() // Node defs now available after comfyApp.setup. // Explicitly initialize nodeSearchService to avoid indexing delay when diff --git a/src/views/InstallView.vue b/src/views/InstallView.vue index c2eca5f2b..5db9c402c 100644 --- a/src/views/InstallView.vue +++ b/src/views/InstallView.vue @@ -166,7 +166,7 @@ const noGpu = computed(() => typeof device.value !== 'string') const electron = electronAPI() const router = useRouter() -const install = () => { +const install = async () => { const options: InstallOptions = { installPath: installPath.value, autoUpdate: autoUpdate.value, @@ -183,7 +183,7 @@ const install = () => { const nextPage = options.device === 'unsupported' ? '/manual-configuration' : '/server-start' - router.push(nextPage) + await router.push(nextPage) } onMounted(async () => { diff --git a/src/views/MetricsConsentView.vue b/src/views/MetricsConsentView.vue index 152e664c6..119c09aad 100644 --- a/src/views/MetricsConsentView.vue +++ b/src/views/MetricsConsentView.vue @@ -78,6 +78,6 @@ const updateConsent = async () => { } finally { isUpdating.value = false } - router.push('/') + await router.push('/') } diff --git a/src/views/NotSupportedView.vue b/src/views/NotSupportedView.vue index b18182768..ae32946d8 100644 --- a/src/views/NotSupportedView.vue +++ b/src/views/NotSupportedView.vue @@ -73,8 +73,8 @@ const reportIssue = () => { } const router = useRouter() -const continueToInstall = () => { - router.push('/install') +const continueToInstall = async () => { + await router.push('/install') } diff --git a/src/views/UserSelectView.vue b/src/views/UserSelectView.vue index d39235c18..917e706fc 100644 --- a/src/views/UserSelectView.vue +++ b/src/views/UserSelectView.vue @@ -76,8 +76,8 @@ const login = async () => { throw new Error('No user selected') } - userStore.login(user) - router.push('/') + await userStore.login(user) + await router.push('/') } catch (err) { loginError.value = err instanceof Error ? err.message : JSON.stringify(err) } diff --git a/src/views/WelcomeView.vue b/src/views/WelcomeView.vue index 07502221f..fac2fb517 100644 --- a/src/views/WelcomeView.vue +++ b/src/views/WelcomeView.vue @@ -27,8 +27,8 @@ import { useRouter } from 'vue-router' import BaseViewTemplate from '@/views/templates/BaseViewTemplate.vue' const router = useRouter() -const navigateTo = (path: string) => { - router.push(path) +const navigateTo = async (path: string) => { + await router.push(path) } diff --git a/tests-ui/tests/composables/useServerLogs.test.ts b/tests-ui/tests/composables/useServerLogs.test.ts index 6415e641a..3af4f0faa 100644 --- a/tests-ui/tests/composables/useServerLogs.test.ts +++ b/tests-ui/tests/composables/useServerLogs.test.ts @@ -38,27 +38,27 @@ describe('useServerLogs', () => { expect(api.subscribeLogs).toHaveBeenCalledWith(true) }) - it('should start listening when startListening is called', () => { + it('should start listening when startListening is called', async () => { const { startListening } = useServerLogs() - startListening() + await startListening() expect(api.subscribeLogs).toHaveBeenCalledWith(true) }) - it('should stop listening when stopListening is called', () => { + it('should stop listening when stopListening is called', async () => { const { startListening, stopListening } = useServerLogs() - startListening() - stopListening() + await startListening() + await stopListening() expect(api.subscribeLogs).toHaveBeenCalledWith(false) }) - it('should register event listener when starting', () => { + it('should register event listener when starting', async () => { const { startListening } = useServerLogs() - startListening() + await startListening() expect(vi.mocked(useEventListener)).toHaveBeenCalledWith( api, @@ -69,7 +69,8 @@ describe('useServerLogs', () => { it('should handle log messages correctly', async () => { const { logs, startListening } = useServerLogs() - startListening() + + await startListening() // Get the callback that was registered with useEventListener const eventCallback = vi.mocked(useEventListener).mock.calls[0][2] as ( @@ -94,7 +95,8 @@ describe('useServerLogs', () => { const { logs, startListening } = useServerLogs({ messageFilter: (msg) => msg !== 'remove me' }) - startListening() + + await startListening() const eventCallback = vi.mocked(useEventListener).mock.calls[0][2] as ( event: CustomEvent