Fix prop confirmation bug, add Wan 2.7 model, refine multiple UI details, improve prop generation quality and aspect ratio, remove text overlays from Asset Center created images, and optimize prop filtering logic

This commit is contained in:
saturn
2026-04-03 22:36:41 +08:00
parent 854b932e67
commit 78b93331b4
136 changed files with 3393 additions and 875 deletions

View File

@@ -1,6 +1,6 @@
import type { Job } from 'bullmq'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { CHARACTER_PROMPT_SUFFIX } from '@/lib/constants'
import { CHARACTER_ASSET_IMAGE_RATIO, CHARACTER_PROMPT_SUFFIX, PROP_IMAGE_RATIO, PROP_PROMPT_SUFFIX } from '@/lib/constants'
import { TASK_TYPE, type TaskJobData } from '@/lib/task/types'
const workersUtilsMock = vi.hoisted(() => ({
@@ -27,7 +27,7 @@ const prismaMock = vi.hoisted(() => ({
}))
const sharedMock = vi.hoisted(() => ({
generateLabeledImageToCos: vi.fn(async () => 'cos/generated-character.png'),
generateCleanImageToStorage: vi.fn(async () => 'cos/generated-character.png'),
parseJsonStringArray: vi.fn(() => []),
}))
@@ -39,7 +39,7 @@ vi.mock('@/lib/workers/handlers/image-task-handler-shared', async () => {
)
return {
...actual,
generateLabeledImageToCos: sharedMock.generateLabeledImageToCos,
generateCleanImageToStorage: sharedMock.generateCleanImageToStorage,
parseJsonStringArray: sharedMock.parseJsonStringArray,
}
})
@@ -93,13 +93,19 @@ describe('asset hub character image prompt suffix regression', () => {
await handleAssetHubImageTask(job)
const generationCall = sharedMock.generateLabeledImageToCos.mock.calls[0] as unknown as [{ prompt?: string }] | undefined
const generationCall = sharedMock.generateCleanImageToStorage.mock.calls[0] as unknown as [{
prompt?: string
options?: { aspectRatio?: string }
label?: string
}] | undefined
const callArg = generationCall?.[0]
const prompt = callArg?.prompt || ''
expect(prompt).toContain('主角,黑发,冷静')
expect(prompt).toContain(CHARACTER_PROMPT_SUFFIX)
expect(countOccurrences(prompt, CHARACTER_PROMPT_SUFFIX)).toBe(1)
expect(callArg?.options).toEqual(expect.objectContaining({ aspectRatio: CHARACTER_ASSET_IMAGE_RATIO }))
expect(callArg?.label).toBeUndefined()
})
it('honors requested count for global location generation', async () => {
@@ -124,11 +130,42 @@ describe('asset hub character image prompt suffix regression', () => {
locationId: 'global-location-1',
imageCount: 1,
})
expect(sharedMock.generateLabeledImageToCos).toHaveBeenCalledTimes(1)
expect(sharedMock.generateCleanImageToStorage).toHaveBeenCalledTimes(1)
expect(prismaMock.globalLocationImage.update).toHaveBeenCalledTimes(1)
expect(prismaMock.globalLocationImage.update).toHaveBeenCalledWith({
where: { id: 'global-location-image-1' },
data: { imageUrl: 'cos/generated-character.png' },
})
})
it('keeps the prop prompt suffix in global prop generation prompts', async () => {
prismaMock.globalLocation.findFirst.mockResolvedValueOnce({
id: 'global-prop-1',
name: 'Silver Cutlery',
images: [
{
id: 'global-prop-image-1',
description: '银质餐具套装,包含刀叉与汤匙,线条简洁,金属冷白光泽',
},
],
})
await handleAssetHubImageTask(buildJob({
type: 'prop',
id: 'global-prop-1',
}))
const generationCall = sharedMock.generateCleanImageToStorage.mock.calls[0] as unknown as [{
prompt?: string
options?: { aspectRatio?: string }
label?: string
}] | undefined
const callArg = generationCall?.[0]
const prompt = callArg?.prompt || ''
expect(prompt).toContain(PROP_PROMPT_SUFFIX)
expect(countOccurrences(prompt, PROP_PROMPT_SUFFIX)).toBe(1)
expect(callArg?.options).toEqual(expect.objectContaining({ aspectRatio: PROP_IMAGE_RATIO }))
expect(callArg?.label).toBeUndefined()
})
})