feat(short-drama-agent-front): 完善质量规则确认与中文交互
This commit is contained in:
1 parent
190333d4f9
commit
c4b43b9725
85 files changed
+2059
-480
No files matched your search
@@ -7,8 +7,9 @@ import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue
|
||||
import { NScrollbar, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTab, NTable, NTabs } from 'naive-ui'
|
||||
import { computed, h, nextTick, onScopeDispose, ref, watch } from 'vue'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { CircleAlert, Layers, LoaderCircle, Settings2 } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import { CircleAlert, Layers, LoaderCircle, Settings2, ShieldCheck } from '@lucide/vue'
|
||||
import { AppDialog, EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import QualityPolicySettings from '../generation-config/components/QualityPolicySettings.vue'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownApi } from './api'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview, ShotValidation } from './types'
|
||||
@@ -24,7 +25,9 @@ import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
|
||||
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
|
||||
import BreakdownIssuesDialog from './components/BreakdownIssuesDialog.vue'
|
||||
import CandidateRepairs from './components/CandidateRepairs.vue'
|
||||
import ActionExceptionRepair from './components/ActionExceptionRepair.vue'
|
||||
import { useBreakdownQuality } from './useBreakdownQuality'
|
||||
import { useBreakdownStartPolicy } from './useBreakdownStartPolicy'
|
||||
import type { DiagnosisLocation } from './diagnosis'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText } from '../../lib/format'
|
||||
@@ -41,6 +44,8 @@ const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
/** 问题查看、人工修订和阶段恢复共用独立窗口。 */
|
||||
const issuesOpen = ref(false)
|
||||
/** 动作例外真实写入期间锁定问题抽屉的关闭,普通查询不锁定。 */
|
||||
const exceptionSaving = ref(false)
|
||||
/** 从设置切换时等待关闭动画结束,避免两层弹窗同时显示。 */
|
||||
const pendingIssues = ref(false)
|
||||
/** 问题入口统一使用红色文字、图标和柔和底色,交互时保持错误语义。 */
|
||||
@@ -343,6 +348,42 @@ const canStart = computed(
|
||||
!error.value &&
|
||||
(!records.value.length || taskStopped.value)
|
||||
)
|
||||
/** 质量确认始终绑定本次真实预览输入,修改设置后立即撤销未完成启动。 */
|
||||
const startScope = computed(() => JSON.stringify(input.value))
|
||||
/** 首次及规则变化时确认,已确认的相同内容不重复弹出规则表单。 */
|
||||
const startPolicy = useBreakdownStartPolicy(projectId, startScope, canStart)
|
||||
/** 复用全局质量表单的完整校验和独立草稿。 */
|
||||
const qualityForm = ref<InstanceType<typeof QualityPolicySettings> | null>(null)
|
||||
/** 仅由用户明确勾选形成规则确认,不能把默认配置当作已确认。 */
|
||||
const rulesAcknowledged = ref(false)
|
||||
/** 每次真实模型启动仍需核对后台任务是否停止。 */
|
||||
const startAcknowledged = ref(false)
|
||||
/** 规则、目标或步骤变化后重新确认,不沿用旧勾选。 */
|
||||
watch([startPolicy.reviewOpen, startPolicy.editorKey, startScope], () => { rulesAcknowledged.value = false })
|
||||
watch(startPolicy.startOpen, () => { startAcknowledged.value = false })
|
||||
/** 关闭整个设置时中断只读确认,不能在关闭后打开迟到的弹窗。 */
|
||||
watch(toolsOpen, shown => { if (!shown) startPolicy.cancel() }, { flush: 'sync' })
|
||||
|
||||
/** 校验用户编辑的规则,成功后进入普通启动确认;此步骤不运行模型。 */
|
||||
async function confirmStartRules() {
|
||||
if (!rulesAcknowledged.value) return
|
||||
const draft = qualityForm.value?.validatedDraft()
|
||||
if (draft) await startPolicy.confirmRules(draft)
|
||||
}
|
||||
|
||||
/** 最终确认费用与任务范围后重新读取规则,再消费本次启动许可。 */
|
||||
async function confirmStart() {
|
||||
if (records.value.length > 0 && !startAcknowledged.value) return
|
||||
if (await startPolicy.verifyStart()) await run('start')
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通启动弹窗只读核对期间仍允许用户取消。
|
||||
* @param shown 弹窗目标显隐状态
|
||||
*/
|
||||
function updateStartOpen(shown: boolean) {
|
||||
if (!shown) startPolicy.cancel()
|
||||
}
|
||||
let previewController: AbortController | undefined
|
||||
let previewVersion = 0
|
||||
|
||||
@@ -395,7 +436,7 @@ 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) return
|
||||
if (action === 'start' && (!canStart.value || !startPolicy.consumePermit())) return
|
||||
const labels: Record<BreakdownAction, string> = {
|
||||
start: '正在拆解剧本',
|
||||
retry: '正在重试失败抽取',
|
||||
@@ -477,12 +518,29 @@ const rules = {
|
||||
:pending="operation.pending"
|
||||
:pending-label="operation.label"
|
||||
v-model:open="toolsOpen"
|
||||
title="拆解设置"
|
||||
:title="startPolicy.reviewOpen.value ? '拆解前确认质量规则' : '拆解设置'"
|
||||
label="拆解设置"
|
||||
:busy="startPolicy.saving.value"
|
||||
fullscreen
|
||||
@closed="finishOpeningIssues"
|
||||
>
|
||||
<section class="panel workspace-panel breakdown-settings-panel">
|
||||
<!-- 以下是在同一全屏抽屉内核对真实质量规则的模块,不叠加第二个抽屉 -->
|
||||
<div v-if="startPolicy.reviewOpen.value && startPolicy.policy.value" class="breakdown-policy-review">
|
||||
<p class="text-sm leading-6 text-muted">请核对动作与物理规则,修改将在继续时保存。当前浏览器会记住确认,规则未变时不再重复提醒。</p>
|
||||
<QualityPolicySettings
|
||||
ref="qualityForm"
|
||||
:key="startPolicy.editorKey.value"
|
||||
:project-id="projectId"
|
||||
:initial-policy="startPolicy.policy.value"
|
||||
:disabled="!canStart || startPolicy.busy.value"
|
||||
/>
|
||||
<NCheckbox v-model:checked="rulesAcknowledged" :disabled="startPolicy.busy.value || !canStart" class="mt-5">
|
||||
我已核对本次拆解使用的质量规则
|
||||
</NCheckbox>
|
||||
<p v-if="startPolicy.error.value" role="alert" class="mt-4 text-sm text-danger">{{ startPolicy.error.value }}</p>
|
||||
</div>
|
||||
<!-- 以下是拆解分组设置模块,规则确认时保留已有预览和草稿 -->
|
||||
<section v-show="!startPolicy.reviewOpen.value" class="panel workspace-panel breakdown-settings-panel">
|
||||
<p
|
||||
v-if="backgroundExecution.discoveryError.value"
|
||||
class="mb-4 text-xs leading-6 text-danger"
|
||||
@@ -583,22 +641,16 @@ const rules = {
|
||||
<span class="mx-2 text-faint">/</span>
|
||||
<strong>{{ preview.estimatedTaskCount }}</strong> 个抽取任务
|
||||
</p>
|
||||
<ConfirmAction
|
||||
<NButton
|
||||
:loading="
|
||||
startPolicy.reading.value ||
|
||||
isOperationRunning(operation, '正在拆解剧本') ||
|
||||
backgroundExecution.active.value
|
||||
"
|
||||
:label="candidateOnly ? '生成拆解候选' : '开始拆解'"
|
||||
:description="
|
||||
candidateOnly
|
||||
? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。'
|
||||
: '将按当前预览配置启动完整的 剧本拆解流程。抽取结束后仍需完成主体整理、分镜生成与入库。'
|
||||
"
|
||||
:acknowledgement="records.length > 0"
|
||||
primary
|
||||
:disabled="!canStart"
|
||||
@confirm="run('start')"
|
||||
/>
|
||||
type="primary"
|
||||
:disabled="!canStart || startPolicy.busy.value"
|
||||
@click="startPolicy.prepare"
|
||||
><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template>{{ candidateOnly ? '生成拆解候选' : '开始拆解' }}</NButton>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<div v-for="group in preview.groups" :key="group.groupId" class="group-chip">
|
||||
@@ -607,6 +659,7 @@ const rules = {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="startPolicy.error.value && !startPolicy.startOpen.value" role="alert" class="mt-4 text-sm text-danger">{{ startPolicy.error.value }}</p>
|
||||
<p v-if="project.status === 'generating'" class="mt-4 text-xs text-danger">
|
||||
剧本仍在生成,暂不允许启动拆解,避免读取到不完整的剧集。
|
||||
</p>
|
||||
@@ -618,6 +671,7 @@ const rules = {
|
||||
</p>
|
||||
</section>
|
||||
<BreakdownCandidatePanel
|
||||
v-show="!startPolicy.reviewOpen.value"
|
||||
:project-id="projectId"
|
||||
:state="qualityObservation.source.value.state || undefined"
|
||||
:quality="quality"
|
||||
@@ -626,7 +680,7 @@ const rules = {
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<!-- 以下是明确标记的历史执行回执,旧任务结论不表示当前候选质量 -->
|
||||
<component :is="executionHistorical ? NCollapse : 'div'" v-if="backgroundExecution.executionId.value" :class="{ 'breakdown-execution-history': executionHistorical }">
|
||||
<component :is="executionHistorical ? NCollapse : 'div'" v-if="backgroundExecution.executionId.value" v-show="!startPolicy.reviewOpen.value" :class="{ 'breakdown-execution-history': executionHistorical }">
|
||||
<component :is="executionHistorical ? NCollapseItem : 'div'" :name="executionHistorical ? 'history' : undefined" :title="executionHistorical ? '历史拆解执行记录(不代表当前质量)' : undefined">
|
||||
<WorkflowExecutionPanel
|
||||
v-if="backgroundExecution.executionId.value"
|
||||
@@ -641,14 +695,34 @@ const rules = {
|
||||
/>
|
||||
</component>
|
||||
</component>
|
||||
<!-- 以下是固定的规则确认底栏,返回不记录确认,继续不会直接调用模型 -->
|
||||
<template v-if="startPolicy.reviewOpen.value" #footer>
|
||||
<NButton :disabled="startPolicy.saving.value" @click="startPolicy.cancel">取消</NButton>
|
||||
<NButton type="primary" :loading="startPolicy.busy.value" :disabled="!rulesAcknowledged || !qualityForm?.canSave || startPolicy.busy.value || !canStart" @click="confirmStartRules"><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template>确认规则并继续</NButton>
|
||||
</template>
|
||||
</WorkspaceTools>
|
||||
<!-- 以下是每次真实模型调用前的费用与任务确认,规则未变时直接进入此步骤 -->
|
||||
<AppDialog
|
||||
:open="startPolicy.startOpen.value"
|
||||
:title="candidateOnly ? '生成拆解候选' : '开始拆解'"
|
||||
:description="candidateOnly ? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。' : '将按当前预览启动完整拆解并调用模型,可能产生模型费用。抽取结束后仍需完成主体整理、分镜生成与入库。'"
|
||||
:busy="operation.pending"
|
||||
@update:open="updateStartOpen"
|
||||
>
|
||||
<NCheckbox v-if="records.length > 0" v-model:checked="startAcknowledged" :disabled="startPolicy.busy.value">我已确认后台任务停止,当前没有同项目的生成或拆解任务在运行。</NCheckbox>
|
||||
<p v-if="startPolicy.error.value" role="alert" class="mt-4 text-sm text-danger">{{ startPolicy.error.value }}</p>
|
||||
<template #footer>
|
||||
<NButton :disabled="operation.pending" @click="startPolicy.cancel">取消</NButton>
|
||||
<NButton type="primary" :loading="startPolicy.reading.value" :disabled="!canStart || startPolicy.busy.value || (records.length > 0 && !startAcknowledged)" @click="confirmStart"><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template>确认{{ candidateOnly ? '生成拆解候选' : '开始拆解' }}</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<NScrollbar v-if="!project?.episodes.length" class="panel-scroll panel">
|
||||
<EmptyState
|
||||
title="还没有可拆解的剧集"
|
||||
description="先完成剧本创作。拆解会读取数据库中的正式剧集,不需要上传 checkpoint。"
|
||||
description="先完成剧本创作。拆解会使用已保存的正式剧集,无需重新上传。"
|
||||
/>
|
||||
</NScrollbar>
|
||||
<template v-else>
|
||||
@@ -799,6 +873,7 @@ const rules = {
|
||||
v-model:open="issuesOpen"
|
||||
:issues="storyboardIssues"
|
||||
:quality="quality"
|
||||
:busy="exceptionSaving"
|
||||
:workflow-error="currentWorkflowError"
|
||||
:locatable="!breakdownBusy && !!shots.length"
|
||||
@locate="locateIssue"
|
||||
@@ -816,6 +891,17 @@ const rules = {
|
||||
>
|
||||
任务状态或结果尚未确认,请先重新读取状态与结果。
|
||||
</p>
|
||||
<!-- 以下是从当前动作冲突带入角色和动作的例外入口,独立保存规则且保留旧例外 -->
|
||||
<ActionExceptionRepair
|
||||
v-if="issuesOpen && qualityObservation.source.value.state && quality.source !== 'history' && quality.actionBlocks.some(block => [...block.blockingCodes, ...block.warningCodes].includes('action_resource_conflict'))"
|
||||
:project-id="projectId"
|
||||
:checkpoint-id="latestCheckpoint?.checkpointId || ''"
|
||||
:state="qualityObservation.source.value.state"
|
||||
:quality="quality"
|
||||
:disabled="issueActionsDisabled"
|
||||
@busy="exceptionSaving = $event"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<CandidateRepairs
|
||||
v-if="issuesOpen && quality.isCandidate && snapshot"
|
||||
:project-id="projectId"
|
||||
@@ -840,21 +926,21 @@ const rules = {
|
||||
<ConfirmAction
|
||||
:loading="isOperationRunning(operation, '正在重试失败抽取')"
|
||||
label="重试失败抽取"
|
||||
description="只重试 character / scene / prop 抽取任务中的失败项。不能用于镜头阶段失败。"
|
||||
description="只重新提取失败的人物、场景或道具,不重做已完成内容。镜头问题请使用对应修复操作。"
|
||||
acknowledgement
|
||||
:disabled="issueActionsDisabled || !recovery.retry"
|
||||
@confirm="run('retry')"
|
||||
/><ConfirmAction
|
||||
:loading="isOperationRunning(operation, '正在补齐镜头')"
|
||||
label="补齐缺失镜头"
|
||||
description="复用已完成剧集的镜头,仅生成尚未完成的 Episode Shot,再进行校验与入库。"
|
||||
description="保留已经完成的镜头,只补齐缺失的镜头,然后检查并保存。"
|
||||
acknowledgement
|
||||
:disabled="issueActionsDisabled || !recovery.shots"
|
||||
@confirm="run('resume-shots')"
|
||||
/><ConfirmAction
|
||||
:loading="isOperationRunning(operation, '正在修复分镜绑定')"
|
||||
label="修复分镜绑定"
|
||||
description="复用已有镜头,修复 SubjectRef 与视觉 Form 绑定,再校验并保存。"
|
||||
description="保留已有镜头,补齐人物、场景、道具及其形态的对应关系,然后检查并保存。"
|
||||
acknowledgement
|
||||
:disabled="issueActionsDisabled || !recovery.storyboard"
|
||||
@confirm="run('resume-storyboard')"
|
||||
@@ -891,6 +977,10 @@ const rules = {
|
||||
.breakdown-settings-panel {
|
||||
container: breakdown-settings / inline-size;
|
||||
}
|
||||
/* 同一抽屉切换步骤时首个可见模块不继承隐藏设置区域的兄弟间距。 */
|
||||
.workspace-tools-body > .breakdown-policy-review + .breakdown-settings-panel {
|
||||
margin-top: 0;
|
||||
}
|
||||
/* 说明与表单留出 16px,避免移除来源标签后紧贴首个字段。 */
|
||||
.breakdown-settings-form {
|
||||
margin-top: 16px;
|
||||
|
||||
Reference in new issue
Block a user