feat(short-drama-agent-front): 新增诊断抽屉并优化项目弹窗
This commit is contained in:
1 parent
97dc784c8b
commit
49ad08a63e
21 files changed
+1479
-363
No files matched your search
@@ -13,7 +13,7 @@ import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownApi } from './api'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview, StoryboardHandOccupancyDiagnostics, StoryboardHandRepairPreview, LegacyActionDiagnosisPreview, LegacyActionDiagnosisResults } from './types'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview } from './types'
|
||||
import { breakdownSnapshot, recoveryOptions, workflowCheckpoints } from '../workflows/selectors'
|
||||
import { getOperation, isOperationRunning, runOperation } from '../workflows/operations'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -21,6 +21,8 @@ import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import SubjectList from './components/SubjectList.vue'
|
||||
import StoryboardList from './components/StoryboardList.vue'
|
||||
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
|
||||
import type { DiagnosisLocation } from './diagnosis'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText, nodeLabel } from '../../lib/format'
|
||||
|
||||
@@ -32,42 +34,6 @@ const preview = ref<BreakdownPreview | null>(null)
|
||||
const previewBusy = ref(false)
|
||||
const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
/** 分镜诊断与拆解设置解耦,默认不占用列表空间。 */
|
||||
const qualityPanelOpen = ref(false)
|
||||
/** 仅打开设置面板时按需查询,不增加页面常驻提示或后台轮询。 */
|
||||
const handDiagnostics = ref<StoryboardHandOccupancyDiagnostics | null>(null)
|
||||
const handDiagnosticsBusy = ref(false)
|
||||
const handRepairPreview = ref<StoryboardHandRepairPreview | null>(null)
|
||||
const handRepairBusy = ref(false)
|
||||
/** 只在用户主动查看时加载修复候选,避免打开设置就请求额外接口。 */
|
||||
async function loadHandRepairPreview(id: string) {
|
||||
const version = handDiagnosticsVersion
|
||||
handRepairBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.handRepairPreview(id)
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) handRepairPreview.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) handRepairBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
let handDiagnosticsVersion = 0
|
||||
async function loadHandDiagnostics(id: string) {
|
||||
const version = ++handDiagnosticsVersion
|
||||
handDiagnosticsBusy.value = true
|
||||
handDiagnostics.value = null
|
||||
try {
|
||||
const data = await breakdownApi.handOccupancyDiagnostics(id)
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) handDiagnostics.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) handDiagnosticsBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
|
||||
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
|
||||
@@ -84,101 +50,37 @@ const summary = computed(() => snapshot.value?.taskSummary)
|
||||
const validation = computed(() => result.value?.storyboardShotValidation ?? snapshot.value?.storyboardShotValidation)
|
||||
const projectId = computed(() => project.value?.id ?? '')
|
||||
const operation = computed(() => getOperation(projectId.value))
|
||||
watch([qualityPanelOpen, projectId], () => {
|
||||
++handDiagnosticsVersion
|
||||
handDiagnostics.value = null
|
||||
handDiagnosticsBusy.value = false
|
||||
handRepairPreview.value = null
|
||||
handRepairBusy.value = false
|
||||
++legacyResultsRequest
|
||||
legacyResultsBusy.value = false
|
||||
legacyResults.value = null
|
||||
/** 分镜阅读和诊断入口共用当前剧集,不维护独立的诊断集号输入。 */
|
||||
const selectedEpisodeNo = ref<number>()
|
||||
/** 按正式规划回退到首集,与分镜列表的默认选中保持一致。 */
|
||||
const currentEpisodeNo = computed(() => {
|
||||
const available = plans.value.length ? plans.value : shots.value.map(item => item.episodePlan)
|
||||
return (available.find(item => item.episodeNo === selectedEpisodeNo.value) ?? available[0])?.episodeNo
|
||||
})
|
||||
|
||||
/** 历史镜头 AI 诊断使用独立的持久化任务观察器,刷新后可恢复进度。 */
|
||||
const legacyDiagnosisExecution = useWorkflowExecution(projectId, 'storyboard-legacy-action-diagnosis')
|
||||
const legacyEpisodeNo = ref(3)
|
||||
const legacyConcurrency = ref(3)
|
||||
const legacyPreview = ref<LegacyActionDiagnosisPreview | null>(null)
|
||||
const legacyPreviewBusy = ref(false)
|
||||
const legacyStarting = ref(false)
|
||||
const legacyDiagnosisScope = ref<'episode' | 'project' | 'beat' | 'shot'>('episode')
|
||||
const legacyBeatNo = ref<number>()
|
||||
const legacyShotNo = ref<number>()
|
||||
const legacyResults = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
const legacyResultsBusy = ref(false)
|
||||
let legacyResultsRequest = 0
|
||||
async function loadLegacyResults() {
|
||||
const id = projectId.value
|
||||
const version = handDiagnosticsVersion
|
||||
const requestVersion = ++legacyResultsRequest
|
||||
const episode = legacyDiagnosisScope.value === 'project' ? undefined : legacyEpisodeNo.value
|
||||
legacyResultsBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisResults(id, episode)
|
||||
if (requestVersion === legacyResultsRequest && version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) legacyResults.value = data
|
||||
} catch (cause) {
|
||||
if (requestVersion === legacyResultsRequest && version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (requestVersion === legacyResultsRequest) legacyResultsBusy.value = false
|
||||
}
|
||||
/** 项目预览涵盖正式剧集与已有分镜剧集,不遗漏已有分镜。 */
|
||||
const diagnosisEpisodeNos = computed(() => [
|
||||
...new Set([
|
||||
...(project.value?.episodes.map(item => item.episode) ?? []),
|
||||
...shots.value.map(item => item.episodeNo)
|
||||
])
|
||||
])
|
||||
/** 分镜列表仅暴露定位方法。 */
|
||||
const storyboardList = ref<InstanceType<typeof StoryboardList> | null>(null)
|
||||
/** 诊断组件仅暴露按范围打开方法。 */
|
||||
const diagnosisPanel = ref<InstanceType<typeof StoryboardDiagnosis> | null>(null)
|
||||
/**
|
||||
* 从分镜卡片直接打开对应的节拍或镜头诊断。
|
||||
* @param location 当前分镜坐标
|
||||
*/
|
||||
function openShotDiagnosis(location: DiagnosisLocation) {
|
||||
diagnosisPanel.value?.open(location)
|
||||
}
|
||||
watch(() => legacyDiagnosisExecution.query.data.value?.status, (status, previous) => {
|
||||
if (status && status !== previous && (status === 'completed' || status === 'failed') && qualityPanelOpen.value) {
|
||||
void loadLegacyResults()
|
||||
}
|
||||
})
|
||||
|
||||
watch([legacyEpisodeNo, legacyBeatNo, legacyShotNo, legacyDiagnosisScope, projectId], () => {
|
||||
++legacyResultsRequest
|
||||
legacyResultsBusy.value = false
|
||||
legacyPreview.value = null
|
||||
legacyResults.value = null
|
||||
})
|
||||
const legacyDiagnosisDescription = computed(() => legacyDiagnosisScope.value === 'project' ? '全项目历史镜头 AI 诊断,已有有效结果将跳过。会产生模型费用,不会修改镜头。' : `第 ${legacyEpisodeNo.value} 集,共 ${legacyPreview.value?.candidateCount ?? '未知'} 个镜头,并发 ${legacyConcurrency.value}。会产生模型费用,已有有效结果将跳过。`)
|
||||
|
||||
async function loadLegacyPreview() {
|
||||
const id = projectId.value
|
||||
const version = handDiagnosticsVersion
|
||||
legacyPreviewBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisPreview(id, legacyEpisodeNo.value,
|
||||
legacyDiagnosisScope.value === 'beat' || legacyDiagnosisScope.value === 'shot' ? legacyBeatNo.value : undefined,
|
||||
legacyDiagnosisScope.value === 'shot' ? legacyShotNo.value : undefined)
|
||||
if (version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) legacyPreview.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) legacyPreviewBusy.value = false
|
||||
}
|
||||
}
|
||||
/** 从 Beat / Shot 悬停入口定位诊断范围,并复用统一费用确认。 */
|
||||
async function openLegacyShotDiagnosis(scope: { episodeNo: number; beatNo: number; shotNo?: number }) {
|
||||
legacyEpisodeNo.value = scope.episodeNo
|
||||
legacyBeatNo.value = scope.beatNo
|
||||
legacyShotNo.value = scope.shotNo
|
||||
legacyDiagnosisScope.value = scope.shotNo === undefined ? 'beat' : 'shot'
|
||||
tab.value = 'storyboard'
|
||||
qualityPanelOpen.value = true
|
||||
await loadLegacyPreview()
|
||||
}
|
||||
async function startLegacyDiagnosis() {
|
||||
const id = projectId.value
|
||||
legacyStarting.value = true
|
||||
try {
|
||||
const diagnosisTask = await breakdownApi.startLegacyActionDiagnosis(id, {
|
||||
confirmed: true,
|
||||
...(legacyDiagnosisScope.value !== 'project' ? { episodeNo: legacyEpisodeNo.value } : {}),
|
||||
...(legacyDiagnosisScope.value === 'beat' || legacyDiagnosisScope.value === 'shot' ? { beatNo: legacyBeatNo.value } : {}),
|
||||
...(legacyDiagnosisScope.value === 'shot' ? { shotNo: legacyShotNo.value } : {}),
|
||||
concurrency: legacyConcurrency.value
|
||||
})
|
||||
await legacyDiagnosisExecution.track(diagnosisTask.executionId, id)
|
||||
} catch (cause) {
|
||||
actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
legacyStarting.value = false
|
||||
}
|
||||
/**
|
||||
* 诊断问题定位到分镜正文,必要时切换到对应剧集。
|
||||
* @param location 待定位的分镜坐标
|
||||
*/
|
||||
function locateDiagnosisShot(location: DiagnosisLocation) {
|
||||
void storyboardList.value?.locate(location)
|
||||
}
|
||||
const backgroundExecution = useWorkflowExecution(projectId, 'breakdown')
|
||||
const recovery = computed(() => recoveryOptions(checkpoints.value))
|
||||
@@ -684,103 +586,23 @@ const rules = {
|
||||
/></div
|
||||
></template>
|
||||
<div v-if="tab === 'storyboard'" class="breakdown-result-pad">
|
||||
<div class="mb-3 flex justify-end">
|
||||
<NButton text @click="qualityPanelOpen = !qualityPanelOpen">{{ qualityPanelOpen ? '收起质量诊断' : '分镜质量诊断' }}</NButton>
|
||||
</div>
|
||||
<div v-if="qualityPanelOpen" class="mb-5 space-y-3">
|
||||
<div class="text-sm font-medium">分镜质量诊断</div>
|
||||
<!-- 手部动作诊断按需读取,历史镜头缺少证据时不误报为安全。 -->
|
||||
<section class="workspace-panel">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">结构化动作校验</h3>
|
||||
<NButton text :loading="handDiagnosticsBusy" :disabled="!projectId || handDiagnosticsBusy" @click="loadHandDiagnostics(projectId)">{{ handDiagnostics ? '刷新' : '查看诊断' }}</NButton>
|
||||
</div>
|
||||
<div v-if="handDiagnostics" class="mt-3 flex flex-wrap gap-x-4 gap-y-2 text-xs text-muted">
|
||||
<span>镜头 {{ handDiagnostics.shotCount }}</span>
|
||||
<span>有效证据 {{ handDiagnostics.evidenceShotCount }} / {{ handDiagnostics.shotCount }}</span>
|
||||
<span>冲突 {{ handDiagnostics.warningCount }}</span>
|
||||
<span v-if="handDiagnostics.assessment === 'insufficient_evidence'">证据不足</span>
|
||||
<span v-else-if="handDiagnostics.assessment === 'partial_evidence'">部分镜头缺少证据</span>
|
||||
</div>
|
||||
<div v-if="handDiagnostics?.diagnostics.length" class="mt-3 space-y-2 text-xs">
|
||||
<div v-for="(issue, index) in handDiagnostics.diagnostics" :key="index">
|
||||
第 {{ issue.episodeNo }} 集 / Beat {{ issue.beatNo }} / Shot {{ issue.shotNo }} / 阶段 {{ issue.phaseNo }}:{{ issue.suggestion }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="workspace-panel">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">历史镜头 AI 诊断</h3>
|
||||
<NButton text :loading="legacyPreviewBusy" @click="loadLegacyPreview">预览范围</NButton>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-3">
|
||||
<NButton size="small" :type="legacyDiagnosisScope === 'episode' ? 'primary' : 'default'" @click="legacyDiagnosisScope = 'episode'">单集</NButton>
|
||||
<NButton size="small" :type="legacyDiagnosisScope === 'project' ? 'primary' : 'default'" @click="legacyDiagnosisScope = 'project'">全项目</NButton>
|
||||
<span v-if="legacyDiagnosisScope === 'beat' || legacyDiagnosisScope === 'shot'" class="text-xs text-muted">Beat {{ legacyBeatNo }}{{ legacyDiagnosisScope === 'shot' ? ` / Shot ${legacyShotNo}` : '' }}</span>
|
||||
<NInputNumber v-if="legacyDiagnosisScope !== 'project'" v-model:value="legacyEpisodeNo" :min="1" :precision="0" size="small" class="w-24" />
|
||||
<span class="text-xs text-muted">并发</span>
|
||||
<NInputNumber v-model:value="legacyConcurrency" :min="1" :max="5" :precision="0" size="small" class="w-20" />
|
||||
</div>
|
||||
<div v-if="legacyPreview" class="mt-3 text-xs text-muted">
|
||||
第 {{ legacyPreview.episodeNo }} 集:{{ legacyPreview.candidateCount }} 个镜头,{{ legacyPreview.needsEvidenceCount }} 个待补证据
|
||||
</div>
|
||||
<div class="mt-3 flex justify-end">
|
||||
<ConfirmAction label="启动 AI 诊断" :description="legacyDiagnosisDescription"
|
||||
:loading="legacyStarting" :disabled="legacyDiagnosisExecution.active.value || legacyStarting || (legacyDiagnosisScope !== 'project' && !legacyPreview)"
|
||||
primary @confirm="startLegacyDiagnosis" />
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-3">
|
||||
<span class="text-xs text-muted">诊断结果</span>
|
||||
<NButton text :loading="legacyResultsBusy" @click="loadLegacyResults">查看结果</NButton>
|
||||
</div>
|
||||
<div v-if="legacyResults" class="mt-2 space-y-3 text-xs">
|
||||
<div class="flex flex-wrap gap-x-4 gap-y-2 text-muted">
|
||||
<span>总计 {{ legacyResults.counts.total }}</span>
|
||||
<span>冲突 {{ legacyResults.counts.conflict }}</span>
|
||||
<span>未发现冲突 {{ legacyResults.counts.clear }}</span>
|
||||
<span>证据不足 {{ legacyResults.counts.insufficient }}</span>
|
||||
<span>证据无效 {{ legacyResults.counts.invalid }}</span>
|
||||
<span>已过期 {{ legacyResults.counts.stale }}</span>
|
||||
<span>未诊断 {{ legacyResults.counts.pending }}</span>
|
||||
</div>
|
||||
<div v-for="item in legacyResults.shots.filter(shot => shot.status !== 'no_conflict_found')" :key="item.shotId" class="py-1">
|
||||
第 {{ item.episodeNo }} 集 / Beat {{ item.beatNo }} / Shot {{ item.shotNo }} · {{ item.title }}
|
||||
<span class="ml-2 text-muted">{{ ({
|
||||
conflict_found: '手部冲突',
|
||||
insufficient_evidence: '证据不足',
|
||||
invalid_evidence: '证据无效',
|
||||
stale: '诊断过期',
|
||||
not_diagnosed: '尚未诊断',
|
||||
no_conflict_found: '未发现冲突'
|
||||
} as const)[item.status] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<WorkflowExecutionPanel v-if="legacyDiagnosisExecution.executionId.value"
|
||||
title="历史动作诊断任务"
|
||||
:execution="legacyDiagnosisExecution.query.data.value ?? null"
|
||||
:loading="legacyDiagnosisExecution.query.loading.value"
|
||||
:error="legacyDiagnosisExecution.query.error.value ?? ''"
|
||||
@refresh="legacyDiagnosisExecution.query.refresh()"
|
||||
@dismiss="legacyDiagnosisExecution.dismiss()" />
|
||||
</section>
|
||||
<section v-if="handDiagnostics?.warningCount" class="workspace-panel">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">局部修复候选</h3>
|
||||
<NButton text :loading="handRepairBusy" :disabled="handRepairBusy" @click="loadHandRepairPreview(projectId)">
|
||||
{{ handRepairPreview ? '刷新候选' : '查看候选' }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div v-if="handRepairPreview" class="mt-3 space-y-2 text-xs">
|
||||
<div v-for="(item, index) in handRepairPreview.candidates" :key="index" class="space-y-1">
|
||||
<p>第 {{ item.episodeNo }} 集 / Beat {{ item.beatNo }} / Shot {{ item.shotNo }} / 阶段 {{ item.phaseNo }}</p>
|
||||
<p class="text-muted">{{ item.suggestion }}</p>
|
||||
<p v-if="item.blockingReasons.length" class="text-muted">{{ item.blockingReasons.join(';') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<StoryboardList :plans="plans" :episodes="shots" @diagnose="openLegacyShotDiagnosis">
|
||||
<StoryboardList
|
||||
ref="storyboardList"
|
||||
v-model:episode-no="selectedEpisodeNo"
|
||||
:plans="plans"
|
||||
:episodes="shots"
|
||||
@diagnose="openShotDiagnosis"
|
||||
>
|
||||
<!-- 以下是跟随当前剧集的一行诊断摘要,抽屉独立于列表滚动 -->
|
||||
<template #diagnosis>
|
||||
<StoryboardDiagnosis
|
||||
ref="diagnosisPanel"
|
||||
:project-id="projectId"
|
||||
:episode-no="currentEpisodeNo"
|
||||
:episode-nos="diagnosisEpisodeNos"
|
||||
@locate="locateDiagnosisShot"
|
||||
/>
|
||||
</template>
|
||||
<template #actions>
|
||||
<RouterLink :to="`/projects/${project?.id}/storyboard`" class="text-button"
|
||||
>进入分镜设计<ArrowRight :size="14"
|
||||
|
||||
Reference in new issue
Block a user