mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Unrestrict text outptu display
This commit is contained in:
@@ -141,6 +141,7 @@ import { computed, defineAsyncComponent, provide, ref, toRef } from 'vue'
|
||||
import IconGroup from '@/components/button/IconGroup.vue'
|
||||
import LoadingOverlay from '@/components/common/LoadingOverlay.vue'
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { getOutputAssetMetadata } from '@/platform/assets/schemas/assetMetadataSchema'
|
||||
import { useAssetsStore } from '@/stores/assetsStore'
|
||||
import {
|
||||
formatDuration,
|
||||
@@ -160,7 +161,8 @@ import type { MediaKind } from '../schemas/mediaAssetSchema'
|
||||
import { MediaAssetKey } from '../schemas/mediaAssetSchema'
|
||||
import MediaTitle from './MediaTitle.vue'
|
||||
|
||||
type PreviewKind = ReturnType<typeof getMediaTypeFromFilename>
|
||||
const MEDIA_TYPES = ['video', 'audio', 'image', '3D', 'text', 'other'] as const
|
||||
type PreviewKind = (typeof MEDIA_TYPES)[number]
|
||||
|
||||
const mediaComponents = {
|
||||
top: {
|
||||
@@ -221,7 +223,15 @@ const fileKind = computed((): MediaKind => {
|
||||
return getMediaTypeFromFilename(asset?.name || '')
|
||||
})
|
||||
|
||||
function isValidMediaType(val: string): val is PreviewKind {
|
||||
return MEDIA_TYPES.includes(val as PreviewKind)
|
||||
}
|
||||
|
||||
const previewKind = computed((): PreviewKind => {
|
||||
const type = getOutputAssetMetadata(asset?.user_metadata)?.allOutputs?.at(
|
||||
-1
|
||||
)?.mediaType
|
||||
if (type && isValidMediaType(type)) return type
|
||||
return getMediaTypeFromFilename(asset?.name || '')
|
||||
})
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ describe('TaskItemImpl', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.skip('should parse text outputs', () => {
|
||||
it('should parse text outputs', () => {
|
||||
const job: JobListItem = {
|
||||
...createHistoryJob(0, 'text-job'),
|
||||
preview_output: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { NodeExecutionOutput, ResultItem } from '@/schemas/apiSchema'
|
||||
import { resultItemType } from '@/schemas/apiSchema'
|
||||
import { ResultItemImpl } from '@/stores/queueStore'
|
||||
|
||||
const METADATA_KEYS = new Set(['animated', 'text'])
|
||||
const METADATA_KEYS = new Set(['animated'])
|
||||
|
||||
/**
|
||||
* Validates that an unknown value is a well-formed ResultItem.
|
||||
@@ -15,8 +15,6 @@ function isResultItem(item: unknown): item is ResultItem {
|
||||
|
||||
const candidate = item as Record<string, unknown>
|
||||
|
||||
if (typeof candidate.filename !== 'string') return false
|
||||
|
||||
if (
|
||||
candidate.type !== undefined &&
|
||||
!resultItemType.safeParse(candidate.type).success
|
||||
@@ -35,6 +33,11 @@ export function parseNodeOutput(
|
||||
.filter(([key, value]) => !METADATA_KEYS.has(key) && Array.isArray(value))
|
||||
.flatMap(([mediaType, items]) =>
|
||||
(items as unknown[])
|
||||
.map((item) =>
|
||||
mediaType === 'text' && typeof item === 'string'
|
||||
? { nodeId, mediaType, content: item }
|
||||
: item
|
||||
)
|
||||
.filter(isResultItem)
|
||||
.map((item) => new ResultItemImpl({ ...item, mediaType, nodeId }))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user