fix(short-drama-agent-front): 修复B01分镜与历史失败状态
This commit is contained in:
1 parent
ecb0423153
commit
75e86f7486
4 files changed
+123
-31
No files matched your search
@@ -116,6 +116,15 @@ const sourceLabel = computed(
|
||||
empty: ''
|
||||
})[quality.value.source]
|
||||
)
|
||||
/** 从当前正式版本逐镜汇总,不沿用历史执行进度或候选统计。 */
|
||||
const formalStoryboardSummary = computed(() => {
|
||||
if (quality.value.source !== 'formal' || !quality.value.committed || !shots.value.length) return ''
|
||||
const allShots = shots.value.flatMap(episode => episode.beatShots.flatMap(beat => beat.shots))
|
||||
const bindingSummary = allShots.some(shot => shot.subjectRefs.length && !shot.subjectBindings)
|
||||
? '绑定数量待确认'
|
||||
: `${allShots.reduce((total, shot) => total + (shot.subjectBindings?.length ?? 0), 0)} 条绑定`
|
||||
return `${shots.value.length} 集 · ${allShots.length} 镜 · ${bindingSummary}`
|
||||
})
|
||||
const operation = computed(() => getOperation(projectId.value))
|
||||
/** 分镜阅读和诊断入口共用当前剧集,不维护独立的诊断集号输入。 */
|
||||
const selectedEpisodeNo = ref<number>()
|
||||
@@ -166,18 +175,23 @@ const execution = computed(() => {
|
||||
}
|
||||
: 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 executionHistorical = computed(() => {
|
||||
const task = execution.value
|
||||
const source = qualityObservation.source.value
|
||||
const checkpoint = source.checkpoint
|
||||
if (!task || task.status === 'running' || !checkpoint) return false
|
||||
const record = backgroundExecution.query.data.value
|
||||
const finishedAt = Date.parse(task.completedAt ?? record?.updatedAt ?? '')
|
||||
const adoptedAt = quality.value.committed ? Date.parse(checkpoint.updatedAt ?? '') : NaN
|
||||
const resultAt = Number.isFinite(adoptedAt) ? adoptedAt : Date.parse(checkpoint.createdAt)
|
||||
if (Number.isFinite(finishedAt) && Number.isFinite(resultAt)) return resultAt > finishedAt
|
||||
return !record && checkpoint === latestCheckpoint.value && !!checkpoint.metadata?.sourceCheckpointId
|
||||
})
|
||||
/** 当前失败与历史回执使用相同的判断,避免状态栏和详情展示相反结论。 */
|
||||
const currentWorkflowError = computed(() =>
|
||||
execution.value?.status === 'failed' && !executionHistorical.value ? execution.value.errorMessage || '' : ''
|
||||
)
|
||||
/** 拆解运行状态同时控制状态栏、诊断入口及所有恢复写操作。 */
|
||||
const breakdownBusy = computed(
|
||||
() =>
|
||||
@@ -252,16 +266,6 @@ 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,
|
||||
@@ -607,7 +611,12 @@ const isInitialEmpty = computed(
|
||||
<span v-if="summary"
|
||||
>抽取 {{ summary.completed }} / {{ summary.total }} · 失败 {{ summary.failed }}</span
|
||||
>
|
||||
<span>主体 {{ subjects.length }} · 分镜剧集 {{ shots.length }} / {{ plans.length }}</span>
|
||||
<span
|
||||
>主体 {{ subjects.length
|
||||
}}<template v-if="!formalStoryboardSummary">
|
||||
· 分镜剧集 {{ shots.length }} / {{ plans.length }}</template
|
||||
></span
|
||||
>
|
||||
<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
|
||||
@@ -836,6 +845,7 @@ const isInitialEmpty = computed(
|
||||
:title="executionHistorical ? '历史拆解任务' : '剧本拆解任务'"
|
||||
class="breakdown-execution-panel"
|
||||
:show-status-hint="false"
|
||||
:result-is-historical="executionHistorical"
|
||||
:execution="backgroundExecution.query.data.value"
|
||||
:loading="backgroundExecution.query.loading.value"
|
||||
:error="backgroundExecution.query.error.value"
|
||||
@@ -908,7 +918,8 @@ const isInitialEmpty = computed(
|
||||
<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>
|
||||
{{ sourceLabel }}<span v-if="formalStoryboardSummary"> · {{ formalStoryboardSummary }}</span
|
||||
><span v-if="quality.loading"> · 正在读取当前质量审核…</span>
|
||||
</p>
|
||||
<div v-if="!isInitialEmpty" class="result-toolbar tabs-toolbar">
|
||||
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="拆解结果"
|
||||
|
||||
@@ -62,10 +62,7 @@ const derivedEpisodes = computed(() => {
|
||||
})
|
||||
/** 只改变旧记录的展示语义,不改写原始任务或审核结果。 */
|
||||
const historical = computed(
|
||||
() =>
|
||||
props.resultIsHistorical &&
|
||||
props.execution?.workflowName === 'create-drama' &&
|
||||
['completed', 'failed'].includes(props.execution.status)
|
||||
() => props.resultIsHistorical && ['completed', 'failed'].includes(props.execution?.status ?? '')
|
||||
)
|
||||
/** 动作诊断执行结束仅表示分析完成,不能套用素材生成的通过文案。 */
|
||||
const diagnosisTask = computed(() => props.execution?.workflowName === 'storyboard-legacy-action-diagnosis')
|
||||
@@ -102,6 +99,7 @@ const breakdownNeedsReview = computed(
|
||||
)
|
||||
/** 拆解卡片区分真实成功、待修复、运行中和结果待确认。 */
|
||||
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'
|
||||
@@ -120,7 +118,8 @@ const progressLabel = computed(() =>
|
||||
const statusLabel = computed(() => {
|
||||
const labels = { pending: '等待开始', running: '执行中', completed: '已完成', failed: '失败' }
|
||||
if (!props.execution) return ''
|
||||
if (historical.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
|
||||
? '执行结束 · 需核对部分结果'
|
||||
@@ -322,7 +321,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<!-- 以下是拆解任务的直接可见摘要,替代折叠详情和重复进度说明 -->
|
||||
<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">当前阶段</dt>
|
||||
<dt class="text-xs text-muted">{{ historical ? '历史阶段' : '当前阶段' }}</dt>
|
||||
<dd class="mt-2 text-sm">{{ executionStageLabel(execution.stage) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -6,6 +6,8 @@ export interface Checkpoint {
|
||||
checkpointId: string
|
||||
workflowName: string
|
||||
createdAt: string
|
||||
/** 正式采用可更新原记录,创建时间仍保留候选生成时刻。 */
|
||||
updatedAt?: string
|
||||
metadata?: { nodeName?: string; nodeDurationMs?: number; [key: string]: unknown } | null
|
||||
state: DramaState & BreakdownState
|
||||
}
|
||||
@@ -410,6 +410,81 @@ it('候选审核通过后只展示候选,修复后的正式结果不再被嵌
|
||||
expect(read).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('原位采用的正式分镜显示完整统计,先前失败仅进入历史执行记录', async () => {
|
||||
const state = candidateState({
|
||||
projectId: 'breakdown-scroll-test',
|
||||
storyboardPersisted: true,
|
||||
candidateCommitted: true
|
||||
})
|
||||
const episode = state.storyboardEpisodeShots![0]!
|
||||
const example = episode.beatShots[0]!.shots[0]!
|
||||
state.storyboardEpisodeShots = [17, 13, 16, 14].map((count, index) => ({
|
||||
episodeNo: index + 1,
|
||||
episodePlan: { ...episode.episodePlan, episodeNo: index + 1 },
|
||||
beatShots: [
|
||||
{
|
||||
beatNo: episode.beatShots[0]!.beatNo,
|
||||
shots: Array.from({ length: count }, (_, shotIndex) => {
|
||||
const subjectBindings = Array.from(
|
||||
{ length: index === 0 && shotIndex < 7 ? 5 : 4 },
|
||||
(_binding, i) => ({
|
||||
...example.subjectBindings![0]!,
|
||||
subjectRef: '@CH000' + (i + 1)
|
||||
})
|
||||
)
|
||||
return {
|
||||
...example,
|
||||
shotNo: shotIndex + 1,
|
||||
subjectRefs: subjectBindings.map(item => item.subjectRef),
|
||||
subjectBindings
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
}))
|
||||
const current = {
|
||||
...candidateCheckpoint(state),
|
||||
updatedAt: '2026-10-17T10:05:00Z'
|
||||
}
|
||||
mountPage([current], 4)
|
||||
const record = {
|
||||
id: 'failed-before-in-place-adoption',
|
||||
projectId: 'breakdown-scroll-test',
|
||||
workflowName: 'breakdown',
|
||||
status: 'failed' as const,
|
||||
stage: 'failed',
|
||||
current: 2,
|
||||
total: 4,
|
||||
currentResourceId: null,
|
||||
metadata: null,
|
||||
result: null,
|
||||
error: '历史分镜时长冲突',
|
||||
startedAt: '2026-10-17T09:20:00Z',
|
||||
completedAt: '2026-10-17T10:00:00Z',
|
||||
createdAt: '2026-10-17T09:20:00Z',
|
||||
updatedAt: '2026-10-17T10:00:00Z'
|
||||
}
|
||||
vi.spyOn(workflowExecutionApi, 'get').mockResolvedValue(record)
|
||||
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview')
|
||||
taskScope = effectScope()
|
||||
const tracker = taskScope.run(() => useWorkflowExecution(ref(record.projectId), 'breakdown'))!
|
||||
await tracker.track(record.id)
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toMatch(/正式拆解结果\s*·\s*4 集\s*·\s*60 镜\s*·\s*247 条绑定/)
|
||||
expect(wrapper!.text()).toContain('已提交正式结果')
|
||||
expect(wrapper!.text()).not.toContain('工作流失败')
|
||||
expect(wrapper!.find('button.breakdown-desktop-issues').exists()).toBe(false)
|
||||
expect(preview).not.toHaveBeenCalled()
|
||||
await wrapper!.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().text()).toContain('历史拆解执行记录')
|
||||
await drawerPanel().get('.breakdown-execution-history .n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().text()).toContain('历史执行记录')
|
||||
expect(drawerPanel().get('[aria-label="历史拆解任务"]').attributes('data-task-state')).toBe('unknown')
|
||||
tracker.dismiss()
|
||||
})
|
||||
|
||||
it('历史修复元数据不能掩盖之后新任务的真实失败', async () => {
|
||||
const current = candidateCheckpoint(
|
||||
candidateState({ projectId: 'breakdown-scroll-test', storyboardPersisted: true, candidateCommitted: true })
|
||||
@@ -531,7 +606,7 @@ function mountPage(records = [checkpoint()], episodes = 1): ReturnType<typeof us
|
||||
style: '',
|
||||
status: 'completed',
|
||||
durationMode: 'auto',
|
||||
episodeCount: 1,
|
||||
episodeCount: episodes,
|
||||
targetDurationSeconds: null,
|
||||
episodeMinSeconds: null,
|
||||
episodeMaxSeconds: null,
|
||||
@@ -540,7 +615,12 @@ function mountPage(records = [checkpoint()], episodes = 1): ReturnType<typeof us
|
||||
characters: [],
|
||||
world: null,
|
||||
|
||||
episodes: episodes ? [{ episode: 1, targetDurationSeconds: null, title: '第一集', content: '正文' }] : []
|
||||
episodes: Array.from({ length: episodes }, (_, index) => ({
|
||||
episode: index + 1,
|
||||
targetDurationSeconds: null,
|
||||
title: index === 0 ? '第一集' : `第 ${index + 1} 集`,
|
||||
content: '正文'
|
||||
}))
|
||||
}
|
||||
const data = ref({
|
||||
project,
|
||||
|
||||
Reference in new issue
Block a user