项目生产总览与批量操作
-
- 当前有 {{ videoRunning }} 个视频任务等待或生成中。系统会持续更新任务状态,同一镜头不会重复提交。
-
-
- 当前有 {{ identityBlocked }} 项角色身份尚未准备完成。请先确认角色母版并完成身份锁定,再生成镜头首帧。
- 前往主体身份 →
-
- 当前有 {{ invalidGenerationSpecs }} 个镜头的设计信息还不完整。请先补齐镜头设计和即时视觉状态。
-
- 前往分镜设计 →
-
-
-
- 当前有
- {{ staleKeyframes }}
- 个主首帧已过期。它们使用的主体参考资产已经变化,视频阶段会被阻止;可在下方逐镜重新生成,或使用“补齐
- / 更新主首帧”批量处理。
-
-
- 当前有
- {{ staleVideos }}
- 个主视频已过期。它们使用的主首帧或主体参考图已经变化;非覆盖模式批量生成时会只重建这些过期主视频。
-
-
-
-
-
-
-
-
-
-
-
STEP {{ stage.code }}
-
- {{ stage.title }}
-
-
-
-
{{ stage.done }} / {{ stage.data?.total ?? 0 }}
-
-
- {{ stage.description }}
-
-
-
-
-
- 可执行
- - {{ stage.data?.ready ?? 0 }}
-
-
-
- 已有结果
- - {{ stage.data?.skipped ?? 0 }}
-
-
-
- 阻塞
- - {{ stage.data?.blocked ?? 0 }}
-
-
-
- 已过期 {{ staleKeyframes }} · 会按当前主体参考资产重新生成
-
-
- 主视频已过期 {{ staleVideos }} ·
- 会按当前主首帧与参考资产重新生成
-
-
- 身份缺失
- {{ query.data.value?.keyframes.missingIdentity ?? 0 }} ·
- 母版缺失
- {{ query.data.value?.keyframes.missingIdentityAnchor ?? 0 }} ·
- 未锁定
- {{ query.data.value?.keyframes.identityUnlocked ?? 0 }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 输入规划暂不可用,仍可按“全部推荐模式”提交;刷新后可重试规划。
-
-
-
-
-
-
-
-
-
-
-
+
+ 当前有
+ {{ videoRunning }}
+ 个视频任务等待或生成中。系统会持续更新任务状态,同一镜头不会重复提交。
+
+
+ 当前有
+ {{ identityBlocked }}
+ 项角色身份尚未准备完成。请先确认角色母版并完成身份锁定,再生成镜头首帧。
+ 前往主体身份 →
+
+ 当前有
+ {{ invalidGenerationSpecs }}
+ 个镜头的设计信息还不完整。请先补齐镜头设计和即时视觉状态。
+
+ 前往分镜设计 →
+
+
+
+ 当前有
+ {{ staleKeyframes }}
+ 个主首帧已过期。它们使用的主体参考资产已经变化,视频阶段会被阻止;可在下方逐镜重新生成,或使用“补齐
+ / 更新主首帧”批量处理。
+
+
+ 当前有
+ {{ staleVideos }}
+ 个主视频已过期。它们使用的主首帧或主体参考图已经变化;非覆盖模式批量生成时会只重建这些过期主视频。
+
+
+
+
+
+
+
+
+
-
视频任务状态
-
- 状态统计取每个镜头最近一次任务,不等同于主视频数量。
-
+
STEP {{ stage.code }}
+
+ {{ stage.title }}
+
-
-
-
-
- 完成
- - {{ query.data.value.videoStatus.completed }}
-
-
-
- 排队/生成
- - {{ videoRunning }}
-
-
-
- 失败
- - {{ query.data.value.videoStatus.failed }}
-
-
-
- 取消
- - {{ query.data.value.videoStatus.cancelled }}
-
-
-
- 未开始
- - {{ query.data.value.videoStatus.notStarted }}
-
-
+
{{ stage.done }} / {{ stage.data?.total ?? 0 }}
+
+ {{ stage.description }}
+
+
+
+
+
- 可执行
+ - {{ stage.data?.ready ?? 0 }}
+
+
+
- 已有结果
+ - {{ stage.data?.skipped ?? 0 }}
+
+
+
- 阻塞
+ - {{ stage.data?.blocked ?? 0 }}
+
+
+
+ 已过期 {{ staleKeyframes }} · 会按当前主体参考资产重新生成
+
+
+ 主视频已过期 {{ staleVideos }} · 会按当前主首帧与参考资产重新生成
+
+
+ 身份缺失
+ {{ query.data.value?.keyframes.missingIdentity ?? 0 }} · 母版缺失
+ {{ query.data.value?.keyframes.missingIdentityAnchor ?? 0 }} · 未锁定
+ {{ query.data.value?.keyframes.identityUnlocked ?? 0 }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 输入规划暂不可用,仍可按“全部推荐模式”提交;刷新后可重试规划。
+
+
+
+
+
+
+
+
+
+
+
+
+
视频任务状态
+
+ 状态统计取每个镜头最近一次任务,不等同于主视频数量。
+
+
+
+
+
+
+
- 完成
+ - {{ query.data.value.videoStatus.completed }}
+
+
+
- 排队/生成
+ - {{ videoRunning }}
+
+
+
- 失败
+ - {{ query.data.value.videoStatus.failed }}
+
+
+
- 取消
+ - {{ query.data.value.videoStatus.cancelled }}
+
+
+
- 未开始
+ - {{ query.data.value.videoStatus.notStarted }}
+
+
+
@@ -720,6 +704,30 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
+
+
+
+
+
+
+ 本集镜头已重新生成。新标题和剧情详情尚未提供,当前只显示正式镜头编号;请按实际生成规格核对内容。
+
本项目镜头素材和视频成片已经准备完成。
镜头制作准备已经完成。视频生成费用较高,可按需要逐批提交视频任务。
@@ -852,12 +860,14 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
:key="shot.shotId"
:project-id="id"
:shot="shot"
+ :episode-no="episodeNo"
:prompt-readiness="promptItem"
:keyframe-readiness="keyframeItem"
:video-readiness="videoItem"
:open-keyframe="openRequestedKeyframe"
- :disabled="blocked || !!linkedShotMissing"
+ :disabled="blocked || keyframeQualityExecution.active.value || !!linkedShotMissing"
@changed="refreshProject"
+ @quality-started="trackKeyframeQuality"
/>
@@ -879,6 +889,7 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
:disabled="blocked"
@changed="refreshProject"
@locate="locateQualityShot"
+ @started="trackKeyframeQuality"
/>
diff --git a/src/features/production/api.ts b/src/features/production/api.ts
index 19e147e..340755d 100644
--- a/src/features/production/api.ts
+++ b/src/features/production/api.ts
@@ -4,7 +4,6 @@ import type {
GenerateKeyframeInput,
GenerateKeyframesInput,
GenerateQualityVideosInput,
- KeyframeBatchResult,
KeyframeReadiness,
KeyframeGenerationPreview,
KeyframeSpec,
@@ -12,6 +11,8 @@ import type {
ProjectVideoInputPlan,
PromptReadiness,
ProductionPlan,
+ ProductionPlanInput,
+ ProductionStartInput,
ProviderInputSpec,
ProjectProductionStatus,
RetryVideosResult,
@@ -56,29 +57,32 @@ export const productionApi = {
request
(`${shotPath(shotId)}/provider-input-spec?provider=${encodeURIComponent(provider)}`, {
signal
}),
- /** 查询当前计划,不生成图片、视频或提示词。 */
- plan: (projectId: string, signal?: AbortSignal, providers?: { imageProvider?: string; videoProvider?: string }) => {
- const params = new URLSearchParams()
- if (providers?.imageProvider) params.set('imageProvider', providers.imageProvider)
- if (providers?.videoProvider) params.set('videoProvider', providers.videoProvider)
- const query = params.size ? `?${params}` : ''
- return request(`${projectPath(projectId)}/production/plan${query}`, { signal })
- },
+ /**
+ * 使用正式 POST 预检当前生产计划,不产生生成费用。
+ * @param projectId 正式项目 ID
+ * @param signal 取消信号
+ * @param input 与启动同源的模型及图片参数
+ * @returns 后端实际生产计划
+ */
+ plan: (projectId: string, signal?: AbortSignal, input: ProductionPlanInput = {}) =>
+ request(`${projectPath(projectId)}/production/plan`, {
+ method: 'POST',
+ body: input,
+ signal
+ }),
/** 读取真实主资产完成状态,不能用任务提交回执代替。 */
status: (projectId: string, signal?: AbortSignal) =>
request(`${projectPath(projectId)}/production/status`, { signal }),
- startPipeline: (
- projectId: string,
- input?: {
- imageProvider?: string
- videoProvider?: string
- stopAfter?: 'keyframes' | 'videoPrompts'
- keyframeLimit?: number
- }
- ) =>
+ /**
+ * 启动有限范围的串联生产,最终结果通过任务查询取得。
+ * @param projectId 正式项目 ID
+ * @param input 模型、断点、停止阶段和各阶段上限
+ * @returns 真实后台任务观察句柄
+ */
+ startPipeline: (projectId: string, input: ProductionStartInput = {}) =>
request(`${projectPath(projectId)}/production/start`, {
method: 'POST',
- body: input ?? {}
+ body: input
}),
promptReadiness: (projectId: string, force: boolean, signal?: AbortSignal) =>
request(`${projectPath(projectId)}/video-prompts/readiness?force=${force}`, { signal }),
@@ -96,8 +100,14 @@ export const productionApi = {
}),
keyframeReadiness: (projectId: string, force: boolean, signal?: AbortSignal) =>
request(`${projectPath(projectId)}/keyframes/readiness?force=${force}`, { signal }),
+ /**
+ * 后台批量生成普通首帧候选。
+ * @param projectId 正式项目 ID
+ * @param input 当前生成范围和模型参数
+ * @returns 真实后台任务观察句柄
+ */
generateKeyframes: (projectId: string, input: GenerateKeyframesInput) =>
- request(`${projectPath(projectId)}/keyframes/generate`, {
+ request(`${projectPath(projectId)}/keyframes/generate`, {
method: 'POST',
body: input,
timeoutMs: 0
diff --git a/src/features/production/components/AdvancedProduction.vue b/src/features/production/components/AdvancedProduction.vue
index 883a119..bfcab79 100644
--- a/src/features/production/components/AdvancedProduction.vue
+++ b/src/features/production/components/AdvancedProduction.vue
@@ -1,5 +1,5 @@
依次补齐形态提示词、参考图、首帧质量校验与修复、视频提示词,再提交视频任务。视觉风格、身份母版、导演设计和即时状态仍需提前准备。
- 范围固定为全项目并跳过已有有效结果。默认开启测试安全模式:允许 LLM、Vision、主体图、少量首帧和 Video Prompt,但会在视频生成前正常停止,不向视频 Provider 提交任务。
+ 范围固定为全项目并跳过已有有效结果。默认开启测试安全模式:允许 LLM、Vision、主体图、少量首帧和 Video
+ Prompt,但会在视频生成前正常停止,不向视频 Provider 提交任务。
+
测试安全模式(不生成视频)
-
-
本轮最多生成首帧
-
-
张;Video Prompt 仍会正常生成。
+
+
+
+
+
+
+
+
-
+ {{ scopeError }}
+
已关闭测试安全模式。启动后会进入视频任务提交阶段并产生较高视频生成费用。
+
- 检查串联生产条件
+
+
+
+ 失败任务结果详情
+ {{ JSON.stringify(failedResult, null, 2) }}
+
{{ error }}
导出回执
+
+ 稳定身份母版:共 {{ receipt.stableIdentityAnchorResult.total }} · 生成
+ {{ receipt.stableIdentityAnchorResult.generated }} · 失败
+ {{ receipt.stableIdentityAnchorResult.failed }}
+
流程返回不等于成片完成。已保存结果不会回滚,最终结果以各资产页为准。
diff --git a/src/features/production/components/KeyframeValidationHistory.vue b/src/features/production/components/KeyframeValidationHistory.vue
new file mode 100644
index 0000000..e40659d
--- /dev/null
+++ b/src/features/production/components/KeyframeValidationHistory.vue
@@ -0,0 +1,74 @@
+
+
+
+
+
+ 暂无校验记录。
+
+
+
+ {{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} · {{ record.status }} ·
+ {{
+ record.status === 'completed' && record.validation
+ ? record.validation.passed
+ ? '视觉通过'
+ : '视觉未通过'
+ : '未取得完整视觉结论'
+ }}
+
+ {{ record.error }}
+
+ {{ record.validation.summary }}
+
+ {{ issue.description }}
+
+
+
+ 原始记录
+ {{ JSON.stringify(record.output, null, 2) }}
+
+
+
+
diff --git a/src/features/production/components/ModelCapabilities.vue b/src/features/production/components/ModelCapabilities.vue
index 9655ade..cad9e8c 100644
--- a/src/features/production/components/ModelCapabilities.vue
+++ b/src/features/production/components/ModelCapabilities.vue
@@ -5,8 +5,13 @@ import { qualityApi } from '../quality-api'
import type { ImageProviderCapability, ShotProviderCapability } from '../quality.types'
import { errorMessage } from '../../../lib/http'
-/** 模型由后端配置;此入口只读公开能力,不提供无效的前端模型切换。 */
-const props = defineProps<{ shotId?: string }>()
+/** 只读查询指定镜头及本次选择模型的公开能力。 */
+const props = defineProps<{
+ /** 当前正式镜头 ID。 */
+ shotId?: string
+ /** 本次选择的图片模型,未提供时读取后端默认。 */
+ provider?: string
+}>()
const providers = ref(null)
const capability = ref(null)
const error = ref('')
@@ -15,27 +20,26 @@ let revision = 0
onScopeDispose(() => {
revision++
})
-watch(
- () => props.shotId,
- () => {
- revision++
- providers.value = null
- capability.value = null
- error.value = ''
- loading.value = false
- }
-)
-/** 按需检查,不自动生成图片;空上限表示未声明,不冒充无限制。 */
+/** 切换镜头或本次模型后清除旧能力记录,迟到响应不能覆盖新目标。 */
+watch([() => props.shotId, () => props.provider], () => {
+ revision++
+ providers.value = null
+ capability.value = null
+ error.value = ''
+ loading.value = false
+})
+/** 按需检查当前模型,不自动生成图片;空上限表示未声明,不冒充无限制。 */
async function inspect() {
if (loading.value) return
const version = ++revision
const shotId = props.shotId
+ const provider = props.provider
loading.value = true
error.value = ''
try {
const list = await qualityApi.providers()
if (version !== revision) return
- const result = shotId ? await qualityApi.capability(shotId) : null
+ const result = shotId ? await qualityApi.capability(shotId, undefined, provider) : null
if (version !== revision) return
if (!Array.isArray(list) || list.some(item => !item.capabilities?.references))
throw new Error('模型能力接口返回不完整。')
@@ -69,8 +73,13 @@ async function inspect() {
{{
capability.valid
- ? `当前镜头需要 ${capability.referenceCount} 张参考图,符合 ${capability.provider} 的已声明能力。`
+ ? capability.message ||
+ `当前镜头共有 ${capability.referenceCount} 张业务参考图,后端已判定本次规划符合 ${capability.provider} 能力。`
: capability.message || '当前镜头不满足模型能力限制。'
}}
+
+ 本次计划输入 {{ capability.plannedReferenceCount }} 张 · 转为文字约束
+ {{ capability.omittedReferenceCount ?? 0 }} 张
+
diff --git a/src/features/production/components/ProductionPlanPanel.vue b/src/features/production/components/ProductionPlanPanel.vue
index 5e46af0..9c67c37 100644
--- a/src/features/production/components/ProductionPlanPanel.vue
+++ b/src/features/production/components/ProductionPlanPanel.vue
@@ -5,8 +5,8 @@ import type { ProductionPlan, ProjectProductionStatus } from '../types'
/** 展示当前制作计划与真实资产状态,不在页面重复推断业务规则。 */
const props = defineProps<{ plan: ProductionPlan; status: ProjectProductionStatus }>()
+/** 生产阶段共享计划字段,角色身份就绪信息单独展示,避免混用不同 DTO。 */
const rows = computed(() => [
- ...(props.plan.characterIdentity ? [{ label: '角色身份', stage: props.plan.characterIdentity }] : []),
...(props.plan.stableIdentityAnchors ? [{ label: '稳定身份锚点', stage: props.plan.stableIdentityAnchors }] : []),
{ label: '主体参考图', stage: props.plan.subjectImages },
{ label: '首帧质量', stage: props.plan.keyframes },
@@ -48,6 +48,12 @@ const problems = computed(() => [
图片模型:{{ plan.providers.image }}
视频模型:{{ plan.providers.video }}
+
+
+ 角色身份:已就绪 {{ plan.characterIdentity.ready }} / {{ plan.characterIdentity.total }} · 待就绪
+ {{ plan.characterIdentity.pending }} · 可自动补齐 {{ plan.characterIdentity.autoResolvable }} · 需人工处理
+ {{ plan.characterIdentity.manualBlocked }}
+
当前制作状态:{{ status.completed ? '制作已完成' : `待完成${stageNames[status.stage]}` }} · 有效主体图
{{ status.subjectImages.current }}/{{ status.subjectImages.total }} · 有效首帧
diff --git a/src/features/production/components/QualityDialog.vue b/src/features/production/components/QualityDialog.vue
index 3e0ee34..9b68a81 100644
--- a/src/features/production/components/QualityDialog.vue
+++ b/src/features/production/components/QualityDialog.vue
@@ -19,35 +19,84 @@ import { allowedTextLines, validQualityInput } from '../quality'
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
import { useQuality } from '../useQuality'
import QualityResult from './QualityResult.vue'
+import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
+import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
+import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
+import { generationConfigApi } from '../../generation-config/api'
+import type { GenerationOptions } from '../../generation-config/types'
+import { useQuery } from '../../../composables/useQuery'
import ModelCapabilities from './ModelCapabilities.vue'
/** 单素材与当前集质量生成共用一个按需打开的面板,默认小批量且不自动调用模型。 */
const props = defineProps<{
+ /** 当前项目 */
projectId: string
+ /** 固定质量目标 */
target: QualityTarget | null
+ /** 上游状态阻断 */
disabled: boolean
}>()
+/** 质量面板的open状态,随目标更新。 */
const open = defineModel('open', { default: false })
-const emit = defineEmits<{ changed: []; locate: [shotId: string] }>()
-const { key, session, operation, blocked, run } = useQuality(
+/** 通知外部刷新、定位与后台任务开始。 */
+const emit = defineEmits<{ changed: []; locate: [shotId: string]; started: [executionId: string] }>()
+const { key, session, operation, execution, blocked, run } = useQuality(
props,
() => open.value,
- () => emit('changed')
+ () => emit('changed'),
+ id => emit('started', id)
)
+/** 模型目录只读查询,随当前项目和弹窗状态取消过期请求。 */
+const modelKey = computed(() =>
+ open.value && props.target?.kind === 'batch' && props.projectId ? props.projectId : ''
+)
+/** 模型与项目画幅读取,不自动写入配置。 */
+const modelQuery = useQuery(modelKey, async (projectId, signal) =>
+ projectId
+ ? {
+ catalog: await generationConfigApi.catalog(signal),
+ profile: await generationConfigApi.profile(projectId, signal)
+ }
+ : null
+)
+/** 本次明确选择的图片供应方。 */
+const provider = ref('')
+/** 本次生成与修复共用参数。 */
+const generationOptions = ref({})
+/** 后台任务期间表单也保持锁定。 */
+const pending = computed(() => operation.value.pending || execution.active.value)
+/** 当前目标的单镜头范围。 */
+const singleShot = computed(() => props.target?.kind === 'batch' && !!props.target.shotId)
+/** 质量面板的formRef状态,随目标更新。 */
const formRef = ref | null>(null)
+/** 质量面板的action状态,随目标更新。 */
const action = ref('validate')
+/** 质量面板的attempts状态,随目标更新。 */
const attempts = ref(1)
+/** 质量面板的concurrency状态,随目标更新。 */
const concurrency = ref(1)
+/** 质量面板的limit状态,随目标更新。 */
const limit = ref(1)
+/** 质量面板的force状态,随目标更新。 */
const force = ref(false)
+/** 质量面板的width状态,随目标更新。 */
const width = ref(null)
+/** 质量面板的height状态,随目标更新。 */
const height = ref(null)
+/** 质量面板的texts状态,随目标更新。 */
const texts = ref('')
+/** 质量面板的acknowledged状态,随目标更新。 */
const acknowledged = ref(false)
+/** 质量面板的videoRepair状态,随目标更新。 */
const videoRepair = computed(() => props.target?.kind === 'video' && action.value === 'repair')
+/** 质量面板的input状态,随目标更新。 */
const input = computed(() => ({
concurrency: action.value === 'batch' ? (concurrency.value ?? 0) : 1,
- limit: action.value === 'batch' ? (limit.value ?? 0) : 1,
+ limit: action.value === 'batch' && !singleShot.value ? (limit.value ?? 0) : 1,
+ ...(props.target?.kind === 'batch' && props.target.shotId ? { shotId: props.target.shotId } : {}),
+ ...(action.value === 'batch' && provider.value
+ ? { provider: provider.value, generationOptions: { ...generationOptions.value } }
+ : {}),
maxRepairAttempts: action.value === 'validate' ? 0 : (attempts.value ?? -1),
force: force.value,
episodeNo: props.target?.kind === 'batch' ? props.target.episodeNo : 1,
@@ -55,10 +104,23 @@ const input = computed(() => ({
...(action.value === 'validate' || width.value === null ? {} : { width: width.value }),
...(action.value === 'validate' || height.value === null ? {} : { height: height.value })
}))
-const valid = computed(
- () => validQualityInput(input.value) && (!videoRepair.value || input.value.maxRepairAttempts > 0)
+/** 批量生图必须读到真实配置并显式选定启用模型,不能回退到未确认的全局默认。 */
+const modelReady = computed(
+ () =>
+ props.target?.kind !== 'batch' ||
+ (!modelQuery.loading.value &&
+ !modelQuery.error.value &&
+ !!modelQuery.data.value?.profile &&
+ modelQuery.data.value.catalog.images.some(model => model.provider === provider.value && model.enabled))
)
+/** 参数及模型均有效时才允许进入费用确认后的提交。 */
+const valid = computed(
+ () =>
+ modelReady.value && validQualityInput(input.value) && (!videoRepair.value || input.value.maxRepairAttempts > 0)
+)
+/** 质量面板的generating状态,随目标更新。 */
const generating = computed(() => action.value !== 'validate')
+/** 质量面板的label状态,随目标更新。 */
const label = computed(() =>
action.value === 'batch'
? '开始质量生成'
@@ -68,6 +130,7 @@ const label = computed(() =>
: '校验并修复'
: '开始视觉校验'
)
+/** 质量面板的maxImages状态,随目标更新。 */
const maxImages = computed(() =>
action.value === 'batch'
? input.value.limit * (1 + input.value.maxRepairAttempts)
@@ -75,10 +138,13 @@ const maxImages = computed(() =>
? input.value.maxRepairAttempts
: 0
)
+/** 质量面板的maxValidations状态,随目标更新。 */
const maxValidations = computed(() =>
action.value === 'batch' ? maxImages.value : action.value === 'repair' ? input.value.maxRepairAttempts + 1 : 1
)
+/** 质量面板的saved状态,随目标更新。 */
const saved = computed(() => (props.target?.kind === 'video' ? (session.value.videoValidation ?? null) : null))
+/** 质量面板的repairAvailable状态,随目标更新。 */
const repairAvailable = computed(
() =>
!videoRepair.value ||
@@ -99,19 +165,35 @@ watch(
width.value = null
height.value = null
texts.value = ''
+ provider.value = ''
+ generationOptions.value = {}
acknowledged.value = false
},
{ immediate: true }
)
+/** 参数变化撤销付费确认。 */
watch([input, action], () => {
acknowledged.value = false
})
+/** 模型目录加载后使用项目已保存的供应方与参数,切镜头重置单次覆盖。 */
+watch(
+ [() => modelQuery.data.value, key],
+ ([data]) => {
+ if (!data?.profile || props.target?.kind !== 'batch') return
+ const selected = data.catalog.images.find(item => item.provider === data.profile!.imageProvider && item.enabled)
+ if (!selected) return
+ provider.value = selected.provider
+ generationOptions.value = { ...selected.defaults, ...data.profile.imageOptions }
+ },
+ { flush: 'post' }
+)
/** 付费入口保留明确确认,不因菜单选择或查看历史自动提交。 */
async function submit() {
if (!acknowledged.value || !valid.value || blocked.value || !repairAvailable.value) return
acknowledged.value = false
await run(action.value, input.value)
}
+/** 质量面板的formModel状态,随目标更新。 */
const formModel = computed(() => ({
attempts: attempts.value,
concurrency: concurrency.value,
@@ -120,16 +202,19 @@ const formModel = computed(() => ({
height: height.value,
texts: texts.value
}))
+/** 质量面板的rules状态,随目标更新。 */
const rules = computed(() => ({
attempts: integerRule('修复次数', videoRepair.value ? 1 : 0),
concurrency: integerRule('批量并发'),
limit: integerRule('本批镜头上限'),
...sizeRules(() => formModel.value)
}))
+/** 更多参数折叠状态。 */
const optionsExpanded = ref(['options'])
+
(['options'])
ref="formRef"
:model="formModel"
:rules="rules"
- :disabled="operation.pending"
+ :disabled="pending"
:reset-key="`${open}:${key}:${action}`"
validate-on-change
@invalid="optionsExpanded = ['options']"
@@ -149,7 +234,7 @@ const optionsExpanded = ref(['options'])
@@ -165,30 +250,26 @@ const optionsExpanded = ref(['options'])
-
- 重做本集已有有效首帧(通过后替换主图)重做当前范围已有有效首帧(通过后替换主图)
- 仅第 {{ target.episodeNo }} 集,最多
- {{ limit ?? '—' }} 镜;非重做模式优先处理过期项,若全项目无过期项则补缺失首帧。
+ 仅第 {{ target.episodeNo }} 集{{ singleShot ? `,指定镜头 ${target.shotId}` : '' }},最多
+ {{ singleShot ? 1 : (limit ?? '—') }} 镜;非重做模式处理符合条件的过期和缺失首帧。
本次仅创建一个修复视频,不自动等待或复检。完成后请打开新候选的质量检查;修复约束沿用上次失败校验,不使用额外参数。
@@ -207,7 +288,7 @@ const optionsExpanded = ref(['options'])
(['options'])
@@ -230,12 +311,39 @@ const optionsExpanded = ref(['options'])
-
+
+
+ {{
+ modelQuery.error.value
+ }}
+
+ {{
+ modelQuery.loading.value
+ ? '正在读取项目模型配置,请稍候。'
+ : '请先保存有效的项目图片模型配置,再选择本次模型。'
+ }}
+
+
@@ -258,17 +366,30 @@ const optionsExpanded = ref(['options'])
: '仅校验,不修改主资产。'
}}
- 我已确认费用、处理范围,且同项目没有其他生成任务。
-
-
- {{ operation.label }}进行中,请勿重复提交。
-
+ {{ operation.label }}进行中,请勿重复提交。
{{
session.error
}}
+
+
+
(['options'])
>
- 校验回执保留在当前会话,可导出;素材列表不提供历史质量结果,刷新浏览器后需重新校验。
+ 本会话回执可导出;首帧已有校验可在历史中只读查看,后台质量任务刷新后继续恢复。
关闭
{{ label }}
+ >{{ label }}
diff --git a/src/features/production/components/QualityResult.vue b/src/features/production/components/QualityResult.vue
index 0ea73ec..0605a28 100644
--- a/src/features/production/components/QualityResult.vue
+++ b/src/features/production/components/QualityResult.vue
@@ -6,7 +6,9 @@ import type { QualityReceipt } from '../quality.types'
/** 摘要、失败与完整逐轮信息默认直接显示,不用完成请求冒充质量通过。 */
const props = defineProps<{ receipt: QualityReceipt }>()
+/** 逐镜结果定位事件。 */
const emit = defineEmits<{ locate: [shotId: string] }>()
+/** 完整最终回执的视觉结论。 */
const passed = computed(() =>
props.receipt.kind === 'batch'
? props.receipt.result.targetCount > 0 && props.receipt.result.passed === props.receipt.result.targetCount
@@ -14,6 +16,7 @@ const passed = computed(() =>
? false
: props.receipt.result.passed
)
+/** 当前失败问题列表。 */
const issues = computed(() => {
const value = props.receipt
return value.kind === 'batch' || value.kind === 'video-repair'
@@ -22,6 +25,7 @@ const issues = computed(() => {
? (value.result.attempts.at(-1)?.issues ?? [])
: value.result.issues
})
+/** 视频专项检查详情。 */
const videoChecks = computed(() => {
if (props.receipt.kind !== 'video') return []
const result = props.receipt.result
@@ -43,6 +47,7 @@ function exportResult() {
+
{{
@@ -67,7 +72,9 @@ function exportResult() {
定位镜头
{{ item.shotId }}
{{
- item.success ? '已通过' : item.error || '未通过'
+ item.success
+ ? '已通过'
+ : item.error || (item.status === 'repair_failed' ? '达到修复上限仍未通过' : '调用失败')
}}
diff --git a/src/features/production/components/ShotProductionAssets.vue b/src/features/production/components/ShotProductionAssets.vue
index 858550c..c66286f 100644
--- a/src/features/production/components/ShotProductionAssets.vue
+++ b/src/features/production/components/ShotProductionAssets.vue
@@ -32,6 +32,8 @@ import type {
import KeyframeDialog from './KeyframeDialog.vue'
import KeyframeCard from './KeyframeCard.vue'
import QualityDialog from './QualityDialog.vue'
+import VideoQualityDiagnostics from './VideoQualityDiagnostics.vue'
+import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
import ActionMenu from '../../../components/ui/ActionMenu.vue'
import { AppDialog } from '../../../components/ui'
import ModelCapabilities from './ModelCapabilities.vue'
@@ -47,25 +49,37 @@ import GenerationModelControls from '../../generation-config/components/Generati
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
const props = defineProps<{
+ /** 当前正式项目 ID。 */
projectId: string
+ /** 当前正式镜头。 */
shot: DesignedShot
+ /** 当前剧集编号,用于限制单镜头质量生成。 */
+ episodeNo?: number
+ /** 视频提示词就绪项。 */
promptReadiness?: PromptReadinessItem
+ /** 首帧就绪项。 */
keyframeReadiness?: KeyframeReadinessItem
+ /** 视频就绪项。 */
videoReadiness?: VideoReadinessItem
+ /** 是否从深链接打开首帧生成。 */
openKeyframe?: boolean
+ /** 页面上游状态是否阻断操作。 */
disabled: boolean
}>()
-const emit = defineEmits<{ changed: [] }>()
+/** 通知父页面刷新及观察已启动的质量任务。 */
+const emit = defineEmits<{ changed: []; qualityStarted: [executionId: string] }>()
const key = computed(() => props.shot.shotId)
/** 仅当前镜头存在后台首帧或视频任务时临时轮询,终态后自动停止。 */
-let query!: ReturnType>
- videos: Awaited>
- qualityStatus: Awaited> | null
- qualityStatusError: string
- inputPlan: Awaited> | null
- inputPlanError: string
-}>>
+let query!: ReturnType<
+ typeof usePolling<{
+ keyframes: Awaited>
+ videos: Awaited>
+ qualityStatus: Awaited> | null
+ qualityStatusError: string
+ inputPlan: Awaited> | null
+ inputPlanError: string
+ }>
+>
const assetPollInterval = computed(() => {
const data = query?.data.value
if (!data) return false
@@ -173,6 +187,17 @@ function openQuality(kind: 'keyframe' | 'video', assetId: string) {
}
qualityOpen.value = true
}
+/** 只打开当前镜头的有限质量重跑表单,费用确认后才发送任务。 */
+function openShotKeyframeQuality() {
+ if (!props.episodeNo || !canGenerateKeyframe.value) return
+ qualityTarget.value = {
+ kind: 'batch',
+ episodeNo: props.episodeNo,
+ shotId: props.shot.shotId,
+ title: `${props.shot.title} · 本镜首帧质量重跑`
+ }
+ qualityOpen.value = true
+}
const confirmingKeyframe = ref('')
const confirmingVideo = ref('')
const inspecting = ref(false)
@@ -458,6 +483,15 @@ async function inspectSpecs() {
/>
尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。
+
+
+
本镜首帧质量重跑
管理候选({{ keyframeCandidates.length }})
@@ -597,6 +634,8 @@ async function inspectSpecs() {
。请检查候选视频和校验结果,调整提示词或参考资产后再重新生成。
+
+
+import { computed, ref } from 'vue'
+import { NAlert, NTag } from 'naive-ui'
+import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
+import { useQuery } from '../../../composables/useQuery'
+import { formatDate } from '../../../lib/format'
+import { videoDiagnosticsApi } from '../diagnostics-api'
+import { videoQualityStatusLabel } from '../model'
+import type { VideoQualityRollbackTarget } from '../diagnostics.types'
+
+/** 视频诊断始终绑定当前正式镜头。 */
+const props = defineProps<{ /** 正式镜头 ID。 */ shotId: string }>()
+/** 仅用户展开后查询,关闭后取消旧请求。 */
+const open = ref(false)
+/** 镜头和展开状态共同决定查询目标。 */
+const key = computed(() => (open.value ? props.shotId : ''))
+/** 切换镜头时取消查询,先读取链状态,耗尽时再查询独立归因。 */
+const query = useQuery(key, async (shotId, signal) => {
+ if (!shotId) return null
+ const detail = await videoDiagnosticsApi.qualityDetail(shotId, signal)
+ if (detail.shotId !== shotId || !Array.isArray(detail.chain)) throw new Error('质量记录与当前镜头不匹配,请刷新。')
+ const analysis =
+ detail.status === 'exhausted'
+ ? await videoDiagnosticsApi.exhaustionAnalysis(shotId, signal)
+ : detail.exhaustionAnalysis
+ if (analysis && analysis.shotId !== shotId) throw new Error('失败归因与当前镜头不匹配,请刷新。')
+ return { detail, analysis }
+})
+/** 当前请求返回的权威质量链。 */
+const detail = computed(() => query.data.value?.detail)
+/** 当前链对应的后端确定性归因。 */
+const analysis = computed(() => query.data.value?.analysis)
+
+/**
+ * 将后端回退层级转成业务标签,未知值保持原文。
+ * @param target 后端建议回退层级
+ * @returns 中文标签
+ */
+function rollbackLabel(target: VideoQualityRollbackTarget) {
+ const labels: Record = {
+ identity_reference: '主体身份母版',
+ subject_reference: '形态参考图',
+ keyframe: '主首帧',
+ motion_plan: '运动计划',
+ video_prompt: '视频提示词',
+ provider: '视频模型'
+ }
+ return labels[target] ?? target
+}
+
+
+
+
+
+
+
+ {{ videoQualityStatusLabel(detail.status) }} · 修复 {{ detail.repairAttempt }} /
+ {{ detail.maxRepairAttempts ?? '未设置' }} · 候选 {{ detail.chain.length }}
+
+ 当前镜头尚无质量链记录。
+
+
+ {{ item.videoId }}
+ 第 {{ item.repairAttempt }} 代
+ {{ item.providerStatus }} ·
+ {{
+ item.validationPassed === true
+ ? '校验通过'
+ : item.validationPassed === false
+ ? '校验未通过'
+ : '尚未校验'
+ }}
+ {{ formatDate(item.updatedAt) }}
+
+
+ -
+ {{ issue.frameLabel ? `${issue.frameLabel} · ` : '' }}{{ issue.description }}
+
+
+
+
+ {{ analysis.summary }}
+
+ 建议检查:{{ analysis.recommendedRollback.map(rollbackLabel).join('、') }}
+
+
+
+ {{ issue.type }} · 出现 {{ issue.occurrences }} 次
+ {{ issue.suspectedCause }}
+
+
+
+
+
diff --git a/src/features/production/diagnostics-api.ts b/src/features/production/diagnostics-api.ts
new file mode 100644
index 0000000..4738e82
--- /dev/null
+++ b/src/features/production/diagnostics-api.ts
@@ -0,0 +1,28 @@
+import { request } from '../../lib/http'
+import type { VideoQualityDetail, VideoQualityExhaustionAnalysis } from './diagnostics.types'
+
+/** 视频诊断只读取持久化记录,不触发视觉模型或 Provider。 */
+export const videoDiagnosticsApi = {
+ /**
+ * 查询指定镜头的完整视频质量链。
+ * @param shotId 正式镜头 ID
+ * @param signal 取消信号
+ * @returns 包含问题详情的质量链
+ */
+ qualityDetail: (shotId: string, signal?: AbortSignal) =>
+ request(
+ `/storyboard-shots/${encodeURIComponent(shotId)}/videos/quality-status?detail=true`,
+ { signal }
+ ),
+ /**
+ * 查询自动修复耗尽后的确定性失败归因。
+ * @param shotId 正式镜头 ID
+ * @param signal 取消信号
+ * @returns 后端实际失败归因和建议回退层级
+ */
+ exhaustionAnalysis: (shotId: string, signal?: AbortSignal) =>
+ request(
+ `/storyboard-shots/${encodeURIComponent(shotId)}/videos/quality-exhaustion-analysis`,
+ { signal }
+ )
+}
diff --git a/src/features/production/diagnostics.types.ts b/src/features/production/diagnostics.types.ts
new file mode 100644
index 0000000..82e6344
--- /dev/null
+++ b/src/features/production/diagnostics.types.ts
@@ -0,0 +1,70 @@
+import type { QualityIssue } from './quality.types'
+import type { ShotVideoQualityStatus } from './types'
+
+/** 修复耗尽后后端建议回退的上游层级。 */
+export type VideoQualityRollbackTarget =
+ | 'identity_reference'
+ | 'subject_reference'
+ | 'keyframe'
+ | 'motion_plan'
+ | 'video_prompt'
+ | 'provider'
+
+/** 多轮视频中反复出现的质量问题,以后端实际归因为准。 */
+export interface PersistentVideoQualityIssue {
+ /** 原始问题类型。 */
+ type: string
+ /** 累计出现次数。 */
+ occurrences: number
+ /** 出现该问题的候选代数。 */
+ generations: number[]
+ /** 实际失败描述。 */
+ descriptions: string[]
+ /** 后端疑似原因。 */
+ suspectedCause: string
+ /** 后端建议回退层级。 */
+ recommendedRollback: VideoQualityRollbackTarget[]
+}
+
+/** 确定性失败归因结果,查询不会重新执行模型。 */
+export interface VideoQualityExhaustionAnalysis {
+ /** 正式镜头 ID。 */
+ shotId: string
+ /** 当前链是否耗尽。 */
+ exhausted: boolean
+ /** 质量链候选数量。 */
+ generations: number
+ /** 未通过的候选数量。 */
+ failedGenerations: number
+ /** 后端判定的持续问题。 */
+ persistentIssues: PersistentVideoQualityIssue[]
+ /** 建议回退层级集合。 */
+ recommendedRollback: VideoQualityRollbackTarget[]
+ /** 是否需要人工检查。 */
+ requiresManualReview: boolean
+ /** 后端摘要。 */
+ summary: string
+}
+
+/** 已有公开质量状态中的候选基础字段。 */
+type VideoQualityChainBase = ShotVideoQualityStatus['chain'][number]
+
+/** 单个候选的持久化质量记录。 */
+export interface VideoQualityChainItem extends VideoQualityChainBase {
+ /** 本次视觉校验的问题详情。 */
+ issues: QualityIssue[]
+ /** 错误数量。 */
+ errorCount: number
+ /** 警告数量。 */
+ warningCount: number
+}
+
+/** 请求 detail=true 时的完整质量链。 */
+export interface VideoQualityDetail extends Omit {
+ /** 最近一次质量问题。 */
+ issues: QualityIssue[]
+ /** 当前失败链的实际记录。 */
+ chain: VideoQualityChainItem[]
+ /** 耗尽后的确定性归因,未耗尽时为空。 */
+ exhaustionAnalysis: VideoQualityExhaustionAnalysis | null
+}
diff --git a/src/features/production/quality-api.ts b/src/features/production/quality-api.ts
index 26a938c..b23b5ce 100644
--- a/src/features/production/quality-api.ts
+++ b/src/features/production/quality-api.ts
@@ -3,7 +3,8 @@ import type {
ImageProviderCapability,
KeyframeRepair,
KeyframeValidation,
- QualityBatchResult,
+ KeyframeQualityStart,
+ KeyframeValidationHistoryItem,
QualityInput,
ShotProviderCapability,
VideoValidation,
@@ -19,9 +20,16 @@ export const qualityApi = {
),
providers: (signal?: AbortSignal) =>
request('/image-providers/capabilities', { signal }),
- capability: (shotId: string, signal?: AbortSignal) =>
+ /**
+ * 只读检查本次选择模型的实际参考图规划能力。
+ * @param shotId 正式镜头 ID
+ * @param signal 取消信号
+ * @param provider 本次明确选择的模型
+ * @returns 后端实际能力和参考图规划
+ */
+ capability: (shotId: string, signal?: AbortSignal, provider?: string) =>
request(
- `/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability`,
+ `/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability${provider ? `?provider=${encodeURIComponent(provider)}` : ''}`,
{ signal }
),
validateKeyframe: (shotId: string, assetId: string, allowedTexts: string[]) =>
@@ -43,8 +51,26 @@ export const qualityApi = {
`/storyboard-shots/${encodeURIComponent(shotId)}/videos/${encodeURIComponent(assetId)}/validate`,
{ method: 'POST', body: { allowedTexts }, timeoutMs: 0 }
),
+ /**
+ * 只读查询指定首帧的已有校验历史。
+ * @param shotId 正式镜头 ID
+ * @param keyframeId 指定首帧 ID
+ * @param signal 取消信号
+ * @returns 后端保存的校验记录列表
+ */
+ keyframeHistory: (shotId: string, keyframeId: string, signal?: AbortSignal) =>
+ request(
+ `/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/validations`,
+ { signal }
+ ),
+ /**
+ * 启动后台首帧质量生成,不把任务开始当作视觉通过。
+ * @param projectId 正式项目 ID
+ * @param input 已确认的镜头、模型和费用范围
+ * @returns 真实后台任务观察句柄
+ */
generate: (projectId: string, input: QualityInput) =>
- request(`/projects/${encodeURIComponent(projectId)}/keyframes/generate-quality`, {
+ request(`/projects/${encodeURIComponent(projectId)}/keyframes/generate-quality`, {
method: 'POST',
body: input,
timeoutMs: 0
diff --git a/src/features/production/quality.ts b/src/features/production/quality.ts
index 16fa27b..ca18c47 100644
--- a/src/features/production/quality.ts
+++ b/src/features/production/quality.ts
@@ -1,7 +1,14 @@
import { reactive } from 'vue'
import { validOptionalSize } from './model'
import type { KeyframeReadiness } from './types'
-import type { QualityInput, QualityReceipt, QualityTarget, VisualValidation, VideoValidation } from './quality.types'
+import type {
+ QualityBatchResult,
+ QualityInput,
+ QualityReceipt,
+ QualityTarget,
+ VisualValidation,
+ VideoValidation
+} from './quality.types'
/** 未返回的操作不显示上次成功结论;网络失败不会自动重发。 */
const sessions = reactive<
@@ -13,7 +20,7 @@ export function qualityKey(projectId: string, target: QualityTarget | null) {
return JSON.stringify([
projectId,
target?.kind,
- target && ('assetId' in target ? [target.shotId, target.assetId] : target.episodeNo)
+ target && ('assetId' in target ? [target.shotId, target.assetId] : [target.episodeNo, target.shotId])
])
}
@@ -44,21 +51,56 @@ export function validQualityInput(input: QualityInput) {
)
}
-/** 与后端保持同一优先级:全项目有过期项时先筛过期,再按当前集筛选。 */
+/**
+ * 按真实后端就绪结果、剧集与指定镜头过滤,过期与缺失项均保留。
+ * @param readiness 后端就绪列表
+ * @param input 已确认的批次参数
+ * @returns 实际候选镜头
+ */
export function qualityTargets(readiness: KeyframeReadiness, input: QualityInput) {
return readiness.items
.filter(
item =>
item.status === 'ready' &&
- (input.force ||
- (readiness.stalePrimaryKeyframe > 0
- ? item.primaryKeyframeStale === true
- : !item.primaryKeyframeId)) &&
- item.episodeNo === input.episodeNo
+ item.episodeNo === input.episodeNo &&
+ (!input.shotId || item.shotId === input.shotId)
)
.slice(0, input.limit)
}
+/**
+ * 解析数据库 JSON 校验结论;原始模型文字不能代替真实结构化结果。
+ * @param output 历史任务输出
+ * @returns 完整视觉结论或空值
+ */
+export function parseKeyframeValidationOutput(output: unknown): VisualValidation | null {
+ try {
+ const value: unknown = typeof output === 'string' ? JSON.parse(output) : output
+ return isVisualValidation(value) ? value : null
+ } catch {
+ return null
+ }
+}
+
+/**
+ * 区分最终逐镜回执与 202 句柄,防止后台开始被显示为完成。
+ * @param value 后端任务最终结果
+ * @returns 是否具有完整计数和逐镜结果
+ */
+export function isQualityBatchResult(value: unknown): value is QualityBatchResult {
+ if (!value || typeof value !== 'object') return false
+ const item = value as QualityBatchResult
+ return (
+ Array.isArray(item.results) &&
+ [item.targetCount, item.selected, item.passed, item.repairFailed, item.failed].every(
+ number => Number.isSafeInteger(number) && number >= 0
+ ) &&
+ item.results.length === item.targetCount &&
+ item.passed + item.repairFailed + item.failed === item.targetCount &&
+ item.results.every(result => typeof result.shotId === 'string' && typeof result.success === 'boolean')
+ )
+}
+
/** 最小响应校验,避免畸形响应或仅 HTTP 200 被显示成视觉通过。 */
export function isVisualValidation(value: unknown): value is VisualValidation {
if (!value || typeof value !== 'object') return false
@@ -90,11 +132,9 @@ export function sessionVideoValidation(projectId: string, shotId: string, assetI
return qualitySession(qualityKey(projectId, { kind: 'video', shotId, assetId, title: '' })).videoValidation ?? null
}
-/** 首帧暂无质量历史 GET,只用本会话后端真实回执决定是否允许人工晋升。 */
+/** 手动晋升仍只使用本会话实际校验回执,读取历史不改变晋升政策。 */
export function sessionKeyframePassed(projectId: string, shotId: string, assetId: string): boolean | null {
- const receipt = qualitySession(
- qualityKey(projectId, { kind: 'keyframe', shotId, assetId, title: '' })
- ).receipt
+ const receipt = qualitySession(qualityKey(projectId, { kind: 'keyframe', shotId, assetId, title: '' })).receipt
if (receipt?.kind === 'keyframe' && receipt.result.keyframeId === assetId) return receipt.result.passed
if (receipt?.kind !== 'repair') return null
if (receipt.result.finalKeyframeId === assetId) return receipt.result.passed
diff --git a/src/features/production/quality.types.ts b/src/features/production/quality.types.ts
index 615dca8..47f700d 100644
--- a/src/features/production/quality.types.ts
+++ b/src/features/production/quality.types.ts
@@ -1,7 +1,12 @@
/** 校验入口绑定正式镜头与资产 ID;批量默认只处理当前集。 */
export type QualityTarget =
| { kind: 'keyframe' | 'video'; shotId: string; assetId: string; title: string }
- | { kind: 'batch'; episodeNo: number; title: string }
+ | {
+ kind: 'batch'
+ /** 当前剧集 */ episodeNo: number
+ /** 指定单镜头 */ shotId?: string
+ /** 显示标题 */ title: string
+ }
/** 质量操作与普通生成独立,不复用生产面板的覆盖、并发或范围。 */
export type QualityAction = 'validate' | 'repair' | 'batch'
@@ -122,13 +127,27 @@ export interface QualityBatchResult {
/** 首帧质量生成配置;limit 强制由前端填写,避免无意执行全项目。 */
export interface QualityInput {
+ /** 本批并发数 */
concurrency: number
+ /** 每镜修复次数上限 */
maxRepairAttempts: number
+ /** 是否重做有效首帧 */
force: boolean
+ /** 固定本批剧集 */
episodeNo: number
+ /** 本批镜头上限 */
limit: number
+ /** 指定镜头,单镜头重跑固定 limit=1 */
+ shotId?: string
+ /** 图片供应方 */
+ provider?: string
+ /** 首次生成与修复共享模型参数 */
+ generationOptions?: import('../generation-config/types').GenerationOptions
+ /** 允许的画面文字 */
allowedTexts?: string[]
+ /** 输出宽度 */
width?: number
+ /** 输出高度 */
height?: number
}
@@ -141,10 +160,23 @@ export interface ImageProviderCapability {
/** 只读能力检查不切换模型;无法满足参考图数量时阻止生图。 */
export interface ShotProviderCapability {
+ /** 本次检查的图片模型。 */
provider: string
+ /** 镜头完整业务参考图候选数量。 */
referenceCount: number
+ /** 模型声明的实际输入上限。 */
maxReferenceImages: number | null
+ /** 后端规划将输入模型的图片数量。 */
+ plannedReferenceCount?: number
+ /** 转为文字约束的参考图数量。 */
+ omittedReferenceCount?: number
+ /** 是否需要参考图规划。 */
+ requiresPlanning?: boolean
+ /** 后端实际规划策略。 */
+ strategy?: string
+ /** 规划后是否满足模型能力。 */
valid: boolean
+ /** 后端实际能力或参考图规划说明。 */
message?: string
}
@@ -160,3 +192,33 @@ export type QualityReceipt =
export type VideoValidationCheck =
| { enabled: false; reason: string }
| { enabled: true; passed: boolean; summary: string; applicable?: boolean; [key: string]: unknown }
+
+/** 首帧质量后台任务启动回执,不包含最终校验结论。 */
+export interface KeyframeQualityStart {
+ /** 后台任务编号 */
+ executionId: string
+ /** 原项目编号 */
+ projectId: string
+ /** 后台已启动 */
+ status: 'running'
+ /** 本批镜头数 */
+ total: number
+}
+
+/** 已保存的只读首帧校验任务记录。 */
+export interface KeyframeValidationHistoryItem {
+ /** 校验任务编号 */
+ id: string
+ /** 任务状态,保留后端原值 */
+ status: string
+ /** 数据库保存的 JSON 输出 */
+ output: string | Record | null
+ /** 调用错误 */
+ error: string | null
+ /** 开始时间 */
+ startedAt: string | null
+ /** 结束时间 */
+ finishedAt: string | null
+ /** 创建时间 */
+ createdAt: string
+}
diff --git a/src/features/production/types.ts b/src/features/production/types.ts
index 55e8142..9de57b2 100644
--- a/src/features/production/types.ts
+++ b/src/features/production/types.ts
@@ -1,3 +1,5 @@
+import type { GenerationOptions, ResolvedGenerationConfig } from '../generation-config/types'
+
/** 项目生产链的就绪状态;进行中只会出现在视频阶段。 */
export type ProductionReadinessStatus = 'ready' | 'skipped' | 'in_progress' | 'blocked'
@@ -420,6 +422,8 @@ export interface ProductionSession {
/** 串联生产回执;completed 由后端核对全部当前有效主资产后给出。 */
export interface ProductionPipelineResult {
projectId: string
+ /** 稳定身份母版生成的实际汇总。 */
+ stableIdentityAnchorResult?: Pick
visualPromptResult?: PipelineBatchResult
subjectImageResult?: PipelineBatchResult
videoPromptResult?: PipelineBatchResult
@@ -459,7 +463,7 @@ export interface VideoInputKeyframe {
export type ProviderInputRecoveryStatus = 'not_required' | 'required' | 'variant_ready' | 'exhausted'
/** 项目当前制作阶段,与剧本创作状态分别展示。 */
-export type ProductionStage = 'subject_images' | 'keyframes' | 'videos' | 'completed'
+export type ProductionStatusStage = 'subject_images' | 'keyframes' | 'videos' | 'completed'
/** 主体参考图的公开就绪明细,阻塞原因由后端提供。 */
export interface SubjectImageReadinessItem {
@@ -487,14 +491,20 @@ export interface ProductionPlanStage {
export interface ProductionPlan {
projectId: string
providers: { image: string; video: string }
- generationConfig?: { image?: Record }
+ /** 实际解析后的图片模型与参数。 */
+ generationConfig?: { image?: ResolvedGenerationConfig }
completed: boolean
canStart: boolean
canAutoRun: boolean
entryReadiness?: { ready: boolean; reason?: string | null }
- characterIdentity?: ProductionPlanStage
- stableIdentityAnchors?: ProductionPlanStage
- stage: ProductionStage
+ /** 角色身份实际就绪汇总。 */
+ characterIdentity?: ProductionCharacterIdentityPlan
+ /** 稳定身份母版阶段与真实逐项计划。 */
+ stableIdentityAnchors?: ProductionPlanStage & {
+ /** 稳定主体的逐项就绪结果。 */
+ items?: ProductionStableIdentityItem[]
+ }
+ stage: ProductionStatusStage
hasManualBlockers: boolean
manualBlocked: number
subjectImages: ProductionPlanStage
@@ -502,6 +512,8 @@ export interface ProductionPlan {
videoPrompts: ProductionPlanStage
videos: ProductionPlanStage
details: {
+ /** 稳定身份母版的逐项计划。 */
+ stableIdentityAnchors?: ProductionStableIdentityItem[]
subjectImages: SubjectImageReadinessItem[]
keyframes: KeyframeReadinessItem[]
videoPrompts: PromptReadinessItem[]
@@ -513,7 +525,7 @@ export interface ProductionPlan {
export interface ProjectProductionStatus {
projectId: string
completed: boolean
- stage: ProductionStage
+ stage: ProductionStatusStage
subjectImages: {
total: number
current: number
@@ -619,3 +631,62 @@ export interface EpisodeAssemblyResult {
durationSeconds: number
videoUrl: string
}
+
+/** 后端允许恢复或正常停止的生产阶段。 */
+export type ProductionStage = 'subjectImages' | 'keyframes' | 'videoPrompts'
+
+/** 无消耗生产计划与实际启动共用的模型配置。 */
+export interface ProductionPlanInput {
+ /** 本轮图片模型供应方。 */
+ imageProvider?: string
+ /** 主体图片与首帧共用的图片生成参数。 */
+ imageGenerationOptions?: GenerationOptions
+ /** 本轮视频模型供应方。 */
+ videoProvider?: string
+}
+
+/** 后端生产启动范围;上限必须是大于零的整数。 */
+export interface ProductionStartInput extends ProductionPlanInput {
+ /** 从具备前置资产的阶段继续。 */
+ startFrom?: ProductionStage
+ /** 完成此阶段后正常停止;省略则允许提交视频。 */
+ stopAfter?: ProductionStage
+ /** 本轮稳定身份母版上限。 */
+ stableIdentityAnchorLimit?: number
+ /** 本轮主体图上限。 */
+ subjectImageLimit?: number
+ /** 本轮首帧上限。 */
+ keyframeLimit?: number
+ /** 本轮视频提示词上限。 */
+ videoPromptLimit?: number
+}
+
+/** 生产计划中的角色身份汇总,字段遵循后端实际返回。 */
+export interface ProductionCharacterIdentityPlan {
+ /** 角色数量。 */
+ total: number
+ /** 已锁定身份数量。 */
+ ready: number
+ /** 待处理数量。 */
+ pending: number
+ /** 生产流程可自动处理数量。 */
+ autoResolvable: number
+ /** 需要人工选角数量。 */
+ manualBlocked: number
+}
+
+/** 后端稳定身份母版计划的单个主体。 */
+export interface ProductionStableIdentityItem {
+ /** 数据库主体 ID。 */
+ subjectId: string
+ /** 主体引用标识。 */
+ subjectRef: string
+ /** 主体名称。 */
+ subjectName: string
+ /** 主体模块。 */
+ module: string
+ /** 已就绪、待生成、上游可补齐或人工阻塞。 */
+ status: 'skipped' | 'ready' | 'upstream' | 'blocked'
+ /** 后端提供的就绪或阻塞原因。 */
+ reason: string
+}
diff --git a/src/features/production/useAdvancedProduction.ts b/src/features/production/useAdvancedProduction.ts
index feff6d4..3f287f3 100644
--- a/src/features/production/useAdvancedProduction.ts
+++ b/src/features/production/useAdvancedProduction.ts
@@ -6,16 +6,26 @@ import { hasRunningImages } from '../subject-images/model'
import { getOperation, runOperation } from '../workflows/operations'
import { useWorkflowExecution } from '../workflows/execution'
import { hasRunningWorkflow } from '../workflows/selectors'
-import { errorMessage } from '../../lib/http'
+import { ApiError, errorMessage } from '../../lib/http'
import { generationConfigApi } from '../generation-config/api'
import { productionApi } from './api'
import { getProductionSession } from './model'
+import type { ProductionStartInput, ProductionStage } from './types'
-/** 使用后端计划区分可自动补齐和人工阻塞,保留项目归属及活动任务检查。 */
-export async function checkPipeline(projectId: string) {
+/**
+ * 使用后端计划区分可自动补齐和人工阻塞,保留项目归属及活动任务检查。
+ * @param projectId 当前项目 ID
+ * @param scope 已选择的生产范围
+ * @returns 无消耗计划、实际状态与同源请求参数
+ */
+export async function checkPipeline(projectId: string, scope: ProductionStartInput = {}) {
const profile = await generationConfigApi.profile(projectId)
const providers = profile
- ? { imageProvider: profile.imageProvider, videoProvider: profile.videoProvider }
+ ? {
+ imageProvider: profile.imageProvider,
+ videoProvider: profile.videoProvider,
+ imageGenerationOptions: { ...profile.imageOptions }
+ }
: undefined
const [project, checkpoints, forms, plan, status] = await Promise.all([
projectsApi.detail(projectId),
@@ -32,6 +42,8 @@ export async function checkPipeline(projectId: string) {
)
throw new Error('预检返回了其他项目的数据,请重新读取。')
const issues: string[] = []
+ if (plan.entryReadiness && !plan.entryReadiness.ready)
+ issues.push(plan.entryReadiness.reason || '项目尚未满足生产入口条件。')
if (!profile) issues.push('尚未配置项目画布与生成模型,请先在批量生产工具中保存配置。')
const shotIds = new Set(plan.details.keyframes.map(item => item.shotId))
if (
@@ -68,23 +80,56 @@ export async function checkPipeline(projectId: string) {
status,
profile,
shotCount: plan.keyframes.total,
+ input: { ...scope, ...providers } as ProductionStartInput,
checkedAt: new Date().toISOString()
}
}
-/** 预检不付费;确认后再次预检并锁住本浏览器项目,长请求不自动重发。 */
+/**
+ * 预检不付费;确认后再次预检并锁住本浏览器项目,长请求不自动重发。
+ * @returns 生产范围、预检状态及一次性提交操作
+ */
export function useAdvancedProduction() {
const context = useProjectContext()
+ /** 当前项目 ID。 */
const id = computed(() => context.project.value?.id ?? '')
+ /** 项目级操作锁。 */
const operation = computed(() => getOperation(id.value))
+ /** 项目生产回执。 */
const session = computed(() => getProductionSession(id.value))
const execution = useWorkflowExecution(id, 'production')
+ /** 正在读取预检。 */
const checking = ref(false)
+ /** 预检错误或已有任务说明。 */
const error = ref('')
/** 默认使用无视频测试模式,只有用户明确切换后才允许提交高费用视频任务。 */
const safeMode = ref(true)
+ /** 本轮有限首帧数量,保留原安全模式字段。 */
const testKeyframeLimit = ref(1)
+ /** 恢复起点;留空从默认入口开始。 */
+ const startFrom = ref(null)
+ /** 显式结束阶段;安全模式下为空时默认在视频提示词后停止。 */
+ const stopAfter = ref(null)
+ /** 本轮稳定身份母版上限。 */
+ const stableIdentityAnchorLimit = ref(1)
+ /** 本轮主体图片上限。 */
+ const subjectImageLimit = ref(1)
+ /** 本轮视频提示词上限。 */
+ const videoPromptLimit = ref(1)
+ /** 可供界面和确认描述共用的生产范围。 */
+ const scope = computed(() => ({
+ ...(startFrom.value ? { startFrom: startFrom.value } : {}),
+ ...(stopAfter.value || safeMode.value ? { stopAfter: stopAfter.value ?? 'videoPrompts' } : {}),
+ stableIdentityAnchorLimit: stableIdentityAnchorLimit.value ?? 0,
+ subjectImageLimit: subjectImageLimit.value ?? 0,
+ keyframeLimit: testKeyframeLimit.value ?? 0,
+ videoPromptLimit: videoPromptLimit.value ?? 0
+ }))
+ /** 阶段顺序与后端正整数约束。 */
+ const scopeError = computed(() => validateProductionScope(scope.value))
+ /** 已读取的预检与其不可变请求快照。 */
const check = ref> | null>(null)
+ /** 当前项目不可提交条件。 */
const blocked = computed(
() =>
!id.value ||
@@ -106,15 +151,27 @@ export function useAdvancedProduction() {
checking.value = false
})
+ watch(
+ [scope, safeMode],
+ () => {
+ version++
+ check.value = null
+ checking.value = false
+ error.value = ''
+ },
+ { deep: true, flush: 'sync' }
+ )
+
+ /** 只读取无消耗计划,保存此次范围与模型参数。 */
async function preflight() {
- if (blocked.value || checking.value) return
+ if (blocked.value || checking.value || scopeError.value) return
const current = ++version
const projectId = id.value
checking.value = true
check.value = null
error.value = ''
try {
- const result = await checkPipeline(projectId)
+ const result = await checkPipeline(projectId, scope.value)
if (current === version && id.value === projectId) check.value = result
} catch (cause) {
if (current === version) error.value = errorMessage(cause)
@@ -123,9 +180,11 @@ export function useAdvancedProduction() {
}
}
+ /** 确认后校验参数快照并提交一次;冲突时观察现有任务。 */
async function start() {
if (
blocked.value ||
+ !!scopeError.value ||
checking.value ||
!check.value ||
check.value.projectId !== id.value ||
@@ -134,36 +193,49 @@ export function useAdvancedProduction() {
return
const projectId = id.value
const target = getProductionSession(projectId)
+ const confirmedInput = JSON.stringify(check.value.input)
+ const confirmedVersion = version
let submitted = false
await runOperation(projectId, '高级串联生产', async () => {
- const result = await checkPipeline(projectId)
+ const result = await checkPipeline(projectId, scope.value)
if (
+ confirmedVersion !== version ||
disposed ||
id.value !== projectId ||
context.project.value?.status !== 'completed' ||
context.error.value
)
return
+ if (JSON.stringify(result.input) !== confirmedInput) {
+ check.value = null
+ throw new Error('项目模型或图片参数已变化,请重新预检并确认费用。')
+ }
check.value = result
if (result.issues.length) throw new Error('提交前预检发现条件变化,未启动生产。请处理下方问题。')
target.pipelineReceipt = null
submitted = true
- const started = await productionApi.startPipeline(projectId, {
- ...(result.profile
- ? {
- imageProvider: result.profile.imageProvider,
- videoProvider: result.profile.videoProvider
- }
- : {}),
- ...(safeMode.value
- ? {
- stopAfter: 'videoPrompts' as const,
- ...(testKeyframeLimit.value ? { keyframeLimit: testKeyframeLimit.value } : {})
- }
- : {})
- })
+ let started
+ try {
+ started = await productionApi.startPipeline(projectId, result.input)
+ } catch (cause) {
+ if (
+ cause instanceof ApiError &&
+ cause.status === 409 &&
+ cause.details &&
+ typeof cause.details === 'object' &&
+ 'executionId' in cause.details &&
+ typeof cause.details.executionId === 'string' &&
+ cause.details.executionId
+ ) {
+ if (!disposed && id.value === projectId)
+ error.value = '已有任务:已附着当前生产后台任务,请等待其结束。'
+ await execution.track(cause.details.executionId, projectId)
+ return
+ }
+ throw cause
+ }
if (!started.executionId) throw new Error('后端未返回 Production executionId,请勿重复提交。')
- await execution.track(started.executionId)
+ await execution.track(started.executionId, projectId)
})
if (!disposed && id.value === projectId) {
if (submitted) check.value = null
@@ -194,17 +266,48 @@ export function useAdvancedProduction() {
blocked,
safeMode,
testKeyframeLimit,
+ startFrom,
+ stopAfter,
+ stableIdentityAnchorLimit,
+ subjectImageLimit,
+ videoPromptLimit,
+ scope,
+ scopeError,
preflight,
start
}
}
-/** WorkflowExecution.result 只在完成后转成串联生产回执,运行中绝不伪造完成状态。 */
-function targetPipelineReceipt(
- projectId: string,
- result: object,
- session: ReturnType
-) {
+/**
+ * 完成任务结果只在项目归属正确时保存为回执。
+ * @param projectId 当前项目 ID
+ * @param result 后端真实完成结果
+ * @param session 当前项目回执容器
+ */
+function targetPipelineReceipt(projectId: string, result: object, session: ReturnType) {
if (!projectId || !('projectId' in result) || result.projectId !== projectId) return
session.pipelineReceipt = result as import('./types').ProductionPipelineResult
}
+
+/**
+ * 验证后端阶段枚举、顺序和本轮生成上限。
+ * @param input 本轮启动范围
+ * @returns 可直接展示的阻断原因;空字符串表示有效
+ */
+export function validateProductionScope(input: ProductionStartInput): string {
+ const stages: ProductionStage[] = ['subjectImages', 'keyframes', 'videoPrompts']
+ if (
+ (input.startFrom && !stages.includes(input.startFrom)) ||
+ (input.stopAfter && !stages.includes(input.stopAfter))
+ )
+ return '请选择有效的生产阶段。'
+ if (input.startFrom && input.stopAfter && stages.indexOf(input.startFrom) > stages.indexOf(input.stopAfter))
+ return '结束阶段不能早于起始阶段。'
+ if (
+ [input.stableIdentityAnchorLimit, input.subjectImageLimit, input.keyframeLimit, input.videoPromptLimit].some(
+ value => value !== undefined && (!Number.isInteger(value) || value <= 0)
+ )
+ )
+ return '所有生成上限必须是大于 0 的整数。'
+ return ''
+}
diff --git a/src/features/production/useProduction.ts b/src/features/production/useProduction.ts
index 939fc8e..0b1f8a6 100644
--- a/src/features/production/useProduction.ts
+++ b/src/features/production/useProduction.ts
@@ -1,7 +1,9 @@
+import type { KeyframeBatchResult } from './types'
+import type { PromptBatchResult } from '../storyboard/types'
import { computed, ref, watch } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { useProjectContext } from '../projects/context'
-import { mergeDesignedShots } from '../storyboard/model'
+import { currentEpisodeSource, getStoryboardSession, mergeDesignedShots } from '../storyboard/model'
import { storyboardApi } from '../storyboard/api'
import { breakdownSnapshot } from '../workflows/selectors'
import { getOperation, runOperation } from '../workflows/operations'
@@ -17,22 +19,37 @@ export type ProductionCommand = 'prompts' | 'keyframes' | 'videos' | 'retry-vide
/** 镜头生产页的查询、筛选、就绪状态与批量操作。 */
export function useProduction() {
const context = useProjectContext()
+ /** 当前工作区的响应式状态或派生业务条件。 */
const id = computed(() => context.project.value?.id ?? '')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const selectedEpisode = ref()
+ /** 当前工作区的响应式状态或派生业务条件。 */
const selectedShot = ref('')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const concurrency = ref(2)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const force = ref(false)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const keyframeLimit = ref('')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const keyframeWidth = ref('')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const keyframeHeight = ref('')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const promptLimit = ref(1)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const videoLimit = ref(1)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const videoRepairAttempts = ref(2)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const videoInputMode = ref('all')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const snapshot = computed(() => breakdownSnapshot(context.checkpoints.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const sourceEpisodes = computed(
() => snapshot.value?.storyboardEpisodeShots ?? snapshot.value?.breakdownResult?.storyboardEpisodeShots ?? []
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const episodeOptions = computed(() => {
const entries = new Map(context.project.value?.episodes.map(episode => [episode.episode, episode.title]) ?? [])
for (const episode of sourceEpisodes.value) {
@@ -42,12 +59,14 @@ export function useProduction() {
.map(([episodeNo, title]) => ({ episodeNo, title }))
.toSorted((a, b) => a.episodeNo - b.episodeNo)
})
+ /** 当前工作区的响应式状态或派生业务条件。 */
const episodeNo = computed(
() =>
episodeOptions.value.find(item => item.episodeNo === selectedEpisode.value)?.episodeNo ??
episodeOptions.value[0]?.episodeNo ??
0
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const queryKey = computed(() => JSON.stringify([id.value, episodeNo.value, force.value]))
/** 生产页已有刷新按钮,就绪状态改为手动更新。 */
const query = usePolling(
@@ -80,23 +99,48 @@ export function useProduction() {
},
false
)
- const source = computed(() => sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
+ /** 重生成后不拿旧剧情快照补充新的正式镜头。 */
+ const source = computed(() =>
+ currentEpisodeSource(
+ id.value,
+ episodeNo.value,
+ sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value)
+ )
+ )
+ /** 未取得重生成后的正文时,只展示正式镜头编号,不填充旧剧情或时长。 */
+ const episodeSourceUnavailable = computed(
+ () => !!getStoryboardSession(id.value).invalidatedEpisodeSources[episodeNo.value]
+ )
+ /** 当前工作区的响应式状态或派生业务条件。 */
const shots = computed(() => mergeDesignedShots(query.data.value?.directions ?? null, null, source.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const shot = computed(() => shots.value.find(item => item.shotId === selectedShot.value) ?? shots.value[0])
+ /** 当前工作区的响应式状态或派生业务条件。 */
const promptItem = computed(() => query.data.value?.prompts.items.find(item => item.shotId === shot.value?.shotId))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const keyframeItem = computed(() =>
query.data.value?.keyframes.items.find(item => item.shotId === shot.value?.shotId)
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const videoItem = computed(() => query.data.value?.videos.items.find(item => item.shotId === shot.value?.shotId))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const videoStatusItem = computed(() =>
query.data.value?.videoStatus.items.find(item => item.shotId === shot.value?.shotId)
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const operation = computed(() => getOperation(id.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const session = computed(() => getProductionSession(id.value))
+ /** 普通首帧后台观察器,刷新页面后恢复真实执行状态。 */
+ const keyframeExecution = useWorkflowExecution(id, 'keyframe-generation')
const promptExecution = useWorkflowExecution(id, 'video-prompt')
const videoExecution = useWorkflowExecution(id, 'video-quality')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const promptValid = computed(() => Number.isSafeInteger(promptLimit.value) && (promptLimit.value ?? 0) > 0)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const keyframeValid = computed(
() =>
(keyframeLimit.value === '' || (Number.isSafeInteger(keyframeLimit.value) && keyframeLimit.value > 0)) &&
@@ -110,6 +154,7 @@ export function useProduction() {
Number.isSafeInteger(videoRepairAttempts.value) &&
(videoRepairAttempts.value ?? 0) > 0
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const blocked = computed(
() =>
operation.value.pending ||
@@ -128,13 +173,39 @@ export function useProduction() {
if ((status === 'completed' || status === 'failed') && status !== previous) void query.refresh()
}
)
+ /** 观察后台状态变化并同步正式资产。 */
watch(
() => promptExecution.query.data.value?.status,
(status, previous) => {
+ const record = promptExecution.query.data.value
+ if (status === 'completed' && record?.projectId === id.value && record.result) {
+ const result = record.result as unknown as PromptBatchResult
+ if (typeof result.total === 'number' && Array.isArray(result.failures)) {
+ getProductionSession(record.projectId).receipt = {
+ kind: 'prompts',
+ title: '项目视频提示词',
+ result
+ }
+ }
+ }
if ((status === 'completed' || status === 'failed') && status !== previous) void query.refresh()
}
)
+ /** 普通首帧任务完成后才展示后端回执;失败仍刷新已经保存的资产。 */
+ watch(
+ () => keyframeExecution.query.data.value,
+ record => {
+ if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
+ if (record.status === 'completed' && record.result) {
+ const result = record.result as unknown as KeyframeBatchResult
+ if (typeof result.total !== 'number' || !Array.isArray(result.failures)) return
+ getProductionSession(record.projectId).receipt = { kind: 'keyframes', title: '项目首帧生成', result }
+ }
+ void query.refresh()
+ }
+ )
+
/** 批量操作只向就绪镜头提交;最终资产状态由轮询查询确认。 */
async function run(command: ProductionCommand) {
if (
@@ -172,21 +243,18 @@ export function useProduction() {
episodeNo: episodeNo.value,
limit: promptLimit.value ?? undefined
})
- await promptExecution.track(started.executionId)
+ await promptExecution.track(started.executionId, projectId)
} else if (command === 'keyframes') {
- target.receipt = {
- kind: 'keyframes',
- title: labels[command],
- result: await productionApi.generateKeyframes(projectId, {
- ...input,
- // 有 stale 时由后端优先处理全部 stale;否则只补当前剧集,避免误跑整个项目。
- ...(force.value || staleKeyframes > 0 ? {} : { episodeNo: episodeNo.value }),
- ...(keyframeLimit.value === '' ? {} : { limit: keyframeLimit.value }),
- ...(keyframeWidth.value === '' || keyframeHeight.value === ''
- ? {}
- : { width: keyframeWidth.value, height: keyframeHeight.value })
- })
- }
+ const started = await productionApi.generateKeyframes(projectId, {
+ ...input,
+ // 有 stale 时由后端优先处理全部 stale;否则只补当前剧集,避免误跑整个项目。
+ ...(force.value || staleKeyframes > 0 ? {} : { episodeNo: episodeNo.value }),
+ ...(keyframeLimit.value === '' ? {} : { limit: keyframeLimit.value }),
+ ...(keyframeWidth.value === '' || keyframeHeight.value === ''
+ ? {}
+ : { width: keyframeWidth.value, height: keyframeHeight.value })
+ })
+ await keyframeExecution.track(started.executionId, projectId)
} else if (command === 'videos') {
const started = await productionApi.startQualityVideoExecution(projectId, {
...input,
@@ -195,7 +263,7 @@ export function useProduction() {
...(videoInputMode.value === 'all' ? {} : { inputMode: videoInputMode.value }),
maxRepairAttempts: videoRepairAttempts.value ?? 0
})
- await videoExecution.track(started.executionId)
+ await videoExecution.track(started.executionId, projectId)
} else {
target.receipt = {
kind: 'retry',
@@ -220,6 +288,7 @@ export function useProduction() {
videoItem,
videoStatusItem,
query,
+ episodeSourceUnavailable,
operation,
session,
concurrency,
@@ -237,6 +306,7 @@ export function useProduction() {
batchValid,
blocked,
run,
+ keyframeExecution,
promptExecution,
videoExecution
}
diff --git a/src/features/production/useQuality.ts b/src/features/production/useQuality.ts
index ee6ee08..9b05dd2 100644
--- a/src/features/production/useQuality.ts
+++ b/src/features/production/useQuality.ts
@@ -1,4 +1,6 @@
-import { computed, onScopeDispose } from 'vue'
+import { computed, onScopeDispose, watch } from 'vue'
+import { useWorkflowExecution } from '../workflows/execution'
+import { isQualityBatchResult } from './quality'
import { projectsApi } from '../projects/api'
import { hasRunningWorkflow } from '../workflows/selectors'
import { getOperation, runOperation } from '../workflows/operations'
@@ -26,22 +28,82 @@ function validAttempts(attempts: RepairAttempt[]) {
)
}
-/** 统一质量操作:只读预检 → 显式付费请求 → 按原目标保存回执,不自动重试。 */
+/**
+ * 只读预检后显式启动质量操作,按原目标保存回执与后台状态。
+ * @param props 当前项目、目标和阻断状态
+ * @param visible 弹窗是否仍可见
+ * @param changed 原项目资产刷新通知
+ * @param started 后台启动编号通知
+ * @returns 质量会话、任务状态与执行入口
+ */
export function useQuality(
props: { projectId: string; target: QualityTarget | null; disabled: boolean },
visible: () => boolean,
- changed: () => void
+ changed: () => void,
+ started: (executionId: string) => void = () => {}
) {
+ /** 原项目与目标共同隔离结果。 */
const key = computed(() => qualityKey(props.projectId, props.target))
+ /** 当前目标的会话回执。 */
const session = computed(() => qualitySession(key.value))
+ /** 当前项目的短操作锁。 */
const operation = computed(() => getOperation(props.projectId))
- const blocked = computed(() => props.disabled || operation.value.pending || !props.target || !props.projectId)
+ /** 按项目恢复后台句柄,关闭弹窗仍继续观察。 */
+ const execution = useWorkflowExecution(
+ computed(() => props.projectId),
+ 'keyframe-quality'
+ )
+ /** 已结束任务只写入其原始范围的回执。 */
+ const handled = new Set()
+ /** 后台任务阻止重复启动。 */
+ const blocked = computed(
+ () => props.disabled || operation.value.pending || execution.active.value || !props.target || !props.projectId
+ )
+ /** 完成后由 metadata 恢复原目标;当前目标变化不改变任务归属。 */
+ watch(
+ () => execution.query.data.value,
+ record => {
+ if (
+ !record ||
+ record.projectId !== props.projectId ||
+ record.workflowName !== 'keyframe-quality' ||
+ !['completed', 'failed'].includes(record.status) ||
+ handled.has(record.id)
+ )
+ return
+ handled.add(record.id)
+ const metadata = record.metadata
+ const episodeNo = metadata?.episodeNo
+ if (typeof episodeNo !== 'number') return
+ const target: QualityTarget = {
+ kind: 'batch',
+ episodeNo,
+ title: '',
+ ...(typeof metadata?.shotId === 'string' ? { shotId: metadata.shotId } : {})
+ }
+ const original = qualitySession(qualityKey(record.projectId, target))
+ if (record.status === 'failed') original.error = record.error || '首帧质量后台任务失败,请核对已完成资产。'
+ else if (
+ isQualityBatchResult(record.result) &&
+ record.result.results.every(item => !target.shotId || item.shotId === target.shotId) &&
+ (typeof metadata?.limit !== 'number' || record.result.targetCount <= metadata.limit)
+ )
+ original.receipt = { kind: 'batch', result: record.result }
+ else original.error = '后台最终回执不完整或范围不匹配,请核对资产,不要重复生成。'
+ changed()
+ }
+ )
let disposed = false
onScopeDispose(() => {
disposed = true
})
- /** 确认之后重新读取后端状态;打开弹窗和查看结果不会调用此函数。 */
+ /**
+ * 确认之后重读状态并只提交一次,固定原目标与费用范围。
+ * @param action 已确认的质量操作
+ * @param input 已确认的参数
+ * @returns 操作结束通知,后台生成由持久化任务继续跟踪
+ */
async function run(action: QualityAction, input: QualityInput) {
if (blocked.value || !visible() || !props.target || !validQualityInput(input)) return
const target = { ...props.target }
@@ -50,10 +112,20 @@ export function useQuality(
(target.kind === 'video' && action === 'repair' && input.maxRepairAttempts <= 0)
)
return
- if (target.kind === 'batch' && input.episodeNo !== target.episodeNo) return
+ if (
+ target.kind === 'batch' &&
+ (input.episodeNo !== target.episodeNo ||
+ input.shotId !== target.shotId ||
+ (target.shotId && input.limit !== 1))
+ )
+ return
const projectId = props.projectId
// 固定本次确认的参数,预检期间的表单变化不能扩大已确认的生成范围。
- input = { ...input, allowedTexts: input.allowedTexts?.slice() }
+ input = {
+ ...input,
+ allowedTexts: input.allowedTexts?.slice(),
+ generationOptions: input.generationOptions ? { ...input.generationOptions } : undefined
+ }
const originalKey = key.value
const receiptTarget = qualitySession(originalKey)
receiptTarget.receipt = null
@@ -90,11 +162,13 @@ export function useQuality(
if (!targets.length)
throw new Error(
readiness.stalePrimaryKeyframe > 0
- ? '当前集没有可更新的过期首帧;后端优先处理全项目过期项,请切换剧集。'
+ ? '当前范围没有可执行的首帧质量镜头,请刷新就绪状态。'
: '当前集没有符合条件的镜头;请补齐设计与参考图,或明确选择重做有效首帧。'
)
// 逐镜只读检查已选的小批量;任何模型能力不足都不启动本批付费流水线。
- const capabilities = await Promise.all(targets.map(item => qualityApi.capability(item.shotId)))
+ const capabilities = await Promise.all(
+ targets.map(item => qualityApi.capability(item.shotId, undefined, input.provider))
+ )
const invalid = capabilities.find(item => item.valid !== true)
if (invalid) throw new Error(invalid.message || '当前图片模型不支持所需参考图。')
const assets = await Promise.all(targets.map(item => productionApi.listKeyframes(item.shotId)))
@@ -112,22 +186,18 @@ export function useQuality(
const result = await qualityApi.generate(projectId, input)
if (
!result ||
- !Array.isArray(result.results) ||
- ![result.targetCount, result.passed, result.repairFailed, result.failed, result.selected].every(
- value => Number.isSafeInteger(value) && value >= 0
- ) ||
- result.targetCount > input.limit ||
- result.results.length !== result.targetCount ||
- result.passed + result.repairFailed + result.failed !== result.targetCount ||
- result.results.some(
- item =>
- !readiness.items.some(
- shot => shot.shotId === item.shotId && shot.episodeNo === input.episodeNo
- ) || typeof item.success !== 'boolean'
- )
+ result.projectId !== projectId ||
+ typeof result.executionId !== 'string' ||
+ !result.executionId ||
+ result.status !== 'running' ||
+ !Number.isSafeInteger(result.total) ||
+ result.total < 0 ||
+ result.total > input.limit
)
- throw new Error('质量流水线回执不完整,请先核对资产,不要重复提交。')
- receipt = { kind: 'batch', result }
+ throw new Error('后台启动回执不完整,请刷新状态,不要重复提交。')
+ await execution.track(result.executionId, projectId)
+ if (!disposed && props.projectId === projectId) started(result.executionId)
+ return
} else {
if (!readiness.items.some(item => item.shotId === target.shotId))
throw new Error('指定镜头不属于当前项目,未提交质量任务。')
@@ -245,5 +315,5 @@ export function useQuality(
// 已提交请求即使切换页面也归原会话;只刷新仍在查看的原项目。
if (!disposed && props.projectId === projectId) changed()
}
- return { key, session, operation, blocked, run }
+ return { key, session, operation, execution, blocked, run }
}
diff --git a/src/features/projects/ProjectLayout.vue b/src/features/projects/ProjectLayout.vue
index f0bbeab..34175c1 100644
--- a/src/features/projects/ProjectLayout.vue
+++ b/src/features/projects/ProjectLayout.vue
@@ -8,6 +8,7 @@ import { getOperation } from '../workflows/operations'
import { projectAccessKey, projectSectionFromPath, type ProjectAccess } from './access'
import { useProjectStageAccess } from './useProjectStageAccess'
import { useWorkflowExecution } from '../workflows/execution'
+import { clearEpisodeSourceInvalidations, invalidateEpisodeSource } from '../storyboard/model'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
@@ -23,6 +24,39 @@ const context = useProjectData(id)
provide(projectContextKey, context)
const operation = computed(() => getOperation(id.value))
const createDramaExecution = useWorkflowExecution(id, 'create-drama')
+/** 项目内跨页面继续观察首帧后台任务,维持活动锁并在真实终态后释放。 */
+useWorkflowExecution(id, 'keyframe-quality')
+/** 既有生成入口在跨页面时继续观察,保持项目活动锁。 */
+for (const workflowName of [
+ 'storyboard-direction',
+ 'storyboard-visual-state',
+ 'video-prompt',
+ 'keyframe-generation',
+ 'video-quality'
+]) {
+ useWorkflowExecution(id, workflowName)
+}
+/** 即使直接刷新到生产页,也按真实重生成任务恢复旧剧情快照的失效标记。 */
+const breakdownExecution = useWorkflowExecution(id, 'breakdown')
+/** 只有后端确认有效的新分镜才废弃旧正文,不推测未完成或失败任务。 */
+watchEffect(() => {
+ const record = breakdownExecution.query.data.value
+ if (!record || record.projectId !== id.value || record.status !== 'completed') return
+ if (record.metadata?.action !== 'regenerate-storyboard-episode') {
+ if (record.metadata?.action === 'start') clearEpisodeSourceInvalidations(record.projectId)
+ return
+ }
+ const number = record.metadata.episodeNo
+ const validation = record.result?.storyboardShotValidation
+ if (
+ typeof number === 'number' &&
+ validation &&
+ typeof validation === 'object' &&
+ 'valid' in validation &&
+ validation.valid === true
+ )
+ invalidateEpisodeSource(record.projectId, number)
+})
watchEffect(() => {
const status = createDramaExecution.query.data.value?.status
if ((status === 'completed' || status === 'failed') && context.project.value?.status === 'generating') {
@@ -135,7 +169,7 @@ onScopeDispose(() => {
>
{{ operation.label }}。可切换页面查看结果,请勿重复提交。{{ operation.label || '后台制作任务执行中' }}。可切换页面查看结果,请勿重复提交。
@@ -178,11 +212,7 @@ onScopeDispose(() => {
>刷新项目状态
-
+
diff --git a/src/features/storyboard/StoryboardPage.vue b/src/features/storyboard/StoryboardPage.vue
index 87bc4c3..779b8b2 100644
--- a/src/features/storyboard/StoryboardPage.vue
+++ b/src/features/storyboard/StoryboardPage.vue
@@ -5,17 +5,7 @@ import { integerRule } from '../../lib/form-rules'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import ActionMenu from '../../components/ui/ActionMenu.vue'
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
-import {
- NScrollbar,
- NAlert,
- NButton,
- NCheckbox,
- NInputNumber,
- NProgress,
- NSelect,
- NTab,
- NTabs
-} from 'naive-ui'
+import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NTab, NTabs } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { ArrowLeft, RefreshCw } from '@lucide/vue'
import { EmptyState } from '../../components/ui'
@@ -25,6 +15,9 @@ import GenerationReceipt from './components/GenerationReceipt.vue'
import ShotDesign from './components/ShotDesign.vue'
import ShotTools from './components/ShotTools.vue'
import BeatShotDirectory from './components/BeatShotDirectory.vue'
+import SubjectCoverageAudit from './components/SubjectCoverageAudit.vue'
+import type { SubjectCoverageIssue } from './coverage.types'
+import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
import { useStoryboard } from './useStoryboard'
import { useProjectContext } from '../projects/context'
@@ -43,6 +36,7 @@ const {
shot,
query,
data,
+ episodeSourceUnavailable,
prerequisites,
session,
operation,
@@ -54,6 +48,7 @@ const {
directionComplete,
visualStateComplete,
hasCurrentEpisodeShots,
+ executions,
run
} = useStoryboard()
const productionReady = computed(() => directionComplete.value && visualStateComplete.value)
@@ -90,6 +85,51 @@ function exportEpisode() {
}
/** 回执到达后打开诊断区;平时留出镜头检查空间。 */
const toolsOpen = ref(false)
+/** 覆盖审计只保存剧集与镜头坐标,正式 ID 从当前查询结果中定位。 */
+const auditLocation = ref(null)
+/** 覆盖定位失败时保留明确反馈,不猜测其它镜头。 */
+const auditLocationError = ref('')
+
+/**
+ * 切换到引用遗漏发生的剧集,等待正式镜头数据后定位。
+ * @param issue 后端实际覆盖问题
+ */
+function locateCoverageIssue(issue: SubjectCoverageIssue) {
+ if (!episodeOptions.value.some(episode => episode.episodeNo === issue.episodeNo)) {
+ auditLocationError.value = '审计中的剧集不在当前项目,请刷新分镜与审计结果。'
+ return
+ }
+ auditLocation.value = issue
+ auditLocationError.value = ''
+ selectedEpisode.value = issue.episodeNo
+}
+
+/** 当前集查询完成后按唯一坐标匹配正式镜头;目标缺失时不切到其他镜头。 */
+watch(
+ [episodeNo, shots, () => query.loading.value, auditLocation],
+ () => {
+ const issue = auditLocation.value
+ if (
+ !issue ||
+ query.loading.value ||
+ episodeNo.value !== issue.episodeNo ||
+ data.value?.directions.episodeNo !== issue.episodeNo
+ )
+ return
+ if (issue.shotNo !== null) {
+ const target = shots.value.find(item => item.beatNo === issue.beatNo && item.shotNo === issue.shotNo)
+ if (!target) {
+ auditLocationError.value = '目标镜头已变化,请刷新后重新检查主体引用。'
+ auditLocation.value = null
+ return
+ }
+ selectedShot.value = target.shotId
+ }
+ toolsOpen.value = false
+ auditLocation.value = null
+ },
+ { flush: 'post' }
+)
watch(
() => session.value.receipt,
receipt => {
@@ -105,6 +145,9 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
+
+ 本集镜头已重新生成。新标题和剧情详情尚未提供,当前只显示正式镜头编号;请按实际生成规格核对内容。
+
分镜设计已经准备完成,可以继续生成首帧、视频提示词和视频。
继续镜头生产 →
@@ -226,109 +269,124 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
+
+
+
{{
+ auditLocationError
+ }}
生成与恢复
-
-
-
- 00本集镜头拆解
-
-
- 只重新拆解当前选择的第
- {{ episodeNo }}
- 集,其它剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
-
-
-
-
-
-
-
- 当前集还没有可用镜头,请先完成剧本拆解。
+
+
+
+ 00本集镜头拆解
+
+
+ 只重新拆解当前选择的第
+ {{ episodeNo }}
+ 集,其它剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
-
-
-
- 01导演摄影设计
-
-
- 景别、机位、运镜与构图。正式项目生成默认跳过已完整剧集,覆盖模式会重新生成全部剧集。
-
-
-
-
-
-
-
-
-
- 02即时视觉状态
-
-
- 表情、姿态、位置、环境与连续性。每集需要完整导演设计;批量中缺少前置设计的剧集会单独报错。
-
-
-
-
-
-
-
- 修改或覆盖前面的设计后,已有状态和视频提示词不会自动更新;请按顺序重新生成后续内容。自动修复次数仅用于
- VisualState。
-
-
- 视频提示词批量操作
-
- 生成前会检查镜头设计和主体参考图是否齐全。这里只生成提示词;首帧、视频任务、状态检查与失败重试已整理到
- 镜头生产。
-
-
-
-
+
+
+
+
+
+ 当前集还没有可用镜头,请先完成剧本拆解。
+
+
+
+
+ 01导演摄影设计
+
+
+ 景别、机位、运镜与构图。正式项目生成默认跳过已完整剧集,覆盖模式会重新生成全部剧集。
+
+
+
+
+
+
+
+
+
+ 02即时视觉状态
+
+
+ 表情、姿态、位置、环境与连续性。每集需要完整导演设计;批量中缺少前置设计的剧集会单独报错。
+
+
+
+
+
+
+
+ 修改或覆盖前面的设计后,已有状态和视频提示词不会自动更新;请按顺序重新生成后续内容。自动修复次数仅用于
+ VisualState。
+
+
+ 视频提示词批量操作
+
+ 生成前会检查镜头设计和主体参考图是否齐全。这里只生成提示词;首帧、视频任务、状态检查与失败重试已整理到
+ 镜头生产。
+
+
+
+
+
+
@@ -360,9 +418,9 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
>
Production 前置设计未完成。
当前导演设计 {{ data.directions.directionCount }}/{{ data.directions.shotCount }},即时视觉状态
- {{ data.visualStates.visualStateCount }}/{{ data.visualStates.shotCount }}。请先补齐后再进入镜头生产,避免
- 后续镜头制作无法开始。
-
Shot ID · {{ shot.shotId }}
-
+
标题与剧情描述取自最近可用 Breakdown 快照;以下设计与状态取自数据库。
diff --git a/src/features/storyboard/api.ts b/src/features/storyboard/api.ts
index 77ddf4c..d48754d 100644
--- a/src/features/storyboard/api.ts
+++ b/src/features/storyboard/api.ts
@@ -1,13 +1,11 @@
+import type { WorkflowExecutionStart } from '../workflows/execution.types'
import { request } from '../../lib/http'
import type {
EpisodeDirections,
EpisodeVisualStates,
- PromptBatchResult,
ShotPromptResult,
ShotReferences,
StoryboardBatchInput,
- StoryboardBatchResult,
- StoryboardShotRegenerationResult,
VisualStateBatchInput
} from './types'
import type { ShotGenerationSpec } from './generation-spec.types'
@@ -24,9 +22,14 @@ function shotPath(id: string) {
/** Storyboard 正式路由契约;测试路由不暴露为前端生产入口。 */
export const storyboardApi = {
- /** 强制重生成指定单集的镜头拆解;后端校验通过后才覆盖正式 Storyboard。 */
+ /**
+ * 后台重生成指定单集镜头,终态后再读取正式分镜。
+ * @param id 正式项目 ID
+ * @param episodeNo 目标剧集编号
+ * @returns 真实后台任务观察句柄
+ */
regenerateEpisodeShots: (id: string, episodeNo: number) =>
- request(`${projectPath(id)}/storyboard-shots/regenerate`, {
+ request(`${projectPath(id)}/storyboard-shots/regenerate`, {
method: 'POST',
body: { episodeNo },
timeoutMs: 0
@@ -35,14 +38,26 @@ export const storyboardApi = {
request(`${projectPath(id)}/storyboard-directions?episodeNo=${episodeNo}`, { signal }),
visualStates: (id: string, episodeNo: number, signal?: AbortSignal) =>
request(`${projectPath(id)}/storyboard-visual-states?episodeNo=${episodeNo}`, { signal }),
+ /**
+ * 后台生成项目导演设计。
+ * @param id 正式项目 ID
+ * @param input 并发与覆盖范围
+ * @returns 真实后台任务观察句柄
+ */
generateDirections: (id: string, input: StoryboardBatchInput) =>
- request(`${projectPath(id)}/storyboard-directions/generate`, {
+ request(`${projectPath(id)}/storyboard-directions/generate`, {
method: 'POST',
body: input,
timeoutMs: 0
}),
+ /**
+ * 后台生成项目即时状态。
+ * @param id 正式项目 ID
+ * @param input 并发、覆盖与有限修复配置
+ * @returns 真实后台任务观察句柄
+ */
generateVisualStates: (id: string, input: VisualStateBatchInput) =>
- request(`${projectPath(id)}/storyboard-visual-states/generate`, {
+ request(`${projectPath(id)}/storyboard-visual-states/generate`, {
method: 'POST',
body: input,
timeoutMs: 0
@@ -59,8 +74,14 @@ export const storyboardApi = {
body: { force },
timeoutMs: 0
}),
+ /**
+ * 后台批量生成项目视频提示词。
+ * @param id 正式项目 ID
+ * @param input 并发与覆盖参数
+ * @returns 真实后台任务观察句柄
+ */
generatePrompts: (id: string, input: StoryboardBatchInput) =>
- request(`${projectPath(id)}/video-prompts/generate`, {
+ request(`${projectPath(id)}/video-prompts/generate`, {
method: 'POST',
body: input,
timeoutMs: 0
diff --git a/src/features/storyboard/components/SubjectCoverageAudit.vue b/src/features/storyboard/components/SubjectCoverageAudit.vue
new file mode 100644
index 0000000..aa9b6b8
--- /dev/null
+++ b/src/features/storyboard/components/SubjectCoverageAudit.vue
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+ {{ result.valid ? '未发现主体引用遗漏' : `发现 ${result.issueCount} 项引用遗漏` }} ·
+ {{ result.episodeCount }} 集 / {{ result.beatCount }} 个 Beat / {{ result.shotCount }} 镜
+
+
+ 检查主体 {{ result.subjectSummary.total }} · 人物 {{ result.subjectSummary.character }} / 场景
+ {{ result.subjectSummary.scene }} / 道具 {{ result.subjectSummary.prop }}
+
+
+
+ 第 {{ issue.episodeNo }} 集 · Beat {{ issue.beatNo
+ }}{{ issue.shotNo !== null ? ` · 镜头 ${issue.shotNo}` : '' }} · {{ issue.subjectName }}
+ {{ issue.subjectRef }}
+ {{
+ issue.shotNo === null ? '查看所在剧集' : '定位镜头'
+ }}
+
+ {{ issue.message }}
+
+ 原文匹配:{{ issue.matchedTerm }} ·
+ {{
+ issue.level === 'visual_state'
+ ? '即时状态'
+ : issue.level === 'beat'
+ ? 'Beat 主体引用'
+ : '镜头主体绑定'
+ }}
+
+
+
+
+
diff --git a/src/features/storyboard/coverage-api.ts b/src/features/storyboard/coverage-api.ts
new file mode 100644
index 0000000..cfd04a1
--- /dev/null
+++ b/src/features/storyboard/coverage-api.ts
@@ -0,0 +1,14 @@
+import { request } from '../../lib/http'
+import type { SubjectCoverageAudit } from './coverage.types'
+
+/**
+ * 只读检查正式分镜的主体引用覆盖,不调用任何 Agent。
+ * @param projectId 当前正式项目 ID
+ * @param signal 取消信号
+ * @returns 后端实际覆盖审计结果
+ */
+export function auditSubjectCoverage(projectId: string, signal?: AbortSignal) {
+ return request(`/projects/${encodeURIComponent(projectId)}/storyboard/subject-coverage`, {
+ signal
+ })
+}
diff --git a/src/features/storyboard/coverage.types.ts b/src/features/storyboard/coverage.types.ts
new file mode 100644
index 0000000..6b662ea
--- /dev/null
+++ b/src/features/storyboard/coverage.types.ts
@@ -0,0 +1,61 @@
+/** 主体引用覆盖检查中的单个遗漏,不推测正式 Shot ID。 */
+export interface SubjectCoverageIssue {
+ /** 遗漏发生的层级。 */
+ level: 'beat' | 'shot' | 'visual_state'
+ /** 正式剧集编号。 */
+ episodeNo: number
+ /** Beat 编号。 */
+ beatNo: number
+ /** 镜头编号,Beat 层级为空。 */
+ shotNo: number | null
+ /** 漏引用的主体 Ref。 */
+ subjectRef: string
+ /** 主体名称。 */
+ subjectName: string
+ /** 主体模块。 */
+ module: string
+ /** 原文中匹配的用语。 */
+ matchedTerm: string
+ /** 后端问题描述。 */
+ message: string
+}
+
+/** 零费用主体引用覆盖审计的实际汇总。 */
+export interface SubjectCoverageAudit {
+ /** 当前项目正式 ID。 */
+ projectId: string
+ /** 后端是否判定引用覆盖完整。 */
+ valid: boolean
+ /** 审计的剧集数量。 */
+ episodeCount: number
+ /** 审计的 Beat 数量。 */
+ beatCount: number
+ /** 审计的镜头数量。 */
+ shotCount: number
+ /** 遗漏问题数量。 */
+ issueCount: number
+ /** 后端用于本次审计的主体快照。 */
+ subjectSnapshot: {
+ /** 正式主体 ID。 */
+ id: string
+ /** 主体引用。 */
+ ref: string
+ /** 主体名称。 */
+ name: string
+ /** 主体模块。 */
+ module: string
+ }[]
+ /** 本次审计的各类型主体数量。 */
+ subjectSummary: {
+ /** 主体总数。 */
+ total: number
+ /** 人物数量。 */
+ character: number
+ /** 场景数量。 */
+ scene: number
+ /** 道具数量。 */
+ prop: number
+ }
+ /** 真实引用遗漏列表。 */
+ issues: SubjectCoverageIssue[]
+}
diff --git a/src/features/storyboard/model.ts b/src/features/storyboard/model.ts
index e25a83f..24df633 100644
--- a/src/features/storyboard/model.ts
+++ b/src/features/storyboard/model.ts
@@ -7,9 +7,89 @@ import type { DesignedShot, EpisodeDirections, EpisodeVisualStates, StoryboardSe
/** 仅保存本会话回执和已返回的 Prompt,切换路由不丢失长请求结果。 */
const sessions = reactive>({})
+/**
+ * 恢复整个项目已失效的剧集集合,兼容隐私模式或损坏的浏览器缓存。
+ * @param projectId 正式项目 ID
+ * @returns 只包含正整数剧集编号的失效标记
+ */
+function savedEpisodeInvalidations(projectId: string): Record {
+ try {
+ if (typeof localStorage === 'undefined') return {}
+ const value: unknown = JSON.parse(
+ localStorage.getItem(`short-drama:storyboard-invalidated:${projectId}`) ?? '[]'
+ )
+ if (!Array.isArray(value)) return {}
+ return Object.fromEntries(
+ value
+ .filter(number => typeof number === 'number' && Number.isSafeInteger(number) && number > 0)
+ .map(number => [number, true])
+ )
+ } catch {
+ return {}
+ }
+}
+
/** 获取指定项目的独立回执容器。 */
export function getStoryboardSession(id: string): StoryboardSession {
- return (sessions[id] ??= { receipt: null, prompts: {}, regeneratedEpisodes: {} })
+ return (sessions[id] ??= {
+ receipt: null,
+ prompts: {},
+ regeneratedEpisodes: {},
+ invalidatedEpisodeSources: savedEpisodeInvalidations(id)
+ })
+}
+
+/**
+ * 根据真实有效终态废弃旧正文,并持久化全部剧集,隐藏任务不影响恢复。
+ * @param projectId 正式项目 ID
+ * @param episodeNo 已有效重生成的剧集编号
+ */
+export function invalidateEpisodeSource(projectId: string, episodeNo: number) {
+ if (!Number.isSafeInteger(episodeNo) || episodeNo <= 0) return
+ const session = getStoryboardSession(projectId)
+ delete session.regeneratedEpisodes[episodeNo]
+ session.invalidatedEpisodeSources = {
+ ...savedEpisodeInvalidations(projectId),
+ ...session.invalidatedEpisodeSources,
+ [episodeNo]: true
+ }
+ try {
+ if (typeof localStorage !== 'undefined')
+ localStorage.setItem(
+ `short-drama:storyboard-invalidated:${projectId}`,
+ JSON.stringify(Object.keys(session.invalidatedEpisodeSources).map(Number))
+ )
+ } catch {
+ /* 浏览器禁止存储时仍保留当前会话保护。 */
+ }
+}
+
+/**
+ * 仅可信完整重新拆解完成后清除旧失效集合。
+ * @param projectId 正式项目 ID
+ */
+export function clearEpisodeSourceInvalidations(projectId: string) {
+ getStoryboardSession(projectId).invalidatedEpisodeSources = {}
+ try {
+ if (typeof localStorage !== 'undefined')
+ localStorage.removeItem(`short-drama:storyboard-invalidated:${projectId}`)
+ } catch {
+ /* 当前会话已经清除,存储限制不会触发业务请求。 */
+ }
+}
+
+/**
+ * 重生成后不向新 Shot ID 回填旧 checkpoint 的标题、剧情或时长。
+ * @param projectId 当前正式项目 ID
+ * @param episodeNo 当前剧集编号
+ * @param fallback 未失效的原始分集快照
+ * @returns 实际正文或缺省;缺省时仅展示正式镜头编号
+ */
+export function currentEpisodeSource(projectId: string, episodeNo: number, fallback?: EpisodeShots) {
+ const session = getStoryboardSession(projectId)
+ return (
+ session.regeneratedEpisodes[episodeNo] ?? (session.invalidatedEpisodeSources[episodeNo] ? undefined : fallback)
+ )
}
/** 后端生成服务只读取最新 Breakdown;不能用历史可恢复快照冒充当前生成前置条件。 */
diff --git a/src/features/storyboard/types.ts b/src/features/storyboard/types.ts
index 7e76e01..b98e0d6 100644
--- a/src/features/storyboard/types.ts
+++ b/src/features/storyboard/types.ts
@@ -181,13 +181,25 @@ export interface DesignedShot {
/** 生成回执按操作区分,切换剧集时仍保留原始目标信息。 */
export type StoryboardReceipt =
- | { kind: 'shots'; title: string; result: StoryboardShotRegenerationResult }
+ | {
+ kind: 'shots'
+ title: string
+ result: Pick<
+ StoryboardShotRegenerationResult,
+ 'episodeNo' | 'storyboardShotSummary' | 'storyboardShotValidation'
+ >
+ }
| { kind: 'batch'; title: string; result: StoryboardBatchResult }
| { kind: 'prompts'; title: string; result: PromptBatchResult }
/** 当前浏览器会话保存回执,不将其当作持久化运行状态。 */
export interface StoryboardSession {
+ /** 当前真实操作回执。 */
receipt: StoryboardReceipt | null
+ /** 按正式镜头缓存的实际视频提示词。 */
prompts: Record
+ /** 已实际返回的重生成分集正文,缺少正文时不构造缓存。 */
regeneratedEpisodes: Record
+ /** 已重生成且旧 checkpoint 正文不再可信的剧集。 */
+ invalidatedEpisodeSources: Record
}
diff --git a/src/features/storyboard/useStoryboard.ts b/src/features/storyboard/useStoryboard.ts
index e314ad8..1aee679 100644
--- a/src/features/storyboard/useStoryboard.ts
+++ b/src/features/storyboard/useStoryboard.ts
@@ -1,10 +1,18 @@
-import { computed, ref } from 'vue'
+import { useWorkflowExecution } from '../workflows/execution'
+import type { StoryboardBatchResult, PromptBatchResult, StoryboardShotRegenerationResult } from './types'
+import { computed, ref, watch } from 'vue'
import { useQuery } from '../../composables/useQuery'
import { useProjectContext } from '../projects/context'
import { breakdownSnapshot } from '../workflows/selectors'
import { getOperation, runOperation } from '../workflows/operations'
import { storyboardApi } from './api'
-import { getStoryboardSession, mergeDesignedShots, storyboardPrerequisites } from './model'
+import {
+ currentEpisodeSource,
+ getStoryboardSession,
+ invalidateEpisodeSource,
+ mergeDesignedShots,
+ storyboardPrerequisites
+} from './model'
/** 分镜页只提供正式主流程命令,不暴露后端测试路由。 */
export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all' | 'prompts'
@@ -12,16 +20,25 @@ export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all'
/** 分镜查询、依赖判断与操作入口;不修改后端 graph。 */
export function useStoryboard() {
const context = useProjectContext()
+ /** 当前工作区的响应式状态或派生业务条件。 */
const id = computed(() => context.project.value?.id ?? '')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const selectedEpisode = ref()
+ /** 当前工作区的响应式状态或派生业务条件。 */
const selectedShot = ref('')
+ /** 当前工作区的响应式状态或派生业务条件。 */
const concurrency = ref(2)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const maxRepairAttempts = ref(2)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const force = ref(false)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const snapshot = computed(() => breakdownSnapshot(context.checkpoints.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const sourceEpisodes = computed(
() => snapshot.value?.storyboardEpisodeShots ?? snapshot.value?.breakdownResult?.storyboardEpisodeShots ?? []
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const episodeOptions = computed(() => {
const entries = new Map(context.project.value?.episodes.map(episode => [episode.episode, episode.title]) ?? [])
for (const episode of sourceEpisodes.value) {
@@ -31,12 +48,14 @@ export function useStoryboard() {
.map(([episodeNo, title]) => ({ episodeNo, title }))
.toSorted((a, b) => a.episodeNo - b.episodeNo)
})
+ /** 当前工作区的响应式状态或派生业务条件。 */
const episodeNo = computed(
() =>
episodeOptions.value.find(item => item.episodeNo === selectedEpisode.value)?.episodeNo ??
episodeOptions.value[0]?.episodeNo ??
0
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const queryKey = computed(() => JSON.stringify([id.value, episodeNo.value]))
/** 分镜页仅在进入、切换剧集或显式刷新时读取。 */
const query = useQuery(queryKey, async (key, signal) => {
@@ -57,21 +76,33 @@ export function useStoryboard() {
return { directions, visualStates }
})
const data = query.data
+ /** 当前工作区的响应式状态或派生业务条件。 */
const session = computed(() => getStoryboardSession(id.value))
/** 单集重生成返回的是最新镜头正文,优先于不会随局部覆盖更新的历史 Breakdown 快照。 */
- const source = computed(
- () =>
- session.value.regeneratedEpisodes[episodeNo.value] ??
+ const source = computed(() =>
+ currentEpisodeSource(
+ id.value,
+ episodeNo.value,
sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value)
+ )
)
+ /** 重生成接口未返回新正文时,明确标记辅助剧情信息不可用。 */
+ const episodeSourceUnavailable = computed(() => !!session.value.invalidatedEpisodeSources[episodeNo.value])
+ /** 当前工作区的响应式状态或派生业务条件。 */
const shots = computed(() =>
mergeDesignedShots(data.value?.directions ?? null, data.value?.visualStates ?? null, source.value)
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const shot = computed(() => shots.value.find(item => item.shotId === selectedShot.value) ?? shots.value[0])
+ /** 当前工作区的响应式状态或派生业务条件。 */
const prerequisites = computed(() => storyboardPrerequisites(context.checkpoints.value, episodeNo.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const operation = computed(() => getOperation(id.value))
+ /** 当前工作区的响应式状态或派生业务条件。 */
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const repairsValid = computed(() => Number.isSafeInteger(maxRepairAttempts.value) && maxRepairAttempts.value >= 0)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const blocked = computed(
() =>
operation.value.pending ||
@@ -81,18 +112,21 @@ export function useStoryboard() {
context.project.value?.status !== 'completed' ||
prerequisites.value.breakdownRunning
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const directionComplete = computed(
() =>
!!data.value?.directions.shotCount &&
data.value.directions.directionCount === data.value.directions.shotCount &&
data.value.directions.coverage === 1
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const visualStateComplete = computed(
() =>
!!data.value?.visualStates.shotCount &&
data.value.visualStates.visualStateCount === data.value.visualStates.shotCount &&
data.value.visualStates.coverage === 1
)
+ /** 当前工作区的响应式状态或派生业务条件。 */
const hasCurrentEpisodeShots = computed(
() => Math.max(data.value?.directions.shotCount ?? 0, data.value?.visualStates.shotCount ?? 0) > 0
)
@@ -103,6 +137,54 @@ export function useStoryboard() {
prompts: !blocked.value && shots.value.length > 0 && batchValid.value
}))
+ /** 正式后台任务观察器;重生成使用后端 breakdown 名称并通过 metadata 区分。 */
+ const executions = [
+ { title: '单集镜头重生成', observer: useWorkflowExecution(id, 'breakdown') },
+ { title: '项目导演设计', observer: useWorkflowExecution(id, 'storyboard-direction') },
+ { title: '项目即时状态', observer: useWorkflowExecution(id, 'storyboard-visual-state') },
+ { title: '项目视频提示词', observer: useWorkflowExecution(id, 'video-prompt') }
+ ]
+ /** 真实终态结果才发布回执;刷新恢复也按后端 metadata 归属。 */
+ for (const [index, entry] of executions.entries()) {
+ watch(
+ () => entry.observer.query.data.value,
+ record => {
+ if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
+ const target = getStoryboardSession(record.projectId)
+ if (index === 0 && record.metadata?.action !== 'regenerate-storyboard-episode') return
+ if (record.status === 'completed' && record.result) {
+ if (index === 0) {
+ const result = record.result as unknown as StoryboardShotRegenerationResult
+ const number = record.metadata?.episodeNo
+ if (
+ typeof number !== 'number' ||
+ result.episodeNo !== number ||
+ !result.storyboardShotValidation ||
+ !result.storyboardShotSummary
+ )
+ return
+ target.receipt = { kind: 'shots', title: `第 ${number} 集镜头`, result }
+ if (result.storyboardShotValidation.valid) {
+ delete target.regeneratedEpisodes[number]
+ invalidateEpisodeSource(record.projectId, number)
+ target.prompts = {}
+ if (episodeNo.value === number) selectedShot.value = ''
+ }
+ } else if (index === 3) {
+ const result = record.result as unknown as PromptBatchResult
+ if (typeof result.failed !== 'number') return
+ target.receipt = { kind: 'prompts', title: entry.title, result }
+ } else {
+ const result = record.result as unknown as StoryboardBatchResult
+ if (result.projectId !== record.projectId || !Array.isArray(result.episodes)) return
+ target.receipt = { kind: 'batch', title: entry.title, result }
+ }
+ }
+ void Promise.all([query.refresh(), context.refresh(), context.refreshStageReadiness()])
+ }
+ )
+ }
+
/** 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。 */
async function run(command: StoryboardCommand) {
if (!allowed.value[command]) return
@@ -119,48 +201,22 @@ export function useStoryboard() {
}
target.receipt = null
await runOperation(projectId, `生成${titles[command]}`, async () => {
- switch (command) {
- case 'shots-current': {
- const result = await storyboardApi.regenerateEpisodeShots(projectId, targetEpisode)
- if (result.projectId !== projectId || result.episodeNo !== targetEpisode) {
- throw new Error('镜头重生成返回了不匹配的项目或剧集,请刷新后重试。')
- }
- target.receipt = { kind: 'shots', title: titles[command], result }
- if (!result.storyboardShotValidation.valid) {
- throw new Error('本集镜头校验未通过,后端未覆盖正式 Storyboard。')
- }
- target.regeneratedEpisodes[targetEpisode] = result.episodeShot
- // 新镜头会获得新的数据库 ID,废弃所有按旧 Shot ID 缓存的提示词。
- target.prompts = {}
- if (episodeNo.value === targetEpisode) selectedShot.value = ''
- break
- }
- case 'direction-all':
- target.receipt = {
- kind: 'batch',
- title: titles[command],
- result: await storyboardApi.generateDirections(projectId, batch)
- }
- break
- case 'visual-all':
- target.receipt = {
- kind: 'batch',
- title: titles[command],
- result: await storyboardApi.generateVisualStates(projectId, {
- ...batch,
- maxRepairAttempts: repairs
- })
- }
- break
- case 'prompts':
- // 断网时也可能已部分覆盖,先清空缓存,避免继续展示可能失效的正文。
- target.prompts = {}
- target.receipt = {
- kind: 'prompts',
- title: titles[command],
- result: await storyboardApi.generatePrompts(projectId, batch)
- }
- break
+ if (command === 'shots-current') {
+ const started = await storyboardApi.regenerateEpisodeShots(projectId, targetEpisode)
+ await executions[0]!.observer.track(started.executionId, projectId)
+ } else if (command === 'direction-all') {
+ const started = await storyboardApi.generateDirections(projectId, batch)
+ await executions[1]!.observer.track(started.executionId, projectId)
+ } else if (command === 'visual-all') {
+ const started = await storyboardApi.generateVisualStates(projectId, {
+ ...batch,
+ maxRepairAttempts: repairs
+ })
+ await executions[2]!.observer.track(started.executionId, projectId)
+ } else {
+ target.prompts = {}
+ const started = await storyboardApi.generatePrompts(projectId, batch)
+ await executions[3]!.observer.track(started.executionId, projectId)
}
})
await Promise.all([query.refresh(), context.refreshStageReadiness()])
@@ -177,6 +233,7 @@ export function useStoryboard() {
query,
data,
source,
+ episodeSourceUnavailable,
prerequisites,
session,
operation,
@@ -190,6 +247,7 @@ export function useStoryboard() {
directionComplete,
visualStateComplete,
hasCurrentEpisodeShots,
+ executions,
run
}
}
diff --git a/src/features/subject-identity/SubjectIdentityPage.vue b/src/features/subject-identity/SubjectIdentityPage.vue
index 8eb187f..45fb399 100644
--- a/src/features/subject-identity/SubjectIdentityPage.vue
+++ b/src/features/subject-identity/SubjectIdentityPage.vue
@@ -25,6 +25,7 @@ import ConfirmAction from '../workflows/ConfirmAction.vue'
import { castingStatusLabel, currentAnchor } from './model'
import { useSubjectIdentity } from './useSubjectIdentity'
import { useProjectContext } from '../projects/context'
+import StableAnchorQualityDialog from './components/StableAnchorQualityDialog.vue'
import IdentityEditor from './components/IdentityEditor.vue'
import IdentityGallery from './components/IdentityGallery.vue'
import IdentityImageDialog from './components/IdentityImageDialog.vue'
@@ -78,11 +79,17 @@ const {
generateImage,
generateCastingCandidate,
confirmStableAnchor,
- confirmCasting
+ confirmCasting,
+ validateImage,
+ generateStableAnchorQuality,
+ validationResult,
+ qualityResult
} = useSubjectIdentity()
const search = ref('')
const module = ref('all')
const identityBatchModule = ref<'all' | 'character' | 'scene' | 'prop'>('all')
+/** 单主体稳定母版质量生成弹窗开关。 */
+const qualityOpen = ref(false)
const imageOpen = ref(false)
const castingOpen = ref(false)
const pendingSelection = ref('')
@@ -122,6 +129,7 @@ watch(
{ immediate: true }
)
watch(selectedId, () => {
+ qualityOpen.value = false
imageOpen.value = false
castingOpen.value = false
pendingSelection.value = ''
@@ -308,7 +316,9 @@ watch(
所有需要确认的角色身份已经准备好,可以继续制作主体形态图片。
- 继续形态图片 →
+ 继续形态图片 →
@@ -345,287 +355,253 @@ watch(
角色选角总览与批量操作
-
- 人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI 默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
-
-
- 先创建项目视觉风格,才能 AI 生成身份或身份图片。设置视觉风格 →
-
-
-
-
-
-
角色选角
-
- 只处理 Character。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。
-
-
-
-
{{ casting.ready }} / {{ casting.total }} 已完成
-
-
-
-
- 缺身份文本
- - {{ casting.missingIdentity }}
-
-
-
- 缺候选图
- - {{ casting.missingAnchor }}
-
-
-
- 待确认演员
- - {{ casting.candidatePending }}
-
-
-
- 母版未锁定
- - {{ casting.unlocked }}
-
-
-
- 选角完成
- - {{ casting.ready }}
-
-
-
-
-
-
-
-
-
-
- 覆盖未锁定身份文本
-
-
-
-
-
-
-
- {{ item.subjectName }}
- {{
- item.subjectRef
- }}
-
-
-
-
-
-
场景与道具稳定母版
-
- 为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。
-
-
-
-
-
-
-
-
-
高级:全部主体身份文本
-
- 同时处理 Character、Scene 和
- Prop;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。
+
+ 人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI
+ 默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
+
+
+ 先创建项目视觉风格,才能 AI 生成身份或身份图片。设置视觉风格 →
+
+
+
+
+
+
角色选角
+
+ 只处理
+ Character。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。
-
-
-
-
-
- {{ session.receipt.title }} · 本次回执
-
- 导出诊断
-
- 共 {{ session.receipt.result.total }} 个主体 · 目标
- {{ session.receipt.result.targetCount }} · 生成
- {{ session.receipt.result.generated }} · 跳过
- {{ session.receipt.result.skipped }}(含锁定
- {{ session.receipt.result.skippedLocked }})· 失败
- {{ session.receipt.result.failed }}
-
-
- 共 {{ session.receipt.result.totalCharacters }} 个角色 · 缺候选
- {{ session.receipt.result.missingAnchor }} · 本批目标
- {{ session.receipt.result.targetCount }} · 已生成
- {{ session.receipt.result.generated }} · 失败
- {{ session.receipt.result.failed }}
-
-
- 共 {{ session.receipt.result.total }} 个{{
- session.receipt.result.module === 'scene' ? '场景' : '道具'
- }}
- · 符合条件 {{ session.receipt.result.eligibleCount }} · 本批目标
- {{ session.receipt.result.targetCount }} · 已生成并锁定
- {{ session.receipt.result.generated }} · 失败
- {{ session.receipt.result.failed }}
-
-
- 本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。
-
-
- -
- {{ failure.subjectRef }} · {{ failure.subjectId }}:{{
- failure.error
- }}
-
-
-
- 回执仅保留于当前浏览器会话;最终状态以刷新后的正式记录为准。
-
-
+
+
{{ casting.ready }} / {{ casting.total }} 已完成
+
+
+
- 缺身份文本
+ - {{ casting.missingIdentity }}
+
+
+
- 缺候选图
+ - {{ casting.missingAnchor }}
+
+
+
- 待确认演员
+ - {{ casting.candidatePending }}
+
+
+
- 母版未锁定
+ - {{ casting.unlocked }}
+
+
+
- 选角完成
+ - {{ casting.ready }}
+
+
+
+
+
+
+
+
+
+
+ 覆盖未锁定身份文本
+
+
+
+
+
+
+
+ {{ item.subjectName }}
+ {{ item.subjectRef }}
+
+
+
+
+
+
场景与道具稳定母版
+
+ 为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。
+
+
+
+
+
+
+
+
+
高级:全部主体身份文本
+
+ 同时处理 Character、Scene 和
+ Prop;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。
+
+
+
+
+
+
{{ session.receipt.title }} · 本次回执
+ 导出诊断
+
+
+ 共 {{ session.receipt.result.total }} 个主体 · 目标
+ {{ session.receipt.result.targetCount }} · 生成
+ {{ session.receipt.result.generated }} · 跳过
+ {{ session.receipt.result.skipped }}(含锁定
+ {{ session.receipt.result.skippedLocked }})· 失败
+ {{ session.receipt.result.failed }}
+
+
+ 共 {{ session.receipt.result.totalCharacters }} 个角色 · 缺候选
+ {{ session.receipt.result.missingAnchor }} · 本批目标
+ {{ session.receipt.result.targetCount }} · 已生成
+ {{ session.receipt.result.generated }} · 失败
+ {{ session.receipt.result.failed }}
+
+
+ 共 {{ session.receipt.result.total }} 个{{
+ session.receipt.result.module === 'scene' ? '场景' : '道具'
+ }}
+ · 符合条件 {{ session.receipt.result.eligibleCount }} · 本批目标
+ {{ session.receipt.result.targetCount }} · 已生成并锁定
+ {{ session.receipt.result.generated }} · 失败
+ {{ session.receipt.result.failed }}
+
+
+ 本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。
+
+
+ -
+ {{ failure.subjectRef }} · {{ failure.subjectId }}:{{ failure.error }}
+
+
+
+ 回执仅保留于当前浏览器会话;最终状态以刷新后的正式记录为准。
+
+
+
@@ -803,6 +779,30 @@ watch(
+
+ 生成稳定母版并校验质量
+
+ {{
+ qualityResult.passed
+ ? '质量闭环通过,母版与锁定已确认'
+ : '质量闭环未通过,候选仍保留在图库'
+ }}
+ · 已修复 {{ qualityResult.repairAttempts }} 次
+ 停止原因:{{ qualityResult.stopReason }}
+ {{
+ JSON.stringify(qualityResult.attempts, null, 2)
+ }}
+
+
+
+ {{ subject.module === 'character' ? '生成辅助参考图' : '生成母版候选' }}
+
@@ -842,22 +844,30 @@ watch(
>前往剧本拆解
-
- {{ subject?.name }} 的身份图片正在生成({{ activeIdentityGeneration.provider || '图片模型' }}),刷新页面不会重复提交,请等待当前任务完成。
+
+ {{ subject?.name }} 的身份图片正在生成({{
+ activeIdentityGeneration.provider || '图片模型'
+ }}),刷新页面不会重复提交,请等待当前任务完成。
-
- 最近一次身份图片生成失败:{{ latestIdentityFailure.error || '未返回具体错误' }}。可以调整模型参数后重新生成。
+
+ 最近一次身份图片生成失败:{{
+ latestIdentityFailure.error || '未返回具体错误'
+ }}。可以调整模型参数后重新生成。
+
(`${identityPath(subjectId)}/images`, { signal }),
generateImage: (subjectId: string, input: GenerateIdentityImageInput) =>
request(`${identityPath(subjectId)}/images`, { method: 'POST', body: input, timeoutMs: 0 }),
+ /**
+ * 读取与实际生图同源的输入预览,道具可能执行已确认的结构模型编译。
+ * @param subjectId 正式主体 ID
+ * @param input 与实际生图相同的参数
+ * @param signal 只读预览取消信号,可能付费的道具不传
+ * @returns 后端真实输入与最终参数
+ */
+ previewImage: (subjectId: string, input: GenerateIdentityImageInput, signal?: AbortSignal) =>
+ request(`${identityPath(subjectId)}/images/preview`, {
+ method: 'POST',
+ body: input,
+ signal,
+ timeoutMs: 0
+ }),
+ /**
+ * 明确确认后对指定身份图片执行视觉校验。
+ * @param subjectId 正式主体 ID
+ * @param imageId 此主体的正式图片 ID
+ * @returns 真实视觉校验回执
+ */
+ validateImage: (subjectId: string, imageId: string) =>
+ request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/validate`, {
+ method: 'POST',
+ timeoutMs: 0
+ }),
+ /**
+ * 为单个场景或道具执行有限预算的稳定母版质量闭环。
+ * @param subjectId 正式主体 ID
+ * @param input 已确认的模型与修复预算
+ * @returns 候选、各轮质量和实际母版确认回执
+ */
+ generateStableAnchorQuality: (subjectId: string, input: StableAnchorQualityInput) =>
+ request(`${identityPath(subjectId)}/stable-anchor/generate-quality`, {
+ method: 'POST',
+ body: input,
+ timeoutMs: 0
+ }),
setAnchor: (subjectId: string, imageId: string) =>
request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/anchor`, {
method: 'PUT'
}),
confirmStableAnchor: (subjectId: string, imageId: string) =>
- request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`, {
- method: 'PUT'
- }),
+ request(
+ `${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`,
+ {
+ method: 'PUT'
+ }
+ ),
confirmCasting: (subjectId: string, imageId: string) =>
request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/casting`, {
method: 'PUT'
diff --git a/src/features/subject-identity/components/IdentityGallery.vue b/src/features/subject-identity/components/IdentityGallery.vue
index b0de3cb..84638ea 100644
--- a/src/features/subject-identity/components/IdentityGallery.vue
+++ b/src/features/subject-identity/components/IdentityGallery.vue
@@ -1,28 +1,38 @@
-
+
+
+
+ 预览本次真实输入
+ {{ previewError }}
+
+
实际供应方:{{ preview.provider }} · 模型:{{ preview.model }}
+
最终提示词:{{ preview.providerPrompt }}
+
{{
+ JSON.stringify(
+ {
+ referenceImages: preview.referenceImages,
+ referencePlan: preview.referencePlan,
+ generationConfig: preview.generationConfig
+ },
+ null,
+ 2
+ )
+ }}
+
- 取消
- 确认生成身份图
-
+ 取消
+ 确认生成身份图
+
diff --git a/src/features/subject-identity/components/StableAnchorQualityDialog.vue b/src/features/subject-identity/components/StableAnchorQualityDialog.vue
new file mode 100644
index 0000000..e4cf1b9
--- /dev/null
+++ b/src/features/subject-identity/components/StableAnchorQualityDialog.vue
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+ 最多生成
+ {{ maxRepairAttempts + 1 }}
+ 张候选,并逐张调用视觉校验;道具还可能调用结构编译模型,均可能产生费用。只有真实通过后,后端才会切换母版并锁定身份。
+
+
+ 我已确认本次候选数量、模型费用,且后台没有同项目任务。
+
+ 取消确认生成并校验
+
+
diff --git a/src/features/subject-identity/types.ts b/src/features/subject-identity/types.ts
index 7507611..77e70f4 100644
--- a/src/features/subject-identity/types.ts
+++ b/src/features/subject-identity/types.ts
@@ -167,3 +167,81 @@ export type IdentityReceipt =
| { kind: 'identities'; title: string; result: IdentityBatchResult }
| { kind: 'casting'; title: string; result: CastingBatchResult }
| { kind: 'stable-anchors'; title: string; result: StableAnchorBatchResult }
+
+/** 最终身份图片 Provider 输入,直接对应身份预览接口。 */
+export interface IdentityImagePreview {
+ /** 实际供应方。 */
+ provider: string
+ /** 实际模型。 */
+ model: string
+ /** 最终提示词。 */
+ providerPrompt: string
+ /** 实际引用图片地址。 */
+ referenceImages: string[]
+ /** 后端参考图选择计划。 */
+ referencePlan: Record
+ /** 后端解析后的生成配置。 */
+ generationConfig: Record
+}
+
+/** 指定身份图片的视觉校验回执。 */
+export interface IdentityValidationResult {
+ /** 正式主体 ID。 */
+ subjectId: string
+ /** 被校验的图片 ID。 */
+ imageId: string
+ /** 是否通过本次校验。 */
+ passed: boolean
+ /** 校验总结。 */
+ summary: string
+ /** 具体问题。 */
+ issues: Array<{
+ /** 问题类型。 */
+ type: string
+ /** 严重程度。 */
+ severity: string
+ /** 问题描述。 */
+ description: string
+ }>
+}
+
+/** 有限预算的单主体稳定母版生成参数。 */
+export interface StableAnchorQualityInput {
+ /** 最大修复次数,页面限制为 0 到 3。 */
+ maxRepairAttempts: number
+ /** 本次供应方。 */
+ provider: string
+ /** 本次图片生成参数。 */
+ generationOptions: Record
+}
+
+/** 单主体质量闭环的真实终态回执。 */
+export interface StableAnchorQualityResult {
+ /** 最终是否通过。 */
+ passed: boolean
+ /** 最后一张候选图片 ID。 */
+ imageId?: string
+ /** 实际修复次数。 */
+ repairAttempts: number
+ /** 后端停止原因。 */
+ stopReason?: string
+ /** 重复错误签名。 */
+ repeatedErrorSignature?: string
+ /** 每轮结果。 */
+ attempts: Array<{
+ /** 从零开始的轮次。 */
+ attempt: number
+ /** 本轮图片 ID。 */
+ imageId: string
+ /** 本轮是否通过。 */
+ passed: boolean
+ /** 原始诊断问题。 */
+ issues: unknown[]
+ /** 结构问题类型。 */
+ structuralIssueTypes?: string[]
+ /** 错误签名。 */
+ errorSignature?: string
+ }>
+ /** 通过后原子确认的母版与锁定回执。 */
+ confirmed?: ConfirmCastingResult
+}
diff --git a/src/features/subject-identity/useSubjectIdentity.ts b/src/features/subject-identity/useSubjectIdentity.ts
index 6753601..37b009e 100644
--- a/src/features/subject-identity/useSubjectIdentity.ts
+++ b/src/features/subject-identity/useSubjectIdentity.ts
@@ -10,6 +10,9 @@ import { useProjectContext } from '../projects/context'
import { subjectIdentityApi } from './api'
import { canBeAnchor, getIdentitySession, groupIdentitySubjects, mergeCastingSubjects } from './model'
import type {
+ IdentityValidationResult,
+ StableAnchorQualityInput,
+ StableAnchorQualityResult,
GenerateCastingCandidateInput,
GenerateIdentityImageInput,
IdentityImage,
@@ -82,7 +85,9 @@ export function useSubjectIdentity() {
)
const subject = computed(() => subjects.value.find(item => item.id === selectedId.value))
const selectionKey = computed(() => subject.value?.id ?? '')
- const detailRef = {} as { current?: ReturnType> }
+ const detailRef = {} as {
+ current?: ReturnType>
+ }
const detailPollInterval = computed(() =>
detailRef.current?.data.value?.images.some(image => image.status === 'pending' || image.status === 'generating')
? 4000
@@ -163,6 +168,72 @@ export function useSubjectIdentity() {
editorRevision.value++
})
+ /** 校验结果以正式主体 ID 保存,切换主体不会串回执。 */
+ const validationResults = ref>({})
+ /** 质量闭环结果以正式主体 ID 保存。 */
+ const qualityResults = ref>({})
+ /** 当前主体的指定图片校验结果。 */
+ const validationResult = computed(() => validationResults.value[selectedId.value] ?? null)
+ /** 当前主体的质量闭环回执。 */
+ const qualityResult = computed(() => qualityResults.value[selectedId.value] ?? null)
+ /**
+ * 校验当前主体的正式图片,费用确认由图库负责。
+ * @param imageId 指定正式身份图片 ID
+ */
+ 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
+ const id = subject.value.id
+ const project = projectId.value
+ delete validationResults.value[id]
+ await runOperation(project, '校验身份参考图质量', async () => {
+ const result = await subjectIdentityApi.validateImage(id, imageId)
+ if (result.subjectId !== id || result.imageId !== imageId) throw new Error('身份校验回执与提交目标不匹配')
+ validationResults.value[id] = result
+ })
+ }
+ /**
+ * 为场景或道具执行有限预算质量闭环,仅按真实回执确认锁定。
+ * @param input 模型、参数和修复次数
+ */
+ async function generateStableAnchorQuality(input: StableAnchorQualityInput) {
+ if (
+ !canGenerateImage.value ||
+ !subject.value ||
+ !identity.value ||
+ !['scene', 'prop'].includes(subject.value.module)
+ )
+ return
+ if (!Number.isInteger(input.maxRepairAttempts) || input.maxRepairAttempts < 0 || input.maxRepairAttempts > 3)
+ return
+ const id = subject.value.id
+ const identityId = identity.value.id
+ const project = projectId.value
+ delete qualityResults.value[id]
+ await runOperation(project, '生成稳定身份母版并校验质量', async () => {
+ const result = await subjectIdentityApi.generateStableAnchorQuality(id, input)
+ if (
+ result.passed &&
+ (!result.confirmed ||
+ result.confirmed.subjectId !== id ||
+ result.confirmed.identityId !== identityId ||
+ !result.confirmed.isLocked ||
+ !result.confirmed.anchor.isAnchor ||
+ result.confirmed.anchor.id !== result.imageId)
+ )
+ throw new Error('质量生成的母版与锁定回执未确认,请刷新核对')
+ qualityResults.value[id] = result
+ })
+ if (projectId.value === project) {
+ await Promise.all([
+ catalog.refresh(),
+ castingQuery.refresh(),
+ projectContext.refreshStageReadiness(),
+ ...(selectedId.value === id ? [detail.refresh()] : [])
+ ])
+ }
+ }
+
/** 长请求跨主体切换后只更新原项目的操作回执,不用旧响应覆盖新主体。 */
async function writeIdentity(label: string, action: (id: string) => Promise) {
if (detailBlocked.value || !subject.value) return
@@ -447,6 +518,10 @@ export function useSubjectIdentity() {
generateCastingCandidate,
setAnchor,
confirmStableAnchor,
- confirmCasting
+ confirmCasting,
+ validateImage,
+ generateStableAnchorQuality,
+ validationResult,
+ qualityResult
}
}
diff --git a/src/features/workflows/WorkflowExecutionPanel.vue b/src/features/workflows/WorkflowExecutionPanel.vue
index c99227c..2ab6ce1 100644
--- a/src/features/workflows/WorkflowExecutionPanel.vue
+++ b/src/features/workflows/WorkflowExecutionPanel.vue
@@ -22,6 +22,29 @@ const statusType = computed(() =>
)
const finished = computed(() => ['completed', 'failed'].includes(props.execution?.status ?? ''))
const videoQuality = computed(() => props.execution?.workflowName === 'video-quality')
+/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
+const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
+/** 只接受后端完整的质量计数,畸形或缺失结果不显示全成功。 */
+const keyframeCounts = computed(() => {
+ const fields = ['targetCount', 'passed', 'repairFailed', 'failed'] as const
+ if (
+ !fields.every(
+ field =>
+ typeof result.value[field] === 'number' &&
+ Number.isSafeInteger(result.value[field]) &&
+ Number(result.value[field]) >= 0
+ )
+ )
+ return null
+ const counts = {
+ targetCount: Number(result.value.targetCount),
+ passed: Number(result.value.passed),
+ repairFailed: Number(result.value.repairFailed),
+ failed: Number(result.value.failed)
+ }
+ return counts.passed + counts.repairFailed + counts.failed === counts.targetCount ? counts : null
+})
+/** 范围描述保留指定镜头或剧集,不把小批量误显示为全项目。 */
const scopeLabel = computed(() => {
const metadata = props.execution?.metadata
if (!metadata) return ''
@@ -32,6 +55,7 @@ const scopeLabel = computed(() => {
: metadata.inputModeFilter === 'omni_reference'
? '全模态参考'
: '全部推荐模式'
+ if (keyframeQuality.value && typeof metadata.shotId === 'string') return `${episode} · 单镜头`
return videoQuality.value ? `${episode} · ${mode}` : episode
})
const inputPlanCounts = computed(() => {
@@ -78,8 +102,8 @@ function isInputMode(value: unknown, inputMode: string): boolean {
aria-label="隐藏制作任务记录"
title="隐藏制作任务记录"
@click="emit('dismiss')"
- >
+ >
@@ -101,12 +125,19 @@ function isInputMode(value: unknown, inputMode: string): boolean {
{{
- videoQuality
- ? '系统会继续生成、检查并按需修复。'
- : '系统会继续处理剩余内容并保存已完成结果。'
+ videoQuality ? '系统会继续生成、检查并按需修复。' : '系统会继续处理剩余内容并保存已完成结果。'
}}可以离开或刷新页面,返回后会继续显示本次任务进度,请勿重复提交。
-
+
本轮任务已结束,页面正在重新读取镜头资产状态。
目标 {{ result.targetCount ?? execution.total }} · 通过 {{ result.passed ?? 0 }} · 修复耗尽
@@ -117,7 +148,14 @@ function isInputMode(value: unknown, inputMode: string): boolean {
输入规划:首帧模式 {{ inputPlanCounts.firstFrame }} · 全模态参考
{{ inputPlanCounts.omniReference }}
-
+
+ 目标 {{ keyframeCounts.targetCount }} · 通过 {{ keyframeCounts.passed }} · 修复未通过
+ {{ keyframeCounts.repairFailed }} · 调用失败 {{ keyframeCounts.failed }}
+ 后端首帧质量统计不完整,请查看任务详情并刷新核对。
+
+
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
@@ -125,7 +163,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
{{ execution.error || '制作任务执行失败。' }}
- 请先刷新下方视频状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。
+ 请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。
diff --git a/src/features/workflows/execution.ts b/src/features/workflows/execution.ts
index a376d71..a4b4adc 100644
--- a/src/features/workflows/execution.ts
+++ b/src/features/workflows/execution.ts
@@ -1,9 +1,32 @@
-import { computed, ref, watch, type Ref } from 'vue'
+import { computed, onScopeDispose, reactive, ref, watch, type Ref } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { workflowExecutionApi } from './execution-api'
const storagePrefix = 'short-drama:workflow-execution'
+/** 同项目观察器共享真实后台句柄与活动状态,防止绕过弹窗重复付费启动。 */
+interface ExecutionActivity {
+ /** 任务所属项目。 */
+ projectId: string
+ /** 后端实际任务编号。 */
+ id: string
+ /** 尚未取得终态时保持活动锁。 */
+ active: boolean
+ /** 同一任务取得终态后,任何迟到记录都不能使它重新活动。 */
+ terminal: boolean
+}
+/** 活动状态按项目和工作流共同隔离。 */
+const executionActivity = reactive>({})
+
+/**
+ * 检查项目是否仍有已跟踪且未结束的后台任务。
+ * @param projectId 正式项目 ID
+ * @returns 是否存在活动后台任务
+ */
+export function hasActiveWorkflowExecution(projectId: string) {
+ return Object.values(executionActivity).some(record => record.projectId === projectId && record.active)
+}
+
/** 任务阶段短标签;未知后端阶段保留原值,避免静默隐藏新能力。 */
export function executionStageLabel(stage: string | null) {
if (!stage) return '等待后端开始'
@@ -19,6 +42,11 @@ export function executionStageLabel(stage: string | null) {
resumeGeneration: '恢复分集剧本生成',
resumeRewrite: '恢复剧本改写',
breakdown: '拆解剧本',
+ storyboardRegenerate: '重生成单集镜头',
+ storyboardDirection: '生成导演设计',
+ storyboardVisualState: '生成即时状态',
+ keyframe_generation: '生成普通首帧',
+ videoPrompt: '生成视频提示词',
breakdownRetry: '重试失败拆解任务',
breakdownResumeShots: '补齐分镜镜头',
breakdownResumeStoryboard: '修复分镜绑定',
@@ -34,6 +62,7 @@ export function executionStageLabel(stage: string | null) {
finalize: '收尾生产状态',
manualReview: '等待人工处理',
video_prompt: '生成视频提示词',
+ keyframe_quality: '首帧质量生成',
submitting: '提交视频候选',
generating: '生成视频',
validating: '质量校验',
@@ -64,6 +93,11 @@ function savedExecutionId(projectId: string, workflowName: string) {
/** 跟踪一个项目最近的持久化任务;刷新页面后从本地句柄恢复,状态仍从后端读取。 */
export function useWorkflowExecution(projectId: Ref, workflowName: string) {
+ /** 卸载后仍保存原项目返回的句柄,但不再更新已销毁的观察器。 */
+ let disposed = false
+ onScopeDispose(() => {
+ disposed = true
+ })
const executionId = ref('')
const terminal = ref(false)
watch(
@@ -71,13 +105,48 @@ export function useWorkflowExecution(projectId: Ref, workflowName: strin
value => {
executionId.value = savedExecutionId(value, workflowName)
terminal.value = false
+ if (executionId.value && executionActivity[storageKey(value, workflowName)]?.id !== executionId.value)
+ executionActivity[storageKey(value, workflowName)] = {
+ projectId: value,
+ id: executionId.value,
+ active: true,
+ terminal: false
+ }
},
{ immediate: true }
)
+ /** 同页面其它入口跟踪了任务时,同步句柄并读取同一后台状态。 */
+ watch(
+ () => executionActivity[storageKey(projectId.value, workflowName)]?.id,
+ id => {
+ if (id && id !== executionId.value) {
+ terminal.value = false
+ executionId.value = id
+ }
+ }
+ )
const key = computed(() => executionId.value)
const query = usePolling(
key,
- (id, signal) => (id ? workflowExecutionApi.get(id, signal) : Promise.resolve(null)),
+ async (id, signal) => {
+ if (!id) return null
+ const targetProjectId = projectId.value
+ const record = await workflowExecutionApi.get(id, signal)
+ if (record.projectId !== targetProjectId || record.workflowName !== workflowName || record.id !== id)
+ throw new Error('后台任务与当前项目或工作流不匹配,请刷新核对。')
+ const activity = executionActivity[storageKey(targetProjectId, workflowName)]
+ if (
+ !signal.aborted &&
+ !disposed &&
+ projectId.value === targetProjectId &&
+ activity?.id === id &&
+ !activity.terminal
+ ) {
+ activity.terminal = ['completed', 'failed'].includes(record.status)
+ activity.active = !activity.terminal
+ }
+ return record
+ },
computed(() => (executionId.value && !terminal.value ? 1_500 : false))
)
watch(
@@ -86,16 +155,31 @@ export function useWorkflowExecution(projectId: Ref, workflowName: strin
terminal.value = status === 'completed' || status === 'failed'
}
)
- const active = computed(
- () =>
- !!executionId.value &&
- (!query.data.value || ['pending', 'running'].includes(query.data.value.status))
- )
+ const active = computed(() => {
+ const activity = executionActivity[storageKey(projectId.value, workflowName)]
+ return activity?.id === executionId.value
+ ? activity.active
+ : !!executionId.value && (!query.data.value || ['pending', 'running'].includes(query.data.value.status))
+ })
- /** 保存后端返回的真实 executionId,随后立即读取一次权威状态。 */
- async function track(id: string) {
- if (!id || !projectId.value) return
- if (typeof localStorage !== 'undefined') localStorage.setItem(storageKey(projectId.value, workflowName), id)
+ /**
+ * 保存任务原项目的真实句柄,只有仍查看该项目时才读取权威状态。
+ * @param id 后端任务编号
+ * @param targetProjectId 启动请求时固定的原项目 ID
+ * @returns 保存句柄与可用观察器刷新完成
+ */
+ async function track(id: string, targetProjectId = projectId.value) {
+ if (typeof id !== 'string' || !id.trim()) throw new Error('后端未返回有效任务编号,请刷新状态,勿重复提交。')
+ if (!targetProjectId) return
+ if (typeof localStorage !== 'undefined') localStorage.setItem(storageKey(targetProjectId, workflowName), id)
+ if (executionActivity[storageKey(targetProjectId, workflowName)]?.id !== id)
+ executionActivity[storageKey(targetProjectId, workflowName)] = {
+ projectId: targetProjectId,
+ id,
+ active: true,
+ terminal: false
+ }
+ if (disposed || projectId.value !== targetProjectId) return
terminal.value = false
executionId.value = id
await query.refresh()
@@ -103,6 +187,8 @@ export function useWorkflowExecution(projectId: Ref, workflowName: strin
/** 只隐藏当前观察记录,不取消后端任务。 */
function dismiss() {
+ if (active.value) return
+ delete executionActivity[storageKey(projectId.value, workflowName)]
if (projectId.value && typeof localStorage !== 'undefined')
localStorage.removeItem(storageKey(projectId.value, workflowName))
executionId.value = ''
diff --git a/src/features/workflows/operations.ts b/src/features/workflows/operations.ts
index 6b25906..6251540 100644
--- a/src/features/workflows/operations.ts
+++ b/src/features/workflows/operations.ts
@@ -1,5 +1,6 @@
import { reactive } from 'vue'
import { errorMessage } from '../../lib/http'
+import { hasActiveWorkflowExecution } from './execution'
/** 当前浏览器会话中的操作状态;切换路由不会丢失长请求。 */
export interface Operation {
@@ -22,7 +23,23 @@ const operations = reactive>({})
/** 取得项目操作状态,不向浏览器持久化虚假的后台运行状态。 */
export function getOperation(projectId: string): Operation {
- return (operations[projectId] ??= { pending: false, label: '', error: '', notice: '', recovery: null })
+ if (operations[projectId]) return operations[projectId]
+ /** 当前 HTTP 操作锁与持久化后台活动锁合并,后台结束前不能重复启动付费操作。 */
+ let requestPending = false
+ return (operations[projectId] = {
+ /** 当前项目是否有短请求或后台任务仍在执行。 */
+ get pending() {
+ return requestPending || hasActiveWorkflowExecution(projectId)
+ },
+ /** 更新短请求锁;后台锁只由后端真实终态释放。 */
+ set pending(value: boolean) {
+ requestPending = value
+ },
+ label: '',
+ error: '',
+ notice: '',
+ recovery: null
+ })
}
/** 只提交一次;断网不自动重试,后台是否已执行由刷新后的 checkpoint 确认。 */
diff --git a/tests/features/production/backend-contract.test.ts b/tests/features/production/backend-contract.test.ts
new file mode 100644
index 0000000..95ebb6a
--- /dev/null
+++ b/tests/features/production/backend-contract.test.ts
@@ -0,0 +1,60 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { productionApi } from '@/features/production/api'
+import { validateProductionScope } from '@/features/production/useAdvancedProduction'
+import type { ProductionStartInput } from '@/features/production/types'
+
+afterEach(() => vi.unstubAllGlobals())
+
+describe('生产后端真实请求契约', () => {
+ it('计划使用 POST JSON 并将图片参数与启动保持同源', async () => {
+ const fetchMock = vi
+ .fn()
+ .mockImplementation(async () => new Response(JSON.stringify({ data: { projectId: 'p' } })))
+ vi.stubGlobal('fetch', fetchMock)
+ const input: ProductionStartInput = {
+ imageProvider: 'qwen-image',
+ imageGenerationOptions: { size: '1024*1024', seed: 3 },
+ videoProvider: 'wan',
+ startFrom: 'subjectImages',
+ stopAfter: 'videoPrompts',
+ stableIdentityAnchorLimit: 1,
+ subjectImageLimit: 2,
+ keyframeLimit: 3,
+ videoPromptLimit: 4
+ }
+ const controller = new AbortController()
+ await productionApi.plan('p', controller.signal, input)
+ await productionApi.startPipeline('p', input)
+ expect(fetchMock.mock.calls[0]?.[0]).toBe('/api/projects/p/production/plan')
+ expect(fetchMock.mock.calls[1]?.[0]).toBe('/api/projects/p/production/start')
+ for (const [, request] of fetchMock.mock.calls) {
+ expect(request?.method).toBe('POST')
+ expect(JSON.parse(String(request?.body))).toEqual(input)
+ }
+ expect(fetchMock.mock.calls[0]?.[1]?.signal).toBeInstanceOf(AbortSignal)
+ })
+
+ it('409 携带现有 executionId 且封装不重试', async () => {
+ const fetchMock = vi.fn().mockImplementation(
+ async () =>
+ new Response(JSON.stringify({ message: '已有任务', details: { executionId: 'existing' } }), {
+ status: 409
+ })
+ )
+ vi.stubGlobal('fetch', fetchMock)
+ await expect(productionApi.startPipeline('p')).rejects.toMatchObject({
+ status: 409,
+ details: { executionId: 'existing' }
+ })
+ expect(fetchMock).toHaveBeenCalledTimes(1)
+ })
+
+ it('拒绝反向阶段、零值和非整数,支持主体图片结束阶段', () => {
+ expect(validateProductionScope({ startFrom: 'videoPrompts', stopAfter: 'subjectImages' })).toContain('结束阶段')
+ expect(validateProductionScope({ subjectImageLimit: 0 })).toContain('整数')
+ expect(validateProductionScope({ stableIdentityAnchorLimit: 1.5 })).toContain('整数')
+ expect(
+ validateProductionScope({ startFrom: 'subjectImages', stopAfter: 'subjectImages', videoPromptLimit: 1 })
+ ).toBe('')
+ })
+})
diff --git a/tests/features/production/capabilities.test.ts b/tests/features/production/capabilities.test.ts
index 546ade5..9e510d5 100644
--- a/tests/features/production/capabilities.test.ts
+++ b/tests/features/production/capabilities.test.ts
@@ -28,7 +28,7 @@ afterEach(() => {
}
})
-/** 所有预检均是模拟 GET;生成接口只记录契约,不调用真实 Provider。 */
+/** 预检支持正式 POST plan;付费启动单独计数,不调用真实 Provider。 */
function stageFixture() {
return { total: 1, planned: 1, skipped: 0, upstreamResolvable: 0, manualBlocked: 0 }
}
@@ -147,7 +147,10 @@ function server() {
plan,
status,
fetcher,
- posts: () => fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
+ posts: () =>
+ fetcher.mock.calls.filter(
+ ([url, init]) => init?.method === 'POST' && !String(url).endsWith('/production/plan')
+ )
}
}
diff --git a/tests/features/production/keyframe-quality-contract.test.ts b/tests/features/production/keyframe-quality-contract.test.ts
new file mode 100644
index 0000000..1a5c09b
--- /dev/null
+++ b/tests/features/production/keyframe-quality-contract.test.ts
@@ -0,0 +1,85 @@
+import { describe, expect, it, vi, afterEach } from 'vitest'
+import { qualityApi } from '@/features/production/quality-api'
+import {
+ qualityTargets,
+ parseKeyframeValidationOutput,
+ isQualityBatchResult,
+ qualityKey
+} from '@/features/production/quality'
+import type { KeyframeReadiness } from '@/features/production/types'
+
+/** 契约测试仅使用本地模拟数据,不调用生成服务。 */
+afterEach(() => vi.unstubAllGlobals())
+describe('首帧质量正式后端契约', () => {
+ it('202 只表示后台开始且保留单镜头模型参数', async () => {
+ const fetcher = vi
+ .fn()
+ .mockResolvedValue(
+ new Response(
+ JSON.stringify({ data: { executionId: 'exec', projectId: 'p', status: 'running', total: 1 } }),
+ { status: 202 }
+ )
+ )
+ vi.stubGlobal('fetch', fetcher)
+ const result = await qualityApi.generate('p', {
+ concurrency: 1,
+ maxRepairAttempts: 2,
+ force: true,
+ episodeNo: 2,
+ limit: 1,
+ shotId: 's',
+ provider: 'image-provider',
+ generationOptions: { quality: 'high' }
+ })
+ expect(result.executionId).toBe('exec')
+ expect(isQualityBatchResult(result)).toBe(false)
+ expect(JSON.parse(String(fetcher.mock.calls[0]![1]?.body))).toMatchObject({
+ shotId: 's',
+ limit: 1,
+ provider: 'image-provider',
+ generationOptions: { quality: 'high' }
+ })
+ })
+ it('就绪项按集和镜头筛选,不因其他集过期漏掉缺失项', () => {
+ const readiness = {
+ stalePrimaryKeyframe: 1,
+ items: [
+ { shotId: 's', episodeNo: 2, status: 'ready' },
+ { shotId: 'other', episodeNo: 1, status: 'ready', primaryKeyframeStale: true }
+ ]
+ } as KeyframeReadiness
+ expect(
+ qualityTargets(readiness, {
+ concurrency: 1,
+ maxRepairAttempts: 1,
+ force: false,
+ episodeNo: 2,
+ limit: 1,
+ shotId: 's'
+ }).map(item => item.shotId)
+ ).toEqual(['s'])
+ expect(qualityKey('p', { kind: 'batch', episodeNo: 2, shotId: 's', title: '' })).not.toBe(
+ qualityKey('p', { kind: 'batch', episodeNo: 2, title: '' })
+ )
+ })
+ it('历史输出 JSON 必须具有真实结论,原始数据不冒充通过', () => {
+ const validation = {
+ passed: false,
+ summary: '缺少主体',
+ subjects: [],
+ subjectCountConsistent: false,
+ unauthorizedText: { detected: false, texts: [] },
+ issues: []
+ }
+ expect(parseKeyframeValidationOutput(JSON.stringify(validation))).toEqual(validation)
+ expect(parseKeyframeValidationOutput('{"raw":"PASS"}')).toBeNull()
+ expect(parseKeyframeValidationOutput('invalid')).toBeNull()
+ })
+ it('历史接口转义目标并传递取消信号', async () => {
+ const fetcher = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: [] })))
+ vi.stubGlobal('fetch', fetcher)
+ await qualityApi.keyframeHistory('s/a', 'k/b', new AbortController().signal)
+ expect(fetcher.mock.calls[0]![0]).toBe('/api/storyboard-shots/s%2Fa/keyframes/k%2Fb/validations')
+ expect(fetcher.mock.calls[0]![1]?.signal).toBeInstanceOf(AbortSignal)
+ })
+})
diff --git a/tests/features/production/quality.test.ts b/tests/features/production/quality.test.ts
index 44c15ab..d849986 100644
--- a/tests/features/production/quality.test.ts
+++ b/tests/features/production/quality.test.ts
@@ -5,6 +5,7 @@ import { NCheckbox, NInputNumber, NRadioGroup } from 'naive-ui'
import { testProjectContext } from '@/testing/project-context'
import { productionApi } from '@/features/production/api'
import { qualityApi } from '@/features/production/quality-api'
+import { generationConfigApi } from '@/features/generation-config/api'
import {
allowedTextLines,
qualityKey,
@@ -108,12 +109,16 @@ function server() {
missingReference: 0,
results: [{ shotId: 'shot-1', success: true, status: 'passed' as const }]
}
+ const executionState = { status: 'completed' as 'running' | 'completed' | 'failed' }
+ let batchMetadata: QualityInput | null = null
const fetcher = vi.fn().mockImplementation(async (url, options) => {
const path = String(url)
let data: unknown
if (options?.method === 'POST') {
- if (path.endsWith('/generate-quality')) data = batch
- else if (path.includes('/videos/') && path.endsWith('/repair'))
+ if (path.endsWith('/generate-quality')) {
+ batchMetadata = JSON.parse(String(options.body)) as QualityInput
+ data = { executionId: `exec-${projectId}`, projectId, status: 'running', total: 1 }
+ } else if (path.includes('/videos/') && path.endsWith('/repair'))
data = {
shotId: 'shot-1',
sourceVideoId: 'video-1',
@@ -142,6 +147,19 @@ function server() {
}
else data = keyframeResult
} else if (path.endsWith(`/projects/${projectId}`)) data = project
+ else if (path.includes('/workflow-executions/'))
+ data = {
+ id: `exec-${projectId}`,
+ projectId,
+ workflowName: 'keyframe-quality',
+ status: executionState.status,
+ stage: 'keyframe_quality',
+ current: 1,
+ total: 1,
+ metadata: batchMetadata,
+ result: batch,
+ error: null
+ }
else if (path.endsWith('/checkpoints')) data = []
else if (path.includes('/readiness')) data = readiness
else if (path.endsWith('/keyframes')) data = [keyframe]
@@ -170,6 +188,7 @@ function server() {
keyframeResult,
repair,
batch,
+ executionState,
fetcher,
posts: () => fetcher.mock.calls.filter(([, options]) => options?.method === 'POST')
}
@@ -301,13 +320,54 @@ describe('视觉质量契约与付费边界', () => {
expect(wrapper.emitted('locate')).toEqual([['shot-1']])
})
- it('过期优先级与后端一致,当前集无过期项时不误补其他镜头', async () => {
+ it('后台开始不显示最终通过,关闭切目标后完成仍归原镜头且刷新能恢复', async () => {
+ const original: QualityTarget = { kind: 'batch', episodeNo: 1, shotId: 'shot-1', title: '原镜头' }
+ const data = setup(original)
+ data.executionState.status = 'running'
+ await data.service.run('batch', input({ shotId: 'shot-1', limit: 1 }))
+ expect(data.service.session.value.receipt).toBeNull()
+ expect(data.service.blocked.value).toBe(true)
+ const postCount = data.posts().length
+ await data.service.run('batch', input({ shotId: 'shot-1' }))
+ expect(data.posts()).toHaveLength(postCount)
+ data.visible.value = false
+ data.props.target = { kind: 'batch', episodeNo: 2, title: '其他集' }
+ await flushPromises()
+ data.executionState.status = 'completed'
+ await data.service.execution.query.refresh()
+ await flushPromises()
+ expect(data.service.session.value.receipt).toBeNull()
+ expect(qualitySession(qualityKey(data.projectId, original)).receipt).toMatchObject({
+ kind: 'batch',
+ result: { passed: 1 }
+ })
+ wrapper!.unmount()
+ let restored!: ReturnType
+ wrapper = mount(
+ defineComponent({
+ setup() {
+ restored = useQuality(
+ data.props,
+ () => false,
+ () => {}
+ )
+ return () => null
+ }
+ })
+ )
+ await flushPromises()
+ expect(restored.execution.executionId.value).toBe(`exec-${data.projectId}`)
+ expect(restored.execution.query.data.value?.status).toBe('completed')
+ expect(data.posts()).toHaveLength(postCount)
+ })
+
+ it('按真实后端 ready 列表处理本集缺失与过期项', async () => {
const data = setup({ kind: 'batch', episodeNo: 1, title: '第一集' })
data.readiness.stalePrimaryKeyframe = 1
- expect(qualityTargets(data.readiness, input())).toHaveLength(0)
+ expect(qualityTargets(data.readiness, input())).toHaveLength(1)
await data.service.run('batch', input())
- expect(data.posts()).toHaveLength(0)
- expect(data.service.session.value.error).toContain('切换剧集')
+ expect(data.posts()).toHaveLength(1)
+ expect(data.service.session.value.error).toBe('')
expect(qualityTargets(data.readiness, input({ force: true }))).toHaveLength(1)
})
@@ -401,6 +461,37 @@ describe('质量面板渐进展示', () => {
it('批量默认当前集一镜,调整次数撤销费用确认', async () => {
const data = server()
+ // 明确的项目配置与启用模型;不能依靠缺失配置进入付费确认。
+ vi.spyOn(generationConfigApi, 'catalog').mockResolvedValue({
+ defaults: { imageProvider: 'qwen-image', videoProvider: 'wan' },
+ images: [
+ {
+ type: 'image',
+ provider: 'qwen-image',
+ providerLabel: 'Qwen',
+ model: 'qwen-model',
+ modelLabel: 'Qwen Model',
+ supported: true,
+ enabled: true,
+ isDefault: true,
+ capabilities: {},
+ generationOptions: [],
+ defaults: {},
+ projectConstraints: []
+ }
+ ],
+ videos: []
+ })
+ vi.spyOn(generationConfigApi, 'profile').mockResolvedValue({
+ projectId: data.projectId,
+ aspectRatio: '9:16',
+ imageProvider: 'qwen-image',
+ imageModel: 'qwen-model',
+ imageOptions: {},
+ videoProvider: 'wan',
+ videoModel: 'wan-model',
+ videoOptions: {}
+ })
wrapper = mount(QualityDialog, {
attachTo: document.body,
props: {
diff --git a/tests/features/storyboard/legacy-async-api.test.ts b/tests/features/storyboard/legacy-async-api.test.ts
new file mode 100644
index 0000000..32c5f32
--- /dev/null
+++ b/tests/features/storyboard/legacy-async-api.test.ts
@@ -0,0 +1,47 @@
+import { afterEach, describe, expect, expectTypeOf, it, vi } from 'vitest'
+import { storyboardApi } from '@/features/storyboard/api'
+import { productionApi } from '@/features/production/api'
+import type { WorkflowExecutionStart } from '@/features/workflows/execution.types'
+
+/** 清除网络替身,保证边界用例相互隔离。 */
+afterEach(() => vi.unstubAllGlobals())
+
+/** 既有批处理入口只接收真实 202 句柄,不产生最终回执或重复请求。 */
+describe('既有生成入口异步契约', () => {
+ it('所有启动入口返回202句柄并保留原请求范围', async () => {
+ const start = { executionId: 'execution-1', status: 'running' as const }
+ const fetcher = vi
+ .fn()
+ .mockImplementation(async () => new Response(JSON.stringify({ data: start }), { status: 202 }))
+ vi.stubGlobal('fetch', fetcher)
+ const batch = { concurrency: 2, force: false }
+ const calls = [
+ storyboardApi.regenerateEpisodeShots('project-1', 3),
+ storyboardApi.generateDirections('project-1', batch),
+ storyboardApi.generateVisualStates('project-1', { ...batch, maxRepairAttempts: 2 }),
+ storyboardApi.generatePrompts('project-1', batch),
+ productionApi.generateKeyframes('project-1', { ...batch, episodeNo: 3, limit: 1 })
+ ]
+ for (const result of await Promise.all(calls)) expect(result).toEqual(start)
+ expect(fetcher).toHaveBeenCalledTimes(5)
+ expect(fetcher.mock.calls[0]?.[1]?.body).toBe(JSON.stringify({ episodeNo: 3 }))
+ expect(fetcher.mock.calls[4]?.[1]?.body).toBe(JSON.stringify({ ...batch, episodeNo: 3, limit: 1 }))
+ })
+ it('启动类型与最终批量回执严格分开', () => {
+ expectTypeOf<
+ Awaited>
+ >().toEqualTypeOf()
+ expectTypeOf<
+ Awaited>
+ >().toEqualTypeOf()
+ expectTypeOf<
+ Awaited>
+ >().toEqualTypeOf()
+ expectTypeOf<
+ Awaited>
+ >().toEqualTypeOf()
+ expectTypeOf<
+ Awaited>
+ >().toEqualTypeOf()
+ })
+})
diff --git a/tests/features/storyboard/regenerated-source.test.ts b/tests/features/storyboard/regenerated-source.test.ts
new file mode 100644
index 0000000..8ffb079
--- /dev/null
+++ b/tests/features/storyboard/regenerated-source.test.ts
@@ -0,0 +1,44 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+/** 重载保护测试后清理本地标记,避免影响其它测试。 */
+afterEach(() => localStorage.clear())
+import { currentEpisodeSource, getStoryboardSession, mergeDesignedShots } from '@/features/storyboard/model'
+import { directionsResult, episodeShots, visualStatesResult } from '@/features/storyboard/testing/fixtures'
+
+describe('重生成后的正式镜头与旧正文隔离', () => {
+ it('新正式镜头仍可操作,但不能回填已失效的旧标题、剧情和时长', () => {
+ const projectId = 'regenerated-source-project'
+ const session = getStoryboardSession(projectId)
+ session.invalidatedEpisodeSources[1] = true
+ const directions = directionsResult(projectId, 1, false)
+ directions.beats[0]!.shots[0]!.shotId = 'new-shot-a'
+ directions.beats[1]!.shots[0]!.shotId = 'new-shot-b'
+ const rows = mergeDesignedShots(
+ directions,
+ visualStatesResult(projectId, 1, false),
+ currentEpisodeSource(projectId, 1, episodeShots())
+ )
+ expect(
+ rows
+ .filter(row => row.shotId.startsWith('new-shot'))
+ .map(row => [row.shotId, row.title, row.description, row.durationSeconds])
+ ).toEqual([
+ ['new-shot-a', '镜头 1', '', undefined],
+ ['new-shot-b', '镜头 1', '', undefined]
+ ])
+ })
+})
+
+it('两集先后重生成后,即使任务句柄被隐藏,重载仍恢复全部失效正文保护', async () => {
+ const module = await import('@/features/storyboard/model')
+ const projectId = 'multi-episode-reload-project'
+ module.invalidateEpisodeSource(projectId, 1)
+ module.invalidateEpisodeSource(projectId, 2)
+ localStorage.removeItem(`short-drama:workflow-execution:${projectId}:breakdown`)
+ vi.resetModules()
+ const restored = await import('@/features/storyboard/model')
+ expect(restored.currentEpisodeSource(projectId, 1, episodeShots(1))).toBeUndefined()
+ expect(restored.currentEpisodeSource(projectId, 2, episodeShots(2))).toBeUndefined()
+ restored.clearEpisodeSourceInvalidations(projectId)
+ expect(restored.currentEpisodeSource(projectId, 1, episodeShots(1))?.episodeNo).toBe(1)
+})
diff --git a/tests/features/subject-identity/contract-sync-api.test.ts b/tests/features/subject-identity/contract-sync-api.test.ts
new file mode 100644
index 0000000..e0d1c76
--- /dev/null
+++ b/tests/features/subject-identity/contract-sync-api.test.ts
@@ -0,0 +1,40 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { subjectIdentityApi } from '@/features/subject-identity/api'
+
+/** 每个契约用例完成后清理网络替身。 */
+afterEach(() => vi.unstubAllGlobals())
+
+/** 验证正式身份路由和付费请求没有自动重试。 */
+describe('身份正式接口契约', () => {
+ it('预览与实际生成传递相同参数,并支持取消预览', async () => {
+ const fetcher = vi
+ .fn()
+ .mockImplementation(async () => new Response(JSON.stringify({ data: {} }), { status: 200 }))
+ vi.stubGlobal('fetch', fetcher)
+ const input = {
+ viewType: 'primary' as const,
+ provider: 'qwen-image',
+ generationOptions: { size: '2048*2048' },
+ referenceImageId: 'image-1',
+ prompt: '真实完整提示词'
+ }
+ await subjectIdentityApi.previewImage('subject-1', input, new AbortController().signal)
+ await subjectIdentityApi.generateImage('subject-1', input)
+ expect(fetcher.mock.calls[0]?.[0]).toContain('/subjects/subject-1/identity/images/preview')
+ expect(fetcher.mock.calls[0]?.[1]?.body).toBe(JSON.stringify(input))
+ expect(fetcher.mock.calls[1]?.[1]?.body).toBe(fetcher.mock.calls[0]?.[1]?.body)
+ })
+ it('校验指定正式图片,质量生成保留有限修复次数和模型参数', async () => {
+ const fetcher = vi
+ .fn()
+ .mockImplementation(async () => new Response(JSON.stringify({ data: {} }), { status: 200 }))
+ vi.stubGlobal('fetch', fetcher)
+ await subjectIdentityApi.validateImage('subject-1', 'image-1')
+ const input = { maxRepairAttempts: 1, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }
+ await subjectIdentityApi.generateStableAnchorQuality('subject-1', input)
+ expect(fetcher.mock.calls[0]?.[0]).toContain('/subjects/subject-1/identity/images/image-1/validate')
+ expect(fetcher.mock.calls[1]?.[0]).toContain('/subjects/subject-1/identity/stable-anchor/generate-quality')
+ expect(fetcher.mock.calls[1]?.[1]?.body).toBe(JSON.stringify(input))
+ expect(fetcher).toHaveBeenCalledTimes(2)
+ })
+})
diff --git a/tests/features/workflows/execution-target.test.ts b/tests/features/workflows/execution-target.test.ts
new file mode 100644
index 0000000..f803362
--- /dev/null
+++ b/tests/features/workflows/execution-target.test.ts
@@ -0,0 +1,117 @@
+import { effectScope, ref } from 'vue'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { useWorkflowExecution } from '@/features/workflows/execution'
+import { workflowExecutionApi } from '@/features/workflows/execution-api'
+
+/** 每个测试恢复句柄和网络依赖,避免项目任务泄漏到下一次验证。 */
+afterEach(() => {
+ localStorage.clear()
+ vi.restoreAllMocks()
+})
+
+describe('异步任务启动后的项目归属', () => {
+ it('原项目的启动回执到达时,只保存原项目句柄,不切换当前项目的观察目标', async () => {
+ const loader = vi.spyOn(workflowExecutionApi, 'get')
+ const scope = effectScope()
+ const projectId = ref('project-b')
+ const execution = scope.run(() => useWorkflowExecution(projectId, 'production'))!
+ await execution.track('execution-a', 'project-a')
+ expect(localStorage.getItem('short-drama:workflow-execution:project-a:production')).toBe('execution-a')
+ expect(localStorage.getItem('short-drama:workflow-execution:project-b:production')).toBeNull()
+ expect(execution.executionId.value).toBe('')
+ expect(loader).not.toHaveBeenCalled()
+ scope.stop()
+ })
+})
+
+it('同项目首帧后台任务在各观察器间同步,并阻止其它付费操作直到真实终态', async () => {
+ const { getOperation } = await import('@/features/workflows/operations')
+ const id = ref('shared-quality-project')
+ const record = {
+ id: 'quality-exec',
+ projectId: id.value,
+ workflowName: 'keyframe-quality',
+ status: 'running' as 'running' | 'completed',
+ stage: 'keyframe_quality',
+ current: 0,
+ total: 1,
+ currentResourceId: null,
+ metadata: {},
+ result: null,
+ error: null,
+ startedAt: null,
+ completedAt: null,
+ createdAt: '2026-10-08',
+ updatedAt: '2026-10-08'
+ }
+ vi.spyOn(workflowExecutionApi, 'get').mockImplementation(async () => ({ ...record }))
+ const scope = effectScope()
+ const [first, second] = scope.run(() => [
+ useWorkflowExecution(id, 'keyframe-quality'),
+ useWorkflowExecution(id, 'keyframe-quality')
+ ])!
+ await first!.track(record.id, id.value)
+ expect(getOperation(id.value).pending).toBe(true)
+ expect(second!.executionId.value).toBe(record.id)
+ expect(second!.active.value).toBe(true)
+ record.status = 'completed'
+ await first!.query.refresh()
+ expect(getOperation(id.value).pending).toBe(false)
+ scope.stop()
+})
+
+it('已卸载观察器的迟到 running 记录不能重新锁住其它观察器已确认结束的任务', async () => {
+ const { getOperation } = await import('@/features/workflows/operations')
+ const id = ref('terminal-monotonic-project')
+ const record = {
+ id: 'terminal-exec',
+ projectId: id.value,
+ workflowName: 'keyframe-quality',
+ status: 'running' as 'running' | 'completed',
+ stage: 'keyframe_quality',
+ current: 0,
+ total: 1,
+ currentResourceId: null,
+ metadata: {},
+ result: null,
+ error: null,
+ startedAt: null,
+ completedAt: null,
+ createdAt: '2026-10-08',
+ updatedAt: '2026-10-08'
+ }
+ let delayed = false
+ let finish!: (value: typeof record) => void
+ vi.spyOn(workflowExecutionApi, 'get').mockImplementation(async () => {
+ if (delayed) {
+ delayed = false
+ return new Promise(resolve => {
+ finish = resolve
+ })
+ }
+ return { ...record }
+ })
+ const firstScope = effectScope()
+ const secondScope = effectScope()
+ const first = firstScope.run(() => useWorkflowExecution(id, 'keyframe-quality'))!
+ const second = secondScope.run(() => useWorkflowExecution(id, 'keyframe-quality'))!
+ await first.track(record.id, id.value)
+ delayed = true
+ const lateResponse = first.query.refresh()
+ firstScope.stop()
+ record.status = 'completed'
+ await second.query.refresh()
+ expect(getOperation(id.value).pending).toBe(false)
+ finish({ ...record, status: 'running' })
+ await lateResponse
+ expect(getOperation(id.value).pending).toBe(false)
+ secondScope.stop()
+})
+
+it('后台启动未返回编号时不静默当作已跟踪,也不保存虚假句柄', async () => {
+ const scope = effectScope()
+ const execution = scope.run(() => useWorkflowExecution(ref('missing-execution-id-project'), 'production'))!
+ await expect(execution.track('', 'missing-execution-id-project')).rejects.toThrow('任务编号')
+ expect(localStorage.getItem('short-drama:workflow-execution:missing-execution-id-project:production')).toBeNull()
+ scope.stop()
+})
diff --git a/tests/features/workflows/execution.test.ts b/tests/features/workflows/execution.test.ts
index a8aac30..e1f69ac 100644
--- a/tests/features/workflows/execution.test.ts
+++ b/tests/features/workflows/execution.test.ts
@@ -40,9 +40,7 @@ describe('WorkflowExecution 前端契约', () => {
it('刷新页面后使用保存的 executionId 读取后端权威状态', async () => {
localStorage.setItem('short-drama:workflow-execution:project-1:video-quality', 'execution-1')
- const fetcher = vi.fn().mockResolvedValue(
- new Response(JSON.stringify({ data: execution() }))
- )
+ const fetcher = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: execution() })))
vi.stubGlobal('fetch', fetcher)
const scope = effectScope()
const tracker = scope.run(() => useWorkflowExecution(ref('project-1'), 'video-quality'))!
@@ -50,6 +48,11 @@ describe('WorkflowExecution 前端契约', () => {
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/workflow-executions/execution-1')
expect(tracker.query.data.value?.stage).toBe('validating')
tracker.dismiss()
+ expect(localStorage.getItem('short-drama:workflow-execution:project-1:video-quality')).toBe('execution-1')
+ expect(tracker.active.value).toBe(true)
+ fetcher.mockResolvedValue(new Response(JSON.stringify({ data: execution({ status: 'completed' }) })))
+ await tracker.query.refresh()
+ tracker.dismiss()
expect(localStorage.getItem('short-drama:workflow-execution:project-1:video-quality')).toBeNull()
scope.stop()
})