feat(short-drama-agent-front): 完善分镜审核与制作准备流程

This commit is contained in:
GJ committed 2026-10-19 21:59:22 +08:00
1 parent c4b43b9725
commit 1da56e0d46
72 files changed
+2801 -528

No files matched your search

+11 -5
View File
@@ -29,7 +29,7 @@ import ActionExceptionRepair from './components/ActionExceptionRepair.vue'
import { useBreakdownQuality } from './useBreakdownQuality'
import { useBreakdownStartPolicy } from './useBreakdownStartPolicy'
import type { DiagnosisLocation } from './diagnosis'
import { errorMessage } from '../../lib/http'
import { ApiError, errorMessage } from '../../lib/http'
import { downloadText } from '../../lib/format'
/** 拆解工作区:先预览真实分组,再启动;恢复操作根据 checkpoint 分阶段展示。 */
@@ -436,7 +436,9 @@ async function loadPreview() {
async function run(action: BreakdownAction) {
if (project.value?.status !== 'completed' || operation.value.pending || error.value) return
if (breakdownBusy.value || backgroundExecution.discovering.value || backgroundExecution.discoveryError.value) return
if (action === 'start' && (!canStart.value || !startPolicy.consumePermit())) return
if (action === 'start' && !canStart.value) return
const permit = action === 'start' ? startPolicy.consumePermit() : null
if (action === 'start' && !permit) return
const labels: Record<BreakdownAction, string> = {
start: '正在拆解剧本',
retry: '正在重试失败抽取',
@@ -444,17 +446,21 @@ async function run(action: BreakdownAction) {
'resume-storyboard': '正在修复分镜绑定'
}
const id = project.value.id
await runOperation(
const success = await runOperation(
id,
labels[action],
async () => {
const started = await breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
const started = await breakdownApi.run(id, action, action === 'start' ? { ...input.value, ...permit! } : undefined)
await backgroundExecution.track(started.executionId)
return started
},
{ type: 'info', content: '拆解任务已提交,可在“拆解设置”中查看进度。' }
)
await refresh()
const cause = operation.value.cause
if (!success && action === 'start' && id === projectId.value && cause instanceof ApiError &&
['QUALITY_POLICY_NOT_CONFIRMED', 'QUALITY_POLICY_VERSION_CONFLICT'].includes(cause.code ?? ''))
await startPolicy.prepare()
}
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
@@ -526,7 +532,7 @@ const rules = {
>
<!-- 以下是在同一全屏抽屉内核对真实质量规则的模块,不叠加第二个抽屉 -->
<div v-if="startPolicy.reviewOpen.value && startPolicy.policy.value" class="breakdown-policy-review">
<p class="text-sm leading-6 text-muted">请核对动作与物理规则,修改将在继续时保存。当前浏览器会记住确认,规则未变时不再重复提醒。</p>
<p class="text-sm leading-6 text-muted">请核对动作与物理规则,修改将在继续时保存。确认会保存到当前项目,规则未变时不再重复提醒。</p>
<QualityPolicySettings
ref="qualityForm"
:key="startPolicy.editorKey.value"
+33 -3
View File
@@ -1,3 +1,4 @@
import type { DiagnosisPreflight, DiagnosisHistory, DiagnosisRepairReadiness } from './diagnosis.types'
import { optionalResource, request } from '../../lib/http'
import type {
BreakdownAction,
@@ -23,6 +24,35 @@ import type {
/** Breakdown API;预览为只读查询,启动和恢复返回可持续观察的后台任务。 */
export const breakdownApi = {
/**
* 只读核对指定正式镜头的诊断来源及可复用记录。
* @param id 项目编号
* @param shotId 正式镜头编号
* @param signal 取消信号
* @returns 不调用模型的检查结果
*/
diagnosisPreflight: (id: string, shotId: string, signal?: AbortSignal) =>
request<DiagnosisPreflight>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnosis-preflight/${encodeURIComponent(shotId)}`, { signal }),
/**
* 查看指定镜头的诊断历史及版本失效情况。
* @param id 项目编号
* @param shotId 正式镜头编号
* @param signal 取消信号
* @returns 最近诊断历史
*/
diagnosisHistory: (id: string, shotId: string, signal?: AbortSignal) =>
request<DiagnosisHistory>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnoses/${encodeURIComponent(shotId)}`, { signal }),
/**
* 核对指定诊断能否进入人工修订,不自动应用建议。
* @param id 项目编号
* @param shotId 正式镜头编号
* @param diagnosisId 真实诊断编号
* @param signal 取消信号
* @returns 候选及资产、来源和版本限制
*/
diagnosisRepairReadiness: (id: string, shotId: string, diagnosisId: string, signal?: AbortSignal) =>
request<DiagnosisRepairReadiness>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-repair-readiness/${encodeURIComponent(shotId)}/${encodeURIComponent(diagnosisId)}`, { signal }),
/**
* 只读重新审核当前候选,不提供正式提交许可。
* @param id 当前项目
@@ -103,17 +133,17 @@ export const breakdownApi = {
},
handOccupancyDiagnostics: (id: string, signal?: AbortSignal) =>
request<StoryboardHandOccupancyDiagnostics>(
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-diagnostics`,
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-action-resource-diagnostics`,
{ signal }
),
handRepairPreview: (id: string, signal?: AbortSignal) =>
request<StoryboardHandRepairPreview>(
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-preview`,
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-action-resource-repair-preview`,
{ signal }
),
handRepairHistory: (id: string, shotId: string, signal?: AbortSignal) =>
request<StoryboardHandRepairHistory>(
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-history/${encodeURIComponent(shotId)}`,
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-shot-revision-history/${encodeURIComponent(shotId)}`,
{ signal }
),
legacyActionDiagnosisPreview: (id: string, episodeNo: number, beatNo?: number, shotNo?: number) => {
+2 -1
View File
@@ -3,6 +3,7 @@ import type { CandidateCommitPreview } from './candidate.types'
/** 安全检查项与用户可理解的阻断原因共用一份映射。 */
export const candidateCheckLabels: Record<keyof CandidateCommitPreview['checks'], string> = {
qualityPolicyMatches: '质量规则与当前已确认版本一致',
episodeNumbersMatch: '剧集范围与候选一致',
episodeFingerprintsMatch: '剧本正文版本未变化',
noActiveExecutions: '没有正在执行的制作任务',
@@ -12,7 +13,7 @@ export const candidateCheckLabels: Record<keyof CandidateCommitPreview['checks']
noProtectedShots: '没有需要保护的镜头资产'
}
/** 必须逐项校验的固定安全门禁,不根据响应动态减少检查项。 */
export const candidateCheckKeys = ['episodeNumbersMatch', 'episodeFingerprintsMatch', 'noActiveExecutions', 'noActiveVideos', 'noSubjectIdentities', 'noSubjectImages', 'noProtectedShots'] as const
export const candidateCheckKeys = ['qualityPolicyMatches', 'episodeNumbersMatch', 'episodeFingerprintsMatch', 'noActiveExecutions', 'noActiveVideos', 'noSubjectIdentities', 'noSubjectImages', 'noProtectedShots'] as const
/**
* 安全预检查必须逐项通过且属于当前项目和候选,不能只相信 ready。
@@ -120,6 +120,8 @@ export interface CandidateCommitPreview {
ready: boolean
/** 剧本版本、活动任务及下游资产保护。 */
checks: {
/** 候选使用的质量规则与当前明确确认版本一致。 */
qualityPolicyMatches: boolean
/** 剧集编号一致。 */
episodeNumbersMatch: boolean
/** 剧本正文指纹一致。 */
@@ -6,7 +6,7 @@ import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHead
import QualityPolicyExceptions from '../../generation-config/components/QualityPolicyExceptions.vue'
import { projectsApi } from '../../projects/api'
import { actionResourceOptions, policyDraft } from '../../projects/quality-policy'
import { invalidateQualityPolicyConfirmation, qualityPolicySignature } from '../../projects/quality-policy-confirmation'
import { validateQualityPolicyReceipt, qualityPolicySignature } from '../../projects/quality-policy-confirmation'
import type { ProjectQualityPolicyResult } from '../../projects/types'
import { getOperation, runOperation } from '../../workflows/operations'
import { actionExceptionTargets, type ActionExceptionTarget } from '../action-exceptions'
@@ -71,9 +71,8 @@ let controller: AbortController | undefined
*/
async function read(id: string, signal: AbortSignal): Promise<ProjectQualityPolicyResult> {
const result = await projectsApi.qualityPolicy(id, signal)
if (result.projectId !== id) throw new Error('规则所属项目不一致,请重新读取。')
qualityPolicySignature(result.policy)
return { projectId: id, policy: policyDraft(result.policy) }
validateQualityPolicyReceipt(result, id)
return { ...result, policy: policyDraft(result.policy) }
}
/** 按需读取已有规则;无真实拆解结果时不创建例外。 */
@@ -152,11 +151,11 @@ async function save() {
const signature = qualityPolicySignature(input)
writing.value = true
const success = await runOperation(id, '正在保存动作例外', async () => {
const result = await projectsApi.saveQualityPolicy(id, input)
invalidateQualityPolicyConfirmation(id)
const result = await projectsApi.saveQualityPolicy(id, input, latest.revision)
validateQualityPolicyReceipt(result, id)
if (result.projectId !== id || qualityPolicySignature(result.policy) !== signature)
throw new Error('规则保存回执与提交内容不一致,请重新读取确认。')
if (version === generation) receipt.value = { projectId: id, policy: policyDraft(result.policy) }
if (version === generation) receipt.value = { ...result, policy: policyDraft(result.policy) }
}, { type: 'info', content: '动作例外已保存,当前分镜仍需审核,不会自动放行提交。' })
if (version !== generation) return
if (success) {
@@ -0,0 +1,120 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
import { RefreshCw, History } from '@lucide/vue'
import { preparationApi } from '../../storyboard-preparation/api'
import type { StoryboardHandRepairHistory } from '../types'
import { breakdownApi } from '../api'
import { diagnosisReason, diagnosisStatusLabels } from '../diagnosis'
import type { DiagnosisHistory, DiagnosisRepairReadiness } from '../diagnosis.types'
import type { LegacyActionDiagnosisResults } from '../types'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import { errorMessage } from '../../../lib/http'
import { userFacingText } from '../../../lib/user-facing-text'
import { formatDate } from '../../../lib/format'
/** 单镜头按需核对修订条件和历史,不从诊断建议拼装可写草稿。 */
const props = defineProps<{
/** 所属正式项目。 */
projectId: string
/** 当前列表记录,切换版本后旧请求失效。 */
shot: LegacyActionDiagnosisResults['shots'][number]
}>()
/** 默认收起,避免对全项目每个镜头预先发起请求。 */
const expanded = ref<string[]>([])
/** 明确的按钮控制 Naive 折叠,折叠标题不再伪装成卡片操作。 */
const showDetails = computed(() => expanded.value.includes('review'))
/** 当前真实诊断历史。 */
const history = ref<DiagnosisHistory | null>(null)
/** 正式动作和主体修订共用的不可变记录。 */
const revisions = ref<StoryboardHandRepairHistory | null>(null)
/** 当前诊断对应的修订资格。 */
const readiness = ref<DiagnosisRepairReadiness | null>(null)
/** 当前列表与资格必须同时有效,不能把旧诊断或直接应用标记解释成修订许可。 */
const repairEligible = computed(() => readiness.value?.eligible === true && readiness.value.requiresManualReview === true &&
readiness.value.canApplyDirectly === false && readiness.value.willCallModel === false && readiness.value.willModifyAssets === false &&
props.shot.status === 'conflict_found' && props.shot.policyStatus === 'current' && props.shot.shotStale === false)
/** 只读请求加载,始终允许关闭主窗口。 */
const loading = ref(false)
/** 保留可重试的查询错误。 */
const error = ref('')
/** 同镜头诊断和版本状态组成请求身份。 */
const target = computed(() => JSON.stringify([props.projectId, props.shot.shotId, props.shot.diagnosisId, props.shot.policyStatus, props.shot.shotStale, props.shot.latestRepairId]))
/** 请求代次用于拦截迟到结果。 */
let version = 0
/** 只读请求关闭时取消。 */
let controller: AbortController | undefined
/** 读取指定镜头历史与对应诊断资格,始终验证返回归属。 */
async function load() {
if (loading.value) return
const current = ++version
const id = props.projectId, shotId = props.shot.shotId, diagnosisId = props.shot.diagnosisId
controller?.abort(); controller = new AbortController()
loading.value = true; error.value = ''
try {
const [records, checked, changes] = await Promise.all([
breakdownApi.diagnosisHistory(id, shotId, controller.signal),
diagnosisId ? breakdownApi.diagnosisRepairReadiness(id, shotId, diagnosisId, controller.signal) : Promise.resolve(null),
preparationApi.revisions(id, shotId, controller.signal)
])
if (current !== version) return
if (changes.projectId !== id || changes.shotId !== shotId || !Array.isArray(changes.revisions) || records.projectId !== id || records.shotId !== shotId || !Array.isArray(records.revisions) ||
checked && (checked.projectId !== id || checked.shotId !== shotId || checked.diagnosisId !== diagnosisId))
throw new Error('记录与当前镜头不一致,请重新读取。')
history.value = records; readiness.value = checked; revisions.value = changes
} catch (cause) { if (current === version) error.value = errorMessage(cause) }
finally { if (current === version) loading.value = false }
}
/** 收起或切换上下文时废弃旧请求,不把旧资格沿用到新版本。 */
function reset() { version++; controller?.abort(); loading.value = false; history.value = null; readiness.value = null; revisions.value = null; error.value = '' }
watch(expanded, value => { if (value.includes('review')) void load(); else reset() })
watch(target, () => { reset(); if (expanded.value.includes('review')) void load() })
onScopeDispose(reset)
</script>
<template>
<!-- 以下是指定诊断的只读修订条件与历史记录,普通列表不暴露内部编号 -->
<div class="diagnosis-shot-tools">
<NButton size="small" :aria-label="showDetails ? '收起修订条件与历史' : '修订条件与诊断历史'" :title="showDetails ? '收起修订条件与历史' : '修订条件与诊断历史'" :aria-expanded="showDetails" @click="expanded = showDetails ? [] : ['review']"><template #icon><History :size="15" aria-hidden="true" /></template><span class="diagnosis-action-label">{{ showDetails ? '收起修订条件与历史' : '修订条件与诊断历史' }}</span></NButton>
<NCollapse v-show="showDetails" v-model:expanded-names="expanded" class="diagnosis-shot-details">
<NCollapseItem name="review" title="修订条件与诊断历史">
<div class="space-y-3 text-xs leading-6">
<NButton size="small" :loading="loading" @click="load"><template #icon><RefreshCw :size="14" aria-hidden="true" /></template>刷新记录</NButton>
<p v-if="error" class="text-danger" role="alert">{{ error }}</p>
<p v-if="loading" role="status" class="text-muted">正在核对当前镜头记录…</p>
<section v-if="readiness" class="space-y-2" aria-label="当前诊断修订条件">
<p>{{ repairEligible ? '已满足人工修订的前提,仍需人工核对完整动作。' : '当前暂不能按这份诊断修订镜头。' }}</p>
<p v-for="reason in readiness.blockingReasons" :key="reason" class="text-muted">{{ diagnosisReason(reason) }}</p>
<p v-if="repairEligible" class="text-muted">可点击“查看并修订动作”,读取当前正式规划后再明确保存。</p>
<article v-for="(candidate, index) in readiness.repairCandidates" :key="index" class="space-y-1">
<p>阶段 {{ candidate.phaseNo }} · {{ candidate.characterRef }}</p><p>{{ userFacingText(candidate.suggestion) }}</p>
</article>
</section>
<section v-if="revisions" class="space-y-3" aria-label="正式修订历史">
<p class="font-medium">正式修订 · {{ revisions.count }} 条</p>
<p v-if="!revisions.revisions.length" class="text-muted">尚无保存的正式修订。</p>
<article v-for="record in revisions.revisions" :key="record.id" class="space-y-1"><p class="text-muted">{{ formatDate(record.createdAt) }}</p><p>{{ record.reason }}</p></article>
</section>
<section v-if="history" class="space-y-3" aria-label="诊断历史">
<p v-if="!history.revisions.length" class="text-muted">尚无保存的诊断记录。</p>
<article v-for="record in history.revisions" :key="record.id" class="space-y-1">
<p>{{ formatDate(record.createdAt) }} · {{ diagnosisStatusLabels[record.effectiveStatus as keyof typeof diagnosisStatusLabels] || '结果待核对' }}</p>
<p class="text-muted">{{ record.shotStale ? '镜头已变化' : '镜头内容一致' }} · {{ record.policyStatus === 'current' ? '规则版本一致' : record.policyStatus === 'stale' ? '规则版本已变化' : '缺少规则版本' }}</p>
<RawDataDetails :value="record" title="完整诊断证据(高级)" />
</article>
</section>
</div>
</NCollapseItem>
</NCollapse>
</div>
</template>
<style scoped>
.diagnosis-shot-tools { display: contents; }
.diagnosis-shot-tools > .n-button { min-height: 34px; }
/* 展开仍由 Naive 组件管理;入口使用独立可聚焦按钮,避免重复折叠标题。 */
.diagnosis-shot-details { flex-basis: 100%; min-width: 0; }
.diagnosis-shot-details :deep(.n-collapse-item__header) { display: none; }
.diagnosis-shot-details :deep(.n-collapse-item__content-wrapper) { padding-top: 16px; }
</style>
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { Trash2 } from '@lucide/vue'
import type { ResourceOccupancy } from '../repair.types'
import { computed } from 'vue'
import { NButton, NCheckbox, NFormItem, NInput, NInputNumber, NSelect } from 'naive-ui'
import { actionResourceOptions } from '../../projects/quality-policy'
@@ -70,6 +72,24 @@ function addEvidence(index: number, kind: 'hand' | 'resource') {
shareable: false
})
}
/**
* 保留明确的持续对象,清空时删除可选字段,不提交非法空字符串。
* @param resource 当前资源证据
* @param value 用户输入的对象引用
*/
function updateContinuity(resource: ResourceOccupancy, value: string) {
if (value.trim()) resource.continuityRef = value
else delete resource.continuityRef
}
/**
* 只记录明确释放或交接;清空不猜测隐含事件。
* @param resource 当前资源证据
* @param value 用户选择的事件
*/
function updateTransition(resource: ResourceOccupancy, value: 'release' | 'transfer' | null) {
if (value) resource.transition = value
else delete resource.transition
}
</script>
<template>
@@ -103,7 +123,7 @@ function addEvidence(index: number, kind: 'hand' | 'resource') {
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="action.mustPerformInShot" :disabled="disabled">本镜必须完成</NCheckbox>
<NButton :disabled="disabled" @click="draft.requiredActions.splice(index, 1)">移除</NButton>
<NButton class="icon-button" :aria-label="`移除动作 ${index + 1}`" :disabled="disabled" @click="draft.requiredActions.splice(index, 1)"><template #icon><Trash2 :size="16" /></template></NButton>
</div>
</section>
<!-- 以下是动作阶段编辑模块,同阶段动作视为同时发生 -->
@@ -123,9 +143,7 @@ function addEvidence(index: number, kind: 'hand' | 'resource') {
>
<div class="flex flex-wrap items-center justify-between gap-3">
<h4 class="text-sm">阶段 {{ index + 1 }}</h4>
<NButton text :disabled="disabled" @click="draft.durationPlanning.phases.splice(index, 1)"
>移除阶段</NButton
>
<NButton class="icon-button" :aria-label="`移除阶段 ${index + 1}`" :disabled="disabled" @click="draft.durationPlanning.phases.splice(index, 1)"><template #icon><Trash2 :size="16" /></template></NButton>
</div>
<NFormItem label="阶段描述"
><NInput v-model:value="phase.action" :aria-label="`阶段 ${index + 1} 描述`" :disabled="disabled"
@@ -181,7 +199,7 @@ function addEvidence(index: number, kind: 'hand' | 'resource') {
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="hand.shareable" :disabled="disabled">可共享</NCheckbox>
<NButton :disabled="disabled" @click="phase.handOccupancy?.splice(handIndex, 1)">移除</NButton>
<NButton class="icon-button" :aria-label="`移除阶段 ${index + 1} 手部证据 ${handIndex + 1}`" :disabled="disabled" @click="phase.handOccupancy?.splice(handIndex, 1)"><template #icon><Trash2 :size="16" /></template></NButton>
</div>
<div
v-for="(resource, resourceIndex) in phase.resourceOccupancy"
@@ -217,9 +235,9 @@ function addEvidence(index: number, kind: 'hand' | 'resource') {
:disabled="disabled"
/></NFormItem>
<NCheckbox v-model:checked="resource.shareable" :disabled="disabled">可共享</NCheckbox>
<NButton :disabled="disabled" @click="phase.resourceOccupancy?.splice(resourceIndex, 1)"
>移除</NButton
>
<NFormItem label="持续对象" :show-feedback="false"><NInput :value="resource.continuityRef || ''" placeholder="仅填写已有明确对象引用" :disabled="disabled" @update:value="updateContinuity(resource, $event)" /></NFormItem>
<NFormItem label="释放或交接" :show-feedback="false"><NSelect :value="resource.transition ?? null" clearable :options="[{ label: '明确释放', value: 'release' }, { label: '明确交接', value: 'transfer' }]" placeholder="未声明" :disabled="disabled" @update:value="updateTransition(resource, $event)" /></NFormItem>
<NButton class="icon-button" :aria-label="`移除阶段 ${index + 1} 资源证据 ${resourceIndex + 1}`" :disabled="disabled" @click="phase.resourceOccupancy?.splice(resourceIndex, 1)"><template #icon><Trash2 :size="16" /></template></NButton>
</div>
</section>
</section>
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NCollapse, NCollapseItem, NInputNumber, NSelect, NSpin, NTag } from 'naive-ui'
import { RefreshCw, ScanLine } from '@lucide/vue'
import { RefreshCw, ScanLine, MapPin, RotateCcw, Wrench } from '@lucide/vue'
import { breakdownApi } from '../api'
import { diagnosisInput, diagnosisStatusLabels, scopeDiagnosisShots, summarizeDiagnosis } from '../diagnosis'
import { diagnosisInput, diagnosisStatusLabels, scopeDiagnosisShots, summarizeDiagnosis, diagnosisHasAttention, diagnosisCanStart, diagnosisReason, handAuditLabels, resourceAuditLabels, bodyDimensionLabels } from '../diagnosis'
import type { DiagnosisLocation, DiagnosisScope } from '../diagnosis'
import type {
LegacyActionDiagnosisPreview,
@@ -14,8 +14,13 @@ import type {
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
import { useWorkflowExecution } from '../../workflows/execution'
import { AppDialog } from '../../../components/ui'
import { AppDrawer } from '../../../components/ui'
import { useActionMessage } from '../../../components/ui/useActionMessage'
import FormalRepairDrawer from '../../storyboard-preparation/FormalRepairDrawer.vue'
import type { PreparationIssue } from '../../storyboard-preparation/types'
import DiagnosisShotDetails from './DiagnosisShotDetails.vue'
import type { DiagnosisPreflight } from '../diagnosis.types'
import { userFacingText } from '../../../lib/user-facing-text'
import { errorMessage } from '../../../lib/http'
/** 当前分镜上下文;诊断入口与列表共用同一个正式剧集。 */
@@ -36,12 +41,18 @@ const execution = useWorkflowExecution(
computed(() => props.projectId),
'storyboard-legacy-action-diagnosis'
)
/** 居中诊断弹窗是否打开。 */
/** 全屏诊断抽屉是否打开。 */
const dialogOpen = ref(false)
/** 首批诊断数据完成前保留固定加载区域,不渲染会闪现的空结果。 */
const dialogDataReady = ref(false)
/** 等待弹窗离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
const pendingLocation = ref<DiagnosisLocation | null>(null)
/** 等诊断抽屉离场后打开正式动作修订,不叠加主界面。 */
const pendingRepair = ref<PreparationIssue | null>(null)
/** 已交接到正式修订的真实目标。 */
const repairTarget = ref<PreparationIssue | null>(null)
/** 正式修订界面由离场事件打开。 */
const repairOpen = ref(false)
/** 本次查看及提交的诊断范围。 */
const scope = ref<DiagnosisScope>({ kind: 'project' })
/** 当前集摘要与弹窗结果分开保存,切换弹窗范围不会改变摘要含义。 */
@@ -58,6 +69,8 @@ const resultsBusy = ref(false)
const resultsError = ref('')
/** 只读范围预览;全项目按正式剧集汇总,任何一集失败都不能启动。 */
const previews = ref<LegacyActionDiagnosisPreview[] | null>(null)
/** 单镜头启动必须完成来源及版本检查。 */
const preflight = ref<DiagnosisPreflight | null>(null)
/** 只读范围预览的读取状态。 */
const previewBusy = ref(false)
/** 范围预览的读取错误。 */
@@ -121,7 +134,7 @@ const visibleShots = computed(() =>
resultFilter.value === 'all' ||
(resultFilter.value === 'pending'
? shot.status === 'not_diagnosed'
: !['not_diagnosed', 'no_conflict_found'].includes(shot.status))
: diagnosisHasAttention(shot))
)
)
/** 预览展示范围内的实际镜头总数,不把待补证据数量冒充付费数量。 */
@@ -140,7 +153,8 @@ const canStart = computed(
concurrencyValid.value &&
!previewBusy.value &&
!execution.active.value &&
!starting.value
!starting.value &&
(scope.value.kind !== 'shot' || diagnosisCanStart(preflight.value, props.projectId, previews.value?.[0]?.candidates[0]?.shotId ?? ''))
)
/** 费用确认使用当前预览范围及并发,不虚构模型价格。 */
const confirmation = computed(
@@ -214,6 +228,7 @@ async function loadPreview() {
const target = scope.value
const version = ++previewVersion
previews.value = null
preflight.value = null
previewBusy.value = true
previewError.value = ''
try {
@@ -229,7 +244,17 @@ async function loadPreview() {
)
)
)
if (version === previewVersion) previews.value = data
if (version !== previewVersion) return
if (target.kind === 'shot') {
const candidate = data[0]?.candidates[0]
if (!candidate || data.length !== 1 || data[0]!.candidates.length !== 1) throw new Error('未取得唯一的正式镜头,请刷新结果。')
const checked = await breakdownApi.diagnosisPreflight(id, candidate.shotId)
if (version !== previewVersion) return
if (checked.projectId !== id || checked.shotId !== candidate.shotId || checked.episodeNo !== target.episodeNo || checked.beatNo !== target.beatNo || checked.shotNo !== target.shotNo)
throw new Error('检查结果与当前镜头不一致,请重新预览。')
preflight.value = checked
}
previews.value = data
} catch (cause) {
if (version === previewVersion) previewError.value = errorMessage(cause)
} finally {
@@ -316,6 +341,8 @@ function issueDescriptions(issues: unknown[]) {
* @param location 可选的节拍或镜头坐标
*/
function open(location?: DiagnosisLocation) {
if (repairOpen.value) return
pendingRepair.value = null
pendingLocation.value = null
scope.value = location
? location.shotNo === undefined
@@ -339,19 +366,51 @@ function locate(location: DiagnosisLocation) {
/** 弹窗关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
function finishLocate() {
if (!pendingLocation.value) return
const location = pendingLocation.value
if (pendingLocation.value) { const location = pendingLocation.value; pendingLocation.value = null; emit('locate', location) }
if (pendingRepair.value) { repairTarget.value = pendingRepair.value; pendingRepair.value = null; repairOpen.value = true }
}
/**
* 交接到用户选中的正式镜头,不沿用旧诊断动作作为草稿。
* @param item 当前列表的真实镜头
*/
function requestRepair(item: LegacyActionDiagnosisResults['shots'][number]) {
if (!dialogOpen.value || starting.value || execution.active.value) return
pendingLocation.value = null
emit('locate', location)
pendingRepair.value = { episodeNo: item.episodeNo, beatNo: item.beatNo, shotNo: item.shotNo, shotId: item.shotId, message: `核对当前正式镜头:${item.title}` }
dialogOpen.value = false
}
/** 费用确认后提交固定范围,并保存后台任务句柄。 */
async function startDiagnosis() {
if (!canStart.value) return
const id = props.projectId
const input = diagnosisInput(scope.value, concurrency.value)
const target = scope.value
const version = previewVersion
const input = diagnosisInput(target, concurrency.value)
starting.value = true
try {
if (target.kind === 'shot') {
const previous = preflight.value
if (!previous) return
const checked = await breakdownApi.diagnosisPreflight(id, previous.shotId)
if (version !== previewVersion || !dialogOpen.value || !diagnosisCanStart(checked, id, previous.shotId)) {
if (version === previewVersion) { preflight.value = checked; void loadResults() }
return
}
const latestPreview = await breakdownApi.legacyActionDiagnosisPreview(id, target.episodeNo, target.beatNo, target.shotNo)
if (version !== previewVersion || !dialogOpen.value) return
if (JSON.stringify(latestPreview.candidates) !== JSON.stringify(previews.value?.[0]?.candidates)) {
previews.value = null
throw new Error('镜头内容已变化,请重新预览后确认诊断。')
}
preflight.value = checked
if (checked.policyRevision !== previous.policyRevision || checked.policyFingerprint !== previous.policyFingerprint) {
previews.value = null
throw new Error('诊断使用的质量规则已变化,请重新预览后确认。')
}
}
if (version !== previewVersion || !dialogOpen.value || id !== props.projectId) return
const task = await breakdownApi.startLegacyActionDiagnosis(id, input)
await execution.track(task.executionId, id)
} catch (cause) {
@@ -366,6 +425,9 @@ watch(
[() => props.projectId, () => props.episodeNo],
() => {
pendingLocation.value = null
pendingRepair.value = null
repairOpen.value = false
repairTarget.value = null
dialogOpen.value = false
++handVersion
handDiagnostics.value = null
@@ -390,6 +452,7 @@ watch(
++previewVersion
++resultsVersion
previews.value = null
preflight.value = null
previewBusy.value = false
previewError.value = ''
results.value = null
@@ -440,12 +503,12 @@ defineExpose({ open })
>
<NTag v-if="execution.active.value" type="info" size="small" :bordered="false">诊断中</NTag>
</div>
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="dialogOpen" @click="open()"
<NButton size="small" :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="dialogOpen" @click="open()"
>查看诊断</NButton
>
</div>
<!-- 以下是居中动作诊断弹窗,正文自然增高,仅超过可用视口后统一滚动 -->
<AppDialog v-model:open="dialogOpen" title="动作诊断" :width="640" @closed="finishLocate">
<!-- 以下是全屏动作诊断抽屉,正文独立滚动,操作底栏固定 -->
<AppDrawer v-model:open="dialogOpen" title="动作诊断" @closed="finishLocate">
<NSpin
:show="dialogOverlayLoading"
description="正在加载诊断数据…"
@@ -501,6 +564,7 @@ defineExpose({ open })
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
><span>未发现冲突 {{ counts.clear }}</span>
</div>
<p class="mb-3 text-xs text-muted">动作占用检查只核对已有证据,与 AI 复查、整体人工审核分别记录。</p>
<NSelect
v-model:value="resultFilter"
aria-label="筛选诊断结果"
@@ -538,7 +602,7 @@ defineExpose({ open })
tabindex="0"
aria-label="镜头诊断列表"
>
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item" :class="{ 'problem-surface': item.status === 'conflict_found' || item.status === 'invalid_evidence' || item.handAudit?.status === 'conflict_found' || item.handAudit?.status === 'invalid_evidence' }">
<div class="diagnosis-section-heading">
<span class="text-xs text-muted"
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头
@@ -548,7 +612,7 @@ defineExpose({ open })
:type="
item.status === 'conflict_found'
? 'error'
: item.status === 'no_conflict_found'
: item.status === 'no_conflict_found' && !diagnosisHasAttention(item)
? 'success'
: 'default'
"
@@ -563,9 +627,31 @@ defineExpose({ open })
:key="index"
class="text-muted"
>
{{ description }}
{{ userFacingText(description) }}
</p>
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
<!-- 以下是修订状态、局部手部检查与 AI 全身疑点,结论各自保留 -->
<p v-if="item.requiresPostRepairDiagnosis" class="text-xs text-muted">镜头已修订,AI 待复查</p>
<p v-else-if="item.repairStatus === 'repaired'" class="text-xs text-muted">镜头已修订,已有当前版本 AI 诊断</p>
<p v-else-if="item.repairStatus === 'repair_history_stale'" class="text-xs text-muted">此前修订记录已过期</p>
<p v-if="item.shotStale" class="text-xs text-muted">镜头内容已变化,旧诊断不作为当前结论。</p>
<p v-if="item.policyStatus === 'stale'" class="text-xs text-muted">质量规则已变化,需要重新核对。</p>
<p v-else-if="item.policyStatus === 'unknown'" class="text-xs text-muted">旧诊断没有完整的质量规则记录。</p>
<div v-if="item.resourceAudit" class="space-y-1 text-xs text-muted"><p>{{ resourceAuditLabels[item.resourceAudit.status] }}<template v-if="item.resourceAudit.expectedActionCount > 0"> · 已覆盖 {{ item.resourceAudit.coveredActionCount }} / {{ item.resourceAudit.expectedActionCount }} 个动作</template></p></div>
<div v-else-if="item.handAudit" class="space-y-1 text-xs text-muted">
<p>{{ handAuditLabels[item.handAudit.status] }}<template v-if="item.handAudit.expectedActionCount > 0"> · 手部动作证据 {{ item.handAudit.coveredActionCount }} / {{ item.handAudit.expectedActionCount }}</template></p>
</div>
<article v-for="(finding, index) in item.bodyMotionFindings" :key="index" class="space-y-1 text-xs">
<p>{{ bodyDimensionLabels[finding.dimension] || '其他动作' }} · {{ finding.status === 'conflict' ? '发现冲突' : finding.status === 'needs_review' ? '需要复核' : '证据不足' }}</p>
<p>{{ userFacingText(finding.description) }}</p><p class="text-muted">原文:{{ finding.quote }}</p>
</article>
<!-- 以下是明确的卡片操作区,按钮有独立底面和图标,不与说明混在一起 -->
<div class="diagnosis-card-actions workspace-action-group">
<NButton size="small" aria-label="定位镜头" title="定位镜头" @click="locate(item)"><template #icon><MapPin :size="15" aria-hidden="true" /></template><span class="diagnosis-action-label">定位镜头</span></NButton>
<NButton v-if="item.requiresPostRepairDiagnosis || item.status === 'stale' || item.status === 'not_diagnosed'" size="small" aria-label="复查本镜头" title="复查本镜头" :disabled="starting || execution.active.value" @click="open(item)"><template #icon><RotateCcw :size="15" aria-hidden="true" /></template><span class="diagnosis-action-label">复查本镜头</span></NButton>
<NButton size="small" aria-label="查看并修订动作" title="查看并修订动作" :disabled="starting || execution.active.value" @click="requestRepair(item)"><template #icon><Wrench :size="15" aria-hidden="true" /></template><span class="diagnosis-action-label">查看并修订动作</span></NButton>
<DiagnosisShotDetails :project-id="projectId" :shot="item" />
</div>
</article>
</div>
</template>
@@ -677,6 +763,11 @@ defineExpose({ open })
{{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
</p>
</div>
<div v-if="preflight" class="mt-3 space-y-2 text-xs" :class="preflight.errors.length ? 'problem-surface p-4' : 'text-muted'">
<p v-if="preflight.existingValid">本镜头已有同版本有效诊断,无需重复调用模型。</p>
<p v-for="code in preflight.errors" :key="code">{{ diagnosisReason(code) }}</p>
<p v-if="preflight.shouldDiagnose">已完成来源预检查,正式诊断仍会再次核对当前版本。</p>
</div>
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
@@ -714,7 +805,9 @@ defineExpose({ open })
@confirm="startDiagnosis"
/>
</template>
</AppDialog>
</AppDrawer>
<!-- 以下是等待诊断抽屉关闭后才打开的正式动作修订模块 -->
<FormalRepairDrawer v-model:open="repairOpen" :project-id="projectId" :issue="repairTarget" @saved="loadSummary" />
</template>
<style>
@@ -731,15 +824,16 @@ defineExpose({ open })
}
/* 加载占位保留最低高度,正文可随内容自然增高,最大高度由公共弹窗按视口限制。 */
.diagnosis-dialog-body {
min-height: min(600px, calc(100dvh - 160px));
min-height: 240px;
}
.diagnosis-dialog-content {
@apply space-y-4;
display: grid;
gap: 24px;
padding-bottom: 4px;
}
/* 各分区使用主题次级底色和留白区分,移除贯穿弹窗的分隔线。 */
.diagnosis-section {
@apply p-4 bg-(--app-subtle) text-sm leading-6;
@apply text-sm leading-6;
}
.diagnosis-section h3,
.diagnosis-evidence-title {
@@ -782,6 +876,12 @@ defineExpose({ open })
.diagnosis-result-item {
@apply p-3 bg-(--app-control) space-y-2;
}
.diagnosis-result-item.problem-surface {
background: var(--app-danger-soft);
}
.diagnosis-card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.diagnosis-card-actions .n-button { min-height: 34px; }
.diagnosis-result-item { padding: 20px; }
.diagnosis-result-item .n-tag {
flex-shrink: 0;
}
@@ -801,6 +901,10 @@ defineExpose({ open })
.diagnosis-repair {
@apply bg-(--app-surface) p-3 mt-3;
}
@media (max-width: 639px) {
.diagnosis-card-actions .diagnosis-action-label { display: none; }
.diagnosis-card-actions .n-button { min-width: 34px; padding-inline: 8px; }
}
@media (max-width: 760px) {
.storyboard-diagnosis-summary {
@apply items-start;
+63 -1
View File
@@ -1,3 +1,5 @@
import { userFacingText } from '../../lib/user-facing-text'
import type { DiagnosisPreflight, DiagnosisHandAudit } from './diagnosis.types'
import type { LegacyActionDiagnosisResults } from './types'
/** 诊断及定位共用的镜头坐标。 */
@@ -72,10 +74,70 @@ const diagnosisCountKeys = {
/** 状态始终保留文字,避免仅通过颜色区分问题。 */
export const diagnosisStatusLabels = {
conflict_found: '手部冲突',
conflict_found: '动作冲突',
no_conflict_found: '未发现冲突',
insufficient_evidence: '证据不足',
invalid_evidence: '证据无效',
stale: '诊断过期',
not_diagnosed: '尚未诊断'
} as const
/**
* 来源或规则检查的内部代码使用中文指引,未知原因也不直接展示内部标识。
* @param code 服务返回的阻断原因
* @returns 可操作的中文说明
*/
export function diagnosisReason(code: string): string {
const labels: Record<string, string> = {
QUALITY_POLICY_NOT_CONFIRMED: '请先确认项目质量规则。',
QUALITY_POLICY_VERSION_CONFLICT: '质量规则已更新,请重新核对。',
QUALITY_POLICY_SNAPSHOT_UNKNOWN: '这份分镜缺少可信的质量规则记录,请先确认规则并重新生成拆解候选。',
QUALITY_POLICY_SNAPSHOT_INVALID: '分镜的质量规则记录不完整,请重新生成拆解候选。',
QUALITY_POLICY_SNAPSHOT_STALE: '分镜与质量规则版本不一致,请核对最新拆解结果。',
STORYBOARD_SOURCE_MISMATCH: '镜头与已提交分镜不一致,请刷新最新结果后核对。'
}
return labels[code.split(':')[0]!] ?? userFacingText(code, '当前镜头暂不满足检查条件,请刷新后核对。')
}
/**
* 单镜头预检查只能提供当前范围的执行前提,不替代实际执行中的再次检查。
* @param value 只读预检查
* @param projectId 当前项目
* @param shotId 当前正式镜头
* @returns 是否可以进入费用确认
*/
export function diagnosisCanStart(value: DiagnosisPreflight | null, projectId: string, shotId: string): boolean {
return !!value && value.projectId === projectId && value.shotId === shotId &&
value.eligibleForFurtherValidation === true && value.shouldDiagnose === true && value.existingValid === false &&
Array.isArray(value.errors) && value.errors.length === 0 && value.requiresExecutionValidation === true &&
Number.isSafeInteger(value.policyRevision) && value.policyRevision! >= 0 &&
typeof value.policyFingerprint === 'string' && /^[a-f\d]{64}$/.test(value.policyFingerprint) &&
value.willCallModel === false && value.willModifyAssets === false
}
/**
* 待复查和全身疑点即使没有手部冲突,也需要留在默认问题列表。
* @param shot 当前镜头诊断
* @returns 是否需要用户关注
*/
export function diagnosisHasAttention(shot: LegacyActionDiagnosisResults['shots'][number]): boolean {
return !['not_diagnosed', 'no_conflict_found'].includes(shot.status) || shot.requiresPostRepairDiagnosis === true ||
!!shot.bodyMotionFindings?.length || !!(shot.resourceAudit ?? shot.handAudit) && ['conflict_found', 'invalid_evidence', 'invalid_snapshot'].includes((shot.resourceAudit ?? shot.handAudit)!.status)
}
/** 免费手部检查的结论,不能据此标记 AI 已通过。 */
export const handAuditLabels: Record<DiagnosisHandAudit['status'], string> = {
insufficient_evidence: '手部证据不足', invalid_snapshot: '镜头记录不完整', invalid_evidence: '手部证据无效',
conflict_found: '手部仍有冲突', partial_evidence: '部分动作缺少手部证据', no_conflict_found: '现有手部证据未发现冲突'
}
/** 全身动作维度的中文说明。 */
export const bodyDimensionLabels: Record<string, string> = {
feet: '脚部动作', balance: '身体平衡', gaze: '视线方向', prop_interaction: '道具交互',
physical_continuity: '动作衔接', cross_shot_continuity: '镜头间衔接'
}
/** 通用动作资源结论不冒充覆盖全部剧情语义。 */
export const resourceAuditLabels: typeof handAuditLabels = {
insufficient_evidence: '动作占用证据不足', invalid_snapshot: '镜头记录不完整', invalid_evidence: '动作占用证据无效',
conflict_found: '动作占用仍有冲突', partial_evidence: '部分动作缺少占用证据', no_conflict_found: '现有动作占用证据未发现冲突'
}
+122
View File
@@ -0,0 +1,122 @@
import type { StoryboardHandRepairPreview } from './types'
/** 单镜头只读检查,实际诊断仍需再次核对来源。 */
export interface DiagnosisPreflight {
/** 所属项目。 */
projectId: string
/** 正式镜头编号。 */
shotId: string
/** 剧集编号。 */
episodeNo: number
/** 剧情段落编号。 */
beatNo: number
/** 段落内镜头编号。 */
shotNo: number
/** 已提交分镜采用的规则修订。 */
policyRevision: number | null
/** 已提交规则内容版本。 */
policyFingerprint: string | null
/** 当前可复用的历史诊断。 */
existingDiagnosisId: string | null
/** 是否已有同规则及镜头版本的有效诊断。 */
existingValid: boolean
/** 是否可以继续执行检查。 */
eligibleForFurtherValidation: boolean
/** 阻断原因,展示时映射中文。 */
errors: string[]
/** 执行时必须再次检查。 */
requiresExecutionValidation: true
/** 是否确实需要新诊断。 */
shouldDiagnose: boolean
/** 当前查询不调用模型。 */
willCallModel: false
/** 当前查询不修改资产。 */
willModifyAssets: false
}
/** 全身动作疑点,不确定结论保持待复核。 */
export interface BodyMotionFinding {
/** 检查维度,兼容未来新增维度。 */
dimension: string
/** 模型建议的结论。 */
status: 'conflict' | 'needs_review' | 'insufficient_evidence'
/** 问题说明。 */
description: string
/** 当前镜头的原文证据。 */
quote: string
/** 可选的关联镜头编号。 */
relatedShotNo?: number
}
/** 不调用模型的手部证据复检,与 AI 诊断独立。 */
export interface DiagnosisHandAudit {
/** 证据完整性或冲突结论。 */
status: 'insufficient_evidence' | 'invalid_snapshot' | 'invalid_evidence' | 'conflict_found' | 'partial_evidence' | 'no_conflict_found'
/** 检出的冲突数。 */
issueCount: number
/** 有效证据数量。 */
evidenceCount: number
/** 需要覆盖的必需动作数。 */
expectedActionCount: number
/** 已有证据覆盖的必需动作数。 */
coveredActionCount: number
/** 覆盖率,无法计算时为空。 */
coverage: number | null
}
/** 诊断历史保留原始结果,分别标注镜头与规则是否过期。 */
export interface DiagnosisHistory {
/** 所属项目。 */
projectId: string
/** 正式镜头编号。 */
shotId: string
/** 本次返回条数。 */
count: number
/** 不可变诊断记录。 */
revisions: Array<{
/** 诊断编号。 */
id: string
/** 原始诊断结论。 */
status: string
/** 当前有效结论。 */
effectiveStatus: string
/** 镜头是否变化。 */
shotStale: boolean
/** 规则对应情况。 */
policyStatus: 'unknown' | 'current' | 'stale'
/** 任一版本过期均不可作为当前结果。 */
stale: boolean
/** 诊断使用的规则修订。 */
qualityPolicyRevision: number | null
/** 诊断模型品牌。 */
modelName: string
/** 完整问题证据仅供核对,不用于生成修订草稿。 */
issuesJson: unknown
/** 生成时间。 */
createdAt: string
}>
}
/** 指定诊断进入人工修订前的只读条件,不代表可直接覆盖镜头。 */
export interface DiagnosisRepairReadiness {
/** 所属项目。 */
projectId: string
/** 正式镜头编号。 */
shotId: string
/** 本次核对的诊断编号。 */
diagnosisId: string
/** 已通过服务检查的具体修复候选。 */
repairCandidates: StoryboardHandRepairPreview['candidates']
/** 具备人工修订前提。 */
eligible: boolean
/** 未满足的安全条件。 */
blockingReasons: string[]
/** 必须由用户复核。 */
requiresManualReview: true
/** 不允许一键直接应用。 */
canApplyDirectly: false
/** 查询不调用模型。 */
willCallModel: false
/** 查询不修改资产。 */
willModifyAssets: false
}
+2
View File
@@ -72,6 +72,8 @@ export function actionDraftIssue(draft: ShotActionDraft): string {
)
return '阶段衔接与建议时长需填写有效秒数。'
for (const phase of planning.phases) {
if (phase.resourceOccupancy?.some(item => item.transition && !item.continuityRef?.trim())) return '释放或交接需要填写明确的持续对象。'
if (phase.resourceOccupancy?.some(item => item.transition === 'release' && item.usage !== 'other')) return '明确释放不能同时声明持有或支撑,请核对资源用途。'
if (!phase.action.trim()) return '请填写每个阶段的动作描述。'
if (!Number.isFinite(phase.estimatedSeconds) || phase.estimatedSeconds <= 0) return '阶段时长必须大于 0 秒。'
const references = [
+4
View File
@@ -36,6 +36,10 @@ export interface ResourceOccupancy {
usage: 'support' | 'hold' | 'move' | 'interact' | 'other'
/** 是否允许共享。 */
shareable: boolean
/** 明确持续持有或支撑的对象。 */
continuityRef?: string
/** 明确释放或交接,不根据文本猜测。 */
transition?: 'release' | 'transfer'
}
/** 镜头完整动作时长规划,保留手部及通用资源证据。 */
+25
View File
@@ -1,3 +1,4 @@
import type { BodyMotionFinding, DiagnosisHandAudit } from './diagnosis.types'
/** 三种可配置的抽取模块,分镜并不是第四个模块。 */
export type BreakdownModule = 'character' | 'scene' | 'prop'
@@ -34,6 +35,8 @@ export interface BreakdownTask {
/** 传给预览与启动接口的相同配置。 */
export interface BreakdownInput {
/** 启动时携带已确认的服务端修订,预览无需此字段。 */
expectedRevision?: number
/** 仅生成候选,正式资产由独立确认入口提交。 */
candidateOnly?: boolean
groupSize: number
@@ -312,6 +315,28 @@ export interface LegacyActionDiagnosisResults {
shotNo: number
title: string
diagnosisId: string | null
/** 规则是否与当前版本一致,旧回执缺省时不推断有效。 */
policyStatus?: 'not_diagnosed' | 'unknown' | 'current' | 'stale'
/** 镜头内容是否已经变化。 */
shotStale?: boolean
/** 最近手部修订的有效性。 */
repairStatus?: 'not_repaired' | 'repaired' | 'repair_history_stale'
/** 当前版本缺少 AI 复查。 */
requiresPostRepairDiagnosis?: boolean
/** 当前镜头手部证据的免费检查。 */
handAudit?: DiagnosisHandAudit
/** 通用手、脚、身体、支撑与道具证据摘要,优先于旧手部摘要。 */
resourceAudit?: DiagnosisHandAudit
/** 全身动作疑点,不与手部确定性结果合并。 */
bodyMotionFindings?: BodyMotionFinding[]
/** 原诊断使用的规则修订。 */
qualityPolicyRevision?: number | null
/** 规则内容版本。 */
qualityPolicyFingerprint?: string | null
/** 最近手部修订编号。 */
latestRepairId?: string | null
/** 最近手部修订时间。 */
latestRepairAt?: string | null
status:
| 'not_diagnosed'
| 'stale'
@@ -3,8 +3,7 @@ import { projectsApi } from '../projects/api'
import { policyDraft } from '../projects/quality-policy'
import type { ProjectQualityPolicy, ProjectQualityPolicyResult } from '../projects/types'
import {
qualityPolicyConfirmationEpoch, qualityPolicySignature,
readQualityPolicyConfirmation, rememberQualityPolicyConfirmation
qualityPolicyConfirmed, qualityPolicySignature, validateQualityPolicyReceipt
} from '../projects/quality-policy-confirmation'
import { errorMessage } from '../../lib/http'
import { showActionFeedback, useActionMessage } from '../../components/ui/useActionMessage'
@@ -17,12 +16,10 @@ interface StartPermit {
scope: string
/** 本次重新读取并确认的质量规则。 */
signature: string
}
/** 存储受限时仅在当前页面有效的确认,规则变更后通过代次撤销。 */
interface SessionConfirmation extends StartPermit {
/** 当前项目在本页面的规则失效代次。 */
epoch: number
/** 服务端已确认的规则修订。 */
revision: number
/** 同修订的服务端内容版本。 */
fingerprint: string
}
/**
@@ -33,9 +30,8 @@ interface SessionConfirmation extends StartPermit {
*/
async function read(id: string, signal: AbortSignal): Promise<ProjectQualityPolicyResult> {
const result = await projectsApi.qualityPolicy(id, signal)
if (result.projectId !== id) throw new Error('质量规则所属项目不一致,请重新读取。')
qualityPolicySignature(result.policy)
return { projectId: id, policy: policyDraft(result.policy) }
validateQualityPolicyReceipt(result, id)
return { ...result, policy: policyDraft(result.policy) }
}
/**
@@ -61,7 +57,7 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
/** 用户可重试的错误反馈。 */
const error = ref('')
/** 编辑器只在服务端版本变化时重建,失败保留草稿。 */
const editorKey = computed(() => policy.value ? `${policy.value.projectId}:${qualityPolicySignature(policy.value.policy)}` : '')
const editorKey = computed(() => policy.value ? `${policy.value.projectId}:${policy.value.revision}:${policy.value.fingerprint}:${qualityPolicySignature(policy.value.policy)}` : '')
/** 应用统一消息层。 */
const message = useActionMessage()
/** 取消项目或配置变更前的旧请求。 */
@@ -70,23 +66,9 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
let generation = 0
/** 普通启动弹窗对应的规则内容。 */
let preparedSignature = ''
/** 存储不可写时,仅本次页面会话使用的确认。 */
let fallback: SessionConfirmation | null = null
/** 成功重读后才能消费的一次性启动许可。 */
/** 成功重读同修订确认后才能消费的一次性启动许可。 */
let permit: StartPermit | null = null
/**
* 判断规则内容是否经过本浏览器明确确认。
* @param id 当前项目
* @param signature 最新服务端内容
* @returns 是否允许跳过规则确认界面
*/
function confirmed(id: string, signature: string): boolean {
return readQualityPolicyConfirmation(id) === signature ||
(fallback?.projectId === id && fallback.signature === signature &&
fallback.epoch === qualityPolicyConfirmationEpoch(id))
}
/** 撤销未完成请求和启动许可,不撤销用户已经完成的规则确认。 */
function reset() {
generation++
@@ -114,7 +96,7 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
if (current !== generation || !allowed.value) return
policy.value = result
const signature = qualityPolicySignature(result.policy)
if (confirmed(id, signature)) {
if (qualityPolicyConfirmed(result)) {
preparedSignature = signature
startOpen.value = true
} else reviewOpen.value = true
@@ -135,7 +117,8 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
if (!allowed.value || busy.value || !reviewOpen.value || !policy.value) return false
const id = projectId.value
const current = ++generation
const expected = qualityPolicySignature(policy.value.policy)
const reviewed = policy.value
const expected = qualityPolicySignature(reviewed.policy)
controller?.abort()
controller = new AbortController()
const signal = controller.signal
@@ -145,7 +128,7 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
const draftSignature = qualityPolicySignature(draft)
let result = await read(id, signal)
if (current !== generation || !allowed.value) return false
if (qualityPolicySignature(result.policy) !== expected) {
if (result.revision !== reviewed.revision || result.fingerprint !== reviewed.fingerprint || qualityPolicySignature(result.policy) !== expected) {
policy.value = result
showActionFeedback(message, '质量规则已在其他位置更新,请重新核对后确认。', 'warning')
return false
@@ -153,24 +136,31 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
if (draftSignature !== expected) {
reading.value = false
saving.value = true
const saved = await projectsApi.saveQualityPolicy(id, policyDraft(draft))
const saved = await projectsApi.saveQualityPolicy(id, policyDraft(draft), result.revision)
if (current !== generation || !allowed.value) return false
if (saved.projectId !== id || qualityPolicySignature(saved.policy) !== draftSignature)
validateQualityPolicyReceipt(saved, id)
if (qualityPolicySignature(saved.policy) !== draftSignature)
throw new Error('质量规则保存结果与草稿不一致,请重新读取。')
saving.value = false
reading.value = true
result = await read(id, signal)
if (current !== generation || !allowed.value) return false
if (qualityPolicySignature(result.policy) !== draftSignature) {
policy.value = result
showActionFeedback(message, '质量规则保存后又有更新,请重新核对。', 'warning')
return false
}
result = saved
}
// 确认是独立写入;确认按钮只在用户明确核对后才调用此接口。
reading.value = false
saving.value = true
const confirmed = validateQualityPolicyReceipt(await projectsApi.confirmQualityPolicy(id, result.revision), id)
if (current !== generation || !allowed.value) return false
if (!qualityPolicyConfirmed(confirmed) || confirmed.revision !== result.revision ||
confirmed.fingerprint !== result.fingerprint || qualityPolicySignature(confirmed.policy) !== draftSignature)
throw new Error('质量规则确认结果不一致,请重新核对。')
saving.value = false
reading.value = true
result = await read(id, signal)
if (current !== generation || !allowed.value) return false
if (!qualityPolicyConfirmed(result) || result.revision !== confirmed.revision || result.fingerprint !== confirmed.fingerprint) {
policy.value = result
showActionFeedback(message, '质量规则已变化,请重新核对后确认。', 'warning')
return false
}
const signature = qualityPolicySignature(result.policy)
const persisted = rememberQualityPolicyConfirmation(id, signature)
fallback = persisted ? null : { projectId: id, scope: scope.value, signature, epoch: qualityPolicyConfirmationEpoch(id) }
if (!persisted) showActionFeedback(message, '当前浏览器未能记住确认,下次进入时可能再次提醒。', 'info')
policy.value = result
preparedSignature = signature
reviewOpen.value = false
@@ -204,7 +194,7 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
const result = await read(id, controller.signal)
if (current !== generation || !allowed.value) return false
const signature = qualityPolicySignature(result.policy)
if (signature !== preparedSignature || !confirmed(id, signature)) {
if (signature !== preparedSignature || !qualityPolicyConfirmed(result) || result.revision !== policy.value?.revision || result.fingerprint !== policy.value?.fingerprint) {
policy.value = result
preparedSignature = ''
startOpen.value = false
@@ -212,7 +202,7 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
showActionFeedback(message, '质量规则已变化,请重新确认后再启动拆解。', 'warning')
return false
}
permit = { projectId: id, scope: currentScope, signature }
permit = { projectId: id, scope: currentScope, signature, revision: result.revision, fingerprint: result.fingerprint }
startOpen.value = false
return true
} catch (cause) {
@@ -225,14 +215,15 @@ export function useBreakdownStartPolicy(projectId: Ref<string>, scope: Ref<strin
}
/**
* 消费同项目、同预览范围的本地一次性启动许可;后端仍需要独立门禁。
* @returns 是否允许本次提交
* 消费同项目、同预览范围的本地一次性启动许可,真实写入仍由服务事务复查。
* @returns 本次确认的服务修订,缺少许可时为空
*/
function consumePermit(): boolean {
function consumePermit(): { expectedRevision: number } | null {
const current = permit
permit = null
return !!current && allowed.value && current.projectId === projectId.value &&
current.scope === scope.value && confirmed(current.projectId, current.signature)
return current && allowed.value && current.projectId === projectId.value && current.scope === scope.value &&
policy.value && qualityPolicyConfirmed(policy.value) && current.revision === policy.value.revision &&
current.fingerprint === policy.value.fingerprint ? { expectedRevision: current.revision } : null
}
/** 用户取消只读确认时撤销未完成请求,保存请求进行中禁止重复取消。 */