Files
short-drama-agent-front/src/features/workflows/WorkflowExecutionPanel.vue
T

753 lines
40 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { visualStateTimeIssueLabel } from '../storyboard/visual-state-time'
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
import ConfirmAction from './ConfirmAction.vue'
import { useQuery } from '../../composables/useQuery'
import { workflowExecutionApi } from './execution-api'
import { userFacingText } from '../../lib/user-facing-text'
import ContextNotice from '../../components/ui/ContextNotice.vue'
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
import { computed } from 'vue'
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'
import type { WorkflowExecution } from './execution.types'
/** 后台任务面板的展示数据与加载状态。 */
const props = withDefaults(
defineProps<{
/** 任务标题。 */
title?: string
/** 后端任务记录。 */
execution: WorkflowExecution | null
/** 是否正在读取状态。 */
loading: boolean
/** 状态读取错误。 */
error: string
/** 是否展示运行、完成和错误详情;关闭后由调用方单独呈现问题。 */
showStatusHint?: boolean
/** 嵌入弹窗时使用扁平正文,标题、关闭及刷新操作由外层统一提供。 */
embedded?: boolean
/** 当前项目结果已更新时,旧创作任务只作为历史执行记录展示。 */
resultIsHistorical?: boolean
/** 当前观察器允许停止派生批次。 */
canStop?: boolean
/** 正在提交停止请求。 */
stopping?: boolean
/** 关联恢复历史只向原任务展开一层。 */
showRecoveryHistory?: boolean
}>(),
{ title: '制作任务', showStatusHint: true, embedded: false, resultIsHistorical: false, showRecoveryHistory: true }
)
/** 刷新状态与隐藏任务记录事件。 */
const emit = defineEmits<{ refresh: []; dismiss: []; stop: [] }>()
const percentage = computed(() => executionPercentage(props.execution?.current ?? 0, props.execution?.total ?? 0))
const result = computed(() => props.execution?.result ?? {})
/** 导演设计和画面状态的逐集结果独立于任务执行终态。 */
const derivedTask = computed(() =>
['storyboard-direction', 'storyboard-visual-state'].includes(props.execution?.workflowName ?? '')
)
/** 用户停止与质量失败分开表达。 */
const stopped = computed(
() => derivedTask.value && (props.execution?.stage === 'stopped' || result.value.stoppedByUser === true)
)
/** 只有明确零模型请求的恢复回执才展示免费复用。 */
const recovered = computed(
() =>
props.execution?.workflowName === 'storyboard-visual-state' &&
props.execution.status === 'completed' &&
typeof props.execution.metadata?.recoveryOf === 'string' &&
result.value.recovered === true &&
result.value.actualModelRequests === 0
)
/** 原失败执行的身份来自当前正式恢复记录,不由用户填写内部字段。 */
const recoveryKey = computed(() =>
props.showRecoveryHistory && props.execution && typeof props.execution.metadata?.recoveryOf === 'string'
? JSON.stringify([props.execution.projectId, props.execution.metadata.recoveryOf])
: ''
)
/** 免费读取原失败记录,原始错误和回执历史完整保留。 */
const originalExecution = useQuery(recoveryKey, async (key, signal) => {
if (!key) return null
const [projectId, executionId] = JSON.parse(key) as [string, string]
const record = await workflowExecutionApi.get(executionId, signal, projectId)
if (
!record ||
record.id !== executionId ||
record.projectId !== projectId ||
record.workflowName !== 'storyboard-visual-state'
)
throw new Error('原执行记录与恢复来源不一致。')
return record
})
/** 只统计正式领取状态,不将已收到结果等同质量通过。 */
const claims = computed(() => {
const rows = props.execution?.metadata?.claims
return Array.isArray(rows)
? rows.filter((row): row is Record<string, unknown> => !!row && typeof row === 'object' && !Array.isArray(row))
: []
})
/** 部分失败和人工核对标记不能显示为全部完成。 */
const derivedNeedsReview = computed(
() =>
derivedTask.value &&
(result.value.manualReviewRequired === true ||
Number(result.value.failedEpisodes) > 0 ||
Number(result.value.staleCount) > 0)
)
/** 逐集记录仅保留实际返回的集号、状态与业务原因。 */
const derivedEpisodes = computed(() => {
if (!derivedTask.value || !Array.isArray(result.value.episodes)) return []
return result.value.episodes.flatMap((item: unknown) => {
if (!item || typeof item !== 'object' || !('episodeNo' in item) || typeof item.episodeNo !== 'number') return []
return [
{
episodeNo: item.episodeNo,
status: 'status' in item && typeof item.status === 'string' ? item.status : '',
error: 'error' in item && typeof item.error === 'string' ? item.error : '',
issues:
'remainingIssues' in item && Array.isArray(item.remainingIssues)
? item.remainingIssues.filter(
(
issue
): issue is {
code?: string
severity?: 'error' | 'needs_review'
field?: string
episodeNo: number
beatNo: number | null
shotNo: number | null
message: string
} => !!issue && typeof issue === 'object' && typeof issue.message === 'string'
)
: []
}
]
})
})
/**
* 展示去重业务摘要,原完整记录仍保留在高级详情中。
* @param value 原业务错误
* @returns 可读且去重的原因
*/
function derivedErrorSummary(value: string) {
return [
...new Set(
userFacingText(value)
.split(/[;;]/)
.map(text => text.trim())
.filter(Boolean)
)
].join(';')
}
/** 只改变旧记录的展示语义,不改写原始任务或审核结果。 */
const historical = computed(
() => props.resultIsHistorical && ['completed', 'failed'].includes(props.execution?.status ?? '')
)
/** 动作诊断执行结束仅表示分析完成,不能套用素材生成的通过文案。 */
const diagnosisTask = computed(() => props.execution?.workflowName === 'storyboard-legacy-action-diagnosis')
/** 服务中断后必须由用户核对记录和费用,不根据未匹配数量自动重试。 */
const diagnosisRecovery = computed(
() => diagnosisTask.value && result.value.recoveryRequired === true && result.value.retryAutomatically === false
)
/**
* 恢复数量缺失时不补零,避免把未知范围描述为没有待核查镜头。
* @param name 服务返回的统计名称
* @returns 有效非负整数或未知
*/
function diagnosisCount(name: string): number | null {
const value = result.value[name]
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : null
}
/** 拆解任务的单位和结果文案与镜头素材任务分开。 */
const breakdownTask = computed(() => props.execution?.workflowName === 'breakdown')
/** 只采用后端明确返回的校验结果,缺失时保留待确认状态。 */
const breakdownValidation = computed<boolean | null>(() => {
const validation = result.value.storyboardShotValidation
if (!validation || typeof validation !== 'object' || !('valid' in validation)) return null
return typeof validation.valid === 'boolean' ? validation.valid : null
})
/** 执行完成不等于业务校验通过,明确保留待修复状态。 */
const breakdownInvalid = computed(() => breakdownTask.value && breakdownValidation.value === false)
/** 后端明确标记的人工审核或待审剧集不能使用成功底色。 */
const breakdownNeedsReview = computed(
() =>
result.value.storyboardNeedsManualReview === true ||
(Array.isArray(result.value.storyboardPendingQualityEpisodeNos) &&
result.value.storyboardPendingQualityEpisodeNos.length > 0)
)
/** 拆解卡片区分真实成功、待修复、运行中和结果待确认。 */
const breakdownState = computed<'success' | 'error' | 'running' | 'unknown'>(() => {
if (historical.value) return 'unknown'
if (props.error || props.execution?.status === 'failed') return 'error'
if (props.execution?.status === 'pending' || props.execution?.status === 'running') return 'running'
if (props.execution?.status !== 'completed') return 'unknown'
if (breakdownInvalid.value || breakdownNeedsReview.value) return 'error'
return breakdownValidation.value === true ? 'success' : 'unknown'
})
/** 后端提供的进度单位,避免把抽取完成误报为整个拆解完成。 */
const progressLabel = computed(() =>
props.execution?.metadata?.progressUnit === 'extraction_tasks'
? '抽取任务'
: props.execution?.metadata?.progressUnit === 'storyboard_episodes'
? '分镜剧集'
: '已处理'
)
/** 后端执行终态与业务审核结果共同决定可读状态。 */
const statusLabel = computed(() => {
const labels = { pending: '等待开始', running: '执行中', completed: '已完成', failed: '失败' }
if (!props.execution) return ''
if (stopped.value) return '已停止'
if (recovered.value) return '已免费复用原回执'
if (historical.value)
return breakdownTask.value && props.execution.status === 'failed' ? '历史执行记录 · 失败' : '历史执行记录'
if (derivedTask.value && ['completed', 'failed'].includes(props.execution.status))
return props.execution.status === 'failed' || derivedNeedsReview.value
? '执行结束 · 需核对部分结果'
: '执行结束 · 请核对覆盖情况'
if (scriptCreation.value && props.execution.status === 'completed') {
if (result.value.projectStatus === 'need_review') return '执行结束 · 待修订'
if (result.value.projectStatus !== 'completed') return '执行结束 · 结果待确认'
}
if (breakdownTask.value && props.execution.status === 'completed') {
if (breakdownInvalid.value) return '执行结束 · 校验未通过'
if (breakdownNeedsReview.value) return '执行结束 · 待修订'
if (breakdownValidation.value !== true) return '执行结束 · 结果待确认'
}
return labels[props.execution.status]
})
const finished = computed(() => ['completed', 'failed'].includes(props.execution?.status ?? ''))
/** 是否为剧本创作任务,避免使用镜头素材的提示文案。 */
const scriptCreation = computed(() => props.execution?.workflowName === 'create-drama')
/** 视频质量任务使用后端聚合后的候选终态统计。 */
const videoQuality = computed(() => props.execution?.workflowName === 'video-quality')
/** 旧任务没有版本过期计数时按零展示,仅接受后端非负整数计数。 */
const staleMotionPlanCount = computed(() => {
const count =
props.execution?.status === 'completed'
? result.value.staleMotionPlan
: props.execution?.metadata?.staleMotionPlan
return typeof count === 'number' && Number.isSafeInteger(count) && count >= 0 ? count : 0
})
/** 业务未通过或结果未知时,不把任务执行结束展示为全成功。 */
const statusType = computed(() => {
if (historical.value || stopped.value || recovered.value) return 'default'
if (derivedTask.value)
return props.execution?.status === 'failed' ? 'error' : derivedNeedsReview.value ? 'warning' : 'default'
if (scriptCreation.value && props.execution?.status === 'completed')
return result.value.projectStatus === 'completed'
? 'success'
: result.value.projectStatus === 'need_review'
? 'warning'
: 'default'
if (diagnosisTask.value)
return props.execution?.status === 'failed'
? 'error'
: props.execution?.status === 'completed'
? 'default'
: 'warning'
if (breakdownTask.value)
return breakdownState.value === 'success'
? 'success'
: breakdownState.value === 'error'
? 'error'
: breakdownState.value === 'unknown'
? 'default'
: 'warning'
return props.execution?.status === 'completed'
? videoQuality.value && staleMotionPlanCount.value > 0
? 'warning'
: 'success'
: props.execution?.status === 'failed'
? 'error'
: 'warning'
})
/** 逐镜终态从运行 metadata 或完成 result 读取,不根据历史通过猜测状态。 */
const settledItems = computed(() => {
const settled = props.execution?.status === 'completed' ? result.value.settled : props.execution?.metadata?.settled
if (!settled || typeof settled !== 'object' || Array.isArray(settled)) return []
return Object.entries(settled).flatMap(([shotId, item]) => {
if (
!item ||
typeof item !== 'object' ||
!('status' in item) ||
!('videoId' in item) ||
typeof item.status !== 'string' ||
typeof item.videoId !== 'string'
)
return []
return [{ shotId, status: item.status, videoId: item.videoId }]
})
})
/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
/** 首帧工作流中断时按持久化恢复说明处理,不推断可重试。 */
const keyframeRecovery = computed(
() =>
(keyframeQuality.value || props.execution?.workflowName === 'keyframe-generation') &&
result.value.recoveryRequired === true &&
result.value.retryAutomatically === false
)
/** 首帧编辑复用质量工作流,最终回执不属于批量质量统计。 */
const keyframeEdit = computed(() => props.execution?.metadata?.action === 'edit-keyframe')
/** 只接受后端完整的质量计数,畸形或缺失结果不显示全成功。 */
const keyframeCounts = computed(() => {
const fields = ['targetCount', 'passed', 'repairFailed', 'failed'] as const
if (
!fields.every(
field =>
typeof result.value[field] === 'number' &&
Number.isSafeInteger(result.value[field]) &&
Number(result.value[field]) >= 0
)
)
return null
const counts = {
targetCount: Number(result.value.targetCount),
passed: Number(result.value.passed),
repairFailed: Number(result.value.repairFailed),
failed: Number(result.value.failed)
}
return counts.passed + counts.repairFailed + counts.failed === counts.targetCount ? counts : null
})
/** 范围描述保留指定镜头或剧集,不把小批量误显示为全项目。 */
const scopeLabel = computed(() => {
const metadata = props.execution?.metadata
if (!metadata) return ''
const episode = typeof metadata.episodeNo === 'number' ? `第 ${metadata.episodeNo} 集` : '全项目'
const mode =
metadata.inputModeFilter === 'first_frame'
? '首帧模式'
: metadata.inputModeFilter === 'omni_reference'
? '全模态参考'
: '全部推荐模式'
if (derivedTask.value && Array.isArray(metadata.shotIds)) return `${episode} · 所选 ${metadata.shotIds.length} 镜`
if (keyframeQuality.value && typeof metadata.shotId === 'string') return `${episode} · 单镜头`
return videoQuality.value ? `${episode} · ${mode}` : episode
})
const inputPlanCounts = computed(() => {
const plans = result.value.inputPlans
if (!Array.isArray(plans)) return null
return {
firstFrame: plans.filter(plan => isInputMode(plan, 'first_frame')).length,
omniReference: plans.filter(plan => isInputMode(plan, 'omni_reference')).length
}
})
/** 对持久化 JSON 做最小结构校验,避免模板依赖不可信结果字段。 */
function isInputMode(value: unknown, inputMode: string): boolean {
return !!value && typeof value === 'object' && 'inputMode' in value && value.inputMode === inputMode
}
</script>
<template>
<section
v-if="execution || error"
:class="[embedded ? '' : 'panel mt-4 p-5', { 'breakdown-execution-card': breakdownTask }]"
:data-task-state="breakdownTask ? breakdownState : undefined"
:aria-label="title"
>
<div v-if="!embedded" class="flex flex-wrap items-start justify-between gap-3">
<div>
<div class="flex flex-wrap items-center gap-2">
<h3 v-if="!embedded" class="text-sm font-semibold">{{ title }}</h3>
<LoaderCircle v-if="!finished" :size="14" class="animate-spin text-muted" aria-hidden="true" />
<NTag v-if="execution" size="small" :type="statusType" :bordered="false">{{ statusLabel }}</NTag>
</div>
<p v-if="execution && !breakdownTask" class="mt-2 text-xs text-muted">
{{ executionStageLabel(execution.stage) }} · 更新于 {{ formatDate(execution.updatedAt) }}
</p>
<p v-if="scopeLabel && !breakdownTask" class="mt-1 text-xs text-muted">范围:{{ scopeLabel }}</p>
</div>
<div class="flex items-center gap-2">
<ConfirmAction
v-if="derivedTask && canStop"
label="停止后续生成"
status="default"
:loading="stopping"
description="停止后不再领取后续模型请求。已发送请求仍可能返回结果并产生费用;停止不代表退款,也不授权重新收费。"
@confirm="emit('stop')"
/>
<NButton v-if="derivedTask" size="small" :loading="loading" @click="emit('refresh')">刷新状态</NButton>
<WorkspaceActionTooltip
v-if="!embedded && showRecoveryHistory && (finished || error)"
label="隐藏制作任务记录"
><NButton class="icon-button" quaternary aria-label="隐藏制作任务记录" @click="emit('dismiss')"
><X :size="15" /></NButton
></WorkspaceActionTooltip>
</div>
</div>
<!-- 以下是弹窗内的任务状态与简洁元信息,用标题和对齐区分说明层级 -->
<template v-else>
<WorkspaceSectionHeading title="任务状态">
<template #actions>
<NTag v-if="execution" size="small" :type="statusType" :bordered="false">{{ statusLabel }}</NTag>
</template>
</WorkspaceSectionHeading>
<dl v-if="execution" class="mt-4 grid grid-cols-2 gap-x-6 gap-y-4">
<div v-if="!finished" class="col-span-2">
<dt class="text-xs text-muted">当前阶段</dt>
<dd class="mt-2 flex items-center gap-2 text-sm">
<LoaderCircle :size="14" class="animate-spin text-muted" aria-hidden="true" />{{
executionStageLabel(execution.stage)
}}
</dd>
</div>
<div>
<dt class="text-xs text-muted">更新时间</dt>
<dd class="mt-2 text-sm">{{ formatDate(execution.updatedAt) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">处理范围</dt>
<dd class="mt-2 text-sm">{{ scopeLabel || '未提供范围' }}</dd>
</div>
</dl>
</template>
<template v-if="execution">
<!-- 以下是派生批次的停止、原回执与免费恢复状态。 -->
<div v-if="derivedTask" class="mt-3 space-y-2 text-xs leading-6" aria-label="模型请求与恢复状态">
<p v-if="stopped">已停止后续生成。已发送请求及已返回结果保留;仍需核对在途结果和费用,不会自动重试。</p>
<p v-if="recovered">
已复用原结果完成免费恢复,新增模型请求 0 次。请重新核对正式画面状态;原失败历史保留。
</p>
<p v-if="claims.length">
请求结果未知 {{ claims.filter(item => item.state === 'submitted').length }} 步 · 已收到结果
{{ claims.filter(item => item.state === 'received').length }} 步。收到结果不代表质量通过。
</p>
<p v-else-if="!recovered">
{{ finished ? '没有可确认的模型领取信息,不能据此判断未产生费用。' : '等待模型领取记录。' }}
</p>
<p v-if="execution.status === 'failed' && !stopped">
原失败记录保留。原回执是否可信需受控核查,不会自动重新生成或重试。
</p>
</div>
<!-- 以下是拆解任务的直接可见摘要,替代折叠详情和重复进度说明 -->
<dl v-if="breakdownTask" class="mt-4 grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4">
<div>
<dt class="text-xs text-muted">{{ historical ? '历史阶段' : '当前阶段' }}</dt>
<dd class="mt-2 text-sm">{{ executionStageLabel(execution.stage) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">处理范围</dt>
<dd class="mt-2 text-sm">{{ scopeLabel || '未提供范围' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ progressLabel }}</dt>
<dd class="mt-2 text-sm">
<template v-if="execution.total > 0">{{ execution.current }} / {{ execution.total }}</template>
<template v-else>{{ finished ? '本次任务已结束' : '等待进度更新' }}</template>
</dd>
</div>
<div>
<dt class="text-xs text-muted">更新时间</dt>
<dd class="mt-2 text-sm">{{ formatDate(execution.updatedAt) }}</dd>
</div>
</dl>
<NProgress
v-if="execution.total > 0 && ((!breakdownTask && !diagnosisTask) || !finished)"
type="line"
:percentage="percentage"
:color="
execution.status === 'failed' ||
derivedTask ||
(scriptCreation && result.projectStatus !== 'completed')
? 'var(--app-muted)'
: undefined
"
:height="5"
:show-indicator="false"
class="mt-4"
/>
<p v-if="!breakdownTask && (!embedded || execution.total > 0)" class="mt-3 text-xs">
<template v-if="execution.total > 0"
>{{ progressLabel }} {{ execution.current }} / {{ execution.total }}</template
>
<template v-else>{{
finished
? '本次任务已结束'
: breakdownTask
? '拆解进行中,等待下一阶段结果'
: scriptCreation
? execution.status === 'pending'
? '等待开始创作剧本'
: '正在创作剧本'
: '正在准备本次任务'
}}</template>
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask && !derivedTask">
· 当前镜头 <code>{{ execution.currentResourceId }}</code></template
>
</p>
<ContextNotice
v-if="execution.status === 'running' && showStatusHint"
type="info"
:show-icon="embedded"
:emphasized="embedded"
:title="embedded ? '任务进行中' : undefined"
class="mt-3"
>
{{
videoQuality ? '系统会继续生成、检查并按需修复。' : '系统会继续处理剩余内容并保存已完成结果。'
}}可以离开或刷新页面,返回后会继续显示本次任务进度,请勿重复提交。
</ContextNotice>
<ContextNotice
v-else-if="execution.status === 'completed' && showStatusHint && !historical"
:type="
derivedTask
? derivedNeedsReview
? 'warning'
: 'info'
: scriptCreation
? result.projectStatus === 'completed'
? 'success'
: result.projectStatus === 'need_review'
? 'warning'
: 'info'
: diagnosisTask
? 'info'
: breakdownInvalid
? 'warning'
: keyframeEdit
? result.passed === true
? 'success'
: result.validationSkipped === true
? 'info'
: 'warning'
: videoQuality && staleMotionPlanCount > 0
? 'warning'
: keyframeQuality &&
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
? 'warning'
: 'success'
"
:show-icon="embedded"
:emphasized="embedded"
:title="
embedded
? scriptCreation && result.projectStatus === 'need_review'
? '审核仍需处理'
: scriptCreation && result.projectStatus !== 'completed'
? '结果待确认'
: '任务已完成'
: undefined
"
class="mt-3"
>
<p>
{{
diagnosisTask
? '动作诊断已结束,请查看最新结果;执行结束不代表动作全部通过。'
: breakdownTask
? '剧本拆解已结束,请查看候选与校验结果。'
: scriptCreation
? result.projectStatus === 'need_review'
? '剧本创作任务已结束,审核仍需处理,请查看当前审核结果。'
: '剧本创作任务已结束,可查看最新剧本内容。'
: derivedTask
? '本轮派生设计已结束,请分别核对成功、失败及过期记录。'
: '本轮任务已结束,可查看最新镜头资产状态。'
}}
</p>
<p v-if="videoQuality" class="mt-2 text-xs">
目标 {{ result.targetCount ?? execution.total }} · 通过 {{ result.passed ?? 0 }} · 修复耗尽
{{ result.exhausted ?? 0 }} · 模型失败 {{ result.providerFailed ?? 0 }} · 提交失败
{{ result.submissionFailed ?? 0 }} · 动作版本过期 {{ staleMotionPlanCount }}
</p>
<!-- 以下是动作版本变化后停止质量流程的候选说明模块 -->
<p v-if="videoQuality && staleMotionPlanCount > 0" class="mt-2 text-xs">
{{ staleMotionPlanCount }}
个镜头的候选因动作规划版本变化已停止质量流程。请先更新视频提示词,再按当前动作规划重新生成视频。
</p>
<p v-if="videoQuality && inputPlanCounts" class="mt-2 text-xs">
输入规划:首帧模式 {{ inputPlanCounts.firstFrame }} · 全模态参考
{{ inputPlanCounts.omniReference }}
</p>
<p v-else-if="keyframeEdit" class="mt-2 text-xs">
{{
result.validationSkipped === true
? '编辑候选已生成,尚未进行质量校验。'
: result.passed === true
? '编辑结果质量通过。'
: '编辑结果未通过质量校验。'
}}
{{ result.primaryChanged === true ? '已更新主首帧。' : '主首帧未替换。' }}
</p>
<p v-else-if="keyframeQuality" class="mt-2 text-xs">
<template v-if="keyframeCounts"
>目标 {{ keyframeCounts.targetCount }} · 通过 {{ keyframeCounts.passed }} · 修复未通过
{{ keyframeCounts.repairFailed }} · 调用失败 {{ keyframeCounts.failed }}</template
>
<template v-else>首帧检查结果尚不完整,请刷新任务详情后核对。</template>
</p>
<p v-else-if="diagnosisTask" class="mt-2 text-xs">具体冲突与证据情况以最新诊断列表为准。</p>
<p v-else-if="!videoQuality && !scriptCreation && !breakdownTask && !derivedTask" class="mt-2 text-xs">
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
</p>
</ContextNotice>
<ContextNotice
v-else-if="execution.status === 'failed' && showStatusHint && !historical && !stopped"
type="error"
:show-icon="embedded || diagnosisRecovery || keyframeRecovery"
:emphasized="embedded || diagnosisRecovery || keyframeRecovery"
:critical="diagnosisRecovery || keyframeRecovery"
:title="embedded ? '任务未完成' : undefined"
class="mt-3"
>
<p>
{{
(derivedTask
? derivedEpisodes.length
? '派生执行未完成,请核对下方逐集原因。'
: derivedErrorSummary(execution.error ?? '')
: userFacingText(execution.error)) || '制作任务执行失败。'
}}
</p>
<p class="mt-2 text-xs">
{{
diagnosisTask
? '请先核对最新诊断记录。服务中断时还需确认费用,再决定是否手动重新诊断。'
: derivedTask
? '请先核对已有结果、原回执和费用;未知请求不得重复提交。'
: scriptCreation
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
}}
</p>
</ContextNotice>
<!-- 以下是派生任务的部分成功与失败明细,失败终态也保留已有结果 -->
<div
v-if="derivedTask && finished && !recovered && Array.isArray(result.episodes)"
class="mt-4 space-y-3 text-xs leading-6"
aria-label="逐集设计结果"
>
<p>
共 {{ result.episodeCount ?? '待确认' }} 集 · 已保存 {{ result.completedEpisodes ?? '待确认' }} 集 ·
跳过 {{ result.skippedEpisodes ?? '待确认' }} 集 · 失败 {{ result.failedEpisodes ?? '待确认' }} 集
</p>
<p v-if="derivedNeedsReview" class="text-danger">成功结果已保留,请核对失败剧集和过期设计。</p>
<ul v-if="derivedEpisodes.length" class="space-y-2">
<li v-for="item in derivedEpisodes" :key="item.episodeNo" class="wrap-anywhere">
第 {{ item.episodeNo }} 集 ·
{{
item.error || item.status === 'failed'
? '失败'
: item.status === 'skipped'
? '跳过'
: item.status === 'completed'
? '已保存'
: '状态待确认'
}}<span v-if="item.error">:{{ derivedErrorSummary(item.error) }}</span>
<p v-for="(issue, index) in item.issues" :key="index" class="mt-1">
<span v-if="visualStateTimeIssueLabel(issue)"
>{{ visualStateTimeIssueLabel(issue) }} · </span
>段落 {{ issue.beatNo ?? '待确认' }} · 镜头 {{ issue.shotNo ?? '待确认' }}:{{
userFacingText(issue.message)
}}
</p>
</li>
</ul>
</div>
<!-- 以下是诊断中断恢复摘要,未知费用与人工核查直接显示 -->
<div v-if="diagnosisTask && finished" class="mt-3 space-y-2 text-xs" aria-label="动作诊断任务统计">
<p v-if="diagnosisRecovery">需要人工核查:中断时的模型请求可能已产生费用,系统不会自动重新诊断。</p>
<p v-if="diagnosisRecovery">
<span v-if="diagnosisCount('reusableShotCount') !== null"
>可复用 {{ diagnosisCount('reusableShotCount') }} 镜 · </span
><span v-if="diagnosisCount('manualReviewShotCount') !== null"
>待核查 {{ diagnosisCount('manualReviewShotCount') }} 镜</span
>
</p>
<p v-if="diagnosisRecovery && result.qualityPolicyVerified !== true">
质量规则来源尚未确认,请先核对最新分镜。
</p>
<p v-else-if="!diagnosisRecovery">
本次处理 {{ diagnosisCount('completed') ?? diagnosisCount('total') ?? '待确认' }} 镜 · 复用
{{ diagnosisCount('skipped') ?? '待确认' }} 镜 · 调用失败
{{ diagnosisCount('failed') ?? '待确认' }} 镜。
</p>
</div>
<!-- 以下是首帧工作流中断后的人工核查说明 -->
<p v-if="keyframeRecovery" class="mt-3 text-xs leading-6">首帧任务已中断,请先核对候选和费用。</p>
<!-- 以下是非拆解任务的 Naive 详情折叠模块 -->
<NCollapse v-if="!breakdownTask && !embedded" class="mt-3 text-xs text-muted">
<NCollapseItem name="task-details" title="任务详情">
<p class="mt-2 break-all font-mono">任务编号 · {{ execution.id }}</p>
<pre v-if="derivedTask && claims.length" class="mt-2 whitespace-pre-wrap wrap-anywhere">{{
JSON.stringify(claims, null, 2)
}}</pre>
<pre
v-if="derivedTask && (execution.error || result.episodes)"
class="mt-2 whitespace-pre-wrap wrap-anywhere"
>{{ JSON.stringify({ error: execution.error, result: execution.result }, null, 2) }}</pre>
<p v-if="recoveryKey" class="mt-2 break-all">原执行 · {{ execution.metadata?.recoveryOf }}</p>
<!-- 以下是逐镜已结束质量任务的持久化状态模块 -->
<ul v-if="videoQuality && settledItems.length" class="mt-2 space-y-2">
<li v-for="item in settledItems" :key="item.shotId" class="break-all">
<a
:href="`/projects/${encodeURIComponent(execution.projectId)}/production?shotId=${encodeURIComponent(item.shotId)}`"
class="text-button"
>查看镜头</a
>
· {{ executionStageLabel(item.status) }} · 视频 {{ item.videoId }}
</li>
</ul>
</NCollapseItem>
</NCollapse>
</template>
<!-- 以下是免费恢复关联的原失败历史,不修改原终态。 -->
<section v-if="recoveryKey" class="mt-4 space-y-2" aria-label="原失败历史">
<p class="text-xs text-muted">
原失败执行{{
originalExecution.data.value?.status === 'failed' ? '仍保留为失败' : '状态待核对'
}},与本次免费恢复分别记录。
</p>
<WorkflowExecutionPanel
v-if="originalExecution.data.value"
title="原失败执行"
:execution="originalExecution.data.value"
:loading="originalExecution.loading.value"
:error="originalExecution.error.value"
:show-recovery-history="false"
@refresh="originalExecution.refresh"
/>
<NButton v-else :loading="originalExecution.loading.value" @click="originalExecution.refresh"
>读取原失败执行</NButton
>
</section>
<!-- 以下是运行期间已经终止的过期候选统计模块 -->
<p
v-if="videoQuality && execution?.status === 'running' && staleMotionPlanCount > 0"
class="mt-3 text-xs"
role="status"
>
动作版本过期 {{ staleMotionPlanCount }} · 这些候选已停止质量流程,其余镜头继续处理。
</p>
<ContextNotice
v-if="error"
type="error"
:show-icon="embedded"
:emphasized="embedded"
:title="embedded ? '状态读取失败' : undefined"
class="mt-3"
>
{{ error }}。任务可能仍在运行,请先重新读取状态;不要直接重复提交。
<NButton v-if="!embedded" text class="ml-3" :loading="loading" @click="emit('refresh')">重试读取</NButton>
</ContextNotice>
</section>
</template>
<style>
/* 拆解任务与设置、候选卡片使用相同底面和内边距,终态不再展示铺满宽度的进度条。 */
.breakdown-execution-card {
background: var(--app-subtle);
}
.breakdown-execution-card[data-task-state='success'] {
background: var(--app-success-soft);
}
</style>