From 10e008ca10f850cfe77c51c8e6093f7692696e23 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 9 Nov 2026 14:40:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(short-drama-agent-front):=20=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E8=BF=9E=E7=BB=AD=E6=80=A7=E7=8A=B6=E6=80=81=E7=AD=BE?= =?UTF-8?q?=E6=94=B6=E4=B8=8E=E8=81=94=E5=90=88=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v02-06-frontend-integration-2026-11-09.md | 34 ++ .../components/ContinuityJointReview.vue | 405 ++++++++++++++++++ .../components/ContinuityReviewDrawer.vue | 72 +++- .../components/ContinuityStateEditor.vue | 150 +++++++ .../production/components/KeyframeCard.vue | 29 +- .../production/components/QualityDialog.vue | 14 +- .../components/ShotProductionAssets.vue | 14 + src/features/production/continuity-joint.ts | 155 +++++++ src/features/production/continuity-state.ts | 85 ++++ src/features/production/continuity.types.ts | 7 + src/features/production/model.ts | 1 + .../production/production-messages.ts | 5 +- src/features/production/types.ts | 2 + src/features/projects/ProjectLayout.vue | 5 + src/features/storyboard/StoryboardPage.vue | 11 + src/lib/http.ts | 10 + src/lib/user-facing-text.ts | 12 + tests/browser/v02-continuity.html | 12 + tests/browser/v02-continuity.ts | 91 ++++ .../production/continuity-joint.test.ts | 157 +++++++ tests/fixtures/continuity-joint.ts | 73 ++++ 21 files changed, 1319 insertions(+), 25 deletions(-) create mode 100644 docs/audits/v02-06-frontend-integration-2026-11-09.md create mode 100644 src/features/production/components/ContinuityJointReview.vue create mode 100644 src/features/production/components/ContinuityStateEditor.vue create mode 100644 src/features/production/continuity-joint.ts create mode 100644 src/features/production/continuity-state.ts create mode 100644 tests/browser/v02-continuity.html create mode 100644 tests/browser/v02-continuity.ts create mode 100644 tests/features/production/continuity-joint.test.ts create mode 100644 tests/fixtures/continuity-joint.ts diff --git a/docs/audits/v02-06-frontend-integration-2026-11-09.md b/docs/audits/v02-06-frontend-integration-2026-11-09.md new file mode 100644 index 0000000..6c2fc5c --- /dev/null +++ b/docs/audits/v02-06-frontend-integration-2026-11-09.md @@ -0,0 +1,34 @@ +# V02-06 前端接入记录 + +2026-11-09,前端根目录 dev,基线 0d58dd8;仅修改前端,未运行真实付费调用或修改受保护三镜。 + +## 正式契约 + +已对照后端四份 frontend-prompt:state-review、consumer-gates、joint-preview、joint-execution,并核对 storyboard.routes.ts、连续性 schema/state/vision/execution 服务。C2 的执行能力覆盖早期 C1 的 executionAvailable=false 限制,资格继续以免费计划当前返回值为准。 + +## 功能 + +- 原连续性抽屉默认固定几何;显式切换 geometry_and_state 后重新读取指纹和 stateContext。边界只取正式紧邻两镜,主体和 sourceIds 只从正式依据选择;before/after 不可辨认时保持 null,意见不默认通过。支持全部十三种维度、证据说明及可选非阻断用途理由。保存仍为用户主动签收,不替代单镜或所有连续性通过。 +- 消费 continuity_review_required,保留原 readiness 门禁及服务端原因;HTTP409 CONTINUITY_REVIEW_REQUIRED 显示具体组问题并可回到 Storyboard 原连续性入口。已有 Primary、Prompt、force 均不清除服务端问题;没有自动重试。 +- 原保存组详情加入联合免费计划,展示真实模型、图片顺序、全部绑定、合并空间图用途、未知执行费用、容量核验;完整脱敏请求与摘要放高级详情。只能读取原签收公开图像地址,不猜测路径。 +- 独立登记真实批准人、操作人、批准材料 SHA 和单次估算范围;maxRequests 固定 1。登记前再次核对总计划 fingerprint,登记不执行,执行必须单独勾选。写入出错即撤销页面批准,断线未知只允许观察,不自动重新批准或重发。 +- 通过免费计划 latestTask/reusableTaskId 找回原任务,沿现有 useWorkflowExecution GET/SSE 与 latest 发现;终态回读业务任务。completed 不推出 passed,原机器解析、当前评估、原人工未知分别追溯。恢复只依据 resumeAvailable/current,明确区分免费解析原回执与原批准下此前未发送的一次请求。 +- 首帧卡片来源复核与画幅、操作组之间增加留白,辅助按钮复用中性底面;质量弹窗免费计划刷新按钮使用块级留白,操作和历史模块间距分明。 + +## 文件与复用 + +新增 continuity-state.ts、ContinuityStateEditor.vue:人工范围类型、输入校验和表单。 +新增 continuity-joint.ts、ContinuityJointReview.vue:正式联合路由、计划、批准、执行和恢复;固定操作复用原抽屉 footer。 +扩展 continuity.types.ts、ContinuityReviewDrawer.vue,复用原诊断、签收、历史接口,不新建质量计算或 SSE 系统。 +扩展 production issue 类型/文案、HTTP 业务错误、项目阻断页和单镜工作区定位入口。 +新增 tests/fixtures/continuity-joint.ts、continuity-joint.test.ts 与 tests/browser/v02-continuity.html/ts。隔离浏览器页只模拟免费诊断,批准、执行、恢复、保存写请求全部拒绝,不连接真实收费模型。 + +## 验证与边界 + +- 定向 Vitest:连续性人工、联合批准/业务失败/恢复/过期、原质量、消息共 5 文件 47 用例通过;更广的 production/projects/storyboard 回归曾为 40 文件 253 用例通过,随后补充两项联合恢复/过期测试也通过。提交钩子将运行最终全量 pnpm check,结果以提交日志为准。 +- TypeScript、Oxlint、ESLint 已执行;最终格式及全量检查随提交钩子复核。 +- 本地 Chrome 复用 localhost:4312 标签页,未使用 Playwright。隔离页面检查默认几何与人工状态范围、空白意见/未知、正式依据选择、长表单滚动、联合图片/合并绑定/未知费用、390×844 窄屏及固定关闭底栏。真实项目检查首帧卡片与质量弹窗的暗色布局、刷新计划和历史模块间距;未点击真实执行或签收。 +- 真实 GET 联合免费预检(原签收 cmw7y6sqt0008rono7bv2lopl):ready、executionAvailable=true、qwen3.8-max、paidCalls=0、最多拟请求 1 次、amount=null;图片序号 1–4,绑定数依次 1/1/1/3。它不代表已获批准或联合审核已通过。 +- 真实授权、联合执行、恢复、状态签收写入没有实测,本次保护正式首组三镜与原签收,自动化使用隔离响应。未生成视频、未修改 Primary、未创造新签收规避缓存。 + +未发现必须新增的后端接口。后续真实联合执行仍需按对象、精确计划、次数及费用获得用户独立明确批准。 diff --git a/src/features/production/components/ContinuityJointReview.vue b/src/features/production/components/ContinuityJointReview.vue new file mode 100644 index 0000000..af8180f --- /dev/null +++ b/src/features/production/components/ContinuityJointReview.vue @@ -0,0 +1,405 @@ + + diff --git a/src/features/production/components/ContinuityReviewDrawer.vue b/src/features/production/components/ContinuityReviewDrawer.vue index a8d65df..2d65b50 100644 --- a/src/features/production/components/ContinuityReviewDrawer.vue +++ b/src/features/production/components/ContinuityReviewDrawer.vue @@ -1,4 +1,7 @@ + diff --git a/src/features/production/components/KeyframeCard.vue b/src/features/production/components/KeyframeCard.vue index 32ed6a6..6080412 100644 --- a/src/features/production/components/KeyframeCard.vue +++ b/src/features/production/components/KeyframeCard.vue @@ -178,13 +178,11 @@ const canSelect = computed(

- 按当前来源人工复核 +
+ 按当前来源人工复核 +

{{ { recorded: '已保存生成输入', 'not-recorded': '历史生成输入未记录', invalid: '生成输入证据已失效' }[ @@ -215,8 +213,13 @@ const canSelect = computed( >恢复已生成图片

{{ formatDate(item.createdAt) }}

-
- +
+ {{ vision.state.value.active || vision.state.value.unknown || vision.uncertain.value ? '查看审核进度' @@ -225,14 +228,18 @@ const canSelect = computed( 编辑此首帧 - 查看首帧校验历史 diff --git a/src/features/production/components/QualityDialog.vue b/src/features/production/components/QualityDialog.vue index 957b87b..f429fc8 100644 --- a/src/features/production/components/QualityDialog.vue +++ b/src/features/production/components/QualityDialog.vue @@ -362,14 +362,11 @@ const optionsExpanded = ref(['options']) v-if="validationPlan.data.value && action === 'validate'" :plan="validationPlan.data.value" /> - 刷新免费审核计划 +
+ 刷新免费审核计划 +

{{ userFacingText(validationPlan.error.value) }}

@@ -545,6 +542,7 @@ const optionsExpanded = ref(['options']) :keyframe-id="target.assetId" :observation="vision" :disabled="disabled || pending" + class="mt-5" initial-open @reviewed="onReviewed" @busy="authorizationPending = $event" diff --git a/src/features/production/components/ShotProductionAssets.vue b/src/features/production/components/ShotProductionAssets.vue index 2a5cce2..097277b 100644 --- a/src/features/production/components/ShotProductionAssets.vue +++ b/src/features/production/components/ShotProductionAssets.vue @@ -1,4 +1,5 @@ + + diff --git a/tests/browser/v02-continuity.ts b/tests/browser/v02-continuity.ts new file mode 100644 index 0000000..95a2204 --- /dev/null +++ b/tests/browser/v02-continuity.ts @@ -0,0 +1,91 @@ +import { createApp, defineComponent, h, ref } from 'vue' +import { NButton, NConfigProvider, NMessageProvider, zhCN, dateZhCN } from 'naive-ui' +import Drawer from '../../src/features/production/components/ContinuityReviewDrawer.vue' +import { createContinuityMock, continuityShots, diagnosisFixture } from '../fixtures/continuity' +import { jointPlan, jointTask, stateContexts } from '../fixtures/continuity-joint' +import '../../src/styles/styles.css' +import '../../src/styles/admin.css' +/** 全部服务隔离,不向真实 API 发写请求。 */ +const mock = createContinuityMock('http://localhost:4312/tests/browser/candidate.svg') +/** 当前隔离计划状态。 */ +const planStatus = ref<'ready' | 'blocked' | 'reusable'>('ready') +/** 当前隔离签收。 */ +const review = { + reviewId: 'mock-review', + reviewer: '隔离审核人', + reviewedAt: '', + status: 'passed', + invalidation: null, + diagnosis: diagnosisFixture( + { shotIds: ['s1', 's2'], sceneFormId: 'scene-form' }, + 'http://localhost:4312/tests/browser/candidate.svg' + ) +} +/** + * 只允许免费诊断和只读回读,批准、签收、执行及恢复全部拒绝。 + * @param input 请求地址 + * @param init 请求选项 + * @returns 隔离响应 + */ +window.fetch = async (input, init) => { + const path = String(input) + if (init?.method && init.method !== 'GET' && !path.endsWith('/continuity/diagnosis')) + return new Response(JSON.stringify({ message: '隔离页禁止写入与付费' }), { status: 403 }) + let data: unknown + if (path.includes('/vision/preview')) + data = { + ...jointPlan, + projectId: 'mock-project', + reviewId: 'mock-review', + status: planStatus.value, + executionAvailable: planStatus.value === 'ready', + reusableTaskId: planStatus.value === 'reusable' ? 't' : null + } + else if (path.includes('/vision-tasks/')) data = { ...jointTask, reviewId: 'mock-review' } + else if (path.endsWith('/reviews/mock-review')) data = review + else if (path.includes('/workflow-executions/')) data = null + else if (path.endsWith('/continuity/diagnosis')) { + const response = await mock.fetcher(input, init) + const body = await response.json() + if (JSON.parse(String(init?.body)).scope) body.data.stateContext = stateContexts + return new Response(JSON.stringify(body)) + } else return mock.fetcher(input, init) + return new Response(JSON.stringify({ data })) +} +/** 可复用现有抽屉的隔离浏览器入口。 */ +const Preview = defineComponent({ + setup() { + /** 当前抽屉。 */ const open = ref(false) + return () => + h('main', { style: 'padding:24px' }, [ + h('h1', 'V02 连续性隔离验收:批准、执行、保存均禁止'), + ...(['ready', 'blocked', 'reusable'] as const).map(value => + h( + NButton, + { + onClick: () => { + planStatus.value = value + open.value = true + } + }, + () => value + ) + ), + h(Drawer, { + open: open.value, + 'onUpdate:open': (v: boolean) => (open.value = v), + projectId: 'mock-project', + shots: continuityShots, + disabled: false + }) + ]) + } +}) +createApp({ + render: () => + h( + NConfigProvider, + { locale: zhCN, dateLocale: dateZhCN }, + { default: () => h(NMessageProvider, null, { default: () => h(Preview) }) } + ) +}).mount('#app') diff --git a/tests/features/production/continuity-joint.test.ts b/tests/features/production/continuity-joint.test.ts new file mode 100644 index 0000000..7678022 --- /dev/null +++ b/tests/features/production/continuity-joint.test.ts @@ -0,0 +1,157 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { mount, flushPromises, type VueWrapper } from '@vue/test-utils' +import { NInput, NInputNumber, NCheckbox } from 'naive-ui' +import Joint from '@/features/production/components/ContinuityJointReview.vue' +import { jointApi } from '@/features/production/continuity-joint' +import { validStateChecks, type StateCheck } from '@/features/production/continuity-state' +import { jointPlan, jointTask, stateContexts } from '../../fixtures/continuity-joint' +import { diagnosisFixture } from '../../fixtures/continuity' +vi.mock('@/features/workflows/execution', () => ({ + useWorkflowExecution: () => ({ + query: { data: { value: null }, loading: { value: false }, error: { value: '' }, refresh: vi.fn<() => void>() }, + track: vi.fn<() => void>() + }) +})) +/** 当前隔离组件。 */ +let wrapper: VueWrapper | undefined +afterEach(() => { + wrapper?.unmount() + vi.restoreAllMocks() +}) +/** + * 挂载真实联合表单,所有服务隔离。 + * @param status 计划状态 + * @returns 组件 + */ +async function open(status: 'ready' | 'blocked' | 'reusable' = 'ready') { + vi.spyOn(jointApi, 'preview').mockResolvedValue({ + ...jointPlan, + status, + executionAvailable: status === 'ready', + reusableTaskId: status === 'reusable' ? 't' : null + }) + vi.spyOn(jointApi, 'task').mockResolvedValue(jointTask) + wrapper = mount(Joint, { + props: { + projectId: 'p', + disabled: false, + review: { + reviewId: 'r', + reviewer: '审核人', + reviewedAt: '', + status: 'passed', + invalidation: null, + diagnosis: diagnosisFixture({ shotIds: ['s1', 's2'], sceneFormId: 'f' }) + } + } + }) + await wrapper.find('button').trigger('click') + await flushPromises() + return wrapper +} +describe('联合审核单次批准和业务状态', () => { + it.each(['ready', 'blocked', 'reusable'] as const)('%s 免费计划不自动批准执行', async status => { + const auth = vi.spyOn(jointApi, 'authorize') + const execute = vi.spyOn(jointApi, 'execute') + const w = await open(status) + expect(w.text()).toContain('未知') + expect(w.text()).toContain('空间参考') + expect(w.text()).toContain('s1') + expect(w.text()).toContain('s2') + expect(auth).not.toHaveBeenCalled() + expect(execute).not.toHaveBeenCalled() + expect((w.vm as unknown as { canExecute: boolean }).canExecute).toBeFalsy() + expect(w.text()).not.toContain('联合任务:通过') + expect(w.text().includes('联合任务:未通过')).toBe(status === 'reusable') + }) + it('明确批准当前总指纹后仍须单独执行确认', async () => { + const w = await open() + const auth = vi + .spyOn(jointApi, 'authorize') + .mockResolvedValue({ authorizationId: 'auth', planFingerprint: jointPlan.fingerprint }) + const execute = vi + .spyOn(jointApi, 'execute') + .mockResolvedValue({ validationTaskId: 't', executionId: 'e', status: 'completed', reused: false }) + w.findAllComponents(NInput).forEach((input, i) => + input.vm.$emit('update:value', ['批准人', '操作人', 'b'.repeat(64)][i]) + ) + w.findAllComponents(NInputNumber).forEach((input, i) => input.vm.$emit('update:value', i)) + await flushPromises() + w.findComponent(NCheckbox).vm.$emit('update:checked', true) + await flushPromises() + const vm = w.vm as unknown as { + authorize: () => Promise + canExecute: boolean + execute: () => Promise + } + await vm.authorize() + expect(auth.mock.calls[0]?.[2].plan).toEqual({ + purpose: 'continuity', + reviewId: 'r', + fingerprint: jointPlan.fingerprint + }) + expect(vm.canExecute).toBe(false) + expect(execute).not.toHaveBeenCalled() + w.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true) + await flushPromises() + await vm.execute() + await flushPromises() + expect(execute).toHaveBeenCalledExactlyOnceWith('p', 'r', 'auth') + expect(w.text()).toContain('联合任务:未通过') + }) +}) +it('状态范围只接受相邻正式主体、原依据和完整人工意见,保留 null', () => { + const check: StateCheck = { + fromShotId: 's1', + toShotId: 's2', + subjectRef: '@CH1', + dimension: 'gaze', + before: null, + after: '向前', + verdict: 'unknown', + sourceIds: ['s1-state'], + evidence: '前镜视线无法辨认' + } + expect(validStateChecks([check], stateContexts)).toBe(true) + expect(validStateChecks([{ ...check, verdict: null }], stateContexts)).toBe(false) + expect(validStateChecks([{ ...check, sourceIds: ['伪造'] }], stateContexts)).toBe(false) + expect(validStateChecks([{ ...check, subjectRef: '@CH2' }], stateContexts)).toBe(false) + expect(validStateChecks([check, check], stateContexts)).toBe(false) +}) + +it('恢复仅使用服务端证明的原任务和原指纹,另行确认且不新授权', async () => { + const w = await open('reusable') + vi.mocked(jointApi.task).mockResolvedValue({ + ...jointTask, + taskStatus: 'failed', + workflowStatus: 'failed', + resumeAvailable: true + }) + const refresh = w.findAll('button').find(b => b.text() === '只读刷新原联合任务')! + await refresh.trigger('click') + await flushPromises() + const auth = vi.spyOn(jointApi, 'authorize') + const resume = vi.spyOn(jointApi, 'resume').mockResolvedValue({ validationTaskId: 't', executionId: 'e' }) + const vm = w.vm as unknown as { canResume: boolean; resume: () => Promise } + expect(vm.canResume).toBe(false) + w.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true) + await flushPromises() + expect(vm.canResume).toBe(true) + expect(w.text()).toContain('免费解析原回执') + await vm.resume() + expect(resume).toHaveBeenCalledExactlyOnceWith('p', 't', jointPlan.fingerprint) + expect(auth).not.toHaveBeenCalled() +}) + +it('旧计划刷新失败后撤销批准,不自动重试或调用收费接口', async () => { + const w = await open() + const auth = vi.spyOn(jointApi, 'authorize') + const execute = vi.spyOn(jointApi, 'execute') + vi.mocked(jointApi.preview).mockRejectedValueOnce(new Error('CONTINUITY_VISION_PLAN_STALE: 来源变化')) + await w.find('button').trigger('click') + await flushPromises() + expect(jointApi.preview).toHaveBeenLastCalledWith('p', 'r', jointPlan.fingerprint, expect.any(AbortSignal)) + expect((w.vm as unknown as { canAuthorize: boolean }).canAuthorize).toBeFalsy() + expect(auth).not.toHaveBeenCalled() + expect(execute).not.toHaveBeenCalled() +}) diff --git a/tests/fixtures/continuity-joint.ts b/tests/fixtures/continuity-joint.ts new file mode 100644 index 0000000..cb43e5a --- /dev/null +++ b/tests/fixtures/continuity-joint.ts @@ -0,0 +1,73 @@ +import type { JointPlan, JointTask } from '../../src/features/production/continuity-joint' +import type { StateContext } from '../../src/features/production/continuity-state' +/** 联合审核隔离计划,不包含真实收费批准。 */ +export const jointPlan: JointPlan = { + projectId: 'p', + reviewId: 'r', + fingerprint: 'a'.repeat(64), + model: '隔离模型', + status: 'ready', + executionAvailable: true, + requiresExplicitApproval: true, + paidCalls: 0, + proposedMaximumProviderRequests: 1, + additionalProviderRequests: 1, + feeEstimate: { currency: 'CNY', amount: null, reason: '待估算' }, + capability: { verified: true, reason: '隔离核验' }, + latestTask: null, + reusableTaskId: null, + imageManifest: [ + { + imageNumber: 1, + label: '首帧', + pixels: { sha256: 'b'.repeat(64), width: 1024, height: 1024 }, + bindings: [{ shotId: 's1', imageId: 'i1', role: 'frame' }] + }, + { + imageNumber: 2, + label: '合并空间图', + pixels: { sha256: 'c'.repeat(64), width: 1024, height: 1024 }, + bindings: [ + { shotId: 's1', imageId: 'layout', role: 'spatial_reference' }, + { shotId: 's2', imageId: 'layout', role: 'spatial_reference' } + ] + } + ], + request: { messages: [{ role: 'user', content: '正式状态与动作依据' }] } +} +/** 已完成但业务失败的原任务。 */ +export const jointTask: JointTask = { + validationTaskId: 't', + executionId: 'e', + reviewId: 'r', + taskStatus: 'completed', + workflowStatus: 'completed', + status: 'failed', + current: true, + planFingerprint: jointPlan.fingerprint, + resumeAvailable: false, + requiresNewProviderRequest: false, + retryAutomatically: false, + diagnosis: { status: 'failed' }, + machineObservation: { summary: '原机器观察' }, + summary: '结构冲突', + feeScope: { currency: 'CNY', estimatedMin: 0, estimatedMax: 1, maxRequests: 1 }, + step: { name: 'general', status: 'completed' } +} +/** 正式相邻两镜人工状态依据。 */ +export const stateContexts: StateContext[] = ['s1', 's2'].map(shotId => ({ + shotId, + generation: { subjects: [{ subjectRef: '@CH1', gaze: shotId === 's1' ? '向左' : '向前' }] }, + requiredActions: [{ id: 'A1', description: '观察', kind: 'action', mustPerformInShot: true }], + sources: [ + { + id: shotId + '-state', + shotId, + kind: 'visual_state', + subjectRef: '@CH1', + field: 'gaze', + text: '当前正式视线', + executable: false + } + ] +}))