From 75e86f7486cf942dc31401019713a5973d0ef801 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 4 Nov 2026 17:22:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(short-drama-agent-front):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DB01=E5=88=86=E9=95=9C=E4=B8=8E=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/breakdown/BreakdownPage.vue | 57 ++++++++----- .../workflows/WorkflowExecutionPanel.vue | 11 ++- src/features/workflows/types.ts | 2 + .../features/breakdown/BreakdownPage.test.ts | 84 ++++++++++++++++++- 4 files changed, 123 insertions(+), 31 deletions(-) diff --git a/src/features/breakdown/BreakdownPage.vue b/src/features/breakdown/BreakdownPage.vue index 31defb0..11b601e 100644 --- a/src/features/breakdown/BreakdownPage.vue +++ b/src/features/breakdown/BreakdownPage.vue @@ -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() @@ -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( 抽取 {{ summary.completed }} / {{ summary.total }} · 失败 {{ summary.failed }} - 主体 {{ subjects.length }} · 分镜剧集 {{ shots.length }} / {{ plans.length }} + 主体 {{ subjects.length + }} 最近阶段:{{ runningStage }}

- {{ sourceLabel }} · 正在读取当前质量审核… + {{ sourceLabel }} · {{ formalStoryboardSummary }} · 正在读取当前质量审核…

{ }) /** 只改变旧记录的展示语义,不改写原始任务或审核结果。 */ 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 {
-
当前阶段
+
{{ historical ? '历史阶段' : '当前阶段' }}
{{ executionStageLabel(execution.stage) }}
diff --git a/src/features/workflows/types.ts b/src/features/workflows/types.ts index cfa1206..e3ac580 100644 --- a/src/features/workflows/types.ts +++ b/src/features/workflows/types.ts @@ -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 } diff --git a/tests/features/breakdown/BreakdownPage.test.ts b/tests/features/breakdown/BreakdownPage.test.ts index de11ae4..4193aba 100644 --- a/tests/features/breakdown/BreakdownPage.test.ts +++ b/tests/features/breakdown/BreakdownPage.test.ts @@ -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 ({ + episode: index + 1, + targetDurationSeconds: null, + title: index === 0 ? '第一集' : `第 ${index + 1} 集`, + content: '正文' + })) } const data = ref({ project,