Deduplicate node title resolving

This commit is contained in:
Benjamin Lu
2026-01-23 18:58:49 -08:00
parent 4eb547b661
commit 9a2383d965
3 changed files with 40 additions and 16 deletions

View File

@@ -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(

View File

@@ -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<JobTab>('All')

View File

@@ -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)
}