mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
[backport core/1.41] fix: use order-independent tag matching in asset browser categories (#10072)
Backport of #9843 to `core/1.41` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10072-backport-core-1-41-fix-use-order-independent-tag-matching-in-asset-browser-categories-3256d73d365081f790b5f092d8e32b8a) by [Unito](https://www.unito.io) Co-authored-by: Luke Mino-Altherr <luke@comfy.org> Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -692,6 +692,25 @@ describe('useAssetBrowser', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('extracts categories regardless of tag order', () => {
|
||||
const assets = [
|
||||
createApiAsset({ tags: ['checkpoints', 'models'] }),
|
||||
createApiAsset({ tags: ['loras', 'models'] }),
|
||||
createApiAsset({ tags: ['models', 'vae'] })
|
||||
]
|
||||
|
||||
const { navItems } = useAssetBrowser(ref(assets))
|
||||
|
||||
const typeGroup = navItems.value[2] as {
|
||||
items: { id: string }[]
|
||||
}
|
||||
expect(typeGroup.items.map((i) => i.id)).toEqual([
|
||||
'checkpoints',
|
||||
'loras',
|
||||
'vae'
|
||||
])
|
||||
})
|
||||
|
||||
it('ignores non-models root tags', () => {
|
||||
const assets = [
|
||||
createApiAsset({ tags: ['input', 'images'] }),
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
getAssetBaseModels,
|
||||
getAssetFilename
|
||||
} from '@/platform/assets/utils/assetMetadataUtils'
|
||||
import { MODELS_TAG } from '@/platform/assets/services/assetService'
|
||||
import { sortAssets } from '@/platform/assets/utils/assetSortUtils'
|
||||
import { useAssetDownloadStore } from '@/stores/assetDownloadStore'
|
||||
import type { NavGroupData, NavItemData } from '@/types/navTypes'
|
||||
@@ -123,9 +124,10 @@ export function useAssetBrowser(
|
||||
|
||||
const typeCategories = computed<NavItemData[]>(() => {
|
||||
const categories = assets.value
|
||||
.filter((asset) => asset.tags[0] === 'models')
|
||||
.map((asset) => asset.tags[1])
|
||||
.filter((tag): tag is string => typeof tag === 'string' && tag.length > 0)
|
||||
.filter((asset) => asset.tags.includes(MODELS_TAG))
|
||||
.flatMap((asset) =>
|
||||
asset.tags.filter((tag) => tag !== MODELS_TAG && tag.length > 0)
|
||||
)
|
||||
.map((tag) => tag.split('/')[0])
|
||||
|
||||
return Array.from(new Set(categories))
|
||||
|
||||
Reference in New Issue
Block a user