diff --git a/src/features/production/ProductionPage.vue b/src/features/production/ProductionPage.vue index 9528c5b..ece28e4 100644 --- a/src/features/production/ProductionPage.vue +++ b/src/features/production/ProductionPage.vue @@ -80,6 +80,9 @@ const linkedShotMissing = computed( query.data.value && !shots.value.some(item => item.shotId === selectedShot.value) ) +const openRequestedKeyframe = computed( + () => queryText(route?.query.action) === 'keyframe' && queryText(route?.query.shotId) === shot.value?.shotId +) const staleVideos = computed(() => query.data.value?.videos.stalePrimaryVideo ?? 0) const stages = computed(() => { const data = query.data.value @@ -694,6 +697,7 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA :prompt-readiness="promptItem" :keyframe-readiness="keyframeItem" :video-readiness="videoItem" + :open-keyframe="openRequestedKeyframe" :disabled="blocked || !!linkedShotMissing" @changed="refreshProject" /> diff --git a/src/features/production/components/ShotProductionAssets.vue b/src/features/production/components/ShotProductionAssets.vue index 0003013..84c8498 100644 --- a/src/features/production/components/ShotProductionAssets.vue +++ b/src/features/production/components/ShotProductionAssets.vue @@ -37,6 +37,7 @@ const props = defineProps<{ promptReadiness?: PromptReadinessItem keyframeReadiness?: KeyframeReadinessItem videoReadiness?: VideoReadinessItem + openKeyframe?: boolean disabled: boolean }>() const emit = defineEmits<{ changed: [] }>() @@ -63,6 +64,13 @@ const activeVideo = computed(() => videos.value.find(isActiveVideo)) const operation = computed(() => getOperation(props.projectId)) const assetBlocked = computed(() => props.disabled || operation.value.pending || !!query.error.value) const keyframeOpen = ref(false) +watch( + () => props.openKeyframe, + requested => { + if (requested) keyframeOpen.value = true + }, + { immediate: true } +) const qualityOpen = ref(false) const qualityTarget = ref(null) const specsOpen = ref(false) diff --git a/src/features/projects/ProjectLayout.vue b/src/features/projects/ProjectLayout.vue index 26c0e93..2aaa970 100644 --- a/src/features/projects/ProjectLayout.vue +++ b/src/features/projects/ProjectLayout.vue @@ -33,11 +33,23 @@ provide(projectContextKey, context) const operation = computed(() => getOperation(id.value)) const complete = computed(() => isProjectComplete(context.project.value, id.value)) const isCreation = computed(() => route.path.replace(/\/+$/, '').endsWith('/create-drama')) -type OperationGuide = { title: string; description: string; action?: string; target?: 'profile' | 'style' | 'identity' } +type OperationGuide = { + title: string + description: string + action?: string + target?: 'profile' | 'style' | 'identity' | 'keyframe' +} const operationGuide = computed(() => { const error = operation.value.error?.trim() if (!error) return null const normalized = error.toLowerCase() + if (normalized.includes('primary keyframe') || error.includes('主首帧')) + return { + title: '缺少镜头主首帧', + description: '视频提示词需要主首帧完成起点校验。请先生成并确认主首帧,再返回分镜页读取/生成提示词。', + action: '先生成主首帧', + target: 'keyframe' + } if (normalized.includes('creative profile')) return { title: '缺少项目生成配置', @@ -65,7 +77,18 @@ const operationGuide = computed(() => { /** 已知前置条件直接送达对应工作区;保留当前页面,修复后可继续原操作。 */ function resolveOperationError() { const target = operationGuide.value?.target - if (target === 'style') void router.push(`/projects/${id.value}/visual-style`) + if (target === 'keyframe') { + const recovery = operation.value.recovery?.target === 'keyframe' ? operation.value.recovery : null + const query = recovery + ? { + ...(recovery.episodeNo ? { episodeNo: String(recovery.episodeNo) } : {}), + shotId: recovery.shotId, + action: 'keyframe' + } + : { action: 'keyframe' } + operation.value.error = '' + void router.push({ path: `/projects/${id.value}/production`, query }) + } else if (target === 'style') void router.push(`/projects/${id.value}/visual-style`) else if (target === 'identity') void router.push(`/projects/${id.value}/subject-identity`) else if (target === 'profile') { const onIdentityPage = route.path.replace(/\/+$/, '').endsWith('/subject-identity') diff --git a/src/features/storyboard/StoryboardPage.vue b/src/features/storyboard/StoryboardPage.vue index fd9b774..a99bfca 100644 --- a/src/features/storyboard/StoryboardPage.vue +++ b/src/features/storyboard/StoryboardPage.vue @@ -419,7 +419,13 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int >
- +
diff --git a/src/features/storyboard/components/ShotTools.vue b/src/features/storyboard/components/ShotTools.vue index a24b062..8e57225 100644 --- a/src/features/storyboard/components/ShotTools.vue +++ b/src/features/storyboard/components/ShotTools.vue @@ -13,7 +13,7 @@ import { getOperation, runOperation } from '../../workflows/operations' import ConfirmAction from '../../workflows/ConfirmAction.vue' /** 镜头级只读资源与显式 Prompt 生成;查询与耗费模型的操作分开。 */ -const props = defineProps<{ projectId: string; shot: DesignedShot; disabled: boolean }>() +const props = defineProps<{ projectId: string; shot: DesignedShot; episodeNo?: number; disabled: boolean }>() const references = ref(null) const spec = ref(null) const errors = ref({ references: '', spec: '' }) @@ -72,7 +72,7 @@ async function generatePrompt() { const projectId = props.projectId const shotId = props.shot.shotId const overwrite = force.value - await runOperation(projectId, `读取/生成镜头 ${props.shot.shotNo} 提示词`, async () => { + const ok = await runOperation(projectId, `读取/生成镜头 ${props.shot.shotNo} 提示词`, async () => { const session = getStoryboardSession(projectId) // 请求结果不确定时不要保留可能已被覆盖的旧正文。 delete session.prompts[shotId] @@ -81,6 +81,13 @@ async function generatePrompt() { throw new Error('接口未返回此镜头的有效提示词,请检查后端记录后重试。') session.prompts[shotId] = result }) + if (!ok && /primary keyframe|主首帧/i.test(operation.value.error)) { + operation.value.recovery = { + target: 'keyframe', + shotId, + episodeNo: props.episodeNo + } + } } /** 仅导出已返回的真实规格或提示词,不在前端补造内容。 */ diff --git a/src/features/workflows/operations.ts b/src/features/workflows/operations.ts index faa119b..6b25906 100644 --- a/src/features/workflows/operations.ts +++ b/src/features/workflows/operations.ts @@ -7,6 +7,14 @@ export interface Operation { label: string error: string notice: string + recovery: OperationRecovery | null +} + +/** 失败后的可执行恢复位置;仅保留当前浏览器会话内的真实上下文。 */ +export type OperationRecovery = { + target: 'keyframe' + shotId: string + episodeNo?: number } /** 按项目而非 graph 上锁,防止改写剧本与拆解同时提交。 */ @@ -14,14 +22,14 @@ const operations = reactive>({}) /** 取得项目操作状态,不向浏览器持久化虚假的后台运行状态。 */ export function getOperation(projectId: string): Operation { - return (operations[projectId] ??= { pending: false, label: '', error: '', notice: '' }) + return (operations[projectId] ??= { pending: false, label: '', error: '', notice: '', recovery: null }) } /** 只提交一次;断网不自动重试,后台是否已执行由刷新后的 checkpoint 确认。 */ export async function runOperation(projectId: string, label: string, action: () => Promise) { const operation = getOperation(projectId) if (operation.pending) return false - Object.assign(operation, { pending: true, label, error: '', notice: '' }) + Object.assign(operation, { pending: true, label, error: '', notice: '', recovery: null }) try { await action() operation.notice = '请求已返回,正在重新读取后端状态;最终结果以下方记录为准。' diff --git a/tests/features/projects/access.test.ts b/tests/features/projects/access.test.ts index 6303e8c..b0895fa 100644 --- a/tests/features/projects/access.test.ts +++ b/tests/features/projects/access.test.ts @@ -7,10 +7,19 @@ import App from '@/App.vue' import ProjectLayout from '@/features/projects/ProjectLayout.vue' import { isProjectComplete } from '@/features/projects/access' import { projectsApi } from '@/features/projects/api' +import { getOperation } from '@/features/workflows/operations' import type { ProjectDetail, ProjectStatus } from '@/features/projects/types' import { readAllStyles } from '@/testing/styles' -const downstream = ['breakdown', 'visual-style', 'subject-identity', 'subject-images', 'assets', 'storyboard', 'production'] +const downstream = [ + 'breakdown', + 'visual-style', + 'subject-identity', + 'subject-images', + 'assets', + 'storyboard', + 'production' +] let wrapper: VueWrapper | undefined afterEach(() => { wrapper?.unmount() @@ -66,14 +75,21 @@ async function openProject(initialPath: string) { } describe('剧本完成前的下游访问限制', () => { - it('项目工作区停留期间不重复读取项目详情和工作流记录', async () => { + it('进入图库暂停父级轮询,返回其他工作区恢复定时更新', async () => { vi.useFakeTimers() - const detail = vi.spyOn(projectsApi, 'detail').mockResolvedValue(project('manual-project', 'completed')) + const detail = vi.spyOn(projectsApi, 'detail').mockResolvedValue(project('manual-gallery', 'completed')) const checkpoints = vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([]) - await openProject('/projects/manual-project/production') + const { router } = await openProject('/projects/manual-gallery/production') + await router.push('/projects/manual-gallery/subject-images') + await flushPromises() await vi.advanceTimersByTimeAsync(30_000) expect(detail).toHaveBeenCalledTimes(1) expect(checkpoints).toHaveBeenCalledTimes(1) + await router.push('/projects/manual-gallery/production') + await flushPromises() + await vi.advanceTimersByTimeAsync(6000) + expect(detail).toHaveBeenCalledTimes(2) + expect(checkpoints).toHaveBeenCalledTimes(2) }) it('图库直接链接只读取一次项目,未完成时可手动刷新解锁', async () => { @@ -84,7 +100,7 @@ describe('剧本完成前的下游访问限制', () => { await openProject('/projects/manual-gate/subject-images') await vi.advanceTimersByTimeAsync(30_000) expect(detail).toHaveBeenCalledTimes(1) - expect(wrapper!.get('.project-access-gate').text()).toContain('请手动刷新项目状态') + expect(wrapper!.get('.project-access-gate').text()).not.toContain('状态会自动更新') status = 'completed' const refresh = wrapper!.findAll('button').find(button => button.text() === '刷新项目状态')! await refresh.trigger('click') @@ -116,21 +132,24 @@ describe('剧本完成前的下游访问限制', () => { } ) - it('未完成项目停留期间不自动解锁,仅在手动刷新后进入下游页面', async () => { + it('轮询完成状态自动解锁;重新变为待审核时撤下下游面板', async () => { vi.useFakeTimers() let status: ProjectStatus = 'generating' vi.spyOn(projectsApi, 'detail').mockImplementation(async id => project(id, status)) vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([]) - const { mounted } = await openProject('/projects/manual-refresh/production') + const { mounted } = await openProject('/projects/polling/production') expect(mounted).not.toHaveBeenCalled() status = 'completed' await vi.advanceTimersByTimeAsync(6000) await flushPromises() - expect(wrapper!.find('.workspace-probe').exists()).toBe(false) - await wrapper!.get('.project-access-gate button:nth-of-type(2)').trigger('click') - await flushPromises() expect(wrapper!.get('.workspace-probe').text()).toBe('production') expect(wrapper!.findAll('.n-menu a')).toHaveLength(9) + status = 'need_review' + await vi.advanceTimersByTimeAsync(6000) + await flushPromises() + expect(wrapper!.find('.workspace-probe').exists()).toBe(false) + expect(wrapper!.get('.project-access-gate').text()).toContain('请先完成剧本创作') + expect(wrapper!.findAll('.n-menu a')).toHaveLength(3) expect(mounted).toHaveBeenCalledExactlyOnceWith('production') }) @@ -158,7 +177,7 @@ describe('剧本完成前的下游访问限制', () => { expect(wrapper!.findAll('.n-menu a')).toHaveLength(2) }) - it('读取失败保持锁定;错误区重试成功后解锁且不恢复项目标题栏', async () => { + it('读取失败保持锁定;错误区重试成功后解锁,页头不恢复标签与刷新按钮', async () => { const detail = vi .spyOn(projectsApi, 'detail') .mockRejectedValueOnce(new Error('项目读取失败')) @@ -167,7 +186,8 @@ describe('剧本完成前的下游访问限制', () => { const { mounted } = await openProject('/projects/retry/storyboard') expect(mounted).not.toHaveBeenCalled() expect(wrapper!.findAll('.n-menu a')).toHaveLength(3) - expect(wrapper!.find('.project-header').exists()).toBe(false) + expect(wrapper!.find('.project-header .n-button').exists()).toBe(false) + expect(wrapper!.find('.project-header .n-tag').exists()).toBe(false) await wrapper!.get('.project-notices button').trigger('click') await flushPromises() expect(detail).toHaveBeenCalledTimes(2) @@ -181,6 +201,33 @@ describe('剧本完成前的下游访问限制', () => { expect(isProjectComplete({ id: 'p', status: 'completed' }, 'p')).toBe(true) }) + it('镜头提示词缺少主首帧时给出下一步,并定位到对应镜头的首帧生成', async () => { + const projectId = 'guided-keyframe' + vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(projectId, 'completed')) + vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([]) + const { router } = await openProject(`/projects/${projectId}/storyboard`) + Object.assign(getOperation(projectId), { + pending: false, + label: '读取/生成镜头 3 提示词', + error: '服务器内部错误 Shot 缺少可用于视频 0 秒起点校验的 Primary Keyframe: shot-db-2-3', + notice: '', + recovery: { target: 'keyframe', shotId: 'shot-db-2-3', episodeNo: 2 } + }) + await flushPromises() + + expect(wrapper!.get('.operation-guide').text()).toContain('缺少镜头主首帧') + expect(wrapper!.get('.operation-guide').text()).toContain('先生成并确认主首帧') + await wrapper!.get('.operation-guide button').trigger('click') + await flushPromises() + + expect(router.currentRoute.value.path).toBe(`/projects/${projectId}/production`) + expect(router.currentRoute.value.query).toEqual({ + episodeNo: '2', + shotId: 'shot-db-2-3', + action: 'keyframe' + }) + }) + it('配置复选框居中对齐,输入表面随面板背景分层而非增加边框', () => { // 保护布局契约;实际像素对齐仍需浏览器视觉验收。 const css = readAllStyles() diff --git a/tests/features/workflows/pages.test.ts b/tests/features/workflows/pages.test.ts index b4329c0..d216bb2 100644 --- a/tests/features/workflows/pages.test.ts +++ b/tests/features/workflows/pages.test.ts @@ -1409,6 +1409,33 @@ describe('工作台页面交互', () => { expect(wrapper.text()).toContain('') expect(wrapper.find('script').exists()).toBe(false) }) + + it('提示词生成缺少主首帧时保存当前剧集和镜头作为恢复位置', async () => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response( + JSON.stringify({ + message: + '服务器内部错误 Shot 缺少可用于视频 0 秒起点校验的 Primary Keyframe: shot-db-1-1' + }), + { status: 500 } + ) + ) + ) + wrapper = mount(ShotTools, { + attachTo: document.body, + props: { projectId: fixture.id, episodeNo: 1, shot: designedShot(), disabled: false } + }) + + await confirmGeneration('读取/生成提示词') + + expect(getOperation(fixture.id).recovery).toEqual({ + target: 'keyframe', + shotId: 'shot-db-1-1', + episodeNo: 1 + }) + }) it('项目筛选无结果时可清除条件并返回真实列表', async () => { vi.stubGlobal( 'fetch',