fix(short-drama-agent-front): 修复首帧当前质量展示
This commit is contained in:
1 parent
13efe5b786
commit
8674ba0c83
18 files changed
+679
-137
No files matched your search
@@ -6,8 +6,7 @@ import { productionMessage } from '../production-messages'
|
||||
import { useKeyframeVision } from '../keyframe-vision'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import SourceReviewDrawer from './SourceReviewDrawer.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { qualityApi } from '../quality-api'
|
||||
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
|
||||
import { NButton, NTag } from 'naive-ui'
|
||||
import { AssetImage, AssetOpenLink, StatusBadge } from '../../../components/ui'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
@@ -69,23 +68,16 @@ watch(
|
||||
)
|
||||
/** 画幅不符的历史图保留浏览和只读审核记录。 */
|
||||
const wrongCanvas = computed(() => props.item.canvasDiagnosis?.status === 'mismatch')
|
||||
/** 质量状态以数据库为准;会话内检查仅在历史状态未知时兜底。 */
|
||||
/** 查询范围包含项目及来源证据,切换立即取消旧请求。 */
|
||||
const reviewKey = computed(() =>
|
||||
props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id, props.reviewRevision ?? 0]) : ''
|
||||
props.item.status === 'completed'
|
||||
? JSON.stringify([props.shotId, props.item.id, props.projectId, props.reviewRevision ?? 0, props.item])
|
||||
: ''
|
||||
)
|
||||
const reviewQuery = useQuery(reviewKey, (value, signal) => {
|
||||
if (!value) return Promise.resolve(null)
|
||||
const [shotId, keyframeId] = JSON.parse(value) as [string, string, number]
|
||||
return qualityApi.keyframeQualityReview(shotId, keyframeId, signal)
|
||||
})
|
||||
const effectiveStatus = computed(() => reviewQuery.data.value?.effectiveQualityStatus ?? 'unknown')
|
||||
/** 其余未达可用门禁的独立质量状态。 */
|
||||
const reviewLabels: Record<string, string> = {
|
||||
stale: '审核来源过期',
|
||||
blocked: '质量受阻',
|
||||
insufficient_evidence: '审核证据不足',
|
||||
unknown: '质量待确认'
|
||||
}
|
||||
/** 所有质量徽标使用当前有效质量。 */
|
||||
const reviewQuery = useEffectiveKeyframeQuality(reviewKey, vision)
|
||||
/** 当前有效质量,不使用会话内历史校验兜底。 */
|
||||
const effectiveStatus = reviewQuery.status
|
||||
/** 旧来源或已损坏的输入证据不能被会话中的历史通过覆盖。 */
|
||||
const isPassed = computed(
|
||||
() =>
|
||||
@@ -97,6 +89,11 @@ const isPassed = computed(
|
||||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||||
(effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted')
|
||||
)
|
||||
/** 独立来源审核变化后同步当前候选和外层列表。 */
|
||||
function onSourceChanged() {
|
||||
void reviewQuery.refresh()
|
||||
emit('settled')
|
||||
}
|
||||
/** 晋升入口只接受持久化通过和已结算审核。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
@@ -142,21 +139,11 @@ const canSelect = computed(
|
||||
<NTag v-else-if="effectiveStatus === 'needs_review'" size="small" type="warning" :bordered="false"
|
||||
>待人工复核</NTag
|
||||
>
|
||||
<NTag
|
||||
v-else-if="
|
||||
effectiveStatus === 'failed' || (effectiveStatus === 'unknown' && validationPassed === false)
|
||||
"
|
||||
size="small"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
<NTag v-else-if="effectiveStatus === 'failed'" size="small" type="error" :bordered="false"
|
||||
>质量未通过</NTag
|
||||
>
|
||||
<NTag
|
||||
v-else-if="item.status === 'completed' && effectiveStatus !== 'passed'"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
>
|
||||
{{ reviewLabels[effectiveStatus] ?? '质量待确认' }}
|
||||
<NTag v-else-if="item.status === 'completed'" size="small" :bordered="false">
|
||||
{{ effectiveQualityLabels[effectiveStatus] }}
|
||||
</NTag>
|
||||
<NTag v-if="item.source === 'provider_variant'" size="small" :bordered="false">视频参考图</NTag>
|
||||
<NTag v-if="item.isPrimary && stale" size="small" type="warning" :bordered="false">已过期</NTag>
|
||||
@@ -267,5 +254,6 @@ const canSelect = computed(
|
||||
:project-id="projectId"
|
||||
:shot-id="shotId"
|
||||
:keyframe-id="item.id"
|
||||
@changed="onSourceChanged"
|
||||
/>
|
||||
</template>
|
||||
@@ -19,29 +19,10 @@ const props = withDefaults(
|
||||
)
|
||||
/** 仅触发只读刷新。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 只有明确质量通过且未标记恢复才使用成功语义。 */
|
||||
const passed = computed(
|
||||
() =>
|
||||
props.execution.status === 'completed' &&
|
||||
props.execution.result?.passed === true &&
|
||||
props.execution.result.qualityDecision === 'passed' &&
|
||||
props.execution.result.recoveryRequired !== true
|
||||
)
|
||||
/** 执行完成后仍清晰保留真实质量结论。 */
|
||||
/** 执行记录仅表达处理状态,当前质量由候选的正式接口独立展示。 */
|
||||
const label = computed(() => {
|
||||
if (passed.value) return '审核质量通过'
|
||||
if (props.execution.status === 'failed') return '执行失败,质量未确认'
|
||||
if (props.execution.status === 'completed') {
|
||||
const quality = props.execution.result?.qualityDecision
|
||||
const labels: Record<string, string> = {
|
||||
failed: '质量未通过',
|
||||
needs_review: '质量待复核',
|
||||
stale: '审核来源已失效',
|
||||
blocked: '质量受阻',
|
||||
insufficient_evidence: '证据不足'
|
||||
}
|
||||
return `执行完成,${typeof quality === 'string' && labels[quality] ? labels[quality] : props.execution.result?.passed === false ? '质量未通过' : '质量待核对'}`
|
||||
}
|
||||
if (props.execution.status === 'failed') return '执行失败,质量请查看当前结论'
|
||||
if (props.execution.status === 'completed') return '执行完成,质量请查看当前结论'
|
||||
return props.execution.status === 'pending'
|
||||
? '等待审核'
|
||||
: props.execution.status === 'running'
|
||||
@@ -52,7 +33,7 @@ const label = computed(() => {
|
||||
|
||||
<template>
|
||||
<!-- 以下是正式执行与实际质量结论模块,不用满格绿色进度暗示通过 -->
|
||||
<section class="mt-4 space-y-2 text-sm" role="status" :class="passed ? 'bg-(--app-success-soft) p-3' : ''">
|
||||
<section class="mt-4 space-y-2 text-sm" role="status">
|
||||
<WorkspaceSectionHeading :title="title"
|
||||
><template #actions
|
||||
><NButton v-if="refreshable" :loading="loading" @click="emit('refresh')">刷新进度</NButton></template
|
||||
@@ -64,7 +45,9 @@ const label = computed(() => {
|
||||
<p class="wrap-anywhere text-xs text-muted">
|
||||
执行编号:{{ execution.id }} · {{ formatDate(execution.updatedAt) }}
|
||||
</p>
|
||||
<p v-if="typeof execution.result?.summary === 'string'">{{ userFacingText(execution.result.summary) }}</p>
|
||||
<p v-if="typeof execution.result?.summary === 'string'">
|
||||
历史执行摘要:{{ userFacingText(execution.result.summary) }}
|
||||
</p>
|
||||
<p v-if="execution.error">{{ userFacingText(execution.error) }}</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -8,7 +8,7 @@ import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NInput } from 'naive-ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { physicalRetryTarget, submitKeyframeVision, useKeyframeVision } from '../keyframe-vision'
|
||||
import KeyframeExecutionHistory from './KeyframeExecutionHistory.vue'
|
||||
@@ -51,13 +51,8 @@ const visionKey = computed(() =>
|
||||
)
|
||||
: ''
|
||||
)
|
||||
const {
|
||||
history: query,
|
||||
execution,
|
||||
state,
|
||||
uncertain,
|
||||
submissionMode
|
||||
} = props.observation ?? useKeyframeVision(visionKey)
|
||||
const observation = props.observation ?? useKeyframeVision(visionKey)
|
||||
const { history: query, execution, state, uncertain, submissionMode } = observation
|
||||
/** 后台结束时同步刷新人工复核与候选状态。 */
|
||||
watch(
|
||||
() => state.value.active,
|
||||
@@ -69,11 +64,7 @@ watch(
|
||||
}
|
||||
)
|
||||
/** 复核证据仅在展开历史时读取,不触发 Vision 或写入审核结论。 */
|
||||
const reviewQuery = useQuery(key, (value, signal) => {
|
||||
if (!value) return Promise.resolve(null)
|
||||
const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string]
|
||||
return qualityApi.keyframeQualityReview(shotId, keyframeId, signal)
|
||||
})
|
||||
const reviewQuery = useEffectiveKeyframeQuality(visionKey, observation)
|
||||
/** 当前正式质量摘要。 */
|
||||
const review = computed(() => reviewQuery.data.value)
|
||||
/** 终止记录不能经人工接受绕过独立授权与 Primary 门禁。 */
|
||||
@@ -197,14 +188,13 @@ const gazeEvidenceLabels: Record<string, string> = {
|
||||
ambiguous: '不明确',
|
||||
unverifiable: '无法核实'
|
||||
}
|
||||
const decisionLabel = (value: string) =>
|
||||
({
|
||||
passed: 'AI 校验通过',
|
||||
failed: 'AI 校验未通过',
|
||||
needs_review: '需要人工复核',
|
||||
manual_accepted: '人工已接受',
|
||||
unknown: '未校验'
|
||||
})[value] ?? '待确认'
|
||||
/**
|
||||
* 历史机器结论的中文名称,仅用于追溯。
|
||||
* @param value 原机器状态
|
||||
* @returns 可读质量名称
|
||||
*/
|
||||
const decisionLabel = (value: keyof typeof effectiveQualityLabels) => effectiveQualityLabels[value] ?? '质量待确认'
|
||||
/** 用户本次明确选择的人工决定。 */
|
||||
const reviewAction = ref<'accepted' | 'rejected' | null>(null)
|
||||
const reviewReason = ref('')
|
||||
const reviewer = ref('user')
|
||||
@@ -212,10 +202,23 @@ const submitting = ref(false)
|
||||
const submitError = ref('')
|
||||
const submitSuccess = ref('')
|
||||
|
||||
/** 归属或门禁变化撤销旧表单,不能把旧确认带到新候选。 */
|
||||
watch(
|
||||
[key, reviewQuery.manualReviewAvailable],
|
||||
() => {
|
||||
reviewAction.value = null
|
||||
reviewReason.value = ''
|
||||
submitError.value = ''
|
||||
submitSuccess.value = ''
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
|
||||
/** 人工接受必须先执行最新安全预检查;任何写入都需要明确按钮操作。 */
|
||||
async function submitReview() {
|
||||
if (
|
||||
!reviewAction.value ||
|
||||
!reviewQuery.manualReviewAvailable.value ||
|
||||
!review.value?.validationTaskId ||
|
||||
!reviewReason.value.trim() ||
|
||||
!reviewer.value.trim() ||
|
||||
@@ -295,8 +298,8 @@ const records = computed(() =>
|
||||
>
|
||||
<section v-if="review" class="panel p-3 text-xs leading-6">
|
||||
<p class="font-semibold">当前质量复核</p>
|
||||
<p>AI 检查:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}</p>
|
||||
<p>当前状态:{{ terminatedReview ? '质量未确认' : decisionLabel(review.effectiveQualityStatus) }}</p>
|
||||
<p>历史机器结论:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}</p>
|
||||
<p>当前状态:{{ effectiveQualityLabels[reviewQuery.status.value] }}</p>
|
||||
<p v-if="review.manualReview">
|
||||
人工审核:{{ review.manualReview.decision === 'accepted' ? '已接受' : '已拒绝' }} ·
|
||||
{{ review.manualReview.reason || '未填写理由' }}
|
||||
@@ -312,7 +315,7 @@ const records = computed(() =>
|
||||
<p class="text-muted">{{ item.reason }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="review?.manualReviewAvailable && !terminatedReview" class="panel mt-3 p-3 text-xs">
|
||||
<section v-if="reviewQuery.manualReviewAvailable.value && !terminatedReview" class="panel mt-3 p-3 text-xs">
|
||||
<p class="font-semibold">人工复核</p>
|
||||
<p class="mt-2 text-muted">请先预览候选图片并确认视觉效果。接受会替换当前主首帧,拒绝只保存审核记录。</p>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
|
||||
@@ -14,6 +14,7 @@ import { AppDialog } from '../../../components/ui'
|
||||
import { useKeyframeVision } from '../keyframe-vision'
|
||||
import { allowedTextLines, validQualityInput } from '../quality'
|
||||
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
|
||||
import { useEffectiveKeyframeQuality } from '../effective-keyframe-quality'
|
||||
import { useQuality } from '../useQuality'
|
||||
import QualityResult from './QualityResult.vue'
|
||||
import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
|
||||
@@ -49,6 +50,7 @@ const { key, session, operation, execution, blocked, run } = useQuality(
|
||||
() => {
|
||||
emit('changed')
|
||||
void videoQuery.refresh()
|
||||
void currentQuality.refresh()
|
||||
},
|
||||
id => emit('started', id)
|
||||
)
|
||||
@@ -59,6 +61,13 @@ const visionKey = computed(() =>
|
||||
: ''
|
||||
)
|
||||
const vision = useKeyframeVision(visionKey)
|
||||
/** 当前候选质量独立回读,不以本会话或后台回执作为当前结论。 */
|
||||
const currentQuality = useEffectiveKeyframeQuality(visionKey, vision)
|
||||
/** 人工审核完成后同步当前质量和外层资产。 */
|
||||
function onReviewed() {
|
||||
void currentQuality.refresh()
|
||||
emit('changed')
|
||||
}
|
||||
/** 有原参数时继续;没有原参数时保留只读核查。 */
|
||||
const visionBlocked = computed(() => !!visionKey.value && vision.blocked.value)
|
||||
/** 质量弹窗重新读取所选候选自身的权限,不以会话历史代替后端事实。 */
|
||||
@@ -486,10 +495,15 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
:observation="vision"
|
||||
:disabled="disabled || pending"
|
||||
initial-open
|
||||
@reviewed="emit('changed')"
|
||||
@reviewed="onReviewed"
|
||||
@busy="authorizationPending = $event"
|
||||
/>
|
||||
<QualityResult v-if="session.receipt" :receipt="session.receipt" @locate="emit('locate', $event)" />
|
||||
<QualityResult
|
||||
v-if="session.receipt"
|
||||
:receipt="session.receipt"
|
||||
:current-status="currentQuality.status.value"
|
||||
@locate="emit('locate', $event)"
|
||||
/>
|
||||
<NCollapse v-else-if="saved" class="mt-4" :default-expanded-names="['saved']"
|
||||
><NCollapseItem name="saved" :title="`本会话最近校验 · ${saved.passed ? '通过' : '未通过'}`"
|
||||
><p>{{ saved.summary }}</p>
|
||||
|
||||
@@ -6,11 +6,15 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { downloadText } from '../../../lib/format'
|
||||
import { keyframeValidationPassed } from '../quality'
|
||||
import { effectiveQualityLabels } from '../effective-keyframe-quality'
|
||||
import type { EffectiveKeyframeQualityStatus } from '../quality-api'
|
||||
import type { QualityReceipt } from '../quality.types'
|
||||
|
||||
/** 摘要、失败与完整逐轮信息默认直接显示,不用完成请求冒充质量通过。 */
|
||||
const props = defineProps<{ receipt: QualityReceipt }>()
|
||||
const props = defineProps<{
|
||||
/** 原操作历史回执。 */ receipt: QualityReceipt
|
||||
/** 首帧当前质量只来自正式回读;尚未取得时为未知。 */ currentStatus?: EffectiveKeyframeQualityStatus
|
||||
}>()
|
||||
/** 逐镜结果定位事件。 */
|
||||
const emit = defineEmits<{ locate: [shotId: string] }>()
|
||||
/** 完整最终回执的视觉结论。 */
|
||||
@@ -20,7 +24,7 @@ const passed = computed(() =>
|
||||
: props.receipt.kind === 'video-repair'
|
||||
? false
|
||||
: props.receipt.kind === 'keyframe'
|
||||
? keyframeValidationPassed(props.receipt.result)
|
||||
? props.currentStatus === 'passed' || props.currentStatus === 'manual_accepted'
|
||||
: props.receipt.result.passed
|
||||
)
|
||||
/** 当前失败问题列表。 */
|
||||
@@ -57,15 +61,30 @@ function exportResult() {
|
||||
<!-- 以下是最终校验结论与逐镜执行结果模块 -->
|
||||
<section class="quality-result" aria-label="质量检查结果">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<strong :class="receipt.kind === 'video-repair' ? '' : passed ? 'text-success' : 'text-danger'">{{
|
||||
receipt.kind === 'video-repair'
|
||||
? '修复任务已提交'
|
||||
: passed
|
||||
? '视觉校验通过'
|
||||
: receipt.kind === 'batch' && !receipt.result.targetCount
|
||||
? '未执行镜头'
|
||||
: '仍需处理'
|
||||
}}</strong>
|
||||
<strong
|
||||
:class="
|
||||
receipt.kind === 'keyframe' && !passed
|
||||
? 'text-muted'
|
||||
: receipt.kind === 'video-repair'
|
||||
? ''
|
||||
: passed
|
||||
? 'text-success'
|
||||
: 'text-muted'
|
||||
"
|
||||
>{{
|
||||
receipt.kind === 'keyframe'
|
||||
? effectiveQualityLabels[currentStatus ?? 'unknown']
|
||||
: receipt.kind === 'video-repair'
|
||||
? '修复任务已提交'
|
||||
: passed
|
||||
? receipt.kind === 'video'
|
||||
? '视觉校验通过'
|
||||
: '本次执行记录通过'
|
||||
: receipt.kind === 'batch' && !receipt.result.targetCount
|
||||
? '未执行镜头'
|
||||
: '仍需处理'
|
||||
}}</strong
|
||||
>
|
||||
<NButton text size="small" @click="exportResult">导出结果</NButton>
|
||||
</div>
|
||||
<template v-if="receipt.kind === 'batch'">
|
||||
@@ -110,7 +129,10 @@ function exportResult() {
|
||||
</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="mt-3 text-sm">{{ receipt.result.summary || '本次检查没有提供结果摘要。' }}</p>
|
||||
<p class="mt-3 text-sm">
|
||||
<span v-if="receipt.kind === 'keyframe'">历史检查摘要:</span
|
||||
>{{ receipt.result.summary || '本次检查没有提供结果摘要。' }}
|
||||
</p>
|
||||
<p v-if="receipt.kind === 'video'" class="mt-2 text-xs text-muted">
|
||||
{{
|
||||
receipt.promoted ? '修复后的视频已通过检查,并设为主视频。' : '本次检查没有更换主视频。'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NSelect } from 'naive-ui'
|
||||
import AppDrawer from '../../../components/ui/AppDrawer.vue'
|
||||
import { AssetImage } from '../../../components/ui'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { validationStepNames } from '../validation-execution-labels'
|
||||
import { isVisualValidation, keyframeValidationPassed } from '../quality'
|
||||
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { sourceFindingLabels } from '../source-review'
|
||||
import { useSourceReview } from '../useSourceReview'
|
||||
@@ -23,6 +23,22 @@ const open = defineModel<boolean>('open', { default: false })
|
||||
const key = computed(() => (open.value ? JSON.stringify([props.shotId, props.keyframeId, props.projectId]) : ''))
|
||||
/** 人工、批准和执行分别操作。 */
|
||||
const form = useSourceReview(key)
|
||||
/** 当前质量与独立人工观察分开展示。 */
|
||||
const quality = useEffectiveKeyframeQuality(key, form.vision)
|
||||
/** 通知外层候选重新回读当前质量。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 本范围的新审核和来源结果变化后同步通知卡片。 */
|
||||
watch([form.result, form.record, form.preview], () => {
|
||||
if (key.value) {
|
||||
void quality.refresh()
|
||||
emit('changed')
|
||||
}
|
||||
})
|
||||
/** 同步只读历史及当前质量。 */
|
||||
function refreshQuality() {
|
||||
void form.vision.history.refresh()
|
||||
void quality.refresh()
|
||||
}
|
||||
/** 仅写入时锁关闭。 */
|
||||
const busy = computed(() => ['save', 'authorize', 'execute'].includes(form.pending.value))
|
||||
/** 用户明确选择,打开时不预填通过。 */
|
||||
@@ -40,16 +56,8 @@ const canResume = computed(
|
||||
!form.vision.state.value.unknown &&
|
||||
task.value?.id === form.vision.resume.value.resumeValidationTaskId
|
||||
)
|
||||
/** 完整回执和实际质量分别表达,失败也复用原结果。 */
|
||||
const resultLabel = computed(() =>
|
||||
isVisualValidation(form.result.value)
|
||||
? keyframeValidationPassed(form.result.value)
|
||||
? '独立机器审核通过,仍需三镜连续性验收'
|
||||
: '执行完成,质量未通过或待复核;保留原结果,不自动重发'
|
||||
: form.result.value
|
||||
? '已受理,正在观察正式执行'
|
||||
: ''
|
||||
)
|
||||
/** 执行受理与当前质量分别显示,不从同步回执推断当前通过。 */
|
||||
const resultLabel = computed(() => (form.result.value ? '本次审核已受理,可查看执行记录。' : ''))
|
||||
/** 当前观察状态的中文摘要。 */
|
||||
const statusLabels: Record<string, string> = {
|
||||
passed: '人工来源观察通过',
|
||||
@@ -68,6 +76,8 @@ const statusLabels: Record<string, string> = {
|
||||
:busy="busy"
|
||||
>
|
||||
<div class="space-y-(--app-content-gap)">
|
||||
<!-- 以下是当前有效质量摘要,人工观察通过不代表机器质量通过 -->
|
||||
<p role="status" class="text-sm">当前质量:{{ effectiveQualityLabels[quality.status.value] }}</p>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<NButton
|
||||
:loading="form.pending.value === 'preview'"
|
||||
@@ -329,9 +339,7 @@ const statusLabels: Record<string, string> = {
|
||||
}}</pre>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
<NButton :loading="form.vision.history.loading.value" @click="form.vision.history.refresh"
|
||||
>只读刷新审核历史</NButton
|
||||
>
|
||||
<NButton :loading="form.vision.history.loading.value" @click="refreshQuality">只读刷新审核历史</NButton>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NButton :disabled="busy" @click="open = false">关闭</NButton>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { computed, watch, type Ref } from 'vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { qualityApi, type EffectiveKeyframeQualityStatus } from './quality-api'
|
||||
import type { useKeyframeVision } from './keyframe-vision'
|
||||
|
||||
/** 当前质量统一文案,与历史机器判定分开展示。 */
|
||||
export const effectiveQualityLabels: Record<EffectiveKeyframeQualityStatus, string> = {
|
||||
passed: '质量通过',
|
||||
failed: '质量未通过',
|
||||
needs_review: '待人工复核',
|
||||
blocked: '质量受阻',
|
||||
insufficient_evidence: '审核证据不足',
|
||||
stale: '审核来源过期',
|
||||
manual_accepted: '人工已接受',
|
||||
unknown: '质量待确认'
|
||||
}
|
||||
|
||||
/**
|
||||
* 按项目、镜头、候选读取有效质量,执行及来源证据变化后重新回读,绝不采用工作流的历史 Passed。
|
||||
* @param key 镜头、候选、项目及可选来源版本的 JSON 查询键
|
||||
* @param vision 当前候选的正式审核观察器
|
||||
* @returns 只读查询、当前质量和人工复核门禁
|
||||
*/
|
||||
export function useEffectiveKeyframeQuality(key: Ref<string>, vision: ReturnType<typeof useKeyframeVision>) {
|
||||
/** 质量只从正式 quality-review 接口取得,归属不符时拒绝回填。 */
|
||||
const query = useQuery(key, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [shotId, keyframeId, projectId] = JSON.parse(value) as [string, string, string?]
|
||||
const review = await qualityApi.keyframeQualityReview(shotId, keyframeId, signal, projectId)
|
||||
if (review.shotId !== shotId || review.keyframeId !== keyframeId)
|
||||
throw new Error('质量记录与当前首帧不符,请刷新。')
|
||||
return review
|
||||
})
|
||||
/** 同一目标的正式历史变化和 SSE 终态只触发重新查询,不复制任务结果。 */
|
||||
watch(
|
||||
() => JSON.stringify([vision.history.data.value, vision.execution.data.value, vision.history.updatedAt.value]),
|
||||
() => {
|
||||
if (key.value) void query.refresh()
|
||||
}
|
||||
)
|
||||
/** 刷新期间或失败时撤销旧质量,避免继续使用已失效的通过结论。 */
|
||||
const status = computed<EffectiveKeyframeQualityStatus>(() =>
|
||||
query.loading.value || query.error.value ? 'unknown' : (query.data.value?.effectiveQualityStatus ?? 'unknown')
|
||||
)
|
||||
/** 人工接受严格依赖服务端开关,刷新和错误期间禁止提交。 */
|
||||
const manualReviewAvailable = computed(
|
||||
() => !query.loading.value && !query.error.value && query.data.value?.manualReviewAvailable === true
|
||||
)
|
||||
return { ...query, status, manualReviewAvailable }
|
||||
}
|
||||
@@ -200,6 +200,12 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
const record = 'done' in payload ? payload.result : payload
|
||||
if (!record || record.id !== id || (projectId && record.projectId !== projectId)) return
|
||||
if (record.workflowName !== 'shot-keyframe-validation') return
|
||||
const [shotId, keyframeId] = JSON.parse(target) as string[]
|
||||
if (
|
||||
(record.metadata?.shotId && record.metadata.shotId !== shotId) ||
|
||||
(record.metadata?.keyframeId && record.metadata.keyframeId !== keyframeId)
|
||||
)
|
||||
return
|
||||
const known = execution.data.value
|
||||
if (
|
||||
known?.id === record.id &&
|
||||
|
||||
@@ -15,27 +15,40 @@ import type {
|
||||
VideoRepair
|
||||
} from './quality.types'
|
||||
|
||||
/** 后端当前有效质量;历史机器结论不能替代此状态。 */
|
||||
export type EffectiveKeyframeQualityStatus =
|
||||
| 'passed'
|
||||
| 'failed'
|
||||
| 'needs_review'
|
||||
| 'blocked'
|
||||
| 'insufficient_evidence'
|
||||
| 'stale'
|
||||
| 'manual_accepted'
|
||||
| 'unknown'
|
||||
|
||||
/** 首帧人工复核只读摘要,AI 原始判定与人工结论分别展示。 */
|
||||
export interface KeyframeQualityReview {
|
||||
qualityDecision: 'passed' | 'failed' | 'needs_review' | 'unknown'
|
||||
effectiveQualityStatus: 'passed' | 'failed' | 'needs_review' | 'manual_accepted' | 'unknown'
|
||||
validationTaskId: string | null
|
||||
historicalGazePreview: Array<{
|
||||
subjectRef: string
|
||||
targetDescription: string
|
||||
decision: 'passed' | 'failed' | 'needs_review'
|
||||
physicalAlignment: string | null
|
||||
observationCertainty: string | null
|
||||
reason: string
|
||||
/** 正式镜头归属。 */ shotId: string
|
||||
/** 正式候选归属。 */ keyframeId: string
|
||||
/** 历史机器结论,仅供追溯。 */ qualityDecision: EffectiveKeyframeQualityStatus
|
||||
/** 当前来源及门禁核对后的有效质量。 */ effectiveQualityStatus: EffectiveKeyframeQualityStatus
|
||||
/** 历史机器任务。 */ validationTaskId: string | null
|
||||
/** 历史视线证据。 */ historicalGazePreview: Array<{
|
||||
/** 主体引用。 */ subjectRef: string
|
||||
/** 目标描述。 */ targetDescription: string
|
||||
/** 历史复核决定。 */ decision: 'passed' | 'failed' | 'needs_review'
|
||||
/** 物理朝向。 */ physicalAlignment: string | null
|
||||
/** 证据确定性。 */ observationCertainty: string | null
|
||||
/** 说明。 */ reason: string
|
||||
}>
|
||||
manualReview: {
|
||||
reviewId: string
|
||||
decision: string
|
||||
reviewer: string | null
|
||||
reason: string | null
|
||||
reviewedAt: string | null
|
||||
/** 已保存的人工决定。 */ manualReview: {
|
||||
/** 人工审核编号。 */ reviewId: string
|
||||
/** 历史复核决定。 */ decision: string
|
||||
/** 审核人。 */ reviewer: string | null
|
||||
/** 说明。 */ reason: string | null
|
||||
/** 审核时间。 */ reviewedAt: string | null
|
||||
} | null
|
||||
manualReviewAvailable: boolean
|
||||
/** 服务端允许人工接受,不能由历史问题推导。 */ manualReviewAvailable: boolean
|
||||
}
|
||||
|
||||
/** 视觉审核提交不自动重试;首帧后台受理有连接超时,长同步操作等候实际结论。 */
|
||||
@@ -113,16 +126,19 @@ export const qualityApi = {
|
||||
{ method: 'POST', body: { allowedTexts }, timeoutMs: 0 }
|
||||
),
|
||||
/**
|
||||
* 只读查询指定首帧的已有校验历史。
|
||||
* @param shotId 正式镜头 ID
|
||||
* @param keyframeId 指定首帧 ID
|
||||
* 零费用读取当前有效质量与历史机器结论。
|
||||
* @param shotId 正式镜头
|
||||
* @param keyframeId 指定候选
|
||||
* @param signal 取消信号
|
||||
* @returns 后端保存的校验记录列表
|
||||
* @param projectId 当前项目范围
|
||||
* @returns 服务端当前质量与人工复核权限
|
||||
*/
|
||||
/** 零费用读取首帧 AI 证据分歧及人工复核状态。 */
|
||||
keyframeQualityReview: (shotId: string, keyframeId: string, signal?: AbortSignal) =>
|
||||
keyframeQualityReview: (shotId: string, keyframeId: string, signal?: AbortSignal, projectId?: string) =>
|
||||
request<KeyframeQualityReview>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/quality-review`,
|
||||
keyframeScope(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/quality-review`,
|
||||
projectId
|
||||
),
|
||||
{ signal }
|
||||
),
|
||||
/** 人工接受前的零费用安全预检查。 */
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360" viewBox="0 0 640 360"><rect width="640" height="360" fill="#eee"/><text x="320" y="180" text-anchor="middle" fill="#666" font-size="28">隔离候选图片</text></svg>
|
||||
|
After Width: | Height: | Size: 233 B |
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>首帧当前质量隔离验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./effective-quality.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,138 @@
|
||||
import { createApp, defineComponent, h, ref } from 'vue'
|
||||
import { NButton, NMessageProvider, NConfigProvider } from 'naive-ui'
|
||||
import KeyframeCard from '../../src/features/production/components/KeyframeCard.vue'
|
||||
import KeyframeValidationHistory from '../../src/features/production/components/KeyframeValidationHistory.vue'
|
||||
import QualityResult from '../../src/features/production/components/QualityResult.vue'
|
||||
import { keyframeFixture } from '../../src/features/production/testing/fixtures'
|
||||
import type { EffectiveKeyframeQualityStatus } from '../../src/features/production/quality-api'
|
||||
import '../../src/styles/styles.css'
|
||||
import '../../src/styles/admin.css'
|
||||
import QualityDialog from '../../src/features/production/components/QualityDialog.vue'
|
||||
import SourceReviewDrawer from '../../src/features/production/components/SourceReviewDrawer.vue'
|
||||
|
||||
/** 浏览器隔离场景,仅拦截本页所有请求,不连接真实 API 或 Provider。 */
|
||||
const status = ref<EffectiveKeyframeQualityStatus>('stale')
|
||||
/** 场景切换后重挂组件,模拟重新进入当前候选。 */
|
||||
const revision = ref(0)
|
||||
/** 仅在待人工复核时开放服务端模拟权限。 */
|
||||
const available = ref(false)
|
||||
/** 历史回执保留 Passed,用于确认当前 Stale 不被覆盖。 */
|
||||
const result = {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
validationTaskId: 't',
|
||||
imageUrl: '',
|
||||
isPrimary: false,
|
||||
passed: true,
|
||||
summary: '历史机器通过,本页使用隔离数据。',
|
||||
subjects: [],
|
||||
issues: [],
|
||||
subjectCountConsistent: true,
|
||||
unauthorizedText: { detected: false, texts: [] }
|
||||
}
|
||||
/**
|
||||
* 隔离所有请求;写请求直接拒绝,验收不会保存业务数据。
|
||||
* @param input 请求路径
|
||||
* @param init 请求选项
|
||||
* @returns 隔离业务响应
|
||||
*/
|
||||
window.fetch = async (input, init) => {
|
||||
if (init?.method && init.method !== 'GET') return new Response('{}', { status: 403 })
|
||||
const path = String(input)
|
||||
const data = path.includes('/quality-review')
|
||||
? {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
qualityDecision: 'passed',
|
||||
effectiveQualityStatus: status.value,
|
||||
manualReviewAvailable: available.value,
|
||||
validationTaskId: 't',
|
||||
historicalGazePreview: [],
|
||||
manualReview: null
|
||||
}
|
||||
: []
|
||||
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } })
|
||||
}
|
||||
/** 复用真实组件进行可重复的桌面和窄屏验收。 */
|
||||
const Preview = defineComponent({
|
||||
setup() {
|
||||
/** 仅打开只读面板,不执行审核。 */
|
||||
const qualityOpen = ref(false)
|
||||
/** 独立来源抽屉仅查看当前质量。 */
|
||||
const sourceOpen = ref(false)
|
||||
return () =>
|
||||
h('main', { style: 'padding:24px;max-width:1100px;margin:auto;height:100dvh;overflow:auto' }, [
|
||||
h('h1', { style: 'font-size:24px;margin-bottom:16px' }, '首帧当前质量 · 隔离验收'),
|
||||
h(
|
||||
'div',
|
||||
{ style: 'display:flex;flex-wrap:wrap;gap:12px;margin-bottom:24px' },
|
||||
(['stale', 'blocked', 'passed', 'unknown', 'needs_review'] as const).map(value =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
status.value = value
|
||||
available.value = value === 'needs_review'
|
||||
revision.value++
|
||||
}
|
||||
},
|
||||
() => value
|
||||
)
|
||||
)
|
||||
),
|
||||
h(NButton, { onClick: () => (qualityOpen.value = true) }, () => '查看质量弹窗'),
|
||||
h(NButton, { onClick: () => (sourceOpen.value = true) }, () => '查看来源抽屉'),
|
||||
h(QualityDialog, {
|
||||
open: qualityOpen.value,
|
||||
'onUpdate:open': (value: boolean) => (qualityOpen.value = value),
|
||||
projectId: 'p',
|
||||
target: { kind: 'keyframe', shotId: 's', assetId: 'k', title: '隔离候选' },
|
||||
disabled: true
|
||||
}),
|
||||
h(SourceReviewDrawer, {
|
||||
open: sourceOpen.value,
|
||||
'onUpdate:open': (value: boolean) => (sourceOpen.value = value),
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
keyframeId: 'k'
|
||||
}),
|
||||
h(
|
||||
'div',
|
||||
{
|
||||
style: 'display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr));gap:24px'
|
||||
},
|
||||
[
|
||||
h(KeyframeCard, {
|
||||
key: 'card' + revision.value,
|
||||
item: keyframeFixture({
|
||||
id: 'k',
|
||||
shotId: 's',
|
||||
imageUrl: 'http://localhost:4312/tests/browser/candidate.svg',
|
||||
isPrimary: false
|
||||
}),
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
shotNo: 1,
|
||||
stale: false,
|
||||
blocked: false,
|
||||
validationPassed: true,
|
||||
confirming: false
|
||||
}),
|
||||
h('div', [
|
||||
h(KeyframeValidationHistory, {
|
||||
key: 'history' + revision.value,
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
initialOpen: true
|
||||
}),
|
||||
h(QualityResult, { receipt: { kind: 'keyframe', result }, currentStatus: status.value })
|
||||
])
|
||||
]
|
||||
)
|
||||
])
|
||||
}
|
||||
})
|
||||
createApp({
|
||||
render: () => h(NConfigProvider, null, { default: () => h(NMessageProvider, null, { default: () => h(Preview) }) })
|
||||
}).mount('#app')
|
||||
@@ -0,0 +1,289 @@
|
||||
import { effectScope, ref } from 'vue'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useKeyframeVision } from '@/features/production/keyframe-vision'
|
||||
import { useEffectiveKeyframeQuality } from '@/features/production/effective-keyframe-quality'
|
||||
import { qualityApi, type EffectiveKeyframeQualityStatus } from '@/features/production/quality-api'
|
||||
import KeyframeCard from '@/features/production/components/KeyframeCard.vue'
|
||||
import KeyframeValidationHistory from '@/features/production/components/KeyframeValidationHistory.vue'
|
||||
import QualityResult from '@/features/production/components/QualityResult.vue'
|
||||
import type { ShotKeyframe } from '@/features/production/types'
|
||||
|
||||
/** 隔离作用域和组件,每例结束关闭观察及定时器。 */
|
||||
let scope = effectScope()
|
||||
/** 当前测试组件的清理入口。 */
|
||||
let unmount = () => {}
|
||||
afterEach(() => {
|
||||
unmount()
|
||||
scope.stop()
|
||||
scope = effectScope()
|
||||
sessionStorage.clear()
|
||||
})
|
||||
|
||||
/**
|
||||
* 正式接口隔离响应。
|
||||
* @param data 模拟业务数据
|
||||
* @returns HTTP 响应
|
||||
*/
|
||||
function response(data: unknown) {
|
||||
return new Response(JSON.stringify({ data }))
|
||||
}
|
||||
/**
|
||||
* 构造带历史 Passed 的当前质量,默认不开放人工接受。
|
||||
* @param status 当前有效状态
|
||||
* @param manualReviewAvailable 后端门禁
|
||||
* @returns 正式质量摘要
|
||||
*/
|
||||
function review(status: EffectiveKeyframeQualityStatus, manualReviewAvailable = false) {
|
||||
return {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
qualityDecision: 'passed',
|
||||
effectiveQualityStatus: status,
|
||||
manualReviewAvailable,
|
||||
validationTaskId: 't',
|
||||
historicalGazePreview: [],
|
||||
manualReview: null
|
||||
}
|
||||
}
|
||||
/** 模拟已完成机器任务的历史原件。 */
|
||||
const historical = { id: 't', executionId: 'e', status: 'completed', output: { passed: true }, createdAt: '2026-11-07' }
|
||||
/** 完整的隔离执行记录,用于验证终态和归属。 */
|
||||
const execution = {
|
||||
id: 'e',
|
||||
projectId: 'p',
|
||||
workflowName: 'shot-keyframe-validation',
|
||||
status: 'running',
|
||||
metadata: { shotId: 's', keyframeId: 'k' },
|
||||
updatedAt: '2026-11-07T00:00:00Z'
|
||||
}
|
||||
|
||||
/** 仅在内存发送消息的 SSE,不连接真实服务。 */
|
||||
class MockEvents {
|
||||
/** 已注册的消息接收器。 */ listener?: (event: { data: string }) => void
|
||||
/** 本例所有连接。 */ static instances: MockEvents[] = []
|
||||
constructor() {
|
||||
MockEvents.instances.push(this)
|
||||
}
|
||||
/**
|
||||
* 注册模拟消息。
|
||||
* @param name 消息名称
|
||||
* @param callback 接收器
|
||||
*/
|
||||
addEventListener(name: string, callback: (event: { data: string }) => void) {
|
||||
if (name === 'message') this.listener = callback
|
||||
}
|
||||
/** 关闭只清理模拟句柄。 */ close() {}
|
||||
/**
|
||||
* 发送测试记录。
|
||||
* @param record 隔离执行快照
|
||||
*/
|
||||
send(record: unknown) {
|
||||
this.listener?.({ data: JSON.stringify(record) })
|
||||
}
|
||||
}
|
||||
|
||||
describe('首帧当前有效质量', () => {
|
||||
it.each([
|
||||
'stale',
|
||||
'blocked',
|
||||
'passed',
|
||||
'unknown',
|
||||
'failed',
|
||||
'needs_review',
|
||||
'insufficient_evidence',
|
||||
'manual_accepted'
|
||||
] as const)('卡片采用当前 %s,不采用历史 Passed 或生成成功', async status => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn(async url => response(String(url).includes('/quality-review') ? review(status) : []))
|
||||
)
|
||||
const wrapper = mount(KeyframeCard, {
|
||||
props: {
|
||||
item: { id: 'k', shotId: 's', status: 'completed', imageUrl: '/mock.png' } as ShotKeyframe,
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
shotNo: 1,
|
||||
stale: false,
|
||||
blocked: false,
|
||||
validationPassed: true,
|
||||
confirming: false
|
||||
}
|
||||
})
|
||||
unmount = () => wrapper.unmount()
|
||||
await flushPromises()
|
||||
const labels = {
|
||||
stale: '审核来源过期',
|
||||
blocked: '质量受阻',
|
||||
passed: '质量通过',
|
||||
unknown: '质量待确认',
|
||||
failed: '质量未通过',
|
||||
needs_review: '待人工复核',
|
||||
insufficient_evidence: '审核证据不足',
|
||||
manual_accepted: '人工已接受'
|
||||
}
|
||||
expect(wrapper.text()).toContain(labels[status])
|
||||
expect(wrapper.text().includes('设为主首帧')).toBe(['passed', 'manual_accepted'].includes(status))
|
||||
expect(wrapper.text().includes('质量通过')).toBe(status === 'passed')
|
||||
})
|
||||
it.each([
|
||||
['needs_review', true],
|
||||
['needs_review', false],
|
||||
['blocked', false],
|
||||
['stale', false],
|
||||
['unknown', false]
|
||||
] as const)('人工接受按服务端 %s / %s 展示', async (status, allowed) => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn(async url => response(String(url).includes('/quality-review') ? review(status, allowed) : []))
|
||||
)
|
||||
const wrapper = mount(KeyframeValidationHistory, {
|
||||
props: { projectId: 'p', shotId: 's', keyframeId: 'k', initialOpen: true }
|
||||
})
|
||||
unmount = () => wrapper.unmount()
|
||||
await flushPromises()
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '人工接受')).toBe(allowed)
|
||||
expect(wrapper.text()).toContain('历史机器结论:质量通过')
|
||||
})
|
||||
it('当前质量刷新失败撤销旧通过和人工门禁,不使用缓存结论', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => response(review('passed', true)))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const quality = scope.run(() =>
|
||||
useEffectiveKeyframeQuality(ref(JSON.stringify(['s', 'k', 'p'])), useKeyframeVision(ref('')))
|
||||
)!
|
||||
await flushPromises()
|
||||
expect(quality.status.value).toBe('passed')
|
||||
fetcher.mockRejectedValue(new Error('隔离网络失败'))
|
||||
const refresh = quality.refresh()
|
||||
expect(quality.status.value).toBe('unknown')
|
||||
expect(quality.manualReviewAvailable.value).toBe(false)
|
||||
await refresh
|
||||
expect(quality.status.value).toBe('unknown')
|
||||
expect(quality.data.value?.qualityDecision).toBe('passed')
|
||||
})
|
||||
it('切换候选清除已打开的人工接受表单,旧表单不能提交', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async url =>
|
||||
response(
|
||||
String(url).includes('/quality-review')
|
||||
? String(url).includes('/k2/')
|
||||
? { ...review('blocked'), keyframeId: 'k2' }
|
||||
: review('needs_review', true)
|
||||
: []
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(KeyframeValidationHistory, {
|
||||
props: { projectId: 'p', shotId: 's', keyframeId: 'k', initialOpen: true }
|
||||
})
|
||||
unmount = () => wrapper.unmount()
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '人工接受')!
|
||||
.trigger('click')
|
||||
expect(wrapper.text()).toContain('确认接受')
|
||||
await wrapper.setProps({ keyframeId: 'k2' })
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('质量受阻')
|
||||
expect(wrapper.text()).not.toContain('确认接受')
|
||||
expect(fetcher.mock.calls.every(([, options]) => options?.method !== 'POST')).toBe(true)
|
||||
})
|
||||
it('项目、镜头、候选及来源变化取消旧请求,迟到响应不回填', async () => {
|
||||
const pending: Array<{ signal?: AbortSignal | null; resolve: (value: Response) => void }> = []
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn((url, options) =>
|
||||
String(url).includes('/quality-review')
|
||||
? new Promise<Response>(resolve => pending.push({ signal: options?.signal, resolve }))
|
||||
: Promise.resolve(response([]))
|
||||
)
|
||||
)
|
||||
const key = ref(JSON.stringify(['s', 'k', 'p', 'source-1']))
|
||||
const quality = scope.run(() => useEffectiveKeyframeQuality(key, useKeyframeVision(ref(''))))!
|
||||
for (const next of [
|
||||
['s', 'k', 'other'],
|
||||
['s2', 'k', 'other'],
|
||||
['s2', 'k2', 'other'],
|
||||
['s2', 'k2', 'other', 'source-2']
|
||||
]) {
|
||||
key.value = JSON.stringify(next)
|
||||
await flushPromises()
|
||||
}
|
||||
expect(pending.slice(0, -1).every(item => item.signal?.aborted)).toBe(true)
|
||||
pending.at(-1)!.resolve(response({ ...review('stale'), shotId: 's2', keyframeId: 'k2' }))
|
||||
await flushPromises()
|
||||
for (const item of pending.slice(0, -1)) item.resolve(response(review('passed')))
|
||||
await flushPromises()
|
||||
expect(quality.status.value).toBe('stale')
|
||||
})
|
||||
it('SSE 终态回读当前接口,拒绝错候选和旧项目事件', async () => {
|
||||
MockEvents.instances = []
|
||||
vi.stubGlobal('EventSource', MockEvents)
|
||||
let status: EffectiveKeyframeQualityStatus = 'stale'
|
||||
const fetcher = vi.fn<typeof fetch>(async url =>
|
||||
response(
|
||||
String(url).includes('/quality-review')
|
||||
? review(status)
|
||||
: String(url).includes('/validations')
|
||||
? [historical]
|
||||
: execution
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const key = ref(JSON.stringify(['s', 'k', 'p']))
|
||||
const quality = scope.run(() => useEffectiveKeyframeQuality(key, useKeyframeVision(key)))!
|
||||
await flushPromises()
|
||||
expect(quality.status.value).toBe('stale')
|
||||
const events = MockEvents.instances.at(-1)!
|
||||
const count = fetcher.mock.calls.length
|
||||
events.send({ ...execution, status: 'completed', metadata: { keyframeId: 'wrong' } })
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.length).toBe(count)
|
||||
status = 'passed'
|
||||
events.send({ ...execution, status: 'completed', updatedAt: '2026-11-07T00:01:00Z', result: { passed: false } })
|
||||
await flushPromises()
|
||||
expect(quality.status.value).toBe('passed')
|
||||
key.value = ''
|
||||
await flushPromises()
|
||||
events.send({ ...execution, status: 'completed' })
|
||||
await flushPromises()
|
||||
expect(quality.status.value).toBe('unknown')
|
||||
expect(
|
||||
fetcher.mock.calls.every(([, options]) => !['POST', 'PUT', 'DELETE'].includes(options?.method ?? 'GET'))
|
||||
).toBe(true)
|
||||
})
|
||||
it('接口携带转义后的项目范围和取消信号', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async () => response(review('unknown')))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await qualityApi.keyframeQualityReview('s/a', 'k/b', new AbortController().signal, 'p/c')
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe(
|
||||
'/api/storyboard-shots/s%2Fa/keyframes/k%2Fb/quality-review?projectId=p%2Fc'
|
||||
)
|
||||
})
|
||||
it('结果组件不把同步历史 Passed 显示为当前通过', () => {
|
||||
const wrapper = mount(QualityResult, {
|
||||
props: {
|
||||
currentStatus: 'stale',
|
||||
receipt: {
|
||||
kind: 'keyframe',
|
||||
result: {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
validationTaskId: 't',
|
||||
imageUrl: '',
|
||||
isPrimary: false,
|
||||
passed: true,
|
||||
summary: '原审核摘要',
|
||||
issues: [],
|
||||
subjects: [],
|
||||
subjectCountConsistent: true,
|
||||
unauthorizedText: { detected: false, texts: [] }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
unmount = () => wrapper.unmount()
|
||||
expect(wrapper.text()).toContain('审核来源过期')
|
||||
expect(wrapper.text()).not.toContain('视觉校验通过')
|
||||
})
|
||||
})
|
||||
@@ -325,8 +325,10 @@ describe('精简公开资产回归', () => {
|
||||
? generationProfile(projectId)
|
||||
: String(url).endsWith('/keyframes')
|
||||
? [primary, candidate]
|
||||
: String(url).endsWith('/quality-review')
|
||||
: String(url).includes('/quality-review')
|
||||
? {
|
||||
shotId: shot.shotId,
|
||||
keyframeId: String(url).includes(candidate.id) ? candidate.id : primary.id,
|
||||
effectiveQualityStatus: String(url).includes(candidate.id)
|
||||
? persistedQuality
|
||||
: 'passed'
|
||||
|
||||
@@ -166,7 +166,13 @@ function server() {
|
||||
else if (path.endsWith('/production/entry-readiness')) data = { ready: true }
|
||||
else if (path.endsWith('/validations')) data = []
|
||||
else if (path.endsWith('/quality-review'))
|
||||
data = { effectiveQualityStatus: 'unknown', qualityDecision: 'unknown', historicalGazePreview: [] }
|
||||
data = {
|
||||
shotId: keyframe.shotId,
|
||||
keyframeId: keyframe.id,
|
||||
effectiveQualityStatus: 'unknown',
|
||||
qualityDecision: 'unknown',
|
||||
historicalGazePreview: []
|
||||
}
|
||||
else if (path.includes('/readiness')) data = readiness
|
||||
else if (path.endsWith('/keyframes')) data = [keyframe]
|
||||
else if (path.endsWith('/videos')) data = [video]
|
||||
@@ -464,7 +470,7 @@ describe('质量面板渐进展示', () => {
|
||||
validationButton().click()
|
||||
await flushPromises()
|
||||
expect(data.posts()).toHaveLength(1)
|
||||
expect(document.body.textContent).toContain('视觉校验通过')
|
||||
expect(document.body.textContent).toContain('质量待确认')
|
||||
})
|
||||
|
||||
it('批量默认当前集一镜,调整次数撤销费用确认', async () => {
|
||||
|
||||
@@ -101,6 +101,8 @@ export function sourceMock(status = 'passed') {
|
||||
else if (path.endsWith('/vision/preview')) data = sourcePlan
|
||||
else if (path.endsWith('/vision/authorizations')) data = { authorizationId: 'auth', plan: sourcePlan }
|
||||
else if (path.endsWith('/source-reviews/r')) data = record
|
||||
else if (path.includes('/quality-review'))
|
||||
data = { shotId: 's', keyframeId: 'k', effectiveQualityStatus: 'stale', manualReviewAvailable: false }
|
||||
else if (path.includes('/validations')) data = []
|
||||
else return new Response(JSON.stringify({ error: { message: '未模拟请求' } }), { status: 404 })
|
||||
return new Response(JSON.stringify({ data }))
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('按任务读取执行历史的页面流程', () => {
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await expand('执行记录')
|
||||
expect(wrapper.text()).toContain('仅补跑物理专项')
|
||||
expect(wrapper.text()).toContain('执行完成,质量待复核')
|
||||
expect(wrapper.text()).toContain('执行完成,质量请查看当前结论')
|
||||
expect(wrapper.text()).toContain('本次新提交步骤:物理关系;复用已有步骤:通用画面')
|
||||
await expand('通用画面')
|
||||
expect(wrapper.text()).toContain('原调用计量,不重复计入本次')
|
||||
|
||||
@@ -59,6 +59,8 @@ describe('独立授权底栏与当前审核结论', () => {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
validationTaskId: 'terminated-task',
|
||||
qualityDecision: 'passed',
|
||||
effectiveQualityStatus: 'passed',
|
||||
@@ -107,7 +109,7 @@ describe('独立授权底栏与当前审核结论', () => {
|
||||
result: { passed: false, qualityDecision: 'failed' }
|
||||
} as WorkflowExecution
|
||||
wrapper = mount(KeyframeExecutionStatus, { props: { execution: record, loading: false } })
|
||||
expect(wrapper.text()).toContain('执行完成,质量未通过')
|
||||
expect(wrapper.text()).toContain('执行完成,质量请查看当前结论')
|
||||
expect(wrapper.classes().join(' ')).not.toContain('success')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user