feat(short-drama-agent-front): 新增拆解候选与质量修订

This commit is contained in:
GJ committed 2026-10-17 08:25:16 +08:00
1 parent 49ad08a63e
commit 3414cc8232
32 files changed
+2319 -454

No files matched your search

+69 -21
View File
@@ -9,7 +9,7 @@ import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NTab, NTable, NTabs } from 'naive-ui'
import { computed, h, onScopeDispose, ref, watch } from 'vue'
import { useActionMessage } from '../../components/ui/useActionMessage'
import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
import { Layers, LoaderCircle, Settings2 } from '@lucide/vue'
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
import { useProjectContext } from '../projects/context'
import { breakdownApi } from './api'
@@ -22,6 +22,8 @@ import { useWorkflowExecution } from '../workflows/execution'
import SubjectList from './components/SubjectList.vue'
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 type { DiagnosisLocation } from './diagnosis'
import { errorMessage } from '../../lib/http'
import { downloadText, nodeLabel } from '../../lib/format'
@@ -32,6 +34,8 @@ const groupSize = ref(3)
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
const preview = ref<BreakdownPreview | null>(null)
const previewBusy = ref(false)
/** 默认只生成候选,正式替换需单独确认。 */
const candidateOnly = ref(true)
const tab = ref('character')
const toolsOpen = ref(false)
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
@@ -40,6 +44,16 @@ const moduleOptions: { value: BreakdownModule; label: string; description: strin
{ value: 'prop', label: '道具', description: '关键物件与视觉描述' }
]
const records = computed(() => workflowCheckpoints(checkpoints.value, 'breakdown'))
/** 提交候选只读取最新原始记录,避免从旧快照恢复提交资格。 */
const latestCheckpoint = computed(() => records.value.at(-1))
/** 有旧结果后统一采用候选模式,不再从设置入口直接覆盖。 */
watch(
() => records.value.length,
count => {
if (count > 0) candidateOnly.value = true
},
{ immediate: true }
)
const snapshot = computed(() => breakdownSnapshot(checkpoints.value))
const result = computed(() => snapshot.value?.breakdownResult ?? snapshot.value)
const subjects = computed(() => result.value?.subjectCandidates ?? [])
@@ -100,8 +114,13 @@ const showRecovery = computed(
const configValid = computed(
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
)
const input = computed<BreakdownInput>(() => ({ groupSize: groupSize.value, modules: [...modules.value] }))
/** 后端就绪状态决定是否显示后续制作入口。 */
/** 预览配置与明确选择的生成模式共用一次启动快照。 */
const input = computed<BreakdownInput>(() => ({
groupSize: groupSize.value,
modules: [...modules.value],
candidateOnly: candidateOnly.value
}))
/** 后端就绪状态用于拆解完成反馈。 */
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
const actionMessage = useActionMessage()
@@ -173,6 +192,8 @@ function invalidatePreview() {
watch(
[
groupSize,
candidateOnly,
projectId,
() => modules.value.join(','),
() => project.value?.episodes.map(item => item.episode + ':' + item.content).join('|')
],
@@ -203,7 +224,10 @@ async function loadPreview() {
}
}
/** 长请求不随路由切换取消,返回后刷新 checkpoint 与正式项目数据。 */
/**
* 提交后台任务并观察真实状态,启动时固定当前候选模式。
* @param action 本次启动或恢复动作
*/
async function run(action: BreakdownAction) {
if (project.value?.status !== 'completed' || operation.value.pending || error.value) return
if (action === 'start' && !canStart.value) return
@@ -227,6 +251,11 @@ async function run(action: BreakdownAction) {
await refresh()
}
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
async function refreshCandidate() {
await Promise.all([refresh(), refreshStageReadiness()])
}
/** 导出当前拆解结果;阶段性数据也明确标记为 snapshot。 */
function exportResult() {
if (!snapshot.value) return
@@ -259,14 +288,16 @@ const rules = {
:status="execution?.status || 'unknown'"
:label="
execution?.status === 'completed'
? '工作流已完成'
? latestCheckpoint?.state.candidateOnly && !latestCheckpoint.state.storyboardPersisted
? '候选生成已完成'
: '工作流已完成'
: execution?.status === 'failed'
? '工作流失败'
: '执行状态待确认'
"
/>
</div>
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗 -->
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗;阶段切换使用侧栏 -->
<div v-if="project?.episodes.length" class="toolbar-actions">
<NButton
v-if="execution?.errorMessage || validation?.valid === false"
@@ -275,9 +306,7 @@ const rules = {
@click="toolsOpen = true"
>查看拆解问题</NButton
>
<RouterLink v-if="stageComplete" :to="`/projects/${projectId}/visual-style`" class="text-button"
>继续视觉风格 →</RouterLink
>
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
@@ -364,6 +393,18 @@ const rules = {
</NButton>
</div>
</AppForm>
<!-- 以下是候选生成模式,已有拆解结果统一通过安全提交替换 -->
<div class="mt-4 space-y-2">
<NCheckbox
v-model:checked="candidateOnly"
:disabled="operation.pending || records.length > 0"
>
仅生成候选,确认后再提交正式结果
</NCheckbox>
<p class="text-xs leading-6 text-muted">
候选不会替换现有主体和分镜。重新拆解使用候选模式,完成后单独审核与提交。
</p>
</div>
<div v-if="preview" class="group-preview">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<p class="text-sm">
@@ -376,10 +417,10 @@ const rules = {
isOperationRunning(operation, '正在拆解剧本') ||
backgroundExecution.active.value
"
:label="records.length ? '重新拆解' : '开始拆解'"
:label="candidateOnly ? '生成拆解候选' : '开始拆解'"
:description="
records.length
? '这会重新运行完整剧本拆解,可能替换已保存的主体与分镜。只想恢复失败阶段时,请使用下方对应恢复操作。'
candidateOnly
? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。'
: '将按当前预览配置启动完整的 剧本拆解流程。抽取结束后仍需完成主体整理、分镜生成与入库。'
"
:acknowledgement="records.length > 0"
@@ -402,6 +443,20 @@ const rules = {
当前任务还没有明确的完成或失败记录。为避免重复执行,已暂停重新拆解;如任务已中断,请先刷新状态,再选择对应恢复操作。
</p>
</section>
<BreakdownCandidatePanel
:project-id="projectId"
:state="latestCheckpoint?.state"
:checkpoint-id="latestCheckpoint?.checkpointId"
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<StoryboardQualityRepair
v-if="toolsOpen && snapshot"
:project-id="projectId"
:checkpoint="latestCheckpoint"
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本拆解任务"
@@ -533,9 +588,7 @@ const rules = {
<EmptyState
title="还没有可拆解的剧集"
description="先完成剧本创作。拆解会读取数据库中的正式剧集,不需要上传 checkpoint。"
><RouterLink class="button button-primary" :to="`/projects/${project?.id}/create-drama`"
>前往剧本创作<ArrowRight :size="14" /></RouterLink
></EmptyState>
/>
</NScrollbar>
<template v-else>
<section class="breakdown-results-section">
@@ -593,7 +646,7 @@ const rules = {
:episodes="shots"
@diagnose="openShotDiagnosis"
>
<!-- 以下是跟随当前剧集的一行诊断摘要,抽屉独立于列表滚动 -->
<!-- 以下是跟随当前剧集的一行诊断摘要,诊断弹窗独立于列表滚动 -->
<template #diagnosis>
<StoryboardDiagnosis
ref="diagnosisPanel"
@@ -603,11 +656,6 @@ const rules = {
@locate="locateDiagnosisShot"
/>
</template>
<template #actions>
<RouterLink :to="`/projects/${project?.id}/storyboard`" class="text-button"
>进入分镜设计<ArrowRight :size="14"
/></RouterLink>
</template>
</StoryboardList>
</div>
<div v-if="tab === 'tasks'" class="breakdown-result-pad">
+50 -1
View File
@@ -4,6 +4,7 @@ import type {
BreakdownInput,
BreakdownPreview,
BreakdownState,
BreakdownCandidateCommit,
StoryboardHandOccupancyDiagnostics,
StoryboardHandRepairPreview,
StoryboardHandRepairHistory,
@@ -12,9 +13,57 @@ import type {
LegacyActionDiagnosisResults
} from './types'
import type { WorkflowExecutionStart } from '../workflows/execution.types'
import type {
QualityRepairPlan,
QualityRepairCandidates,
QualityRepairInput,
QualityRepairResult
} from './repair.types'
/** Breakdown API;预览为 GET,启动和恢复为等待完成的长 POST。 */
/** Breakdown API;预览为只读查询,启动和恢复返回可持续观察的后台任务。 */
export const breakdownApi = {
/**
* 读取当前仍被质量审核阻断的镜头。
* @param id 当前项目编号
* @param signal 请求取消信号
* @returns 版本化的修复清单
*/
qualityRepairPlan: (id: string, signal?: AbortSignal) =>
request<QualityRepairPlan>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair-plan`, {
signal
}),
/**
* 读取后端确认仍有效的局部修订候选。
* @param id 当前项目编号
* @param signal 请求取消信号
* @returns 含镜头指纹的候选建议
*/
qualityRepairCandidates: (id: string, signal?: AbortSignal) =>
request<QualityRepairCandidates>(
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair-candidates`,
{ signal }
),
/**
* 人工修订单镜头动作规划,不触发模型或替换正式资产。
* @param id 当前项目编号
* @param input 完整动作字段与版本约束
* @returns 修订后的检查点和恢复资格
*/
repairQualityShot: (id: string, input: QualityRepairInput) =>
request<QualityRepairResult>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair`, {
method: 'POST',
body: input
}),
/**
* 明确确认后提交服务端最新候选,不上传或拼装正式资产。
* @param id 当前项目编号
* @returns 后端事务保存后的正式资产统计
*/
commitCandidate: (id: string) =>
request<BreakdownCandidateCommit>(`/projects/${encodeURIComponent(id)}/breakdown/commit-candidate`, {
method: 'POST',
body: { confirmed: true }
}),
preview: (id: string, input: BreakdownInput, signal?: AbortSignal) => {
const query = new URLSearchParams({ groupSize: String(input.groupSize), modules: input.modules.join(',') })
return request<BreakdownPreview>(`/projects/${encodeURIComponent(id)}/breakdown-preview?${query}`, { signal })
+32
View File
@@ -0,0 +1,32 @@
import type { BreakdownState } from './types'
/**
* 仅用最新原始快照提示提交条件,实际替换权限仍由后端事务判断。
* @param state 最新原始拆解快照,禁止传入历史回退拼接结果
* @returns 提交前需要处理的问题,空字符串表示可以请求后端提交
*/
export function candidateCommitIssue(state: BreakdownState | null | undefined): string {
if (state?.candidateOnly !== true) return '当前最新结果不是候选模式。'
if (state.storyboardPersisted === true || state.candidateCommitted === true) return '这份候选已经提交。'
if (state.workflowExecution?.status === 'running') return '候选拆解仍在执行。'
if (state.storyboardShotValidation?.valid !== true) return '候选分镜尚未通过校验。'
if (state.storyboardPendingQualityEpisodeNos?.length) return '仍有剧集未通过质量审核,请先修订。'
if (!state.expectedEpisodeFingerprints || !state.runConfig?.sourceEpisodes?.length)
return '候选缺少剧本版本信息,请重新生成候选。'
const episodes = state.storyboardEpisodeShots ?? []
const source = state.runConfig.sourceEpisodes
if (
!state.subjectCandidates?.length ||
!Array.isArray(state.subjectForms) ||
episodes.length !== source.length ||
source.some(
item =>
!state.expectedEpisodeFingerprints?.[item.episodeNo] ||
!episodes.some(
episode => episode.episodeNo === item.episodeNo && episode.beatShots.some(beat => beat.shots.length)
)
)
)
return '候选主体或分镜不完整,请先完成拆解。'
return ''
}
@@ -0,0 +1,116 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NButton } from 'naive-ui'
import type { BreakdownState } from '../types'
import { candidateCommitIssue } from '../candidate'
import { breakdownApi } from '../api'
import { runOperation, getOperation, isOperationRunning } from '../../workflows/operations'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import { projectsApi } from '../../projects/api'
import { workflowCheckpoints } from '../../workflows/selectors'
/** 最新候选快照及独立提交入口。 */
const props = defineProps<{
/** 当前正式项目编号。 */
projectId: string
/** 服务端最新原始快照,不使用历史回退结果。 */
state?: BreakdownState
/** 当前快照版本,用于撤销旧确认。 */
checkpointId?: string
/** 项目存在活动任务或读取错误。 */
disabled: boolean
}>()
/** 提交后刷新正式资产和阶段状态。 */
const emit = defineEmits<{ refresh: [] }>()
/** 项目级操作锁与错误反馈沿用现有工作区。 */
const operation = computed(() => getOperation(props.projectId))
/** 显式候选标记,历史通过记录不作为提交依据。 */
const isCandidate = computed(() => props.state?.candidateOnly === true)
/** 候选完成后是否已经提交。 */
const committed = computed(() => props.state?.storyboardPersisted === true || props.state?.candidateCommitted === true)
/** 本地可见的提交阻断原因。 */
const issue = computed(() => candidateCommitIssue(props.state))
/** 本轮候选的真实规模。 */
const counts = computed(() => ({
subjects: props.state?.subjectCandidates?.length ?? 0,
episodes: props.state?.storyboardEpisodeShots?.length ?? 0,
shots:
props.state?.storyboardEpisodeShots?.reduce(
(total, episode) => total + episode.beatShots.reduce((sum, beat) => sum + beat.shots.length, 0),
0
) ?? 0
}))
/** 只提交一次,后端事务再次校验剧本版本、候选审核和下游资产。 */
async function commit() {
if (props.disabled || issue.value || operation.value.pending) return
const id = props.projectId
const checkpointId = props.checkpointId
await runOperation(
id,
'正在提交拆解候选',
async () => {
const records = await projectsApi.checkpoints(id)
const latest = workflowCheckpoints(records, 'breakdown').at(-1)
if (
!checkpointId ||
!latest ||
props.projectId !== id ||
props.checkpointId !== checkpointId ||
latest.checkpointId !== checkpointId
)
throw new Error('拆解候选版本已变化,请刷新后重新确认。')
const nextIssue = candidateCommitIssue(latest.state)
if (nextIssue) throw new Error(nextIssue)
const receipt = await breakdownApi.commitCandidate(id)
if (receipt.projectId !== id) throw new Error('候选提交回执的项目不一致,请刷新确认。')
return receipt
},
receipt => ({
type: 'success',
content: `候选已提交:${receipt.subjectCount} 个主体、${receipt.episodeCount} 集、${receipt.shotCount} 个镜头。`
})
)
if (props.projectId === id) emit('refresh')
}
</script>
<template>
<!-- 以下是候选审核与正式提交模块,沿用设置区的模块间距和按钮层级 -->
<section v-if="isCandidate" class="workspace-panel space-y-4" aria-label="拆解候选">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-medium">{{ committed ? '候选已提交' : '待确认的拆解候选' }}</h3>
<span class="text-xs text-muted"
>主体 {{ counts.subjects }} · {{ counts.episodes }} 集 · {{ counts.shots }} 镜</span
>
</div>
<p class="text-xs leading-6 text-muted">
{{
committed
? '这份结果已写入正式主体、形态与分镜。'
: '候选生成不替换正式数据。确认后由后端核对剧本版本、审核结果和下游资产,再统一提交。已有身份、参考图或镜头生产资产时会拒绝替换。'
}}
</p>
<p v-if="!committed && issue" class="text-xs leading-6 text-muted" role="status">{{ issue }}</p>
<div class="flex flex-wrap items-center gap-3">
<ConfirmAction
v-if="!committed"
:key="checkpointId"
label="提交候选为正式结果"
description="将使用服务端最新候选统一替换正式主体、形态与分镜。此操作不调用模型;已有下游资产、剧本变化或审核未通过时,后端会拒绝提交。"
acknowledgement
:disabled="disabled || !!issue || operation.pending"
:loading="isOperationRunning(operation, '正在提交拆解候选')"
@confirm="commit"
/>
<NButton text :disabled="operation.pending" @click="emit('refresh')">刷新候选状态</NButton>
</div>
<p
v-if="operation.error && operation.label === '正在提交拆解候选'"
role="alert"
class="text-xs leading-6 text-danger"
>
{{ operation.error }}
</p>
</section>
</template>
@@ -0,0 +1,291 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NButton, NCheckbox, NFormItem, NInput, NInputNumber, NSelect } from 'naive-ui'
import { actionResourceOptions } from '../../projects/quality-policy'
import type { ShotActionDraft } from '../repair.types'
/** 单镜头动作及资源证据的结构化编辑器。 */
defineProps<{
/** 保存或后台操作期间只读。 */
disabled: boolean
}>()
/** 调用方持有独立草稿,编辑器不改动原始检查点。 */
const draft = defineModel<ShotActionDraft>({ required: true })
/** 动作引用选项随草稿编号更新,非法旧引用由提交校验提示。 */
const actionOptions = computed(() =>
draft.value.requiredActions
.filter(item => item.id.trim())
.map(item => ({ value: item.id, label: `${item.id} · ${item.description || '待填写描述'}` }))
)
/** 动作种类。 */
const kindOptions = [
{ value: 'action', label: '动作' },
{ value: 'state', label: '状态' }
]
/** 动作复杂度。 */
const complexityOptions = [
{ value: 'low', label: '低' },
{ value: 'medium', label: '中' },
{ value: 'high', label: '高' }
]
/** 手部枚举。 */
const handOptions = [
{ value: 'left', label: '左手' },
{ value: 'right', label: '右手' },
{ value: 'both', label: '双手' }
]
/** 通用资源用途。 */
const usageOptions = [
{ value: 'support', label: '支撑' },
{ value: 'hold', label: '持有' },
{ value: 'move', label: '移动' },
{ value: 'interact', label: '交互' },
{ value: 'other', label: '其他' }
]
/** 添加待人工填写的动作,不自动编造编号或描述。 */
function addAction() {
draft.value.requiredActions.push({ id: '', description: '', kind: 'action', mustPerformInShot: true })
}
/** 添加待人工填写的动作阶段。 */
function addPhase() {
draft.value.durationPlanning.phases.push({ action: '', actionIds: [], estimatedSeconds: 0 })
}
/**
* 添加一项空资源证据,由用户明确选择对应动作和主体。
* @param index 目标阶段序号
* @param kind 手部或通用资源
*/
function addEvidence(index: number, kind: 'hand' | 'resource') {
const phase = draft.value.durationPlanning.phases[index]
if (!phase) return
if (kind === 'hand')
(phase.handOccupancy ??= []).push({ actionId: '', characterRef: '', hands: 'left', shareable: false })
else
(phase.resourceOccupancy ??= []).push({
actionId: '',
ownerRef: '',
resource: 'left_hand',
usage: 'hold',
shareable: false
})
}
</script>
<template>
<!-- 以下是必需动作、阶段时长与完整资源证据编辑模块 -->
<div class="shot-action-editor">
<section class="space-y-4" aria-label="必需动作">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-medium">必需动作</h3>
<NButton size="small" :disabled="disabled" @click="addAction">添加动作</NButton>
</div>
<div v-for="(action, index) in draft.requiredActions" :key="index" class="action-fields">
<NFormItem label="动作编号" :show-feedback="false"
><NInput
v-model:value="action.id"
:aria-label="`动作 ${index + 1} 编号`"
placeholder="动作编号"
:disabled="disabled"
/></NFormItem>
<NFormItem label="动作描述" :show-feedback="false"
><NInput
v-model:value="action.description"
:aria-label="`动作 ${index + 1} 描述`"
placeholder="具体动作描述"
:disabled="disabled"
/></NFormItem>
<NFormItem label="动作类型" :show-feedback="false"
><NSelect
v-model:value="action.kind"
:aria-label="`动作 ${index + 1} 类型`"
:options="kindOptions"
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="action.mustPerformInShot" :disabled="disabled">本镜必须完成</NCheckbox>
<NButton :disabled="disabled" @click="draft.requiredActions.splice(index, 1)">移除</NButton>
</div>
</section>
<!-- 以下是动作阶段编辑模块,同阶段动作视为同时发生 -->
<section class="space-y-4" aria-label="动作阶段">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-medium">动作阶段</h3>
<NButton size="small" :disabled="disabled" @click="addPhase">添加阶段</NButton>
</div>
<p class="text-xs leading-6 text-muted">
同阶段动作视为同时发生;需要释放资源后再执行的动作,请安排在不同阶段。已有证据会完整保留。
</p>
<section
v-for="(phase, index) in draft.durationPlanning.phases"
:key="index"
class="action-phase space-y-4"
:aria-label="`动作阶段 ${index + 1}`"
>
<div class="flex flex-wrap items-center justify-between gap-3">
<h4 class="text-sm">阶段 {{ index + 1 }}</h4>
<NButton text :disabled="disabled" @click="draft.durationPlanning.phases.splice(index, 1)"
>移除阶段</NButton
>
</div>
<NFormItem label="阶段描述"
><NInput v-model:value="phase.action" :aria-label="`阶段 ${index + 1} 描述`" :disabled="disabled"
/></NFormItem>
<div class="phase-fields">
<NFormItem label="阶段动作"
><NSelect
v-model:value="phase.actionIds"
multiple
:options="actionOptions"
:aria-label="`阶段 ${index + 1} 动作引用`"
:disabled="disabled"
/></NFormItem>
<NFormItem label="阶段时长(秒)"
><NInputNumber
:value="phase.estimatedSeconds"
@update:value="phase.estimatedSeconds = $event ?? 0"
:min="0.1"
:aria-label="`阶段 ${index + 1} 时长`"
:disabled="disabled"
/></NFormItem>
</div>
<div class="flex flex-wrap gap-3">
<NButton size="small" :disabled="disabled" @click="addEvidence(index, 'hand')">添加手部证据</NButton
><NButton size="small" :disabled="disabled" @click="addEvidence(index, 'resource')"
>添加资源证据</NButton
>
</div>
<div
v-for="(hand, handIndex) in phase.handOccupancy"
:key="`hand-${handIndex}`"
class="evidence-fields"
>
<NFormItem label="关联动作" :show-feedback="false"
><NSelect
v-model:value="hand.actionId"
:options="actionOptions"
aria-label="手部证据动作"
:disabled="disabled"
/></NFormItem>
<NFormItem label="主体引用" :show-feedback="false"
><NInput
v-model:value="hand.characterRef"
placeholder="主体引用"
aria-label="手部证据主体引用"
:disabled="disabled"
/></NFormItem>
<NFormItem label="手部" :show-feedback="false"
><NSelect
v-model:value="hand.hands"
:options="handOptions"
aria-label="使用的手"
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="hand.shareable" :disabled="disabled">可共享</NCheckbox>
<NButton :disabled="disabled" @click="phase.handOccupancy?.splice(handIndex, 1)">移除</NButton>
</div>
<div
v-for="(resource, resourceIndex) in phase.resourceOccupancy"
:key="`resource-${resourceIndex}`"
class="evidence-fields"
>
<NFormItem label="关联动作" :show-feedback="false"
><NSelect
v-model:value="resource.actionId"
:options="actionOptions"
aria-label="资源证据动作"
:disabled="disabled"
/></NFormItem>
<NFormItem label="主体引用" :show-feedback="false"
><NInput
v-model:value="resource.ownerRef"
placeholder="主体引用"
aria-label="资源证据主体引用"
:disabled="disabled"
/></NFormItem>
<NFormItem label="占用资源" :show-feedback="false"
><NSelect
v-model:value="resource.resource"
:options="actionResourceOptions"
aria-label="占用资源"
:disabled="disabled"
/></NFormItem>
<NFormItem label="资源用途" :show-feedback="false"
><NSelect
v-model:value="resource.usage"
:options="usageOptions"
aria-label="资源用途"
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="resource.shareable" :disabled="disabled">可共享</NCheckbox>
<NButton :disabled="disabled" @click="phase.resourceOccupancy?.splice(resourceIndex, 1)"
>移除</NButton
>
</div>
</section>
</section>
<!-- 以下是镜头整体时长依据模块 -->
<section class="phase-fields" aria-label="整体时长规划">
<NFormItem label="动作复杂度"
><NSelect
v-model:value="draft.durationPlanning.complexity"
:options="complexityOptions"
:disabled="disabled"
/></NFormItem>
<NFormItem label="阶段衔接(秒)"
><NInputNumber
:value="draft.durationPlanning.transitionSeconds"
@update:value="draft.durationPlanning.transitionSeconds = $event ?? 0"
:min="0"
:disabled="disabled"
/></NFormItem>
<NFormItem label="建议总时长(秒)"
><NInputNumber
:value="draft.durationPlanning.recommendedDurationSeconds"
@update:value="draft.durationPlanning.recommendedDurationSeconds = $event ?? 0"
:min="0.1"
:disabled="disabled"
/></NFormItem>
</section>
<NFormItem label="时长规划依据"
><NInput
v-model:value="draft.durationPlanning.reason"
type="textarea"
:autosize="{ minRows: 2, maxRows: 6 }"
:disabled="disabled"
/></NFormItem>
</div>
</template>
<style scoped>
.shot-action-editor {
display: grid;
gap: 24px;
}
.action-fields,
.evidence-fields {
display: flex;
flex-wrap: wrap;
align-items: end;
gap: 12px;
}
.action-fields > :deep(.n-form-item),
.evidence-fields > :deep(.n-form-item) {
flex: 1 1 140px;
min-width: 0;
}
.phase-fields {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
gap: 16px;
}
.action-phase {
background: var(--app-subtle);
padding: 20px;
}
@media (max-width: 640px) {
.action-fields > :deep(.n-form-item),
.evidence-fields > :deep(.n-form-item) {
flex-basis: 100%;
}
}
</style>
@@ -1,17 +1,7 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import {
NButton,
NCollapse,
NCollapseItem,
NDrawer,
NDrawerContent,
NInputNumber,
NScrollbar,
NSelect,
NTag
} from 'naive-ui'
import { ScanLine } from '@lucide/vue'
import { NButton, NCollapse, NCollapseItem, NInputNumber, NSelect, NSpin, NTag } from 'naive-ui'
import { RefreshCw, ScanLine } from '@lucide/vue'
import { breakdownApi } from '../api'
import { diagnosisInput, diagnosisStatusLabels, scopeDiagnosisShots, summarizeDiagnosis } from '../diagnosis'
import type { DiagnosisLocation, DiagnosisScope } from '../diagnosis'
@@ -24,6 +14,7 @@ import type {
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
import { useWorkflowExecution } from '../../workflows/execution'
import { AppDialog } from '../../../components/ui'
import { useActionMessage } from '../../../components/ui/useActionMessage'
import { errorMessage } from '../../../lib/http'
@@ -36,32 +27,34 @@ const props = defineProps<{
/** 全项目预览所需的正式剧集编号。 */
episodeNos: number[]
}>()
/** 关闭抽屉后定位对应镜头或节拍。 */
/** 关闭弹窗后定位对应镜头或节拍。 */
const emit = defineEmits<{ locate: [location: DiagnosisLocation] }>()
/** 统一操作消息层。 */
const message = useActionMessage()
/** 任务观察独立于抽屉显隐,关闭抽屉后继续跟踪真实进度。 */
/** 任务观察独立于弹窗显隐,关闭弹窗后继续跟踪真实进度。 */
const execution = useWorkflowExecution(
computed(() => props.projectId),
'storyboard-legacy-action-diagnosis'
)
/** 右侧诊断抽屉是否展开。 */
const drawerOpen = ref(false)
/** 等待抽屉离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
/** 居中诊断弹窗是否打开。 */
const dialogOpen = ref(false)
/** 首批诊断数据完成前保留固定加载区域,不渲染会闪现的空结果。 */
const dialogDataReady = ref(false)
/** 等待弹窗离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
const pendingLocation = ref<DiagnosisLocation | null>(null)
/** 本次查看及提交的诊断范围。 */
const scope = ref<DiagnosisScope>({ kind: 'project' })
/** 当前集摘要与抽屉结果分开保存,切换抽屉范围不会改变摘要含义。 */
/** 当前集摘要与弹窗结果分开保存,切换弹窗范围不会改变摘要含义。 */
const episodeResults = ref<LegacyActionDiagnosisResults | null>(null)
/** 当前集摘要的读取状态。 */
const summaryBusy = ref(false)
/** 当前集摘要的读取错误。 */
const summaryError = ref('')
/** 抽屉范围对应的后端结果,节拍及镜头会再次筛选。 */
/** 弹窗范围对应的后端结果,节拍及镜头会再次筛选。 */
const results = ref<LegacyActionDiagnosisResults | null>(null)
/** 抽屉结果读取状态。 */
/** 弹窗结果读取状态。 */
const resultsBusy = ref(false)
/** 抽屉结果读取错误。 */
/** 弹窗结果读取错误。 */
const resultsError = ref('')
/** 只读范围预览;全项目按正式剧集汇总,任何一集失败都不能启动。 */
const previews = ref<LegacyActionDiagnosisPreview[] | null>(null)
@@ -87,7 +80,7 @@ const repairIssue = ref<number | null>(null)
const repairPreview = ref<StoryboardHandRepairPreview | null>(null)
/** 修复建议读取状态。 */
const repairBusy = ref(false)
/** 请求版本用于忽略范围变化、关闭抽屉及组件卸载后的迟到响应。 */
/** 请求版本用于忽略范围变化、关闭弹窗及组件卸载后的迟到响应。 */
let summaryVersion = 0
/** 当前范围结果请求版本。 */
let resultsVersion = 0
@@ -96,6 +89,15 @@ let previewVersion = 0
/** 项目级校验和修复建议的请求版本。 */
let handVersion = 0
/** 合并用户触发的只读请求状态;后台任务轮询不触发整窗遮罩。 */
const dialogLoading = computed(() => resultsBusy.value || handBusy.value || previewBusy.value || repairBusy.value)
/** 已有结果或校验的刷新只使用按钮加载态,首次读取及预览、修复请求保留整窗加载反馈。 */
const dialogOverlayLoading = computed(
() =>
dialogLoading.value &&
(!dialogDataReady.value || (handBusy.value && !handDiagnostics.value) || previewBusy.value || repairBusy.value)
)
/** 当前查看范围的中文名称,同时用于费用确认。 */
const scopeLabel = computed(() => {
const target = scope.value
@@ -108,7 +110,7 @@ const scopeLabel = computed(() => {
const scopeKey = computed(() => JSON.stringify(scope.value))
/** 当前集摘要根据真实诊断记录统计。 */
const summaryCounts = computed(() => (episodeResults.value ? summarizeDiagnosis(episodeResults.value.shots) : null))
/** 抽屉统计严格对应当前集、节拍或镜头范围。 */
/** 弹窗统计严格对应当前集、节拍或镜头范围。 */
const scopedShots = computed(() => scopeDiagnosisShots(results.value?.shots ?? [], scope.value))
/** 当前范围的状态计数。 */
const counts = computed(() => summarizeDiagnosis(scopedShots.value))
@@ -128,9 +130,11 @@ const previewCount = computed(() => previews.value?.reduce((sum, item) => sum +
const concurrencyValid = computed(
() => Number.isSafeInteger(concurrency.value) && concurrency.value >= 1 && concurrency.value <= 5
)
/** 启动前必须取得当前范围预览,并保证没有同项目同工作流活动任务。 */
/** 底栏启动操作要求数据就绪、读取结束且预览有效,同时保证没有同项目同工作流活动任务。 */
const canStart = computed(
() =>
dialogDataReady.value &&
!dialogLoading.value &&
!!previews.value &&
previewCount.value > 0 &&
concurrencyValid.value &&
@@ -175,7 +179,7 @@ async function loadSummary() {
}
/**
* 读取当前抽屉范围结果;同集结果同时更新顶部摘要。
* 读取当前弹窗范围结果;同集结果同时更新顶部摘要。
* @returns 当前结果读取结束
*/
async function loadResults() {
@@ -233,18 +237,22 @@ async function loadPreview() {
}
}
/** 读取全项目结构化证据;证据不足时不以零冲突暗示安全。 */
/**
* 读取全项目结构化证据,刷新期间保留已展示内容,避免弹窗高度收缩后又恢复。
* @returns 本轮校验读取结束
*/
async function loadHandDiagnostics() {
const version = ++handVersion
handBusy.value = true
handError.value = ''
handDiagnostics.value = null
repairPreview.value = null
repairIssue.value = null
repairBusy.value = false
try {
const data = await breakdownApi.handOccupancyDiagnostics(props.projectId)
if (version === handVersion) handDiagnostics.value = data
if (version === handVersion) {
handDiagnostics.value = data
repairPreview.value = null
repairIssue.value = null
}
} catch (cause) {
if (version === handVersion) handError.value = errorMessage(cause)
} finally {
@@ -304,7 +312,7 @@ function issueDescriptions(issues: unknown[]) {
}
/**
* 从顶部或镜头入口打开抽屉;指定镜头时自动取得只读范围预览。
* 从顶部或镜头入口打开弹窗;指定镜头时自动取得只读范围预览。
* @param location 可选的节拍或镜头坐标
*/
function open(location?: DiagnosisLocation) {
@@ -316,20 +324,20 @@ function open(location?: DiagnosisLocation) {
: props.episodeNo === undefined
? { kind: 'project' }
: { kind: 'episode', episodeNo: props.episodeNo }
drawerOpen.value = true
dialogOpen.value = true
if (location) void loadPreview()
}
/**
* 关闭抽屉后通知列表定位,保留当前任务观察。
* 关闭弹窗后通知列表定位,保留当前任务观察。
* @param location 待定位的镜头或节拍
*/
function locate(location: DiagnosisLocation) {
pendingLocation.value = location
drawerOpen.value = false
dialogOpen.value = false
}
/** 抽屉关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
/** 弹窗关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
function finishLocate() {
if (!pendingLocation.value) return
const location = pendingLocation.value
@@ -358,7 +366,7 @@ watch(
[() => props.projectId, () => props.episodeNo],
() => {
pendingLocation.value = null
drawerOpen.value = false
dialogOpen.value = false
++handVersion
handDiagnostics.value = null
handBusy.value = false
@@ -367,9 +375,17 @@ watch(
},
{ immediate: true, flush: 'sync' }
)
/** 首批范围结果与结构化校验全部结束后才显示正文,失败时显示对应错误。 */
watch(
dialogLoading,
loading => {
if (dialogOpen.value && !loading) dialogDataReady.value = true
},
{ flush: 'sync' }
)
/** 关闭或切换范围立即废弃预览及结果请求,禁止确认旧预览。 */
watch(
[drawerOpen, scopeKey],
[dialogOpen, scopeKey],
([shown]) => {
++previewVersion
++resultsVersion
@@ -380,6 +396,7 @@ watch(
resultsBusy.value = false
resultsError.value = ''
resultFilter.value = 'attention'
dialogDataReady.value = false
if (shown) {
void loadResults()
if (!handDiagnostics.value && !handBusy.value) void loadHandDiagnostics()
@@ -391,13 +408,13 @@ watch(
},
{ flush: 'sync' }
)
/** 后台任务结束后更新摘要和已打开的结果,不因关闭抽屉停止跟踪。 */
/** 后台任务结束后更新摘要和已打开的结果,不因关闭弹窗停止跟踪。 */
watch(
() => execution.query.data.value?.status,
(status, previous) => {
if (status !== previous && (status === 'completed' || status === 'failed')) {
void loadSummary()
if (drawerOpen.value) void loadResults()
if (dialogOpen.value) void loadResults()
}
}
)
@@ -423,254 +440,280 @@ defineExpose({ open })
>
<NTag v-if="execution.active.value" type="info" size="small" :bordered="false">诊断中</NTag>
</div>
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="drawerOpen" @click="open()"
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="dialogOpen" @click="open()"
>查看诊断</NButton
>
</div>
<!-- 以下是独立滚动的右侧诊断抽屉模块,手机自动使用全屏宽度 -->
<NDrawer
v-model:show="drawerOpen"
placement="right"
width="min(560px, 100vw)"
class="storyboard-diagnosis-drawer"
@after-leave="finishLocate"
>
<NDrawerContent title="动作诊断" closable :native-scrollbar="false">
<p class="diagnosis-intro">检查手部动作占用与冲突,帮助定位需要处理的镜头。</p>
<!-- 以下是当前范围模块,剧集编号始终与阅读列表一致 -->
<section class="diagnosis-section">
<h3>诊断范围</h3>
<div class="diagnosis-scope-controls">
<NButton
size="small"
:disabled="episodeNo === undefined"
:type="scope.kind !== 'project' ? 'primary' : 'default'"
@click="scope = { kind: 'episode', episodeNo: episodeNo! }"
>当前集</NButton
>
<NButton
size="small"
:type="scope.kind === 'project' ? 'primary' : 'default'"
@click="scope = { kind: 'project' }"
>全项目</NButton
>
</div>
<p class="diagnosis-scope-label">{{ scopeLabel }}</p>
<p class="text-xs text-muted">当前支持手部动作冲突检查。</p>
</section>
<!-- 以下是诊断结果模块,默认隐藏未诊断长列表 -->
<section class="diagnosis-section">
<div class="diagnosis-section-heading">
<h3>诊断结果</h3>
<NButton text size="small" :loading="resultsBusy" @click="loadResults">刷新结果</NButton>
</div>
<p v-if="resultsError" class="text-danger" role="alert">{{ resultsError }}</p>
<template v-else-if="results">
<div class="diagnosis-counts">
<span>范围内 {{ counts.total }} 镜</span
><span :class="{ 'text-danger': counts.conflict }">冲突 {{ counts.conflict }}</span>
<span>证据不足 {{ counts.insufficient }}</span
><span>证据无效 {{ counts.invalid }}</span
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
><span>未发现冲突 {{ counts.clear }}</span>
</div>
<NSelect
v-model:value="resultFilter"
aria-label="筛选诊断结果"
size="small"
class="diagnosis-result-filter"
:options="[
{ label: '需处理:冲突、证据异常与过期', value: 'attention' },
{ label: `未诊断(${counts.pending})`, value: 'pending' },
{ label: `全部镜头(${counts.total})`, value: 'all' }
]"
/>
<div v-if="!visibleShots.length" class="diagnosis-empty">
<p>
{{
counts.total === 0
? '当前范围尚无镜头。'
: counts.pending === counts.total
? `${counts.pending} 个镜头尚未诊断,暂无法判断冲突情况。`
: resultFilter === 'attention'
? '当前没有需处理的诊断记录。'
: '当前筛选下没有镜头。'
}}
</p>
<NButton
v-if="counts.pending && resultFilter !== 'pending'"
text
size="small"
@click="resultFilter = 'pending'"
>查看未诊断镜头</NButton
>
</div>
<NScrollbar
v-if="visibleShots.length"
class="diagnosis-result-list"
tabindex="0"
aria-label="镜头诊断列表"
>
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
<div class="diagnosis-section-heading">
<span class="text-xs text-muted"
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头 {{ item.shotNo }}</span
>
<NTag
:type="
item.status === 'conflict_found'
? 'error'
: item.status === 'no_conflict_found'
? 'success'
: 'default'
"
size="small"
:bordered="false"
>{{ diagnosisStatusLabels[item.status] }}</NTag
>
</div>
<p class="font-medium">{{ item.title }}</p>
<p
v-for="(description, index) in issueDescriptions(item.issues)"
:key="index"
class="text-muted"
<!-- 以下是居中动作诊断弹窗,正文自然增高,仅超过可用视口后统一滚动 -->
<AppDialog v-model:open="dialogOpen" title="动作诊断" :width="640" @closed="finishLocate">
<NSpin
:show="dialogOverlayLoading"
description="正在加载诊断数据…"
class="storyboard-diagnosis-dialog"
:aria-busy="dialogLoading"
>
<div class="diagnosis-dialog-body">
<!-- 首批数据加载期间仅显示遮罩,避免先显示零计数或空结果再跳变 -->
<div v-if="dialogDataReady" class="diagnosis-dialog-content">
<!-- 以下是当前范围模块,剧集编号始终与阅读列表一致 -->
<section class="diagnosis-section">
<h3>诊断范围</h3>
<div class="diagnosis-scope-controls">
<NButton
size="small"
:disabled="episodeNo === undefined"
:type="scope.kind !== 'project' ? 'primary' : 'default'"
@click="scope = { kind: 'episode', episodeNo: episodeNo! }"
>当前集</NButton
>
{{ description }}
</p>
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
</article>
</NScrollbar>
</template>
<p v-else class="text-muted">{{ resultsBusy ? '正在读取当前范围结果…' : '尚未读取结果' }}</p>
</section>
<!-- 以下是使用 Naive UI 折叠组件的全项目结构化校验模块,默认收起 -->
<section class="diagnosis-section">
<NCollapse>
<NCollapseItem name="hand-diagnostics">
<template #header>
<span class="diagnosis-evidence-title">结构化动作校验</span>
<span class="ml-2 text-xs text-muted">全项目</span>
</template>
<div class="diagnosis-section-heading">
<span class="text-xs text-muted">直接读取已有动作证据,不调用模型</span>
<NButton text size="small" :loading="handBusy" @click="loadHandDiagnostics"
>刷新校验</NButton
<NButton
size="small"
:type="scope.kind === 'project' ? 'primary' : 'default'"
@click="scope = { kind: 'project' }"
>全项目</NButton
>
</div>
<p v-if="handError" class="text-danger" role="alert">{{ handError }}</p>
<template v-else-if="handDiagnostics">
<p class="mt-2">
有效动作证据 {{ handDiagnostics.evidenceShotCount }} /
{{ handDiagnostics.shotCount }} 镜
</p>
<p class="text-muted">
{{
handDiagnostics.assessment === 'no_shots'
? '全项目尚无镜头。'
: handDiagnostics.assessment === 'insufficient_evidence'
? '证据不足,暂无法判断冲突情况。'
: handDiagnostics.assessment === 'partial_evidence'
? `部分镜头缺少有效证据;现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
: `现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
}}
</p>
<article
v-for="(issue, index) in handDiagnostics.diagnostics"
:key="index"
class="diagnosis-result-item"
<p class="diagnosis-scope-label">{{ scopeLabel }}</p>
</section>
<!-- 以下是诊断结果模块,默认隐藏未诊断长列表 -->
<section class="diagnosis-section">
<div class="diagnosis-section-heading">
<h3>诊断结果</h3>
<!-- 刷新图标始终占位,加载前后按钮和标题行保持同一尺寸 -->
<NButton
text
size="small"
class="diagnosis-refresh-button"
:loading="resultsBusy"
@click="loadResults"
>
<p class="text-xs text-muted">
第 {{ issue.episodeNo }} 集 / 节拍 {{ issue.beatNo }} / 镜头 {{ issue.shotNo }} /
阶段
{{ issue.phaseNo }}
<template #icon><RefreshCw :size="14" aria-hidden="true" /></template>
刷新结果
</NButton>
</div>
<p v-if="resultsError" class="text-danger" role="alert">{{ resultsError }}</p>
<template v-else-if="results">
<div class="diagnosis-counts">
<span>范围内 {{ counts.total }} 镜</span
><span :class="{ 'text-danger': counts.conflict }">冲突 {{ counts.conflict }}</span>
<span>证据不足 {{ counts.insufficient }}</span
><span>证据无效 {{ counts.invalid }}</span
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
><span>未发现冲突 {{ counts.clear }}</span>
</div>
<NSelect
v-model:value="resultFilter"
aria-label="筛选诊断结果"
size="small"
class="diagnosis-result-filter"
:options="[
{ label: '需处理:冲突、证据异常与过期', value: 'attention' },
{ label: `未诊断(${counts.pending})`, value: 'pending' },
{ label: `全部镜头(${counts.total})`, value: 'all' }
]"
/>
<div v-if="!visibleShots.length" class="diagnosis-empty">
<p>
{{
counts.total === 0
? '当前范围尚无镜头。'
: counts.pending === counts.total
? `${counts.pending} 个镜头尚未诊断,暂无法判断冲突情况。`
: resultFilter === 'attention'
? '当前没有需处理的诊断记录。'
: '当前筛选下没有镜头。'
}}
</p>
<p>{{ issue.suggestion }}</p>
<div class="diagnosis-scope-controls">
<NButton text size="small" @click="locate(issue)">定位镜头</NButton>
<NButton
v-if="counts.pending && resultFilter !== 'pending'"
text
size="small"
@click="resultFilter = 'pending'"
>查看未诊断镜头</NButton
>
</div>
<div
v-if="visibleShots.length"
class="diagnosis-result-list"
tabindex="0"
aria-label="镜头诊断列表"
>
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
<div class="diagnosis-section-heading">
<span class="text-xs text-muted"
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头
{{ item.shotNo }}</span
>
<NTag
:type="
item.status === 'conflict_found'
? 'error'
: item.status === 'no_conflict_found'
? 'success'
: 'default'
"
size="small"
:bordered="false"
>{{ diagnosisStatusLabels[item.status] }}</NTag
>
</div>
<p class="font-medium">{{ item.title }}</p>
<p
v-for="(description, index) in issueDescriptions(item.issues)"
:key="index"
class="text-muted"
>
{{ description }}
</p>
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
</article>
</div>
</template>
<p v-else class="text-muted">{{ resultsBusy ? '正在读取当前范围结果…' : '尚未读取结果' }}</p>
</section>
<!-- 以下是使用 Naive UI 折叠组件的全项目结构化校验模块,默认收起 -->
<section class="diagnosis-section">
<NCollapse class="diagnosis-evidence-collapse">
<NCollapseItem name="hand-diagnostics">
<template #header>
<span class="diagnosis-evidence-title">结构化动作校验</span>
<span class="ml-2 text-xs text-muted">全项目</span>
</template>
<!-- 校验刷新放在折叠标题右侧,仅展开时显示,点击不会切换折叠。 -->
<template #header-extra="{ collapsed }">
<NButton
v-if="!collapsed"
text
size="small"
:loading="repairBusy && repairIssue === index"
@click="showRepair(index)"
>{{ repairIssue === index ? '收起修复建议' : '查看修复建议' }}</NButton
class="diagnosis-refresh-button"
:loading="handBusy"
@click.stop="loadHandDiagnostics"
>
</div>
<div v-if="repairIssue === index && repairPreview" class="diagnosis-repair">
<div v-for="(repair, repairIndex) in repairsFor(issue)" :key="repairIndex">
<p>{{ repair.suggestion }}</p>
<p v-if="repair.blockingReasons.length" class="text-xs text-muted">
{{ repair.blockingReasons.join(';') }}
<template #icon><RefreshCw :size="14" aria-hidden="true" /></template>
刷新校验
</NButton>
</template>
<p class="text-xs text-muted">直接读取已有动作证据,不调用模型</p>
<p v-if="handError" class="text-danger" role="alert">{{ handError }}</p>
<template v-else-if="handDiagnostics">
<p class="mt-2">
有效动作证据 {{ handDiagnostics.evidenceShotCount }} /
{{ handDiagnostics.shotCount }} 镜
</p>
<p class="text-muted">
{{
handDiagnostics.assessment === 'no_shots'
? '全项目尚无镜头。'
: handDiagnostics.assessment === 'insufficient_evidence'
? '证据不足,暂无法判断冲突情况。'
: handDiagnostics.assessment === 'partial_evidence'
? `部分镜头缺少有效证据;现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
: `现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
}}
</p>
<article
v-for="(issue, index) in handDiagnostics.diagnostics"
:key="index"
class="diagnosis-result-item mt-3"
>
<p class="text-xs text-muted">
第 {{ issue.episodeNo }} 集 / 节拍 {{ issue.beatNo }} / 镜头
{{ issue.shotNo }} / 阶段
{{ issue.phaseNo }}
</p>
</div>
<p v-if="!repairsFor(issue).length" class="text-muted">当前没有可用修复建议。</p>
</div>
</article>
</template>
<p v-else class="text-muted">{{ handBusy ? '正在读取全项目校验…' : '尚未读取校验' }}</p>
</NCollapseItem>
</NCollapse>
</section>
<!-- 以下是统一的 AI 诊断启动模块,预览和费用确认集中展示 -->
<section class="diagnosis-section">
<h3>启动 AI 诊断</h3>
<p class="text-muted mt-2">{{ scopeLabel }} · 已有当前版本有效结果的镜头将跳过。</p>
<!-- 以下是使用 Naive UI 折叠组件的高级设置模块,默认收起 -->
<NCollapse class="diagnosis-advanced">
<NCollapseItem name="advanced-settings">
<template #header><span class="text-xs text-muted">高级设置</span></template>
<label class="diagnosis-concurrency"
><span>任务并发</span
><NInputNumber
v-model:value="concurrency"
aria-label="诊断任务并发"
:min="1"
:max="5"
:precision="0"
size="small"
/></label>
</NCollapseItem>
</NCollapse>
<div v-if="previews" class="diagnosis-preview" aria-live="polite">
<p>{{ scopeLabel }} · 范围内 {{ previewCount }} 个镜头</p>
<p class="text-xs text-muted">
缺少结构化动作证据 {{ previews.reduce((sum, item) => sum + item.needsEvidenceCount, 0) }} 镜 ·
快照无效 {{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
</p>
</div>
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
<div class="diagnosis-start-actions">
<NButton
:loading="previewBusy"
:disabled="previewBusy || starting || execution.active.value"
@click="loadPreview"
>{{ previews ? '重新预览范围' : '预览诊断范围' }}</NButton
>
<ConfirmAction
label="启动 AI 诊断"
:description="confirmation"
primary
:disabled="!canStart"
:loading="starting"
@confirm="startDiagnosis"
<p>{{ issue.suggestion }}</p>
<div class="diagnosis-scope-controls">
<NButton text size="small" @click="locate(issue)">定位镜头</NButton>
<NButton
text
size="small"
:loading="repairBusy && repairIssue === index"
@click="showRepair(index)"
>{{ repairIssue === index ? '收起修复建议' : '查看修复建议' }}</NButton
>
</div>
<div v-if="repairIssue === index && repairPreview" class="diagnosis-repair">
<div v-for="(repair, repairIndex) in repairsFor(issue)" :key="repairIndex">
<p>{{ repair.suggestion }}</p>
<p v-if="repair.blockingReasons.length" class="text-xs text-muted">
{{ repair.blockingReasons.join(';') }}
</p>
</div>
<p v-if="!repairsFor(issue).length" class="text-muted">
当前没有可用修复建议。
</p>
</div>
</article>
</template>
<p v-else class="text-muted">{{ handBusy ? '正在读取全项目校验…' : '尚未读取校验' }}</p>
</NCollapseItem>
</NCollapse>
</section>
<!-- 以下是诊断配置、预览与费用说明模块,执行操作统一保留在弹窗底栏 -->
<section class="diagnosis-section">
<h3>启动 AI 诊断</h3>
<p class="text-muted mt-2">{{ scopeLabel }} · 已有当前版本有效结果的镜头将跳过。</p>
<!-- 以下是使用 Naive UI 折叠组件的高级设置模块,默认收起 -->
<NCollapse class="diagnosis-advanced">
<NCollapseItem name="advanced-settings">
<template #header><span class="text-xs text-muted">高级设置</span></template>
<label class="diagnosis-concurrency"
><span>任务并发</span
><NInputNumber
v-model:value="concurrency"
aria-label="诊断任务并发"
:min="1"
:max="5"
:precision="0"
size="small"
/></label>
</NCollapseItem>
</NCollapse>
<div v-if="previews" class="diagnosis-preview" aria-live="polite">
<p>{{ scopeLabel }} · 范围内 {{ previewCount }} 个镜头</p>
<p class="text-xs text-muted">
缺少结构化动作证据
{{ previews.reduce((sum, item) => sum + item.needsEvidenceCount, 0) }} 镜 · 快照无效
{{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
</p>
</div>
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
诊断任务进行中,可关闭弹窗继续查看分镜。
</p>
</section>
<!-- 以下是持久化诊断任务进度模块,刷新页面后仍可恢复 -->
<WorkflowExecutionPanel
v-if="execution.executionId.value"
title="动作诊断任务"
:execution="execution.query.data.value ?? null"
:loading="execution.query.loading.value"
:error="execution.query.error.value ?? ''"
@refresh="execution.query.refresh()"
@dismiss="execution.dismiss()"
/>
</div>
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
诊断任务进行中,可关闭抽屉继续查看分镜。
</p>
</section>
<!-- 以下是持久化诊断任务进度模块,刷新页面后仍可恢复 -->
<WorkflowExecutionPanel
v-if="execution.executionId.value"
title="动作诊断任务"
:execution="execution.query.data.value ?? null"
:loading="execution.query.loading.value"
:error="execution.query.error.value ?? ''"
@refresh="execution.query.refresh()"
@dismiss="execution.dismiss()"
</div>
</NSpin>
<!-- 以下是固定底栏操作模块,正文滚动时仍可预览范围并进行费用确认 -->
<template #footer>
<NButton
:loading="previewBusy"
:disabled="!dialogDataReady || dialogLoading || starting || execution.active.value"
@click="loadPreview"
>{{ previews ? '重新预览范围' : '预览诊断范围' }}</NButton
>
<ConfirmAction
label="启动 AI 诊断"
:description="confirmation"
primary
:disabled="!canStart"
:loading="starting"
@confirm="startDiagnosis"
/>
</NDrawerContent>
</NDrawer>
</template>
</AppDialog>
</template>
<style>
@@ -685,18 +728,17 @@ defineExpose({ open })
.storyboard-diagnosis-summary > .n-button {
flex-shrink: 0;
}
/* 抽屉分区依靠留白和细线区分,避免再堆叠大面积面板。 */
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
padding: 20px 24px 32px;
/* 加载占位保留最低高度,正文可随内容自然增高,最大高度由公共弹窗按视口限制。 */
.diagnosis-dialog-body {
min-height: min(600px, calc(100dvh - 160px));
}
.storyboard-diagnosis-drawer .n-drawer-header {
padding: 20px 24px;
}
.diagnosis-intro {
@apply text-sm text-muted leading-6;
.diagnosis-dialog-content {
@apply space-y-4;
padding-bottom: 4px;
}
/* 各分区使用主题次级底色和留白区分,移除贯穿弹窗的分隔线。 */
.diagnosis-section {
@apply py-5 border-b border-(--app-border) text-sm leading-6;
@apply p-4 bg-(--app-subtle) text-sm leading-6;
}
.diagnosis-section h3,
.diagnosis-evidence-title {
@@ -705,6 +747,18 @@ defineExpose({ open })
.diagnosis-section-heading {
@apply flex items-center justify-between gap-3;
}
/* 折叠标题与结果标题保持相同行高,展开后出现刷新按钮时不额外撑高标题。 */
.diagnosis-evidence-collapse .n-collapse-item__header {
min-height: 28px;
}
/* 文字按钮默认随加载图标增高;固定高度并保留图标宽度,避免居中弹窗上下晃动。 */
.diagnosis-refresh-button.n-button {
height: 28px;
min-width: 92px;
}
.diagnosis-refresh-button .n-button__icon {
margin-block: 0;
}
.diagnosis-scope-controls {
@apply flex flex-wrap items-center gap-2 mt-3;
}
@@ -714,18 +768,18 @@ defineExpose({ open })
.diagnosis-counts {
@apply flex flex-wrap gap-x-4 gap-y-1 mt-3 mb-4 text-xs text-muted;
}
/* 长结果列表独立滚动,避免把范围预览和启动操作推到列表末尾。 */
.diagnosis-result-list {
max-height: min(40dvh, 360px);
}
.diagnosis-result-filter {
@apply mb-3;
}
.diagnosis-empty {
@apply py-4 text-muted;
}
/* 镜头结果以略浅底色单独成组,不再给每条结果增加边框。 */
.diagnosis-result-list {
@apply space-y-3;
}
.diagnosis-result-item {
@apply py-4 border-t border-(--app-border) space-y-2;
@apply p-3 bg-(--app-control) space-y-2;
}
.diagnosis-result-item .n-tag {
flex-shrink: 0;
@@ -739,23 +793,14 @@ defineExpose({ open })
.diagnosis-concurrency .n-input-number {
@apply w-28;
}
.diagnosis-preview,
.diagnosis-repair {
@apply bg-(--app-subtle) p-3 mt-3;
/* 预览与修复建议沿用主题灰阶,与所在分区保留清晰层级。 */
.diagnosis-preview {
@apply bg-(--app-control) p-3 mt-3;
}
.diagnosis-start-actions {
@apply flex flex-wrap justify-end gap-3 mt-4;
.diagnosis-repair {
@apply bg-(--app-surface) p-3 mt-3;
}
@media (max-width: 760px) {
.n-drawer.storyboard-diagnosis-drawer {
width: 100vw !important;
}
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
padding: 16px 16px 28px;
}
.storyboard-diagnosis-drawer .n-drawer-header {
padding: 16px;
}
.storyboard-diagnosis-summary {
@apply items-start;
}
@@ -65,8 +65,8 @@ defineExpose({ locate })
<template>
<div ref="root" class="breakdown-storyboard">
<!-- 以下是分镜剧集选择与工作区入口模块 -->
<div v-if="plan || $slots.actions" class="breakdown-storyboard-toolbar">
<!-- 以下是当前剧集选择与分镜数量模块 -->
<div v-if="plan" class="breakdown-storyboard-toolbar">
<label v-if="plan" class="breakdown-episode-picker"
><span>选择剧集</span
><NSelect
@@ -86,10 +86,9 @@ defineExpose({ locate })
>{{ plan.beats.length }} 个节拍 ·
{{ episode?.beatShots.reduce((sum, beat) => sum + beat.shots.length, 0) ?? 0 }} 个镜头</span
>
<slot name="actions" />
</div>
</div>
<!-- 以下是当前集诊断摘要插槽,完整结果在右侧抽屉展示 -->
<!-- 以下是当前集诊断摘要插槽,完整结果在居中弹窗展示 -->
<slot name="diagnosis" />
<!-- 以下是当前集节拍与分镜正文模块 -->
<template v-if="plan">
@@ -189,7 +188,7 @@ defineExpose({ locate })
<style>
/* 本组件专属布局与 Naive 内部结构覆盖。 */
@reference "../../../styles/styles.css";
/* 问题定位保留轮廓提示,便于关闭抽屉后识别目标。 */
/* 问题定位保留轮廓提示,便于关闭弹窗后识别目标。 */
.diagnosis-located {
outline: 1px solid var(--app-accent);
outline-offset: 3px;
@@ -0,0 +1,255 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton } from 'naive-ui'
import { AppDialog } from '../../../components/ui'
import { breakdownApi } from '../api'
import type { Checkpoint } from '../../workflows/types'
import type { QualityRepairCandidates, QualityRepairPlan, QualityRepairTarget, ShotActionDraft } from '../repair.types'
import { actionDraft, actionDraftIssue, qualityIssueLabel } from '../repair'
import { errorMessage } from '../../../lib/http'
import { getOperation, runOperation } from '../../workflows/operations'
import ShotActionEditor from './ShotActionEditor.vue'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
/** 未入库镜头的质量门禁修订面板,正式资产仍使用独立接口保护。 */
const props = defineProps<{
/** 当前项目编号。 */
projectId: string
/** 当前最新原始检查点。 */
checkpoint?: Checkpoint
/** 活动任务、读取错误等外部禁用条件。 */
disabled: boolean
}>()
/** 保存后读取新检查点,不能直接宣称已正式入库。 */
const emit = defineEmits<{ refresh: [] }>()
/** 实际修复计划。 */
const plan = ref<QualityRepairPlan | null>(null)
/** 实际局部修复候选。 */
const candidates = ref<QualityRepairCandidates | null>(null)
/** 只读查询状态。 */
const loading = ref(false)
/** 查询或版本错误。 */
const error = ref('')
/** 当前人工选择的修订目标。 */
const target = ref<QualityRepairTarget | null>(null)
/** 用户编辑的独立草稿。 */
const draft = ref<ShotActionDraft | null>(null)
/** 编辑弹窗可见性。 */
const open = ref(false)
/** 草稿修订号,任何修改均撤销先前确认。 */
const draftVersion = ref(0)
/** 项目级活动操作锁。 */
const operation = computed(() => getOperation(props.projectId))
/** 计划必须与当前原始检查点完全一致。 */
const current = computed(() => !!plan.value?.checkpointId && plan.value.checkpointId === props.checkpoint?.checkpointId)
/** 当前镜头的有效候选指纹与建议。 */
const candidate = computed(() =>
target.value && candidates.value && candidates.value.checkpointId === plan.value?.checkpointId
? candidates.value.candidates.find(
item =>
item.shotId ===
`episode:${target.value!.episodeNo}/beat:${target.value!.beatNo}/shot:${target.value!.shotNo}`
)
: undefined
)
/** 草稿字段校验问题。 */
const issue = computed(() => (draft.value ? actionDraftIssue(draft.value) : '请先选择待修订镜头。'))
/** 当前编辑目标的可读名称。 */
const targetLabel = computed(() =>
target.value
? `第 ${target.value.episodeNo} 集 · 节拍 ${target.value.beatNo} · 镜头 ${target.value.shotNo}`
: '镜头修订'
)
/** 请求版本控制,关闭或切换项目后不回填旧结果。 */
let version = 0
/** 当前查询取消控制器。 */
let controller: AbortController | undefined
/** 按需读取真实修复计划与有效候选,不触发模型。 */
async function load() {
if (loading.value || props.disabled) return
const currentVersion = ++version
const id = props.projectId
controller?.abort()
controller = new AbortController()
loading.value = true
error.value = ''
plan.value = null
candidates.value = null
try {
const [nextPlan, nextCandidates] = await Promise.all([
breakdownApi.qualityRepairPlan(id, controller.signal),
breakdownApi.qualityRepairCandidates(id, controller.signal)
])
if (version !== currentVersion) return
if (nextPlan.projectId !== id || nextCandidates.projectId !== id)
throw new Error('修复清单所属项目不一致,请刷新。')
plan.value = nextPlan
candidates.value = nextCandidates
if (nextPlan.repairPlan.length && nextPlan.checkpointId !== props.checkpoint?.checkpointId)
throw new Error('拆解结果已更新,请先刷新候选状态,再重新读取修复清单。')
} catch (cause) {
if (version === currentVersion) error.value = errorMessage(cause)
} finally {
if (version === currentVersion) loading.value = false
}
}
/**
* 从对应版本的原始镜头创建完整草稿,不用历史诊断重建动作证据。
* @param item 当前修复计划中的镜头坐标
*/
function edit(item: QualityRepairTarget) {
if (!current.value || props.disabled) return
const shot = props.checkpoint?.state.storyboardEpisodeShots
?.find(episode => episode.episodeNo === item.episodeNo)
?.beatShots.find(beat => beat.beatNo === item.beatNo)
?.shots.find(value => value.shotNo === item.shotNo)
if (!shot) {
error.value = '当前版本缺少镜头原始数据,请刷新拆解结果。'
return
}
target.value = { ...item }
draft.value = actionDraft(shot)
open.value = true
}
/** 人工确认后只写入新的检查点,恢复资格采用服务端结果。 */
async function save() {
if (
!current.value ||
props.disabled ||
operation.value.pending ||
issue.value ||
!target.value ||
!draft.value ||
!plan.value?.checkpointId
)
return
const id = props.projectId
const input = {
...actionDraft(draft.value),
episodeNo: target.value.episodeNo,
beatNo: target.value.beatNo,
shotNo: target.value.shotNo,
expectedCheckpointId: plan.value.checkpointId,
...(candidate.value
? { expectedFingerprint: candidate.value.expectedFingerprint, source: 'candidate' as const }
: { source: 'manual' as const })
}
const success = await runOperation(
id,
'正在保存镜头人工修订',
async () => {
const result = await breakdownApi.repairQualityShot(id, input)
if (result.projectId !== id || !result.checkpointId || result.checkpointId === input.expectedCheckpointId)
throw new Error('未取得新的修订版本,请刷新确认。')
return result
},
result => ({
type: result.canResumeBreakdown ? 'success' : 'warning',
content: result.canResumeBreakdown
? '人工修订已保存,可继续恢复拆解。正式数据尚未提交。'
: '人工修订已保存,仍有待处理质量问题。'
})
)
if (props.projectId !== id) return
if (success) {
open.value = false
plan.value = null
candidates.value = null
} else {
plan.value = null
error.value = '保存未成功,请刷新拆解结果并重新读取修复清单。'
}
emit('refresh')
}
watch(
draft,
() => {
draftVersion.value++
},
{ deep: true, flush: 'sync' }
)
watch(
() => [props.projectId, props.checkpoint?.checkpointId],
() => {
version++
controller?.abort()
loading.value = false
plan.value = null
candidates.value = null
target.value = null
draft.value = null
open.value = false
error.value = ''
}
)
onScopeDispose(() => {
version++
controller?.abort()
})
</script>
<template>
<!-- 以下是未入库分镜质量门禁的按需修订入口 -->
<section class="workspace-panel space-y-4" aria-label="分镜质量修订">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-medium">分镜质量修订</h3>
<NButton :loading="loading" :disabled="disabled || loading" @click="load">读取修复清单</NButton>
</div>
<p class="text-xs leading-6 text-muted">
用于尚未入库的质量阻断镜头。读取不调用模型;人工修订保存为新快照,通过后再恢复拆解。
</p>
<p v-if="error" role="alert" class="text-xs leading-6 text-danger">{{ error }}</p>
<p v-if="plan && !plan.repairPlan.length && !error" role="status" class="text-xs text-muted">
当前没有可人工修订的质量阻断镜头,不代表未诊断镜头已通过。
</p>
<article
v-for="item in plan?.repairPlan"
:key="`${item.episodeNo}-${item.beatNo}-${item.shotNo}`"
class="flex flex-wrap items-center justify-between gap-3"
>
<div class="min-w-0">
<p class="text-sm">第 {{ item.episodeNo }} 集 · 节拍 {{ item.beatNo }} · 镜头 {{ item.shotNo }}</p>
<p class="mt-2 break-words text-xs text-muted">
{{ item.blockingCodes.map(qualityIssueLabel).join('、') }}
</p>
</div>
<NButton :disabled="disabled || !current" @click="edit(item)">人工修订</NButton>
</article>
</section>
<!-- 以下是版本化镜头人工修订模块,沿用公共弹窗底栏与间距 -->
<AppDialog
v-model:open="open"
:title="targetLabel"
description="修订完整动作与阶段证据;保存前后端会重新审核当前镜头。此操作不调用模型。"
:busy="operation.pending"
wide
>
<div v-if="draft" class="space-y-5">
<p v-if="candidate" class="text-xs leading-6 text-muted">
{{ candidate.suggestion }} {{ candidate.blockingReasons.join(';') }}
</p>
<ShotActionEditor v-model="draft" :disabled="disabled || operation.pending || !current" />
<p v-if="issue" role="status" class="text-xs leading-6 text-danger">{{ issue }}</p>
<p
v-if="operation.error && operation.label === '正在保存镜头人工修订'"
role="alert"
class="text-xs leading-6 text-danger"
>
{{ operation.error }}
</p>
</div>
<template #footer
><NButton :disabled="operation.pending" @click="open = false">取消</NButton
><ConfirmAction
:key="draftVersion"
label="保存人工修订"
description="将保存当前完整动作与阶段证据。若版本变化或质量审核仍不通过,后端会拒绝保存。保存成功后仍需恢复拆解与正式提交。"
:disabled="disabled || operation.pending || !current || !!issue"
@confirm="save"
/></template>
</AppDialog>
</template>
+100
View File
@@ -0,0 +1,100 @@
import type { ShotActionDraft } from './repair.types'
import { actionResourceOptions } from '../projects/quality-policy'
/**
* 将后端质量代码转为页面可理解的问题描述。
* @param code 后端质量原因码
* @returns 中文原因,未知问题保留代码便于定位
*/
export function qualityIssueLabel(code: string): string {
const labels: Record<string, string> = {
duplicate_action_id: '动作编号重复',
invalid_state_execution: '静态状态被要求执行',
invalid_duration_phase: '动作阶段无效',
missing_action_phase: '动作缺少对应阶段',
unknown_phase_action_id: '阶段引用了未知动作',
state_used_as_action_phase: '静态状态被用作动作阶段',
duration_phase_sum_mismatch: '阶段时长合计不一致',
unknown_resource_action_id: '资源引用了未知动作',
resource_action_not_in_phase: '资源动作不属于当前阶段',
invalid_resource_owner_ref: '资源主体引用无效',
action_resource_conflict: '动作资源占用冲突',
hand_occupancy_conflict: '手部占用冲突',
missing_required_actions: '缺少必需动作',
missing_duration_planning: '缺少时长规划',
insufficient_action_duration: '动作执行时间不足',
unknown_hand_action_id: '手部证据引用了未知动作',
hand_action_not_in_phase: '手部动作不属于当前阶段',
invalid_hand_character_ref: '手部主体引用无效'
}
return labels[code] ?? `待复核问题(${code})`
}
/**
* 深复制实际动作与全部证据,缺失字段保留待人工填写。
* @param shot 原始镜头中的可编辑字段
* @returns 独立的完整修订草稿
*/
export function actionDraft(shot: Partial<ShotActionDraft>): ShotActionDraft {
return JSON.parse(
JSON.stringify({
requiredActions: shot.requiredActions ?? [],
durationPlanning: shot.durationPlanning ?? {
complexity: 'low',
phases: [],
transitionSeconds: 0,
recommendedDurationSeconds: 0,
reason: ''
}
})
) as ShotActionDraft
}
/**
* 校验动作编号、阶段时长与证据引用,不替代后端质量审核。
* @param draft 当前人工编辑草稿
* @returns 首项问题,空字符串表示可以提交审核
*/
export function actionDraftIssue(draft: ShotActionDraft): string {
const ids = draft.requiredActions.map(item => item.id.trim())
if (!ids.length || ids.some(item => !item) || new Set(ids).size !== ids.length) return '请填写不重复的动作编号。'
if (draft.requiredActions.some(item => !item.description.trim() || !['action', 'state'].includes(item.kind)))
return '请补齐动作描述与类型。'
const planning = draft.durationPlanning
if (!planning.phases.length) return '请至少添加一个动作阶段。'
if (!['low', 'medium', 'high'].includes(planning.complexity) || !planning.reason.trim())
return '请补齐复杂度与时长依据。'
if (
!Number.isFinite(planning.transitionSeconds) ||
planning.transitionSeconds < 0 ||
!Number.isFinite(planning.recommendedDurationSeconds) ||
planning.recommendedDurationSeconds <= 0
)
return '阶段衔接与建议时长需填写有效秒数。'
for (const phase of planning.phases) {
if (!phase.action.trim()) return '请填写每个阶段的动作描述。'
if (!Number.isFinite(phase.estimatedSeconds) || phase.estimatedSeconds <= 0) return '阶段时长必须大于 0 秒。'
const references = [
...(phase.actionIds ?? []),
...(phase.handOccupancy?.map(item => item.actionId) ?? []),
...(phase.resourceOccupancy?.map(item => item.actionId) ?? [])
]
if (references.some(id => !ids.includes(id))) return '阶段证据引用了不存在的动作编号,请重新选择。'
if (
phase.handOccupancy?.some(
item => !item.characterRef.trim() || !['left', 'right', 'both'].includes(item.hands)
)
)
return '手部证据需填写主体引用和使用的手。'
if (
phase.resourceOccupancy?.some(
item =>
!item.ownerRef.trim() ||
!actionResourceOptions.some(option => option.value === item.resource) ||
!['support', 'hold', 'move', 'interact', 'other'].includes(item.usage)
)
)
return '资源证据需填写主体引用、资源和用途。'
}
return ''
}
+159
View File
@@ -0,0 +1,159 @@
import type { ActionResource } from '../projects/types'
/** 单镜头中必须执行或保持的动作。 */
export interface RequiredAction {
/** 动作唯一编号。 */
id: string
/** 具体动作描述。 */
description: string
/** 动作或静态状态。 */
kind: 'action' | 'state'
/** 是否必须在本镜头完成。 */
mustPerformInShot: boolean
}
/** 同一阶段的手部占用证据。 */
export interface HandOccupancy {
/** 被引用的动作编号。 */
actionId: string
/** 主体引用。 */
characterRef: string
/** 使用的手。 */
hands: 'left' | 'right' | 'both'
/** 是否允许共享。 */
shareable?: boolean
}
/** 通用身体或道具资源占用证据。 */
export interface ResourceOccupancy {
/** 主体引用。 */
ownerRef: string
/** 动作资源。 */
resource: ActionResource
/** 被引用的动作编号。 */
actionId: string
/** 具体用途。 */
usage: 'support' | 'hold' | 'move' | 'interact' | 'other'
/** 是否允许共享。 */
shareable: boolean
}
/** 镜头完整动作时长规划,保留手部及通用资源证据。 */
export interface ShotDurationPlanning {
/** 动作复杂度。 */
complexity: 'low' | 'medium' | 'high'
/** 按先后执行的动作阶段。 */
phases: Array<{
/** 阶段描述。 */
action: string
/** 阶段覆盖的动作编号。 */
actionIds?: string[]
/** 阶段预估秒数。 */
estimatedSeconds: number
/** 手部占用明细。 */
handOccupancy?: HandOccupancy[]
/** 身体与道具占用明细。 */
resourceOccupancy?: ResourceOccupancy[]
}>
/** 阶段切换所需秒数。 */
transitionSeconds: number
/** 建议镜头总时长。 */
recommendedDurationSeconds: number
/** 时长规划依据。 */
reason: string
}
/** 镜头人工修订草稿,仅包含后端允许编辑的动作字段。 */
export interface ShotActionDraft {
/** 全部必需动作。 */
requiredActions: RequiredAction[]
/** 完整阶段规划。 */
durationPlanning: ShotDurationPlanning
}
/** 只读质量修复目标。 */
export interface QualityRepairTarget {
/** 剧集编号。 */
episodeNo: number
/** 节拍编号。 */
beatNo: number
/** 镜头编号。 */
shotNo: number
/** 后端质量阻断原因码。 */
blockingCodes: string[]
}
/** 当前可恢复版本的修复计划。 */
export interface QualityRepairPlan {
/** 所属项目。 */
projectId: string
/** 被审核的检查点版本。 */
checkpointId: string | null
/** 待修订数量。 */
repairCount: number
/** 真实阻断镜头清单。 */
repairPlan: QualityRepairTarget[]
}
/** 当前有效的局部修复候选。 */
export interface QualityRepairCandidates {
/** 所属项目。 */
projectId: string
/** 当前检查点版本。 */
checkpointId: string | null
/** 已验证指纹的候选清单。 */
candidates: Array<{
/** 所属项目。 */
projectId: string
/** 检查点镜头位置标识。 */
shotId: string
/** 质量分类。 */
category: string
/** 问题原因码。 */
issueCodes: string[]
/** 当前目标镜头内容指纹。 */
expectedFingerprint: string
/** 后端修复建议。 */
suggestion: string
/** 限制与注意事项。 */
blockingReasons: string[]
/** 必须人工确认。 */
requiresManualConfirmation: true
/** 候选建议本身是否需要模型。 */
willCallModel: boolean
/** 查询不修改资产。 */
willModifyAssets: false
}>
}
/** 版本约束下的人工修订请求。 */
export interface QualityRepairInput extends ShotActionDraft {
/** 被编辑的检查点版本。 */
expectedCheckpointId: string
/** 从候选发起时必须提供镜头指纹。 */
expectedFingerprint?: string
/** 修订来源。 */
source: 'manual' | 'candidate'
/** 剧集编号。 */
episodeNo: number
/** 节拍编号。 */
beatNo: number
/** 镜头编号。 */
shotNo: number
}
/** 人工修订成功后仍需按后端就绪状态恢复拆解。 */
export interface QualityRepairResult {
/** 所属项目。 */
projectId: string
/** 新检查点版本。 */
checkpointId: string
/** 后端判断是否可恢复拆解。 */
canResumeBreakdown: boolean
/** 检查点是否可恢复。 */
checkpointRecoverable: boolean
/** 尚未验收的剧集编号。 */
pendingEpisodeNos: number[]
/** 尚存的质量问题,原样保留。 */
remainingQualityIssues: unknown[]
}
+40 -1
View File
@@ -34,6 +34,8 @@ export interface BreakdownTask {
/** 传给预览与启动接口的相同配置。 */
export interface BreakdownInput {
/** 仅生成候选,正式资产由独立确认入口提交。 */
candidateOnly?: boolean
groupSize: number
modules: BreakdownModule[]
}
@@ -100,6 +102,10 @@ export interface EpisodePlan {
/** 最小连续镜头及其主体形态绑定。 */
export interface StoryboardShot {
/** 完整必需动作,缺失时不自动补造历史证据。 */
requiredActions?: import('./repair.types').RequiredAction[]
/** 阶段时长与资源占用证据。 */
durationPlanning?: import('./repair.types').ShotDurationPlanning
shotNo: number
title: string
description: string
@@ -143,8 +149,23 @@ export interface WorkflowExecution {
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
export interface BreakdownState extends BreakdownResult {
/** 后端候选模式标记,缺省时不推断为候选。 */
candidateOnly?: boolean
/** 最新快照是否已经写入正式主体与分镜。 */
storyboardPersisted?: boolean
/** 候选是否已经通过安全提交入口保存。 */
candidateCommitted?: boolean
/** 候选生成时固定的剧本正文版本。 */
expectedEpisodeFingerprints?: Record<number, string>
/** 尚未完成质量审核的剧集。 */
storyboardPendingQualityEpisodeNos?: number[]
workflowExecution?: WorkflowExecution
runConfig?: BreakdownInput & { episodeGroups: EpisodeGroup[] }
runConfig?: BreakdownInput & {
/** 抽取任务使用的剧集分组。 */
episodeGroups: EpisodeGroup[]
/** 候选固定的源剧集编号,仅用于完整性提示。 */
sourceEpisodes?: { episodeNo: number }[]
}
taskSummary?: TaskSummary
tasks?: BreakdownTask[]
breakdownResult?: BreakdownResult
@@ -153,6 +174,24 @@ export interface BreakdownState extends BreakdownResult {
/** 不同失败阶段的恢复端点,不能用 retry 替代所有恢复。 */
export type BreakdownAction = 'start' | 'retry' | 'resume-shots' | 'resume-storyboard'
/** 安全提交候选的正式资产统计。 */
export interface BreakdownCandidateCommit {
/** 所属项目编号。 */
projectId: string
/** 正式主体数量。 */
subjectCount: number
/** 正式形态数量。 */
subjectFormCount: number
/** 正式剧集数量。 */
episodeCount: number
/** 正式节拍数量。 */
beatCount: number
/** 正式镜头数量。 */
shotCount: number
/** 镜头主体绑定数量。 */
shotSubjectCount: number
}
/** 已持久化分镜的手部动作诊断;无证据不代表无冲突。 */
export interface StoryboardHandOccupancyDiagnostics {
projectId: string