mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
- Hide "*" indicator in the browser tab title when autosave is enabled (Comfy.Workflow.AutoSave === 'after delay'). - Refactor: extract readable computed values (`shouldShowUnsavedIndicator`, `isActiveWorkflowModified`, `isActiveWorkflowPersisted`). - Aligns with workflow tab behavior; also hides while Shift is held (matches in-app tab logic). Files touched: - src/composables/useBrowserTabTitle.ts Validation: - Ran `pnpm lint:fix` and `pnpm typecheck` — both passed. Manual test suggestions: - With autosave set to 'after delay': modify a workflow → browser tab should not show `*`. - With autosave 'off': modify or open non-persisted workflow → browser tab shows `*`. - Hold Shift: indicator hidden while held (consistent with workflow tab). ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6568-Hide-browser-tab-star-when-autosave-is-enabled-refactor-title-logic-2a16d73d365081549906e9d1fed07a42) by [Unito](https://www.unito.io)
96 lines
2.9 KiB
TypeScript
96 lines
2.9 KiB
TypeScript
import { useTitle } from '@vueuse/core'
|
|
import { computed } from 'vue'
|
|
|
|
import { t } from '@/i18n'
|
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
|
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
|
import { useExecutionStore } from '@/stores/executionStore'
|
|
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
|
|
|
const DEFAULT_TITLE = 'ComfyUI'
|
|
const TITLE_SUFFIX = ' - ComfyUI'
|
|
|
|
export const useBrowserTabTitle = () => {
|
|
const executionStore = useExecutionStore()
|
|
const settingStore = useSettingStore()
|
|
const workflowStore = useWorkflowStore()
|
|
const workspaceStore = useWorkspaceStore()
|
|
|
|
const executionText = computed(() =>
|
|
executionStore.isIdle
|
|
? ''
|
|
: `[${Math.round(executionStore.executionProgress * 100)}%]`
|
|
)
|
|
|
|
const newMenuEnabled = computed(
|
|
() => settingStore.get('Comfy.UseNewMenu') !== 'Disabled'
|
|
)
|
|
|
|
const isAutoSaveEnabled = computed(
|
|
() => settingStore.get('Comfy.Workflow.AutoSave') === 'after delay'
|
|
)
|
|
|
|
const isActiveWorkflowModified = computed(
|
|
() => !!workflowStore.activeWorkflow?.isModified
|
|
)
|
|
const isActiveWorkflowPersisted = computed(
|
|
() => !!workflowStore.activeWorkflow?.isPersisted
|
|
)
|
|
|
|
const shouldShowUnsavedIndicator = computed(() => {
|
|
if (workspaceStore.shiftDown) return false
|
|
if (isAutoSaveEnabled.value) return false
|
|
if (!isActiveWorkflowPersisted.value) return true
|
|
if (isActiveWorkflowModified.value) return true
|
|
return false
|
|
})
|
|
|
|
const isUnsavedText = computed(() =>
|
|
shouldShowUnsavedIndicator.value ? ' *' : ''
|
|
)
|
|
const workflowNameText = computed(() => {
|
|
const workflowName = workflowStore.activeWorkflow?.filename
|
|
return workflowName
|
|
? isUnsavedText.value + workflowName + TITLE_SUFFIX
|
|
: DEFAULT_TITLE
|
|
})
|
|
|
|
const nodeExecutionTitle = computed(() => {
|
|
// Check if any nodes are in progress
|
|
const nodeProgressEntries = Object.entries(
|
|
executionStore.nodeProgressStates
|
|
)
|
|
const runningNodes = nodeProgressEntries.filter(
|
|
([_, state]) => state.state === 'running'
|
|
)
|
|
|
|
if (runningNodes.length === 0) {
|
|
return ''
|
|
}
|
|
|
|
// If multiple nodes are running
|
|
if (runningNodes.length > 1) {
|
|
return `${executionText.value}[${runningNodes.length} ${t('g.nodesRunning', 'nodes running')}]`
|
|
}
|
|
|
|
// If only one node is running
|
|
const [nodeId, state] = runningNodes[0]
|
|
const progress = Math.round((state.value / state.max) * 100)
|
|
const nodeType =
|
|
executionStore.activePrompt?.workflow?.changeTracker?.activeState.nodes.find(
|
|
(n) => String(n.id) === nodeId
|
|
)?.type || 'Node'
|
|
|
|
return `${executionText.value}[${progress}%] ${nodeType}`
|
|
})
|
|
|
|
const workflowTitle = computed(
|
|
() =>
|
|
executionText.value +
|
|
(newMenuEnabled.value ? workflowNameText.value : DEFAULT_TITLE)
|
|
)
|
|
|
|
const title = computed(() => nodeExecutionTitle.value || workflowTitle.value)
|
|
useTitle(title)
|
|
}
|