diff --git a/src/features/breakdown/candidate.ts b/src/features/breakdown/candidate.ts
index a4ae699..bcdec76 100644
--- a/src/features/breakdown/candidate.ts
+++ b/src/features/breakdown/candidate.ts
@@ -3,6 +3,7 @@ import type { CandidateCommitPreview, CandidateCommitCheckPreview } from './cand
/** 安全检查项与用户可理解的阻断原因共用一份映射。 */
export const candidateCheckLabels: Record = {
+ durationBudgetCurrent: '候选预算与当前正式时长一致',
qualityPolicyMatches: '质量规则与当前已确认版本一致',
episodeNumbersMatch: '剧集范围与候选一致',
episodeFingerprintsMatch: '剧本正文版本未变化',
@@ -16,6 +17,7 @@ export const candidateCheckLabels: Record candidatePreviewReady(preview.value, props.projectI
const failedChecks = computed(() =>
current.value ? candidateCheckKeys.filter(key => current.value!.checks?.[key] !== true) : []
)
+
/** 原始关系只能来自本次安全预检,不解析问题字符串构造删除参数。 */
const targets = computed(() => current.value?.relationRepairTargets ?? [])
/** 用户选择的关系仍需校验完整且定位唯一。 */
@@ -398,6 +400,10 @@ async function commit() {
+
+
+ {{ userFacingText(current.durationSourceIssue) }}
+
+import { computed } from 'vue'
+import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
+import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
+import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
+import { useQuery } from '../../../composables/useQuery'
+import { userFacingText } from '../../../lib/user-facing-text'
+import { projectsApi } from '../../projects/api'
+import { breakdownApi } from '../api'
+import type { BreakdownDurationFailure, EpisodeShots } from '../types'
+
+/** 时长诊断使用最新候选证据和正式预算的独立只读来源。 */
+const props = defineProps<{
+ /** 当前项目编号。 */ projectId: string
+ /** 当前保存记录变化时刷新。 */ checkpointId?: string
+}>()
+/** 查询随保存记录更新,旧候选不会回填当前任务。 */
+const key = computed(() => JSON.stringify([props.projectId, props.checkpointId]))
+/** 正式结果和候选诊断独立读取,保留某一来源暂不可用时的另一份结果。 */
+const query = useQuery(key, async (value, signal) => {
+ const [projectId] = JSON.parse(value) as [string, string?]
+ const [formal, latest] = await Promise.allSettled([
+ projectsApi.durationBudget(projectId, signal),
+ breakdownApi.latest(projectId, signal)
+ ])
+ if (formal.status === 'fulfilled' && formal.value.projectId !== projectId)
+ throw new Error('时长资料与当前项目不匹配。')
+ if (latest.status === 'fulfilled' && latest.value?.projectId && latest.value.projectId !== projectId)
+ throw new Error('失败记录与当前项目不匹配。')
+ return { formal, latest }
+})
+/** 正式预算来自当前项目服务,包含尚无镜头的正式剧集。 */
+const formal = computed(() =>
+ query.data.value?.formal.status === 'fulfilled' ? query.data.value.formal.value.episodes : []
+)
+/** 最新失败候选和原始预算快照保留用于诊断。 */
+const latest = computed(() => (query.data.value?.latest.status === 'fulfilled' ? query.data.value.latest.value : null))
+/** 只选最新记录中实际返回的完整失败候选。 */
+const failures = computed(() => {
+ const entries = latest.value?.failureDetails?.details
+ return Array.isArray(entries)
+ ? entries.filter(
+ (item): item is BreakdownDurationFailure =>
+ item?.kind === 'storyboard-duration-failure' &&
+ item.candidate?.episodePlan &&
+ Array.isArray(item.candidate?.beatShots)
+ )
+ : []
+})
+/**
+ * 失败时可能尚未产出预算审计,按已返回的镜头阶段估算供复盘。
+ * @param candidate 服务器返回的失败候选
+ * @returns 只读估算,不用于通过审核或修改正式分镜
+ */
+function estimateFailedBudget(candidate: EpisodeShots) {
+ const beatSuggestions = candidate.beatShots.flatMap(beat => {
+ const budget = candidate.episodePlan.beats.find(item => item.beatNo === beat.beatNo)?.estimatedDurationSeconds
+ if (!budget || !beat.shots.length) return []
+ const required = beat.shots.reduce((sum, shot) => {
+ const planning = shot.durationPlanning
+ const estimated = planning?.phases.reduce(
+ (total, phase) => total + phase.estimatedSeconds,
+ planning.transitionSeconds
+ )
+ const supported =
+ planning && estimated !== undefined && Math.abs(estimated - planning.recommendedDurationSeconds) <= 0.1
+ return sum + (supported ? Math.max(shot.durationSeconds, estimated) : shot.durationSeconds)
+ }, 0)
+ return [
+ {
+ beatNo: beat.beatNo,
+ requiredSeconds: Number(required.toFixed(2)),
+ deficitSeconds: required > budget + 0.1 ? Number((required - budget).toFixed(2)) : 0
+ }
+ ]
+ })
+ if (!beatSuggestions.length) return undefined
+ return {
+ beatSuggestions,
+ minimumRequiredSeconds: Number(beatSuggestions.reduce((sum, beat) => sum + beat.requiredSeconds, 0).toFixed(2)),
+ deficitSeconds: Number(beatSuggestions.reduce((sum, beat) => sum + beat.deficitSeconds, 0).toFixed(2)),
+ estimated: true
+ }
+}
+/** 对应候选规划的目标版本、所有段落预算与已知缺口。 */
+const plans = computed(() => {
+ const items = new Map((latest.value?.storyboardPlans ?? []).map(plan => [plan.episodeNo, plan]))
+ for (const failure of failures.value) items.set(failure.episodeNo, failure.candidate.episodePlan)
+ return [...items.values()].map(plan => ({
+ ...plan,
+ report:
+ latest.value?.storyboardEpisodeDurationBudgets?.find(item => item.episodeNo === plan.episodeNo) ??
+ failures.value
+ .filter(item => item.episodeNo === plan.episodeNo)
+ .map(item => estimateFailedBudget(item.candidate))[0],
+ formal: formal.value.find(item => item.episodeNo === plan.episodeNo)
+ }))
+})
+
+
+
+
+
+
+ 正在读取时长预算…
+
+
{{ query.error.value }}
+
重新读取预算
+
+
+
+ 部分时长来源暂时无法读取。重新读取
+
+
+ -
+ 第 {{ episode.episodeNo }} 集 · 正式目标
+ {{ episode.targetDurationSeconds == null ? '自动' : `${episode.targetDurationSeconds} 秒` }} ·
+ 正式镜头
+ {{ episode.shotCount && episode.shotSeconds != null ? `${episode.shotSeconds} 秒` : '未生成' }}
+
+
+
+
+
+
+ 拆解时目标
+ {{
+ plan.targetDurationSeconds === undefined
+ ? '历史未记录'
+ : plan.targetDurationSeconds === null
+ ? '自动'
+ : `${plan.targetDurationSeconds} 秒`
+ }}
+
+
+ {{
+ plan.targetDurationSeconds === undefined
+ ? '缺少原预算快照,请核对来源。'
+ : '拆解后的正式目标已变化,请核对来源。'
+ }}
+
+
+ 根据失败候选估算 · 动作最低需求
+ {{ plan.report.minimumRequiredSeconds }} 秒 · 段落缺口合计
+ {{ plan.report.deficitSeconds }} 秒
+
+
+ -
+ 段落 {{ beat.beatNo }} · {{ beat.title }} · 预算 {{ beat.estimatedDurationSeconds }} 秒
+
+ · 最低需求 {{ gap.requiredSeconds }} 秒 · 缺口 {{ gap.deficitSeconds }} 秒
+
+
+
+
+
+
+
+ {{ userFacingText(latest.workflowExecution.errorMessage) }}
+
+
+
+
+
diff --git a/src/features/breakdown/components/BreakdownIssuesDialog.vue b/src/features/breakdown/components/BreakdownIssuesDialog.vue
index 4b1ef7c..f2d59b7 100644
--- a/src/features/breakdown/components/BreakdownIssuesDialog.vue
+++ b/src/features/breakdown/components/BreakdownIssuesDialog.vue
@@ -68,6 +68,8 @@ const groups = computed(() => {
const count = computed(() => groups.value.reduce((total, group) => total + group.messages.length, 0))
/** 等待离场后执行的定位。 */
const pendingLocation = ref(null)
+/** 时长资料按需读取,与其它问题查询独立。 */
+const diagnosticSections = ref([])
/**
* 关闭问题抽屉后定位到对应剧集、节拍或镜头。
@@ -104,6 +106,12 @@ function finish() {
>{{ count }} 项校验问题 · {{ groups.length }} 个位置查看最近保存结果中的问题
+
+
+
+
+
+
正在读取当前候选审核…
diff --git a/src/features/breakdown/types.ts b/src/features/breakdown/types.ts
index ad6e981..d6d6d4b 100644
--- a/src/features/breakdown/types.ts
+++ b/src/features/breakdown/types.ts
@@ -93,6 +93,8 @@ export interface StoryboardBeat {
/** 单集分镜规划。 */
export interface EpisodePlan {
+ /** 正式时长目标快照,空值为自动,缺失为历史未记录。 */
+ targetDurationSeconds?: number | null
episodeNo: number
episodeTitle: string
storyGoal: string
@@ -131,6 +133,30 @@ export interface ShotValidation {
issues: { episodeNo: number; beatNo?: number | null; shotNo?: number | null; message: string }[]
}
+/** 当前拆解候选的只读时长审计。 */
+export interface BreakdownDurationBudget {
+ /** 正式集数。 */ episodeNo: number
+ /** 已规划的段落预算之和。 */ plannedSeconds: number
+ /** 当前镜头及动作所需最低总时长。 */ minimumRequiredSeconds: number
+ /** 局部段落缺口之和。 */ deficitSeconds: number
+ /** 局部段落的预算及缺口。 */
+ beatSuggestions: Array<{
+ /** 段落号。 */ beatNo: number
+ /** 原段落预算。 */ budgetSeconds: number
+ /** 最低需求。 */ requiredSeconds: number
+ /** 当前缺口。 */ deficitSeconds: number
+ }>
+ /** 当前需要人工核对。 */ needsReview: boolean
+}
+
+/** 最新失败保存记录中的完整实际候选。 */
+export interface BreakdownDurationFailure {
+ /** 正式候选诊断类型。 */ kind: 'storyboard-duration-failure'
+ /** 失败集数。 */ episodeNo: number
+ /** 完整候选保留供诊断。 */ candidate: EpisodeShots
+ /** 此失败不自动恢复。 */ retryAutomatically: false
+}
+
/** Breakdown 的最终成果及阶段 checkpoint 共有的可展示字段。 */
export interface BreakdownResult {
subjectCandidates?: SubjectCandidate[]
@@ -152,6 +178,12 @@ export interface WorkflowExecution {
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
export interface BreakdownState extends BreakdownResult {
+ /** 最新保存记录编号。 */
+ checkpointId?: string
+ /** 当前服务端时长审计。 */
+ storyboardEpisodeDurationBudgets?: BreakdownDurationBudget[]
+ /** 失败详情仅用于诊断,不作为恢复请求参数。 */
+ failureDetails?: { /** 实际失败的结构化证据。 */ details?: unknown }
/** 快照所属项目;旧版观测响应可能缺省。 */
projectId?: string
/** 当前镜头动作质量决策,不从嵌套历史成果继承。 */
diff --git a/src/features/production/ProductionPage.vue b/src/features/production/ProductionPage.vue
index 290dc53..55c3e78 100644
--- a/src/features/production/ProductionPage.vue
+++ b/src/features/production/ProductionPage.vue
@@ -77,7 +77,7 @@ const latestVideoTaskLabel = computed(() =>
: `最近视频任务:${productionStatusLabel(videoStatusItem.value?.status ?? 'not_started')}`
)
/** 首帧质量任务在关闭弹窗后仍可观察,刷新页面后恢复持久化句柄。 */
-const keyframeQualityExecution = useWorkflowExecution(id, 'keyframe-quality')
+const keyframeQualityExecution = useWorkflowExecution(id, 'keyframe-quality', { discover: true })
/**
* 将首帧质量启动句柄交给页面级观察器,始终保存当前原项目归属。
diff --git a/src/features/production/api.ts b/src/features/production/api.ts
index 6352003..883a291 100644
--- a/src/features/production/api.ts
+++ b/src/features/production/api.ts
@@ -159,9 +159,14 @@ export const productionApi = {
keyframeSpec: (shotId: string, signal?: AbortSignal) =>
request
(`${shotPath(shotId)}/keyframe-spec`, { signal }),
/** 按本次请求选择的图片模型与参数预览最终输入,不创建首帧任务。 */
- previewKeyframe: (shotId: string, input: Pick) =>
+ previewKeyframe: (
+ shotId: string,
+ input: Pick,
+ signal?: AbortSignal
+ ) =>
request(`${shotPath(shotId)}/keyframe/preview`, {
method: 'POST',
+ signal,
body: input
}),
generateKeyframe: (shotId: string, input: GenerateKeyframeInput) =>
@@ -170,6 +175,17 @@ export const productionApi = {
body: input,
timeoutMs: 0
}),
+ /**
+ * 仅恢复已有首帧的下载,不重新发起生成。
+ * @param shotId 当前镜头
+ * @param keyframeId 已保存结果的候选
+ * @returns 同一候选更新后的记录
+ */
+ recoverSavedKeyframe: (shotId: string, keyframeId: string) =>
+ request(`${shotPath(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/recover-saved-result`, {
+ method: 'POST',
+ timeoutMs: 0
+ }),
setPrimaryKeyframe: (shotId: string, keyframeId: string) =>
request(`${shotPath(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/primary`, {
method: 'PUT'
diff --git a/src/features/production/components/KeyframeCard.vue b/src/features/production/components/KeyframeCard.vue
index 6106f0a..991e376 100644
--- a/src/features/production/components/KeyframeCard.vue
+++ b/src/features/production/components/KeyframeCard.vue
@@ -23,10 +23,13 @@ const props = defineProps<{
blocked: boolean
/** 只在当前源图编辑任务运行期间显示局部加载。 */
editing?: boolean
+ /** 仅本候选在下载时显示加载。 */
+ recovering?: boolean
validationPassed: boolean | null
confirming: boolean
}>()
-const emit = defineEmits<{ quality: []; edit: []; select: []; confirm: []; cancel: []; history: [] }>()
+/** 用户显式触发候选审核、确认或免费恢复。 */
+const emit = defineEmits<{ recover: []; quality: []; edit: []; select: []; confirm: []; cancel: []; history: [] }>()
/** 质量状态以数据库为准;会话内检查仅在历史状态未知时兜底。 */
const reviewKey = computed(() =>
props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id, props.reviewRevision ?? 0]) : ''
@@ -37,11 +40,21 @@ const reviewQuery = useQuery(reviewKey, (value, signal) => {
return qualityApi.keyframeQualityReview(shotId, keyframeId, signal)
})
const effectiveStatus = computed(() => reviewQuery.data.value?.effectiveQualityStatus ?? 'unknown')
+/** 其余未达可用门禁的独立质量状态。 */
+const reviewLabels: Record = {
+ stale: '审核来源过期',
+ blocked: '质量受阻',
+ insufficient_evidence: '审核证据不足',
+ unknown: '质量待确认'
+}
+/** 旧来源或已损坏的输入证据不能被会话中的历史通过覆盖。 */
const isPassed = computed(
() =>
- effectiveStatus.value === 'passed' ||
- effectiveStatus.value === 'manual_accepted' ||
- (effectiveStatus.value === 'unknown' && props.validationPassed === true)
+ !props.stale &&
+ props.item.inputSnapshotStatus !== 'invalid' &&
+ (effectiveStatus.value === 'passed' ||
+ effectiveStatus.value === 'manual_accepted' ||
+ (effectiveStatus.value === 'unknown' && props.validationPassed === true))
)
const canSelect = computed(
() =>
@@ -49,6 +62,8 @@ const canSelect = computed(
!!props.item.imageUrl &&
props.item.source !== 'provider_variant' &&
!props.item.isPrimary &&
+ !props.stale &&
+ props.item.inputSnapshotStatus !== 'invalid' &&
isPassed.value
)
@@ -71,7 +86,11 @@ const canSelect = computed(
{{ item.isPrimary ? '主首帧' : '候选首帧' }}
- 人工已接受
质量通过
@@ -87,6 +106,13 @@ const canSelect = computed(
:bordered="false"
>质量未通过
+
+ {{ reviewLabels[effectiveStatus] ?? '质量待确认' }}
+
视频参考图
已过期
@@ -95,6 +121,36 @@ const canSelect = computed(
>
+
+
+ {{
+ { recorded: '已保存生成输入', 'not-recorded': '历史生成输入未记录', invalid: '生成输入证据已失效' }[
+ item.inputSnapshotStatus
+ ]
+ }}
+
+ · {{ item.providerInputFingerprint.slice(0, 12) }}
+
+
+ {{
+ productionMessage(
+ item.recoveryReason ||
+ (item.canRecoverSavedResult
+ ? '可以恢复已生成图片的下载。'
+ : '原请求结果待核查,请先核对候选和模型服务记录。')
+ )
+ }}
+
+ 恢复已生成图片
{{ formatDate(item.createdAt) }}
diff --git a/src/features/production/components/KeyframeDialog.vue b/src/features/production/components/KeyframeDialog.vue
index 5d8d687..b3cb7b4 100644
--- a/src/features/production/components/KeyframeDialog.vue
+++ b/src/features/production/components/KeyframeDialog.vue
@@ -1,6 +1,7 @@
@@ -115,11 +119,12 @@ async function loadPreview() {
v-model:open="open"
:title="`${replacePrimary ? '生成替代候选' : '生成首帧候选'} · ${shotTitle}`"
description="新图先作为候选;完成质量检查并通过后,才能设为主首帧。"
+ :busy="submitting"
>
@@ -149,22 +154,53 @@ async function loadPreview() {
生成模型目录读取失败:{{ generationCatalogError }}
-
- 预览实际生成输入
- 只读取参考图规划与最终画面描述,不调用图片模型。
-
-
-
-
- {{ preview.provider }} / {{ preview.model }}
-
- 已选 {{ preview.referencePlan.selected.length }} /
- {{ preview.referencePlan.totalCandidates }} 张
-
-
- 省略 {{ preview.referencePlan.omitted.length }} 张
-
-
+
+
+
+ {{ directionSummary }}
+
+
+
+ {{
+ [
+ visualState.timeOfDay,
+ visualState.weather,
+ visualState.atmosphere,
+ visualState.environmentTransientState,
+ visualState.continuityNote
+ ]
+ .filter(Boolean)
+ .join(' · ')
+ }}
+
+
+ {{
+ [
+ subject.subjectRef,
+ subject.formName,
+ subject.position,
+ subject.pose,
+ subject.expression,
+ subject.gaze,
+ subject.transientState
+ ]
+ .filter(Boolean)
+ .join(' · ')
+ }}
+
+
+
+
+
+
-
- -
- {{ item.subjectRef }} · {{ item.role }} ·
{{ item.imageId }}
-
-
-
-
- {{ preview.providerPrompt }}
-
-
-
- -
- {{ item.subjectRef }} · {{ item.role }} ·
{{ item.imageId }}
-
-
-
-
- {{
- JSON.stringify(preview.generationConfig, null, 2)
- }}
-
-
我已确认调用图片模型可能产生费用,且当前没有相同镜头的生图任务。
+ >我已核对实际输入,并确认本次图片生成可能产生费用。
- 取消
- 取消
+ 确认生成首帧
diff --git a/src/features/production/components/ShotProductionAssets.vue b/src/features/production/components/ShotProductionAssets.vue
index eeb06d3..4e9f9fb 100644
--- a/src/features/production/components/ShotProductionAssets.vue
+++ b/src/features/production/components/ShotProductionAssets.vue
@@ -13,7 +13,7 @@ import { ImagePlus, RefreshCw } from '@lucide/vue'
import { AssetImage } from '../../../components/ui'
import { usePolling } from '../../../composables/usePolling'
import { useQuery } from '../../../composables/useQuery'
-import { errorMessage } from '../../../lib/http'
+import { ApiError, errorMessage } from '../../../lib/http'
import { candidateDialogWidth } from '../../../lib/candidate-layout'
import type { DesignedShot } from '../../storyboard/types'
import { storyboardApi } from '../../storyboard/api'
@@ -328,7 +328,7 @@ const canGeneratePrompt = computed(
const canGenerateKeyframe = computed(
() =>
!assetBlocked.value &&
- !keyframes.value.some(item => ['pending', 'generating'].includes(item.status)) &&
+ !keyframes.value.some(item => item.recoveryRequired || ['pending', 'generating'].includes(item.status)) &&
!!props.keyframeReadiness &&
props.keyframeReadiness.issues.length === 0
)
@@ -442,15 +442,38 @@ async function generatePrompt() {
await refreshAll()
}
-/** 调用图片模型生成单镜头首帧;成功后重新读取候选和主图。 */
+/**
+ * 提交已确认的首帧输入,并刷新该镜头候选。
+ * @param input 预览绑定的生成参数
+ * @returns 真实提交结果与可能的冲突
+ */
async function generateKeyframe(input: GenerateKeyframeInput) {
- if (!canGenerateKeyframe.value) return
+ if (!canGenerateKeyframe.value || !input.expectedPreviewFingerprint) return { accepted: false }
const shotId = props.shot.shotId
- await runOperation(props.projectId, `生成镜头 ${props.shot.shotNo} 首帧`, async () => {
+ const projectId = props.projectId
+ const accepted = await runOperation(projectId, `生成镜头 ${props.shot.shotNo} 首帧`, async () => {
const result = await productionApi.generateKeyframe(shotId, input)
- if (!result || result.shotId !== shotId) throw new Error('接口未确认首帧生成结果。')
+ if (!result || result.shotId !== shotId) throw new ApiError('首帧生成结果待核对。', 200)
})
- await refreshAll()
+ const cause = getOperation(projectId).cause
+ if (props.projectId === projectId && props.shot.shotId === shotId) await refreshAll()
+ return { accepted, cause }
+}
+
+/**
+ * 恢复原候选下载,只在服务明确有可恢复结果时允许。
+ * @param item 当前候选
+ */
+async function recoverSavedKeyframe(item: ShotKeyframe) {
+ if (assetBlocked.value || !item.canRecoverSavedResult || item.shotId !== props.shot.shotId) return
+ const projectId = props.projectId
+ const shotId = props.shot.shotId
+ await runOperation(projectId, `恢复已生成首帧 ${item.id}`, async () => {
+ const result = await productionApi.recoverSavedKeyframe(shotId, item.id)
+ if (result.id !== item.id || result.shotId !== shotId || result.status !== 'completed')
+ throw new Error('下载结果待核对,请刷新候选。')
+ })
+ if (projectId === props.projectId && shotId === props.shot.shotId) await refreshAll()
}
/** 切换主首帧不调用模型,但会改变后续视频生成输入。 */
@@ -966,6 +989,8 @@ defineExpose({ inspectSpecs, inspecting })
:shot-id="shot.shotId"
:review-revision="reviewRevision"
:item="item"
+ :recovering="isOperationRunning(getOperation(projectId), `恢复已生成首帧 ${item.id}`)"
+ @recover="recoverSavedKeyframe(item)"
:editing="
editSource?.id === item.id &&
isOperationRunning(getOperation(projectId), `编辑镜头 ${shot.shotId} 首帧`)
@@ -1054,8 +1079,10 @@ defineExpose({ inspectSpecs, inspecting })
:shot-title="shot.title"
:project-id="projectId"
:replace-primary="keyframeStale"
+ :direction="shot.direction"
+ :visual-state="shot.visualState"
:disabled="!canGenerateKeyframe"
- @generate="generateKeyframe"
+ :submit-generation="generateKeyframe"
/>
diff --git a/src/features/production/types.ts b/src/features/production/types.ts
index 904a702..f4b9ab8 100644
--- a/src/features/production/types.ts
+++ b/src/features/production/types.ts
@@ -1,3 +1,4 @@
+import type { ImageGenerationPreview } from '../subject-images/generation-preview'
import type { GenerationOptions, ResolvedGenerationConfig } from '../generation-config/types'
/** 项目生产链的就绪状态;进行中只会出现在视频阶段。 */
@@ -141,6 +142,16 @@ export interface VideoReadiness {
/** 首帧生成记录;成功图片与失败历史都保留。 */
export interface ShotKeyframe {
+ /** 持久化的实际输入状态。 */
+ inputSnapshotStatus?: 'recorded' | 'not-recorded' | 'invalid'
+ /** 当次实际输入指纹。 */
+ providerInputFingerprint?: string | null
+ /** 中断后需核查已有请求。 */
+ recoveryRequired?: boolean
+ /** 保存的恢复原因。 */
+ recoveryReason?: string | null
+ /** 仅允许下载已知生成结果。 */
+ canRecoverSavedResult?: boolean
id: string
shotId: string
source: string | null
@@ -221,15 +232,8 @@ export type ImageReferenceRole =
| 'style-prop'
| 'identity-anchor'
| 'form-primary'
-
-export interface KeyframePreviewReference {
- originalImageNumber: number
- subjectRef: string
- module: string
- role: ImageReferenceRole
- imageId: string
- imageUrl: string
-}
+ | 'scene-form-view'
+ | 'layout-master'
export interface KeyframeReferencePlanItem {
subjectId?: string
@@ -251,7 +255,8 @@ export interface KeyframeSpecConsistencyIssue {
message: string
}
-export interface KeyframeGenerationPreview {
+/** 正式镜头的最终图片输入与导演约束检查。 */
+export interface KeyframeGenerationPreview extends ImageGenerationPreview {
specConsistencyIssues?: KeyframeSpecConsistencyIssue[]
specConsistencySummary?: {
warningCount: number
@@ -263,10 +268,6 @@ export interface KeyframeGenerationPreview {
episodeNo: number
beatNo: number
shotNo: number
- provider: string
- model: string
- generationConfig: Record
- references: KeyframePreviewReference[]
referencePlan: {
provider: string
maxReferenceImages: number | null
@@ -275,7 +276,6 @@ export interface KeyframeGenerationPreview {
selected: KeyframeReferencePlanItem[]
omitted: KeyframeReferencePlanItem[]
}
- providerPrompt: string
}
/** 视频生成规格中的主体参考图。 */
@@ -326,6 +326,8 @@ export interface GenerateKeyframesInput {
/** 单镜头首帧生成参数。 */
export interface GenerateKeyframeInput {
+ /** 用户确认的最终输入版本。 */
+ expectedPreviewFingerprint?: string
setPrimary: boolean
provider?: string
generationOptions?: Record
diff --git a/src/features/production/useProduction.ts b/src/features/production/useProduction.ts
index b708101..300f9a2 100644
--- a/src/features/production/useProduction.ts
+++ b/src/features/production/useProduction.ts
@@ -73,21 +73,25 @@ export function useProduction() {
async (key, signal) => {
const [projectId, number, overwrite] = JSON.parse(key) as [string, number, boolean]
if (!projectId || !number) return null
- const [directions, prompts, keyframes, videos, videoStatus, videoInputPlanState] = await Promise.all([
- storyboardApi.directions(projectId, number, signal),
- productionApi.promptReadiness(projectId, overwrite, signal),
- productionApi.keyframeReadiness(projectId, overwrite, signal),
- productionApi.videoReadiness(projectId, overwrite, signal),
- productionApi.projectVideoStatus(projectId, signal),
- productionApi
- .videoInputPlans(projectId, number, signal)
- .then(data => ({ data, error: '' }))
- .catch(cause => ({ data: null, error: errorMessage(cause) }))
- ])
+ const [directions, visualStates, prompts, keyframes, videos, videoStatus, videoInputPlanState] =
+ await Promise.all([
+ storyboardApi.directions(projectId, number, signal),
+ storyboardApi.visualStates(projectId, number, signal).catch(() => null),
+ productionApi.promptReadiness(projectId, overwrite, signal),
+ productionApi.keyframeReadiness(projectId, overwrite, signal),
+ productionApi.videoReadiness(projectId, overwrite, signal),
+ productionApi.projectVideoStatus(projectId, signal),
+ productionApi
+ .videoInputPlans(projectId, number, signal)
+ .then(data => ({ data, error: '' }))
+ .catch(cause => ({ data: null, error: errorMessage(cause) }))
+ ])
if (directions.projectId !== projectId || directions.episodeNo !== number)
throw new Error('镜头生产查询返回了不匹配的项目或剧集,请刷新后重试。')
return {
directions,
+ visualStates:
+ visualStates?.projectId === projectId && visualStates.episodeNo === number ? visualStates : null,
prompts,
keyframes,
videos,
@@ -112,7 +116,9 @@ export function useProduction() {
() => !!getStoryboardSession(id.value).invalidatedEpisodeSources[episodeNo.value]
)
/** 当前剧集的正式镜头目录。 */
- const shots = computed(() => mergeDesignedShots(query.data.value?.directions ?? null, null, source.value))
+ const shots = computed(() =>
+ mergeDesignedShots(query.data.value?.directions ?? null, query.data.value?.visualStates ?? null, source.value)
+ )
/** 明确指定的镜头不存在时不代选其它镜头;首次进入才选择第一镜。 */
const shot = computed(() =>
selectedShot.value ? shots.value.find(item => item.shotId === selectedShot.value) : shots.value[0]
@@ -134,7 +140,7 @@ export function useProduction() {
/** 当前工作区的响应式状态或派生业务条件。 */
const session = computed(() => getProductionSession(id.value))
/** 普通首帧后台观察器,刷新页面后恢复真实执行状态。 */
- const keyframeExecution = useWorkflowExecution(id, 'keyframe-generation')
+ const keyframeExecution = useWorkflowExecution(id, 'keyframe-generation', { discover: true })
const promptExecution = useWorkflowExecution(id, 'video-prompt')
const videoExecution = useWorkflowExecution(id, 'video-quality')
/** 当前工作区的响应式状态或派生业务条件。 */
diff --git a/src/features/subject-identity/SubjectIdentityPage.vue b/src/features/subject-identity/SubjectIdentityPage.vue
index e6a4825..a7cdeeb 100644
--- a/src/features/subject-identity/SubjectIdentityPage.vue
+++ b/src/features/subject-identity/SubjectIdentityPage.vue
@@ -34,6 +34,7 @@ import { useSubjectIdentity } from './useSubjectIdentity'
import { useProjectContext } from '../projects/context'
import { useProjectStageAccess } from '../projects/useProjectStageAccess'
import StableAnchorQualityDialog from './components/StableAnchorQualityDialog.vue'
+import VisualFactRevisionDrawer from './components/VisualFactRevisionDrawer.vue'
import IdentityEditor from './components/IdentityEditor.vue'
import SubjectIdentitySkeleton from './SubjectIdentitySkeleton.vue'
import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue'
@@ -113,6 +114,21 @@ const identityBatchScopeLabel = computed(
/** 单主体稳定母版质量生成弹窗开关。 */
const qualityOpen = ref(false)
const imageOpen = ref(false)
+/** 当前主体视觉事实修订抽屉。 */
+const revisionOpen = ref(false)
+watch(selectedId, () => {
+ revisionOpen.value = false
+})
+
+/** 保存后重读身份、全部形态与制作准入。 */
+async function refreshVisualFacts() {
+ await Promise.all([
+ detail.refresh(),
+ catalog.refresh(),
+ castingQuery.refresh(),
+ projectContext.refreshStageReadiness()
+ ])
+}
/** 从失败记录重试时保留原视角,普通生成仍使用弹窗默认视角。 */
const retryImageView = ref()
const castingOpen = ref(false)
@@ -921,6 +937,25 @@ function runNextAction() {
请先保存身份修改,再使用 AI 或生成图片。
+
+ 核对与修订视觉事实
+
+
+
(() => ({
generationOptions: { ...generationOptions.value }
}))
/** 选角使用 primary 且不引用当前母版,与正式候选生成一致。 */
-const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
- useImageGenerationPreview({
- open,
- target: () => JSON.stringify([props.subjectId, props.profile]),
- input: () => generationInput.value,
- disabled: () => props.disabled || !valid.value,
- load: (input, signal) =>
- subjectIdentityApi.previewImage(
- props.subjectId,
- { ...input, viewType: 'primary', useAnchorReference: false },
- signal
- ),
- generate: input => props.submitGeneration(input)
- })
+const {
+ preview,
+ acknowledged,
+ loading,
+ submitting,
+ error,
+ staleNotice,
+ recoveryNotice,
+ canSubmit,
+ loadPreview,
+ submit
+} = useImageGenerationPreview({
+ open,
+ recoveryTarget: () => (props.subjectId ? 'identity:' + props.subjectId : ''),
+ target: () => JSON.stringify([props.subjectId, props.profile]),
+ input: () => generationInput.value,
+ disabled: () => props.disabled || !valid.value,
+ load: (input, signal) =>
+ subjectIdentityApi.previewImage(
+ props.subjectId,
+ { ...input, viewType: 'primary', useAnchorReference: false },
+ signal
+ ),
+ generate: input => props.submitGeneration(input)
+})
/** 当前描述草稿对应的表单模型。 */
const formModel = computed(() => ({ prompt: prompt.value }))
@@ -94,7 +105,7 @@ const formModel = computed(() => ({ prompt: prompt.value }))
>
AI
- 会根据角色身份、项目视觉风格和选角要求生成一张新的候选图,不会复用当前身份母版。生成完成后,请在图库点击“确认选角并锁定”,将图片设为角色母版。
+ 会根据角色身份、项目视觉风格和选角要求生成一张新的候选图,不会复用当前身份母版。生成后请在图库审核候选,通过后再确认选角并锁定身份。
({ prompt: prompt.value }))
:loading="loading"
:disabled="disabled || submitting || !valid"
:error="error"
- :stale-notice="staleNotice"
+ :stale-notice="staleNotice || recoveryNotice"
@load="loadPreview"
/>
@@ -169,6 +171,7 @@ defineExpose({ openCandidates, closeCandidates })
:identity-locked="identityLocked"
:disabled="disabled"
:pending-operation="pendingOperation"
+ :validation-result="validationResult"
:retry-disabled-reason="retryDisabledReason"
:active="candidatesOpen"
@anchor="emit('anchor', $event)"
@@ -181,6 +184,7 @@ defineExpose({ openCandidates, closeCandidates })
v-if="validationResult && managedCandidates.some(image => image.id === validationResult?.imageId)"
class="mt-5"
:result="validationResult"
+ :module="module"
/>
diff --git a/src/features/subject-identity/components/IdentityImageCard.vue b/src/features/subject-identity/components/IdentityImageCard.vue
index 721a9bc..3395bfb 100644
--- a/src/features/subject-identity/components/IdentityImageCard.vue
+++ b/src/features/subject-identity/components/IdentityImageCard.vue
@@ -5,7 +5,8 @@ import { AppDialog, AssetImage, AssetOpenLink, StatusBadge } from '../../../comp
import { formatDate } from '../../../lib/format'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import { canBeAnchor, identityViewLabels } from '../model'
-import type { IdentityImage, IdentityImageOperation } from '../types'
+import { imageValidationPassed } from '../../subject-images/validation'
+import type { IdentityImage, IdentityImageOperation, IdentityValidationResult } from '../types'
/** 母版与候选共用图片卡片,操作始终绑定卡片的正式图片编号。 */
const props = defineProps<{
@@ -27,6 +28,8 @@ const props = defineProps<{
description?: string
/** 候选管理是否可见,关闭管理弹窗时同步收起错误浮层。 */
active?: boolean
+ /** 只用于同一候选的已知审核证据。 */
+ validationResult?: IdentityValidationResult | null
}>()
/** 卡片只请求父页面执行操作,不直接调用模型或修改母版。 */
const emit = defineEmits<{
@@ -51,12 +54,19 @@ const confirmLoading = computed(
const validateLoading = computed(
() => props.pendingOperation?.imageId === props.image.id && props.pendingOperation.kind === 'validate'
)
+/** 当前图片需要具备刚刚读取的明确审核结果。 */
+const quality = computed(() =>
+ props.validationResult?.imageId === props.image.id
+ ? imageValidationPassed(props.validationResult, props.module)
+ : null
+)
/** 只有完成的 primary 可以确认,已锁定的当前母版不提供重复确认。 */
const canSelect = computed(
() =>
!props.disabled &&
!props.pendingOperation &&
canBeAnchor(props.image) &&
+ quality.value === true &&
(!props.image.isAnchor || (character.value && !props.identityLocked))
)
/** 卡片标识区分身份母版、母版候选和辅助视角,不重复强调当前状态。 */
@@ -174,6 +184,13 @@ function regenerate() {
{{ imageLabel }}
+
+ {{ quality === null ? '待审核' : quality ? '审核通过' : '审核未通过或待复核' }}
+
- 确认时会核对当前来源和质量,可能调用视觉模型并产生审核费用。通过后才锁定并采纳;未通过时保留旧母版,不自动追加生图。
+ {{
+ character
+ ? '将复核已保存的质量证据,通过后锁定并采纳。'
+ : '将复核已保存的质量证据。若审核记录失效,服务可能再次调用视觉模型并产生费用。'
+ }}
取消
{{
- character ? '确认演员选择' : '确认切换身份母版'
+ character ? '确认演员选择' : '确认费用并切换母版'
}}
diff --git a/src/features/subject-identity/components/IdentityImageDialog.vue b/src/features/subject-identity/components/IdentityImageDialog.vue
index 4aefb24..ab38395 100644
--- a/src/features/subject-identity/components/IdentityImageDialog.vue
+++ b/src/features/subject-identity/components/IdentityImageDialog.vue
@@ -110,11 +110,13 @@ const {
submitting,
error: previewError,
staleNotice,
+ recoveryNotice,
canSubmit,
loadPreview,
submit
} = useImageGenerationPreview({
open,
+ recoveryTarget: () => (props.subjectId ? 'identity:' + props.subjectId : ''),
target: () =>
JSON.stringify([props.subjectId, props.images.filter(image => image.status === 'completed'), props.profile]),
input: () => generationInput.value,
@@ -229,7 +231,7 @@ const rules = {
:loading="previewLoading"
:disabled="disabled || submitting || !valid"
:error="previewError"
- :stale-notice="staleNotice"
+ :stale-notice="staleNotice || recoveryNotice"
@load="loadPreview"
/>
+import { computed, ref, watch } from 'vue'
+import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect } from 'naive-ui'
+import { AppDrawer } from '../../../components/ui'
+import ContextNotice from '../../../components/ui/ContextNotice.vue'
+import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
+import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
+import { useQuery } from '../../../composables/useQuery'
+import { ApiError, errorMessage } from '../../../lib/http'
+import { projectsApi } from '../../projects/api'
+import { getOperation, runOperation } from '../../workflows/operations'
+import { visualFactsApi, type VisualFactFormEdit, type VisualFactRevision } from '../visual-facts'
+
+/** 仅修订当前项目中尚未生图的正式主体。 */
+const props = defineProps<{
+ /** 正式项目编号。 */
+ projectId: string
+ /** 正式主体编号。 */
+ subjectId: string
+ /** 主体名称。 */
+ subjectName: string
+ /** 项目当前禁止写入。 */
+ disabled: boolean
+}>()
+/** 全屏修订界面可见状态。 */
+const open = defineModel('open', { default: false })
+/** 保存后刷新身份、形态和制作状态。 */
+const emit = defineEmits<{ saved: [] }>()
+/** 请求只绑定当前打开的项目和主体。 */
+const key = computed(() => (open.value ? JSON.stringify([props.projectId, props.subjectId]) : ''))
+/** 同时读取正式来源正文及事实版本,来源选择器只显示双方能绑定的记录。 */
+const query = useQuery(key, async (value, signal) => {
+ if (!value) return null
+ const [projectId, subjectId] = JSON.parse(value) as [string, string]
+ const [preview, project] = await Promise.all([
+ visualFactsApi.preview(subjectId, signal),
+ projectsApi.detail(projectId, signal)
+ ])
+ if (preview.subjectId !== subjectId || project.id !== projectId) throw new Error('资料与当前主体不匹配。')
+ return { preview, project }
+})
+/** 原始主题以空选择区分,避免与真实剧集编号混用。 */
+const sourceId = ref(null)
+/** 逐字原文由操作者明确填写。 */
+const quote = ref('')
+/** 主体稳定外观和叙事描述分别保留。 */
+const appearance = ref('')
+/** 可选修改的主体叙事说明。 */
+const description = ref('')
+/** 所有现存形态的人工草稿。 */
+const forms = ref([])
+/** 人工审阅人。 */
+const operator = ref('')
+/** 可追溯的人工修订理由。 */
+const reason = ref('')
+/** 只对本轮草稿和所选原文生效的明确确认。 */
+const confirmed = ref(false)
+/** 保存期间禁止重复提交或关闭。 */
+const saving = ref(false)
+/** 首次提交后显示完整校验。 */
+const attempted = ref(false)
+/** 当前写入失败说明。 */
+const conflict = ref('')
+/** 上次发生冲突的输入供人工对照,不作为新版本自动提交。 */
+const previousDraft = ref(null)
+/** 正式来源文本和版本直接从两个只读结果匹配。 */
+const sources = computed(() => {
+ const data = query.data.value
+ if (!data) return []
+ const episodes = data.preview.sources.episodes.flatMap(source => {
+ const episode = data.project.episodes.find(item => item.id === source.id && item.episode === source.episode)
+ return episode
+ ? [
+ {
+ value: source.id,
+ label: `第 ${source.episode} 集 · ${episode.title}`,
+ text: episode.content,
+ fingerprint: source.fingerprint
+ }
+ ]
+ : []
+ })
+ return [
+ {
+ value: 'topic',
+ label: '原始主题',
+ text: data.project.topic,
+ fingerprint: data.preview.sources.topicFingerprint
+ },
+ ...episodes
+ ]
+})
+/** 当前原文展示与提交使用同一正式来源。 */
+const source = computed(() => sources.value.find(item => item.value === sourceId.value))
+watch(
+ () => query.data.value,
+ data => {
+ const facts = data?.preview.facts
+ appearance.value = facts?.appearancePrompt ?? ''
+ description.value = facts?.description ?? ''
+ forms.value =
+ facts?.forms.map(form => ({
+ formId: form.id,
+ description: form.description ?? '',
+ appearancePrompt: form.appearancePrompt ?? ''
+ })) ?? []
+ sourceId.value = null
+ operator.value = ''
+ reason.value = ''
+ attempted.value = false
+ confirmed.value = false
+ }
+)
+watch(sourceId, () => {
+ quote.value = ''
+})
+watch(
+ [appearance, description, forms, sourceId, quote, operator, reason],
+ () => {
+ confirmed.value = false
+ },
+ { deep: true, flush: 'sync' }
+)
+watch(key, () => {
+ conflict.value = ''
+ previousDraft.value = null
+})
+
+/** 提交时校验全部形态和逐字证据,服务事务再次核对真实原文。 */
+const validationError = computed(() => {
+ if (
+ !appearance.value.trim() ||
+ !forms.value.length ||
+ forms.value.length > 30 ||
+ forms.value.some(form => !form.description.trim() || !form.appearancePrompt.trim())
+ )
+ return '请填写主体外观和所有形态的说明与外观。'
+ if (!source.value || !quote.value.trim() || !source.value.text.includes(quote.value.trim()))
+ return '请选择原文来源,并粘贴其中逐字一致的引文。'
+ if (!operator.value.trim() || !reason.value.trim()) return '请填写修订人及修订原因。'
+ return ''
+})
+
+/** 提交当前版本一次,409 只重新读取资料,要求人工重新核对。 */
+async function save() {
+ if (
+ saving.value ||
+ props.disabled ||
+ query.loading.value ||
+ query.error.value ||
+ !query.data.value?.preview.canRevise
+ )
+ return
+ attempted.value = true
+ const selected = source.value
+ if (validationError.value || !selected || !confirmed.value) return
+ const { projectId, subjectId } = props
+ const target = key.value
+ const preview = query.data.value.preview
+ const evidence = { quote: quote.value.trim(), expectedFingerprint: selected.fingerprint }
+ const input: VisualFactRevision = {
+ expectedVersion: preview.version,
+ appearancePrompt: appearance.value.trim(),
+ description: description.value.trim() || undefined,
+ forms: forms.value.map(form => ({
+ formId: form.formId,
+ description: form.description.trim(),
+ appearancePrompt: form.appearancePrompt.trim()
+ })),
+ source:
+ selected.value === 'topic'
+ ? { kind: 'topic', ...evidence }
+ : { kind: 'episode', episodeId: selected.value, ...evidence },
+ operator: operator.value.trim(),
+ reason: reason.value.trim()
+ }
+ saving.value = true
+ conflict.value = ''
+ try {
+ const ok = await runOperation(
+ projectId,
+ '修订主体视觉事实',
+ async () => {
+ const result = await visualFactsApi.revise(subjectId, input)
+ if (result.subjectId !== subjectId || !result.revisionId)
+ throw new Error('保存结果待核对,请刷新资料。')
+ },
+ { type: 'success', content: '视觉事实已保存。需要时可重新准备身份和形态描述。' }
+ )
+ if (key.value !== target) return
+ if (ok) {
+ emit('saved')
+ open.value = false
+ } else {
+ const cause = getOperation(projectId).cause
+ confirmed.value = false
+ if (cause instanceof ApiError && cause.status === 409) {
+ previousDraft.value = input
+ conflict.value = `${errorMessage(cause)} 将重新读取当前资料,请复核后再提交。`
+ await query.refresh()
+ }
+ }
+ } finally {
+ saving.value = false
+ }
+}
+
+
+
+
+
+
+
{{ conflict }}
+
+
{{
+ query.error.value
+ }}
+
正在读取事实与原文…
+
+ 此主体当前无法修订。请检查是否已有身份或形态图片、身份已锁定,或项目还有任务进行中。
+
+
+
+
+
+
+
+
+ {{ query.data.value.preview.facts.forms[index]?.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ source.text }}
+
+
+
+
+
+
+ 我已核对原文和全部形态,并确认保存本次修订。
+
+ {{ validationError }}
+
+
+
+
+
+ 关闭
+ 保存修订
+ 重新读取
+
+
+
diff --git a/src/features/subject-identity/useSubjectIdentity.ts b/src/features/subject-identity/useSubjectIdentity.ts
index 8d025c0..1925d3a 100644
--- a/src/features/subject-identity/useSubjectIdentity.ts
+++ b/src/features/subject-identity/useSubjectIdentity.ts
@@ -1,3 +1,4 @@
+import { ApiError } from '../../lib/http'
import { imageValidationPassed } from '../subject-images/validation'
import type { ImageGenerationSubmission } from '../subject-images/generation-preview'
import { computed, ref, shallowRef, watch } from 'vue'
@@ -271,9 +272,18 @@ export function useSubjectIdentity() {
*/
async function validateImage(imageId: string) {
const image = images.value.find(item => item.id === imageId)
- if (detailBlocked.value || !subject.value || image?.status !== 'completed' || !image.imageUrl) return
+ if (
+ detailBlocked.value ||
+ !subject.value ||
+ image?.viewType !== 'primary' ||
+ image.status !== 'completed' ||
+ !image.imageUrl
+ )
+ return
const id = subject.value.id
const name = subject.value.name
+ const project = projectId.value
+ const module = subject.value.module
delete validationResults.value[id]
const sourceKey = validationSourceKey.value
await runImageOperation(
@@ -284,12 +294,20 @@ export function useSubjectIdentity() {
const result = await subjectIdentityApi.validateImage(id, imageId)
if (result.subjectId !== id || result.imageId !== imageId)
throw new Error('身份校验回执与提交目标不匹配')
- if (validationSourceKey.value === sourceKey) validationResults.value[id] = result
+ if (validationSourceKey.value === sourceKey) {
+ await refreshImageConfirmation(project, id)
+ if (
+ projectId.value === project &&
+ selectedId.value === id &&
+ images.value.some(item => item.id === imageId && item.imageUrl === image.imageUrl)
+ )
+ validationResults.value[id] = result
+ }
return result
},
result => ({
- type: imageValidationPassed(result) ? 'success' : 'warning',
- content: `${name} 的身份图片校验${imageValidationPassed(result) ? '通过' : '未通过或待复核'}:${result.summary}`
+ type: imageValidationPassed(result, module) ? 'success' : 'warning',
+ content: `${name} 的身份图片校验${imageValidationPassed(result, module) ? '通过' : '未通过或待复核'}:${result.summary}`
})
)
}
@@ -520,7 +538,7 @@ export function useSubjectIdentity() {
image.identityId !== identityId ||
!['pending', 'generating'].includes(image.status)
) {
- throw new Error(image?.error || '身份参考图任务未成功创建,请刷新后重试。')
+ throw new ApiError('身份参考图任务回执待核对,请刷新候选和任务。', 202)
}
if (projectId.value === project && selectedId.value === id) {
// 先展示真实回执中的生成记录,后续读取失败也能保留状态并继续轮询。
@@ -555,7 +573,7 @@ export function useSubjectIdentity() {
async () => {
const image = await subjectIdentityApi.generateCastingCandidate(id, input)
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
- throw new Error(image?.error || '选角候选任务未成功创建,请刷新后重试。')
+ throw new ApiError('角色候选任务回执待核对,请刷新候选和任务。', 202)
}
if (projectId.value === project)
await Promise.all([
@@ -612,14 +630,16 @@ export function useSubjectIdentity() {
(subject.value?.module !== 'scene' && subject.value?.module !== 'prop') ||
!identity.value ||
!image ||
- !canBeAnchor(image)
+ !canBeAnchor(image) ||
+ validationResult.value?.imageId !== imageId ||
+ !imageValidationPassed(validationResult.value, subject.value.module)
)
return
const subjectId = subject.value.id
const identityId = identity.value.id
const project = projectId.value
const name = subject.value.name
- await runImageOperation(
+ const confirmed = await runImageOperation(
'confirm',
imageId,
`确认 ${name} 身份母版`,
@@ -641,6 +661,10 @@ export function useSubjectIdentity() {
},
{ type: 'success', content: `${name} 的身份母版已确认并锁定。` }
)
+ if (!confirmed) {
+ delete validationResults.value[subjectId]
+ await refreshImageConfirmation(project, subjectId)
+ }
}
/**
@@ -656,14 +680,16 @@ export function useSubjectIdentity() {
!!castingQuery.error.value ||
!identity.value ||
!image ||
- !canBeAnchor(image)
+ !canBeAnchor(image) ||
+ validationResult.value?.imageId !== imageId ||
+ !imageValidationPassed(validationResult.value, subject.value.module)
)
return
const subjectId = subject.value.id
const identityId = identity.value.id
const project = projectId.value
const name = subject.value.name
- await runImageOperation(
+ const confirmed = await runImageOperation(
'confirm',
imageId,
`确认 ${name} 角色选角`,
@@ -685,6 +711,10 @@ export function useSubjectIdentity() {
},
{ type: 'success', content: `${name} 的角色选角已确认,身份已锁定。` }
)
+ if (!confirmed) {
+ delete validationResults.value[subjectId]
+ await refreshImageConfirmation(project, subjectId)
+ }
}
return {
diff --git a/src/features/subject-identity/visual-facts.ts b/src/features/subject-identity/visual-facts.ts
new file mode 100644
index 0000000..8754151
--- /dev/null
+++ b/src/features/subject-identity/visual-facts.ts
@@ -0,0 +1,104 @@
+import { request } from '../../lib/http'
+
+/** 修订必须完整保留每个已存在形态的绑定。 */
+export interface VisualFactFormEdit {
+ /** 正式形态编号。 */
+ formId: string
+ /** 纠正后的形态说明。 */
+ description: string
+ /** 纠正后的形态外观。 */
+ appearancePrompt: string
+}
+
+/** 只读修订预览。 */
+export interface VisualFactPreview {
+ /** 正式主体编号。 */
+ subjectId: string
+ /** 当前事实的并发版本。 */
+ version: string
+ /** 当前允许人工修订。 */
+ canRevise: boolean
+ /** 当前正式主体和全部形态。 */
+ facts: {
+ /** 主体说明。 */
+ description: string | null
+ /** 主体稳定外观。 */
+ appearancePrompt: string | null
+ /** 已存在的正式形态。 */
+ forms: Array<{
+ /** 正式形态编号。 */
+ id: string
+ /** 形态显示名称。 */
+ name: string
+ /** 当前形态说明。 */
+ description: string | null
+ /** 当前形态外观。 */
+ appearancePrompt: string | null
+ }>
+ }
+ /** 允许用于举证的正式原文版本。 */
+ sources: {
+ /** 原始主题的版本。 */
+ topicFingerprint: string
+ /** 正式剧集的原文版本。 */
+ episodes: Array<{
+ /** 正式剧集编号。 */
+ id: string
+ /** 用户可见的集数。 */
+ episode: number
+ /** 正文版本。 */
+ fingerprint: string
+ }>
+ }
+}
+
+/** 原文引证含同一来源的版本,原文变化由服务事务复核。 */
+type VisualFactSource = {
+ /** 最新预览中的原文版本。 */
+ expectedFingerprint: string
+ /** 用户核对并填写的逐字原文。 */
+ quote: string
+} & ({ /** 原始主题。 */ kind: 'topic' } | { /** 正式剧集。 */ kind: 'episode'; /** 剧集编号。 */ episodeId: string })
+
+/** 明确的人工修订请求,沿用正式接口的严格字段。 */
+export interface VisualFactRevision {
+ /** 最新事实版本。 */
+ expectedVersion: string
+ /** 主体稳定外观。 */
+ appearancePrompt: string
+ /** 可选修订主体说明。 */
+ description?: string
+ /** 全部现有形态。 */
+ forms: VisualFactFormEdit[]
+ /** 用户核对的原文证据。 */
+ source: VisualFactSource
+ /** 实际修订人员。 */
+ operator: string
+ /** 本次修订原因。 */
+ reason: string
+}
+
+/** 正式修订 API,读取免费,保存人工输入后不会触发生成。 */
+export const visualFactsApi = {
+ /**
+ * 读取当前事实及可修订性。
+ * @param subjectId 正式主体编号
+ * @param signal 关闭抽屉时取消读取
+ * @returns 当前修订预览
+ */
+ preview: (subjectId: string, signal?: AbortSignal) =>
+ request(`/subjects/${encodeURIComponent(subjectId)}/visual-facts/revision-preview`, {
+ signal
+ }),
+ /**
+ * 原子保存本次人工修订。
+ * @param subjectId 正式主体编号
+ * @param input 人工确认的事实、全部形态和来源
+ * @returns 已保存的正式修订回执
+ */
+ revise: (subjectId: string, input: VisualFactRevision) =>
+ request<{ revisionId: string; subjectId: string; version: string; formIds: string[] }>(
+ `/subjects/${encodeURIComponent(subjectId)}/visual-facts/revisions`,
+ { method: 'POST', body: input }
+ )
+}
diff --git a/src/features/subject-images/api.ts b/src/features/subject-images/api.ts
index 8574463..7399a00 100644
--- a/src/features/subject-images/api.ts
+++ b/src/features/subject-images/api.ts
@@ -1,4 +1,5 @@
import { request } from '../../lib/http'
+import type { ProviderImageInputSnapshot } from './generation-preview'
import type { ImageValidationResult } from './validation'
import type {
GenerateFormImageInput,
@@ -47,6 +48,23 @@ export const subjectImagesApi = {
listForms: (projectId: string, signal?: AbortSignal) =>
request(`/projects/${encodeURIComponent(projectId)}/subject-forms`, { signal }),
listImages: (formId: string, signal?: AbortSignal) => request(formPath(formId), { signal }),
+ /**
+ * 只读核对指定候选的来源及当时实际输入。
+ * @param formId 正式形态
+ * @param imageId 正式图片
+ * @param signal 取消过期读取
+ * @returns 当前来源与审核资格
+ */
+ validationPreview: (formId: string, imageId: string, signal?: AbortSignal) =>
+ request<{
+ /** 正式形态编号。 */ subjectFormId: string
+ /** 正式图片编号。 */ imageId: string
+ /** 当前图片是否可审核。 */ canValidate: boolean
+ /** 正式来源是否仍有效。 */ sourceCurrent: boolean
+ /** 失效说明。 */ sourceStaleReason: string | null
+ /** 持久化的实际输入版本。 */ providerInputFingerprint: string | null
+ /** 持久化的实际输入证据。 */ providerInputSnapshot: ProviderImageInputSnapshot | null
+ }>(`${formPath(formId)}/${encodeURIComponent(imageId)}/validate/preview`, { signal }),
/**
* 用户确认费用后审核指定候选,不自动切换主图。
* @param formId 正式形态编号
diff --git a/src/features/subject-images/components/FormSourceDiagnostics.vue b/src/features/subject-images/components/FormSourceDiagnostics.vue
new file mode 100644
index 0000000..096ef03
--- /dev/null
+++ b/src/features/subject-images/components/FormSourceDiagnostics.vue
@@ -0,0 +1,191 @@
+
+
+
+
+
+
+ 正在核对来源…
+
+
{{ query.error.value }}
+
重新读取来源
+
+
+
+
{{
+ statusLabels[prop.status]
+ }}
+
+ {{ userFacingText(prop.reason, '请重新核对当前形态与剧本来源。') }}
+
+
{{ prop.spec.semanticClass }}
+
+ -
+ {{ part.name }} · 原始 {{ part.quantity }} 件 · 当前 {{ part.current }} 件
+
+
{{ part.state.description }} · {{ episodeLabel(part.state.evidence.episodeId) }}
+
+ {{ part.state.evidence.quote }}
+
+
+
+
+
+ 部件归属证据
+
+
{{ item.name }} · 原文数量 {{ item.quantity }}
+
数量来源 · {{ episodeLabel(item.episodeId) }}
+
+ {{ item.sourceQuote }}
+
+
拆装来源 · {{ episodeLabel(item.relationEpisodeId) }}
+
+ {{ item.relationQuote }}
+
+
+
+
+ 最近准备记录
+
+
+ {{ prop.lastGenerationAttempt.sourceCurrent ? '对应当前来源' : '准备时的来源已过期' }} ·
+ {{ attemptLabels[prop.lastGenerationAttempt.status] ?? '结果待核对' }}
+
+
+ {{ userFacingText(prop.lastGenerationAttempt.error) }}
+
+
+
+ 无独立模型准备记录。
+
+
+
+
+
+
场景身份母版
+
+
+ {{
+ query.data.value.anchor
+ ? form.subject.identity?.isLocked
+ ? '已确认并锁定'
+ : '已选母版 · 待锁定'
+ : '尚无已确认的场景身份母版。'
+ }}
+
+
+
尚无共享空间布局记录。
+
+ 此场景关联多个布局,请在生成前核对唯一适用的空间范围。
+
+
+ {{ layout.name }}
+ 当前几何版本 {{ layout.version }}
+ 尚无当前形态的机位或全局空间参考。
+
+
+
+
+ {{ master.subjectFormId ? '当前形态机位' : '全局空间母版' }} ·
+ {{
+ master.spatialLayoutVersion !== layout.version
+ ? '几何已过期'
+ : master.status === 'confirmed'
+ ? '参考已确认'
+ : '参考未确认'
+ }}
+
+ {{ master.viewDescription }}
+
+
+
+
+
+
+
diff --git a/src/features/subject-images/components/GenerateImageDialog.vue b/src/features/subject-images/components/GenerateImageDialog.vue
index 7a99f99..1dccc30 100644
--- a/src/features/subject-images/components/GenerateImageDialog.vue
+++ b/src/features/subject-images/components/GenerateImageDialog.vue
@@ -9,7 +9,6 @@ import GenerationModelControls from '../../generation-config/components/Generati
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
import { subjectImagesApi } from '../api'
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../generation-preview'
-import { primaryImage } from '../model'
import type { GenerateFormImageInput, SubjectFormAsset } from '../types'
import ImageGenerationPreview from './ImageGenerationPreview.vue'
@@ -34,34 +33,43 @@ const prompt = ref('')
const provider = ref('')
/** 当前模型动态参数。 */
const generationOptions = ref({})
-/** 明确选择质量通过后切换主图,默认只保留候选。 */
-const setPrimary = ref(false)
/** 预览与生成共用同一份输入。 */
const generationInput = computed(() => ({
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
provider: provider.value,
generationOptions: { ...generationOptions.value },
- setPrimary: setPrimary.value
+ setPrimary: false
}))
/** 表单模型用于统一禁用与间距。 */
const formModel = computed(() => ({ prompt: prompt.value }))
/** 目标、参数与可见周期变化后废弃旧确认。 */
-const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
- useImageGenerationPreview({
- open,
- target: () =>
- JSON.stringify([props.form?.id, props.form?.generationPrompt, props.form?.subject.identity, props.profile]),
- input: () => generationInput.value,
- disabled: () => props.disabled || !props.form || !provider.value,
- load: async (input, signal) => {
- const formId = props.form!.id
- const { setPrimary: _setPrimary, ...previewInput } = input
- const result = await subjectImagesApi.preview(formId, previewInput, signal)
- if (result.subjectFormId !== formId) throw new Error('预览结果与当前形态不匹配,请重新读取。')
- return result
- },
- generate: input => props.submitGeneration(props.form!.id, input)
- })
+const {
+ preview,
+ acknowledged,
+ loading,
+ submitting,
+ error,
+ staleNotice,
+ recoveryNotice,
+ canSubmit,
+ loadPreview,
+ submit
+} = useImageGenerationPreview({
+ open,
+ recoveryTarget: () => (props.form ? 'form:' + props.form.id : ''),
+ target: () =>
+ JSON.stringify([props.form?.id, props.form?.generationPrompt, props.form?.subject.identity, props.profile]),
+ input: () => generationInput.value,
+ disabled: () => props.disabled || !props.form || !provider.value,
+ load: async (input, signal) => {
+ const formId = props.form!.id
+ const { setPrimary: _setPrimary, ...previewInput } = input
+ const result = await subjectImagesApi.preview(formId, previewInput, signal)
+ if (result.subjectFormId !== formId) throw new Error('预览结果与当前形态不匹配,请重新读取。')
+ return result
+ },
+ generate: input => props.submitGeneration(props.form!.id, input)
+})
/** 每次打开恢复项目配置,不沿用其它形态的草稿。 */
watch(
() => [open.value, props.form?.id],
@@ -70,7 +78,6 @@ watch(
const defaults = imageGenerationDefaults(props.catalog, props.profile)
provider.value = defaults.provider
generationOptions.value = defaults.options
- setPrimary.value = false
},
{ immediate: true }
)
@@ -118,24 +125,20 @@ watch(
@update:provider="provider = $event"
@update:options="generationOptions = $event"
/>
-
- 生成并通过质量审核后设为主参考图
-
- 会调用视觉审核并可能产生额外费用。{{
- form && primaryImage(form.images) ? '审核未通过时保留旧主图。' : '审核未通过时仅保留候选图。'
- }}不会自动重试或追加生图。
-
- 我已核对本次预览和主图选项,确认模型费用。我已核对本次预览,并确认图片生成可能产生费用。
diff --git a/src/features/subject-images/components/ImageGalleryDialog.vue b/src/features/subject-images/components/ImageGalleryDialog.vue
index bac37fb..2be86ea 100644
--- a/src/features/subject-images/components/ImageGalleryDialog.vue
+++ b/src/features/subject-images/components/ImageGalleryDialog.vue
@@ -1,5 +1,6 @@
@@ -74,17 +101,60 @@ const references = computed(() => {
>{{ preview.actualProviderReferenceCount ?? preview.referenceImages.length }} 张参考图
-
- - 图 {{ item.order }} · {{ item.label }}
+
+
- 本次没有图片参考。
+ 本次没有图片参考。
{{ preview.providerPrompt }}
+
+
+
diff --git a/src/features/subject-images/components/ImageValidationPanel.vue b/src/features/subject-images/components/ImageValidationPanel.vue
index 369f8d8..10bd879 100644
--- a/src/features/subject-images/components/ImageValidationPanel.vue
+++ b/src/features/subject-images/components/ImageValidationPanel.vue
@@ -3,17 +3,30 @@ import { computed } from 'vue'
import { NCollapse, NCollapseItem, NTag } from 'naive-ui'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import { userFacingText } from '../../../lib/user-facing-text'
-import { imageValidationPassed, sourceRequirementRows, type ImageValidationResult } from '../validation'
+import {
+ characterCheckRows,
+ imageValidationPassed,
+ sourceRequirementRows,
+ type ImageValidationResult
+} from '../validation'
/** 展示指定图片本次审核与原始定义对照,不推断主图或母版已采纳。 */
const props = defineProps<{
/** 明确绑定当前图片的正式审核结果。 */
result: ImageValidationResult
+ /** 当前正式主体模块。 */
+ module?: string
}>()
/** 只有证据完整才使用成功状态。 */
-const passed = computed(() => imageValidationPassed(props.result))
+const passed = computed(() => imageValidationPassed(props.result, props.module))
/** 原文与观测按标识关联,内部标识不出现在标题中。 */
const requirements = computed(() => sourceRequirementRows(props.result))
+/** 角色的四项独立审核证据。 */
+const characterChecks = computed(() =>
+ props.module === 'character' || props.result.characterCheckResults ? characterCheckRows(props.result) : []
+)
+/** 分项状态使用可读中文,保留实际证据。 */
+const checkLabels = { passed: '通过', failed: '未通过', needs_review: '待复核', not_applicable: '不适用' }
@@ -37,6 +50,17 @@ const requirements = computed(() => sourceRequirementRows(props.result))
>{{ userFacingText(issue.description) }}
+
+
+ 角色交付检查
+
+ -
+ {{ label }} · {{ item ? checkLabels[item.status] : '待复核' }}
+
{{ userFacingText(item?.evidence, '尚无完整审核证据。') }}
+
+
+
+
diff --git a/src/features/subject-images/generation-preview.ts b/src/features/subject-images/generation-preview.ts
index 1564110..ca8f026 100644
--- a/src/features/subject-images/generation-preview.ts
+++ b/src/features/subject-images/generation-preview.ts
@@ -1,7 +1,42 @@
import { computed, onBeforeUnmount, ref, shallowRef, watch, type Ref } from 'vue'
import { ApiError, errorMessage } from '../../lib/http'
-/** 三类图片入口共用的实际生成预览。 */
+/** 同一张实际参考图可承担多个来源职责。 */
+export interface ImageReferenceBinding {
+ /** 业务主体引用。 */
+ subjectRef: string
+ /** 正式参考职责。 */
+ role: string
+ /** 当前形态的机位说明。 */
+ viewDescription?: string
+ /** 绑定的空间几何版本。 */
+ spatialLayoutVersion?: string
+}
+
+/** 服务端记录的最终输入,不含图片二进制。 */
+export interface ProviderImageInputSnapshot {
+ /** 与执行一致的输入指纹。 */
+ fingerprint: string
+ /** 实际来源版本。 */
+ sourceFingerprint: string
+ /** 实际提交的参数。 */
+ generationOptions: Record
+ /** 可选实际宽度。 */
+ width?: number
+ /** 可选实际高度。 */
+ height?: number
+ /** 实际负向描述。 */
+ negativePrompt?: string
+ /** 按实际发送顺序保存的图片和职责。 */
+ references: Array<{
+ /** 一基图片顺序。 */
+ imageNumber: number
+ /** 此物理图片上的全部职责。 */
+ bindings: ImageReferenceBinding[]
+ }>
+}
+
+/** 图片入口共用的实际生成预览。 */
export interface ImageGenerationPreview {
/** 实际供应方。 */
provider: string
@@ -17,6 +52,8 @@ export interface ImageGenerationPreview {
generationConfig: Record
/** 参考图顺序和职责等诊断信息。 */
referencePlan?: Record
+ /** 已冻结的正式输入快照。 */
+ providerInputSnapshot?: ProviderImageInputSnapshot
/** 形态接口给出的有序参考图明细。 */
references?: Array<{
/** 传入模型的顺序。 */
@@ -27,6 +64,8 @@ export interface ImageGenerationPreview {
imageId: string
/** 可展示的图片地址。 */
imageUrl: string
+ /** 同一实际参考图的全部职责。 */
+ bindings?: ImageReferenceBinding[]
}>
/** 含布局母版的真实参考图数量。 */
actualProviderReferenceCount?: number
@@ -46,6 +85,8 @@ interface PreviewOptions
/** 主体、形态及已有来源的稳定标识。 */
target: () => string
+ /** 跨表单开关稳定的计费核对目标。 */
+ recoveryTarget?: () => string
/** 当前完整生成参数。 */
input: () => Input
/** 当前是否允许提交。 */
@@ -56,6 +97,39 @@ interface PreviewOptions Promise
}
+/** 同一浏览器标签页的待核对目标。记录不含提示词、图片或确认状态。 */
+const unresolvedGenerations = ref(new Set())
+const recoveryStoragePrefix = 'short-drama:image-request-unknown:'
+
+/**
+ * 恢复已提交但结果未知的保护,包括同标签页刷新。
+ * @param target 当前正式生成目标
+ * @returns 该目标是否有待核对的原请求
+ */
+function hasUnknownGeneration(target: string) {
+ if (!target) return false
+ if (unresolvedGenerations.value.has(target)) return true
+ try {
+ return sessionStorage.getItem(recoveryStoragePrefix + target) === '1'
+ } catch {
+ return false
+ }
+}
+
+/**
+ * 标记未知结果,禁止在当前标签页把未知当成失败再提交。
+ * @param target 原生成请求的正式目标
+ */
+function markUnknownGeneration(target: string) {
+ if (!target) return
+ unresolvedGenerations.value.add(target)
+ try {
+ sessionStorage.setItem(recoveryStoragePrefix + target, '1')
+ } catch {
+ // 浏览器存储不可用时,当前工作区仍保留内存保护。
+ }
+}
+
/**
* 绑定预览与提交参数,处理过期响应、关闭及 409 重新确认。
* @param options 当前表单、正式预览与生成操作
@@ -82,6 +156,14 @@ export function useImageGenerationPreview options.recoveryTarget?.() || options.target())
+ /** 已提交但回执未知时,保留候选核对提示。 */
+ const recoveryNotice = computed(() =>
+ hasUnknownGeneration(recoveryKey.value)
+ ? '本次请求的结果和费用待核对。请先刷新候选与任务记录,并核对原请求。'
+ : ''
+ )
/** 当前界面的预览必须完整且费用已确认。 */
const canSubmit = computed(
() =>
@@ -89,6 +171,7 @@ export function useImageGenerationPreview= 500 ||
+ (result.cause.status >= 200 && result.cause.status < 300))
+ ) {
+ markUnknownGeneration(recoveryTarget)
+ }
if (current !== revision) return
if (result.accepted) {
options.open.value = false
@@ -163,14 +262,27 @@ export function useImageGenerationPreview
+ /** 由正式原文解析的当前状态。 */
+ formState?: {
+ /** 部件的当前变化和正式来源。 */
+ changes: Array<{
+ /** 基础部件编号。 */ partId: string
+ /** 当前状态说明。 */ description: string
+ /** 当前数量,包含明确缺失时的零。 */ visibleQuantity?: number
+ /** 正式剧集和逐字证据。 */ evidence: {
+ /** 剧集编号。 */ episodeId: string
+ /** 引文。 */ quote: string
+ }
+ }>
+ }
+ } | null
+ /** 当前状态投影,明确缺失的部件可不出现在列表。 */
+ currentSpec?: NonNullable
+ /** 正式剧集来源。 */
+ sourceEpisodes?: Array<{
+ /** 剧集编号。 */ episodeId: string
+ /** 集数。 */ episode: number
+ /** 标题。 */ title: string
+ }>
+ /** 数量与拆装可能由不同剧集证明。 */
+ ownershipEvidence?: Array<{
+ /** 部件名称。 */ name: string
+ /** 原文明确的数量。 */ quantity: number
+ /** 数量证据的剧集编号。 */ episodeId: string
+ /** 数量证据原句。 */ sourceQuote: string
+ /** 拆装证据的剧集编号。 */ relationEpisodeId: string
+ /** 拆装证据原句。 */ relationQuote: string
+ }>
+ /** 实际尝试的结果,仅供诊断。 */
+ lastGenerationAttempt?: {
+ /** 是否仍对应当前来源。 */ sourceCurrent: boolean
+ /** 任务状态。 */ status: string
+ /** 原始失败原因。 */ error: string | null
+ /** 完整解析候选与纠正过程。 */ evidence: unknown
+ /** 当时输入与来源,仅供复核。 */ inputSnapshot: unknown
+ } | null
+}
+
+/** 共享空间布局与其几何版本。 */
+interface SceneLayout {
+ /** 布局编号。 */ id: string
+ /** 布局名称。 */ name: string
+ /** 当前几何版本。 */ version: string
+ /** 同一布局涵盖的场景主体。 */ sceneSubjectIds: string[]
+}
+
+/** 布局内独立的全局参考或形态专属机位。 */
+interface SceneMaster {
+ /** 参考资产编号。 */ id: string
+ /** 形态编号,空值表示全局。 */ subjectFormId: string | null
+ /** 当前目标机位。 */ viewDescription: string | null
+ /** 参考图片地址。 */ imageUrl: string
+ /** 服务保存的确认状态。 */ status: string
+ /** 当时采用的几何版本。 */ spatialLayoutVersion: string
+}
+
+/** 现有图库按需读取上游诊断,全程只读。 */
+export const sourceDiagnosticsApi = {
+ /**
+ * 读取道具规格、来源和最近准备记录。
+ * @param formId 正式形态编号
+ * @param signal 关闭诊断时取消
+ * @returns 当前结构与历史证据
+ */
+ prop: (formId: string, signal?: AbortSignal) =>
+ request(`/subject-forms/${encodeURIComponent(formId)}/prop-structure-spec/readiness`, {
+ signal
+ }),
+ /**
+ * 读取当前场景几何及全局和当前形态的机位参考。
+ * @param projectId 正式项目编号
+ * @param subjectId 正式场景主体编号
+ * @param formId 正式形态编号
+ * @param signal 关闭诊断时取消
+ * @returns 按布局分组的实际参考及其记录状态
+ */
+ async scene(projectId: string, subjectId: string, formId: string, signal?: AbortSignal) {
+ const path = `/projects/${encodeURIComponent(projectId)}/shared-spatial-layouts`
+ const layouts = (await request(path, { signal })).filter(layout =>
+ layout.sceneSubjectIds.includes(subjectId)
+ )
+ return Promise.all(
+ layouts.map(async layout => ({
+ ...layout,
+ masters: (
+ await request(`${path}/${encodeURIComponent(layout.id)}/masters`, { signal })
+ ).filter(master => master.subjectFormId === null || master.subjectFormId === formId)
+ }))
+ )
+ }
+}
diff --git a/src/features/subject-images/types.ts b/src/features/subject-images/types.ts
index a38f76f..2eb87a1 100644
--- a/src/features/subject-images/types.ts
+++ b/src/features/subject-images/types.ts
@@ -6,6 +6,10 @@ export type SubjectImageStatus = 'pending' | 'generating' | 'completed' | 'faile
/** 图库列表返回的图片元数据;正式图片 ID 与形态 ID 均来自数据库。 */
export interface SubjectImage {
+ /** 生成时的输入记录状态,包含失败候选。 */
+ inputSnapshotStatus?: 'recorded' | 'not-recorded' | 'invalid'
+ /** 实际生成输入指纹。 */
+ providerInputFingerprint?: string | null
/** 最近一次结构化质量结论;缺失或 null 不代表通过。 */
qualityPassed?: boolean | null
/** 最近一次质量问题;最新可用性仍以制作准备检查为准。 */
diff --git a/src/features/subject-images/useSubjectImages.ts b/src/features/subject-images/useSubjectImages.ts
index 11c0612..2b1aa57 100644
--- a/src/features/subject-images/useSubjectImages.ts
+++ b/src/features/subject-images/useSubjectImages.ts
@@ -158,7 +158,7 @@ export function useSubjectImages() {
const ok = await runOperation(projectId, `提交 ${form.subject.name} · ${form.name} 图片生成`, async () => {
const image = await subjectImagesApi.generate(formId, input)
if (!image || image.subjectFormId !== formId || !['pending', 'generating'].includes(image.status))
- throw new Error(image?.error || '图片生成任务未成功创建,请刷新后重试。')
+ throw new ApiError('图片任务回执待核对,请刷新候选和任务。', 202)
})
const cause = getOperation(projectId).cause
if (ok && id.value === projectId) {
diff --git a/src/features/subject-images/validation.ts b/src/features/subject-images/validation.ts
index 14f60ea..e61da36 100644
--- a/src/features/subject-images/validation.ts
+++ b/src/features/subject-images/validation.ts
@@ -46,6 +46,24 @@ export interface SourceVisualRequirementResult {
}>
}
+/** 角色交付检查名称与展示文案。 */
+export const characterCheckLabels = {
+ presentation: '画面交付要求',
+ skinWithinImage: '单图肤色与肤质',
+ skinAcrossReferences: '跨图肤色一致性',
+ identityAcrossReferences: '跨图身份一致性'
+} as const
+
+/** 单项角色质量证据。 */
+export interface CharacterCheckResult {
+ /** 正式审核项。 */
+ check: keyof typeof characterCheckLabels
+ /** 实际检查状态。 */
+ status: 'passed' | 'failed' | 'needs_review' | 'not_applicable'
+ /** 像素观察或不适用原因。 */
+ evidence: string
+}
+
/** 身份与形态图片共用的正式视觉审核结果。 */
export interface ImageValidationResult {
/** 正式主体编号。 */
@@ -68,6 +86,8 @@ export interface ImageValidationResult {
physicalStructureValid?: boolean
/** 空间布局是否有效。 */
spatialLayoutValid?: boolean
+ /** 角色交付审核分项。 */
+ characterCheckResults?: CharacterCheckResult[]
/** 本次质量问题。 */
issues: ImageQualityIssue[]
/** 业务摘要。 */
@@ -122,14 +142,33 @@ export function sourceRequirementRows(result: ImageValidationResult) {
})
}
+/**
+ * 将四项角色证据按固定顺序展示,缺失与重复均标为待复核。
+ * @param result 当前图片审核结果
+ * @returns 每项名称和唯一证据
+ */
+export function characterCheckRows(result: ImageValidationResult) {
+ return Object.entries(characterCheckLabels).map(([check, label]) => {
+ const matches = result.characterCheckResults?.filter(item => item.check === check) ?? []
+ const item = matches.length === 1 && matches[0]?.evidence?.trim() ? matches[0] : undefined
+ return { check, label, item }
+ })
+}
+
/**
* 展示成功必须同时具备服务端通过结论和完整原始定义证据。
* @param result 当前图片审核结果
+ * @param module 当前主体模块
* @returns 是否可以展示本次审核通过
*/
-export function imageValidationPassed(result: ImageValidationResult): boolean {
+export function imageValidationPassed(result: ImageValidationResult, module?: string): boolean {
return (
result.passed === true &&
+ (!(module === 'character' || result.characterCheckResults) ||
+ characterCheckRows(result).every(
+ ({ check, item }) =>
+ item?.status === 'passed' || (check !== 'presentation' && item?.status === 'not_applicable')
+ )) &&
result.sourceRequirementsPassed === true &&
Array.isArray(result.sourceVisualRequirements) &&
!result.issues.some(issue => issue.severity === 'error') &&
diff --git a/src/features/workflows/WorkflowExecutionPanel.vue b/src/features/workflows/WorkflowExecutionPanel.vue
index bb87fa1..214c10d 100644
--- a/src/features/workflows/WorkflowExecutionPanel.vue
+++ b/src/features/workflows/WorkflowExecutionPanel.vue
@@ -201,6 +201,13 @@ const settledItems = computed(() => {
})
/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
+/** 首帧工作流中断时按持久化恢复说明处理,不推断可重试。 */
+const keyframeRecovery = computed(
+ () =>
+ (keyframeQuality.value || props.execution?.workflowName === 'keyframe-generation') &&
+ result.value.recoveryRequired === true &&
+ result.value.retryAutomatically === false
+)
/** 首帧编辑复用质量工作流,最终回执不属于批量质量统计。 */
const keyframeEdit = computed(() => props.execution?.metadata?.action === 'edit-keyframe')
/** 只接受后端完整的质量计数,畸形或缺失结果不显示全成功。 */
@@ -537,6 +544,10 @@ function isInputMode(value: unknown, inputMode: string): boolean {
{{ diagnosisCount('failed') ?? '待确认' }} 镜。
+
+
+ 首帧任务中断,费用与结果待核对。请先查看已保存候选并核对原请求,再决定后续操作。
+
diff --git a/src/lib/user-facing-text.ts b/src/lib/user-facing-text.ts
index 3d80427..9961d82 100644
--- a/src/lib/user-facing-text.ts
+++ b/src/lib/user-facing-text.ts
@@ -93,6 +93,20 @@ export function userFacingText(value: string | null | undefined, fallback = '暂
const codeLabels: Record = {
...configurationErrorLabels,
PROP_STRUCTURE_SPEC_NOT_READY: '道具结构规格尚未就绪,请在形态图片的“图片准备检查”中准备资料后重新预览。',
+ SUBJECT_VISUAL_FACTS_STALE: '主体、形态或原文版本已变化,请重新核对。',
+ SUBJECT_VISUAL_FACTS_LOCKED: '主体已有图片、身份已锁定或项目任务正在进行,当前无法修订。',
+ SUBJECT_VISUAL_FACTS_SOURCE_INVALID: '逐字引文与当前正式原文不匹配。',
+ SUBJECT_VISUAL_FACTS_FORM_BINDING: '形态列表已变化,请核对全部正式形态。',
+ IMAGE_REQUIRED_REFERENCE_MISSING: '缺少必要参考图,请先准备并确认正式资产。',
+ IMAGE_REFERENCE_CAPACITY_EXCEEDED: '必要参考图超出当前模型容量。',
+ IMAGE_INPUT_STALE: '图片使用的正式来源已变化。',
+ IMAGE_INPUT_SNAPSHOT_INVALID: '图片的实际生成输入记录已失效。',
+ SCENE_FORM_VIEW_REFERENCE_INVALID: '当前形态的机位参考不匹配。',
+ SCENE_FORM_VIEW_REFERENCE_UNCONFIRMED: '当前形态机位尚未确认。',
+ SCENE_FORM_VIEW_REFERENCE_STALE: '机位参考采用的几何版本已过期。',
+ DURATION_BUDGET_SOURCE_STALE: '正式剧集预算已变化,请重新核对。',
+ DURATION_BUDGET_SOURCE: '缺少可核对的正式预算快照。',
+ DURATION_BUDGET: '动作需求与当前时长预算冲突。',
IMAGE_PREVIEW_STALE: '生成依据或配置已变化,请重新预览并确认后再生成。',
INVALID_IMAGE_PREVIEW_FINGERPRINT: '预览版本无效,请重新读取生成预览。',
QUALITY_POLICY_RECONFIRM_REQUIRED: '质量规则或正式分镜来源需要重新核对并确认。',
@@ -108,6 +122,7 @@ export function userFacingText(value: string | null | undefined, fallback = '暂
)
if (code === 'PROP_STRUCTURE_SPEC_NOT_READY' || code === 'INVALID_IMAGE_PREVIEW_FINGERPRINT')
return codeLabels[code]!
+ if (code === 'DURATION_BUDGET' && /^[::]\s*\{/.test(text.slice(code.length))) return codeLabels[code]!
if (code)
text =
text
diff --git a/tests/features/breakdown/duration-diagnostics.test.ts b/tests/features/breakdown/duration-diagnostics.test.ts
new file mode 100644
index 0000000..58d4d7c
--- /dev/null
+++ b/tests/features/breakdown/duration-diagnostics.test.ts
@@ -0,0 +1,69 @@
+import { flushPromises, mount } from '@vue/test-utils'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import BreakdownDurationDiagnostics from '@/features/breakdown/components/BreakdownDurationDiagnostics.vue'
+
+afterEach(() => vi.unstubAllGlobals())
+
+describe('时长冲突诊断', () => {
+ it('分开显示正式目标与失败候选预算,诊断只发出 GET', async () => {
+ const plan = {
+ episodeNo: 2,
+ targetDurationSeconds: 45,
+ beats: [{ beatNo: 3, title: '拆卸', estimatedDurationSeconds: 9 }]
+ }
+ const fetcher = vi.fn(
+ async url =>
+ new Response(
+ JSON.stringify({
+ data: String(url).endsWith('/duration-budget')
+ ? {
+ projectId: 'duration-project',
+ episodes: [
+ { episodeNo: 2, targetDurationSeconds: 60, shotCount: 0, shotSeconds: null }
+ ]
+ }
+ : {
+ projectId: 'duration-project',
+ storyboardPlans: [plan],
+ storyboardEpisodeDurationBudgets: [
+ {
+ episodeNo: 2,
+ minimumRequiredSeconds: 10,
+ deficitSeconds: 1,
+ beatSuggestions: [
+ { beatNo: 3, budgetSeconds: 9, requiredSeconds: 10, deficitSeconds: 1 }
+ ]
+ }
+ ],
+ failureDetails: {
+ details: [
+ {
+ kind: 'storyboard-duration-failure',
+ episodeNo: 2,
+ candidate: { episodeNo: 2, episodePlan: plan, beatShots: [] },
+ retryAutomatically: false
+ }
+ ]
+ }
+ }
+ })
+ )
+ )
+ vi.stubGlobal('fetch', fetcher)
+ const wrapper = mount(BreakdownDurationDiagnostics, { props: { projectId: 'duration-project' } })
+ try {
+ await flushPromises()
+ expect(wrapper.text()).toContain('正式目标 60 秒')
+ expect(wrapper.text()).toContain('正式镜头 未生成')
+ expect(wrapper.text()).toContain('完整失败候选')
+ await wrapper.get('.n-collapse-item__header-main').trigger('click')
+ await flushPromises()
+ expect(wrapper.text()).toMatch(/拆解时目标\s+45 秒/)
+ expect(wrapper.text()).toContain('正式目标已变化')
+ expect(wrapper.text()).toMatch(/最低需求 10 秒 · 缺口 1 秒/)
+ expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
+ } finally {
+ wrapper.unmount()
+ }
+ })
+})
diff --git a/tests/features/production/production.test.ts b/tests/features/production/production.test.ts
index 1b18e30..8228456 100644
--- a/tests/features/production/production.test.ts
+++ b/tests/features/production/production.test.ts
@@ -197,44 +197,64 @@ describe('镜头生产数据契约', () => {
expect(fetcher.mock.calls[1]?.[1]?.method).toBe('GET')
})
- it('所有首帧生成都先成为候选,并要求费用确认', async () => {
- /** 弹窗打开时只读取模型目录和项目配置,测试不依赖真实后端。 */
+ it('首帧只提交用户核对过的版本,替换也先保存候选', async () => {
+ const fingerprint = 'a'.repeat(64)
+ const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
const fetcher = vi.fn().mockImplementation(async url => {
const path = String(url)
if (path === '/api/generation-models') return new Response(JSON.stringify({ data: imageCatalog }))
if (path === '/api/projects/project-1/creative-profile')
return new Response(JSON.stringify({ data: generationProfile('project-1') }))
- throw new Error(`首帧弹窗出现未预期请求:${path}`)
+ const shotId = path.match(/storyboard-shots\/([^/]+)/)?.[1]
+ return new Response(
+ JSON.stringify({
+ data: {
+ shotId,
+ previewFingerprint: fingerprint,
+ provider: 'qwen-image',
+ model: 'qwen-image-3.0-pro',
+ providerPrompt: '完整首帧画面描述',
+ generationConfig: {},
+ referenceImages: []
+ }
+ })
+ )
})
vi.stubGlobal('fetch', fetcher)
wrapper = mount(KeyframeDialog, {
attachTo: document.body,
- props: { open: true, shotId: 'shot-1', shotTitle: '开场', projectId: 'project-1', disabled: false }
+ props: {
+ open: true,
+ shotId: 'shot-1',
+ shotTitle: '开场',
+ projectId: 'project-1',
+ disabled: false,
+ submitGeneration
+ }
})
await flushPromises()
expect(button('确认生成首帧').disabled).toBe(true)
- document.querySelector('#confirm-keyframe-cost')!.click()
- await flushPromises()
- button('确认生成首帧').click()
- await flushPromises()
- expect(wrapper.emitted('generate')).toEqual([
- [{ provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }]
- ])
-
- await wrapper.setProps({ open: false })
- await flushPromises()
- await wrapper.setProps({ open: true, shotId: 'shot-2', replacePrimary: true })
- await flushPromises()
- expect(document.body.textContent).toContain('生成替代候选')
- document.querySelector('#confirm-keyframe-cost')!.click()
- await flushPromises()
- button('确认生成首帧').click()
- await flushPromises()
- expect(wrapper.emitted('generate')?.at(-1)).toEqual([
- { provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }
- ])
- expect(fetcher).toHaveBeenCalledTimes(4)
- expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
+ for (const shotId of ['shot-1', 'shot-2']) {
+ if (shotId === 'shot-2') {
+ await wrapper.setProps({ open: false })
+ await wrapper.setProps({ open: true, shotId, replacePrimary: true })
+ await flushPromises()
+ }
+ button('预览实际生成输入').click()
+ await flushPromises()
+ expect(button('确认生成首帧').disabled).toBe(true)
+ document.querySelector('#confirm-keyframe-cost')!.click()
+ await flushPromises()
+ button('确认生成首帧').click()
+ await flushPromises()
+ }
+ expect(submitGeneration).toHaveBeenCalledTimes(2)
+ expect(submitGeneration).toHaveBeenLastCalledWith({
+ provider: 'qwen-image',
+ generationOptions: { size: '2048*2048' },
+ setPrimary: false,
+ expectedPreviewFingerprint: fingerprint
+ })
})
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
@@ -277,6 +297,8 @@ describe('镜头生产数据契约', () => {
model: 'image-model',
generationConfig: {},
references: [],
+ previewFingerprint: 'a'.repeat(64),
+ referenceImages: ['/storage/preview.png'],
referencePlan: {
provider: 'seedream',
maxReferenceImages: 4,
@@ -307,7 +329,14 @@ describe('镜头生产数据契约', () => {
vi.stubGlobal('fetch', fetcher)
wrapper = mount(KeyframeDialog, {
attachTo: document.body,
- props: { open: true, shotId: 'shot-1', shotTitle: '开场', projectId: 'project-1', disabled: false }
+ props: {
+ open: true,
+ shotId: 'shot-1',
+ shotTitle: '开场',
+ projectId: 'project-1',
+ disabled: false,
+ submitGeneration: vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
+ }
})
await flushPromises()
button('预览实际生成输入').click()
@@ -318,8 +347,8 @@ describe('镜头生产数据契约', () => {
provider: 'seedream',
generationOptions: {}
})
- expect(document.body.textContent).toContain('已选 1 / 2 张')
- expect(document.body.textContent).toContain('省略 1 张')
+ expect(document.body.textContent).toContain('1 张参考图')
+ expect(document.body.textContent).toContain('未进入模型的参考图')
expect(document.body.textContent).toContain('最终首帧 Prompt')
expect(wrapper.emitted('generate')).toBeUndefined()
})
diff --git a/tests/features/subject-identity/identity.test.ts b/tests/features/subject-identity/identity.test.ts
index fe7bbc3..e794b50 100644
--- a/tests/features/subject-identity/identity.test.ts
+++ b/tests/features/subject-identity/identity.test.ts
@@ -1,4 +1,4 @@
-import { imagePreviewFixture } from '../../fixtures/image-preview'
+import { approvedCharacter, imagePreviewFixture } from '../../fixtures/image-preview'
import { imageCatalog, generationProfile } from '../../fixtures/generation'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -259,6 +259,31 @@ describe('身份图与母版契约', () => {
expect(wrapper.emitted('regenerate')).toEqual([['failed-front']])
})
+ it('角色交付分项失败时不能以总结果通过开启选角', async () => {
+ const candidate = identityImageFixture({ id: 'candidate', isAnchor: false })
+ const failed = approvedCharacter(candidate.id)
+ failed.characterCheckResults![0] = {
+ check: 'presentation',
+ status: 'failed',
+ evidence: '胸口出现未经授权的文字。'
+ }
+ wrapper = mount(IdentityGallery, {
+ attachTo: document.body,
+ props: {
+ subjectName: '林夏',
+ module: 'character',
+ identityLocked: false,
+ disabled: false,
+ images: [candidate],
+ validationResult: failed
+ }
+ })
+ await flushPromises()
+ expect(button('确认选角并锁定').disabled).toBe(true)
+ expect(wrapper.text()).toContain('胸口出现未经授权的文字。')
+ expect(wrapper.text()).toContain('跨图身份一致性 · 不适用')
+ expect(wrapper.emitted('anchor')).toBeUndefined()
+ })
it('明确确认目标后才提交指定候选,刷新同一母版保持管理弹窗,新母版返回后关闭弹窗', async () => {
const anchor = identityImageFixture({ id: 'anchor' })
const candidate = identityImageFixture({ id: 'candidate', isAnchor: false })
@@ -269,7 +294,8 @@ describe('身份图与母版契约', () => {
module: 'character',
identityLocked: true,
disabled: false,
- images: [anchor, candidate]
+ images: [anchor, candidate],
+ validationResult: approvedCharacter(candidate.id)
}
})
button('管理候选(1)').click()
@@ -464,7 +490,8 @@ describe('身份图与母版契约', () => {
module: 'character',
identityLocked: false,
disabled: false,
- images: [identityImageFixture({ isAnchor: true })]
+ images: [identityImageFixture({ isAnchor: true })],
+ validationResult: approvedCharacter('identity-image-1')
}
})
button('确认选角并锁定').click()
diff --git a/tests/features/subject-images/generation-preview.test.ts b/tests/features/subject-images/generation-preview.test.ts
index 403e0f4..91cc700 100644
--- a/tests/features/subject-images/generation-preview.test.ts
+++ b/tests/features/subject-images/generation-preview.test.ts
@@ -20,7 +20,8 @@ function setup(
generate = vi.fn<() => Promise>(
async (): Promise => ({ accepted: true })
),
- load = vi.fn<() => Promise>>(async () => imagePreviewFixture())
+ load = vi.fn<() => Promise>>(async () => imagePreviewFixture()),
+ target = 'form-1'
) {
const open = ref(true),
prompt = ref('初始描述')
@@ -30,7 +31,7 @@ function setup(
setup() {
flow = useImageGenerationPreview({
open,
- target: () => 'form-1',
+ target: () => target,
input: () => ({ prompt: prompt.value }),
disabled: () => false,
load,
@@ -65,7 +66,7 @@ describe('生图预览与版本确认', () => {
it('明确的预览过期 409 只重新预览,不自动重复收费请求', async () => {
const generate = vi.fn<() => Promise>(async () => ({
accepted: false,
- cause: new ApiError('过期', 409, undefined, 'IMAGE_PREVIEW_STALE')
+ cause: new ApiError('IMAGE_PREVIEW_STALE: 来源已变化', 409, { code: 'IMAGE_PREVIEW_STALE' })
}))
const { flow, open, load } = setup(generate)
await flow.loadPreview()
@@ -93,6 +94,47 @@ describe('生图预览与版本确认', () => {
expect(flow.error.value).toContain('活动任务')
expect(flow.acknowledged.value).toBe(false)
})
+ it.each(['IMAGE_REQUIRED_REFERENCE_MISSING', 'IMAGE_REFERENCE_CAPACITY_EXCEEDED'])(
+ '参考图阻断 %s 时禁止生成',
+ async code => {
+ const { flow, generate } = setup(
+ undefined,
+ vi.fn(async () => {
+ throw new ApiError(code, 409, { code })
+ })
+ )
+ await flow.loadPreview()
+ flow.acknowledged.value = true
+ await flow.submit()
+ expect(flow.canSubmit.value).toBe(false)
+ expect(generate).not.toHaveBeenCalled()
+ }
+ )
+ it('计费未知后即使重读免费预览也不重复发起同一目标', async () => {
+ const generate = vi.fn<() => Promise>(async () => ({
+ accepted: false,
+ cause: new ApiError('连接中断', 0)
+ }))
+ const { flow, open, prompt } = setup(generate, undefined, 'form-unknown')
+ await flow.loadPreview()
+ flow.acknowledged.value = true
+ await flow.submit()
+ open.value = false
+ open.value = true
+ prompt.value = '新参数'
+ await flow.loadPreview()
+ flow.acknowledged.value = true
+ await flow.submit()
+ expect(flow.canSubmit.value).toBe(false)
+ expect(generate).toHaveBeenCalledOnce()
+ wrapper?.unmount()
+ const restored = setup(generate, undefined, 'form-unknown').flow
+ await restored.loadPreview()
+ restored.acknowledged.value = true
+ await restored.submit()
+ expect(restored.recoveryNotice.value).toContain('费用待核对')
+ expect(generate).toHaveBeenCalledOnce()
+ })
it('关闭再打开相同参数后,旧预览响应不得回填', async () => {
let resolve!: (value: ReturnType) => void
const { flow, open } = setup(
diff --git a/tests/features/subject-images/images.test.ts b/tests/features/subject-images/images.test.ts
index 2da9934..87ecc15 100644
--- a/tests/features/subject-images/images.test.ts
+++ b/tests/features/subject-images/images.test.ts
@@ -1,3 +1,4 @@
+import { validationPreviewResponse } from '../../fixtures/image-preview'
import { imagePreviewFixture } from '../../fixtures/image-preview'
import { imageCatalog, generationProfile } from '../../fixtures/generation'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
@@ -48,7 +49,13 @@ describe('形态图片选择与操作', () => {
imageFixture({ id: 'candidate', isPrimary: false, imageUrl: '/storage/candidate.png' }),
imageFixture({ id: 'failed', isPrimary: false, status: 'failed', imageUrl: null, error: '生成失败详情' })
]
- const fetcher = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: rows })))
+ const fetcher = vi
+ .fn()
+ .mockImplementation(async url =>
+ String(url).endsWith('/validate/preview')
+ ? validationPreviewResponse(String(url))
+ : new Response(JSON.stringify({ data: rows }))
+ )
vi.stubGlobal('fetch', fetcher)
wrapper = mount(ImageGalleryDialog, {
attachTo: document.body,
@@ -74,8 +81,8 @@ describe('形态图片选择与操作', () => {
await flushPromises()
expect(document.querySelector('.asset-image-preview')?.textContent).toContain('本次生成失败')
expect(button('设为主参考图').disabled).toBe(true)
- expect(fetcher).toHaveBeenCalledOnce()
- expect(fetcher.mock.calls[0]![1]?.method).toBe('GET')
+ expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/images'))).toHaveLength(1)
+ expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
expect(wrapper.emitted('changed')).toBeUndefined()
})
@@ -253,7 +260,8 @@ describe('形态图片选择与操作', () => {
it('图库不自动生图,主图切换经确认后 PUT,失败图片不能设主图', async () => {
vi.useFakeTimers()
let primary = false
- const fetcher = vi.fn().mockImplementation(async (_url, init) => {
+ const fetcher = vi.fn().mockImplementation(async (url, init) => {
+ if (String(url).endsWith('/validate/preview')) return validationPreviewResponse(String(url))
if (init?.method === 'PUT') {
primary = true
return new Response(JSON.stringify({ data: imageFixture() }))
@@ -261,7 +269,7 @@ describe('形态图片选择与操作', () => {
return new Response(
JSON.stringify({
data: [
- imageFixture({ isPrimary: primary }),
+ imageFixture({ isPrimary: primary, qualityPassed: true }),
imageFixture({
id: 'failed',
isPrimary: false,
@@ -279,15 +287,15 @@ describe('形态图片选择与操作', () => {
props: { projectId: 'gallery-test', form: formFixture('gallery-test'), open: true, disabled: false }
})
await flushPromises()
- expect(fetcher.mock.calls).toHaveLength(1)
+ expect(fetcher.mock.calls).toHaveLength(2)
await vi.advanceTimersByTimeAsync(30_000)
- expect(fetcher.mock.calls).toHaveLength(1)
+ expect(fetcher.mock.calls).toHaveLength(2)
await expandSections()
expect(document.body.textContent).not.toContain('本次实际提示词')
expect(document.querySelector('[role="dialog"] script')).toBeNull()
button('设为主参考图').click()
await flushPromises()
- expect(fetcher.mock.calls).toHaveLength(1)
+ expect(fetcher.mock.calls).toHaveLength(2)
button('确认费用并设为主图').click()
await flushPromises()
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
diff --git a/tests/features/subject-images/quality-flow.test.ts b/tests/features/subject-images/quality-flow.test.ts
index ffc677b..7a84863 100644
--- a/tests/features/subject-images/quality-flow.test.ts
+++ b/tests/features/subject-images/quality-flow.test.ts
@@ -1,3 +1,4 @@
+import { validationPreviewResponse } from '../../fixtures/image-preview'
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
import ImageGalleryDialog from '@/features/subject-images/components/ImageGalleryDialog.vue'
@@ -34,25 +35,26 @@ describe('候选质量与主图门禁', () => {
qualityPassed: false,
qualityIssues: [{ type: 'form_mismatch', severity: 'error', description: '原始数量不一致' }]
})
- const fetcher = vi.fn().mockImplementation(
- async (_url, init) =>
- new Response(
- JSON.stringify({
- data:
- init?.method === 'POST'
- ? {
- subjectId: 'subject-db-1',
- subjectFormId: 'form-db-1',
- imageId: 'candidate',
- passed: false,
- sourceRequirementsPassed: false,
- sourceVisualRequirements: [],
- summary: '需核对数量',
- issues: []
- }
- : [candidate, original]
- })
- )
+ const fetcher = vi.fn().mockImplementation(async (url, init) =>
+ String(url).endsWith('/validate/preview')
+ ? validationPreviewResponse(String(url))
+ : new Response(
+ JSON.stringify({
+ data:
+ init?.method === 'POST'
+ ? {
+ subjectId: 'subject-db-1',
+ subjectFormId: 'form-db-1',
+ imageId: 'candidate',
+ passed: false,
+ sourceRequirementsPassed: false,
+ sourceVisualRequirements: [],
+ summary: '需核对数量',
+ issues: []
+ }
+ : [candidate, original]
+ })
+ )
)
vi.stubGlobal('fetch', fetcher)
wrapper = mount(ImageGalleryDialog, {
@@ -67,7 +69,7 @@ describe('候选质量与主图门禁', () => {
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
button('审核此图片').click()
await flushPromises()
- expect(fetcher).toHaveBeenCalledOnce()
+ expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
button('确认费用并审核').click()
await flushPromises()
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
@@ -75,16 +77,38 @@ describe('候选质量与主图门禁', () => {
expect(original.isPrimary).toBe(true)
expect(document.body.textContent).toContain('需核对数量')
})
+ it('来源过期禁止发起审核与主图确认,保留该候选', async () => {
+ const image = imageFixture({ isPrimary: false, qualityPassed: true })
+ const fetcher = vi
+ .fn()
+ .mockImplementation(async url =>
+ String(url).endsWith('/validate/preview')
+ ? validationPreviewResponse(String(url), false)
+ : new Response(JSON.stringify({ data: [image] }))
+ )
+ vi.stubGlobal('fetch', fetcher)
+ wrapper = mount(ImageGalleryDialog, {
+ attachTo: document.body,
+ props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
+ })
+ await flushPromises()
+ expect(document.body.textContent).toContain('本次机位采用的几何已过期')
+ expect(button('审核此图片').disabled).toBe(true)
+ expect(button('设为主参考图').disabled).toBe(true)
+ expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
+ })
it('主图晋升 409 保留原主图,不乐观切换或自动重试', async () => {
const original = imageFixture({ id: 'old' })
- const fetcher = vi.fn().mockImplementation(async (_url, init) =>
- init?.method === 'PUT'
- ? new Response(JSON.stringify({ message: '审核证据已过期,请明确重新审核' }), { status: 409 })
- : new Response(
- JSON.stringify({
- data: [imageFixture({ id: 'candidate', isPrimary: false, qualityPassed: true }), original]
- })
- )
+ const fetcher = vi.fn().mockImplementation(async (url, init) =>
+ String(url).endsWith('/validate/preview')
+ ? validationPreviewResponse(String(url))
+ : init?.method === 'PUT'
+ ? new Response(JSON.stringify({ message: '审核证据已过期,请明确重新审核' }), { status: 409 })
+ : new Response(
+ JSON.stringify({
+ data: [imageFixture({ id: 'candidate', isPrimary: false, qualityPassed: true }), original]
+ })
+ )
)
vi.stubGlobal('fetch', fetcher)
wrapper = mount(ImageGalleryDialog, {
@@ -105,26 +129,27 @@ describe('候选质量与主图门禁', () => {
})
it('质量处理默认预算为零,只有明确确认后发出一次请求', async () => {
const image = imageFixture({ isPrimary: false })
- const fetcher = vi.fn().mockImplementation(
- async (_url, init) =>
- new Response(
- JSON.stringify({
- data:
- init?.method === 'POST'
- ? {
- subjectFormId: 'form-db-1',
- initialImageId: image.id,
- finalImageId: image.id,
- passed: false,
- repaired: false,
- repairAttempts: 0,
- maxRepairAttempts: 0,
- primaryChanged: false,
- attempts: []
- }
- : [image]
- })
- )
+ const fetcher = vi.fn().mockImplementation(async (url, init) =>
+ String(url).endsWith('/validate/preview')
+ ? validationPreviewResponse(String(url))
+ : new Response(
+ JSON.stringify({
+ data:
+ init?.method === 'POST'
+ ? {
+ subjectFormId: 'form-db-1',
+ initialImageId: image.id,
+ finalImageId: image.id,
+ passed: false,
+ repaired: false,
+ repairAttempts: 0,
+ maxRepairAttempts: 0,
+ primaryChanged: false,
+ attempts: []
+ }
+ : [image]
+ })
+ )
)
vi.stubGlobal('fetch', fetcher)
wrapper = mount(ImageGalleryDialog, {
diff --git a/tests/features/subject-images/source-diagnostics.test.ts b/tests/features/subject-images/source-diagnostics.test.ts
new file mode 100644
index 0000000..a30cb1e
--- /dev/null
+++ b/tests/features/subject-images/source-diagnostics.test.ts
@@ -0,0 +1,66 @@
+import { flushPromises, mount } from '@vue/test-utils'
+import { NCollapse } from 'naive-ui'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import FormSourceDiagnostics from '@/features/subject-images/components/FormSourceDiagnostics.vue'
+import { formFixture } from '@/features/subject-images/testing/fixtures'
+
+afterEach(() => vi.unstubAllGlobals())
+
+describe('道具与场景来源诊断', () => {
+ it.each([
+ ['missing', '尚未准备结构规格'],
+ ['stale', '结构来源已过期']
+ ])('道具 %s 只读取原文和历史,不调用生成', async (status, label) => {
+ const form = formFixture('source-project')
+ form.subject.module = 'prop'
+ const fetcher = vi.fn(
+ async () =>
+ new Response(
+ JSON.stringify({
+ data: {
+ subjectFormId: form.id,
+ status,
+ spec: null,
+ sourceEpisodes: [
+ { episodeId: 'origin', episode: 1, title: '基础形态' },
+ { episodeId: 'change', episode: 2, title: '拆卸' }
+ ],
+ ownershipEvidence: [
+ {
+ name: '搭扣',
+ quantity: 2,
+ episodeId: 'origin',
+ sourceQuote: '工具箱有两个搭扣',
+ relationEpisodeId: 'change',
+ relationQuote: '搭扣从工具箱脱落'
+ }
+ ],
+ lastGenerationAttempt: {
+ status: 'failed',
+ sourceCurrent: false,
+ error: '无法核对归属',
+ evidence: { candidates: [{ semanticClass: '工具箱' }] },
+ inputSnapshot: {}
+ }
+ }
+ })
+ )
+ )
+ vi.stubGlobal('fetch', fetcher)
+ const wrapper = mount(FormSourceDiagnostics, { props: { form, projectId: 'source-project' } })
+ try {
+ await flushPromises()
+ expect(fetcher).not.toHaveBeenCalled()
+ wrapper.getComponent(NCollapse).vm.$emit('update:expandedNames', ['source'])
+ await flushPromises()
+ expect(wrapper.text()).toContain(label)
+ expect(wrapper.text()).toContain('数量来源 · 第 1 集')
+ expect(wrapper.text()).toContain('拆装来源 · 第 2 集')
+ expect(wrapper.text()).toContain('准备时的来源已过期')
+ expect(fetcher.mock.calls).toHaveLength(1)
+ expect(fetcher.mock.calls[0]?.[1]?.method).toBe('GET')
+ } finally {
+ wrapper.unmount()
+ }
+ })
+})
diff --git a/tests/features/workflows/pages.test.ts b/tests/features/workflows/pages.test.ts
index 4321b5c..5cfc17a 100644
--- a/tests/features/workflows/pages.test.ts
+++ b/tests/features/workflows/pages.test.ts
@@ -1,3 +1,4 @@
+import { approvedCharacter } from '../../fixtures/image-preview'
import { imagePreviewFixture } from '../../fixtures/image-preview'
import { preparationFixture } from '../storyboard-preparation/fixtures'
import { generationProfile, imageCatalog } from '../../fixtures/generation'
@@ -1176,6 +1177,7 @@ describe('视觉风格与主体身份工作区', () => {
expect(getOperation(fixture.id).pending).toBe(true)
finish(
jsonResponse({
+ ...approvedCharacter('identity-image-1'),
subjectId: 'subject-db-1',
imageId: 'identity-image-1',
passed,
@@ -1203,6 +1205,8 @@ describe('视觉风格与主体身份工作区', () => {
const fetcher = vi.fn().mockImplementation(async (url, init) => {
if (String(url).endsWith('/subject-forms')) return jsonResponse([form])
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
+ if (init?.method === 'POST' && String(url).endsWith('/validate'))
+ return jsonResponse(approvedCharacter('candidate'))
if (init?.method === 'PUT') {
selected = true
return jsonResponse({
@@ -1219,10 +1223,13 @@ describe('视觉风格与主体身份工作区', () => {
stubFetch(fetcher)
await mountAssets('identity')
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
+ expect(button('设为身份母版').disabled).toBe(true)
+ wrapper!.findComponent(IdentityGallery).vm.$emit('validate', 'candidate')
+ await flushPromises()
button('设为身份母版').click()
await flushPromises()
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'PUT')).toBe(false)
- button('确认切换身份母版').click()
+ button('确认费用并切换母版').click()
await flushPromises()
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
'/api/subjects/subject-db-1/identity/images/candidate/stable-anchor'
@@ -1338,6 +1345,8 @@ describe('视觉风格与主体身份工作区', () => {
]
})
if (path.endsWith('/identity/images')) return jsonResponse([{ ...candidate, isAnchor: selected }])
+ if (init?.method === 'POST' && path.endsWith('/validate'))
+ return jsonResponse(approvedCharacter(candidate.id))
if (init?.method === 'PUT' && path.endsWith('/casting')) {
locked = true
selected = true
@@ -1354,6 +1363,9 @@ describe('视觉风格与主体身份工作区', () => {
await mountAssets('identity')
expect(wrapper!.text()).toContain('待确认选角')
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
+ expect(button('确认选角并锁定').disabled).toBe(true)
+ wrapper!.findComponent(IdentityGallery).vm.$emit('validate', candidate.id)
+ await flushPromises()
button('确认选角并锁定').click()
await flushPromises()
button('确认演员选择').click()
diff --git a/tests/fixtures/breakdown-candidate.ts b/tests/fixtures/breakdown-candidate.ts
index cccd7c1..49aab6a 100644
--- a/tests/fixtures/breakdown-candidate.ts
+++ b/tests/fixtures/breakdown-candidate.ts
@@ -206,6 +206,7 @@ export function commitPreview(overrides: Partial =
relationRepairTargets: [],
checks: {
qualityPolicyMatches: true,
+ durationBudgetCurrent: true,
episodeNumbersMatch: true,
episodeFingerprintsMatch: true,
noActiveExecutions: true,
diff --git a/tests/fixtures/image-preview.ts b/tests/fixtures/image-preview.ts
index bbb960d..e5bc3f4 100644
--- a/tests/fixtures/image-preview.ts
+++ b/tests/fixtures/image-preview.ts
@@ -1,3 +1,8 @@
+import {
+ characterCheckLabels,
+ type CharacterCheckResult,
+ type ImageValidationResult
+} from '@/features/subject-images/validation'
import type { SubjectImageGenerationPreview } from '@/features/subject-images/types'
/**
@@ -17,3 +22,47 @@ export function imagePreviewFixture(subjectFormId = 'form-db-1'): SubjectImageGe
references: []
}
}
+
+/**
+ * 返回绑定当前图库图像的只读审核来源。
+ * @param url 正式预检路径
+ * @param sourceCurrent 来源是否仍有效
+ * @returns 对应当前图片的预检响应
+ */
+export function validationPreviewResponse(url: string, sourceCurrent = true) {
+ const [, subjectFormId, imageId] = url.match(/subject-forms\/([^/]+)\/images\/([^/]+)\/validate\/preview$/) ?? []
+ return new Response(
+ JSON.stringify({
+ data: {
+ subjectFormId,
+ imageId,
+ sourceCurrent,
+ canValidate: sourceCurrent,
+ sourceStaleReason: sourceCurrent ? null : '本次机位采用的几何已过期',
+ providerInputSnapshot: null,
+ providerInputFingerprint: null
+ }
+ })
+ )
+}
+/**
+ * 模拟已通过明确审核的角色候选。
+ * @param imageId 当前候选
+ * @returns 四项完整的像素审核证据
+ */
+export function approvedCharacter(imageId: string): ImageValidationResult {
+ return {
+ subjectId: 'subject-db-1',
+ imageId,
+ passed: true,
+ sourceRequirementsPassed: true,
+ sourceVisualRequirements: [],
+ summary: '已核对图像',
+ issues: [],
+ characterCheckResults: (Object.keys(characterCheckLabels) as CharacterCheckResult['check'][]).map(check => ({
+ check,
+ status: check.endsWith('References') ? 'not_applicable' : 'passed',
+ evidence: '具体观察结果'
+ }))
+ }
+}