From 630e1edd2d2b75a0a39d1166ce4bd02a65528a0c Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Tue, 1 Sep 2026 17:27:47 -0700 Subject: [PATCH 1/5] WIP followup patches --- .../assets/composables/media/assetMappers.ts | 2 +- .../extensions/linearMode/useOutputHistory.ts | 4 +-- src/stores/assetsStore.ts | 7 +++-- src/utils/pagedList.ts | 28 +++++++++++++++---- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/platform/assets/composables/media/assetMappers.ts b/src/platform/assets/composables/media/assetMappers.ts index 1190cc0cd06..290b05be546 100644 --- a/src/platform/assets/composables/media/assetMappers.ts +++ b/src/platform/assets/composables/media/assetMappers.ts @@ -98,7 +98,7 @@ function flatAssetToResultItem(asset: AssetItem): ResultItemImpl { mediaType: getMediaTypeFromFilename(asset.name), nodeId: metadata?.nodeId ?? '', subfolder: metadata?.subfolder ?? '', - type: 'output' + type: asset.tags.includes('temp') ? 'temp' : 'output' }) } diff --git a/src/renderer/extensions/linearMode/useOutputHistory.ts b/src/renderer/extensions/linearMode/useOutputHistory.ts index 3445dfdf4c1..2a170a29646 100644 --- a/src/renderer/extensions/linearMode/useOutputHistory.ts +++ b/src/renderer/extensions/linearMode/useOutputHistory.ts @@ -9,7 +9,7 @@ import { flattenNodeOutput } from '@/renderer/extensions/linearMode/flattenNodeO import { useLinearOutputStore } from '@/renderer/extensions/linearMode/linearOutputStore' import { api } from '@/scripts/api' import { getJobDetail } from '@/services/jobOutputCache' -import { wrapPagedList } from '@/utils/pagedList' +import { WrappedList } from '@/utils/pagedList' import type { PagedList } from '@/utils/pagedList' import { useAssetsStore } from '@/stores/assetsStore' import { useAppModeStore } from '@/stores/appModeStore' @@ -69,7 +69,7 @@ export function useOutputHistory(): { ) } - const outputs = wrapPagedList(assetsStore.outputAssets, (items) => { + const outputs = new WrappedList(assetsStore.outputAssets, (items) => { const path = workflowStore.activeWorkflow?.path if (!path) return [] diff --git a/src/stores/assetsStore.ts b/src/stores/assetsStore.ts index 1331c5fd0fb..5747f351821 100644 --- a/src/stores/assetsStore.ts +++ b/src/stores/assetsStore.ts @@ -31,7 +31,7 @@ import { assetService } from '@/platform/assets/services/assetService' import type { AssetPaginationOptions } from '@/platform/assets/services/assetService' import type { JobListItem } from '@/platform/remote/comfyui/jobs/jobTypes' import { api } from '@/scripts/api' -import { wrapPagedList } from '@/utils/pagedList' +import { WrappedList } from '@/utils/pagedList' import type { PagedList } from '@/utils/pagedList' import { TaskItemImpl } from './queueStore' @@ -296,7 +296,10 @@ export const useAssetsStore = defineStore('assets', () => { assetsScope.run(() => { inputAssets.value = useAssetsQuery({ tags_any: ['input'] }) const flatAssets = useAssetsQuery({ tags_any: ['output', 'temp'] }) - outputAssets.value = wrapPagedList(flatAssets, unflattenOutputAssets) + outputAssets.value = new WrappedList( + flatAssets, + unflattenOutputAssets + ) }) } else { inputAssets.value = historyInputs diff --git a/src/utils/pagedList.ts b/src/utils/pagedList.ts index b34e65c478d..315802e6101 100644 --- a/src/utils/pagedList.ts +++ b/src/utils/pagedList.ts @@ -10,11 +10,29 @@ export interface PagedList { loadNew: () => Promise } -export function wrapPagedList( - list: PagedList, - transform: (items: readonly T[]) => T[] -): PagedList { - return { ...list, items: computed(() => transform(toValue(list.items))) } +export class WrappedList implements PagedList { + readonly items: MaybeRef + constructor( + private readonly childList: PagedList, + private readonly transform: (items: readonly T[]) => T[] + ) { + this.items = computed(() => this.transform(toValue(this.childList.items))) + } + get hasMore() { + return this.childList.hasMore + } + async invalidate() { + await this.childList.invalidate() + } + get isLoading() { + return this.childList.isLoading + } + async loadMore() { + await this.childList.loadMore() + } + async loadNew() { + await this.childList.loadNew() + } } interface CacheEntry { From dd76d79deb8f05e7c99f32cfa887fb5f526b0ab1 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Tue, 1 Sep 2026 21:23:43 -0700 Subject: [PATCH 2/5] Fix freeze on swap to linear mode Prior looses a `this` bind. And `this` is needed after swapping to classes. Thanks Alex --- src/renderer/extensions/linearMode/OutputHistory.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/extensions/linearMode/OutputHistory.vue b/src/renderer/extensions/linearMode/OutputHistory.vue index dd59d187ce1..8e54271b67b 100644 --- a/src/renderer/extensions/linearMode/OutputHistory.vue +++ b/src/renderer/extensions/linearMode/OutputHistory.vue @@ -219,7 +219,7 @@ watch( } ) -useInfiniteScroll(outputsRef, outputs.loadMore, { +useInfiniteScroll(outputsRef, () => outputs.loadMore(), { canLoadMore: () => toValue(outputs.hasMore) }) From 81d7c1d41d5aa01608835e65cf942566cb3eeae2 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Wed, 2 Sep 2026 00:23:11 -0700 Subject: [PATCH 3/5] Fix additional this unbinding --- src/utils/pagedList.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/pagedList.ts b/src/utils/pagedList.ts index 315802e6101..7bc50b80886 100644 --- a/src/utils/pagedList.ts +++ b/src/utils/pagedList.ts @@ -99,8 +99,8 @@ class SharedPagedList implements PagedList { get items() { return this.childList.items } - get loadMore() { - return this.childList.loadMore + async loadMore() { + await this.childList.loadMore() } async loadNew() { await Promise.all(this.overlapping().map((l) => l.loadNew())) From 33e6eef131f0c477a8d0548948d931dd463e22f2 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Wed, 2 Sep 2026 10:52:36 -0700 Subject: [PATCH 4/5] Add missing invalidate arg --- src/utils/pagedList.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/pagedList.ts b/src/utils/pagedList.ts index 7bc50b80886..e52c8e616dc 100644 --- a/src/utils/pagedList.ts +++ b/src/utils/pagedList.ts @@ -21,8 +21,8 @@ export class WrappedList implements PagedList { get hasMore() { return this.childList.hasMore } - async invalidate() { - await this.childList.invalidate() + async invalidate(stale?: string[]) { + await this.childList.invalidate(stale) } get isLoading() { return this.childList.isLoading From 08821cbad4adeb26b028dd77e0570f0e0ea01dd4 Mon Sep 17 00:00:00 2001 From: Amp Date: Wed, 2 Sep 2026 22:23:01 +0000 Subject: [PATCH 5/5] test: cover assets follow-up regressions Amp-Thread-ID: https://ampcode.com/threads/T-01a06424-bf1c-7689-87da-cae18151af35 --- .../composables/media/assetMappers.test.ts | 40 ++++++++++++++++- src/utils/pagedList.test.ts | 43 ++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/platform/assets/composables/media/assetMappers.test.ts b/src/platform/assets/composables/media/assetMappers.test.ts index 957b7442376..21d5ee97402 100644 --- a/src/platform/assets/composables/media/assetMappers.test.ts +++ b/src/platform/assets/composables/media/assetMappers.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it, vi } from 'vitest' -import { mapInputFileToAssetItem } from './assetMappers' +import { getOutputAssetMetadata } from '@/platform/assets/schemas/assetMetadataSchema' +import type { AssetItem } from '@/platform/assets/schemas/assetSchema' + +import { mapInputFileToAssetItem, unflattenOutputAssets } from './assetMappers' vi.mock('@/scripts/api', () => ({ api: { @@ -56,3 +59,38 @@ describe('mapInputFileToAssetItem', () => { expect(asset.tags).toEqual(['output']) }) }) + +describe('unflattenOutputAssets', () => { + it('preserves each output directory type', () => { + const asset = { + job_id: 'job-id', + size: 1, + created_at: '2026-01-01T00:00:00Z', + updated_at: '2026-01-01T00:00:00Z' + } + const assets = [ + { + ...asset, + id: 'temp-id', + name: 'preview.png', + tags: ['temp'] + }, + { + ...asset, + id: 'output-id', + name: 'saved.png', + created_at: '2026-01-01T00:00:01Z', + updated_at: '2026-01-01T00:00:01Z', + tags: ['output'] + } + ] satisfies AssetItem[] + + const [grouped] = unflattenOutputAssets(assets) + const metadata = getOutputAssetMetadata(grouped.user_metadata) + + expect(metadata?.allOutputs?.map((output) => output.type)).toEqual([ + 'temp', + 'output' + ]) + }) +}) diff --git a/src/utils/pagedList.test.ts b/src/utils/pagedList.test.ts index f6d23e999e7..e236d6e447d 100644 --- a/src/utils/pagedList.test.ts +++ b/src/utils/pagedList.test.ts @@ -3,7 +3,7 @@ import { computed, effectScope, ref, shallowRef, toValue } from 'vue' import type { Ref } from 'vue' import type { PagedList, SharedPagedListState } from './pagedList' -import { getPagedList, usePreemptableQueue } from './pagedList' +import { getPagedList, usePreemptableQueue, WrappedList } from './pagedList' function mockPagedList(initial: T[] = [], genNew?: () => T): PagedList { const items: Ref = shallowRef(initial) @@ -33,6 +33,47 @@ function makeShared( return (params: TParams) => getPagedList(params, state) } +describe('WrappedList', () => { + it('transforms items and delegates stateful operations', async () => { + const child = { + isLoading: ref(false), + items: ref([1, 2]), + get hasMore() { + return this.items.value.length < 3 + }, + async invalidate(stale?: string[]) { + this.items.value = this.items.value.filter( + (item) => !stale?.includes(String(item)) + ) + }, + async loadMore() { + this.items.value.push(3) + }, + async loadNew() { + this.items.value.unshift(0) + } + } + + const list = new WrappedList(child, (items) => + items.map((item) => item * 2) + ) + + expect(toValue(list.items)).toEqual([2, 4]) + expect(toValue(list.hasMore)).toBe(true) + expect(toValue(list.isLoading)).toBe(false) + + await list.loadMore() + expect(toValue(list.items)).toEqual([2, 4, 6]) + expect(toValue(list.hasMore)).toBe(false) + + await list.loadNew() + expect(toValue(list.items)).toEqual([0, 2, 4, 6]) + + await list.invalidate(['2']) + expect(toValue(list.items)).toEqual([0, 2, 6]) + }) +}) + describe('getPagedList', () => { it('same params share reactive state', async () => { const useShared = makeShared(