feat(short-drama-agent-front): 同步拆解候选审核与安全提交
This commit is contained in:
1 parent
cc27d463e0
commit
190333d4f9
26 files changed
+1495
-249
No files matched your search
@@ -4,7 +4,7 @@ import { NFormItem } from 'naive-ui'
|
||||
import { integerRule, fieldRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue'
|
||||
import { NScrollbar, NButton, NCheckbox, NInputNumber, NTab, NTable, NTabs } from 'naive-ui'
|
||||
import { NScrollbar, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTab, NTable, NTabs } from 'naive-ui'
|
||||
import { computed, h, nextTick, onScopeDispose, ref, watch } from 'vue'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { CircleAlert, Layers, LoaderCircle, Settings2 } from '@lucide/vue'
|
||||
@@ -23,6 +23,8 @@ import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
|
||||
import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
|
||||
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
|
||||
import BreakdownIssuesDialog from './components/BreakdownIssuesDialog.vue'
|
||||
import CandidateRepairs from './components/CandidateRepairs.vue'
|
||||
import { useBreakdownQuality } from './useBreakdownQuality'
|
||||
import type { DiagnosisLocation } from './diagnosis'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText } from '../../lib/format'
|
||||
@@ -68,15 +70,25 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
const snapshot = computed(() => breakdownSnapshot(checkpoints.value))
|
||||
const result = computed(() => snapshot.value?.breakdownResult ?? snapshot.value)
|
||||
/** 当前项目用于候选审核及所有版本化写操作。 */
|
||||
const projectId = computed(() => project.value?.id ?? '')
|
||||
/** 候选、正式和历史来源及质量状态统一选择。 */
|
||||
const qualityObservation = useBreakdownQuality(projectId, checkpoints)
|
||||
/** 当前质量结论不使用历史嵌套错误,也不作为正式提交许可。 */
|
||||
const quality = qualityObservation.quality
|
||||
/** 仅结果展示可回看历史,历史质量不进入当前审核。 */
|
||||
const snapshot = computed(() => qualityObservation.source.value.state ?? breakdownSnapshot(checkpoints.value))
|
||||
/** 当前同版本归一化成果,顶层修复优先。 */
|
||||
const result = computed(() => snapshot.value)
|
||||
const subjects = computed(() => result.value?.subjectCandidates ?? [])
|
||||
const forms = computed(() => result.value?.subjectForms ?? [])
|
||||
const plans = computed(() => result.value?.storyboardPlans ?? [])
|
||||
const shots = computed(() => result.value?.storyboardEpisodeShots ?? [])
|
||||
const summary = computed(() => snapshot.value?.taskSummary)
|
||||
const validation = computed(() => result.value?.storyboardShotValidation ?? snapshot.value?.storyboardShotValidation)
|
||||
const projectId = computed(() => project.value?.id ?? '')
|
||||
/** 候选审核读取完成前不展示旧错误。 */
|
||||
const validation = computed(() => quality.value.structureValid === null ? undefined : { valid: quality.value.structureValid, issues: quality.value.structuralIssues })
|
||||
/** 数据来源在桌面和移动端正文均明确显示,候选数量不冒充正式资产。 */
|
||||
const sourceLabel = computed(() => ({ candidate: '拆解候选 · 尚未提交正式结果', formal: '正式拆解结果', history: '历史结果 · 仅供回看', empty: '' })[quality.value.source])
|
||||
const operation = computed(() => getOperation(projectId.value))
|
||||
/** 分镜阅读和诊断入口共用当前剧集,不维护独立的诊断集号输入。 */
|
||||
const selectedEpisodeNo = ref<number>()
|
||||
@@ -101,7 +113,7 @@ const diagnosisPanel = ref<InstanceType<typeof StoryboardDiagnosis> | null>(null
|
||||
* @param location 当前分镜坐标
|
||||
*/
|
||||
function openShotDiagnosis(location: DiagnosisLocation) {
|
||||
if (breakdownBusy.value || backgroundExecution.discovering.value) return
|
||||
if (quality.value.source !== 'formal' || breakdownBusy.value || backgroundExecution.discovering.value) return
|
||||
diagnosisPanel.value?.open(location)
|
||||
}
|
||||
/**
|
||||
@@ -124,7 +136,19 @@ const execution = computed(() => {
|
||||
startedAt: record.startedAt ?? record.createdAt,
|
||||
completedAt: record.completedAt ?? undefined
|
||||
}
|
||||
: snapshot.value?.workflowExecution
|
||||
: latestCheckpoint.value?.state.workflowExecution
|
||||
})
|
||||
/** 修复或提交之后的历史失败不污染新版本;活动任务仍使用真实状态。 */
|
||||
const currentWorkflowError = computed(() => {
|
||||
if (execution.value?.status !== 'failed') return ''
|
||||
const latest = latestCheckpoint.value
|
||||
const failedAt = Date.parse(execution.value.completedAt ?? '')
|
||||
const checkpointAt = Date.parse(latest?.createdAt ?? '')
|
||||
// 优先比较真实终态时间,修复元数据不能屏蔽随后启动的新任务失败。
|
||||
if (Number.isFinite(failedAt) && Number.isFinite(checkpointAt))
|
||||
return checkpointAt > failedAt ? '' : execution.value.errorMessage || ''
|
||||
if (!backgroundExecution.query.data.value && latest?.metadata?.sourceCheckpointId) return ''
|
||||
return execution.value.errorMessage || ''
|
||||
})
|
||||
/** 拆解运行状态同时控制状态栏、诊断入口及所有恢复写操作。 */
|
||||
const breakdownBusy = computed(
|
||||
@@ -180,6 +204,11 @@ async function locateIssue(issue: ShotValidation['issues'][number]) {
|
||||
})
|
||||
}
|
||||
const taskStopped = computed(() => execution.value?.status === 'failed' || execution.value?.status === 'completed')
|
||||
/** 后续候选修订已替代旧任务结果时,只在明确的历史记录中展示回执。 */
|
||||
const executionHistorical = computed(() => {
|
||||
const record = backgroundExecution.query.data.value
|
||||
return !!record && !!latestCheckpoint.value && !!record.completedAt && Date.parse(latestCheckpoint.value.createdAt) > Date.parse(record.completedAt)
|
||||
})
|
||||
/** 后台拆解结束后自动刷新项目、Checkpoint 与正式主体/分镜数据。 */
|
||||
watch(
|
||||
() => backgroundExecution.query.data.value?.status,
|
||||
@@ -189,26 +218,44 @@ watch(
|
||||
}
|
||||
)
|
||||
/** 结构校验通过后仍可能存在服务端明确标记的质量待审剧集。 */
|
||||
const pendingQuality = computed(() => !!latestCheckpoint.value?.state.storyboardPendingQualityEpisodeNos?.length)
|
||||
const pendingQuality = computed(() => quality.value.actionStatus === 'blocked')
|
||||
/** 只在已有拆解结果且任务中断或校验待处理时提供阶段恢复。 */
|
||||
const showRecovery = computed(
|
||||
() =>
|
||||
records.value.length > 0 &&
|
||||
(execution.value?.status !== 'completed' || validation.value?.valid === false || pendingQuality.value)
|
||||
!quality.value.needsRefresh &&
|
||||
(!!currentWorkflowError.value || validation.value?.valid === false || pendingQuality.value)
|
||||
)
|
||||
/** 问题入口兼顾执行异常、结构错误、质量待审和已停止的恢复任务。 */
|
||||
const hasBreakdownIssues = computed(() =>
|
||||
Boolean(
|
||||
execution.value?.errorMessage ||
|
||||
validation.value?.valid === false ||
|
||||
pendingQuality.value ||
|
||||
currentWorkflowError.value ||
|
||||
quality.value.problems.length ||
|
||||
quality.value.error ||
|
||||
(showRecovery.value && taskStopped.value)
|
||||
)
|
||||
)
|
||||
/** 问题按钮按真实问题类型展示,不把质量待审或执行异常误称为结构校验失败。 */
|
||||
const issueEntryLabel = computed(() =>
|
||||
validation.value?.valid === false ? '分镜校验未通过' : pendingQuality.value ? '分镜质量待修订' : '拆解问题待处理'
|
||||
quality.value.error ? '候选审核待刷新' : validation.value?.valid === false ? '分镜校验未通过' : pendingQuality.value ? '分镜质量待修订' : '拆解问题待处理'
|
||||
)
|
||||
/** 当前状态颜色只取当前质量和活动任务,不继承历史执行失败。 */
|
||||
const qualityStatus = computed(() => breakdownBusy.value ? 'running' : quality.value.loading ? 'pending' : quality.value.needsRefresh ? 'unknown' : currentWorkflowError.value ? 'failed' : quality.value.problems.length ? 'blocked' : quality.value.structureValid === true ? quality.value.isCandidate ? 'candidate_pending' : 'completed' : 'unknown')
|
||||
/** 当前生命周期与审核文案集中展示。 */
|
||||
const qualityLabel = computed(() => {
|
||||
if (breakdownBusy.value) return '拆解进行中'
|
||||
if (backgroundExecution.discovering.value) return '正在读取任务状态'
|
||||
if (quality.value.loading) return '正在审核候选'
|
||||
if (quality.value.needsRefresh) return '候选审核待确认'
|
||||
if (validation.value?.valid === false) return '分镜校验未通过'
|
||||
if (pendingQuality.value) return '分镜质量待修订'
|
||||
if (currentWorkflowError.value) return '工作流失败'
|
||||
if (quality.value.committed) return '已提交正式结果'
|
||||
if (quality.value.isCandidate && quality.value.canRequestCommitPreview) return '候选审核通过 · 待安全预检查'
|
||||
if (quality.value.source === 'history') return '历史结果 · 当前质量待确认'
|
||||
if (quality.value.isCandidate) return '候选审核待处理'
|
||||
return quality.value.structureValid === true ? '正式分镜校验通过' : '执行状态待确认'
|
||||
})
|
||||
/** 所有问题修改和恢复共用活动锁及后台状态读取限制,查看问题不受影响。 */
|
||||
const issueActionsDisabled = computed(
|
||||
() =>
|
||||
@@ -218,6 +265,7 @@ const issueActionsDisabled = computed(
|
||||
breakdownBusy.value ||
|
||||
backgroundExecution.discovering.value ||
|
||||
!!backgroundExecution.discoveryError.value
|
||||
|| quality.value.loading || !!quality.value.error
|
||||
)
|
||||
const configValid = computed(
|
||||
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
|
||||
@@ -235,25 +283,30 @@ const actionMessage = useActionMessage()
|
||||
/** 问题内容变化才通知,轮询取得相同快照时不会重复弹出。 */
|
||||
const issueSignature = computed(() =>
|
||||
JSON.stringify({
|
||||
error: execution.value?.errorMessage || '',
|
||||
issues: validation.value?.valid === false ? validation.value.issues : []
|
||||
projectId: projectId.value,
|
||||
checkpointId: quality.value.checkpointId,
|
||||
error: currentWorkflowError.value,
|
||||
problems: quality.value.problems
|
||||
})
|
||||
)
|
||||
/** 首次读取或问题变化时只显示一条汇总,保留可操作的详情入口。 */
|
||||
/** 当前会话同一版本的相同问题只通知一次,重审或切集不重复弹出。 */
|
||||
const notifiedIssues = new Set<string>()
|
||||
watch(
|
||||
issueSignature,
|
||||
() => {
|
||||
const executionError = execution.value?.errorMessage
|
||||
const invalid = validation.value?.valid === false
|
||||
if (breakdownBusy.value || backgroundExecution.discovering.value) return
|
||||
if (!executionError && !invalid) return
|
||||
const executionError = currentWorkflowError.value
|
||||
const invalid = quality.value.issueCount > 0
|
||||
if (quality.value.needsRefresh || quality.value.loading || breakdownBusy.value || backgroundExecution.discovering.value) return
|
||||
if ((!executionError && !invalid) || notifiedIssues.has(issueSignature.value)) return
|
||||
notifiedIssues.add(issueSignature.value)
|
||||
actionMessage?.warning(
|
||||
() =>
|
||||
h('div', { class: 'flex flex-wrap items-center gap-3' }, [
|
||||
h(
|
||||
'span',
|
||||
invalid
|
||||
? `分镜校验未通过,共 ${validation.value?.issues.length ?? 0} 项问题。`
|
||||
? `当前${quality.value.isCandidate ? '候选' : '正式分镜'}待处理:结构 ${quality.value.structuralCount} 项,动作 ${quality.value.actionBlocks.length} 镜${quality.value.pendingEpisodeNos.length ? `,待审 ${quality.value.pendingEpisodeNos.length} 集` : ''}。`
|
||||
: '拆解任务未完成,请查看错误详情。'
|
||||
),
|
||||
h(
|
||||
@@ -365,7 +418,9 @@ async function run(action: BreakdownAction) {
|
||||
|
||||
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
|
||||
async function refreshCandidate() {
|
||||
await Promise.all([refresh(), refreshStageReadiness()])
|
||||
const key = qualityObservation.key.value
|
||||
await Promise.all([refresh(), refreshStageReadiness(), backgroundExecution.query.refresh()])
|
||||
if (key === qualityObservation.key.value) await qualityObservation.refresh()
|
||||
}
|
||||
|
||||
/** 导出当前拆解结果;阶段性数据也明确标记为 snapshot。 */
|
||||
@@ -397,31 +452,7 @@ const rules = {
|
||||
>抽取 {{ summary.completed }} / {{ summary.total }} · 失败 {{ summary.failed }}</span
|
||||
>
|
||||
<span>主体 {{ subjects.length }} · 分镜剧集 {{ shots.length }} / {{ plans.length }}</span>
|
||||
<StatusBadge
|
||||
:status="
|
||||
breakdownBusy
|
||||
? 'running'
|
||||
: validation?.valid === false
|
||||
? 'blocked'
|
||||
: execution?.status || 'unknown'
|
||||
"
|
||||
:label="
|
||||
breakdownBusy
|
||||
? '拆解进行中'
|
||||
: backgroundExecution.discovering.value
|
||||
? '正在读取任务状态'
|
||||
: validation?.valid === false
|
||||
? '分镜校验未通过'
|
||||
: execution?.status === 'completed'
|
||||
? latestCheckpoint?.state.candidateOnly &&
|
||||
!latestCheckpoint.state.storyboardPersisted
|
||||
? '候选生成已完成'
|
||||
: '工作流已完成'
|
||||
: execution?.status === 'failed'
|
||||
? '工作流失败'
|
||||
: '执行状态待确认'
|
||||
"
|
||||
/>
|
||||
<StatusBadge :status="qualityStatus" :label="qualityLabel" />
|
||||
<span v-if="breakdownBusy" class="flex items-center gap-2" role="status"
|
||||
><LoaderCircle :size="13" class="animate-spin" />最近阶段:{{ runningStage }}</span
|
||||
>
|
||||
@@ -588,14 +619,18 @@ const rules = {
|
||||
</section>
|
||||
<BreakdownCandidatePanel
|
||||
:project-id="projectId"
|
||||
:state="latestCheckpoint?.state"
|
||||
:state="qualityObservation.source.value.state || undefined"
|
||||
:quality="quality"
|
||||
:checkpoint-id="latestCheckpoint?.checkpointId"
|
||||
:disabled="!!error || operation.pending || backgroundExecution.active.value"
|
||||
:disabled="issueActionsDisabled"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<!-- 以下是明确标记的历史执行回执,旧任务结论不表示当前候选质量 -->
|
||||
<component :is="executionHistorical ? NCollapse : 'div'" v-if="backgroundExecution.executionId.value" :class="{ 'breakdown-execution-history': executionHistorical }">
|
||||
<component :is="executionHistorical ? NCollapseItem : 'div'" :name="executionHistorical ? 'history' : undefined" :title="executionHistorical ? '历史拆解执行记录(不代表当前质量)' : undefined">
|
||||
<WorkflowExecutionPanel
|
||||
v-if="backgroundExecution.executionId.value"
|
||||
title="剧本拆解任务"
|
||||
:title="executionHistorical ? '历史拆解任务' : '剧本拆解任务'"
|
||||
class="breakdown-execution-panel"
|
||||
:show-status-hint="false"
|
||||
:execution="backgroundExecution.query.data.value"
|
||||
@@ -604,6 +639,8 @@ const rules = {
|
||||
@refresh="backgroundExecution.query.refresh"
|
||||
@dismiss="backgroundExecution.dismiss"
|
||||
/>
|
||||
</component>
|
||||
</component>
|
||||
</WorkspaceTools>
|
||||
</div>
|
||||
</div>
|
||||
@@ -615,7 +652,9 @@ const rules = {
|
||||
/>
|
||||
</NScrollbar>
|
||||
<template v-else>
|
||||
<section class="breakdown-results-section">
|
||||
<section class="breakdown-results-section" :data-breakdown-source="quality.source">
|
||||
<!-- 以下是候选与正式数据来源提示,手机也不隐藏,防止把候选镜头当作正式资产 -->
|
||||
<p v-if="sourceLabel" class="text-xs text-muted" role="status">{{ sourceLabel }}<span v-if="quality.loading"> · 正在读取当前质量审核…</span></p>
|
||||
<div class="result-toolbar tabs-toolbar">
|
||||
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="拆解结果"
|
||||
><!-- 以下是仅显示分类名称的拆解标签模块,主体数量保留在搜索统计中 -->
|
||||
@@ -670,7 +709,7 @@ const rules = {
|
||||
<template v-for="option in moduleOptions" :key="option.value"
|
||||
><div v-if="tab === option.value" class="breakdown-result-pad">
|
||||
<SubjectList
|
||||
:project-id="project?.id"
|
||||
:project-id="quality.source === 'formal' ? project?.id : undefined"
|
||||
:subjects="subjects.filter(item => item.module === option.value)"
|
||||
:forms="forms"
|
||||
/></div
|
||||
@@ -681,13 +720,13 @@ const rules = {
|
||||
v-model:episode-no="selectedEpisodeNo"
|
||||
:plans="plans"
|
||||
:episodes="shots"
|
||||
:diagnosis-disabled="breakdownBusy || backgroundExecution.discovering.value"
|
||||
:diagnosis-disabled="quality.source !== 'formal' || breakdownBusy || backgroundExecution.discovering.value"
|
||||
@diagnose="openShotDiagnosis"
|
||||
>
|
||||
<!-- 以下是跟随当前剧集的一行诊断摘要,诊断弹窗独立于列表滚动 -->
|
||||
<template #diagnosis>
|
||||
<StoryboardDiagnosis
|
||||
v-if="!breakdownBusy && !backgroundExecution.discovering.value"
|
||||
v-if="quality.source === 'formal' && !breakdownBusy && !backgroundExecution.discovering.value"
|
||||
ref="diagnosisPanel"
|
||||
:project-id="projectId"
|
||||
:episode-no="currentEpisodeNo"
|
||||
@@ -759,9 +798,11 @@ const rules = {
|
||||
<BreakdownIssuesDialog
|
||||
v-model:open="issuesOpen"
|
||||
:issues="storyboardIssues"
|
||||
:workflow-error="execution?.errorMessage"
|
||||
:quality="quality"
|
||||
:workflow-error="currentWorkflowError"
|
||||
:locatable="!breakdownBusy && !!shots.length"
|
||||
@locate="locateIssue"
|
||||
@refresh="refreshCandidate"
|
||||
>
|
||||
<!-- 以下是只属于问题处理的人工修订与阶段恢复,不混入拆解启动配置 -->
|
||||
<template #repair>
|
||||
@@ -775,8 +816,17 @@ const rules = {
|
||||
>
|
||||
任务状态或结果尚未确认,请先重新读取状态与结果。
|
||||
</p>
|
||||
<CandidateRepairs
|
||||
v-if="issuesOpen && quality.isCandidate && snapshot"
|
||||
:project-id="projectId"
|
||||
:checkpoint-id="latestCheckpoint?.checkpointId || ''"
|
||||
:state="snapshot"
|
||||
:review="qualityObservation.review.value"
|
||||
:disabled="issueActionsDisabled"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<StoryboardQualityRepair
|
||||
v-if="issuesOpen && snapshot"
|
||||
v-else-if="issuesOpen && snapshot && !quality.isCandidate"
|
||||
:project-id="projectId"
|
||||
:checkpoint="latestCheckpoint"
|
||||
:disabled="issueActionsDisabled"
|
||||
@@ -816,6 +866,13 @@ const rules = {
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 历史折叠只保留一层内容留白,避免 Naive 内容间距叠加任务卡片的 mt-4。 */
|
||||
.breakdown-execution-history.n-collapse .n-collapse-item .n-collapse-item__content-wrapper .n-collapse-item__content-inner {
|
||||
padding-top: 8px;
|
||||
}
|
||||
.breakdown-execution-history .breakdown-execution-panel {
|
||||
margin-top: 0;
|
||||
}
|
||||
/* 键盘聚焦仍有清晰提示,并与问题入口的红色语义保持一致。 */
|
||||
.breakdown-workspace-page .breakdown-issues-trigger.n-button:focus-visible {
|
||||
outline-color: var(--app-danger);
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
LegacyActionDiagnosisResults
|
||||
} from './types'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import type { CandidateRevalidation, CandidateCommitPreview, CandidateSubjectRepairInput, CandidateSubjectRepairResult, CandidateActionRepairInput, CandidateActionRepairResult } from './candidate.types'
|
||||
import type {
|
||||
QualityRepairPlan,
|
||||
QualityRepairCandidates,
|
||||
@@ -22,6 +23,38 @@ import type {
|
||||
|
||||
/** Breakdown API;预览为只读查询,启动和恢复返回可持续观察的后台任务。 */
|
||||
export const breakdownApi = {
|
||||
/**
|
||||
* 只读重新审核当前候选,不提供正式提交许可。
|
||||
* @param id 当前项目
|
||||
* @param signal 取消信号
|
||||
* @returns 版本化质量审核
|
||||
*/
|
||||
revalidateCandidate: (id: string, signal?: AbortSignal) =>
|
||||
request<CandidateRevalidation>(`/projects/${encodeURIComponent(id)}/breakdown/candidate-revalidation`, { signal }),
|
||||
/**
|
||||
* 只读检查剧本与下游资产的正式提交安全条件。
|
||||
* @param id 当前项目
|
||||
* @param signal 取消信号
|
||||
* @returns 版本化安全检查
|
||||
*/
|
||||
candidateCommitPreview: (id: string, signal?: AbortSignal) =>
|
||||
request<CandidateCommitPreview>(`/projects/${encodeURIComponent(id)}/breakdown/candidate-commit-preview`, { signal }),
|
||||
/**
|
||||
* 用户确认后补齐候选主体引用与真实形态。
|
||||
* @param id 当前项目
|
||||
* @param input 修复目标与候选版本
|
||||
* @returns 新候选检查点
|
||||
*/
|
||||
repairCandidateSubject: (id: string, input: CandidateSubjectRepairInput) =>
|
||||
request<CandidateSubjectRepairResult>(`/projects/${encodeURIComponent(id)}/breakdown/candidate-subject-repair`, { method: 'POST', body: input }),
|
||||
/**
|
||||
* 用户确认后批量修订候选动作描述,不触发模型。
|
||||
* @param id 当前项目
|
||||
* @param input 原始动作目标、人工描述与候选版本
|
||||
* @returns 新候选检查点及剩余待审剧集
|
||||
*/
|
||||
repairCandidateActions: (id: string, input: CandidateActionRepairInput) =>
|
||||
request<CandidateActionRepairResult>(`/projects/${encodeURIComponent(id)}/breakdown/candidate-action-batch-repair`, { method: 'POST', body: input }),
|
||||
/**
|
||||
* 读取当前仍被质量审核阻断的镜头。
|
||||
* @param id 当前项目编号
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
import type { BreakdownState } from './types'
|
||||
import type { CandidateCommitPreview } from './candidate.types'
|
||||
|
||||
/** 安全检查项与用户可理解的阻断原因共用一份映射。 */
|
||||
export const candidateCheckLabels: Record<keyof CandidateCommitPreview['checks'], string> = {
|
||||
episodeNumbersMatch: '剧集范围与候选一致',
|
||||
episodeFingerprintsMatch: '剧本正文版本未变化',
|
||||
noActiveExecutions: '没有正在执行的制作任务',
|
||||
noActiveVideos: '没有正在生成的视频',
|
||||
noSubjectIdentities: '没有需要保护的主体身份',
|
||||
noSubjectImages: '没有需要保护的主体图片',
|
||||
noProtectedShots: '没有需要保护的镜头资产'
|
||||
}
|
||||
/** 必须逐项校验的固定安全门禁,不根据响应动态减少检查项。 */
|
||||
export const candidateCheckKeys = ['episodeNumbersMatch', 'episodeFingerprintsMatch', 'noActiveExecutions', 'noActiveVideos', 'noSubjectIdentities', 'noSubjectImages', 'noProtectedShots'] as const
|
||||
|
||||
/**
|
||||
* 安全预检查必须逐项通过且属于当前项目和候选,不能只相信 ready。
|
||||
* @param preview 安全预检查回执
|
||||
* @param projectId 当前项目
|
||||
* @param checkpointId 当前候选版本
|
||||
* @returns 是否可进入最终确认
|
||||
*/
|
||||
export function candidatePreviewReady(preview: CandidateCommitPreview | null, projectId: string, checkpointId?: string): boolean {
|
||||
if (!preview || preview.projectId !== projectId || preview.checkpointId !== checkpointId) return false
|
||||
// 外部 JSON 的布尔值必须严格为 true,不接受缺失值或字符串等真值。
|
||||
const flags: unknown[] = [preview.readOnly, preview.ready, ...candidateCheckKeys.map(key => preview.checks?.[key])]
|
||||
return flags.every(value => value === true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅用最新原始快照提示提交条件,实际替换权限仍由后端事务判断。
|
||||
* @param state 最新原始拆解快照,禁止传入历史回退拼接结果
|
||||
* @returns 提交前需要处理的问题,空字符串表示可以请求后端提交
|
||||
* @returns 完整性阻断原因,空字符串只表示可继续安全预检查,不是提交许可
|
||||
*/
|
||||
export function candidateCommitIssue(state: BreakdownState | null | undefined): string {
|
||||
if (state?.candidateOnly !== true) return '当前最新结果不是候选模式。'
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
import type { ShotValidation, StoryboardShot, SubjectCandidate, SubjectForm } from './types'
|
||||
|
||||
/** 候选整体完整性审核,不代表正式提交许可。 */
|
||||
export interface CandidateValidation {
|
||||
/** 是否通过当前确定性校验。 */
|
||||
valid: boolean
|
||||
/** 完整性与绑定问题。 */
|
||||
issues: string[]
|
||||
}
|
||||
|
||||
/** 候选镜头坐标。 */
|
||||
export interface CandidateShotLocation {
|
||||
/** 剧集编号。 */
|
||||
episodeNo: number
|
||||
/** 节拍编号。 */
|
||||
beatNo: number
|
||||
/** 镜头编号。 */
|
||||
shotNo: number
|
||||
}
|
||||
|
||||
/** 当前动作质量决策,与后端原始状态一致。 */
|
||||
export interface CandidateActionBlock extends CandidateShotLocation {
|
||||
/** 审核结果。 */
|
||||
status: 'passed' | 'needs_review' | 'blocked'
|
||||
/** 阻断代码。 */
|
||||
blockingCodes: string[]
|
||||
/** 警告代码。 */
|
||||
warningCodes: string[]
|
||||
/** 对应剧集是否仍待处理。 */
|
||||
isPendingEpisode: boolean
|
||||
}
|
||||
|
||||
/** 缺失引用的原始诊断及可选真实形态。 */
|
||||
export interface CandidateMissingSubject {
|
||||
/** 剧集编号。 */
|
||||
episodeNo: number
|
||||
/** 未提供精确位置时不可写入修复。 */
|
||||
beatNo?: number | null
|
||||
/** 未提供精确位置时不可写入修复。 */
|
||||
shotNo?: number | null
|
||||
/** 后端原始问题。 */
|
||||
message: string
|
||||
/** 目标镜头原始引用。 */
|
||||
shot: Pick<StoryboardShot, 'title' | 'description' | 'visualFocus' | 'subjectRefs' | 'subjectBindings'> | null
|
||||
/** 节拍允许的主体。 */
|
||||
beatSubjectRefs: string[]
|
||||
/** 解析到的候选主体。 */
|
||||
subject: SubjectCandidate | null
|
||||
/** 该主体已有形态。 */
|
||||
availableForms: SubjectForm[]
|
||||
}
|
||||
|
||||
/** 道具引用诊断,全部标志正常时不展示为问题。 */
|
||||
export interface CandidatePropDiagnostic extends CandidateShotLocation {
|
||||
/** 道具引用。 */
|
||||
subjectRef: string
|
||||
/** 镜头标题。 */
|
||||
shotTitle: string
|
||||
/** 镜头正文。 */
|
||||
shotDescription: string
|
||||
/** 节拍是否包含道具。 */
|
||||
beatAllowsSubject: boolean
|
||||
/** 镜头是否包含道具。 */
|
||||
shotHasSubject: boolean
|
||||
/** 镜头是否已有绑定。 */
|
||||
shotHasBinding: boolean
|
||||
/** 道具名称。 */
|
||||
subjectName: string
|
||||
/** 该道具的真实形态。 */
|
||||
availableForms: SubjectForm[]
|
||||
}
|
||||
|
||||
/** 当前候选只读重新审核响应,不修改数据库或调用模型。 */
|
||||
export interface CandidateRevalidation {
|
||||
/** 当前检查点。 */
|
||||
checkpointId: string
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 候选剧集数。 */
|
||||
episodeCount: number
|
||||
/** 候选镜头数,尚不代表正式资产。 */
|
||||
shotCount: number
|
||||
/** 历史问题,仅用于明确标记的历史记录。 */
|
||||
previousIssues: ShotValidation['issues']
|
||||
/** 当前结构问题。 */
|
||||
currentIssues: ShotValidation['issues']
|
||||
/** 当前缺失引用。 */
|
||||
missingSubjectRefs: CandidateMissingSubject[]
|
||||
/** 当前待审核剧集。 */
|
||||
pendingQualityEpisodeNos: number[]
|
||||
/** 当前动作阻断或资源冲突。 */
|
||||
actionQualityBlocks: CandidateActionBlock[]
|
||||
/** 阻断镜头的原始动作规划。 */
|
||||
actionRepairTargets: Array<CandidateActionBlock & {
|
||||
/** 缺少原始镜头时禁止修复。 */
|
||||
shot: Pick<StoryboardShot, 'title' | 'description' | 'visualFocus' | 'durationSeconds' | 'subjectRefs'> & {
|
||||
/** 原始动作,不提供 kind 编辑入口。 */
|
||||
requiredActions: NonNullable<StoryboardShot['requiredActions']>
|
||||
/** 原始阶段规划。 */
|
||||
durationPlanning: StoryboardShot['durationPlanning'] | null
|
||||
} | null
|
||||
}>
|
||||
/** 道具引用检查。 */
|
||||
propReferenceDiagnostics: CandidatePropDiagnostic[]
|
||||
/** 没有对应动作阻断的残留待审剧集,仍需明确处理。 */
|
||||
pendingWithoutActionBlocks: number[]
|
||||
/** 当前候选完整性审核。 */
|
||||
candidateValidation: CandidateValidation
|
||||
/** 此接口始终不提供提交许可。 */
|
||||
canCommit: false
|
||||
}
|
||||
|
||||
/** 候选提交安全预检查响应,正式提交仍会在事务内复查。 */
|
||||
export interface CandidateCommitPreview {
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 被检查的候选版本。 */
|
||||
checkpointId: string
|
||||
/** 所有检查是否通过。 */
|
||||
ready: boolean
|
||||
/** 剧本版本、活动任务及下游资产保护。 */
|
||||
checks: {
|
||||
/** 剧集编号一致。 */
|
||||
episodeNumbersMatch: boolean
|
||||
/** 剧本正文指纹一致。 */
|
||||
episodeFingerprintsMatch: boolean
|
||||
/** 没有活动制作任务。 */
|
||||
noActiveExecutions: boolean
|
||||
/** 没有活动视频任务。 */
|
||||
noActiveVideos: boolean
|
||||
/** 没有主体身份资产。 */
|
||||
noSubjectIdentities: boolean
|
||||
/** 没有主体图片资产。 */
|
||||
noSubjectImages: boolean
|
||||
/** 没有受保护镜头资产。 */
|
||||
noProtectedShots: boolean
|
||||
}
|
||||
/** 真实数据数量。 */
|
||||
counts: {
|
||||
/** 正式剧集。 */
|
||||
episodes: number
|
||||
/** 已有分镜剧集。 */
|
||||
existingStoryboards: number
|
||||
/** 活动工作流。 */
|
||||
activeExecutions: number
|
||||
/** 活动视频。 */
|
||||
activeVideos: number
|
||||
/** 主体身份。 */
|
||||
subjectIdentities: number
|
||||
/** 主体图片。 */
|
||||
subjectImages: number
|
||||
/** 受保护镜头。 */
|
||||
protectedShots: number
|
||||
}
|
||||
/** 此操作只读。 */
|
||||
readOnly: true
|
||||
}
|
||||
|
||||
/** 人工确认的候选主体补齐请求。 */
|
||||
export interface CandidateSubjectRepairInput extends CandidateShotLocation {
|
||||
/** 乐观版本锁。 */
|
||||
expectedCheckpointId: string
|
||||
/** 真实候选主体引用。 */
|
||||
subjectRef: string
|
||||
/** 属于该主体的已有形态。 */
|
||||
formId: string
|
||||
}
|
||||
|
||||
/** 只创建候选新版本的主体修复回执。 */
|
||||
export interface CandidateSubjectRepairResult {
|
||||
/** 新检查点。 */
|
||||
checkpointId: string
|
||||
/** 修复后的结构校验。 */
|
||||
storyboardShotValidation: ShotValidation
|
||||
/** 修复后的候选完整性。 */
|
||||
candidateValidation: CandidateValidation
|
||||
}
|
||||
|
||||
/** 单个动作语义修订,只允许编辑描述。 */
|
||||
export interface CandidateActionRepair extends CandidateShotLocation {
|
||||
/** 原始动作编号。 */
|
||||
actionId: string
|
||||
/** 用户明确确认的过程描述。 */
|
||||
description: string
|
||||
}
|
||||
|
||||
/** 批量候选动作修复请求。 */
|
||||
export interface CandidateActionRepairInput {
|
||||
/** 乐观版本锁。 */
|
||||
expectedCheckpointId: string
|
||||
/** 用户选择的多个动作。 */
|
||||
repairs: CandidateActionRepair[]
|
||||
}
|
||||
|
||||
/** 批量修复回执,不代表正式资产已写入。 */
|
||||
export interface CandidateActionRepairResult {
|
||||
/** 新检查点。 */
|
||||
checkpointId: string
|
||||
/** 实际修复镜头数。 */
|
||||
repairedShotCount: number
|
||||
/** 仍待审核的剧集。 */
|
||||
pendingQualityEpisodeNos: number[]
|
||||
}
|
||||
@@ -1,112 +1,152 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox } from 'naive-ui'
|
||||
import { AppDialog, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import type { BreakdownState } from '../types'
|
||||
import { candidateCommitIssue } from '../candidate'
|
||||
import type { BreakdownQuality } from '../quality'
|
||||
import type { CandidateCommitPreview } from '../candidate.types'
|
||||
import { candidateCheckKeys, candidateCheckLabels, candidatePreviewReady } from '../candidate'
|
||||
import { breakdownApi } from '../api'
|
||||
import { runOperation, getOperation, isOperationRunning } from '../../workflows/operations'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { runOperation, getOperation } from '../../workflows/operations'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { workflowCheckpoints } from '../../workflows/selectors'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { showActionFeedback, useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
|
||||
/** 最新候选快照及独立提交入口。 */
|
||||
/** 当前原始版本与集中审核结论共同决定安全检查入口。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式项目编号。 */
|
||||
/** 当前项目。 */
|
||||
projectId: string
|
||||
/** 服务端最新原始快照,不使用历史回退结果。 */
|
||||
/** 当前版本归一化候选。 */
|
||||
state?: BreakdownState
|
||||
/** 当前快照版本,用于撤销旧确认。 */
|
||||
/** 当前检查点。 */
|
||||
checkpointId?: string
|
||||
/** 项目存在活动任务或读取错误。 */
|
||||
/** 页面统一质量结论。 */
|
||||
quality: BreakdownQuality
|
||||
/** 活动任务或读取失败时禁止写入。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 提交后刷新正式资产和阶段状态。 */
|
||||
/** 只在真实写回后刷新服务端资产及阶段状态。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 项目级操作锁与错误反馈沿用现有工作区。 */
|
||||
/** 应用消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 项目级写操作锁。 */
|
||||
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
|
||||
}))
|
||||
/** 当前预检查回执。 */
|
||||
const preview = ref<CandidateCommitPreview | null>(null)
|
||||
/** 只读安全检查加载状态。 */
|
||||
const checking = ref(false)
|
||||
/** 本面板正式提交状态。 */
|
||||
const committing = ref(false)
|
||||
/** 预检查请求失败原因。 */
|
||||
const checkError = ref('')
|
||||
/** 仅通过预检查才能打开最终确认。 */
|
||||
const confirmOpen = ref(false)
|
||||
/** 用户对替换正式资产的明确确认。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 已收到成功回执的版本,服务端刷新前也不允许重复写入。 */
|
||||
const submittedId = ref('')
|
||||
/** 过期、关闭和卸载时取消只读预检查。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 拒绝忽略取消信号后返回的旧响应。 */
|
||||
let version = 0
|
||||
/** 当前候选生成或提交后的面板。 */
|
||||
const isCandidate = computed(() => props.state?.candidateOnly === true && (props.quality.isCandidate || props.quality.committed))
|
||||
/** 后端持久化标记优先,成功回执只在当前会话补充防重复锁。 */
|
||||
const committed = computed(() => props.quality.committed || submittedId.value === `${props.projectId}:${props.checkpointId}`)
|
||||
/** 审核通过后只允许请求预检查,绝不直接允许写入。 */
|
||||
const canCheck = computed(() => !props.disabled && !operation.value.pending && !committed.value && props.quality.canRequestCommitPreview && props.quality.checkpointId === props.checkpointId)
|
||||
/** 逐项与版本确认后的预检查结果。 */
|
||||
const ready = computed(() => candidatePreviewReady(preview.value, props.projectId, props.checkpointId))
|
||||
/** 仅展示具体未通过的安全检查。 */
|
||||
const failedChecks = computed(() => preview.value ? candidateCheckKeys.filter(key => preview.value!.checks?.[key] !== true).map(key => candidateCheckLabels[key]) : [])
|
||||
/** 当前候选规模与正式资产区别标注。 */
|
||||
const counts = computed(() => ({ subjects: props.state?.subjectCandidates?.length ?? 0, episodes: props.state?.storyboardEpisodeShots?.length ?? 0, shots: props.state?.storyboardEpisodeShots?.reduce((sum, episode) => sum + episode.beatShots.reduce((total, beat) => total + beat.shots.length, 0), 0) ?? 0 }))
|
||||
|
||||
/** 只提交一次,后端事务再次校验剧本版本、候选审核和下游资产。 */
|
||||
async function commit() {
|
||||
if (props.disabled || issue.value || operation.value.pending) return
|
||||
/** 撤销旧检查与确认,版本变化后不能复用提交许可。 */
|
||||
function invalidate() {
|
||||
version++
|
||||
controller?.abort()
|
||||
checking.value = false
|
||||
preview.value = null
|
||||
confirmOpen.value = false
|
||||
acknowledged.value = false
|
||||
checkError.value = ''
|
||||
}
|
||||
watch([() => props.projectId, () => props.checkpointId, () => props.quality.canRequestCommitPreview, () => props.quality.committed], invalidate, { flush: 'sync' })
|
||||
watch(() => props.disabled, disabled => { if (disabled && !committing.value) invalidate() })
|
||||
onScopeDispose(invalidate)
|
||||
|
||||
/** 安全检查通过后才展示最终确认;不调用任何写接口。 */
|
||||
async function check() {
|
||||
if (!canCheck.value || checking.value) return
|
||||
invalidate()
|
||||
const current = version
|
||||
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')
|
||||
controller = new AbortController()
|
||||
checking.value = true
|
||||
try {
|
||||
const result = await breakdownApi.candidateCommitPreview(id, controller.signal)
|
||||
if (current !== version) return
|
||||
if (result.projectId !== id || result.checkpointId !== checkpointId || result.readOnly !== true) throw new Error('候选安全预检查已过期,请刷新后重新检查。')
|
||||
preview.value = result
|
||||
if (candidatePreviewReady(result, id, checkpointId)) confirmOpen.value = true
|
||||
else showActionFeedback(message, '候选暂不能提交,请处理未通过的安全检查。', 'warning')
|
||||
} catch (cause) {
|
||||
if (current === version) {
|
||||
checkError.value = errorMessage(cause)
|
||||
showActionFeedback(message, checkError.value, 'error')
|
||||
}
|
||||
} finally { if (current === version) checking.value = false }
|
||||
}
|
||||
|
||||
/** 最终确认时重新核对版本和全部安全门禁,随后交由后端事务提交。 */
|
||||
async function commit() {
|
||||
if (!canCheck.value || !ready.value || !confirmOpen.value || !acknowledged.value || committing.value) return
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
const checkedVersion = version
|
||||
committing.value = true
|
||||
const ok = await runOperation(id, '正在提交拆解候选', async () => {
|
||||
const records = await projectsApi.checkpoints(id)
|
||||
const latest = workflowCheckpoints(records, 'breakdown').at(-1)
|
||||
if (!checkpointId || latest?.checkpointId !== checkpointId || latest.state.storyboardPersisted || latest.state.candidateCommitted || props.projectId !== id || props.checkpointId !== checkpointId) throw new Error('拆解候选版本已变化或已经提交,请刷新后重新确认。')
|
||||
const checked = await breakdownApi.candidateCommitPreview(id)
|
||||
if (checkedVersion !== version || !props.quality.canRequestCommitPreview || !candidatePreviewReady(checked, id, checkpointId) || props.projectId !== id || props.checkpointId !== checkpointId) throw new Error('提交安全条件已变化,请重新检查候选。')
|
||||
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) {
|
||||
if (ok) submittedId.value = `${id}:${checkpointId}`
|
||||
invalidate()
|
||||
emit('refresh')
|
||||
}
|
||||
committing.value = false
|
||||
}
|
||||
</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
|
||||
>
|
||||
<span class="text-xs text-muted">{{ committed ? '正式主体' : '候选主体' }} {{ 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>
|
||||
<p class="text-xs leading-6 text-muted">{{ committed ? '这份结果已写入正式主体、形态与分镜。' : '候选尚未写入正式资产,质量审核后还需通过安全预检查。' }}</p>
|
||||
<p v-if="!committed" class="text-xs text-muted" role="status">{{ quality.loading ? '正在重新审核当前候选…' : quality.needsRefresh ? '当前候选审核尚未确认,请刷新候选状态。' : quality.canRequestCommitPreview ? '候选质量审核通过,可执行提交安全预检查。' : '候选仍有待处理问题,请先修订。' }}</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>
|
||||
<NButton v-if="!committed" :disabled="!canCheck" :loading="checking || committing" @click="check">提交候选为正式结果</NButton>
|
||||
<WorkspaceRefreshButton label="刷新候选状态" :loading="quality.loading" :disabled="operation.pending || checking" @refresh="emit('refresh')" />
|
||||
</div>
|
||||
<p
|
||||
v-if="operation.error && operation.label === '正在提交拆解候选'"
|
||||
role="alert"
|
||||
class="text-xs leading-6 text-danger"
|
||||
>
|
||||
{{ operation.error }}
|
||||
</p>
|
||||
<section v-if="failedChecks.length" class="problem-surface p-4" aria-label="未通过的提交安全检查"><p class="mb-2 text-sm">提交安全检查未通过</p><ul class="list-inside list-disc space-y-2 text-xs"><li v-for="label in failedChecks" :key="label">{{ label }}</li></ul></section>
|
||||
<p v-if="checkError" class="text-xs text-danger" role="alert">{{ checkError }}</p>
|
||||
<!-- 以下是通过只读预检查后才出现的最终确认,取消和关闭撤销确认 -->
|
||||
<AppDialog v-model:open="confirmOpen" title="确认提交候选为正式结果" :busy="committing" description="将替换正式主体、形态与分镜。提交时后端仍会在事务内重新检查剧本版本和下游资产。">
|
||||
<p class="text-sm">本次候选:{{ counts.subjects }} 个主体、{{ counts.episodes }} 集、{{ counts.shots }} 个镜头。</p>
|
||||
<NCheckbox v-model:checked="acknowledged" class="mt-5">我已确认替换正式结果,当前没有同项目的制作任务在运行。</NCheckbox>
|
||||
<template #footer><NButton :disabled="committing" @click="confirmOpen = false; acknowledged = false">取消</NButton><NButton type="primary" :loading="committing" :disabled="!acknowledged || !ready || !canCheck" @click="commit">确认提交候选为正式结果</NButton></template>
|
||||
</AppDialog>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import type { ShotValidation } from '../types'
|
||||
import type { BreakdownQuality } from '../quality'
|
||||
|
||||
/** 同一剧集、节拍和镜头的校验问题分组。 */
|
||||
interface BreakdownIssueGroup {
|
||||
@@ -22,11 +23,18 @@ const props = defineProps<{
|
||||
workflowError?: string
|
||||
/** 当前结果是否允许定位到分镜正文。 */
|
||||
locatable: boolean
|
||||
/** 当前版本统一审核,历史问题与当前问题分开。 */
|
||||
quality?: BreakdownQuality
|
||||
}>()
|
||||
/** 独立问题抽屉显隐。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 抽屉关闭后再定位正文,避免焦点陷阱阻止定位。 */
|
||||
const emit = defineEmits<{ locate: [issue: ShotValidation['issues'][number]] }>()
|
||||
const emit = defineEmits<{ locate: [issue: ShotValidation['issues'][number]]; refresh: [] }>()
|
||||
/** 问题类型统一分类,缺失精确坐标时只提供剧集查看。 */
|
||||
const problemGroups = computed(() => ([
|
||||
['subject', '主体引用缺失'], ['binding', '形态绑定异常'], ['structure', '分镜结构校验'],
|
||||
['action', '动作质量阻断'], ['pending', '待审核剧集'], ['workflow', '当前执行异常']
|
||||
] as const).map(([type, label]) => ({ type, label, items: props.quality?.problems.filter(item => item.type === type) ?? [] })).filter(group => group.items.length))
|
||||
/** 相同镜头的问题合并为一组,重复消息不重复显示。 */
|
||||
const groups = computed(() => {
|
||||
const result = new Map<string, BreakdownIssueGroup>()
|
||||
@@ -64,18 +72,36 @@ function finish() {
|
||||
|
||||
<template>
|
||||
<!-- 以下是全屏展示的拆解执行错误与分镜校验问题模块 -->
|
||||
<AppDrawer v-model:open="open" title="拆解问题" @closed="finish">
|
||||
<AppDrawer v-model:open="open" title="拆解问题" class="breakdown-issues-drawer" @closed="finish">
|
||||
<template #description
|
||||
><span v-if="count">{{ count }} 项校验问题 · {{ groups.length }} 个位置</span
|
||||
><span v-if="quality">{{ quality.isCandidate ? '当前候选' : quality.source === 'history' ? '历史结果(当前质量未确认)' : '当前正式结果' }} · 结构 {{ quality.structuralCount }} 项 · 动作 {{ quality.actionBlocks.length }} 镜</span
|
||||
><span v-else-if="count">{{ count }} 项校验问题 · {{ groups.length }} 个位置</span
|
||||
><span v-else>查看最近保存结果中的问题</span></template
|
||||
>
|
||||
<!-- 以下是当前版本的分类问题,历史错误不会混入当前问题数量 -->
|
||||
<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>
|
||||
<div v-else-if="quality.error" class="problem-surface p-5 space-y-3"><p class="text-sm break-words">{{ quality.error }}</p><NButton @click="emit('refresh')">重新读取审核</NButton></div>
|
||||
<template v-else>
|
||||
<section v-for="group in problemGroups" :key="group.type" class="space-y-3" :aria-label="group.label">
|
||||
<h3 class="text-sm font-medium">{{ group.label }} · {{ group.items.length }}</h3>
|
||||
<article v-for="item in group.items" :key="item.key" class="workspace-panel problem-surface space-y-3 break-words" :data-problem-type="item.type">
|
||||
<div v-if="item.location" class="flex flex-wrap items-center justify-between gap-3"><p class="text-sm">第 {{ item.location.episodeNo }} 集<span v-if="item.location.beatNo"> · 节拍 {{ item.location.beatNo }}</span><span v-if="item.location.shotNo"> · 镜头 {{ item.location.shotNo }}</span><span class="ml-3 text-xs text-muted">待处理</span></p><NButton v-if="locatable" text size="small" @click="locate(item.location)">{{ item.location.beatNo ? '定位分镜' : '查看本集' }}</NButton></div>
|
||||
<p class="text-sm leading-6">{{ item.message }}</p><p v-if="item.codes.length" class="text-xs text-muted break-all">阻断代码:{{ item.codes.join('、') }}</p>
|
||||
</article>
|
||||
</section>
|
||||
<p v-if="!quality.issueCount && !workflowError" class="text-sm text-muted">当前版本没有待处理的质量问题。</p>
|
||||
<!-- 以下是使用 Naive 折叠组件的历史记录,默认收起且不计入当前问题 -->
|
||||
<NCollapse v-if="quality.historyIssues.length" class="text-xs text-muted" data-history-issues><NCollapseItem name="history" :title="`历史审核记录 · ${quality.historyIssues.length} 项(不计入当前问题)`"><p v-for="(item, index) in quality.historyIssues" :key="index" class="mt-3 break-words">第 {{ item.episodeNo }} 集 · {{ item.message }}</p></NCollapseItem></NCollapse>
|
||||
</template>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<section v-if="workflowError" class="workspace-panel problem-surface space-y-3" aria-label="执行异常">
|
||||
<h3 class="text-sm font-medium">执行异常</h3>
|
||||
<p class="whitespace-pre-wrap break-words text-sm leading-6">{{ workflowError }}</p>
|
||||
</section>
|
||||
<article
|
||||
v-for="group in groups"
|
||||
v-for="group in quality ? [] : groups"
|
||||
:key="group.key"
|
||||
class="workspace-panel problem-surface breakdown-issue-group space-y-3"
|
||||
>
|
||||
@@ -93,7 +119,7 @@ function finish() {
|
||||
{{ message }}
|
||||
</p>
|
||||
</article>
|
||||
<p v-if="!groups.length && !workflowError" class="py-5 text-sm text-muted">
|
||||
<p v-if="!quality && !groups.length && !workflowError" class="py-5 text-sm text-muted">
|
||||
当前没有具体错误描述,可读取修复清单确认待处理镜头。
|
||||
</p>
|
||||
</div>
|
||||
@@ -103,3 +129,10 @@ function finish() {
|
||||
<template #footer><NButton type="default" @click="open = false">关闭</NButton></template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 问题正文可滚动,滚动轨道隐藏;公共抽屉继续固定标题与底部关闭操作。 */
|
||||
.breakdown-issues-drawer .n-scrollbar-rail {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,192 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NCheckbox, NFormItem, NInput, NSelect } from 'naive-ui'
|
||||
import { WorkspaceSectionHeading } from '../../../components/ui'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { getOperation, isOperationRunning, runOperation } from '../../workflows/operations'
|
||||
import { breakdownApi } from '../api'
|
||||
import type { BreakdownState } from '../types'
|
||||
import type { CandidateActionRepair, CandidateRevalidation, CandidateShotLocation } from '../candidate.types'
|
||||
|
||||
/** 人工编辑的动作描述与原始动作对照,禁止编辑 kind。 */
|
||||
interface ActionDraft extends CandidateActionRepair {
|
||||
/** 稳定选择键。 */
|
||||
key: string
|
||||
/** 用户是否选择此动作。 */
|
||||
selected: boolean
|
||||
/** 原始描述,只读保留。 */
|
||||
original: string
|
||||
/** 原始镜头标题。 */
|
||||
title: string
|
||||
/** 对应阶段是否包含并行动作。 */
|
||||
parallel: boolean
|
||||
}
|
||||
|
||||
/** 全部修复仅针对尚未提交的当前候选。 */
|
||||
const props = defineProps<{
|
||||
/** 当前项目。 */
|
||||
projectId: string
|
||||
/** 当前原始检查点。 */
|
||||
checkpointId: string
|
||||
/** 当前同版本的主体、形态与镜头。 */
|
||||
state: BreakdownState
|
||||
/** 服务端真实审核结果。 */
|
||||
review: CandidateRevalidation | null
|
||||
/** 活动任务、读取错误或审核中时禁用。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 修复成功后要求父级重读检查点与审核,不修改本地候选伪造成功。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 项目写锁与统一消息反馈。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 必须匹配当前检查点与项目的审核。 */
|
||||
const review = computed(() => props.review?.checkpointId === props.checkpointId && props.review.projectId === props.projectId ? props.review : null)
|
||||
/** 只有明确候选且没有活动操作才允许修订。 */
|
||||
const writable = computed(() => !!review.value && props.state.candidateOnly === true && !props.state.storyboardPersisted && !props.state.candidateCommitted && !props.disabled && !operation.value.pending)
|
||||
/** 已选择的镜头坐标键。 */
|
||||
const targetKey = ref('')
|
||||
/** 从真实主体选项中选择的引用。 */
|
||||
const subjectRef = ref('')
|
||||
/** 从所选主体已有形态中选择的编号。 */
|
||||
const formId = ref('')
|
||||
/** 多镜头动作草稿,失败后保留。 */
|
||||
const actionDrafts = ref<ActionDraft[]>([])
|
||||
/** 草稿所属版本,审核同版本刷新不清空人工编辑。 */
|
||||
let draftVersion = ''
|
||||
|
||||
/**
|
||||
* 为同镜头的缺失引用合并操作目标。
|
||||
* @param location 原始镜头坐标
|
||||
* @returns 稳定位置键
|
||||
*/
|
||||
function positionKey(location: CandidateShotLocation) {
|
||||
return `${location.episodeNo}/${location.beatNo}/${location.shotNo}`
|
||||
}
|
||||
/** 只展示接口确实支持补齐的缺失引用,已有绑定不会伪装成可修复。 */
|
||||
const targets = computed(() => {
|
||||
const values = new Map<string, CandidateShotLocation & { refs: string[] }>()
|
||||
const add = (location: CandidateShotLocation, subjectReference: string) => {
|
||||
if (!props.state.subjectCandidates?.some(subject => subject.ref === subjectReference)) return
|
||||
const shot = props.state.storyboardEpisodeShots?.find(item => item.episodeNo === location.episodeNo)?.beatShots.find(item => item.beatNo === location.beatNo)?.shots.find(item => item.shotNo === location.shotNo)
|
||||
if (!shot || shot.subjectRefs.includes(subjectReference) || shot.subjectBindings?.some(item => item.subjectRef === subjectReference)) return
|
||||
const key = positionKey(location)
|
||||
const value = values.get(key) ?? { ...location, refs: [] }
|
||||
if (!value.refs.includes(subjectReference)) value.refs.push(subjectReference)
|
||||
values.set(key, value)
|
||||
}
|
||||
for (const item of review.value?.missingSubjectRefs ?? []) {
|
||||
if (item.beatNo && item.shotNo && item.subject) add({ episodeNo: item.episodeNo, beatNo: item.beatNo, shotNo: item.shotNo }, item.subject.ref)
|
||||
}
|
||||
for (const item of review.value?.propReferenceDiagnostics ?? []) {
|
||||
if (!item.shotHasSubject && !item.shotHasBinding) add(item, item.subjectRef)
|
||||
}
|
||||
return [...values.values()]
|
||||
})
|
||||
/** 当前镜头的可信缺失引用选项。 */
|
||||
const target = computed(() => targets.value.find(item => positionKey(item) === targetKey.value))
|
||||
/** 主体只取当前候选,禁止任意输入。 */
|
||||
const subjectOptions = computed(() => (props.state.subjectCandidates ?? []).filter(item => target.value?.refs.includes(item.ref)).map(item => ({ label: `${item.name}(${item.ref})`, value: item.ref })))
|
||||
/** 形态严格按真实主体 profileId 过滤。 */
|
||||
const formOptions = computed(() => {
|
||||
const subject = props.state.subjectCandidates?.find(item => item.ref === subjectRef.value)
|
||||
return (props.state.subjectForms ?? []).filter(item => item.profileId === subject?.profileId).map(item => ({ label: item.formName || item.name, value: item.formId }))
|
||||
})
|
||||
/** 可提交主体目标,切换任何字段后都会撤销先前确认。 */
|
||||
const subjectReady = computed(() => writable.value && !!target.value && subjectOptions.value.some(item => item.value === subjectRef.value) && formOptions.value.some(item => item.value === formId.value))
|
||||
/** 多镜头修复摘要只取用户选择的真实动作。 */
|
||||
const repairs = computed(() => actionDrafts.value.filter(item => item.selected).map(({ episodeNo, beatNo, shotNo, actionId, description }) => ({ episodeNo, beatNo, shotNo, actionId, description: description.trim() })))
|
||||
/** 每个选中动作都必须提供非空的、经过人工改写的过程描述。 */
|
||||
const actionReady = computed(() => writable.value && repairs.value.length > 0 && actionDrafts.value.filter(item => item.selected).every(item => !!item.description.trim() && item.description.trim() !== item.original.trim()))
|
||||
/** 主体修复的最终确认摘要。 */
|
||||
const subjectSummary = computed(() => `只更新候选检查点,不修改正式资产。目标:${targetKey.value};主体:${subjectRef.value};形态:${formOptions.value.find(item => item.value === formId.value)?.label ?? ''}。`)
|
||||
/** 批量修复的最终确认摘要,描述变化后必须重新确认。 */
|
||||
const actionSummary = computed(() => `只更新候选,不调用模型。共 ${repairs.value.length} 个动作:${repairs.value.map(item => `${positionKey(item)} · ${item.actionId}:${item.description}`).join(';')}`)
|
||||
|
||||
watch(targetKey, () => { subjectRef.value = ''; formId.value = '' })
|
||||
watch(subjectRef, () => { formId.value = '' })
|
||||
watch([() => props.projectId, () => props.checkpointId, review], () => {
|
||||
const version = `${props.projectId}:${props.checkpointId}`
|
||||
if (version !== draftVersion) {
|
||||
draftVersion = version
|
||||
targetKey.value = ''
|
||||
subjectRef.value = ''
|
||||
formId.value = ''
|
||||
actionDrafts.value = []
|
||||
}
|
||||
if (!review.value || actionDrafts.value.length) return
|
||||
actionDrafts.value = review.value.actionRepairTargets.flatMap(item => {
|
||||
if (!item.blockingCodes.includes('state_used_as_action_phase') || !item.shot) return []
|
||||
const shot = item.shot
|
||||
return shot.requiredActions.filter(action => action.kind === 'state' && shot.durationPlanning?.phases.some(phase => phase.actionIds?.includes(action.id))).map(action => ({
|
||||
episodeNo: item.episodeNo, beatNo: item.beatNo, shotNo: item.shotNo,
|
||||
key: `${positionKey(item)}/${action.id}`, actionId: action.id, selected: false,
|
||||
description: '', original: action.description, title: shot.title,
|
||||
parallel: shot.durationPlanning?.phases.some(phase => phase.actionIds?.includes(action.id) && phase.actionIds.length > 1) ?? false
|
||||
}))
|
||||
})
|
||||
}, { immediate: true })
|
||||
|
||||
/** 用户确认后提交单镜头主体补齐,成功后重读真实新版本。 */
|
||||
async function repairSubject() {
|
||||
if (!subjectReady.value || !target.value) return
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
const input = { expectedCheckpointId: checkpointId, episodeNo: target.value.episodeNo, beatNo: target.value.beatNo, shotNo: target.value.shotNo, subjectRef: subjectRef.value, formId: formId.value }
|
||||
const ok = await runOperation(id, '修复候选主体引用', async () => {
|
||||
const receipt = await breakdownApi.repairCandidateSubject(id, input)
|
||||
if (!receipt.checkpointId || receipt.checkpointId === checkpointId) throw new Error('未确认候选新版本,请刷新审核后核对。')
|
||||
return receipt
|
||||
}, { type: 'success', content: '候选引用已修订,正在重新读取审核结果。' })
|
||||
if (ok && props.projectId === id) emit('refresh')
|
||||
}
|
||||
|
||||
/** 用户确认所选动作的真实过程描述后批量写入,失败保留草稿。 */
|
||||
async function repairActions() {
|
||||
if (!actionReady.value) return
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
const input = { expectedCheckpointId: checkpointId, repairs: structuredClone(repairs.value) }
|
||||
const ok = await runOperation(id, '批量修复候选动作', async () => {
|
||||
const receipt = await breakdownApi.repairCandidateActions(id, input)
|
||||
if (!receipt.checkpointId || receipt.checkpointId === checkpointId) throw new Error('未确认候选新版本,请刷新审核后核对。')
|
||||
return receipt
|
||||
}, { type: 'success', content: '候选动作已修订,正在重新读取审核结果。' })
|
||||
if (ok && props.projectId === id) emit('refresh')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是仅针对候选的主体与形态补齐模块 -->
|
||||
<section v-if="targets.length" class="workspace-panel space-y-4" aria-label="候选主体修复">
|
||||
<WorkspaceSectionHeading title="补齐候选主体引用" description="选择当前缺失引用及该主体已有形态,确认后保存为新的候选版本。" />
|
||||
<div class="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
||||
<NFormItem label="目标镜头"><NSelect v-model:value="targetKey" aria-label="主体修复目标镜头" :disabled="!writable" :options="targets.map(item => ({ label: `第 ${item.episodeNo} 集 · 节拍 ${item.beatNo} · 镜头 ${item.shotNo}`, value: positionKey(item) }))" /></NFormItem>
|
||||
<NFormItem label="候选主体"><NSelect v-model:value="subjectRef" aria-label="待补齐候选主体" :disabled="!writable || !target" :options="subjectOptions" /></NFormItem>
|
||||
<NFormItem label="已有形态"><NSelect v-model:value="formId" aria-label="候选主体已有形态" :disabled="!writable || !subjectRef" :options="formOptions" /></NFormItem>
|
||||
</div>
|
||||
<ConfirmAction :key="`${checkpointId}:${subjectSummary}`" label="修复候选主体引用" :description="subjectSummary" :disabled="!subjectReady" :loading="isOperationRunning(operation, '修复候选主体引用')" @confirm="repairSubject" />
|
||||
</section>
|
||||
<!-- 以下是动作质量阻断的批量语义修订模块,不提供 kind 修改或自动修复 -->
|
||||
<section v-if="review?.actionQualityBlocks.length" class="workspace-panel space-y-4" aria-label="候选批量动作修复">
|
||||
<WorkspaceSectionHeading title="批量修订候选动作" description="仅展示当前阻断镜头。逐项选择并填写可观察的动作过程,提交前核对修复摘要。" />
|
||||
<p v-if="!actionDrafts.length" class="text-xs text-muted">当前阻断不属于批量接口支持的结果状态引用问题,无法在此自动修订。</p>
|
||||
<article v-for="draft in actionDrafts" :key="draft.key" class="candidate-action-draft space-y-3 p-4" :data-action-id="draft.actionId">
|
||||
<NCheckbox v-model:checked="draft.selected" :disabled="!writable">第 {{ draft.episodeNo }} 集 · 节拍 {{ draft.beatNo }} · 镜头 {{ draft.shotNo }} · {{ draft.title }} · {{ draft.actionId }}</NCheckbox>
|
||||
<p class="text-xs leading-6 text-muted">原始状态:{{ draft.original }}</p>
|
||||
<p v-if="draft.parallel" class="text-xs text-danger">该动作处于并行阶段,后端可能拒绝覆盖,需核对同阶段其他动作。</p>
|
||||
<NInput v-model:value="draft.description" type="textarea" :disabled="!writable || !draft.selected" :input-props="{ 'aria-label': `动作 ${draft.key} 修订描述` }" placeholder="请人工填写动作如何发生,不能只把结果状态改名" :autosize="{ minRows: 3, maxRows: 8 }" />
|
||||
</article>
|
||||
<p v-if="repairs.length" class="text-xs leading-6 text-muted break-words" aria-label="批量修复摘要">{{ actionSummary }}</p>
|
||||
<ConfirmAction v-if="actionDrafts.length" :key="`${checkpointId}:${actionSummary}`" label="批量修复候选动作" :description="actionSummary" :disabled="!actionReady" :loading="isOperationRunning(operation, '批量修复候选动作')" @confirm="repairActions" />
|
||||
</section>
|
||||
<p v-if="operation.error && ['修复候选主体引用', '批量修复候选动作'].includes(operation.label)" role="alert" class="text-xs text-danger break-words">{{ operation.error }}</p>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 修订草稿只作轻量分组,窄屏控件自然换行且不产生横向滚动。 */
|
||||
.candidate-action-draft {
|
||||
min-width: 0;
|
||||
background: var(--app-subtle);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,182 @@
|
||||
import type { BreakdownResult, BreakdownState, ShotValidation } from './types'
|
||||
import type { CandidateActionBlock, CandidateRevalidation } from './candidate.types'
|
||||
import type { Checkpoint } from '../workflows/types'
|
||||
import { candidateCommitIssue } from './candidate'
|
||||
|
||||
/** 明确区分当前候选、已提交正式结果和仅供回看的历史快照。 */
|
||||
export interface BreakdownSource {
|
||||
/** 当前数据来源。 */
|
||||
kind: 'candidate' | 'formal' | 'history' | 'empty'
|
||||
/** 当前原始检查点。 */
|
||||
checkpoint?: Checkpoint
|
||||
/** 同一检查点归一化后的结果,禁止跨版本拼装资产。 */
|
||||
state: BreakdownState | null
|
||||
/** 另外保存的正式结果,绝不拿候选冒充正式数据。 */
|
||||
formal?: Checkpoint
|
||||
}
|
||||
|
||||
/** 带类型、位置和状态的问题行。 */
|
||||
export interface BreakdownProblem {
|
||||
/** 去重标识。 */
|
||||
key: string
|
||||
/** 问题分类。 */
|
||||
type: 'structure' | 'subject' | 'binding' | 'action' | 'pending' | 'workflow'
|
||||
/** 后端位置,缺失时不提供镜头定位。 */
|
||||
location?: ShotValidation['issues'][number]
|
||||
/** 原始描述。 */
|
||||
message: string
|
||||
/** 原始阻断代码。 */
|
||||
codes: string[]
|
||||
}
|
||||
|
||||
/** 全页面共用的质量状态,审核通过不代表允许提交。 */
|
||||
export interface BreakdownQuality {
|
||||
/** 当前数据来源。 */
|
||||
source: BreakdownSource['kind']
|
||||
/** 当前版本。 */
|
||||
checkpointId?: string
|
||||
/** 是否仍为未提交候选。 */
|
||||
isCandidate: boolean
|
||||
/** 是否有明确提交标记。 */
|
||||
committed: boolean
|
||||
/** 结构校验,null 表示尚未确认。 */
|
||||
structureValid: boolean | null
|
||||
/** 动作审核结果。 */
|
||||
actionStatus: 'passed' | 'blocked' | 'unknown'
|
||||
/** 当前结构问题。 */
|
||||
structuralIssues: ShotValidation['issues']
|
||||
/** 含完整性与形态绑定的结构问题总数。 */
|
||||
structuralCount: number
|
||||
/** 当前动作阻断,不计入结构问题数量。 */
|
||||
actionBlocks: CandidateActionBlock[]
|
||||
/** 当前待处理剧集。 */
|
||||
pendingEpisodeNos: number[]
|
||||
/** 统一的问题行。 */
|
||||
problems: BreakdownProblem[]
|
||||
/** 历史结构问题,默认不参与当前提示。 */
|
||||
historyIssues: ShotValidation['issues']
|
||||
/** 当前可见问题数。 */
|
||||
issueCount: number
|
||||
/** 只允许进入安全预检查,不能据此提交。 */
|
||||
canRequestCommitPreview: boolean
|
||||
/** 需要重新读取审核,失败和过期均不判为通过。 */
|
||||
needsRefresh: boolean
|
||||
/** 审核正在读取。 */
|
||||
loading: boolean
|
||||
/** 当前读取失败或版本不符原因。 */
|
||||
error: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一版本的顶层修复字段优先,兼容早期仅存于 breakdownResult 的结果。
|
||||
* @param state 服务端原始检查点
|
||||
* @returns 不修改原对象的统一成果快照
|
||||
*/
|
||||
export function normalizeBreakdownState(state: BreakdownState): BreakdownState {
|
||||
// 新版候选只信任顶层;旧版无候选标记的快照才兼容嵌套成果。
|
||||
const result: BreakdownResult = state.candidateOnly === true ? {} : { ...state.breakdownResult }
|
||||
for (const key of ['subjectCandidates', 'subjectForms', 'storyboardPlans', 'storyboardEpisodeShots', 'storyboardShotValidation', 'storyboardNeedsManualReview'] as const) {
|
||||
if (state[key] !== undefined) Object.assign(result, { [key]: state[key] })
|
||||
}
|
||||
if (result.storyboardEpisodeShots?.length) {
|
||||
// 主体修复可能只更新镜头内的 episodePlan,保留未完成剧集并替换已更新规划。
|
||||
const plans = new Map(result.storyboardPlans?.map(plan => [plan.episodeNo, plan]))
|
||||
for (const episode of result.storyboardEpisodeShots) plans.set(episode.episodeNo, episode.episodePlan)
|
||||
result.storyboardPlans = [...plans.values()].toSorted((a, b) => a.episodeNo - b.episodeNo)
|
||||
}
|
||||
return { ...state, ...result, breakdownResult: result }
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断检查点是否含真实成果,而不是只有失败执行信息。
|
||||
* @param record 原始检查点
|
||||
* @returns 是否含可回看的资产内容
|
||||
*/
|
||||
function hasBreakdownData(record: Checkpoint): boolean {
|
||||
return Boolean(record.state.breakdownResult || record.state.subjectCandidates || record.state.storyboardEpisodeShots || record.state.storyboardPlans)
|
||||
}
|
||||
|
||||
/**
|
||||
* 按检查点生命周期选择当前来源,失败空快照只能回看历史,不继承历史质量。
|
||||
* @param records 已按创建时间排列的拆解检查点
|
||||
* @returns 当前与正式快照分别存放的数据来源
|
||||
*/
|
||||
export function selectBreakdownSource(records: Checkpoint[]): BreakdownSource {
|
||||
const latest = records.at(-1)
|
||||
if (!latest) return { kind: 'empty', state: null }
|
||||
const formal = records.toReversed().find(record => hasBreakdownData(record) && (record.state.storyboardPersisted === true || record.state.candidateCommitted === true || record.state.candidateOnly !== true))
|
||||
if (latest.state.candidateOnly === true || hasBreakdownData(latest) || latest.state.runConfig) {
|
||||
const state = normalizeBreakdownState(latest.state)
|
||||
return { checkpoint: latest, state, formal, kind: state.storyboardPersisted === true || state.candidateCommitted === true || state.candidateOnly !== true ? 'formal' : 'candidate' }
|
||||
}
|
||||
const previous = records.toReversed().find(hasBreakdownData)
|
||||
return { kind: previous ? 'history' : 'empty', checkpoint: previous, state: previous ? normalizeBreakdownState(previous.state) : null, formal }
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证审核结果的项目和检查点归属,拒绝过期响应。
|
||||
* @param review 后端只读审核响应
|
||||
* @param projectId 当前项目
|
||||
* @param checkpointId 当前候选版本
|
||||
* @returns 原始有效审核结果
|
||||
*/
|
||||
export function assertCandidateReview(review: CandidateRevalidation, projectId: string, checkpointId: string): CandidateRevalidation {
|
||||
if (!review || review.projectId !== projectId || review.checkpointId !== checkpointId)
|
||||
throw new Error('候选审核版本已过期,请刷新候选状态。')
|
||||
const arrayKeys = ['previousIssues', 'currentIssues', 'missingSubjectRefs', 'actionQualityBlocks', 'actionRepairTargets', 'pendingQualityEpisodeNos', 'propReferenceDiagnostics', 'pendingWithoutActionBlocks'] as const
|
||||
if (!review.candidateValidation || typeof review.candidateValidation.valid !== 'boolean' || !Array.isArray(review.candidateValidation.issues) || !arrayKeys.every(key => Array.isArray(review[key])))
|
||||
throw new Error('候选审核响应不完整,请刷新候选状态。')
|
||||
return review
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总当前版本的结构、动作与待审状态,不把历史错误当作当前问题。
|
||||
* @param source 当前数据来源
|
||||
* @param review 与当前版本匹配的候选审核
|
||||
* @param loading 是否正在读取候选审核
|
||||
* @param error 读取失败或版本过期原因
|
||||
* @returns 页面、问题抽屉与提交面板共享的质量状态
|
||||
*/
|
||||
export function breakdownQuality(source: BreakdownSource, review: CandidateRevalidation | null, loading = false, error = ''): BreakdownQuality {
|
||||
const candidate = source.kind === 'candidate'
|
||||
const current = candidate && review?.checkpointId === source.checkpoint?.checkpointId ? review : null
|
||||
const known = candidate ? !!current && !loading && !error : source.kind === 'formal'
|
||||
const structuralIssues = known ? candidate ? current!.currentIssues : source.state?.storyboardShotValidation?.issues ?? [] : []
|
||||
const validation = known ? candidate ? current!.currentIssues.length === 0 : source.state?.storyboardShotValidation?.valid ?? null : null
|
||||
const actionBlocks = known ? candidate ? current!.actionQualityBlocks : (source.state?.storyboardActionQualityDecisions ?? []).filter(item => item.status === 'blocked' || item.warningCodes.includes('action_resource_conflict')).map(item => ({ ...item, isPendingEpisode: true })) : []
|
||||
const pendingEpisodeNos = known ? candidate ? current!.pendingQualityEpisodeNos : source.state?.storyboardPendingQualityEpisodeNos ?? [] : []
|
||||
const problems: BreakdownProblem[] = structuralIssues.map((item, index) => ({
|
||||
key: `structure-${item.episodeNo}-${item.beatNo}-${item.shotNo}-${index}`,
|
||||
type: item.message.includes('主体引用缺失') ? 'subject' : /绑定|形态|Form/.test(item.message) ? 'binding' : 'structure',
|
||||
location: item,
|
||||
message: item.message,
|
||||
codes: []
|
||||
}))
|
||||
for (const block of actionBlocks) problems.push({ key: `action-${block.episodeNo}-${block.beatNo}-${block.shotNo}`, type: 'action', location: { ...block, message: '动作质量待修订' }, message: '当前动作规划仍有阻断或资源冲突。', codes: [...new Set([...block.blockingCodes, ...block.warningCodes])] })
|
||||
for (const episodeNo of pendingEpisodeNos.filter(no => !actionBlocks.some(item => item.episodeNo === no))) problems.push({ key: `pending-${episodeNo}`, type: 'pending', location: { episodeNo, message: '剧集仍标记为待审核' }, message: '该集仍标记为待审核,当前没有动作阻断明细,请重新核对审核状态。', codes: [] })
|
||||
if (current && known) {
|
||||
for (const diagnostic of current.propReferenceDiagnostics) {
|
||||
if (diagnostic.beatAllowsSubject && diagnostic.shotHasSubject && diagnostic.shotHasBinding) continue
|
||||
if (problems.some(item => item.location?.episodeNo === diagnostic.episodeNo && item.location.beatNo === diagnostic.beatNo && item.location.shotNo === diagnostic.shotNo && item.message.includes(diagnostic.subjectRef))) continue
|
||||
problems.push({ key: `prop-${diagnostic.episodeNo}-${diagnostic.beatNo}-${diagnostic.shotNo}-${diagnostic.subjectRef}`, type: 'subject', location: { ...diagnostic, message: '道具引用或形态绑定缺失' }, message: `道具 ${diagnostic.subjectName}(${diagnostic.subjectRef})的节拍引用、镜头引用或形态绑定不完整。`, codes: [] })
|
||||
}
|
||||
for (const [index, message] of current.candidateValidation.issues.entries()) {
|
||||
if (message === 'Storyboard 质量审核未通过' && structuralIssues.length || message === '仍存在待处理的分镜质量问题' && pendingEpisodeNos.length) continue
|
||||
problems.push({ key: `candidate-${index}`, type: /Form|形态|绑定/.test(message) ? 'binding' : 'structure', message, codes: [] })
|
||||
}
|
||||
}
|
||||
if (known && ((validation === false && !problems.some(item => ['structure', 'subject', 'binding'].includes(item.type))) || (current?.candidateValidation.valid === false && !problems.length))) {
|
||||
problems.push({ key: 'validation-unknown', type: 'structure', message: '当前版本校验未通过,服务端未提供具体结构问题,请重新读取审核。', codes: [] })
|
||||
}
|
||||
const structuralCount = problems.filter(item => ['structure', 'subject', 'binding'].includes(item.type)).length
|
||||
const structureValid = validation === null ? null : validation && structuralCount === 0
|
||||
return {
|
||||
source: source.kind, checkpointId: source.checkpoint?.checkpointId, isCandidate: candidate,
|
||||
committed: source.state?.storyboardPersisted === true || source.state?.candidateCommitted === true,
|
||||
structureValid, actionStatus: known ? actionBlocks.length || pendingEpisodeNos.length ? 'blocked' : 'passed' : 'unknown',
|
||||
structuralIssues, structuralCount, actionBlocks, pendingEpisodeNos, problems,
|
||||
historyIssues: current?.previousIssues ?? [], issueCount: problems.length,
|
||||
canRequestCommitPreview: candidate && known && current!.candidateValidation.valid && structureValid === true && !problems.length && !candidateCommitIssue({ ...source.state, workflowExecution: undefined, storyboardShotValidation: { valid: true, issues: [] }, storyboardPendingQualityEpisodeNos: pendingEpisodeNos }),
|
||||
needsRefresh: candidate && (!known || !!error), loading: candidate && loading, error: candidate ? error : ''
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,10 @@ export interface WorkflowExecution {
|
||||
|
||||
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
|
||||
export interface BreakdownState extends BreakdownResult {
|
||||
/** 快照所属项目;旧版观测响应可能缺省。 */
|
||||
projectId?: string
|
||||
/** 当前镜头动作质量决策,不从嵌套历史成果继承。 */
|
||||
storyboardActionQualityDecisions?: Omit<import('./candidate.types').CandidateActionBlock, 'isPendingEpisode'>[]
|
||||
/** 后端候选模式标记,缺省时不推断为候选。 */
|
||||
candidateOnly?: boolean
|
||||
/** 最新快照是否已经写入正式主体与分镜。 */
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { computed, onScopeDispose, ref, watch, type Ref } from 'vue'
|
||||
import { workflowCheckpoints } from '../workflows/selectors'
|
||||
import type { Checkpoint } from '../workflows/types'
|
||||
import type { CandidateRevalidation } from './candidate.types'
|
||||
import { breakdownApi } from './api'
|
||||
import { assertCandidateReview, breakdownQuality, selectBreakdownSource } from './quality'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { showActionFeedback, useActionMessage } from '../../components/ui/useActionMessage'
|
||||
|
||||
/**
|
||||
* 观察候选版本并去重读取只读审核,不设置任何轮询。
|
||||
* @param projectId 当前项目
|
||||
* @param checkpoints 服务端检查点列表
|
||||
* @returns 统一数据源、审核状态及显式刷新入口
|
||||
*/
|
||||
export function useBreakdownQuality(projectId: Ref<string>, checkpoints: Ref<Checkpoint[]>) {
|
||||
/** 当前生命周期与正式数据分别选择。 */
|
||||
const source = computed(() => selectBreakdownSource(workflowCheckpoints(checkpoints.value, 'breakdown')))
|
||||
/** 审核请求只绑定尚未提交的候选及其项目。 */
|
||||
const key = computed(() => source.value.kind === 'candidate' ? `${projectId.value}:${source.value.checkpoint?.checkpointId}` : '')
|
||||
/** 仅存放当前版本已验证的审核。 */
|
||||
const review = ref<CandidateRevalidation | null>(null)
|
||||
/** 审核区域的独立加载状态。 */
|
||||
const loading = ref(false)
|
||||
/** 审核读取错误,失败不回退为历史通过状态。 */
|
||||
const error = ref('')
|
||||
/** 应用统一消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 取消或版本变化时废弃旧请求。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 当前请求序号。 */
|
||||
let generation = 0
|
||||
/** 相同版本的并发读取共用一个 Promise。 */
|
||||
let pending: Promise<void> | null = null
|
||||
|
||||
/** 显式重新审核当前候选,同一版本进行中的请求不重复发送。 */
|
||||
function refresh(): Promise<void> {
|
||||
if (!key.value) return Promise.resolve()
|
||||
if (pending) return pending
|
||||
const id = projectId.value
|
||||
const checkpointId = source.value.checkpoint!.checkpointId
|
||||
const version = ++generation
|
||||
controller = new AbortController()
|
||||
const signal = controller.signal
|
||||
review.value = null
|
||||
error.value = ''
|
||||
loading.value = true
|
||||
pending = (async () => {
|
||||
try {
|
||||
const result = await breakdownApi.revalidateCandidate(id, signal)
|
||||
if (version !== generation || signal.aborted) return
|
||||
review.value = assertCandidateReview(result, id, checkpointId)
|
||||
} catch (cause) {
|
||||
if (version === generation && !signal.aborted) {
|
||||
error.value = errorMessage(cause)
|
||||
showActionFeedback(message, error.value, 'error')
|
||||
}
|
||||
} finally {
|
||||
if (version === generation) { loading.value = false; pending = null }
|
||||
}
|
||||
})()
|
||||
return pending
|
||||
}
|
||||
/** 撤销旧版本,切换项目、提交完成和卸载都不得回填旧审核。 */
|
||||
function invalidate() {
|
||||
generation++
|
||||
controller?.abort()
|
||||
pending = null
|
||||
review.value = null
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
}
|
||||
watch(key, () => { invalidate(); void refresh() }, { immediate: true, flush: 'sync' })
|
||||
onScopeDispose(invalidate)
|
||||
/** 页面、问题与提交面板共用一个结论。 */
|
||||
const quality = computed(() => breakdownQuality(source.value, review.value, loading.value, error.value))
|
||||
return { source, key, review, loading, error, quality, refresh }
|
||||
}
|
||||
@@ -153,10 +153,11 @@ const confirmationDescription = computed(
|
||||
@dismiss="execution.dismiss"
|
||||
/>
|
||||
<!-- 以下是失败任务真实结果详情模块。 -->
|
||||
<details v-if="failedResult" class="mt-3 text-xs">
|
||||
<summary>失败任务结果详情</summary>
|
||||
<NCollapse v-if="failedResult" class="mt-3 text-xs">
|
||||
<NCollapseItem name="failed-result" title="失败任务结果详情">
|
||||
<pre class="mt-2 whitespace-pre-wrap break-all">{{ JSON.stringify(failedResult, null, 2) }}</pre>
|
||||
</details>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<FeedbackMessage v-if="error" :message="error" />
|
||||
<ContextNotice
|
||||
v-if="operation.label === '高级串联生产' && operation.error"
|
||||
|
||||
@@ -4,7 +4,7 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NInput } from 'naive-ui'
|
||||
import { NButton, NCollapse, NCollapseItem, NInput } from 'naive-ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
@@ -217,10 +217,12 @@ const records = computed(() =>
|
||||
{{ issue.description }}
|
||||
</p>
|
||||
</template>
|
||||
<details class="mt-2">
|
||||
<summary class="cursor-pointer text-muted">原始记录</summary>
|
||||
<!-- 以下是原始校验结果的 Naive 折叠模块 -->
|
||||
<NCollapse class="mt-2 text-muted">
|
||||
<NCollapseItem name="raw-record" title="原始记录">
|
||||
<pre class="whitespace-pre-wrap wrap-anywhere">{{ JSON.stringify(record.output, null, 2) }}</pre>
|
||||
</details>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</article>
|
||||
</ReadonlyInspection>
|
||||
</template>
|
||||
@@ -6,7 +6,7 @@ import { usePolling } from '../../composables/usePolling'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { currentEpisodeSource, getStoryboardSession, mergeDesignedShots } from '../storyboard/model'
|
||||
import { storyboardApi } from '../storyboard/api'
|
||||
import { breakdownSnapshot } from '../workflows/selectors'
|
||||
import { formalBreakdownSnapshot } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { productionApi } from './api'
|
||||
@@ -42,8 +42,8 @@ export function useProduction() {
|
||||
const videoRepairAttempts = ref<number | null>(2)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const videoInputMode = ref<VideoInputMode | 'all'>('all')
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const snapshot = computed(() => breakdownSnapshot(context.checkpoints.value))
|
||||
/** 生产页只关联正式镜头和正式正文,未提交候选不能补入当前资产。 */
|
||||
const snapshot = computed(() => formalBreakdownSnapshot(context.checkpoints.value))
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const sourceEpisodes = computed(
|
||||
() => snapshot.value?.storyboardEpisodeShots ?? snapshot.value?.breakdownResult?.storyboardEpisodeShots ?? []
|
||||
|
||||
@@ -96,16 +96,18 @@ export function currentEpisodeSource(projectId: string, episodeNo: number, fallb
|
||||
export function storyboardPrerequisites(checkpoints: Checkpoint[], episodeNo: number) {
|
||||
const latest = workflowCheckpoints(checkpoints, 'breakdown').at(-1)
|
||||
const state = latest?.state
|
||||
/** 候选只供阅读和修订,提交前不能充当正式制作输入。 */
|
||||
const uncommitted = state?.candidateOnly === true && state.storyboardPersisted !== true && state.candidateCommitted !== true
|
||||
const directionEpisodes = state?.breakdownResult?.storyboardEpisodeShots ?? []
|
||||
const visualEpisodes = state?.storyboardEpisodeShots ?? []
|
||||
return {
|
||||
directionEpisode: directionEpisodes.some(item => item.episodeNo === episodeNo),
|
||||
directionProject: directionEpisodes.length > 0,
|
||||
directionEpisode: !uncommitted && directionEpisodes.some(item => item.episodeNo === episodeNo),
|
||||
directionProject: !uncommitted && directionEpisodes.length > 0,
|
||||
visualEpisode:
|
||||
visualEpisodes.some(item => item.episodeNo === episodeNo) &&
|
||||
!uncommitted && visualEpisodes.some(item => item.episodeNo === episodeNo) &&
|
||||
!!state?.subjectCandidates?.length &&
|
||||
!!state?.subjectForms?.length,
|
||||
visualProject: visualEpisodes.length > 0 && !!state?.subjectCandidates?.length && !!state?.subjectForms?.length,
|
||||
visualProject: !uncommitted && visualEpisodes.length > 0 && !!state?.subjectCandidates?.length && !!state?.subjectForms?.length,
|
||||
breakdownRunning: state?.workflowExecution?.status === 'running'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { StoryboardBatchResult, PromptBatchResult, StoryboardShotRegenerati
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownSnapshot } from '../workflows/selectors'
|
||||
import { formalBreakdownSnapshot } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { storyboardApi } from './api'
|
||||
import {
|
||||
@@ -31,8 +31,8 @@ export function useStoryboard() {
|
||||
const maxRepairAttempts = ref(2)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const force = ref(false)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const snapshot = computed(() => breakdownSnapshot(context.checkpoints.value))
|
||||
/** 正式镜头查询只补充正式快照正文,不混入最新候选。 */
|
||||
const snapshot = computed(() => formalBreakdownSnapshot(context.checkpoints.value))
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const sourceEpisodes = computed(
|
||||
() => snapshot.value?.storyboardEpisodeShots ?? snapshot.value?.breakdownResult?.storyboardEpisodeShots ?? []
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NProgress, NTag } from 'naive-ui'
|
||||
import { NButton, NCollapse, NCollapseItem, NProgress, NTag } from 'naive-ui'
|
||||
import { LoaderCircle, X } from '@lucide/vue'
|
||||
import { formatDate } from '../../lib/format'
|
||||
import { executionPercentage, executionStageLabel } from './execution'
|
||||
@@ -345,8 +345,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
}}
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<details v-if="!breakdownTask" class="mt-3 text-[10px] text-muted">
|
||||
<summary class="cursor-pointer">任务详情</summary>
|
||||
<!-- 以下是非拆解任务的 Naive 详情折叠模块 -->
|
||||
<NCollapse v-if="!breakdownTask" class="mt-3 text-xs text-muted">
|
||||
<NCollapseItem name="task-details" title="任务详情">
|
||||
<p class="mt-2 break-all font-mono">任务编号 · {{ execution.id }}</p>
|
||||
<!-- 以下是逐镜已结束质量任务的持久化状态模块 -->
|
||||
<ul v-if="videoQuality && settledItems.length" class="mt-2 space-y-2">
|
||||
@@ -359,7 +360,8 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
· {{ executionStageLabel(item.status) }} · 视频 {{ item.videoId }}
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</template>
|
||||
<!-- 以下是运行期间已经终止的过期候选统计模块 -->
|
||||
<p
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BreakdownState } from '../breakdown/types'
|
||||
import type { Checkpoint } from './types'
|
||||
import { normalizeBreakdownState, selectBreakdownSource } from '../breakdown/quality'
|
||||
|
||||
/** 按工作流隔离并排序,后端数组顺序变化不会影响恢复判断。 */
|
||||
export function workflowCheckpoints(checkpoints: Checkpoint[], name: string): Checkpoint[] {
|
||||
@@ -19,7 +20,17 @@ export function breakdownSnapshot(checkpoints: Checkpoint[]): BreakdownState | n
|
||||
.toReversed()
|
||||
.find(item => item.state.runConfig || item.state.breakdownResult || item.state.storyboardPlans?.length)
|
||||
?.state ?? {}
|
||||
return { ...data, workflowExecution: latest.state.workflowExecution }
|
||||
return { ...normalizeBreakdownState(data), workflowExecution: latest.state.workflowExecution }
|
||||
}
|
||||
|
||||
/**
|
||||
* 正式工作区只消费已提交或兼容旧版的正式快照,不读取未提交候选正文。
|
||||
* @param checkpoints 项目检查点
|
||||
* @returns 单个正式版本的数据,缺失时不以候选补造
|
||||
*/
|
||||
export function formalBreakdownSnapshot(checkpoints: Checkpoint[]): BreakdownState | null {
|
||||
const formal = selectBreakdownSource(workflowCheckpoints(checkpoints, 'breakdown')).formal
|
||||
return formal ? normalizeBreakdownState(formal.state) : null
|
||||
}
|
||||
|
||||
/** 根据最近后端可恢复窗口推导操作;页面仍需先确认任务已经结束。 */
|
||||
|
||||
Reference in new issue
Block a user