Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d435968
feat(assets): group model library by model_type tags
synap5e Jun 18, 2026
01a51fc
refactor(assets): gate model_type grouping on supports_model_type_tags
synap5e Jun 18, 2026
86faaee
refactor(assets): run model-asset store on non-cloud builds
synap5e Jun 19, 2026
1897ec5
fix(assets): strip model_type: prefix from asset card type badge
synap5e Jun 21, 2026
31c043e
fix(assets): strip model_type: prefix from the asset browser title
synap5e Jun 22, 2026
979f01f
fix(assets): port model_type node-category resolution to resolveModel…
synap5e Jun 23, 2026
c8af4c5
fix(assets): keep reserved-tag constants local in assetMetadataUtils
synap5e Jun 23, 2026
7117caf
test(assets): restore mocks after each resolveModelNodeFromAsset test
synap5e Jun 23, 2026
ccc6a1f
fix(assets): prefer resolvable model_type over incidental slash tags
synap5e Jul 1, 2026
c34bef8
fix(assets): align badge and loader resolution with model_type tags
synap5e Jul 12, 2026
09877d7
fix(assets): surface refresh errors and harden pagination races
synap5e Jul 12, 2026
ece07cc
fix(assets): close pagination-termination and title-preservation gaps
synap5e Jul 12, 2026
d43ecf8
fix(assets): represent every category of a shared multi-type asset
synap5e Jul 12, 2026
74e4e38
fix(assets): dedupe category candidates and share pagination tolerance
synap5e Jul 20, 2026
8c3b946
test(assets): align cache tests with cursor pagination
synap5e Jul 23, 2026
b1b7b78
feat(assets): write model_type: tag from discovery
synap5e Jun 18, 2026
0f71ca4
test(assets): pin import write keeps user_metadata.model_type bare
synap5e Jun 19, 2026
c848833
fix(assets): recognize model_type: prefix in import type-mismatch guard
synap5e Jun 23, 2026
5101631
refactor(assets): require modelTypeMode on the write-path helpers
synap5e Jul 12, 2026
e0dfcd1
fix(assets): preserve sibling model_type memberships on re-type
synap5e Jul 20, 2026
179e7a3
fix(assets): guard toModelTypeTag against double-prefixing
synap5e Jul 20, 2026
93249d3
test(assets): restore getServerFeature mock in afterEach for order-in…
synap5e Jul 28, 2026
8a80fee
Merge remote-tracking branch 'origin/main' into synap5e/fe-1084-fe-wr…
synap5e Jul 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/platform/assets/components/modelInfo/ModelInfoPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ import { useI18n } from 'vue-i18n'

import EditableText from '@/components/common/EditableText.vue'
import { useCopyToClipboard } from '@/composables/useCopyToClipboard'
import { useFeatureFlags } from '@/composables/useFeatureFlags'
import PropertiesAccordionItem from '@/components/rightSidePanel/layout/PropertiesAccordionItem.vue'
import Button from '@/components/ui/button/Button.vue'
import Select from '@/components/ui/select/Select.vue'
Expand All @@ -231,15 +232,16 @@ import type { AssetDisplayItem } from '@/platform/assets/composables/useAssetBro
import { useModelTypes } from '@/platform/assets/composables/useModelTypes'
import type { AssetUserMetadata } from '@/platform/assets/schemas/assetSchema'
import {
buildModelTypeTagUpdate,
getAssetAdditionalTags,
getAssetBaseModels,
getAssetDescription,
getAssetDisplayName,
getAssetFilename,
getAssetModelType,
getAssetSourceUrl,
getAssetTriggerPhrases,
getAssetUserDescription,
getEditableModelType,
getSourceName
} from '@/platform/assets/utils/assetMetadataUtils'
import { useAssetsStore } from '@/stores/assetsStore'
Expand All @@ -265,6 +267,7 @@ const { asset, cacheKey, selectContentStyle } = defineProps<{
}>()

const assetsStore = useAssetsStore()
const { flags } = useFeatureFlags()
const { modelTypes } = useModelTypes()

const pendingUpdates = ref<AssetUserMetadata>({})
Expand Down Expand Up @@ -319,11 +322,16 @@ function handleDisplayNameEdit(newName: string) {

const debouncedSaveModelType = useDebounceFn((newModelType: string) => {
if (isImmutable.value) return
const currentModelType = getAssetModelType(asset)
const currentModelType = getEditableModelType(
asset,
flags.supportsModelTypeTags
)
if (currentModelType === newModelType) return
const newTags = asset.tags
.filter((tag) => tag !== currentModelType)
.concat(newModelType)
const newTags = buildModelTypeTagUpdate(
asset,
newModelType,
flags.supportsModelTypeTags
)
assetsStore.updateAssetTags(asset, newTags, cacheKey)
}, 500)

Expand All @@ -345,7 +353,10 @@ const userDescription = computed({
})

const selectedModelType = computed({
get: () => pendingModelType.value ?? getAssetModelType(asset) ?? undefined,
get: () =>
pendingModelType.value ??
getEditableModelType(asset, flags.supportsModelTypeTags) ??
undefined,
set: (value: string | undefined) => {
if (!value) return
pendingModelType.value = value
Expand Down
97 changes: 94 additions & 3 deletions src/platform/assets/composables/useUploadModelWizard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createI18n } from 'vue-i18n'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import type { AsyncUploadResponse } from '@/platform/assets/schemas/assetSchema'
import { api } from '@/scripts/api'

import { useUploadModelWizard } from './useUploadModelWizard'

Expand Down Expand Up @@ -38,7 +39,10 @@ vi.mock('@/scripts/api', () => ({
api: {
fetchApi: vi.fn(),
addEventListener: vi.fn(),
apiURL: vi.fn((path: string) => path)
apiURL: vi.fn((path: string) => path),
getServerFeature: vi.fn(
(_name: string, defaultValue?: unknown) => defaultValue
)
}
}))

Expand Down Expand Up @@ -90,6 +94,7 @@ describe('useUploadModelWizard', () => {
})

afterEach(() => {
vi.mocked(api.getServerFeature).mockReset()
for (const app of mountedApps.splice(0)) {
app.unmount()
}
Expand Down Expand Up @@ -135,7 +140,6 @@ describe('useUploadModelWizard', () => {
status: 'completed' as const
}
const event = new CustomEvent('asset_download', { detail })
const { api } = await import('@/scripts/api')
const handler = vi
.mocked(api.addEventListener)
.mock.calls.find((c) => c[0] === 'asset_download')?.[1] as
Expand Down Expand Up @@ -171,7 +175,6 @@ describe('useUploadModelWizard', () => {
expect(wizard.uploadStatus.value).toBe('processing')

// Simulate WebSocket: download fails
const { api } = await import('@/scripts/api')
const handler = vi
.mocked(api.addEventListener)
.mock.calls.find((c) => c[0] === 'asset_download')?.[1] as
Expand Down Expand Up @@ -279,6 +282,35 @@ describe('useUploadModelWizard', () => {
expect(result?.modelType).toBe('checkpoints')
})

it('namespaces the tag but keeps user_metadata.model_type bare when the backend supports it', async () => {
const { assetService } =
await import('@/platform/assets/services/assetService')
vi.mocked(assetService.uploadAssetAsync).mockResolvedValue({
type: 'sync',
asset: {
id: 'asset-1',
name: 'model.safetensors',
tags: ['models', 'model_type:checkpoints']
}
})
vi.mocked(api.getServerFeature).mockImplementation((name, defaultValue) =>
name === 'supports_model_type_tags' ? true : defaultValue
)

const wizard = setupUploadModelWizard(modelTypes, {
requiredModelType: 'checkpoints'
})
wizard.wizardData.value.url = 'https://civitai.com/models/12345'

await wizard.uploadModel()

const uploadArg = vi.mocked(assetService.uploadAssetAsync).mock.calls[0][0]
expect(uploadArg.tags).toEqual(['models', 'model_type:checkpoints'])
expect(uploadArg.user_metadata?.model_type).toBe('checkpoints')
// The namespaced returned tag must not trip the required-type guard.
expect(wizard.uploadTypeMismatch.value).toBeNull()
})

it('returns the synced asset filename for sync imports', async () => {
const { assetService } =
await import('@/platform/assets/services/assetService')
Expand Down Expand Up @@ -347,6 +379,65 @@ describe('useUploadModelWizard', () => {
})
})

it('treats a namespaced model_type: tag as satisfying the required type', async () => {
const { assetService } =
await import('@/platform/assets/services/assetService')
vi.mocked(assetService.uploadAssetAsync).mockResolvedValue({
type: 'sync',
asset: {
id: 'asset-1',
name: 'model.safetensors',
tags: ['models', 'model_type:checkpoints']
}
})

const wizard = setupUploadModelWizard(
ref([
{ name: 'Checkpoint', value: 'checkpoints' },
{ name: 'LoRA', value: 'loras' }
]),
{ requiredModelType: 'checkpoints' }
)
wizard.wizardData.value.url = 'https://civitai.com/models/12345'

const result = await wizard.uploadModel()

expect(result).not.toBeNull()
expect(wizard.uploadTypeMismatch.value).toBeNull()
})

it('strips the model_type: prefix from the imported-type label on a real mismatch', async () => {
const { assetService } =
await import('@/platform/assets/services/assetService')
vi.mocked(assetService.uploadAssetAsync).mockResolvedValue({
type: 'sync',
asset: {
id: 'asset-lora',
name: 'model.safetensors',
tags: ['models', 'model_type:loras']
}
})

const wizard = setupUploadModelWizard(
ref([
{ name: 'Checkpoint', value: 'checkpoints' },
{ name: 'LoRA', value: 'loras' }
]),
{ requiredModelType: 'checkpoints' }
)
wizard.wizardData.value.url = 'https://civitai.com/models/12345'

const result = await wizard.uploadModel()

expect(result).toBeNull()
expect(wizard.uploadTypeMismatch.value).toEqual({
importedModelType: 'loras',
importedModelTypeLabel: 'LoRA',
requiredModelType: 'checkpoints',
requiredModelTypeLabel: 'Checkpoint'
})
})

it('does not block sync imports as mismatches without a required model type', async () => {
const { assetService } =
await import('@/platform/assets/services/assetService')
Expand Down
27 changes: 20 additions & 7 deletions src/platform/assets/composables/useUploadModelWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'

import { useFeatureFlags } from '@/composables/useFeatureFlags'
import { st } from '@/i18n'
import { civitaiImportSource } from '@/platform/assets/importSources/civitaiImportSource'
import { huggingfaceImportSource } from '@/platform/assets/importSources/huggingfaceImportSource'
Expand All @@ -11,7 +12,11 @@ import type {
} from '@/platform/assets/schemas/assetSchema'
import { assetService } from '@/platform/assets/services/assetService'
import type { ImportSource } from '@/platform/assets/types/importSource'
import { getAssetFilename } from '@/platform/assets/utils/assetMetadataUtils'
import {
getAssetFilename,
stripModelTypePrefix,
toModelTypeTag
} from '@/platform/assets/utils/assetMetadataUtils'
import { validateSourceUrl } from '@/platform/assets/utils/importSourceUtil'
import { useAssetDownloadStore } from '@/stores/assetDownloadStore'
import { useAssetsStore } from '@/stores/assetsStore'
Expand Down Expand Up @@ -68,6 +73,7 @@ export function useUploadModelWizard(
options: UploadModelWizardOptions = {}
) {
const { t } = useI18n()
const { flags } = useFeatureFlags()
const assetsStore = useAssetsStore()
const assetDownloadStore = useAssetDownloadStore()
const modelToNodeStore = useModelToNodeStore()
Expand Down Expand Up @@ -271,19 +277,22 @@ export function useUploadModelWizard(
}

function getImportedModelType(asset: AssetItem): string | undefined {
const knownType = asset.tags.find(
(tag) =>
tag !== MODEL_ROOT_TAG &&
const subtypeTags = asset.tags
.filter((tag) => tag !== MODEL_ROOT_TAG)
.map(stripModelTypePrefix)
return (
subtypeTags.find((tag) =>
modelTypes.value.some((type) => type.value === tag)
) ?? subtypeTags[0]
)
return knownType ?? asset.tags.find((tag) => tag !== MODEL_ROOT_TAG)
}

function blockMismatchedImportedModel(
asset: AssetItem,
requiredType: string
): boolean {
if (asset.tags.includes(requiredType)) return false
if (asset.tags.map(stripModelTypePrefix).includes(requiredType))
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
return false

const importedType = getImportedModelType(asset)
uploadStatus.value = 'error'
Expand Down Expand Up @@ -317,7 +326,11 @@ export function useUploadModelWizard(

try {
const modelType = resolvedModelType.value
const tags = modelType ? ['models', modelType] : ['models']
const subtypeTag =
modelType && flags.supportsModelTypeTags
? toModelTypeTag(modelType)
: modelType
const tags = subtypeTag ? [MODEL_ROOT_TAG, subtypeTag] : [MODEL_ROOT_TAG]
Comment thread
synap5e marked this conversation as resolved.
Resolved
Comment on lines +329 to +333

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question — is the bare directory-path twin written synchronously?

With supportsModelTypeTags on, this creates a newly imported model as ['models', 'model_type:<x>'] via toModelTypeTag. But every category fetch in the FE filters server-side on the bare value:

  • assetService.ts:368 — getAssetModels(folder) → { includeTags: [MODELS_TAG, folder] }
  • assetService.ts:446 — { includeTags: [MODELS_TAG, category] }, where category is modelToNodeStore.getCategoryForNodeType(nodeType) (modelToNodeStore.ts:66-75), a bare nodeTypeToCategory lookup

I checked whether anything rewrites these on the way out — normalizeAssetTags (assetService.ts:208-210) only trims and drops empties, and no includeTags call site in the file prefixes with model_type:. So the FE genuinely never sends model_type:* in include_tags; the write side moved to the namespaced tag and the read side did not.

That makes the import path's correctness rest entirely on the backend behaviour asserted in the doc comment at assetMetadataUtils.ts:168:

the backend keeps the bare directory-path twin in sync

The timing of that sync is what I want to pin down, because the upload path re-reads immediately. refreshModelCaches() (useUploadModelWizard.ts:251-258) runs right after a successful upload (:380, :418) and goes updateModelsForNodeType → assetsStore.ts:672-679 → getAssetsForNodeType → include_tags=models,<bare>. So:

  • twin written in the same transaction → fine, no issue here.
  • twin written asynchronously → a visible race on every import: the refetch can land before the bare tag exists, and the model is missing from the browser until something else triggers a refresh.
  • twin not written at all → imported models never appear under their category.

Is the twin write part of the same transaction as the asset create? If it's eventually-consistent, this probably wants the FE to send both forms in include_tags (or the upload path to optimistically insert) rather than relying on read-after-write.

@synap5e synap5e Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered comprehensively on #12948 (#12948 (comment)): cloud writes the twin synchronously in one Ent transaction; core (#14511) writes model_type: only, no bare twin. The sidebar handles core's namespaced-only tags by bucketing the single models walk client-side (modelFolderFromTag keyed on supports_model_type_tags), so it needs no bare twin, and the only server-side bare-tag fetch is isCloud-gated. FE-originated uploads write bare names via useModelTypes and are unaffected. Details in that comment.

Posted by Claude Code on Simon's behalf.

const filename =
wizardData.value.metadata?.filename ||
wizardData.value.metadata?.name ||
Expand Down
Loading
Loading