feat(short-drama-agent-front): 接入分阶段镜头生产与摄影修订
This commit is contained in:
1 parent
1e9ef33d1d
commit
87427d9d43
29 files changed
+2787
-136
No files matched your search
@@ -1,4 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
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'
|
||||
@@ -27,17 +31,63 @@ const props = withDefaults(
|
||||
embedded?: boolean
|
||||
/** 当前项目结果已更新时,旧创作任务只作为历史执行记录展示。 */
|
||||
resultIsHistorical?: boolean
|
||||
/** 当前观察器允许停止派生批次。 */
|
||||
canStop?: boolean
|
||||
/** 正在提交停止请求。 */
|
||||
stopping?: boolean
|
||||
/** 关联恢复历史只向原任务展开一层。 */
|
||||
showRecoveryHistory?: boolean
|
||||
}>(),
|
||||
{ title: '制作任务', showStatusHint: true, embedded: false, resultIsHistorical: false }
|
||||
{ title: '制作任务', showStatusHint: true, embedded: false, resultIsHistorical: false, showRecoveryHistory: true }
|
||||
)
|
||||
/** 刷新状态与隐藏任务记录事件。 */
|
||||
const emit = defineEmits<{ refresh: []; dismiss: [] }>()
|
||||
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(
|
||||
() =>
|
||||
@@ -55,11 +105,39 @@ const derivedEpisodes = computed(() => {
|
||||
{
|
||||
episodeNo: item.episodeNo,
|
||||
status: 'status' in item && typeof item.status === 'string' ? item.status : '',
|
||||
error: 'error' in item && typeof item.error === 'string' ? item.error : ''
|
||||
error: 'error' in item && typeof item.error === 'string' ? item.error : '',
|
||||
issues:
|
||||
'remainingIssues' in item && Array.isArray(item.remainingIssues)
|
||||
? item.remainingIssues.filter(
|
||||
(
|
||||
issue
|
||||
): issue is {
|
||||
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 ?? '')
|
||||
@@ -118,6 +196,8 @@ const progressLabel = computed(() =>
|
||||
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))
|
||||
@@ -150,7 +230,7 @@ const staleMotionPlanCount = computed(() => {
|
||||
})
|
||||
/** 业务未通过或结果未知时,不把任务执行结束展示为全成功。 */
|
||||
const statusType = computed(() => {
|
||||
if (historical.value) return 'default'
|
||||
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')
|
||||
@@ -240,6 +320,7 @@ const scopeLabel = computed(() => {
|
||||
: 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
|
||||
})
|
||||
@@ -278,15 +359,21 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<p v-if="scopeLabel && !breakdownTask" class="mt-1 text-xs text-muted">范围:{{ scopeLabel }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<NButton
|
||||
v-if="!embedded && (finished || error)"
|
||||
class="icon-button"
|
||||
quaternary
|
||||
aria-label="隐藏制作任务记录"
|
||||
title="隐藏制作任务记录"
|
||||
@click="emit('dismiss')"
|
||||
><X :size="15"
|
||||
/></NButton>
|
||||
<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>
|
||||
|
||||
@@ -318,6 +405,23 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</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>
|
||||
@@ -370,7 +474,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
: '正在创作剧本'
|
||||
: '正在准备本次任务'
|
||||
}}</template>
|
||||
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask">
|
||||
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask && !derivedTask">
|
||||
· 当前镜头 <code>{{ execution.currentResourceId }}</code></template
|
||||
>
|
||||
</p>
|
||||
@@ -482,7 +586,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<ContextNotice
|
||||
v-else-if="execution.status === 'failed' && showStatusHint && !historical"
|
||||
v-else-if="execution.status === 'failed' && showStatusHint && !historical && !stopped"
|
||||
type="error"
|
||||
:show-icon="embedded || diagnosisRecovery || keyframeRecovery"
|
||||
:emphasized="embedded || diagnosisRecovery || keyframeRecovery"
|
||||
@@ -490,19 +594,33 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
:title="embedded ? '任务未完成' : undefined"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ userFacingText(execution.error) || '制作任务执行失败。' }}</p>
|
||||
<p>
|
||||
{{
|
||||
(derivedTask
|
||||
? derivedEpisodes.length
|
||||
? '派生执行未完成,请核对下方逐集原因。'
|
||||
: derivedErrorSummary(execution.error ?? '')
|
||||
: userFacingText(execution.error)) || '制作任务执行失败。'
|
||||
}}
|
||||
</p>
|
||||
<p class="mt-2 text-xs">
|
||||
{{
|
||||
diagnosisTask
|
||||
? '请先核对最新诊断记录。服务中断时还需确认费用,再决定是否手动重新诊断。'
|
||||
: scriptCreation
|
||||
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
|
||||
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
|
||||
: derivedTask
|
||||
? '请先核对已有结果、原回执和费用;未知请求不得重复提交。'
|
||||
: scriptCreation
|
||||
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
|
||||
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
|
||||
}}
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<!-- 以下是派生任务的部分成功与失败明细,失败终态也保留已有结果 -->
|
||||
<div v-if="derivedTask && finished" class="mt-4 space-y-3 text-xs leading-6" aria-label="逐集设计结果">
|
||||
<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 ?? '待确认' }} 集
|
||||
@@ -519,7 +637,12 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
: item.status === 'completed'
|
||||
? '已保存'
|
||||
: '状态待确认'
|
||||
}}<span v-if="item.error">:{{ userFacingText(item.error) }}</span>
|
||||
}}<span v-if="item.error">:{{ derivedErrorSummary(item.error) }}</span>
|
||||
<p v-for="(issue, index) in item.issues" :key="index" class="mt-1">
|
||||
段落 {{ issue.beatNo ?? '待确认' }} · 镜头 {{ issue.shotNo ?? '待确认' }}:{{
|
||||
userFacingText(issue.message)
|
||||
}}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -548,6 +671,14 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<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">
|
||||
@@ -562,6 +693,26 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</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"
|
||||
|
||||
Reference in new issue
Block a user