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..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,15 @@ function createAssetService() { return EMPTY_PAGE } - // Fetch assets for this category using same API pattern as getAssetModels 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..a62a1ecc99b 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 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 () => { mockFetchEmpty() mockFetchEmpty() diff --git a/src/platform/assets/utils/assetPreviewUtil.ts b/src/platform/assets/utils/assetPreviewUtil.ts index 4170316f348..22a4edd0b81 100644 --- a/src/platform/assets/utils/assetPreviewUtil.ts +++ b/src/platform/assets/utils/assetPreviewUtil.ts @@ -21,10 +21,10 @@ export function isAssetPreviewSupported(): boolean { return useFeatureFlags().flags.assetsEnabled } -async function fetchAssets( +async function fetchOwnAssets( params: Record ): Promise { - const query = new URLSearchParams(params) + const query = new URLSearchParams({ ...params, include_public: 'false' }) const res = await api.fetchApi(`/assets?${query}`) if (!res.ok) return [] const data = await res.json() @@ -46,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) }