diff --git a/src/services/jobOutputCache.ts b/src/services/jobOutputCache.ts index 4ae7140ef..4fcca2011 100644 --- a/src/services/jobOutputCache.ts +++ b/src/services/jobOutputCache.ts @@ -11,6 +11,7 @@ import QuickLRU from '@alloc/quick-lru' import type { JobDetail } from '@/platform/remote/comfyui/jobs/jobTypes' import { extractWorkflow } from '@/platform/remote/comfyui/jobs/fetchJobs' import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' +import { resultItemType } from '@/schemas/apiSchema' import type { ResultItem, TaskOutput } from '@/schemas/apiSchema' import { api } from '@/scripts/api' import { ResultItemImpl } from '@/stores/queueStore' @@ -101,7 +102,34 @@ function getPreviewableOutputs(outputs?: TaskOutput): ResultItemImpl[] { } function isResultItem(item: unknown): item is ResultItem { - return typeof item === 'object' && item !== null + if (!item || typeof item !== 'object' || Array.isArray(item)) { + return false + } + + const candidate = item as Record + + if ( + candidate.filename !== undefined && + typeof candidate.filename !== 'string' + ) { + return false + } + + if ( + candidate.subfolder !== undefined && + typeof candidate.subfolder !== 'string' + ) { + return false + } + + if ( + candidate.type !== undefined && + !resultItemType.safeParse(candidate.type).success + ) { + return false + } + + return true } export function getPreviewableOutputsFromJobDetail(