feat(short-drama-agent-front): 完善视觉资产审核流程

This commit is contained in:
GJ committed 2026-11-04 14:09:21 +08:00
1 parent dc8bb17a23
commit b88ad8770f
45 files changed
+2258 -352

No files matched your search

+9
View File
@@ -24,6 +24,7 @@ import StoryboardList from './components/StoryboardList.vue'
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
import BreakdownDurationDiagnostics from './components/BreakdownDurationDiagnostics.vue'
import BreakdownIssuesDialog from './components/BreakdownIssuesDialog.vue'
import CandidateRepairs from './components/CandidateRepairs.vue'
import ActionExceptionRepair from './components/ActionExceptionRepair.vue'
@@ -1119,6 +1120,14 @@ const isInitialEmpty = computed(
@locate="locateIssue"
@refresh="refreshCandidate"
>
<!-- 以下是失败候选与正式时长来源的只读核对 -->
<template #duration>
<BreakdownDurationDiagnostics
v-if="issuesOpen && projectId"
:project-id="projectId"
:checkpoint-id="latestCheckpoint?.checkpointId"
/>
</template>
<!-- 以下是只属于问题处理的人工修订与阶段恢复,不混入拆解启动配置 -->
<template #repair>
<p v-if="breakdownBusy || operation.pending" role="status" class="text-xs leading-6 text-muted">
+4 -1
View File
@@ -3,6 +3,7 @@ import type { CandidateCommitPreview, CandidateCommitCheckPreview } from './cand
/** 安全检查项与用户可理解的阻断原因共用一份映射。 */
export const candidateCheckLabels: Record<keyof CandidateCommitCheckPreview['checks'], string> = {
durationBudgetCurrent: '候选预算与当前正式时长一致',
qualityPolicyMatches: '质量规则与当前已确认版本一致',
episodeNumbersMatch: '剧集范围与候选一致',
episodeFingerprintsMatch: '剧本正文版本未变化',
@@ -16,6 +17,7 @@ export const candidateCheckLabels: Record<keyof CandidateCommitCheckPreview['che
/** 必须逐项校验的固定安全门禁,不根据响应动态减少检查项。 */
export const candidateCheckKeys = [
'qualityPolicyMatches',
'durationBudgetCurrent',
'episodeNumbersMatch',
'episodeFingerprintsMatch',
'noActiveExecutions',
@@ -42,7 +44,8 @@ export function candidatePreviewReady(
!preview ||
preview.status === 'already_committed' ||
preview.projectId !== projectId ||
preview.checkpointId !== checkpointId
preview.checkpointId !== checkpointId ||
!!preview.durationSourceIssue
)
return false
// 外部 JSON 的布尔值必须严格为 true,不接受缺失值或字符串等真值。
@@ -147,8 +147,12 @@ export interface CandidateCommitCheckPreview {
/** 未提交分支不携带已提交状态。 */ status?: never
/** 关系来源阻断的原始说明。 */ relationIssues: string[]
/** 可供人工核对的原始关系,不代表已经确认删除。 */ relationRepairTargets: CandidateRelationTarget[]
/** 当前正式预算来源冲突说明。 */
durationSourceIssue?: string | null
/** 剧本版本、活动任务及下游资产保护。 */
checks: {
/** 候选与正式预算版本一致。 */
durationBudgetCurrent: boolean
/** 候选使用的质量规则与当前明确确认版本一致。 */
qualityPolicyMatches: boolean
/** 剧集编号一致。 */
@@ -12,6 +12,7 @@ import { breakdownApi } from '../api'
import { runOperation, getOperation } from '../../workflows/operations'
import { projectsApi } from '../../projects/api'
import { workflowCheckpoints } from '../../workflows/selectors'
import { userFacingText } from '../../../lib/user-facing-text'
import { ApiError, errorMessage } from '../../../lib/http'
import { showActionFeedback, useActionMessage } from '../../../components/ui/useActionMessage'
@@ -86,6 +87,7 @@ const ready = computed(() => candidatePreviewReady(preview.value, props.projectI
const failedChecks = computed(() =>
current.value ? candidateCheckKeys.filter(key => current.value!.checks?.[key] !== true) : []
)
/** 原始关系只能来自本次安全预检,不解析问题字符串构造删除参数。 */
const targets = computed(() => current.value?.relationRepairTargets ?? [])
/** 用户选择的关系仍需校验完整且定位唯一。 */
@@ -398,6 +400,10 @@ async function commit() {
</section>
</section>
<!-- 以下是后端返回的关系问题与正式原文,窄屏自然改为单列 -->
<!-- 以下是正式时长预算的来源冲突 -->
<p v-if="current.durationSourceIssue" class="text-sm text-danger">
{{ userFacingText(current.durationSourceIssue) }}
</p>
<div v-if="targets.length || current.relationIssues?.length" class="grid min-w-0 gap-6 lg:grid-cols-2">
<section class="min-w-0 space-y-4" aria-label="无来源关系">
<WorkspaceSectionHeading
@@ -0,0 +1,192 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
import { useQuery } from '../../../composables/useQuery'
import { userFacingText } from '../../../lib/user-facing-text'
import { projectsApi } from '../../projects/api'
import { breakdownApi } from '../api'
import type { BreakdownDurationFailure, EpisodeShots } from '../types'
/** 时长诊断使用最新候选证据和正式预算的独立只读来源。 */
const props = defineProps<{
/** 当前项目编号。 */ projectId: string
/** 当前保存记录变化时刷新。 */ checkpointId?: string
}>()
/** 查询随保存记录更新,旧候选不会回填当前任务。 */
const key = computed(() => JSON.stringify([props.projectId, props.checkpointId]))
/** 正式结果和候选诊断独立读取,保留某一来源暂不可用时的另一份结果。 */
const query = useQuery(key, async (value, signal) => {
const [projectId] = JSON.parse(value) as [string, string?]
const [formal, latest] = await Promise.allSettled([
projectsApi.durationBudget(projectId, signal),
breakdownApi.latest(projectId, signal)
])
if (formal.status === 'fulfilled' && formal.value.projectId !== projectId)
throw new Error('时长资料与当前项目不匹配。')
if (latest.status === 'fulfilled' && latest.value?.projectId && latest.value.projectId !== projectId)
throw new Error('失败记录与当前项目不匹配。')
return { formal, latest }
})
/** 正式预算来自当前项目服务,包含尚无镜头的正式剧集。 */
const formal = computed(() =>
query.data.value?.formal.status === 'fulfilled' ? query.data.value.formal.value.episodes : []
)
/** 最新失败候选和原始预算快照保留用于诊断。 */
const latest = computed(() => (query.data.value?.latest.status === 'fulfilled' ? query.data.value.latest.value : null))
/** 只选最新记录中实际返回的完整失败候选。 */
const failures = computed(() => {
const entries = latest.value?.failureDetails?.details
return Array.isArray(entries)
? entries.filter(
(item): item is BreakdownDurationFailure =>
item?.kind === 'storyboard-duration-failure' &&
item.candidate?.episodePlan &&
Array.isArray(item.candidate?.beatShots)
)
: []
})
/**
* 失败时可能尚未产出预算审计,按已返回的镜头阶段估算供复盘。
* @param candidate 服务器返回的失败候选
* @returns 只读估算,不用于通过审核或修改正式分镜
*/
function estimateFailedBudget(candidate: EpisodeShots) {
const beatSuggestions = candidate.beatShots.flatMap(beat => {
const budget = candidate.episodePlan.beats.find(item => item.beatNo === beat.beatNo)?.estimatedDurationSeconds
if (!budget || !beat.shots.length) return []
const required = beat.shots.reduce((sum, shot) => {
const planning = shot.durationPlanning
const estimated = planning?.phases.reduce(
(total, phase) => total + phase.estimatedSeconds,
planning.transitionSeconds
)
const supported =
planning && estimated !== undefined && Math.abs(estimated - planning.recommendedDurationSeconds) <= 0.1
return sum + (supported ? Math.max(shot.durationSeconds, estimated) : shot.durationSeconds)
}, 0)
return [
{
beatNo: beat.beatNo,
requiredSeconds: Number(required.toFixed(2)),
deficitSeconds: required > budget + 0.1 ? Number((required - budget).toFixed(2)) : 0
}
]
})
if (!beatSuggestions.length) return undefined
return {
beatSuggestions,
minimumRequiredSeconds: Number(beatSuggestions.reduce((sum, beat) => sum + beat.requiredSeconds, 0).toFixed(2)),
deficitSeconds: Number(beatSuggestions.reduce((sum, beat) => sum + beat.deficitSeconds, 0).toFixed(2)),
estimated: true
}
}
/** 对应候选规划的目标版本、所有段落预算与已知缺口。 */
const plans = computed(() => {
const items = new Map((latest.value?.storyboardPlans ?? []).map(plan => [plan.episodeNo, plan]))
for (const failure of failures.value) items.set(failure.episodeNo, failure.candidate.episodePlan)
return [...items.values()].map(plan => ({
...plan,
report:
latest.value?.storyboardEpisodeDurationBudgets?.find(item => item.episodeNo === plan.episodeNo) ??
failures.value
.filter(item => item.episodeNo === plan.episodeNo)
.map(item => estimateFailedBudget(item.candidate))[0],
formal: formal.value.find(item => item.episodeNo === plan.episodeNo)
}))
})
</script>
<template>
<!-- 以下是正式时长与候选来源的只读诊断 -->
<section class="space-y-4" aria-label="时长预算诊断">
<WorkspaceSectionHeading
title="时长预算"
description="分别核对正式剧集目标和拆解时采用的预算。失败候选可用于复盘。"
/>
<p v-if="query.loading.value" class="text-sm text-muted">正在读取时长预算…</p>
<div v-else-if="query.error.value" class="space-y-2 text-sm">
<p>{{ query.error.value }}</p>
<NButton size="small" @click="query.refresh">重新读取预算</NButton>
</div>
<template v-else>
<p
v-if="query.data.value?.formal.status === 'rejected' || query.data.value?.latest.status === 'rejected'"
class="text-sm text-muted"
>
部分时长来源暂时无法读取。<NButton text size="small" @click="query.refresh">重新读取</NButton>
</p>
<ul v-if="formal.length" class="grid gap-2 sm:grid-cols-2 text-sm">
<li v-for="episode in formal" :key="episode.episodeNo">
第 {{ episode.episodeNo }} 集 · 正式目标
{{ episode.targetDurationSeconds == null ? '自动' : `${episode.targetDurationSeconds} 秒` }} ·
正式镜头
{{ episode.shotCount && episode.shotSeconds != null ? `${episode.shotSeconds} 秒` : '未生成' }}
</li>
</ul>
<NCollapse v-if="plans.length">
<NCollapseItem
v-for="plan in plans"
:key="plan.episodeNo"
:name="plan.episodeNo"
:title="`第 ${plan.episodeNo} 集 · 拆解预算快照`"
>
<div class="space-y-2 text-sm">
<p>
拆解时目标
{{
plan.targetDurationSeconds === undefined
? '历史未记录'
: plan.targetDurationSeconds === null
? '自动'
: `${plan.targetDurationSeconds} 秒`
}}
</p>
<p
v-if="plan.formal && plan.targetDurationSeconds !== plan.formal.targetDurationSeconds"
class="text-danger"
>
{{
plan.targetDurationSeconds === undefined
? '缺少原预算快照,请核对来源。'
: '拆解后的正式目标已变化,请核对来源。'
}}
</p>
<p v-if="plan.report">
<span v-if="'estimated' in plan.report">根据失败候选估算 · </span>动作最低需求
{{ plan.report.minimumRequiredSeconds }} 秒 · 段落缺口合计
{{ plan.report.deficitSeconds }} 秒
</p>
<ul class="space-y-2">
<li v-for="beat in plan.beats" :key="beat.beatNo">
段落 {{ beat.beatNo }} · {{ beat.title }} · 预算 {{ beat.estimatedDurationSeconds }} 秒
<span
v-for="gap in plan.report?.beatSuggestions.filter(
item => item.beatNo === beat.beatNo
)"
:key="gap.beatNo"
:class="{ 'text-danger': gap.deficitSeconds > 0 }"
>
· 最低需求 {{ gap.requiredSeconds }} 秒 · 缺口 {{ gap.deficitSeconds }} 秒
</span>
</li>
</ul>
</div>
</NCollapseItem>
</NCollapse>
<p
v-if="failures.length && latest?.workflowExecution?.errorMessage"
class="text-sm text-danger wrap-anywhere"
>
{{ userFacingText(latest.workflowExecution.errorMessage) }}
</p>
<RawDataDetails
v-for="(failure, index) in failures"
:key="index"
:title="`第 ${failure.episodeNo} 集 · 完整失败候选`"
:value="failure"
/>
</template>
</section>
</template>
@@ -68,6 +68,8 @@ const groups = computed(() => {
const count = computed(() => groups.value.reduce((total, group) => total + group.messages.length, 0))
/** 等待离场后执行的定位。 */
const pendingLocation = ref<ShotValidation['issues'][number] | null>(null)
/** 时长资料按需读取,与其它问题查询独立。 */
const diagnosticSections = ref<string[]>([])
/**
* 关闭问题抽屉后定位到对应剧集、节拍或镜头。
@@ -104,6 +106,12 @@ function finish() {
><span v-else-if="count">{{ count }} 项校验问题 · {{ groups.length }} 个位置</span
><span v-else>查看最近保存结果中的问题</span></template
>
<!-- 以下是独立的上游时长诊断 -->
<NCollapse v-if="$slots.duration" v-model:expanded-names="diagnosticSections" class="mb-5">
<NCollapseItem name="duration" title="查看时长预算与失败候选">
<slot v-if="diagnosticSections.includes('duration')" name="duration" />
</NCollapseItem>
</NCollapse>
<!-- 以下是当前版本的分类问题,历史错误不会混入当前问题数量 -->
<div v-if="quality" class="space-y-5" :aria-busy="quality.loading">
<p v-if="quality.loading" class="text-sm text-muted" role="status">正在读取当前候选审核…</p>
+32
View File
@@ -93,6 +93,8 @@ export interface StoryboardBeat {
/** 单集分镜规划。 */
export interface EpisodePlan {
/** 正式时长目标快照,空值为自动,缺失为历史未记录。 */
targetDurationSeconds?: number | null
episodeNo: number
episodeTitle: string
storyGoal: string
@@ -131,6 +133,30 @@ export interface ShotValidation {
issues: { episodeNo: number; beatNo?: number | null; shotNo?: number | null; message: string }[]
}
/** 当前拆解候选的只读时长审计。 */
export interface BreakdownDurationBudget {
/** 正式集数。 */ episodeNo: number
/** 已规划的段落预算之和。 */ plannedSeconds: number
/** 当前镜头及动作所需最低总时长。 */ minimumRequiredSeconds: number
/** 局部段落缺口之和。 */ deficitSeconds: number
/** 局部段落的预算及缺口。 */
beatSuggestions: Array<{
/** 段落号。 */ beatNo: number
/** 原段落预算。 */ budgetSeconds: number
/** 最低需求。 */ requiredSeconds: number
/** 当前缺口。 */ deficitSeconds: number
}>
/** 当前需要人工核对。 */ needsReview: boolean
}
/** 最新失败保存记录中的完整实际候选。 */
export interface BreakdownDurationFailure {
/** 正式候选诊断类型。 */ kind: 'storyboard-duration-failure'
/** 失败集数。 */ episodeNo: number
/** 完整候选保留供诊断。 */ candidate: EpisodeShots
/** 此失败不自动恢复。 */ retryAutomatically: false
}
/** Breakdown 的最终成果及阶段 checkpoint 共有的可展示字段。 */
export interface BreakdownResult {
subjectCandidates?: SubjectCandidate[]
@@ -152,6 +178,12 @@ export interface WorkflowExecution {
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
export interface BreakdownState extends BreakdownResult {
/** 最新保存记录编号。 */
checkpointId?: string
/** 当前服务端时长审计。 */
storyboardEpisodeDurationBudgets?: BreakdownDurationBudget[]
/** 失败详情仅用于诊断,不作为恢复请求参数。 */
failureDetails?: { /** 实际失败的结构化证据。 */ details?: unknown }
/** 快照所属项目;旧版观测响应可能缺省。 */
projectId?: string
/** 当前镜头动作质量决策,不从嵌套历史成果继承。 */