From cbacc76b9fac18d11c14a6ace439b4cf5f04ab4c Mon Sep 17 00:00:00 2001 From: bymyself Date: Sun, 1 Nov 2026 21:51:16 +0000 Subject: [PATCH 1/3] fix(assets): send include_public explicitly from model pickers and output lookup Two asset list calls still relied on the server's include_public=true default: - getAssetsPageForNodeType (model pickers) now asks for public models explicitly, so it keeps working when the default changes. - findOutputAsset (thumbnail lookup for outputs) now sends include_public=false, so a public catalog file with the same name can never be matched as the user's own output. Production telemetry counts thousands of list requests a day that omit the parameter, which blocks flipping the server default. --- src/platform/assets/services/assetService.test.ts | 12 ++++++++++++ src/platform/assets/services/assetService.ts | 11 ++++++++++- src/platform/assets/utils/assetPreviewUtil.test.ts | 14 ++++++++++++++ src/platform/assets/utils/assetPreviewUtil.ts | 3 ++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/platform/assets/services/assetService.test.ts b/src/platform/assets/services/assetService.test.ts index b7b6b6c3835..ec8abdf6479 100644 --- a/src/platform/assets/services/assetService.test.ts +++ b/src/platform/assets/services/assetService.test.ts @@ -1439,6 +1439,18 @@ describe(assetService.getAssetsPageForNodeType, () => { }) describe(assetService.getAssetsForNodeType, () => { + it('asks for public models explicitly instead of relying on the server default', async () => { + vi.mocked(api.fetchApi).mockResolvedValueOnce( + buildAssetListResponse([validAsset({ id: 'ckpt-1' })]) + ) + + await assetService.getAssetsForNodeType('CheckpointLoaderSimple') + + const requestedUrl = vi.mocked(api.fetchApi).mock.calls[0]?.[0] + const params = new URL(requestedUrl, 'http://localhost').searchParams + expect(params.get('include_public')).toBe('true') + }) + it('returns just the assets array from the page response', async () => { vi.mocked(api.fetchApi).mockResolvedValueOnce( buildAssetListResponse([validAsset({ id: 'ckpt-1' })], { hasMore: true }) diff --git a/src/platform/assets/services/assetService.ts b/src/platform/assets/services/assetService.ts index 9b288d4fc3a..473e3d65984 100644 --- a/src/platform/assets/services/assetService.ts +++ b/src/platform/assets/services/assetService.ts @@ -629,8 +629,17 @@ function createAssetService() { } // Fetch assets for this category using same API pattern as getAssetModels + // Model pickers need the shared catalog; ask for it explicitly so the + // server can stop defaulting include_public to true (BE-20085). return await handleAssetRequest( - { includeTags: [MODELS_TAG, category], limit, offset, after, signal }, + { + includeTags: [MODELS_TAG, category], + limit, + offset, + after, + includePublic: true, + signal + }, `assets for ${nodeType}` ) } diff --git a/src/platform/assets/utils/assetPreviewUtil.test.ts b/src/platform/assets/utils/assetPreviewUtil.test.ts index 0471cbdeada..d15d98d96f6 100644 --- a/src/platform/assets/utils/assetPreviewUtil.test.ts +++ b/src/platform/assets/utils/assetPreviewUtil.test.ts @@ -144,6 +144,20 @@ describe('findOutputAsset', () => { expect(result).toEqual(localAsset) }) + it("only searches the user's own assets, never the public catalog", async () => { + mockFetchEmpty() + mockFetchEmpty() + + await findOutputAsset('ComfyUI_00081_.glb') + + const urls = vi.mocked(api.fetchApi).mock.calls.map(([url]) => url) + expect(urls).toHaveLength(2) + for (const url of urls) { + const params = new URL(url, 'http://localhost').searchParams + expect(params.get('include_public')).toBe('false') + } + }) + it('returns undefined when no asset matches', async () => { mockFetchEmpty() mockFetchEmpty() diff --git a/src/platform/assets/utils/assetPreviewUtil.ts b/src/platform/assets/utils/assetPreviewUtil.ts index 4170316f348..f1f7e182009 100644 --- a/src/platform/assets/utils/assetPreviewUtil.ts +++ b/src/platform/assets/utils/assetPreviewUtil.ts @@ -24,7 +24,8 @@ export function isAssetPreviewSupported(): boolean { async function fetchAssets( params: Record ): Promise { - const query = new URLSearchParams(params) + // Outputs are always the user's own; never match a public catalog asset. + const query = new URLSearchParams({ ...params, include_public: 'false' }) const res = await api.fetchApi(`/assets?${query}`) if (!res.ok) return [] const data = await res.json() From ea02ae22b8a85c1e4b898f5cf6abf6f335282228 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sun, 1 Nov 2026 22:21:04 +0000 Subject: [PATCH 2/3] refactor(assets): drop code comments, name the output lookup fetchOwnAssets Review: https://github.com/Comfy-Org/ComfyUI_frontend/pull/22650#pullrequestreview (AGENTS.md disallows code comments). --- src/platform/assets/services/assetService.ts | 4 ---- src/platform/assets/utils/assetPreviewUtil.ts | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/platform/assets/services/assetService.ts b/src/platform/assets/services/assetService.ts index 473e3d65984..4d87eae5e9a 100644 --- a/src/platform/assets/services/assetService.ts +++ b/src/platform/assets/services/assetService.ts @@ -620,7 +620,6 @@ function createAssetService() { return EMPTY_PAGE } - // Find the category for this node type using efficient O(1) lookup const modelToNodeStore = useModelToNodeStore() const category = modelToNodeStore.getCategoryForNodeType(nodeType) @@ -628,9 +627,6 @@ function createAssetService() { return EMPTY_PAGE } - // Fetch assets for this category using same API pattern as getAssetModels - // Model pickers need the shared catalog; ask for it explicitly so the - // server can stop defaulting include_public to true (BE-20085). return await handleAssetRequest( { includeTags: [MODELS_TAG, category], diff --git a/src/platform/assets/utils/assetPreviewUtil.ts b/src/platform/assets/utils/assetPreviewUtil.ts index f1f7e182009..22a4edd0b81 100644 --- a/src/platform/assets/utils/assetPreviewUtil.ts +++ b/src/platform/assets/utils/assetPreviewUtil.ts @@ -21,10 +21,9 @@ export function isAssetPreviewSupported(): boolean { return useFeatureFlags().flags.assetsEnabled } -async function fetchAssets( +async function fetchOwnAssets( params: Record ): Promise { - // Outputs are always the user's own; never match a public catalog asset. const query = new URLSearchParams({ ...params, include_public: 'false' }) const res = await api.fetchApi(`/assets?${query}`) if (!res.ok) return [] @@ -47,11 +46,11 @@ export function resolvePreviewUrl(asset: AssetRecord): string { export async function findOutputAsset( name: string ): Promise { - const byHash = await fetchAssets({ hash: name }) + const byHash = await fetchOwnAssets({ hash: name }) const hashMatch = byHash.find((a) => a.hash === name) if (hashMatch) return hashMatch - const byName = await fetchAssets({ name_contains: name }) + const byName = await fetchOwnAssets({ name_contains: name }) return byName.find((a) => a.name === name) } From ee93175733f77a08db96e1485c4fef2a4d444d5e Mon Sep 17 00:00:00 2001 From: bymyself Date: Sun, 1 Nov 2026 22:37:32 +0000 Subject: [PATCH 3/3] test(assets): assert include_public across both lookups without a loop --- src/platform/assets/utils/assetPreviewUtil.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/platform/assets/utils/assetPreviewUtil.test.ts b/src/platform/assets/utils/assetPreviewUtil.test.ts index d15d98d96f6..a62a1ecc99b 100644 --- a/src/platform/assets/utils/assetPreviewUtil.test.ts +++ b/src/platform/assets/utils/assetPreviewUtil.test.ts @@ -150,12 +150,12 @@ describe('findOutputAsset', () => { await findOutputAsset('ComfyUI_00081_.glb') - const urls = vi.mocked(api.fetchApi).mock.calls.map(([url]) => url) - expect(urls).toHaveLength(2) - for (const url of urls) { - const params = new URL(url, 'http://localhost').searchParams - expect(params.get('include_public')).toBe('false') - } + const includePublic = vi + .mocked(api.fetchApi) + .mock.calls.map(([url]) => + new URL(url, 'http://localhost').searchParams.get('include_public') + ) + expect(includePublic).toEqual(['false', 'false']) }) it('returns undefined when no asset matches', async () => {