11<script setup lang="ts">
22import { capitalize } from ' es-toolkit'
3- import { computed , provide , ref , toRef , watch } from ' vue'
3+ import { computed , onMounted , provide , ref , toRef , watch } from ' vue'
44
55import { useWidgetValue } from ' @/composables/graph/useWidgetValue'
66import { useTransformCompatOverlayProps } from ' @/composables/useTransformCompatOverlayProps'
@@ -19,7 +19,7 @@ import { useAssetWidgetData } from '@/renderer/extensions/vueNodes/widgets/compo
1919import type { ResultItemType } from ' @/schemas/apiSchema'
2020import { api } from ' @/scripts/api'
2121import { useAssetsStore } from ' @/stores/assetsStore'
22- import { useQueueStore } from ' @/stores/queueStore '
22+ import { useOutputsStore } from ' @/stores/outputsStore '
2323import type { SimplifiedWidget } from ' @/types/simplifiedWidget'
2424import type { AssetKind } from ' @/types/widgetTypes'
2525import {
@@ -55,7 +55,8 @@ const { localValue, onChange } = useWidgetValue({
5555})
5656
5757const toastStore = useToastStore ()
58- const queueStore = useQueueStore ()
58+
59+ const outputsStore = useOutputsStore ()
5960
6061const transformCompatProps = useTransformCompatOverlayProps ()
6162
@@ -121,33 +122,30 @@ const inputItems = computed<DropdownItem[]>(() => {
121122const outputItems = computed <DropdownItem []>(() => {
122123 if (! [' image' , ' video' ].includes (props .assetKind ?? ' ' )) return []
123124
124- const outputs = new Set <string >()
125-
126- // Extract output images/videos from queue history
127- queueStore .historyTasks .forEach ((task ) => {
128- task .flatOutputs .forEach ((output ) => {
129- const isTargetType =
130- (props .assetKind === ' image' && output .mediaType === ' images' ) ||
131- (props .assetKind === ' video' && output .mediaType === ' video' )
132-
133- if (output .type === ' output' && isTargetType ) {
134- const path = output .subfolder
135- ? ` ${output .subfolder }/${output .filename } `
136- : output .filename
137- // Add [output] annotation so the preview component knows the type
138- const annotatedPath = ` ${path } [output] `
139- outputs .add (annotatedPath )
140- }
141- })
125+ const outputFiles = ((): string [] => {
126+ switch (props .assetKind ) {
127+ case ' image' :
128+ return outputsStore .outputImages
129+ case ' video' :
130+ return outputsStore .outputVideos
131+ case ' audio' :
132+ return outputsStore .outputAudios
133+ default :
134+ return []
135+ }
136+ })()
137+
138+ return outputFiles .map ((filename , index ) => {
139+ // Add [output] annotation so the preview component knows the type
140+ const annotatedPath = ` ${filename } [output] `
141+ return {
142+ id: ` output-${index } ` ,
143+ mediaSrc: getMediaUrl (filename , ' output' ),
144+ name: annotatedPath ,
145+ label: getDisplayLabel (annotatedPath ),
146+ metadata: ' '
147+ }
142148 })
143-
144- return Array .from (outputs ).map ((output , index ) => ({
145- id: ` output-${index } ` ,
146- mediaSrc: getMediaUrl (output .replace (' [output]' , ' ' ), ' output' ),
147- name: output ,
148- label: getDisplayLabel (output ),
149- metadata: ' '
150- }))
151149})
152150
153151const allItems = computed <DropdownItem []>(() => {
@@ -337,6 +335,11 @@ function getMediaUrl(
337335 if (! [' image' , ' video' ].includes (props .assetKind ?? ' ' )) return ' '
338336 return ` /api/view?filename=${encodeURIComponent (filename )}&type=${type } `
339337}
338+
339+ // Fetch output files on component mount
340+ onMounted (() => {
341+ outputsStore .fetchOutputFiles ()
342+ })
340343 </script >
341344
342345<template >
0 commit comments