Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor(assets): use zAssetResponse.has_more in fetchFlatOutputs instead of page-size heuristic

Open
#12,339 1 comment 1 reaction 1 assignee Claimed by @dante01yoon View on GitHub
perf:speed
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

Follow-up from [#12006 review](https://github.com/Comfy-Org/ComfyUI_frontend/pull/12006#discussion_r3240955782) (thanks @pythongosssss).

## Problem

`useAssetsStore().fetchFlatOutputs` (`src/stores/assetsStore.ts:300`) derives `flatOutputHasMore` from `page.length === FLAT_OUTPUT_PAGE_SIZE`. When the final page is exactly `FLAT_OUTPUT_PAGE_SIZE` items the heuristic thinks there is more, so the next scroll-triggered `loadMoreFlatOutputs` fires an avoidable empty-page request.

The backend already returns the authoritative signal — `zAssetResponse` carries `has_more` — but `assetService.getAssetsByTag` drops it on the floor and only returns `AssetItem[]`.

## Proposed change

1. Widen `getAssetsByTag`'s return type to include `{ items: AssetItem[]; has_more: boolean }` (or a new `getAssetsByTagPage` variant if we don't want to churn input/models callers).
2. In `fetchFlatOutputs`, set `flatOutputHasMore.value = response.has_more` and remove the `page.length === FLAT_OUTPUT_PAGE_SIZE` check.
3. Update the `Flat Output Assets (cloud-only)` describe in `assetsStore.test.ts` to cover the exact-page-size terminal case.

## Acceptance

- Scrolling to the bottom of a result set whose total is a multiple of `FLAT_OUTPUT_PAGE_SIZE` issues exactly one terminal request, not two.
- `getAssetsByTag` callers (`updateInputs`, models browser, flat outputs) compile without unsafe property access on the new return shape.

Non-blocking; pure efficiency / code-quality cleanup.

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-12339-refactor-assets-use-zAssetResponse-has_more-in-fetchFlatOutputs-instead-of-page-siz-3656d73d3650814db19edff87733e8ec) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.