mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 17:37:46 +00:00
## Summary Rename all internal TypeScript usage of legacy `promptId`/`PromptId` naming to `jobId`/`JobId` across ~38 files for consistency with the domain model. ## Changes - **What**: Renamed internal variable names, type aliases, function names, class getters, interface fields, and comments from `promptId`/`PromptId` to `jobId`/`JobId`. Wire-protocol field names (`prompt_id` in Zod schemas and `e.detail.prompt_id` accesses) are intentionally preserved since they match the backend API contract. ## Review Focus - All changes are pure renames with no behavioral changes - Wire-protocol fields (`prompt_id`) are deliberately unchanged to maintain backend compatibility - Test fixtures updated to use consistent `job-id` naming ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8730-refactor-rename-internal-promptId-PromptId-to-jobId-JobId-3016d73d3650813ca40ce337f7c5271a) 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.activeJob?.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)
|
|
}
|