diff --git a/src/features/production/api.ts b/src/features/production/api.ts index 883a291..f6263c1 100644 --- a/src/features/production/api.ts +++ b/src/features/production/api.ts @@ -161,7 +161,7 @@ export const productionApi = { /** 按本次请求选择的图片模型与参数预览最终输入,不创建首帧任务。 */ previewKeyframe: ( shotId: string, - input: Pick, + input: Pick, signal?: AbortSignal ) => request(`${shotPath(shotId)}/keyframe/preview`, { diff --git a/src/features/production/components/KeyframeCard.vue b/src/features/production/components/KeyframeCard.vue index 991e376..bc89b6f 100644 --- a/src/features/production/components/KeyframeCard.vue +++ b/src/features/production/components/KeyframeCard.vue @@ -3,7 +3,8 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue' import IssueHint from '../../../components/ui/IssueHint.vue' import { productionMessage } from '../production-messages' -import { computed } from 'vue' +import { useKeyframeVision } from '../keyframe-vision' +import { computed, watch } from 'vue' import { useQuery } from '../../../composables/useQuery' import { qualityApi } from '../quality-api' import { NButton, NTag } from 'naive-ui' @@ -29,7 +30,29 @@ const props = defineProps<{ confirming: boolean }>() /** 用户显式触发候选审核、确认或免费恢复。 */ -const emit = defineEmits<{ recover: []; quality: []; edit: []; select: []; confirm: []; cancel: []; history: [] }>() +const emit = defineEmits<{ + recover: [] + quality: [] + edit: [] + select: [] + confirm: [] + cancel: [] + history: [] + settled: [] +}>() +/** 每张可见候选可独立找回自己的审核任务。 */ +const visionKey = computed(() => + props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id]) : '' +) +const vision = useKeyframeVision(visionKey) +watch( + () => vision.state.value.active, + (active, previous) => { + if (previous && !active && visionKey.value) emit('settled') + } +) +/** 画幅不符的历史图保留浏览和只读审核记录。 */ +const wrongCanvas = computed(() => props.item.canvasDiagnosis?.status === 'mismatch') /** 质量状态以数据库为准;会话内检查仅在历史状态未知时兜底。 */ const reviewKey = computed(() => props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id, props.reviewRevision ?? 0]) : '' @@ -51,11 +74,11 @@ const reviewLabels: Record = { const isPassed = computed( () => !props.stale && + !wrongCanvas.value && props.item.inputSnapshotStatus !== 'invalid' && - (effectiveStatus.value === 'passed' || - effectiveStatus.value === 'manual_accepted' || - (effectiveStatus.value === 'unknown' && props.validationPassed === true)) + (effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted') ) +/** 晋升入口只接受持久化通过和已结算审核。 */ const canSelect = computed( () => props.item.status === 'completed' && @@ -64,7 +87,10 @@ const canSelect = computed( !props.item.isPrimary && !props.stale && props.item.inputSnapshotStatus !== 'invalid' && - isPassed.value + isPassed.value && + !reviewQuery.error.value && + !vision.blocked.value && + !vision.state.value.resumable ) @@ -120,6 +146,30 @@ const canSelect = computed( >{{ item.width }} × {{ item.height }} + +

+ {{ [item.provider, item.model].filter(Boolean).join(' / ') }} +

+

+ {{ + wrongCanvas + ? `历史画幅 ${item.canvasDiagnosis.actual ?? '未知'} 与交付画幅 ${item.canvasDiagnosis.expected ?? '未知'} 不符,仅供查看。` + : item.canvasDiagnosis.status === 'matched' + ? `匹配交付画幅 ${item.canvasDiagnosis.expected}` + : '画幅尚未确认' + }} +

+

+ {{ vision.state.value.active?.executionId ? '质量审核在后台进行' : '审核结果或费用待核查' }} +

@@ -153,11 +203,15 @@ const canSelect = computed( >

{{ formatDate(item.createdAt) }}

- - {{ validationPassed === null ? '质量检查' : '重新检查' }} + + {{ + vision.state.value.active || vision.state.value.unknown || vision.uncertain.value + ? '查看审核进度' + : '质量检查' + }}
- +

该候选已满足当前质量要求。确认让后续视频使用此首帧?

- 确认切换 + 确认切换 取消
diff --git a/src/features/production/components/KeyframeDialog.vue b/src/features/production/components/KeyframeDialog.vue index 8be37d1..6bcad42 100644 --- a/src/features/production/components/KeyframeDialog.vue +++ b/src/features/production/components/KeyframeDialog.vue @@ -1,12 +1,12 @@ + + diff --git a/src/features/production/components/KeyframeValidationHistory.vue b/src/features/production/components/KeyframeValidationHistory.vue index 7eb304f..b89d168 100644 --- a/src/features/production/components/KeyframeValidationHistory.vue +++ b/src/features/production/components/KeyframeValidationHistory.vue @@ -4,12 +4,13 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue' import ContextNotice from '../../../components/ui/ContextNotice.vue' -import { computed, ref } from 'vue' +import { computed, ref, watch } from 'vue' import { NButton, NCollapse, NCollapseItem, NInput } from 'naive-ui' import { errorMessage } from '../../../lib/http' import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue' import { useQuery } from '../../../composables/useQuery' import { formatDate } from '../../../lib/format' +import { useKeyframeVision } from '../keyframe-vision' import { qualityApi } from '../quality-api' import { parseKeyframeValidationOutput } from '../quality' @@ -26,6 +27,7 @@ const props = defineProps<{ /** 在独立弹窗内直接展示内容,并隐藏内部标题、说明与操作栏。 */ initialOpen?: boolean }>() +/** 通知候选重新读取当前质量状态。 */ const emit = defineEmits<{ reviewed: [] }>() /** 普通入口展开后查询,独立弹窗打开时直接查询。 */ const open = ref(props.initialOpen ?? false) @@ -35,13 +37,32 @@ const key = computed(() => ? JSON.stringify([props.projectId, props.shotId, props.keyframeId]) : '' ) -/** 后端历史查询支持取消,空目标不请求。 */ -const query = useQuery(key, (value, signal) => { - if (!value) return Promise.resolve([]) - const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string] - return qualityApi.keyframeHistory(shotId, keyframeId, signal) -}) -/** 仅真实结构化结论可以显示通过,调用完成不等于视觉通过。 */ +/** 独立打开历史后恢复后台观察。 */ +const visionKey = computed(() => (key.value ? JSON.stringify([props.shotId, props.keyframeId]) : '')) +const { history: query, execution, state, uncertain } = useKeyframeVision(visionKey) +/** 后台结束时同步刷新人工复核与候选状态。 */ +watch( + () => state.value.active, + (active, previous) => { + if (previous && !active && key.value) { + void reviewQuery.refresh() + emit('reviewed') + } + } +) +/** 公开步骤状态的中文名称。 */ +const stepLabels: Record = { + pending: '等待', + running: '执行中', + received: '已收到回执', + completed: '完成', + failed: '失败', + needs_review: '需要人工核查' +} +/** 不显示内部模型名称作为审核步骤。 */ +const stepNames = { general: '通用画面', physical: '物理关系', gaze: '视线' } +/** 仅显示公开词元计量。 */ +const usageLabels = { inputTokens: '输入', outputTokens: '输出', totalTokens: '合计', reasoningTokens: '推理' } /** 复核证据仅在展开历史时读取,不触发 Vision 或写入审核结论。 */ const reviewQuery = useQuery(key, (value, signal) => { if (!value) return Promise.resolve(null) @@ -72,7 +93,10 @@ async function submitReview() { !reviewReason.value.trim() || !reviewer.value.trim() || submitting.value || - props.disabled + props.disabled || + state.value.active || + state.value.unknown || + uncertain.value ) return submitting.value = true @@ -158,10 +182,16 @@ const records = computed(() =>

人工复核

请先预览候选图片并确认视觉效果。接受会替换当前主首帧,拒绝只保存审核记录。

- 人工接受 - 人工拒绝
@@ -198,11 +228,24 @@ const records = computed(() => submitSuccess }}

{{ reviewQuery.error.value }}

+ +

+ 审核结果或费用待核查,请勿重复提交。 +

+

+ 审核{{ execution.data.value?.status === 'pending' ? '等待开始' : '在后台进行' }},关闭页面后仍会保存记录。 +

+

可在质量检查中使用原参数继续;已保存的步骤会复用。

暂无校验记录。

- {{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} · {{ record.status }} · + {{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} · + {{ stepLabels[record.status] ?? '待确认' }} · {{ record.status === 'completed' && record.validation ? record.validation.passed @@ -218,10 +261,24 @@ const records = computed(() => {{ userFacingText(issue.description) }}

- - - -
{{ JSON.stringify(record.output, null, 2) }}
+ + + +
+
开始:{{ formatDate(step.startedAt) }}
+
完成:{{ formatDate(step.finishedAt) }}
+
请求编号:{{ step.requestId }}
+
模型服务请求编号:{{ step.providerRequestId }}
+
+ {{ usageLabels[unit] }}词元:{{ count }} +
+
+

{{ userFacingText(step.error) }}

diff --git a/src/features/production/components/QualityDialog.vue b/src/features/production/components/QualityDialog.vue index 7e42132..ff0b285 100644 --- a/src/features/production/components/QualityDialog.vue +++ b/src/features/production/components/QualityDialog.vue @@ -11,6 +11,7 @@ import { integerRule, sizeRules } from '../../../lib/form-rules' import { computed, ref, watch } from 'vue' import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NRadioButton, NRadioGroup } from 'naive-ui' import { AppDialog } from '../../../components/ui' +import { useKeyframeVision } from '../keyframe-vision' import { allowedTextLines, validQualityInput } from '../quality' import type { QualityAction, QualityInput, QualityTarget } from '../quality.types' import { useQuality } from '../useQuality' @@ -51,6 +52,13 @@ const { key, session, operation, execution, blocked, run } = useQuality( }, id => emit('started', id) ) +/** 打开首帧质量弹窗时读取正式审核状态。 */ +const visionKey = computed(() => + open.value && props.target?.kind === 'keyframe' ? JSON.stringify([props.target.shotId, props.target.assetId]) : '' +) +const vision = useKeyframeVision(visionKey) +/** 有原参数时继续;没有原参数时保留只读核查。 */ +const visionBlocked = computed(() => !!visionKey.value && vision.blocked.value) /** 质量弹窗重新读取所选候选自身的权限,不以会话历史代替后端事实。 */ const videoKey = computed(() => open.value && props.target?.kind === 'video' ? JSON.stringify([props.target.shotId, props.target.assetId]) : '' @@ -135,7 +143,7 @@ const input = computed(() => ({ maxRepairAttempts: action.value === 'validate' ? 0 : (attempts.value ?? -1), force: force.value, episodeNo: props.target?.kind === 'batch' ? props.target.episodeNo : 1, - allowedTexts: allowedTextLines(texts.value), + allowedTexts: vision.resumeTexts.value ?? allowedTextLines(texts.value), ...(action.value === 'validate' || width.value === null ? {} : { width: width.value }), ...(action.value === 'validate' || height.value === null ? {} : { height: height.value }) })) @@ -229,7 +237,15 @@ watch( ) /** 付费入口保留明确确认,不因菜单选择或查看历史自动提交。 */ async function submit() { - if (!acknowledged.value || !valid.value || blocked.value || !repairAvailable.value) return + if ( + !acknowledged.value || + !valid.value || + blocked.value || + visionBlocked.value || + !repairAvailable.value || + (!!vision.resumeTexts.value && action.value !== 'validate') + ) + return acknowledged.value = false await run(action.value, input.value) } @@ -358,8 +374,9 @@ const optionsExpanded = ref(['options']) (['options']) @refresh="execution.query.refresh" @dismiss="execution.dismiss" /> +

+ 此窗口没有原审核参数,暂不能安全继续。 +

(['options']) {{ label }}{{ vision.resumeTexts.value && action === 'validate' ? '继续原审核' : label }} diff --git a/src/features/production/components/ShotProductionAssets.vue b/src/features/production/components/ShotProductionAssets.vue index 7c38630..633d74e 100644 --- a/src/features/production/components/ShotProductionAssets.vue +++ b/src/features/production/components/ShotProductionAssets.vue @@ -28,6 +28,7 @@ import type { GenerateKeyframeInput, KeyframeReadinessItem, KeyframeSpec, + KeyframeGenerationPreview, PromptReadinessItem, VideoGenerationSpec, VideoReadinessItem @@ -47,6 +48,8 @@ import KeyframeValidationHistory from './KeyframeValidationHistory.vue' import { AppDialog } from '../../../components/ui' import ModelCapabilities from './ModelCapabilities.vue' import type { QualityTarget } from '../quality.types' +import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue' +import { visionState } from '../keyframe-vision' import { clearVideoConflict, clearVideoQualification, sessionKeyframePassed, sessionVideoValidation } from '../quality' import { useProjectGenerationRevision } from '../../generation-config/context' import { generationConfigApi } from '../../generation-config/api' @@ -98,6 +101,8 @@ const props = defineProps<{ keyframeReadiness?: KeyframeReadinessItem /** 视频就绪项。 */ videoReadiness?: VideoReadinessItem + /** 分镜工作台只展示单镜头首帧,不进入项目级制作。 */ + keyframeOnly?: boolean /** 是否从深链接打开首帧生成。 */ openKeyframe?: boolean /** 页面上游状态是否阻断操作。 */ @@ -136,6 +141,18 @@ const assetPollInterval = computed(() => { query = usePolling( key, async (shotId, signal) => { + if (props.keyframeOnly) { + const keyframes = await productionApi.listKeyframes(shotId, signal) + if (keyframes.some(item => item.shotId !== shotId)) throw new Error('候选与当前镜头不匹配。') + return { + keyframes, + videos: [], + qualityStatus: null, + qualityStatusError: '', + inputPlan: null, + inputPlanError: '' + } + } const [keyframes, videos, qualityState, inputPlanState] = await Promise.all([ productionApi.listKeyframes(shotId, signal), productionApi.listVideos(shotId, signal), @@ -164,10 +181,19 @@ query = usePolling( assetPollInterval ) /** 单独读取已保存的提示词,查询失败不影响首帧和视频资产展示。 */ -const promptQuery = usePolling(key, (shotId, signal) => storyboardApi.videoPrompt(shotId, signal), false) +const promptQuery = usePolling( + key, + (shotId, signal) => (props.keyframeOnly ? Promise.resolve(null) : storyboardApi.videoPrompt(shotId, signal)), + false +) const savedPrompt = computed(() => (promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null)) /** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */ -const videoInputQuery = usePolling(key, (shotId, signal) => productionApi.videoGenerationSpec(shotId, signal), false) +const videoInputQuery = usePolling( + key, + (shotId, signal) => + props.keyframeOnly ? Promise.resolve(null) : productionApi.videoGenerationSpec(shotId, signal), + false +) /** 素材查询问题与就绪检查使用同一中文说明,避免重复展示后端术语。 */ const videoInputError = computed(() => productionMessage(videoInputQuery.error.value)) /** 视频准备问题按实际含义去重,保留所有不同的处理建议。 */ @@ -322,6 +348,30 @@ function openShotKeyframeQuality() { } /** 当前查看历史的候选 ID;历史记录在独立弹窗内按候选隔离。 */ const historyKeyframeId = ref('') +/** 当前会话保留最近一次真实正式预览,只用于相同候选输入的证据展示。 */ +const latestKeyframePreview = ref(null) +/** 历史候选的实际输入只有指纹完全一致时才能显示。 */ +const historyInput = computed(() => { + const preview = latestKeyframePreview.value + const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value) + return preview && + item && + item.shotId === preview.shotId && + preview.previewFingerprint === item.providerInputFingerprint + ? preview + : null +}) +/** 历史候选画幅或来源失效时保留浏览、禁止人工采用。 */ +const historyBlocked = computed(() => { + const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value) + return ( + assetBlocked.value || + !item || + item.canvasDiagnosis?.status === 'mismatch' || + item.inputSnapshotStatus === 'invalid' || + (item.isPrimary && keyframeStale.value) + ) +}) /** 首帧校验历史弹窗的显示状态。 */ const historyOpen = ref(false) /** @@ -341,6 +391,7 @@ const videoSpec = ref(null) const canGeneratePrompt = computed( () => !assetBlocked.value && !!props.promptReadiness && props.promptReadiness.issues.length === 0 ) +/** 付费生成同时要求当前镜头就绪和有效正式预览。 */ const canGenerateKeyframe = computed( () => !assetBlocked.value && @@ -518,14 +569,28 @@ async function setPrimaryKeyframe() { if ( assetBlocked.value || !keyframeId || - keyframes.value.find(item => item.id === keyframeId)?.source === 'provider_variant' + !keyframes.value.some( + item => + item.id === keyframeId && + item.source !== 'provider_variant' && + item.status === 'completed' && + !!item.imageUrl && + item.canvasDiagnosis?.status !== 'mismatch' && + item.inputSnapshotStatus !== 'invalid' && + !item.recoveryRequired + ) ) return const shotId = props.shot.shotId confirmingKeyframe.value = '' await runOperation(props.projectId, `设置镜头 ${props.shot.shotNo} 主首帧`, async () => { // 晋升前重新读取持久化质量结论,刷新页面后也认可真实历史通过。 - const review = await qualityApi.keyframeQualityReview(shotId, keyframeId) + const [review, history] = await Promise.all([ + qualityApi.keyframeQualityReview(shotId, keyframeId), + qualityApi.keyframeHistory(shotId, keyframeId) + ]) + const vision = visionState(history) + if (vision.active || vision.unknown || vision.resumable) throw new Error('审核尚未结算,暂不能设为主首帧。') if (!['passed', 'manual_accepted'].includes(review.effectiveQualityStatus)) throw new Error('此候选尚未通过当前质量要求,请先完成质量检查或有效人工复核。') const result = await productionApi.setPrimaryKeyframe(shotId, keyframeId) @@ -620,7 +685,8 @@ defineExpose({ inspectSpecs, inspecting }) >{{ query.error.value }} 当前保留上次成功读取的资产,操作已暂停。 -
+ +
01 · 视频提示词
@@ -681,7 +747,7 @@ defineExpose({ inspectSpecs, inspecting })
-
02 · 首帧
+
{{ keyframeOnly ? '本镜首帧' : '02 · 首帧' }}

尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。

@@ -729,7 +796,10 @@ defineExpose({ inspectSpecs, inspecting }) 视频质量链状态暂时无法读取;视频资产仍可查看。请稍后刷新。
- 本镜首帧质量重跑 @@ -741,7 +811,7 @@ defineExpose({ inspectSpecs, inspecting }) {{ keyframeStale ? '生成替代候选' : currentKeyframe ? '再生成一张候选' : '生成首帧候选' @@ -750,7 +820,8 @@ defineExpose({ inspectSpecs, inspecting })
-
+ +
03 · 视频
@@ -1039,6 +1110,7 @@ defineExpose({ inspectSpecs, inspecting }) @quality="openQuality('keyframe', item.id)" @edit="openEdit(item)" @history="openKeyframeHistory(item.id)" + @settled="refreshAfterReview" @select="confirmingKeyframe = item.id" @confirm="setPrimaryKeyframe" @cancel="confirmingKeyframe = ''" @@ -1094,17 +1166,33 @@ defineExpose({ inspectSpecs, inspecting }) + + + + +

+ 当前无法读取这张图的原始生成输入。可查看候选原图和已有审核记录。 +

+
+
@@ -1120,6 +1208,7 @@ defineExpose({ inspectSpecs, inspecting }) :disabled="!canGenerateKeyframe" :previous-candidate-ids="keyframes.map(item => item.id)" :submit-generation="generateKeyframe" + @previewed="latestKeyframePreview = $event" /> diff --git a/src/features/production/keyframe-vision.ts b/src/features/production/keyframe-vision.ts new file mode 100644 index 0000000..4e8d4a4 --- /dev/null +++ b/src/features/production/keyframe-vision.ts @@ -0,0 +1,224 @@ +import { computed, onScopeDispose, ref, watch, type Ref } from 'vue' +import { useQuery } from '../../composables/useQuery' +import { ApiError } from '../../lib/http' +import { workflowExecutionApi } from '../workflows/execution-api' +import { qualityApi } from './quality-api' +import { isVisualValidation } from './quality' +import type { KeyframeValidationHistoryItem } from './quality.types' + +/** 当前候选的最近一次客户端提交,用于断线后只读恢复。 */ +interface Submission { + /** 本次确认的文字授权。 */ + texts: string[] + /** 请求前已存在的最近记录。 */ + before: string | null + /** 同一任务继续时,原执行编号用于识别新一轮。 */ + beforeExecutionId?: string + /** 服务确认的任务编号。 */ + taskId?: string + /** 服务确认的执行编号。 */ + executionId?: string + /** 任务属于其他提交,当前文字不能用于继续。 */ + external?: boolean + /** 已明确结算,仅保留原参数供显式继续。 */ + settled?: boolean +} + +/** 同一窗口内的各入口共享候选提交状态。 */ +const submissions = ref>({}) + +/** + * 读取原提交,刷新后仍禁止因连接中断直接重发。 + * @param key 镜头及候选查询键 + * @returns 原提交 + */ +function readSubmission(key: string) { + const memory = submissions.value[key] + if (!key) return undefined + try { + const saved = sessionStorage.getItem('keyframe-vision:' + key) + return saved ? (JSON.parse(saved) as Submission) : undefined + } catch { + return memory + } +} + +/** + * 保存观察位置,不发起审核。 + * @param key 镜头及候选查询键 + * @param value 原提交;缺省时清除 + */ +function saveSubmission(key: string, value?: Submission) { + try { + const storageKey = 'keyframe-vision:' + key + if (value) sessionStorage.setItem(storageKey, JSON.stringify(value)) + else sessionStorage.removeItem(storageKey) + } catch { + // 存储不可用时保留内存状态。 + } + submissions.value[key] = value +} + +/** + * 从公开审核历史判断是否应观察、阻断或显式继续。 + * @param records 按新到旧排列的候选历史 + * @returns 与写入安全相关的当前记录 + */ +export function visionState(records: KeyframeValidationHistoryItem[]) { + const active = records.find(item => item.status === 'pending' || item.status === 'running') + const unknown = records.find(item => item.status === 'failed' && visionOutput(item).recoveryRequired !== false) + const resumable = records.find(item => item.status === 'failed' && visionOutput(item).resumeAvailable === true) + return { active, unknown, resumable } +} + +/** + * 提取历史公开输出中的状态字段。 + * @param record 历史记录 + * @returns 审核恢复状态及公开质量结论对象 + */ +function visionOutput(record: KeyframeValidationHistoryItem): Record { + try { + const value: unknown = typeof record.output === 'string' ? JSON.parse(record.output) : record.output + return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record) : {} + } catch { + return {} + } +} + +/** + * 按候选发现后台任务,轮询仅查询历史和正式执行记录。 + * @param key 镜头和候选 ID 的 JSON 查询键 + * @returns 观察状态和一次性提交凭据操作 + */ +export function useKeyframeVision(key: Ref) { + /** 当前候选的客户端凭据。 */ + const submission = computed(() => readSubmission(key.value)) + /** 公开审核记录是刷新恢复的正式来源。 */ + const history = useQuery(key, (value, signal) => { + if (!value) return Promise.resolve([]) + const [shotId, keyframeId] = JSON.parse(value) as [string, string] + return qualityApi.keyframeHistory(shotId, keyframeId, signal) + }) + /** 当前活跃、未结或可继续的记录。 */ + const state = computed(() => visionState(history.data.value ?? [])) + /** 旧版活跃记录没有执行编号,仍只能观察和核查。 */ + const executionKey = computed( + () => state.value.active?.executionId ?? (submission.value?.settled ? '' : submission.value?.executionId) ?? '' + ) + /** 只读取执行状态,不展示工作流内部原始结果。 */ + const execution = useQuery(executionKey, (id, signal) => + id ? workflowExecutionApi.get(id, signal) : Promise.resolve(null) + ) + /** 未明确结算的断线状态禁止再次写入。 */ + const uncertain = computed(() => !!submission.value && !submission.value.settled && !state.value.active) + /** 只有本次会话确知原文字授权时才能安全继续。 */ + const resumeTexts = computed(() => { + const saved = submission.value + return saved?.settled && !saved.external && saved.taskId && saved.taskId === state.value.resumable?.id + ? saved.texts + : null + }) + /** 初次读取或失败时不允许盲目启动,轮询期间不清空旧状态。 */ + const blocked = computed( + () => + !history.data.value || + !!history.error.value || + !!state.value.active || + !!state.value.unknown || + uncertain.value || + (!!state.value.resumable && !resumeTexts.value) + ) + + watch([history.data, submission], ([records, saved]) => { + if (!records || !saved || saved.settled) return + const latest = records[0] + const found = saved.taskId + ? records.find(item => item.id === saved.taskId) + : latest && (latest.id !== saved.before || latest.executionId !== saved.beforeExecutionId) + ? latest + : undefined + if (!found || !['failed', 'completed'].includes(found.status)) return + if (saved.executionId && found.executionId !== saved.executionId) return + saveSubmission(key.value, { ...saved, settled: true, taskId: found.id }) + }) + + const timer = setInterval(() => { + if (key.value && (state.value.active || uncertain.value)) { + if (!history.loading.value) void history.refresh() + if (executionKey.value && !execution.loading.value) void execution.refresh() + } + }, 2500) + onScopeDispose(() => clearInterval(timer)) + return { history, state, execution, uncertain, blocked, resumeTexts } +} + +/** + * 只提交一次审核;冲突和断线回到只读观察。 + * @param shotId 正式镜头 + * @param assetId 当前候选 + * @param texts 已明确确认的文字授权 + * @param records 提交前读取的审核历史 + * @returns 已复用的质量结论,或后台受理时返回空 + */ +export async function submitKeyframeVision( + shotId: string, + assetId: string, + texts: string[], + records: KeyframeValidationHistoryItem[] +) { + const key = JSON.stringify([shotId, assetId]) + const previous = readSubmission(key) + const current = visionState(records) + if (current.active || current.unknown || (previous && !previous.settled)) + throw new Error('已有审核或费用待核查,请查看审核记录。') + if ( + current.resumable && + (!previous || + previous.external || + previous.taskId !== current.resumable.id || + JSON.stringify(texts) !== JSON.stringify(previous.texts)) + ) + throw new Error('继续审核需要原审核参数,请核对原操作记录。') + const pending: Submission = { + texts: [...texts], + before: records[0]?.id ?? null, + beforeExecutionId: records[0]?.executionId + } + saveSubmission(key, pending) + try { + const result = await qualityApi.validateKeyframe(shotId, assetId, texts) + if (result.shotId !== shotId || result.keyframeId !== assetId || !result.validationTaskId) + throw new Error('审核回执与当前候选不一致,请刷新审核记录。') + if ('executionId' in result && result.status === 'pending' && result.executionId) { + saveSubmission(key, { ...pending, taskId: result.validationTaskId, executionId: result.executionId }) + return null + } + if ('passed' in result && isVisualValidation(result)) { + saveSubmission(key, { ...pending, taskId: result.validationTaskId, settled: true }) + return result + } + throw new Error('审核回执不完整,请刷新审核记录。') + } catch (cause) { + if (cause instanceof ApiError && cause.status === 409) { + const details = cause.details as { code?: string; taskId?: string; executionId?: string } | null + const code = details?.code ?? cause.code ?? cause.message.split(':')[0] + if (code === 'KEYFRAME_VALIDATION_ACTIVE') { + saveSubmission(key, { + ...pending, + taskId: details?.taskId, + executionId: details?.executionId, + external: true + }) + return null + } + if (code === 'KEYFRAME_VALIDATION_RECOVERY_REQUIRED') { + saveSubmission(key, { ...pending, taskId: details?.taskId, external: true }) + throw new Error('原审核结果或费用待核查,请查看审核记录。', { cause }) + } + saveSubmission(key, previous) + throw new Error('候选或审核输入可能已变化,请刷新正式候选后核对。', { cause }) + } + if (cause instanceof ApiError && cause.status >= 400 && cause.status < 500) saveSubmission(key, previous) + throw cause + } +} diff --git a/src/features/production/quality-api.ts b/src/features/production/quality-api.ts index 9663c1e..41cadde 100644 --- a/src/features/production/quality-api.ts +++ b/src/features/production/quality-api.ts @@ -3,6 +3,7 @@ import type { ImageProviderCapability, KeyframeRepair, KeyframeValidation, + KeyframeValidationAccepted, KeyframeQualityStart, KeyframeValidationHistoryItem, QualityInput, @@ -34,7 +35,7 @@ export interface KeyframeQualityReview { manualReviewAvailable: boolean } -/** 校验会调用视觉模型,POST 不设短超时、不自动重试;能力检查只读。 */ +/** 视觉审核提交不自动重试;首帧后台受理有连接超时,长同步操作等候实际结论。 */ export const qualityApi = { repairVideo: (shotId: string, videoId: string, maxRepairAttempts: number) => request( @@ -55,10 +56,11 @@ export const qualityApi = { `/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability${provider ? `?provider=${encodeURIComponent(provider)}` : ''}`, { signal } ), + /** 显式请求一次审核,返回后台受理或既有质量结果。 */ validateKeyframe: (shotId: string, assetId: string, allowedTexts: string[]) => - request( + request( `/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(assetId)}/validate`, - { method: 'POST', body: { allowedTexts }, timeoutMs: 0 } + { method: 'POST', body: { allowedTexts } } ), repair: ( shotId: string, diff --git a/src/features/production/quality.types.ts b/src/features/production/quality.types.ts index ec05010..746fb1f 100644 --- a/src/features/production/quality.types.ts +++ b/src/features/production/quality.types.ts @@ -205,6 +205,40 @@ export interface KeyframeQualityStart { total: number } +/** 正式 Vision 后台受理回执,不表示质量已通过。 */ +export interface KeyframeValidationAccepted { + /** 工作流执行编号。 */ + executionId: string + /** 已保存的审核任务。 */ + validationTaskId: string + /** 镜头编号。 */ + shotId: string + /** 候选编号。 */ + keyframeId: string + /** 正在等待执行。 */ + status: 'pending' +} + +/** 审核历史中公开的步骤证据。 */ +export interface KeyframeValidationStep { + /** 审核范围。 */ + name: 'general' | 'physical' | 'gaze' + /** 已保存的实际步骤状态。 */ + status: 'pending' | 'running' | 'received' | 'completed' | 'failed' | 'needs_review' + /** 请求编号。 */ + requestId?: string + /** 模型服务请求编号。 */ + providerRequestId?: string + /** 开始时间。 */ + startedAt?: string + /** 完成时间。 */ + finishedAt?: string + /** 可取得的词元计量。 */ + usage?: Partial> + /** 公开错误说明。 */ + error?: string +} + /** 已保存的只读首帧校验任务记录。 */ export interface KeyframeValidationHistoryItem { /** 校验任务编号 */ @@ -213,6 +247,10 @@ export interface KeyframeValidationHistoryItem { status: string /** 数据库保存的 JSON 输出 */ output: string | Record | null + /** 新版工作流执行编号。 */ + executionId?: string + /** 公开步骤进度。 */ + steps?: KeyframeValidationStep[] /** 调用错误 */ error: string | null /** 开始时间 */ diff --git a/src/features/production/types.ts b/src/features/production/types.ts index f4b9ab8..04b4c6d 100644 --- a/src/features/production/types.ts +++ b/src/features/production/types.ts @@ -142,6 +142,12 @@ export interface VideoReadiness { /** 首帧生成记录;成功图片与失败历史都保留。 */ export interface ShotKeyframe { + /** 当前项目画幅与候选实际像素的诊断。 */ + canvasDiagnosis?: { + /** 项目要求的画幅。 */ expected: string | null + /** 候选实际画幅。 */ actual: string | null + /** 服务端比较结论。 */ status: 'matched' | 'mismatch' | 'unknown' + } /** 持久化的实际输入状态。 */ inputSnapshotStatus?: 'recorded' | 'not-recorded' | 'invalid' /** 当次实际输入指纹。 */ @@ -207,7 +213,11 @@ export interface KeyframeReference { subjectId: string subjectRef: string module: string - role: 'identity-anchor' | 'form-primary' + role: ImageReferenceRole + /** 该机位参考绑定的场景几何版本。 */ + spatialLayoutVersion?: string + /** 确认的机位说明。 */ + viewDescription?: string subjectFormId?: string imageId: string imageUrl: string @@ -216,6 +226,12 @@ export interface KeyframeReference { /** 后端确定性编译的首帧生成规格,不会在查询时调用图片模型。 */ export interface KeyframeSpec { + /** 当前正式来源指纹。 */ + formalSourceFingerprint: string + /** 项目交付画幅。 */ + deliveryCanvas?: string + /** 只读相邻镜头依据。 */ + continuity?: import('../storyboard/generation-spec.types').ShotContinuityEvidence | null projectId: string shotId: string episodeNo: number @@ -257,6 +273,10 @@ export interface KeyframeSpecConsistencyIssue { /** 正式镜头的最终图片输入与导演约束检查。 */ export interface KeyframeGenerationPreview extends ImageGenerationPreview { + /** 项目正式交付画幅。 */ + deliveryCanvas?: string + /** 只读相邻镜头依据与待确认事项。 */ + continuity?: import('../storyboard/generation-spec.types').ShotContinuityEvidence | null specConsistencyIssues?: KeyframeSpecConsistencyIssue[] specConsistencySummary?: { warningCount: number @@ -328,9 +348,11 @@ export interface GenerateKeyframesInput { export interface GenerateKeyframeInput { /** 用户确认的最终输入版本。 */ expectedPreviewFingerprint?: string - setPrimary: boolean - provider?: string - generationOptions?: Record + /** 单镜头生成总是先生成候选。 */ setPrimary: boolean + /** 图片模型供应方。 */ provider?: string + /** 本次已核对的图片参数。 */ generationOptions?: Record + /** 旧版显式尺寸宽度,仍由项目画幅限制。 */ width?: number + /** 旧版显式尺寸高度,仍由项目画幅限制。 */ height?: number } /** 首帧批量生成回执;详细阻塞原因应配合 readiness 查看。 */ diff --git a/src/features/production/useQuality.ts b/src/features/production/useQuality.ts index f21861d..f4a6b14 100644 --- a/src/features/production/useQuality.ts +++ b/src/features/production/useQuality.ts @@ -6,6 +6,8 @@ import { projectsApi } from '../projects/api' import { hasRunningWorkflow } from '../workflows/selectors' import { getOperation, runOperation } from '../workflows/operations' import { productionApi } from './api' +import { preparationApi } from '../storyboard-preparation/api' +import { submitKeyframeVision } from './keyframe-vision' import { qualityApi } from './quality-api' import { isVisualValidation, @@ -160,6 +162,8 @@ export function useQuality( throw new Error('镜头就绪列表不完整,请刷新。') let receipt: QualityReceipt if (target.kind === 'batch') { + const entry = await preparationApi.entry(projectId) + if (entry.ready !== true) throw new Error(entry.reason || '项目制作条件尚未满足。') const targets = qualityTargets(readiness, input) if (!targets.length) throw new Error( @@ -203,6 +207,30 @@ export function useQuality( } else { if (!readiness.items.some(item => item.shotId === target.shotId)) throw new Error('指定镜头不属于当前项目,未提交质量任务。') + if (target.kind === 'keyframe' && action === 'validate') { + const [images, history] = await Promise.all([ + productionApi.listKeyframes(target.shotId), + qualityApi.keyframeHistory(target.shotId, target.assetId) + ]) + const image = images.find(item => item.id === target.assetId && item.shotId === target.shotId) + if ( + !image || + image.status !== 'completed' || + !image.imageUrl || + image.canvasDiagnosis?.status === 'mismatch' || + image.inputSnapshotStatus === 'invalid' + ) + throw new Error('首帧未完成、画幅不符或来源过期,不能执行质量检查。') + if (!stillCurrent()) throw new Error('已离开原候选,未提交审核。') + const result = await submitKeyframeVision( + target.shotId, + target.assetId, + input.allowedTexts ?? [], + history + ) + if (result) receiptTarget.receipt = { kind: 'keyframe', result } + return + } if (target.kind === 'video') { const videos = await productionApi.listVideos(target.shotId) const video = videos.find(item => item.id === target.assetId && item.shotId === target.shotId) @@ -298,19 +326,7 @@ export function useQuality( throw new Error('修复回执不完整,请先核对首帧与主图状态,不要重复生图。') receipt = { kind: 'repair', result } } else { - const result = await qualityApi.validateKeyframe( - target.shotId, - target.assetId, - input.allowedTexts ?? [] - ) - if ( - !isVisualValidation(result) || - result.shotId !== target.shotId || - result.keyframeId !== target.assetId || - !result.validationTaskId - ) - throw new Error('首帧检查结果不完整或与所选图片不一致,请刷新检查记录。') - receipt = { kind: 'keyframe', result } + throw new Error('当前质量操作不可用。') } } } diff --git a/src/features/projects/useProjectStageAccess.ts b/src/features/projects/useProjectStageAccess.ts index 7d1af1d..f64a7f1 100644 --- a/src/features/projects/useProjectStageAccess.ts +++ b/src/features/projects/useProjectStageAccess.ts @@ -49,10 +49,11 @@ export function useProjectStageAccess(projectId: Ref, readiness: Ref - request(`${root(id)}/storyboard/quality-confirmation`, { signal }), + request(`${root(id)}/storyboard-quality-confirmation`, { signal }), + /** + * 同次读取人工确认和当前分镜质量。 + * @param id 正式项目 + * @param signal 取消旧读取 + * @returns 当前版本、质量和覆盖 + */ + qualityPreflight: (id: string, signal?: AbortSignal) => + request(`${root(id)}/storyboard-quality-confirmation/preflight`, { signal }), /** * 明确确认当前分镜的整体审核。 * @param id 当前项目编号 @@ -71,7 +80,7 @@ export const preparationApi = { * @returns 正式接口的实际业务回执 */ confirmApproval: (id: string, input: StoryboardReviewInput) => - request(`${root(id)}/storyboard/quality-confirmation`, { method: 'POST', body: input }), + request(`${root(id)}/storyboard-quality-confirmation`, { method: 'POST', body: input }), /** * 只读制作入口结论,必须在制作计划前核对。 * @param id 当前项目编号 diff --git a/src/features/storyboard-preparation/types.ts b/src/features/storyboard-preparation/types.ts index c9af60c..2b60865 100644 --- a/src/features/storyboard-preparation/types.ts +++ b/src/features/storyboard-preparation/types.ts @@ -18,7 +18,7 @@ export interface PreparationIssue extends Omit { export interface StoryboardRecheck { /** 所属项目。 */ projectId: string - /** 综合问题状态,当前接口不返回全局通过。 */ + /** 综合问题状态,确定性检查通过也不代替人工审核。 */ status: 'blocked' | 'insufficient_evidence' | 'needs_review' /** 结构检查。 */ structure: { @@ -64,8 +64,8 @@ export interface StoryboardRecheck { } /** 可以继续进入人工审核,不能代替正式生产准入。 */ preflightEligible: boolean - /** 本接口始终不直接确认。 */ - canConfirm: false + /** 是否符合提交人工确认的前置条件;此查询不写入记录。 */ + canConfirm: boolean } /** 历史分镜缺少规则快照时,明确建立新审核来源的只读预览。 */ export interface ReviewBaselinePreview { @@ -230,3 +230,9 @@ export interface BeatSubjectRepairResult { /** 修订后段落内容版本。 */ resultFingerprint: string /** 真实保存状态。 */ written: true } + +/** 人工确认前一次性返回当前来源和质量覆盖。 */ +export interface StoryboardQualityPreflight { + /** 当前人工确认凭据及分镜版本。 */ current: StoryboardApprovalState + /** 确定性复检及待核对问题。 */ quality: StoryboardRecheck +} diff --git a/src/features/storyboard/StoryboardPage.vue b/src/features/storyboard/StoryboardPage.vue index a83a3f7..8188d93 100644 --- a/src/features/storyboard/StoryboardPage.vue +++ b/src/features/storyboard/StoryboardPage.vue @@ -16,6 +16,10 @@ import { EmptyState } from '../../components/ui' import { downloadText } from '../../lib/format' import ConfirmAction from '../workflows/ConfirmAction.vue' import GenerationReceipt from './components/GenerationReceipt.vue' +import { useQuery } from '../../composables/useQuery' +import { productionApi } from '../production/api' +import ShotProductionAssets from '../production/components/ShotProductionAssets.vue' +import ShotDerivedReview from './components/ShotDerivedReview.vue' import ShotDesign from './components/ShotDesign.vue' import MotionPlanPanel from './components/MotionPlanPanel.vue' import MotionAuditPanel from './components/MotionAuditPanel.vue' @@ -64,6 +68,7 @@ const { data, episodeSourceUnavailable, prerequisites, + projectAssetsReady, session, operation, concurrency, @@ -79,6 +84,16 @@ const { executions, run } = useStoryboard() +/** 仅在首帧标签读取项目列表中的本镜就绪结果,独立于项目制作入口。 */ +const keyframeProject = computed(() => (detailTab.value === 'keyframes' ? id.value : '')) +/** 按当前项目读取后端的逐镜头首帧就绪项。 */ +const keyframeReadiness = useQuery(keyframeProject, (projectId, signal) => + projectId ? productionApi.keyframeReadiness(projectId, true, signal) : Promise.resolve(null) +) +/** 只使用当前镜头对应的结果。 */ +const shotReadiness = computed(() => + keyframeReadiness.data.value?.items.find(item => item.shotId === shot.value?.shotId) +) /** 切换详情标签后仍观察起点视觉任务,重新进入项目时恢复真实终态。 */ useWorkflowExecution(id, 'motion-plan-start-state-validation') const productionReady = computed(() => directionComplete.value && visualStateComplete.value) @@ -634,7 +649,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
设计与状态参考图与提示词动作与视线动作与视线首帧
-
+ +
+ + +
+ +
+

+ 正在检查本镜生成条件… +

+ 重新读取生成条件 + +
diff --git a/src/features/storyboard/components/ShotDerivedReview.vue b/src/features/storyboard/components/ShotDerivedReview.vue new file mode 100644 index 0000000..9c43977 --- /dev/null +++ b/src/features/storyboard/components/ShotDerivedReview.vue @@ -0,0 +1,546 @@ + + + diff --git a/src/features/storyboard/derived-review-api.ts b/src/features/storyboard/derived-review-api.ts new file mode 100644 index 0000000..fcceaee --- /dev/null +++ b/src/features/storyboard/derived-review-api.ts @@ -0,0 +1,37 @@ +import { request } from '../../lib/http' +import type { + DerivedReviewSelection, + DraftProviderInput, + ShotDraftPreview, + ShotReviewDraft +} from './derived-review.types' + +/** 已审摄影草案的正式读写入口。 */ +export const derivedReviewApi = { + /** + * 免费编译草案,不保存、不调用模型。 + * @param shotId 当前正式镜头 + * @param draft 待审草案 + * @param provider 选定的模型参数 + * @param signal 取消过期查询 + * @returns 对应草案指纹及实际模型输入 + */ + preview: (shotId: string, draft: ShotReviewDraft, provider: DraftProviderInput, signal?: AbortSignal) => + request(`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe/preview`, { + method: 'POST', + body: { ...provider, draft }, + signal + }), + /** + * 用户明确采用已经预览的镜头草案。 + * @param projectId 正式项目 + * @param reviewer 人工审核人 + * @param shots 本次选中的预览及原模型参数 + * @returns 已保存的正式镜头归属 + */ + confirm: (projectId: string, reviewer: string, shots: DerivedReviewSelection[]) => + request<{ shots: Array<{ shotId: string }> }>( + `/projects/${encodeURIComponent(projectId)}/storyboard-derived-reviews/confirm`, + { method: 'POST', body: { reviewer, shots } } + ) +} diff --git a/src/features/storyboard/derived-review.ts b/src/features/storyboard/derived-review.ts new file mode 100644 index 0000000..8d245d4 --- /dev/null +++ b/src/features/storyboard/derived-review.ts @@ -0,0 +1,64 @@ +import type { KeyframeSpec } from '../production/types' +import type { ShotReviewDraft } from './derived-review.types' +import type { DesignedShot } from './types' + +/** + * 从正式记录创建受控草案,保留原来的动作、形态及环境。 + * @param shot 已保存的摄影和即时状态 + * @param keyframe 当前正式首帧来源及参考 + * @param fingerprint 当前项目分镜版本 + * @returns 正式字段的可审副本 + */ +export function draftFromFormal(shot: DesignedShot, keyframe: KeyframeSpec, fingerprint: string): ShotReviewDraft { + const { direction, visualState, shotNo } = shot + if (!direction || !visualState || keyframe.shotId !== shot.shotId || !keyframe.formalSourceFingerprint) + throw new Error('当前镜头缺少有效的正式摄影或即时状态。') + const sceneSources = keyframe.references + .filter(item => item.role === 'layout-master' || item.role === 'scene-form-view') + .map(item => { + if (!item.spatialLayoutVersion) throw new Error('场景机位参考缺少当前几何依据。') + return { + subjectRef: item.subjectRef, + imageId: item.imageId, + spatialLayoutVersion: item.spatialLayoutVersion + } + }) + return { + expectedShotFingerprint: fingerprint, + direction: { + shotNo, + shotSize: direction.shotSize, + cameraAngle: direction.cameraAngle, + cameraMovement: direction.cameraMovement, + composition: direction.composition, + cameraPosition: direction.cameraPosition, + lensIntent: direction.lensIntent, + depthOfField: direction.depthOfField, + visualIntent: direction.visualIntent + }, + sceneSources, + visualState: { + shotNo, + environment: { + timeOfDay: visualState.timeOfDay, + weather: visualState.weather, + atmosphere: visualState.atmosphere, + transientState: visualState.environmentTransientState + }, + continuityNote: visualState.continuityNote, + subjects: visualState.subjects.map(item => { + if (!item.subjectFormId) throw new Error('主体缺少正式形态,不能修订摄影设计。') + return { + subjectRef: item.subjectRef, + formId: item.subjectFormId, + formName: item.formName, + expression: item.expression, + pose: item.pose, + gaze: item.gaze, + position: item.position, + transientState: item.transientState + } + }) + } + } +} diff --git a/src/features/storyboard/derived-review.types.ts b/src/features/storyboard/derived-review.types.ts new file mode 100644 index 0000000..ece1ae3 --- /dev/null +++ b/src/features/storyboard/derived-review.types.ts @@ -0,0 +1,64 @@ +import type { GenerateKeyframeInput, KeyframeGenerationPreview } from '../production/types' +import type { ShotDirection } from './types' + +/** 正式审核约束的摄影草案。 */ +export interface ShotReviewDraft { + /** 当前正式分镜版本。 */ + expectedShotFingerprint: string + /** 本镜摄影设计及镜头序号。 */ + direction: ShotDirection & { /** 段落内镜头序号。 */ shotNo: number } + /** 本镜待确认的即时状态。 */ + visualState: { + /** 段落内镜头序号。 */ shotNo: number + /** 与镜头正式绑定一致的主体形态。 */ + subjects: Array<{ + /** 主体引用。 */ subjectRef: string + /** 形态编号。 */ formId: string + /** 形态名称。 */ formName: string + /** 表情。 */ expression: string + /** 姿态。 */ pose: string + /** 视线。 */ gaze: string + /** 位置。 */ position: string + /** 即时变化。 */ transientState: string + }> + /** 环境即时状态。 */ + environment: { + /** 时间。 */ timeOfDay: string + /** 天气。 */ weather: string + /** 氛围。 */ atmosphere: string + /** 即时环境变化。 */ transientState: string + } + /** 衔接说明。 */ continuityNote: string + } + /** 已确认的场景机位参考和对应几何版本。 */ + sceneSources: Array<{ + /** 正式场景引用。 */ subjectRef: string + /** 参考图编号。 */ imageId: string + /** 几何版本。 */ spatialLayoutVersion: string + }> + /** 用户明确选择的前镜状态来源。 */ + sceneStateCarryForward?: { + /** 同集紧邻前镜。 */ previousShotId: string + /** 所选场景。 */ subjectRef: string + } +} + +/** 原样传给免费预览和人工采用的可选模型参数。 */ +export type DraftProviderInput = Pick + +/** 草案只有草案指纹,不能提交正式生图。 */ +export interface ShotDraftPreview extends Omit { + /** 本次草案的确切输入版本。 */ draftFingerprint: string + /** 草案始终不能直接生成。 */ productionReady: false + /** 项目级制作门禁。 */ + productionGate: { /** 项目是否就绪。 */ ready: boolean; /** 当前阻断原因。 */ reason: string | null } + /** 实际审核的场景几何依据。 */ sceneSources: ShotReviewDraft['sceneSources'] +} + +/** 每次人工采用一个或多个已预览镜头。 */ +export interface DerivedReviewSelection extends DraftProviderInput { + /** 正式镜头编号。 */ shotId: string + /** 用户核对过的草案。 */ draft: ShotReviewDraft + /** 对应的免费预览指纹。 */ expectedDraftFingerprint: string + /** 控制正式修订时必须携带的旧来源。 */ expectedCurrentFormalSourceFingerprint?: string +} diff --git a/src/features/storyboard/generation-spec.types.ts b/src/features/storyboard/generation-spec.types.ts index f4c9d0c..1745336 100644 --- a/src/features/storyboard/generation-spec.types.ts +++ b/src/features/storyboard/generation-spec.types.ts @@ -49,6 +49,8 @@ export interface ShotGenerationEnvironmentSpec { * 此结构只负责编译已有正式数据,不调用模型,也不重新解释剧情。 */ export interface ShotGenerationSpec { + /** 上一镜与当前镜头的正式连续性证据。 */ + continuity?: ShotContinuityEvidence | null projectId: string episodeNo: number beatNo: number @@ -63,3 +65,30 @@ export interface ShotGenerationSpec { environment: ShotGenerationEnvironmentSpec continuityNote: string } + +/** 编译时读取的相邻镜头证据,首态与尾态分别记录。 */ +export interface ShotContinuityEvidence { + /** 同集紧邻前镜。 */ previousShotId: string + /** 是否共用场景。 */ sameScene: boolean + /** 单独确认的前镜尾态。 */ + previousClosingState: { + /** 动作修订编号。 */ revisionId: string + /** 修订版本。 */ fingerprint: string + /** 已确认尾态。 */ text: string + } | null + /** 可比较的主体状态。 */ + subjects: Array<{ + /** 主体引用。 */ subjectRef: string + /** 主体分类。 */ module: string + /** 前镜正式形态。 */ previousFormId: string | null + /** 当前正式形态。 */ currentFormId: string + /** 当前形态变化的依据。 */ formDecision: 'same_form' | 'confirmed_change' | 'bound_form' | 'needs_review' + /** 前镜即时状态。 */ previousStartState: string | null + /** 当前镜头即时状态。 */ currentStartState: string | null + }> + /** 等待人工核对的冲突。 */ + reviewIssues: Array<{ + /** 冲突类型。 */ code: 'character_form_transition_unconfirmed' | 'scene_state_transition_unconfirmed' + /** 需要核对的主体。 */ subjectRef: string + }> +} diff --git a/src/features/storyboard/useStoryboard.ts b/src/features/storyboard/useStoryboard.ts index fa99f0c..2a37e2b 100644 --- a/src/features/storyboard/useStoryboard.ts +++ b/src/features/storyboard/useStoryboard.ts @@ -148,16 +148,30 @@ export function useStoryboard() { const hasCurrentEpisodeShots = computed( () => Math.max(data.value?.directions.shotCount ?? 0, data.value?.visualStates.shotCount ?? 0) > 0 ) + /** 旧的批量生成仍要求项目素材阶段完成,独立首帧使用逐镜头门禁。 */ + const projectAssetsReady = computed( + () => + context.stageReadiness.value?.projectId === id.value && + context.stageReadiness.value.subjectAssets.ready === true + ) + /** 批量操作继续使用原项目级前置条件。 */ const allowed = computed>(() => ({ - 'shots-current': !blocked.value && episodeNo.value > 0 && hasCurrentEpisodeShots.value, - 'direction-all': approved.value && !blocked.value && prerequisites.value.directionProject && batchValid.value, + 'shots-current': + projectAssetsReady.value && !blocked.value && episodeNo.value > 0 && hasCurrentEpisodeShots.value, + 'direction-all': + projectAssetsReady.value && + approved.value && + !blocked.value && + prerequisites.value.directionProject && + batchValid.value, 'visual-all': + projectAssetsReady.value && approved.value && !blocked.value && prerequisites.value.visualProject && batchValid.value && repairsValid.value, - prompts: !blocked.value && shots.value.length > 0 && batchValid.value + prompts: projectAssetsReady.value && !blocked.value && shots.value.length > 0 && batchValid.value })) /** 正式后台任务观察器;重生成使用后端 breakdown 名称并通过 metadata 区分。 */ @@ -268,6 +282,7 @@ export function useStoryboard() { source, episodeSourceUnavailable, prerequisites, + projectAssetsReady, session, operation, concurrency, diff --git a/src/features/subject-images/api.ts b/src/features/subject-images/api.ts index 7399a00..8485458 100644 --- a/src/features/subject-images/api.ts +++ b/src/features/subject-images/api.ts @@ -24,11 +24,13 @@ export const subjectImagesApi = { /** * 显式准备道具结构规格,可能调用文字模型,不生成图片。 * @param formId 正式形态编号 + * @param reuseOnly 是否仅复用已有正式结构,禁止调用模型 * @returns 当前结构规格,页面随后重新读取正式准备状态 */ - prepareStructure: (formId: string) => + prepareStructure: (formId: string, reuseOnly = false) => request>(`/subject-forms/${encodeURIComponent(formId)}/prop-structure-spec/generate`, { method: 'POST', + body: { reuseOnly }, timeoutMs: 0 }), /** 生成并保存正式生图提示词;force 仅覆盖提示词,不生成或替换图片。 */ diff --git a/src/features/subject-images/components/FormSourceDiagnostics.vue b/src/features/subject-images/components/FormSourceDiagnostics.vue index 096ef03..07d4a3d 100644 --- a/src/features/subject-images/components/FormSourceDiagnostics.vue +++ b/src/features/subject-images/components/FormSourceDiagnostics.vue @@ -3,6 +3,10 @@ import { computed, ref } from 'vue' import { NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui' import { AssetImage } from '../../../components/ui' import RawDataDetails from '../../../components/ui/RawDataDetails.vue' +import { ApiError } from '../../../lib/http' +import { getOperation, runOperation } from '../../workflows/operations' +import { useActionMessage } from '../../../components/ui/useActionMessage' +import { subjectImagesApi } from '../api' import { useQuery } from '../../../composables/useQuery' import { userFacingText } from '../../../lib/user-facing-text' import { subjectIdentityApi } from '../../subject-identity/api' @@ -43,6 +47,38 @@ const query = useQuery(key, async (value, signal) => { }) /** 道具当前有效规格或独立的缺失、过期状态。 */ const prop = computed(() => query.data.value?.prop) +/** 复用中的局部按钮状态。 */ +const reusing = ref(false) +/** 复用反馈只在消息层展示。 */ +const message = useActionMessage() + +/** 仅复用已有结构;冲突保留当前数据,不调用生成入口。 */ +async function reuseStructure() { + if (!prop.value || reusing.value || getOperation(props.projectId).pending) return + const target = key.value + const formId = props.form.id + reusing.value = true + try { + const ok = await runOperation(props.projectId, '复用道具结构规格', async () => { + try { + await subjectImagesApi.prepareStructure(formId, true) + } catch (cause) { + if (cause instanceof ApiError && cause.status === 409) + throw new Error('没有可直接复用的当前规格,已有资料未变更。', { cause }) + throw cause + } + }) + if (target !== key.value) return + if (ok) { + message?.success('已复用道具结构规格') + await query.refresh() + } else { + message?.error(getOperation(props.projectId).error) + } + } finally { + reusing.value = false + } +} /** 以原始部件顺序展示原始与当前数量。 */ const parts = computed( () => @@ -92,6 +128,18 @@ function episodeLabel(id: string) {

{{ userFacingText(prop.reason, '请重新核对当前形态与剧本来源。') }}

+ +
+ + 免费复用已有规格 + + 需要新规格时,可在图片准备检查中另行确认文字模型费用。 +

{{ prop.spec.semanticClass }}

  • diff --git a/src/features/subject-images/components/ImageGenerationPreview.vue b/src/features/subject-images/components/ImageGenerationPreview.vue index bd4c471..2d2a0ab 100644 --- a/src/features/subject-images/components/ImageGenerationPreview.vue +++ b/src/features/subject-images/components/ImageGenerationPreview.vue @@ -17,6 +17,8 @@ const props = defineProps<{ preview: ImageGenerationPreview | null /** 预览读取中。 */ loading: boolean + /** 只显示已取得的实际输入。 */ + displayOnly?: boolean /** 当前不能读取预览。 */ disabled?: boolean /** 读取或提交错误。 */ @@ -81,10 +83,12 @@ const omitted = computed(
    = { CREATIVE_PROFILE_REQUIRED: '请先保存项目生成配置,再重新检查制作计划。', CANVAS_CHANGE_REQUIRES_REVALIDATION: '已有分镜,暂时不能直接修改作品画幅。需要先重新核对镜头设计和相关素材,当前配置未保存。', + KEYFRAME_CANVAS_MISMATCH: '所选尺寸与项目交付画幅不符。请在当前模型目录选择与项目画幅一致的尺寸。', + KEYFRAME_CANVAS_SIZE_UNAVAILABLE: '所选模型或尺寸不能用于当前项目画幅,请选择目录中与画幅一致的固定尺寸。', + KEYFRAME_SOURCE_STALE: '镜头、正式设计或参考已变化,请刷新候选并重新预览。', + SCENE_STATE_SOURCE_STALE: '前镜或当前场景状态已变化,请重新核对衔接后预览。', CREATIVE_PROFILE_ACTIVE_WORKFLOW: '项目仍有任务进行中,请等待任务结束后再保存生成配置。', GENERATION_CONFIG_CHANGE_REQUIRES_REVALIDATION: '已有首帧或视频,暂时不能直接修改相关模型或参数。需要先处理现有素材的更新关系,当前配置未保存。' diff --git a/tests/features/production/keyframe-vision.test.ts b/tests/features/production/keyframe-vision.test.ts new file mode 100644 index 0000000..aaa5e48 --- /dev/null +++ b/tests/features/production/keyframe-vision.test.ts @@ -0,0 +1,174 @@ +import { effectScope, ref } from 'vue' +import { flushPromises } from '@vue/test-utils' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { submitKeyframeVision, useKeyframeVision } from '@/features/production/keyframe-vision' +import type { KeyframeValidationHistoryItem } from '@/features/production/quality.types' + +/** 使用隔离候选和会话状态模拟正式 HTTP。 */ +const shotId = 'vision-shot' +const assetId = 'vision-candidate' +const taskId = 'vision-task' +const executionId = 'vision-run' +let scope = effectScope() + +afterEach(() => { + scope.stop() + scope = effectScope() + sessionStorage.clear() +}) + +/** + * 模拟正式历史中的公开任务证据。 + * @param status 服务保存的状态 + * @param output 公开结果 + * @returns 审核历史 + */ +function history(status: string, output: Record = {}): KeyframeValidationHistoryItem { + return { + id: taskId, + executionId, + status, + output, + error: null, + startedAt: null, + finishedAt: null, + createdAt: '2026-11-06', + steps: [ + { name: 'general', status: 'completed', providerRequestId: 'request-1', usage: { totalTokens: 42 } }, + { name: 'gaze', status: 'received' } + ] + } +} + +/** + * 返回一个 HTTP Mock 响应。 + * @param data 公开数据 + * @param status HTTP 状态 + * @returns 可交给 fetch 的响应 + */ +function response(data: unknown, status = 200) { + return new Response(JSON.stringify({ data }), { status }) +} + +/** 从新页面创建观察者,不触发任何 POST。 */ +function observe() { + return scope.run(() => useKeyframeVision(ref(JSON.stringify([shotId, assetId]))))! +} + +describe('正式首帧 Vision 的费用与恢复边界', () => { + it('202 只受理一次,刷新后从历史恢复分步状态与执行记录', async () => { + const fetcher = vi.fn().mockImplementation(async (url, options) => { + if (options?.method === 'POST') + return response( + { shotId, keyframeId: assetId, validationTaskId: taskId, executionId, status: 'pending' }, + 202 + ) + if (String(url).endsWith('/validations')) return response([history('running')]) + return response({ id: executionId, status: 'running' }) + }) + vi.stubGlobal('fetch', fetcher) + expect(await submitKeyframeVision(shotId, assetId, ['门牌'], [])).toBeNull() + const vision = observe() + await flushPromises() + expect(vision.state.value.active?.steps?.[0]?.usage?.totalTokens).toBe(42) + expect(vision.execution.data.value?.id).toBe(executionId) + expect(vision.blocked.value).toBe(true) + await expect(submitKeyframeVision(shotId, assetId, ['门牌'], [history('running')])).rejects.toThrow('待核查') + expect(fetcher.mock.calls.filter(([, options]) => options?.method === 'POST')).toHaveLength(1) + }) + + it('200 复用真实结论,包括未通过的已完成结果', async () => { + const fetcher = vi.fn().mockResolvedValue( + response({ + shotId, + keyframeId: assetId, + validationTaskId: taskId, + passed: false, + issues: [], + summary: '视线未通过', + subjects: [], + subjectCountConsistent: true, + unauthorizedText: { detected: false, texts: [] } + }) + ) + vi.stubGlobal('fetch', fetcher) + expect(await submitKeyframeVision(shotId, assetId, [], [])).toMatchObject({ passed: false }) + expect(fetcher).toHaveBeenCalledTimes(1) + }) + + it('断线保留原提交并只读找回任务;未知费用不自动重试', async () => { + const fetcher = vi.fn().mockImplementation(async (url, options) => { + if (options?.method === 'POST') throw new TypeError('HTTP 断线') + if (String(url).endsWith('/validations')) return response([history('failed', { recoveryRequired: true })]) + return response({ id: executionId, status: 'failed' }) + }) + vi.stubGlobal('fetch', fetcher) + await expect(submitKeyframeVision(shotId, assetId, [], [])).rejects.toThrow('暂时无法连接服务') + const vision = observe() + await flushPromises() + expect(vision.state.value.unknown?.id).toBe(taskId) + expect(vision.blocked.value).toBe(true) + await expect( + submitKeyframeVision(shotId, assetId, [], [history('failed', { recoveryRequired: true })]) + ).rejects.toThrow('已有审核或费用待核查') + expect(fetcher.mock.calls.filter(([, options]) => options?.method === 'POST')).toHaveLength(1) + }) + + it('有正式可继续结论时使用原文字显式提交,保留已完成步骤', async () => { + let accepted = 0 + const saved = history('failed', { recoveryRequired: false, resumeAvailable: true }) + const fetcher = vi.fn().mockImplementation(async (_url, options) => { + if (options?.method === 'POST') { + accepted++ + return response( + { + shotId, + keyframeId: assetId, + validationTaskId: taskId, + executionId: accepted === 1 ? executionId : 'resume-execution', + status: 'pending' + }, + 202 + ) + } + return response([saved]) + }) + vi.stubGlobal('fetch', fetcher) + await submitKeyframeVision(shotId, assetId, ['旧门牌'], []) + const vision = observe() + await flushPromises() + expect(vision.resumeTexts.value).toEqual(['旧门牌']) + expect(vision.state.value.resumable?.steps?.map(item => item.status)).toEqual(['completed', 'received']) + await expect(submitKeyframeVision(shotId, assetId, ['新门牌'], [saved])).rejects.toThrow('原审核参数') + expect(accepted).toBe(1) + await submitKeyframeVision(shotId, assetId, ['旧门牌'], [saved]) + expect(accepted).toBe(2) + expect( + fetcher.mock.calls + .filter(([, options]) => options?.method === 'POST') + .map(([, options]) => JSON.parse(String(options?.body))) + ).toEqual([{ allowedTexts: ['旧门牌'] }, { allowedTexts: ['旧门牌'] }]) + }) + + it('409 活动审核只观察原编号,不能把当前表单参数当作原参数', async () => { + const fetcher = vi.fn().mockImplementation(async (url, options) => { + if (options?.method === 'POST') + return new Response( + JSON.stringify({ + message: 'KEYFRAME_VALIDATION_ACTIVE', + details: { code: 'KEYFRAME_VALIDATION_ACTIVE', taskId, executionId } + }), + { status: 409 } + ) + if (String(url).endsWith('/validations')) return response([history('running')]) + return response({ id: executionId, status: 'running' }) + }) + vi.stubGlobal('fetch', fetcher) + expect(await submitKeyframeVision(shotId, assetId, ['新文字'], [])).toBeNull() + const vision = observe() + await flushPromises() + expect(vision.execution.data.value?.id).toBe(executionId) + expect(vision.resumeTexts.value).toBeNull() + expect(vision.blocked.value).toBe(true) + }) +}) diff --git a/tests/features/production/public-assets.test.ts b/tests/features/production/public-assets.test.ts index d21d1e8..4127ae5 100644 --- a/tests/features/production/public-assets.test.ts +++ b/tests/features/production/public-assets.test.ts @@ -70,6 +70,15 @@ function recoveryButton(label: string) { return [...document.querySelectorAll('button')].find(item => item.textContent?.trim() === label)! } +/** + * 在实际弹窗中定位当前可操作的按钮。 + * @param label 完整按钮文字 + * @returns 对应按钮 + */ +function dialogButton(label: string) { + return [...document.querySelectorAll('button')].find(item => item.textContent?.trim() === label) +} + describe('精简公开资产回归', () => { it('无内部字段的视频可播放,晋升使用后端权限,会话通过不能授权', async () => { const projectId = 'public-video-contract' @@ -298,24 +307,35 @@ describe('精简公开资产回归', () => { const projectId = 'keyframe-promotion-contract' const primary = keyframeFixture() const candidate = keyframeFixture({ id: 'keyframe-2', isPrimary: false }) + let persistedQuality = 'unknown' + const primaryRequests: string[] = [] vi.stubGlobal( 'fetch', - vi.fn().mockImplementation( - async url => - new Response( - JSON.stringify({ - data: String(url).endsWith('/generation-models') - ? imageCatalog - : String(url).endsWith('/creative-profile') - ? generationProfile(projectId) - : String(url).endsWith('/keyframes') - ? [primary, candidate] - : [] - }) - ) - ) + vi.fn().mockImplementation(async (url, options) => { + if (options?.method === 'PUT') { + primaryRequests.push(String(url)) + return new Response(JSON.stringify({ data: { ...candidate, isPrimary: true } })) + } + return new Response( + JSON.stringify({ + data: String(url).endsWith('/generation-models') + ? imageCatalog + : String(url).endsWith('/creative-profile') + ? generationProfile(projectId) + : String(url).endsWith('/keyframes') + ? [primary, candidate] + : String(url).endsWith('/quality-review') + ? { + effectiveQualityStatus: String(url).includes(candidate.id) + ? persistedQuality + : 'passed' + } + : [] + }) + ) + }) ) - const wrapper = mount(ShotProductionAssets, { + let wrapper = mount(ShotProductionAssets, { attachTo: document.body, props: { projectId, shot, disabled: false } }) @@ -365,7 +385,29 @@ describe('精简公开资产回归', () => { expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(true) expect( [...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧')) - ).toBe(true) + ).toBe(false) + + wrapper.unmount() + persistedQuality = 'passed' + wrapper = mount(ShotProductionAssets, { + attachTo: document.body, + props: { projectId, shot, disabled: false } + }) + await flushPromises() + await wrapper + .findAll('button') + .find(item => item.text().includes('管理候选'))! + .trigger('click') + await flushPromises() + const promote = dialogButton('设为主首帧') + expect(promote).toBeDefined() + promote?.click() + await flushPromises() + dialogButton('确认切换')?.click() + await flushPromises() + expect(primaryRequests).toEqual([ + '/api/storyboard-shots/' + shot.shotId + '/keyframes/' + candidate.id + '/primary' + ]) } finally { wrapper.unmount() } diff --git a/tests/features/production/quality.test.ts b/tests/features/production/quality.test.ts index 6eca2d4..1a1b933 100644 --- a/tests/features/production/quality.test.ts +++ b/tests/features/production/quality.test.ts @@ -30,6 +30,7 @@ afterEach(() => { wrapper?.unmount() wrapper = undefined document.body.innerHTML = '' + sessionStorage.clear() vi.restoreAllMocks() vi.unstubAllGlobals() }) @@ -162,6 +163,10 @@ function server() { error: null } else if (path.endsWith('/checkpoints')) data = [] + else if (path.endsWith('/production/entry-readiness')) data = { ready: true } + else if (path.endsWith('/validations')) data = [] + else if (path.endsWith('/quality-review')) + data = { effectiveQualityStatus: 'unknown', qualityDecision: 'unknown', historicalGazePreview: [] } else if (path.includes('/readiness')) data = readiness else if (path.endsWith('/keyframes')) data = [keyframe] else if (path.endsWith('/videos')) data = [video] @@ -450,7 +455,7 @@ describe('质量面板渐进展示', () => { expect(validationButton().disabled).toBe(true) expect(document.body.textContent).toContain('更多参数与模型限制') expect(document.querySelector('[aria-label="额外允许的画面文字"]')).not.toBeNull() - expect(data.fetcher).not.toHaveBeenCalled() + expect(data.posts()).toHaveLength(0) wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true) await flushPromises() expect(validationButton().disabled).toBe(false) diff --git a/tests/features/projects/access.test.ts b/tests/features/projects/access.test.ts index 74f9628..dabbde0 100644 --- a/tests/features/projects/access.test.ts +++ b/tests/features/projects/access.test.ts @@ -487,7 +487,7 @@ describe('剧本完成前的下游访问限制', () => { expect(wrapper!.find(`.n-menu a[href="/projects/${id}/subject-identity"]`).exists()).toBe(false) }) - it('部分身份未齐备时可以逐项准备形态资料,但不能提前进入镜头设计或生产', async () => { + it('部分身份未齐备时允许核对已准备分镜,项目制作仍受限', async () => { const id = 'partial-asset-preparation' const state = readiness(id) state.identity = { ready: false, reason: '还有角色尚未确认选角' } @@ -499,7 +499,7 @@ describe('剧本完成前的下游访问限制', () => { const { mounted } = await openProject(`/projects/${id}/subject-images`) expect(mounted).toHaveBeenCalledExactlyOnceWith('subject-images') expect(wrapper!.find(`.n-menu a[href="/projects/${id}/subject-images"]`).exists()).toBe(true) - expect(wrapper!.find(`.n-menu a[href="/projects/${id}/storyboard"]`).exists()).toBe(false) + expect(wrapper!.find(`.n-menu a[href="/projects/${id}/storyboard"]`).exists()).toBe(true) expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false) }) diff --git a/tests/features/storyboard/derived-review.test.ts b/tests/features/storyboard/derived-review.test.ts new file mode 100644 index 0000000..2100580 --- /dev/null +++ b/tests/features/storyboard/derived-review.test.ts @@ -0,0 +1,144 @@ +import { describe, expect, it, vi } from 'vitest' +import { derivedReviewApi } from '@/features/storyboard/derived-review-api' +import { draftFromFormal } from '@/features/storyboard/derived-review' +import { subjectImagesApi } from '@/features/subject-images/api' +import type { DesignedShot } from '@/features/storyboard/types' +import type { KeyframeSpec } from '@/features/production/types' + +/** 已保存的正式镜头样本,保留空间、动作和形态值。 */ +const shot: DesignedShot = { + shotId: 'shot/1', + beatNo: 1, + shotNo: 1, + title: '开门', + description: '角色站在门边', + visualFocus: '手', + direction: { + shotSize: 'wide', + cameraAngle: 'eye_level', + cameraMovement: 'static', + composition: '门在右侧', + cameraPosition: '室内', + lensIntent: 'wide', + depthOfField: 'deep', + visualIntent: '空间关系' + }, + visualState: { + timeOfDay: '午后', + weather: '', + atmosphere: '', + environmentTransientState: '日光', + continuityNote: '保持视角', + subjects: [ + { + subjectId: 'scene', + subjectRef: '@SC0001', + subjectFormId: 'scene-form', + formName: '客厅', + expression: '', + pose: '', + gaze: '', + position: '画面右侧', + transientState: '' + } + ] + } +} +/** 正式来源及已确认的场景几何。 */ +const keyframe: KeyframeSpec = { + formalSourceFingerprint: 'a'.repeat(64), + projectId: 'p/1', + shotId: shot.shotId, + episodeNo: 1, + beatNo: 1, + shotNo: 1, + prompt: '正式描述', + references: [ + { + subjectId: 'scene', + subjectRef: '@SC0001', + module: 'scene', + role: 'layout-master', + imageId: 'master-1', + imageUrl: '/storage/master.png', + spatialLayoutVersion: 'geometry-1' + } + ] +} + +describe('摄影草案与规格复用的正式契约', () => { + it('受控修订只变更摄影字段,采用原预览和正式来源', async () => { + const fingerprint = 'b'.repeat(64) + const draft = draftFromFormal(shot, keyframe, fingerprint) + const original = structuredClone(draft) + draft.direction.composition = '保留原场景并移动构图' + draft.direction.cameraPosition = '室内右侧' + expect(draft.visualState).toEqual(original.visualState) + expect(draft.sceneSources).toEqual([ + { subjectRef: '@SC0001', imageId: 'master-1', spatialLayoutVersion: 'geometry-1' } + ]) + const mock = vi + .fn() + .mockResolvedValueOnce( + new Response( + JSON.stringify({ data: { draftFingerprint: 'draft-fingerprint', productionReady: false } }) + ) + ) + .mockResolvedValueOnce(new Response(JSON.stringify({ data: { shots: [{ shotId: shot.shotId }] } }))) + vi.stubGlobal('fetch', mock) + const params = { provider: 'seedream', generationOptions: { size: '2048x2048' } } + const preview = await derivedReviewApi.preview(shot.shotId, draft, params) + expect(preview.productionReady).toBe(false) + expect(mock).toHaveBeenCalledTimes(1) + await derivedReviewApi.confirm('p/1', '人工', [ + { + ...params, + shotId: shot.shotId, + draft, + expectedDraftFingerprint: preview.draftFingerprint, + expectedCurrentFormalSourceFingerprint: keyframe.formalSourceFingerprint + } + ]) + expect(mock.mock.calls.map(([url]) => url)).toEqual([ + '/api/storyboard-shots/shot%2F1/keyframe/preview', + '/api/projects/p%2F1/storyboard-derived-reviews/confirm' + ]) + expect(JSON.parse(String(mock.mock.calls[1]![1]?.body)).shots[0]).toMatchObject({ + ...params, + draft, + expectedCurrentFormalSourceFingerprint: keyframe.formalSourceFingerprint, + expectedDraftFingerprint: 'draft-fingerprint' + }) + }) + + it('场景沿用保留其它状态,只将选定的正式前镜证据交给免费预览', async () => { + const draft = draftFromFormal(shot, keyframe, 'b'.repeat(64)) + draft.sceneStateCarryForward = { previousShotId: 'previous', subjectRef: '@SC0001' } + draft.visualState.subjects[0]!.transientState = '门半开' + const mock = vi + .fn() + .mockResolvedValue(new Response(JSON.stringify({ data: { productionReady: false } }))) + vi.stubGlobal('fetch', mock) + await derivedReviewApi.preview(shot.shotId, draft, {}) + expect(JSON.parse(String(mock.mock.calls[0]![1]?.body)).draft).toMatchObject({ + sceneStateCarryForward: draft.sceneStateCarryForward, + visualState: { + subjects: [{ formId: 'scene-form', transientState: '门半开' }], + environment: { transientState: '日光' } + } + }) + expect(shot.visualState?.subjects[0]?.transientState).toBe('') + expect(mock).toHaveBeenCalledTimes(1) + }) + + it('道具复用冲突只发送一次 reuseOnly,不回退文字模型', async () => { + const mock = vi + .fn() + .mockResolvedValue(new Response(JSON.stringify({ message: '没有等价规格' }), { status: 409 })) + vi.stubGlobal('fetch', mock) + await expect(subjectImagesApi.prepareStructure('form/1', true)).rejects.toMatchObject({ status: 409 }) + expect(mock).toHaveBeenCalledTimes(1) + expect(mock.mock.calls[0]![0]).toBe('/api/subject-forms/form%2F1/prop-structure-spec/generate') + expect(JSON.parse(String(mock.mock.calls[0]![1]?.body))).toEqual({ reuseOnly: true }) + }) +}) diff --git a/tests/features/workflows/pages.test.ts b/tests/features/workflows/pages.test.ts index 1f97cae..3bcbfaa 100644 --- a/tests/features/workflows/pages.test.ts +++ b/tests/features/workflows/pages.test.ts @@ -112,7 +112,7 @@ function stubFetch(fetcher: Mock) { let executionCount = 0 fetcher.mockImplementation(async (url, init) => { const path = String(url) - if (path.endsWith('/storyboard/quality-confirmation')) { + if (path.endsWith('/storyboard-quality-confirmation')) { const current = preparationFixture(fixture.id) return jsonResponse({ ...current.approval, valid: true, confirmation: current.record }) } @@ -1955,7 +1955,7 @@ describe('工作台页面交互', () => { fetcher.mock.calls.filter( ([url, init]) => (!init?.method || init.method === 'GET') && - !String(url).endsWith('/storyboard/quality-confirmation') + !String(url).endsWith('/storyboard-quality-confirmation') ) ).toHaveLength(12) expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/duration-budget'))).toHaveLength(2) @@ -2055,10 +2055,10 @@ describe('工作台页面交互', () => { expect(wrapper!.text()).not.toContain('第1集镜头1') /** 切换剧集只增加当前集查询,项目时长预算只在挂载时读取一次。 */ expect( - fetcher.mock.calls.filter(([url]) => !String(url).endsWith('/storyboard/quality-confirmation')) + fetcher.mock.calls.filter(([url]) => !String(url).endsWith('/storyboard-quality-confirmation')) ).toHaveLength(6) expect( - fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard/quality-confirmation')) + fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard-quality-confirmation')) ).toHaveLength(1) expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/duration-budget'))).toHaveLength(1) expect(fetcher.mock.calls.every(([, init]) => !init?.method || init.method === 'GET')).toBe(true)