diff --git a/AGENTS.md b/AGENTS.md index b2266c2..0776ae2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,6 +29,7 @@ - 修改前先查看所在完整页面、相邻模块及已有公共组件,同时考虑整体协调、元素间距和功能一致性,不能只修改截图中的一个局部而忽略其他状态。 - 同类布局、按钮、状态色、关闭入口和交互流程保持一致;发现本次改动涉及的同类问题时,一并修正相关公共组件或当前功能中的使用位置。 - 优先复用 `src/components/ui` 中的公共组件、`src/styles/admin.css` 中的设计变量和现有主题配置;公共问题在公共层解决,避免各页面重复覆盖或硬编码颜色、尺寸。 +- 所有折叠、展开和历史详情区域统一使用 Naive UI 的 `NCollapse`、`NCollapseItem` 等组件,不再使用原生 `details`、`summary` 或自制折叠控件;修改同类区域时同步统一现有实现。 - 维持项目现有简洁、扁平的视觉风格。用标题、简短说明、留白和对齐区分普通功能区域,避免无意义的底色、边框和装饰线。 - 页面文案保持精简,说明应帮助用户理解当前操作;不把大量错误、技术细节和重复提示堆在设置页面。 diff --git a/src/features/breakdown/BreakdownPage.vue b/src/features/breakdown/BreakdownPage.vue index 2e9b0a3..7e63562 100644 --- a/src/features/breakdown/BreakdownPage.vue +++ b/src/features/breakdown/BreakdownPage.vue @@ -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() @@ -101,7 +113,7 @@ const diagnosisPanel = ref | 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() 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 }} 主体 {{ subjects.length }} · 分镜剧集 {{ shots.length }} / {{ plans.length }} - + 最近阶段:{{ runningStage }} @@ -588,14 +619,18 @@ const rules = { + + + + + @@ -615,7 +652,9 @@ const rules = { />