From f0f554392d1dac4544df114886fad4d0d6504212 Mon Sep 17 00:00:00 2001 From: Jin Yi Date: Fri, 14 Nov 2025 04:15:44 +0900 Subject: [PATCH] feat: Add pagination support for media assets history (#6373) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Implement pagination for media assets history to handle large datasets efficiently - Add infinite scroll support with approach-end event handler - Support offset parameter in history API for both V1 and V2 endpoints ## Changes - Add offset parameter support to `api.getHistory()` method - Update history fetchers (V1/V2) to include offset in API requests - Implement `loadMoreHistory()` in assetsStore with pagination state management - Add `loadMore`, `hasMore`, and `isLoadingMore` to IAssetsProvider interface - Add approach-end handler in AssetsSidebarTab for infinite scroll - Set BATCH_SIZE to 200 for efficient loading ## Implementation Improvements Simplified offset-based pagination by removing unnecessary reconciliation logic: - Remove `reconcileHistory`, `taskItemsMap`, `lastKnownQueueIndex` (offset is sufficient) - Replace `assetItemsByPromptId` Map → `loadedIds` Set (store IDs only) - Replace `findInsertionIndex` binary search → push + sort (faster for batch operations) - Replace `loadingPromise` → `isLoadingMore` boolean (simpler state management) - Fix memory leak by cleaning up Set together with array slice ## Test Plan - [x] TypeScript compilation passes - [x] ESLint and Prettier formatting applied - [x] Test infinite scroll in media assets tab - [x] Verify network requests include correct offset parameter - [x] Confirm no duplicate items when loading more 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude --- .../sidebar/tabs/AssetSidebarTemplate.vue | 4 +- .../sidebar/tabs/AssetsSidebarTab.vue | 54 +- .../assets/components/Media3DBottom.vue | 6 +- .../assets/components/MediaAudioBottom.vue | 6 +- .../assets/components/MediaVideoBottom.vue | 3 +- .../assets/components/MediaVideoTop.vue | 6 +- .../composables/media/IAssetsProvider.ts | 15 + .../assets/composables/media/useAssetsApi.ts | 19 +- .../composables/media/useInternalFilesApi.ts | 19 +- src/platform/assets/schemas/assetSchema.ts | 2 +- .../history/fetchers/fetchHistoryV1.ts | 19 +- .../history/fetchers/fetchHistoryV2.ts | 19 +- src/scripts/api.ts | 9 +- src/stores/assetsStore.ts | 162 ++++- tests-ui/tests/store/assetsStore.test.ts | 614 +++++++++++++----- 15 files changed, 735 insertions(+), 222 deletions(-) diff --git a/src/components/sidebar/tabs/AssetSidebarTemplate.vue b/src/components/sidebar/tabs/AssetSidebarTemplate.vue index f7de9022d..6e139f7a6 100644 --- a/src/components/sidebar/tabs/AssetSidebarTemplate.vue +++ b/src/components/sidebar/tabs/AssetSidebarTemplate.vue @@ -14,8 +14,8 @@ - -