From a0a00bacdd187f774ccf15819f1cf4b706e3bd1b Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 14 May 2025 07:44:06 +1000 Subject: [PATCH] Allow users to opt-out of changing favicon --- src/composables/useProgressFavicon.ts | 38 ++++++++++++++++++++------- src/constants/coreSettings.ts | 9 +++++++ src/schemas/apiSchema.ts | 3 ++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/composables/useProgressFavicon.ts b/src/composables/useProgressFavicon.ts index 0326274f4..9402dd9e8 100644 --- a/src/composables/useProgressFavicon.ts +++ b/src/composables/useProgressFavicon.ts @@ -1,23 +1,41 @@ import { useFavicon } from '@vueuse/core' -import { watch } from 'vue' +import { type WatchHandle, ref, watch } from 'vue' import { useExecutionStore } from '@/stores/executionStore' +import { useSettingStore } from '@/stores/settingStore' export const useProgressFavicon = () => { const defaultFavicon = '/assets/images/favicon_progress_16x16/frame_9.png' const favicon = useFavicon(defaultFavicon) const executionStore = useExecutionStore() + const settingsStore = useSettingStore() const totalFrames = 10 - watch( - [() => executionStore.executionProgress, () => executionStore.isIdle], - ([progress, isIdle]) => { - if (isIdle) { - favicon.value = defaultFavicon - } else { - const frame = Math.floor(progress * totalFrames) - favicon.value = `/assets/images/favicon_progress_16x16/frame_${frame}.png` + const watchHandle = ref() + + function watchProgress() { + watchHandle.value = watch( + [() => executionStore.executionProgress, () => executionStore.isIdle], + ([progress, isIdle]) => { + if (isIdle) { + favicon.value = defaultFavicon + } else { + const frame = Math.floor(progress * totalFrames) + favicon.value = `/assets/images/favicon_progress_16x16/frame_${frame}.png` + } } - } + ) + } + + watch( + () => settingsStore.get('Comfy.Window.TabIconProgress'), + (showProgress) => { + if (showProgress) { + watchProgress() + } else { + watchHandle.value?.stop() + } + }, + { immediate: true } ) } diff --git a/src/constants/coreSettings.ts b/src/constants/coreSettings.ts index 27a530667..2292ad362 100644 --- a/src/constants/coreSettings.ts +++ b/src/constants/coreSettings.ts @@ -828,5 +828,14 @@ export const CORE_SETTINGS: SettingParams[] = [ type: 'boolean', defaultValue: false, versionAdded: '1.19.1' + }, + { + id: 'Comfy.Window.TabIconProgress', + name: 'Browser tab icon shows progress', + tooltip: + 'Updates the browser tab icon to show the progress of the current task.', + type: 'boolean', + defaultValue: true, + versionAdded: '1.20.0' } ] diff --git a/src/schemas/apiSchema.ts b/src/schemas/apiSchema.ts index 88990b311..69cb84804 100644 --- a/src/schemas/apiSchema.ts +++ b/src/schemas/apiSchema.ts @@ -463,7 +463,8 @@ const zSettings = z.object({ 'main.sub.setting.name': z.any(), 'single.setting': z.any(), 'LiteGraph.Node.DefaultPadding': z.boolean(), - 'LiteGraph.Pointer.TrackpadGestures': z.boolean() + 'LiteGraph.Pointer.TrackpadGestures': z.boolean(), + 'Comfy.Window.TabIconProgress': z.boolean() }) export type EmbeddingsResponse = z.infer