From 9a2383d9657870fb26242154bfd18060ee7f418a Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Fri, 23 Jan 2026 18:58:49 -0800 Subject: [PATCH] Deduplicate node title resolving --- .../queue/QueueInlineProgressSummary.vue | 14 ++++------ src/composables/queue/useJobList.ts | 14 ++++------ src/utils/nodeTitleUtil.ts | 28 +++++++++++++++++++ 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 src/utils/nodeTitleUtil.ts diff --git a/src/components/queue/QueueInlineProgressSummary.vue b/src/components/queue/QueueInlineProgressSummary.vue index 0ab749928..758c5d316 100644 --- a/src/components/queue/QueueInlineProgressSummary.vue +++ b/src/components/queue/QueueInlineProgressSummary.vue @@ -37,7 +37,7 @@ import { useI18n } from 'vue-i18n' import { st } from '@/i18n' import { useQueueProgress } from '@/composables/queue/useQueueProgress' import { useExecutionStore } from '@/stores/executionStore' -import { normalizeI18nKey } from '@/utils/formatUtil' +import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil' const props = defineProps<{ hidden?: boolean @@ -53,13 +53,11 @@ const { } = useQueueProgress() const currentNodeName = computed(() => { - const node = executionStore.executingNode - if (!node) return t('g.emDash') - const title = (node.title ?? '').toString().trim() - if (title) return title - const nodeType = (node.type ?? '').toString().trim() || t('g.untitled') - const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name` - return st(key, nodeType) + return resolveNodeDisplayName(executionStore.executingNode, { + emptyLabel: t('g.emDash'), + untitledLabel: t('g.untitled'), + st + }) }) const shouldShow = computed( diff --git a/src/composables/queue/useJobList.ts b/src/composables/queue/useJobList.ts index 9d5a73e50..715778adb 100644 --- a/src/composables/queue/useJobList.ts +++ b/src/composables/queue/useJobList.ts @@ -17,7 +17,7 @@ import { isToday, isYesterday } from '@/utils/dateTimeUtil' -import { normalizeI18nKey } from '@/utils/formatUtil' +import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil' import { buildJobDisplay } from '@/utils/queueDisplay' import { jobStateFromTask } from '@/utils/queueUtil' @@ -185,13 +185,11 @@ export function useJobList() { executionStore.isPromptInitializing(promptId) const currentNodeName = computed(() => { - const node = executionStore.executingNode - if (!node) return t('g.emDash') - const title = (node.title ?? '').toString().trim() - if (title) return title - const nodeType = (node.type ?? '').toString().trim() || t('g.untitled') - const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name` - return st(key, nodeType) + return resolveNodeDisplayName(executionStore.executingNode, { + emptyLabel: t('g.emDash'), + untitledLabel: t('g.untitled'), + st + }) }) const selectedJobTab = ref('All') diff --git a/src/utils/nodeTitleUtil.ts b/src/utils/nodeTitleUtil.ts new file mode 100644 index 000000000..18f8b23ec --- /dev/null +++ b/src/utils/nodeTitleUtil.ts @@ -0,0 +1,28 @@ +import { normalizeI18nKey } from '@/utils/formatUtil' + +export type NodeTitleInfo = { + title?: string | number | null + type?: string | number | null +} + +export type StaticTranslate = (key: string, fallbackMessage: string) => string + +type ResolveNodeDisplayNameOptions = { + emptyLabel: string + untitledLabel: string + st: StaticTranslate +} + +export function resolveNodeDisplayName( + node: NodeTitleInfo | null | undefined, + options: ResolveNodeDisplayNameOptions +): string { + if (!node) return options.emptyLabel + + const title = (node.title ?? '').toString().trim() + if (title.length > 0) return title + + const nodeType = (node.type ?? '').toString().trim() || options.untitledLabel + const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name` + return options.st(key, nodeType) +}