From 87427d9d4347fcc5535cbe74728ab00bf53ae796 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 15 Nov 2026 20:55:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(short-drama-agent-front):=20=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E5=88=86=E9=98=B6=E6=AE=B5=E9=95=9C=E5=A4=B4=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E4=B8=8E=E6=91=84=E5=BD=B1=E4=BF=AE=E8=AE=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api-contract-sync.md | 8 + .../v8-9-staged-production-2026-11-15.md | 109 +++ src/features/production/api.ts | 4 +- .../production/components/KeyframeDialog.vue | 14 +- src/features/production/types.ts | 17 + src/features/projects/ProjectLayout.vue | 25 +- .../projects/useProjectStageAccess.ts | 10 +- src/features/storyboard-preparation/types.ts | 9 + src/features/storyboard/StoryboardPage.vue | 215 +++++- .../components/BeatShotDirectory.vue | 85 ++- .../components/DirectionCameraFields.vue | 32 + .../components/DirectionStageReview.vue | 249 +++++++ .../components/ShotDerivedReview.vue | 65 +- .../components/StagedShotPreparation.vue | 208 ++++++ src/features/storyboard/derived-review-api.ts | 14 + .../storyboard/derived-review.types.ts | 37 + src/features/storyboard/staged-derived.ts | 120 ++++ src/features/storyboard/types.ts | 18 + src/features/storyboard/useStoryboard.ts | 356 +++++++++- src/features/workflows/ConfirmAction.vue | 4 +- .../workflows/WorkflowExecutionPanel.vue | 193 +++++- src/features/workflows/execution-api.ts | 11 + src/features/workflows/execution.ts | 70 +- src/lib/user-facing-text.ts | 7 + tests/browser/staged-production.html | 12 + tests/browser/staged-production.ts | 299 ++++++++ tests/features/projects/access.test.ts | 21 + .../storyboard/staged-derived.test.ts | 656 ++++++++++++++++++ tests/features/workflows/pages.test.ts | 55 +- 29 files changed, 2787 insertions(+), 136 deletions(-) create mode 100644 docs/audits/v8-9-staged-production-2026-11-15.md create mode 100644 src/features/storyboard/components/DirectionCameraFields.vue create mode 100644 src/features/storyboard/components/DirectionStageReview.vue create mode 100644 src/features/storyboard/components/StagedShotPreparation.vue create mode 100644 src/features/storyboard/staged-derived.ts create mode 100644 tests/browser/staged-production.html create mode 100644 tests/browser/staged-production.ts create mode 100644 tests/features/storyboard/staged-derived.test.ts diff --git a/docs/api-contract-sync.md b/docs/api-contract-sync.md index b968099..c29d87f 100644 --- a/docs/api-contract-sync.md +++ b/docs/api-contract-sync.md @@ -1,5 +1,13 @@ # 接口数据同步说明 +## 2026-11-15 V8-9.1 / V8-9.2 分阶段镜头生产 + +已在根目录 dev 增量接入正式 shotIds 定向摄影/画面状态、逐镜复用、派生批次停止、原 executionId 刷新恢复观察、独立摄影免费预检与版本绑定采用、原失败及零模型请求恢复展示,以及所选范围的参考素材/计划/资产缺口。默认 force=false、concurrency=1、maxRepairAttempts=0,不自动开始下一阶段或重发未知请求。 + +继续使用原分镜目录、摄影抽屉、工作流观察、统一 HTTP 错误和首帧授权/Preview 流程。正式四镜已完成摄影和画面状态,默认不重复生成。当前项目级生产仍受真实 needs_review 门禁限制,局部完成不改写全项目结论。 + +逐文件职责、真实免费 API 结果、Mock/Chrome 验收、正式使用条件与接口局限见 [本轮完整交接](audits/v8-9-staged-production-2026-11-15.md)。只修改前端,未执行真实付费或正式业务写入;实现验收后用户已授权提交并推送 dev,Git 结果以仓库记录为准。 + ## 2026-11-01 图片预览、质量门禁与派生任务 本次只接入后端根目录 `dev` 的正式 `/api` 路由,依据 `subject-form.routes.ts`、`subject-identity.routes.ts`、`production.routes.ts`、`storyboard.routes.ts` 及相应 Service 核对。未接入 3413 隔离验收服务、脚本、测试专用路由或测试页面;测试夹具只用于 Vitest。 diff --git a/docs/audits/v8-9-staged-production-2026-11-15.md b/docs/audits/v8-9-staged-production-2026-11-15.md new file mode 100644 index 0000000..b1c4d4f --- /dev/null +++ b/docs/audits/v8-9-staged-production-2026-11-15.md @@ -0,0 +1,109 @@ +# V8-9.1 / V8-9.2 前端接入交接 + +## 范围与基线 + +- 前端根目录 `dev`,基线 `1e9ef33d1d3a78766c08933a97f1b2f7c1faecd0`。开始时工作区干净。本轮只修改前端,未创建工作树。实现验收时未提交;随后用户明确授权检查完整 Diff、提交并推送 dev,Git 结果以仓库记录为准,不合并发布分支。 +- 已核对后端根目录 `dev@c6f03454ed98e843a6f4ce3548bb1fbd9154bc18` 的 AGENTS、活跃计划、交接、Storyboard / Workflow 公开文档、两份前端 Prompt,以及正式路由、摄影 Schema、采用服务、派生新鲜度和生产准备服务。 +- 正式项目 `cmw02vpwi000005axrdtus3pa`。所有收费生成、摄影采用、停止和并发写入测试均使用 Mock;正式项目只做免费读取、生产计划和首帧 Preview。没有覆盖正式结果、修改主体绑定或调用文本、图片、Vision、视频、Repair、Primary。 + +## 已交付行为 + +1. 复用分镜工作台的 Episode / Beat / Shot 目录,增加单镜及段落勾选。默认“所选镜头”、`concurrency=1`、`force=false`、`maxRepairAttempts=0`。当前集及全项目仍保留原批量语义,省略 `shotIds`。 +2. 显示正式摄影、画面状态、任务运行/停止/失败及未知请求。有效结果全部具备时不重复 POST;混合范围完整传递正式镜头,后端逐镜复用。空、重复、跨集范围不能提交。HTTP 错误、空响应、字段缺失和合法空目录分别处理。 +3. 画面状态必须等本次范围摄影有效后由用户单独发起,提交前重新读取正式确认、摄影和准备情况。`force=true` 明示下游失效及独立文本费用;同数量不同镜头、参数和范围变化会撤销原确认。 +4. 沿用项目级发现、原 executionId、免费 GET / SSE 和活动任务锁。增加两类派生任务停止入口。停止后使用“已停止”,保留费用和在途结果。相同终态允许接受更晚的回执,拒绝重新激活和重复相同记录;未知领取即使 force 也不能重发。提交连接中断时持久保留待核对范围,只提供免费核对原提交。 +5. 在原“摄影草案与审核”全屏抽屉内,已有摄影且无画面状态时使用独立摄影阶段。复用构图/机位编辑字段,保留其余真实摄影枚举及意图。免费预检携带原 id、ISO 时间、rawJson(含 null)和正式 shotFingerprint;采用冻结同一请求并加入 sourceFingerprint。`changed=false` 的预检仍可采用;幂等回执可接受。409 保留输入、撤销预检并要求显式重读,不自动覆盖。已有下游仍由原组合草案与服务端即时保护处理。 +6. 画面状态免费恢复显示原执行、新执行、零模型请求和原失败历史。`received` 仅表示收到模型结果,不能证明可信回执或业务通过。普通页面没有 trace / 请求指纹输入,没有自动恢复或重试按钮;管理核查与原收费失败保持独立。 +7. 免费核对所选镜头参考素材、正式项目入口、分阶段门禁和逐镜首帧/视频描述/视频缺口。先显示参考,再顺序读取完整计划与资产状态,避免重查询争抢;计划及状态可取消,读取上限为 120 秒。局部就绪不改变全项目生产门禁。 +8. 完整项目上游复检受限时,可凭真实正式确认归属和非零镜头数进入分镜核对;完整生产和素材入口仍保留原门禁。图片授权、OpenAI 选择、原首帧 Preview 指纹、独立 Vision 与 Primary 流程沿用。首帧摄影摘要只展示摄影字段,不混入原文和内部版本。 + +## 复用组件及链路 + +保留 `StoryboardPage`、`BeatShotDirectory`、`DirectoryItem`、`ShotDerivedReview`、`ShotDesign`、`WorkspacePage`、`WorkspaceTools`、`AppDrawer`、`AppDialog`、`AppForm`、`WorkspaceSectionHeading`、`WorkspaceActionTooltip`、`ConfirmAction`、`WorkflowExecutionPanel`、`useWorkflowExecution`、`useQuery`、`runOperation`、`useActionMessage` 与统一 HTTP 错误处理。没有另建分镜页面、任务中心、API 服务或第二套主体归属规则。 + +构图和机位字段抽为 `DirectionCameraFields`,独立阶段与原组合修订共用。原组合草案、场景沿用、视线修订、保存草案及正式首帧候选流程保留。 + +## 真实 API 核对结果 + +以下均在 2026-11-15 本地正式 `localhost:3412/api` 核对,未做正式写入: + +| 接口 | 结果 | +| --- | --- | +| GET Storyboard quality-confirmation(原别名及 `/storyboard/quality-confirmation`) | 200,valid=true,正式 60 镜,确认与证据指纹一致 | +| GET storyboard-directions / storyboard-visual-states,episodeNo=1 | 各 200,本集 7/17,staleCount=0;全项目各 7/60 | +| GET production/entry-readiness | 200,ready=false;当前原因为正式分镜复检 needs_review,不能当作全项目可生产 | +| POST production/plan `{}` | 200,约 19.25 秒,canStart=false,分阶段门禁保持真实阻断 | +| GET production/status | 200,约 16.27 秒,completed=false,stage=subject_images | +| GET image-authorizations | 200,有 1 条授权,billingBlocked=false;未修改授权额度和范围 | +| GET 四镜 references | 200,缺失引用为空;普通引用数量为 3/3/4/5,不等同最终模型参考职责数 | +| POST 四镜 keyframe/preview `{provider:'openai-image'}` | 均 200,返回正式指纹,blocking=false;最终实际参考数量 3/4/5/6 | +| GET 最新画面状态 Workflow 及其 recoveryOf 原任务 | 新任务 completed、recovered=true、actualModelRequests=0;原任务仍 failed,历史保留 | + +生成、停止和采用的正式路由/Schema已核对,写操作成功、失败与并发边界由隔离 Mock 验证。本轮未为验收在正式项目执行任何此类写操作。普通 UI 不开放管理用 SDK 回执恢复参数。 + +## 素材导航禁用原因补充核查 + +用户截图中的“视觉风格、主体身份、形态图片”禁用来自正式 `stage-readiness.preparation.ready=false`,不是这三项自身数据丢失。实际 `visualStyle.ready=true`、`identity.ready=true`;正式质量确认 valid=true,结构检查、来源审计和动作审计均通过。 + +免费质量预检具体返回第 1 集 Beat 3 的 3.1~3.4 共 4 项 `missing_subject_reference`:VisualState 出现“金属搭扣”,但没有绑定独立 `@PR0003`。当前状态为 needs_review、preflightEligible=false,再经 checkCurrent → stage-readiness → 前端三个素材入口共同禁用。 + +已只读定位后端不一致:`storyboard-visual-state.service.ts` 的生成/恢复校验使用 `isBoundAttachedPropPartMention` 判定已绑定母件的连接部件;`storyboard-subject-coverage-audit.service.ts` 在 VisualState 分支直接调用普通 findMissing 并写入问题,没有经过相同归属过滤。因此四镜正式 VS 已免费恢复保存、单镜 Preview 通过,但项目复检仍出现同类误报。此前后端交接所述“覆盖审计共用部件规则”在此分支未完整落实,必须以当前代码与真实接口为准。 + +建议后端复用正式母件/Form/字段归属规则修复原覆盖审计,并覆盖完整 preflight、checkCurrent、stage-readiness、production/entry-readiness 链路。前端本轮不绕过门禁、不新增独立搭扣、不重生成四镜,不改写已通过数据;后端仓库未修改。 + +## 自动化与 Chrome 验收 + +- Vitest 集中回归:30 套、243 项通过,涵盖分镜、制作前审核、工作流、项目访问、原首帧、授权和预览。新增定向用例 19 项,覆盖范围/复用/顺序/force/断线持久保护/停止及在途回执/摄影预检采用/并发/原失败与免费恢复。相关复验 9 套、153 项通过,含免费准备失败/取消及同数量不同范围撤销确认;随后补充原组合摄影完整预览采用回归,新增定向套最终 19 项全部通过。其余未变更用例复用此前通过结果。 +- 本次 Git 检查另执行完整 Vitest:113 套、873 项通过,无真实模型调用。 +- TypeScript、改动范围 Oxlint、Vue ESLint、定向格式与 `git diff --check` 均通过。Vite production build 通过;测试页面不进入正式构建入口。 +- 本机 pnpm 的版本管理拉取返回 fetch failed,因此直接运行项目现有 node_modules/.bin 下同名工具完成上述脚本对应检查,没有安装或升级依赖。 +- 复用本地 Chrome 标签页,全部使用 localhost,未使用 Playwright。正式项目核对四镜 4/4 可复用、默认生成禁用、全项目与局部门禁区分、真实逐镜参考和阶段缺口、免费恢复与原失败并存。覆盖确认只打开查看并取消,恢复 force=false,未提交。 +- `tests/browser/staged-production.html` 全量拦截请求,未知接口 403,不连接正式服务。桌面完成摄影编辑→免费预检→人工确认→采用并刷新;停止批次→查看“已停止”→免费刷新收到在途结果;均显示真实模型请求 0。 +- 手机宽度 390px(约 650 / 905px 高度)检查目录、字段间距、24 行长内容输入、局部滚动、固定标题和底栏、关闭及采用按钮。任务状态和辅助按钮正常换行,不横向挤出。普通、键盘焦点及禁用状态沿用主题中性底面。 +- 当前用户主题主色为蓝色,沿用其已有偏好;主操作仍使用统一 primary,默认主题为绿色。 + +## 文件与职责 + +| 状态 | 文件 | 职责 | +| --- | --- | --- | +| 新增 | src/features/storyboard/staged-derived.ts | 正式范围、来源状态、任务范围及未知领取保护 | +| 新增 | src/features/storyboard/components/DirectionCameraFields.vue | 独立与组合摄影共享构图、机位编辑及间距 | +| 新增 | src/features/storyboard/components/DirectionStageReview.vue | 独立摄影来源读取、免费预检、版本绑定采用与冲突 | +| 新增 | src/features/storyboard/components/StagedShotPreparation.vue | 所选参考、项目阶段计划和逐镜缺口读取 | +| 新增 | tests/features/storyboard/staged-derived.test.ts | 19 项定向流程、费用和历史边界回归 | +| 新增 | tests/browser/staged-production.html | 本地 Chrome 隔离验收入口 | +| 新增 | tests/browser/staged-production.ts | 全请求 Mock 与真实组件场景 | +| 新增 | docs/audits/v8-9-staged-production-2026-11-15.md | 本轮范围、API、验证、文件职责及交接 | +| 修改 | src/features/storyboard/StoryboardPage.vue | 原目录多选、范围/费用确认、准备摘要与停止入口 | +| 修改 | src/features/storyboard/useStoryboard.ts | 定向生成编排、有效结果复用、原任务及未知提交保护 | +| 修改 | src/features/storyboard/types.ts | 正式摄影原版本和可选 shotIds | +| 修改 | src/features/storyboard/components/BeatShotDirectory.vue | 原目录增加镜头、段落多选和窄屏布局 | +| 修改 | src/features/storyboard/components/ShotDerivedReview.vue | 原抽屉接入独立摄影,保留组合草案,共用字段 | +| 修改 | src/features/storyboard/derived-review-api.ts | 原 confirm 路由的 phase=direction 模式 | +| 修改 | src/features/storyboard/derived-review.types.ts | 独立摄影请求、预检和幂等回执契约 | +| 修改 | src/features/workflows/execution-api.ts | 原任务 stop 请求,绑定 projectId | +| 修改 | src/features/workflows/execution.ts | 停止状态、原回执更新、任务恢复观察及防回退 | +| 修改 | src/features/workflows/WorkflowExecutionPanel.vue | 停止/领取/恢复/原失败、位置问题及高级详情 | +| 修改 | src/features/workflows/ConfirmAction.vue | 同数量不同输入或范围改变时撤销费用确认 | +| 修改 | src/features/storyboard-preparation/types.ts | 正式入口中的阶段与逐镜缺口字段 | +| 修改 | src/features/production/types.ts | 正式项目分阶段准备契约 | +| 修改 | src/features/production/api.ts | 完整计划、状态读取的可取消耗时边界 | +| 修改 | src/features/production/components/KeyframeDialog.vue | 摄影摘要排除内部记录元数据,保留原生图流程 | +| 修改 | src/features/projects/ProjectLayout.vue | 正式镜头只读发现,不修改项目质量或生产结论 | +| 修改 | src/features/projects/useProjectStageAccess.ts | 只读分镜与完整生产入口分离 | +| 修改 | src/lib/user-facing-text.ts | 七类来源、范围及未知请求业务错误中文 | +| 修改 | tests/features/projects/access.test.ts | 正式分镜可读、完整生产仍受限 | +| 修改 | tests/features/workflows/pages.test.ts | 原批量操作明确选择范围,更新默认参数及状态回归 | +| 修改 | docs/api-contract-sync.md | 更新现有前端交接索引 | + +删除 0。保留原后端门禁、原组合修订、图片授权、首帧/审核/Primary 与任务发现;强化原范围、版本、停止及请求未知保护。没有重复实现或待迁移的旧主流程。 + +## 正式使用与边界 + +可以在现有分镜工作台选择镜头、核对准备情况,默认复用有效成果;满足真实来源和费用条件后,由用户主动分别启动摄影或画面状态。独立摄影仅适用于尚无下游的真实镜头,最终以服务端预检与事务保护为准。正式四镜已有画面状态,因此应沿原组合摄影修订,不走独立阶段。 + +当前正式项目完整生产仍被服务端 needs_review 阻断。局部首帧 Preview 通过不能解除它,也不代表图片或视觉审核已经完成。后续由用户主动进入原首帧入口选择 openai-image,重新核对来源、参考图、授权额度及未知费用后生成候选;不自动切换供应方或启动后续流程。 + +接口局限:当服务只返回整集 staleCount 而没有逐镜 derivedAssetShotGaps 时,无法可靠定位具体过期镜头。此时已有记录标记“需核对来源”,不猜测过期位置,也不放行依赖未知摄影的画面状态。普通 UI 不提供缺少可信回执时的自动恢复。 + +未执行真实收费或正式写入验收,属于本轮明确禁止项;这部分通过 Mock 覆盖。没有其它主动省略的前端目标。 diff --git a/src/features/production/api.ts b/src/features/production/api.ts index c74e1fb..5b3c772 100644 --- a/src/features/production/api.ts +++ b/src/features/production/api.ts @@ -68,6 +68,8 @@ export const productionApi = { plan: (projectId: string, signal?: AbortSignal, input: ProductionPlanInput = {}) => request(`${projectPath(projectId)}/production/plan`, { method: 'POST', + // 完整项目计划可能耗时,仍可通过信号取消,不重发 POST。 + timeoutMs: 120_000, // 计划携带与当前准备范围一致的阶段,不创建任务。 body: { stage: input.stage, @@ -79,7 +81,7 @@ export const productionApi = { }), /** 读取真实主资产完成状态,不能用任务提交回执代替。 */ status: (projectId: string, signal?: AbortSignal) => - request(`${projectPath(projectId)}/production/status`, { signal }), + request(`${projectPath(projectId)}/production/status`, { signal, timeoutMs: 120_000 }), /** * 启动有限范围的串联生产,最终结果通过任务查询取得。 * @param projectId 正式项目 ID diff --git a/src/features/production/components/KeyframeDialog.vue b/src/features/production/components/KeyframeDialog.vue index e1e219e..25a3b3b 100644 --- a/src/features/production/components/KeyframeDialog.vue +++ b/src/features/production/components/KeyframeDialog.vue @@ -46,7 +46,19 @@ const formRef = ref | null>(null) const directionSummary = computed(() => props.direction ? Object.entries(props.direction) - .filter(([, value]) => value) + .filter( + ([field, value]) => + [ + 'shotSize', + 'cameraAngle', + 'cameraMovement', + 'composition', + 'cameraPosition', + 'lensIntent', + 'depthOfField', + 'visualIntent' + ].includes(field) && value + ) .map(([field, value]) => directionLabel(value, field)) .join(' · ') : '' diff --git a/src/features/production/types.ts b/src/features/production/types.ts index c20f1b5..e2d499d 100644 --- a/src/features/production/types.ts +++ b/src/features/production/types.ts @@ -562,8 +562,23 @@ export interface ProductionPlanStage { manualBlocked: number } +/** 服务端计算的项目分阶段门禁,不能由局部结果推断。 */ +export interface ProductionStageReadiness { + /** 参考素材阶段。 */ referenceImages: { + /** 当前门禁。 */ status: 'ready' | 'blocked' + /** 真实原因。 */ reason: string | null + } + /** 首帧阶段。 */ keyframes: { + /** 当前门禁。 */ status: 'ready' | 'blocked' + /** 真实原因。 */ reason: string | null + } + /** 视频阶段。 */ videos: { /** 当前门禁。 */ status: 'ready' | 'blocked'; /** 真实原因。 */ reason: string | null } +} + /** 后端执行计划只读取资产,不触发模型生成。 */ export interface ProductionPlan { + /** 免费计划返回的分阶段准备状态。 */ + stageReadiness?: ProductionStageReadiness /** 项目配置就绪状态;兼容尚未返回此字段的服务版本。 */ configuration?: { /** 当前配置可用于制作计划。 */ @@ -613,6 +628,8 @@ export interface ProductionPlan { /** 缺少项目配置时仅返回入口状态,各制作阶段不可读取或执行。 */ export interface ProductionConfigurationBlockedPlan { + /** 配置阻断时仍保留真实分阶段门禁。 */ + stageReadiness?: ProductionStageReadiness /** 所属项目编号。 */ projectId: string /** 配置未完成时禁止启动。 */ diff --git a/src/features/projects/ProjectLayout.vue b/src/features/projects/ProjectLayout.vue index 4f1c2ee..93e54b0 100644 --- a/src/features/projects/ProjectLayout.vue +++ b/src/features/projects/ProjectLayout.vue @@ -1,4 +1,6 @@ + diff --git a/src/features/storyboard/components/DirectionStageReview.vue b/src/features/storyboard/components/DirectionStageReview.vue new file mode 100644 index 0000000..33a2fc0 --- /dev/null +++ b/src/features/storyboard/components/DirectionStageReview.vue @@ -0,0 +1,249 @@ + + diff --git a/src/features/storyboard/components/ShotDerivedReview.vue b/src/features/storyboard/components/ShotDerivedReview.vue index b37343f..f59c119 100644 --- a/src/features/storyboard/components/ShotDerivedReview.vue +++ b/src/features/storyboard/components/ShotDerivedReview.vue @@ -1,4 +1,6 @@ + + diff --git a/src/features/storyboard/derived-review-api.ts b/src/features/storyboard/derived-review-api.ts index 83fd4db..878b33b 100644 --- a/src/features/storyboard/derived-review-api.ts +++ b/src/features/storyboard/derived-review-api.ts @@ -1,6 +1,8 @@ import { keyframeScope } from '../production/keyframe-scope' import { request } from '../../lib/http' import type { + DirectionReviewInput, + DirectionReviewResult, DerivedReviewSelection, DraftProviderInput, ShotDraftPreview, @@ -11,6 +13,18 @@ import type { /** 已审摄影草案的正式读写入口。 */ export const derivedReviewApi = { + /** + * 沿原采用接口免费预检或采用独立摄影,不生成画面状态。 + * @param projectId 正式项目 + * @param body 原摄影版本、正式确认与同一草案 + * @param signal 取消过期的免费预检 + * @returns 摄影阶段的版本绑定与幂等回执 + */ + direction: (projectId: string, body: DirectionReviewInput, signal?: AbortSignal) => + request( + `/projects/${encodeURIComponent(projectId)}/storyboard-derived-reviews/confirm`, + { method: 'POST', body, signal } + ), /** 读取指定镜头已保存的原稿,无草案时返回空。 */ draft: (projectId: string, shotId: string, signal?: AbortSignal) => request( diff --git a/src/features/storyboard/derived-review.types.ts b/src/features/storyboard/derived-review.types.ts index 33f761b..3e26dfe 100644 --- a/src/features/storyboard/derived-review.types.ts +++ b/src/features/storyboard/derived-review.types.ts @@ -95,3 +95,40 @@ export interface SaveKeyframeDraft { /** 本次原模型参数。 */ providerInput?: DraftProviderInput /** 受控修订绑定的正式来源。 */ expectedCurrentFormalSourceFingerprint?: string } + +/** 摄影阶段独立修订的完整原版本与草案,不包含虚构的画面状态。 */ +export interface DirectionReviewSelection { + /** 正式镜头身份。 */ shotId: string + /** 已读取的原摄影记录身份。 */ expectedDirectionId: string + /** 已读取的原摄影更新时间,原样回传。 */ expectedDirectionUpdatedAt: string + /** 原摄影原文,保持字符串与 null。 */ expectedDirectionRawJson: string | null + /** 原枚举及完整摄影字段,仅修改用户编辑的内容。 */ direction: ShotDirection & { + /** 段落内镜号。 */ shotNo: number + } +} + +/** 独立摄影免费预检与正式采用请求。 */ +export interface DirectionReviewInput { + /** 仅修改摄影阶段。 */ phase: 'direction' + /** 免费预检不写入。 */ preview: boolean + /** 实际审核署名。 */ reviewer: string + /** 正式确认中的分镜版本。 */ expectedShotFingerprint: string + /** 正式采用必须绑定原免费预检。 */ expectedSourceFingerprint?: string + /** 一到十二个不重复的正式镜头。 */ shots: DirectionReviewSelection[] +} + +/** 原采用接口在摄影阶段返回的幂等回执。 */ +export interface DirectionReviewResult { + /** 所属项目。 */ projectId: string + /** 独立摄影阶段。 */ phase: 'direction' + /** 是否只读预检。 */ preview: boolean + /** 绑定当前摄影、主体与来源的版本。 */ sourceFingerprint: string + /** 正式采用是否写入变化,预检始终为 false。 */ changed: boolean + /** 每镜正式采用情况。 */ shots: Array<{ + /** 正式镜头。 */ shotId: string + /** 正式摄影身份。 */ directionId: string + /** 当前摄影更新时间。 */ updatedAt: string + /** 是否实际更新。 */ changed: boolean + /** 是否已经采用相同草案。 */ alreadyApplied: boolean + }> +} diff --git a/src/features/storyboard/staged-derived.ts b/src/features/storyboard/staged-derived.ts new file mode 100644 index 0000000..e3d8692 --- /dev/null +++ b/src/features/storyboard/staged-derived.ts @@ -0,0 +1,120 @@ +import type { ProductionEntryReadiness } from '../storyboard-preparation/types' +import type { WorkflowExecution } from '../workflows/execution.types' +import type { DesignedShot, StoryboardBatchInput } from './types' + +/** 可独立执行的派生阶段。 */ +export type DerivedPhase = 'direction' | 'visualState' +/** 范围状态以正式读取为准,未知与缺失分别展示。 */ +export type DerivedState = 'current' | 'missing' | 'stale' | 'unknown' +/** 原批次的镜头状态,不作为业务质量结论。 */ +export type DerivedTaskState = 'running' | 'stopped' | 'failed' | 'unresolved' | null + +/** + * 读取单镜正式状态;旧接口缺少逐镜过期信息时保守保留待核对。 + * @param shot 当前正式镜头 + * @param phase 派生阶段 + * @param staleCount 当前集该阶段的真实过期数 + * @param entry 当前项目的正式入口结果 + * @returns 正式有效、缺失、过期或待核对 + */ +export function derivedState( + shot: DesignedShot, + phase: DerivedPhase, + staleCount: number | undefined, + entry?: ProductionEntryReadiness | null +): DerivedState { + if (!shot[phase]) return 'missing' + const gap = entry?.derivedAssetShotGaps?.find(item => item.shotId === shot.shotId) + if (gap) return gap[phase] + return staleCount === 0 ? 'current' : 'unknown' +} + +/** + * 仅按服务端记录的镜头范围关联执行,保留未知请求和停止语义。 + * @param execution 原任务记录 + * @param shotId 正式镜头身份 + * @param episodeNo 当前集号 + * @returns 本镜所属任务状态或无关联 + */ +export function derivedTaskState( + execution: WorkflowExecution | null, + shotId: string, + episodeNo: number +): DerivedTaskState { + if (!execution) return null + const metadata = execution.metadata ?? {} + if (typeof metadata.episodeNo === 'number' && metadata.episodeNo !== episodeNo) return null + if (Array.isArray(metadata.shotIds) && !metadata.shotIds.includes(shotId)) return null + if (execution.status === 'running' || execution.status === 'pending') return 'running' + const text = JSON.stringify(execution.result) + (execution.error ?? '') + if (text.includes('STORYBOARD_DERIVED_REQUEST_UNRESOLVED')) return 'unresolved' + if (execution.stage === 'stopped' || execution.result?.stoppedByUser === true) return 'stopped' + return execution.status === 'failed' ? 'failed' : null +} + +/** + * 固定用户确认的正式范围,拒绝空选、重复或跨集镜头。 + * @param scope 用户选择的范围模式 + * @param shotIds 当前勾选的正式镜头 + * @param shots 当前集正式目录 + * @param episodeNo 当前集号 + * @param concurrency 并发数 + * @param force 是否明确覆盖 + * @returns 不包含占位或重复镜头的正式请求 + */ +export function derivedBatchInput( + scope: 'selected' | 'episode' | 'project', + shotIds: string[], + shots: DesignedShot[], + episodeNo: number, + concurrency: number, + force: boolean +): StoryboardBatchInput { + if (!Number.isSafeInteger(concurrency) || concurrency < 1) throw new Error('请填写有效的并发数。') + if (scope !== 'project' && (!Number.isSafeInteger(episodeNo) || episodeNo < 1)) + throw new Error('请先选择正式剧集。') + if (scope === 'selected') { + if (!shotIds.length || new Set(shotIds).size !== shotIds.length) throw new Error('请选择不重复的正式镜头。') + if (shotIds.some(id => !shots.some(shot => shot.shotId === id))) + throw new Error('所选镜头已不属于当前集,请刷新目录后重新选择。') + } + return { + concurrency, + force, + ...(scope !== 'project' ? { episodeNo } : {}), + ...(scope === 'selected' ? { shotIds: [...shotIds] } : {}) + } +} + +/** + * 原已领取但未收回结果的范围不能因停止或覆盖而再次收费。 + * @param execution 原派生任务 + * @param episodeNo 本次集号,省略表示全项目 + * @param shotIds 本次正式镜头,省略表示整个所选集或项目 + * @returns 本次范围是否存在结果未知的领取 + */ +export function unresolvedDerivedRequest(execution: WorkflowExecution | null, episodeNo?: number, shotIds?: string[]) { + const metadata = execution?.metadata + if (!metadata) return false + const matchesEpisode = + episodeNo === undefined || typeof metadata.episodeNo !== 'number' || metadata.episodeNo === episodeNo + const matchesShots = + !shotIds || + !Array.isArray(metadata.shotIds) || + shotIds.some(shotId => (metadata.shotIds as unknown[]).includes(shotId)) + if ( + matchesEpisode && + matchesShots && + ((execution?.error ?? '') + JSON.stringify(execution?.result)).includes('STORYBOARD_DERIVED_REQUEST_UNRESOLVED') + ) + return true + if (!Array.isArray(metadata.claims)) return false + return metadata.claims.some((claim: unknown) => { + if (!claim || typeof claim !== 'object' || !('state' in claim) || claim.state !== 'submitted') return false + const scope = claim as Record + const claimEpisode = typeof scope.episodeNo === 'number' ? scope.episodeNo : metadata.episodeNo + if (episodeNo !== undefined && typeof claimEpisode === 'number' && episodeNo !== claimEpisode) return false + const ids = Array.isArray(scope.shotIds) ? scope.shotIds : metadata.shotIds + return !shotIds || !Array.isArray(ids) || shotIds.some(shotId => ids.includes(shotId)) + }) +} diff --git a/src/features/storyboard/types.ts b/src/features/storyboard/types.ts index dfc2bda..119fc9c 100644 --- a/src/features/storyboard/types.ts +++ b/src/features/storyboard/types.ts @@ -2,13 +2,27 @@ import type { EpisodeShots } from '../breakdown/types' /** 导演摄影设计的正式数据库字段。 */ export interface ShotDirection { + /** 正式摄影记录身份,编辑前必须重新读取并核对。 */ + id?: string + /** 正式摄影更新时间,采用时原样回传。 */ + updatedAt?: string + /** 正式摄影原文,采用时保留 null 与原始字符串。 */ + rawJson?: string | null + /** 正式景别。 */ shotSize: string + /** 正式摄影角度。 */ cameraAngle: string + /** 正式运镜方式。 */ cameraMovement: string + /** 画面构图原文。 */ composition: string + /** 摄影机位置原文。 */ cameraPosition: string + /** 正式焦段倾向。 */ lensIntent: string + /** 正式景深倾向。 */ depthOfField: string + /** 摄影视觉意图原文。 */ visualIntent: string } @@ -103,7 +117,11 @@ export interface StoryboardBatchResult { /** 批处理配置:默认跳过完成项,force 才覆盖。 */ export interface StoryboardBatchInput { + /** 正式镜头范围;省略时沿用原批量语义,不允许空数组或重复。 */ + shotIds?: string[] + /** 本批最大并发数量。 */ concurrency: number + /** 用户明确开启后覆盖本次范围的已有结果。 */ force: boolean /** 可选试跑剧集范围。 */ episodeNo?: number diff --git a/src/features/storyboard/useStoryboard.ts b/src/features/storyboard/useStoryboard.ts index abc4a17..8e8afda 100644 --- a/src/features/storyboard/useStoryboard.ts +++ b/src/features/storyboard/useStoryboard.ts @@ -1,6 +1,10 @@ +import { derivedBatchInput, derivedState, unresolvedDerivedRequest, type DerivedPhase } from './staged-derived' +import type { WorkflowExecution } from '../workflows/execution.types' +import { workflowExecutionApi } from '../workflows/execution-api' import { useShotSelection } from './useShotSelection' import { useWorkflowExecution } from '../workflows/execution' import type { StoryboardBatchResult, PromptBatchResult, StoryboardShotRegenerationResult } from './types' +import { ApiError } from '../../lib/http' import { computed, ref, watch } from 'vue' import { useQuery } from '../../composables/useQuery' import { useProjectContext } from '../projects/context' @@ -23,16 +27,87 @@ export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all' /** 分镜查询、依赖判断与操作入口;不修改后端 graph。 */ export function useStoryboard() { const context = useProjectContext() + /** 用户勾选的正式镜头;切换项目或集后清空。 */ + const checkedShotIds = ref([]) + /** 默认只处理所选镜头,旧全项目批量需用户明确选择。 */ + const generationScope = ref<'selected' | 'episode' | 'project'>('selected') + /** 本地只保存原待核对请求的范围与任务身份,不代替服务端执行状态。 */ + const pendingSubmission = ref<{ + /** 原工作流名称。 */ workflowName: string + /** 提交前已知的旧执行,避免误认历史任务。 */ previousExecutionId: string + /** 用户已确认的真实范围。 */ batch: { episodeNo?: number; shotIds?: string[] } + } | null>(null) + /** 提交回执未知时保持禁止重复发送,刷新页面后也不解除。 */ + const submissionUnknown = computed(() => pendingSubmission.value !== null) /** 正式镜头与候选来源仍由完整拆解记录判断。 */ const breakdownRecords = context.useWorkflowCheckpoints('breakdown') /** 当前工作区的响应式状态或派生业务条件。 */ const id = computed(() => context.project.value?.id ?? '') + /** + * 保存待核对请求,明确按原项目隔离,切换项目不串写。 + * @param projectId 原请求所属项目 + * @param value 尚未核清的请求或已核清状态 + */ + function setPendingSubmission(projectId: string, value: typeof pendingSubmission.value) { + if (id.value === projectId) pendingSubmission.value = value + try { + const storageKey = `short-drama:derived-submission:${projectId}` + if (value) localStorage.setItem(storageKey, JSON.stringify(value)) + else localStorage.removeItem(storageKey) + } catch { + /* 存储受限时仍保留当前会话的重复请求保护。 */ + } + } + /** 刷新页面恢复原待核对范围,不通过自动重发来恢复。 */ + watch( + id, + projectId => { + pendingSubmission.value = null + try { + const saved = JSON.parse(localStorage.getItem(`short-drama:derived-submission:${projectId}`) ?? 'null') + if ( + saved && + ['storyboard-direction', 'storyboard-visual-state'].includes(saved.workflowName) && + typeof saved.previousExecutionId === 'string' && + saved.batch && + typeof saved.batch === 'object' + ) + pendingSubmission.value = saved + } catch { + /* 损坏记录不构造假的任务身份。 */ + } + }, + { immediate: true, flush: 'sync' } + ) + /** + * 只核对与原范围一致的新执行,不能将旧历史误当作提交成功。 + * @param record 服务端发现的真实工作流 + * @returns 当前记录是否属于待核对请求 + */ + function recognizeSubmission(record: WorkflowExecution) { + const pending = pendingSubmission.value + if ( + !pending || + record.projectId !== id.value || + record.workflowName !== pending.workflowName || + record.id === pending.previousExecutionId + ) + return false + if ( + record.metadata?.episodeNo !== pending.batch.episodeNo || + JSON.stringify(record.metadata?.shotIds) !== JSON.stringify(pending.batch.shotIds) + ) + return false + setPendingSubmission(record.projectId, null) + return true + } + /** 两个镜头工作区共用地址选择,刷新恢复同一正式镜头。 */ const { selectedEpisode, selectedShot } = useShotSelection(() => episodeNo.value) /** 当前工作区的响应式状态或派生业务条件。 */ - const concurrency = ref(2) + const concurrency = ref(1) /** 当前工作区的响应式状态或派生业务条件。 */ - const maxRepairAttempts = ref(2) + const maxRepairAttempts = ref(0) /** 当前工作区的响应式状态或派生业务条件。 */ const force = ref(false) /** 正式镜头查询只补充正式快照正文,不混入最新候选。 */ @@ -69,6 +144,10 @@ export function useStoryboard() { storyboardApi.visualStates(projectId, number, signal) ]) if ( + !directions || + !visualStates || + !Array.isArray(directions.beats) || + !Array.isArray(visualStates.beats) || directions.projectId !== projectId || visualStates.projectId !== projectId || directions.episodeNo !== number || @@ -76,6 +155,38 @@ export function useStoryboard() { ) { throw new Error('分镜查询返回了不匹配的项目或剧集,请刷新后重试。') } + if ( + ![directions.coverage, visualStates.coverage].every( + value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1 + ) || + directions.beats.some(beat => !Array.isArray(beat.shots)) || + visualStates.beats.some(beat => !Array.isArray(beat.shots)) + ) + throw new Error('分镜状态字段缺失,请重新读取;暂不允许生成。') + const directionRows = directions.beats.flatMap(beat => beat.shots) + const visualRows = visualStates.beats.flatMap(beat => beat.shots) + if ( + directionRows.some(row => !row || !Object.hasOwn(row, 'direction') || row.direction === undefined) || + visualRows.some(row => !row || !Object.hasOwn(row, 'visualState') || row.visualState === undefined) + ) + throw new Error('分镜状态字段缺失,请重新读取;暂不允许生成。') + if ( + ![ + directions.shotCount, + directions.directionCount, + directions.staleCount, + visualStates.shotCount, + visualStates.visualStateCount, + visualStates.staleCount + ].every(count => Number.isSafeInteger(count) && count >= 0) || + directionRows.length !== directions.shotCount || + visualRows.length !== visualStates.shotCount || + directionRows.length !== visualRows.length || + new Set(directionRows.map(row => row.shotId)).size !== directionRows.length || + new Set(visualRows.map(row => row.shotId)).size !== visualRows.length || + directionRows.some(row => !row.shotId || !visualRows.some(visual => visual.shotId === row.shotId)) + ) + throw new Error('分镜状态记录不完整,请重新读取;暂不允许生成。') return { directions, visualStates } }) const data = query.data @@ -88,10 +199,8 @@ export function useStoryboard() { () => !approval.loading.value && !approval.error.value && currentStoryboardApproval(approval.data.value, id.value) ) - /** 仅在分镜页且项目设计尚未就绪时读取全项目覆盖,不为每次切换剧集重复查询。 */ - const designProject = computed(() => - approved.value && context.stageReadiness.value?.storyboard.ready === false ? id.value : '' - ) + /** 分镜页独立读取项目覆盖和门禁,不为切换剧集重复查询。 */ + const designProject = computed(() => id.value) /** 全项目有效设计数量与制作前检查使用同一接口。 */ const designEntry = useQuery(designProject, (projectId, signal) => projectId ? preparationApi.entry(projectId, signal) : Promise.resolve(null) @@ -127,6 +236,92 @@ export function useStoryboard() { const shots = computed(() => mergeDesignedShots(data.value?.directions ?? null, data.value?.visualStates ?? null, source.value) ) + /** 目录与集号共同约束选中范围,刷新后删除已失效的镜头身份。 */ + watch( + queryKey, + () => { + checkedShotIds.value = [] + force.value = false + }, + { flush: 'sync' } + ) + watch(shots, rows => { + checkedShotIds.value = checkedShotIds.value.filter(shotId => rows.some(shot => shot.shotId === shotId)) + }) + /** 本次实际选中的镜头,不用预设镜号或历史快照代替正式身份。 */ + const selectedShots = computed(() => shots.value.filter(shot => checkedShotIds.value.includes(shot.shotId))) + /** 本次范围说明同时用于按钮与费用确认,改变范围会撤销确认。 */ + const scopeLabel = computed(() => + generationScope.value === 'project' + ? '全项目' + : generationScope.value === 'episode' + ? `第 ${episodeNo.value} 集` + : `第 ${episodeNo.value} 集所选 ${checkedShotIds.value.length} 镜` + ) + /** + * 单镜状态只采用正式缺口与真实过期计数。 + * @param shot 当前正式镜头 + * @param phase 派生阶段 + * @returns 本镜正式来源状态 + */ + function stateFor(shot: (typeof shots.value)[number], phase: DerivedPhase) { + return derivedState( + shot, + phase, + phase === 'direction' ? data.value?.directions.staleCount : data.value?.visualStates.staleCount, + designEntry.error.value || designEntry.loading.value ? null : designEntry.data.value + ) + } + /** 所选范围与全项目门禁分开计算,只放行已核实的本次摄影。 */ + const rangeDirectionCurrent = computed(() => { + if (generationScope.value === 'project') { + const assets = designEntry.data.value?.derivedAssets + return ( + !designEntry.loading.value && + !designEntry.error.value && + !!assets?.shotCount && + assets.directionCount === assets.shotCount && + assets.staleDirectionCount === 0 + ) + } + const range = generationScope.value === 'selected' ? selectedShots.value : shots.value + return range.length > 0 && range.every(shot => stateFor(shot, 'direction') === 'current') + }) + /** + * 有效结果全部具备时不再提交相同阶段,覆盖模式须单独确认。 + * @param phase 当前派生阶段 + * @returns 本次范围是否仍有待补齐结果 + */ + function needsGeneration(phase: DerivedPhase) { + if (force.value) return true + if (generationScope.value === 'project') { + const assets = designEntry.data.value?.derivedAssets + if (!assets || designEntry.error.value || designEntry.loading.value) return false + return phase === 'direction' + ? assets.directionCount !== assets.shotCount || assets.staleDirectionCount !== 0 + : assets.visualStateCount !== assets.shotCount || assets.staleVisualStateCount !== 0 + } + const range = generationScope.value === 'selected' ? selectedShots.value : shots.value + return range.some(shot => stateFor(shot, phase) !== 'current') + } + /** 处理范围必须已经选定且属于当前正式目录。 */ + const rangeValid = computed( + () => + generationScope.value !== 'selected' || + (checkedShotIds.value.length > 0 && checkedShotIds.value.length === selectedShots.value.length) + ) + /** + * 只修改正式目录中的勾选项。 + * @param ids 用户切换的单镜或段落范围 + */ + function toggleShots(ids: string[]) { + if (operation.value.pending || query.loading.value) return + if (ids.some(shotId => !shots.value.some(shot => shot.shotId === shotId))) return + const remove = ids.every(shotId => checkedShotIds.value.includes(shotId)) + checkedShotIds.value = remove + ? checkedShotIds.value.filter(shotId => !ids.includes(shotId)) + : [...new Set([...checkedShotIds.value, ...ids])] + } /** 明确指定的镜头不存在时不代选其它镜头;首次进入才选择第一镜。 */ const shot = computed(() => selectedShot.value ? shots.value.find(item => item.shotId === selectedShot.value) : shots.value[0] @@ -143,6 +338,8 @@ export function useStoryboard() { const blocked = computed( () => operation.value.pending || + submissionUnknown.value || + query.loading.value || !!context.error.value || context.summaryBlocked.value || breakdownRecords.loading.value || @@ -179,31 +376,46 @@ export function useStoryboard() { context.stageReadiness.value?.projectId === id.value && context.stageReadiness.value.subjectAssets.ready === true ) - /** 批量操作继续使用原项目级前置条件。 */ + /** + * 只阻断本次范围未收回的模型请求,停止不解除费用核对。 + * @param phase 当前派生阶段 + * @returns 是否存在重发风险 + */ + function unresolvedRequest(phase: DerivedPhase) { + return unresolvedDerivedRequest( + executions[phase === 'direction' ? 1 : 2]!.observer.query.data.value, + generationScope.value === 'project' ? undefined : episodeNo.value, + generationScope.value === 'selected' ? checkedShotIds.value : undefined + ) + } + /** 派生使用本次正式范围,旧拆镜与视频描述继续遵守项目素材门禁。 */ const allowed = computed>(() => ({ 'shots-current': projectAssetsReady.value && !blocked.value && episodeNo.value > 0 && hasCurrentEpisodeShots.value, 'direction-all': - projectAssetsReady.value && approved.value && !blocked.value && - prerequisites.value.directionProject && - batchValid.value, - 'visual-all': - projectAssetsReady.value && - approved.value && - !blocked.value && - prerequisites.value.visualProject && batchValid.value && - repairsValid.value, + rangeValid.value && + needsGeneration('direction') && + !unresolvedRequest('direction'), + 'visual-all': + approved.value && + !blocked.value && + batchValid.value && + repairsValid.value && + rangeValid.value && + rangeDirectionCurrent.value && + needsGeneration('visualState') && + !unresolvedRequest('visualState'), prompts: projectAssetsReady.value && !blocked.value && shots.value.length > 0 && batchValid.value })) /** 正式后台任务观察器;重生成使用后端 breakdown 名称并通过 metadata 区分。 */ const executions = [ { title: '单集镜头重生成', observer: useWorkflowExecution(id, 'breakdown') }, - { title: '项目导演设计', observer: useWorkflowExecution(id, 'storyboard-direction') }, - { title: '项目即时状态', observer: useWorkflowExecution(id, 'storyboard-visual-state') }, + { title: '摄影设计任务', observer: useWorkflowExecution(id, 'storyboard-direction') }, + { title: '画面状态任务', observer: useWorkflowExecution(id, 'storyboard-visual-state') }, { title: '项目视频提示词', observer: useWorkflowExecution(id, 'video-prompt') } ] /** 真实终态结果才发布回执;刷新恢复也按后端 metadata 归属。 */ @@ -211,7 +423,9 @@ export function useStoryboard() { watch( () => entry.observer.query.data.value, (record, previous) => { - if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return + if (!record || record.projectId !== id.value) return + recognizeSubmission(record) + if (!['completed', 'failed'].includes(record.status)) return const target = getStoryboardSession(record.projectId) if (index === 0 && record.metadata?.action !== 'regenerate-storyboard-episode') return if (record.result && (record.status === 'completed' || index === 1 || index === 2)) { @@ -238,13 +452,14 @@ export function useStoryboard() { target.receipt = { kind: 'prompts', title: entry.title, result } } else { const result = record.result as unknown as StoryboardBatchResult - if (result.projectId !== record.projectId || !Array.isArray(result.episodes)) return - target.receipt = { kind: 'batch', title: entry.title, result } + if (result.projectId === record.projectId && Array.isArray(result.episodes)) + target.receipt = { kind: 'batch', title: entry.title, result } } } if (!previous) return void Promise.all([ query.refresh(), + designEntry.refresh(), index === 0 ? context.refreshWorkflow('breakdown', record.projectId, record.id + ':' + record.status) : context.refreshWorkflow(null, record.projectId, record.id + ':' + record.status), @@ -254,19 +469,32 @@ export function useStoryboard() { ) } - /** 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。 */ + /** + * 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。 + * @param command 用户已确认的生成阶段 + */ async function run(command: StoryboardCommand) { if (!allowed.value[command]) return const projectId = id.value - const batch = { concurrency: concurrency.value, force: force.value } + const derived = command === 'direction-all' || command === 'visual-all' + const batch = derived + ? derivedBatchInput( + generationScope.value, + checkedShotIds.value, + shots.value, + episodeNo.value, + concurrency.value, + force.value + ) + : { concurrency: concurrency.value, force: force.value } const repairs = maxRepairAttempts.value const targetEpisode = episodeNo.value const target = getStoryboardSession(projectId) const expectedApproval = JSON.stringify(approval.data.value?.evidence) const titles: Record = { 'shots-current': `第 ${targetEpisode} 集镜头`, - 'direction-all': '项目导演设计', - 'visual-all': '项目即时状态', + 'direction-all': `${scopeLabel.value}摄影设计`, + 'visual-all': `${scopeLabel.value}画面状态`, prompts: '项目视频提示词' } target.receipt = null @@ -292,13 +520,57 @@ export function useStoryboard() { terminal ? record.id + ':' + record.status : undefined ) } else if (command === 'direction-all') { + setPendingSubmission(projectId, { + workflowName: 'storyboard-direction', + previousExecutionId: executions[1]!.observer.executionId.value, + batch + }) const started = await storyboardApi.generateDirections(projectId, batch) + if (!started?.executionId) throw new Error('未收到可核对的任务回执,请先读取原任务状态。') + setPendingSubmission(projectId, null) await executions[1]!.observer.track(started.executionId, projectId) } else if (command === 'visual-all') { + const fresh = await storyboardApi.directions(projectId, targetEpisode) + const freshEntry = await preparationApi.entry(projectId) + if (!freshEntry?.derivedAssets) throw new Error('准备状态未返回有效结果,请重新读取。') + if ( + batch.episodeNo && + fresh.staleCount !== 0 && + (!batch.shotIds || + batch.shotIds.some( + shotId => + freshEntry.derivedAssetShotGaps?.find(item => item.shotId === shotId)?.direction !== + 'current' + )) + ) + throw new Error('本次范围的摄影来源未确认有效,请刷新并核对。') + if ( + !batch.episodeNo && + (freshEntry.derivedAssets.directionCount !== freshEntry.derivedAssets.shotCount || + freshEntry.derivedAssets.staleDirectionCount !== 0) + ) + throw new Error('请先补齐全项目当前有效摄影。') + const freshRows = fresh.beats.flatMap(beat => beat.shots) + if (batch.shotIds?.some(shotId => !freshRows.some(row => row.shotId === shotId))) + throw new Error('所选镜头来源已变化,请重新读取正式目录。') + if ( + batch.episodeNo && + freshRows + .filter(row => !batch.shotIds || batch.shotIds.includes(row.shotId)) + .some(row => !row.direction) + ) + throw new Error('请先补齐本次范围的摄影设计。') + setPendingSubmission(projectId, { + workflowName: 'storyboard-visual-state', + previousExecutionId: executions[2]!.observer.executionId.value, + batch + }) const started = await storyboardApi.generateVisualStates(projectId, { ...batch, maxRepairAttempts: repairs }) + if (!started?.executionId) throw new Error('未收到可核对的任务回执,请先读取原任务状态。') + setPendingSubmission(projectId, null) await executions[2]!.observer.track(started.executionId, projectId) } else { target.prompts = {} @@ -306,16 +578,50 @@ export function useStoryboard() { await executions[3]!.observer.track(started.executionId, projectId) } }) + const cause = getOperation(projectId).cause + if (!submitted && cause instanceof ApiError && cause.status >= 400 && cause.status < 500) + setPendingSubmission(projectId, null) if (id.value !== projectId) return await Promise.all([ query.refresh(), + designEntry.refresh(), context.refreshStageReadiness(), submitted && command !== 'shots-current' ? context.summaryQuery.refresh() : Promise.resolve() ]) } + /** + * 仅免费读取待核对原任务,不重新提交生成。 + * @returns 是否找到范围一致的原执行;无待核对请求时不处理 + */ + async function inspectSubmission() { + const pending = pendingSubmission.value + const projectId = id.value + if (!pending) return + const record = await workflowExecutionApi.latest(projectId, pending.workflowName) + if (id.value !== projectId) return false + if (!record || !recognizeSubmission(record)) return false + const entry = + executions.find(item => item.observer.query.data.value?.workflowName === record.workflowName) ?? + executions[pending.workflowName === 'storyboard-direction' ? 1 : 2]! + await entry.observer.track(record.id, projectId) + return true + } + return { id, + inspectSubmission, + checkedShotIds, + generationScope, + selectedShots, + scopeLabel, + stateFor, + needsGeneration, + unresolvedRequest, + toggleShots, + rangeDirectionCurrent, + designEntry, + submissionUnknown, selectedEpisode, episodeNo, episodeOptions, diff --git a/src/features/workflows/ConfirmAction.vue b/src/features/workflows/ConfirmAction.vue index f51d8d9..70a8d01 100644 --- a/src/features/workflows/ConfirmAction.vue +++ b/src/features/workflows/ConfirmAction.vue @@ -11,6 +11,8 @@ const props = defineProps<{ description: string /** 费用与覆盖确认默认警告;调用方可按真实语义使用默认、成功或错误状态。 */ status?: 'default' | 'warning' | 'success' | 'error' + /** 同数量的不同镜头或输入变化时,也撤销原费用确认。 */ + confirmationKey?: string /** 前置条件未满足时禁止操作。 */ disabled?: boolean /** 当前操作请求是否仍在执行。 */ @@ -35,7 +37,7 @@ function requestOpen() { } /** 取消后重新打开,或确认目标改变,都必须重新确认任务与费用。 */ -watch([open, () => props.label, () => props.description], () => { +watch([open, () => props.label, () => props.description, () => props.confirmationKey], () => { acknowledged.value = false }) diff --git a/src/features/workflows/WorkflowExecutionPanel.vue b/src/features/workflows/WorkflowExecutionPanel.vue index 2e4854d..5ff8844 100644 --- a/src/features/workflows/WorkflowExecutionPanel.vue +++ b/src/features/workflows/WorkflowExecutionPanel.vue @@ -1,4 +1,8 @@ + + diff --git a/tests/browser/staged-production.ts b/tests/browser/staged-production.ts new file mode 100644 index 0000000..ea7057c --- /dev/null +++ b/tests/browser/staged-production.ts @@ -0,0 +1,299 @@ +import { createApp, computed, defineComponent, h, provide, ref } from 'vue' +import { NButton, NConfigProvider, NGlobalStyle, NMessageProvider, zhCN, dateZhCN } from 'naive-ui' +import { useTheme } from '../../src/composables/useTheme' +import ActionMessageProvider from '../../src/components/ui/ActionMessageProvider.vue' +import StoryboardPage from '../../src/features/storyboard/StoryboardPage.vue' +import { projectContextKey, useProjectData } from '../../src/features/projects/context' +import { + directionsResult, + visualStatesResult, + storyboardCheckpoint +} from '../../src/features/storyboard/testing/fixtures' +import { preparationFixture } from '../features/storyboard-preparation/fixtures' +import type { WorkflowExecution } from '../../src/features/workflows/execution.types' +import { billingCatalog, billingProfile } from '../fixtures/billing' +import '../../src/styles/styles.css' +import '../../src/styles/admin.css' + +/** 隔离场景,任何请求都不会进入本地真实 API。 */ +const scenario = new URLSearchParams(location.search).get('scenario') ?? 'direction' +/** 固定隔离身份以验证刷新恢复,和正式项目完全分开。 */ +const projectId = `staged-browser-${scenario}` +/** 显式显示模拟写入次数,便于 Chrome 验证没有自动生产。 */ +const calls = ref>([]) +/** 当前正式模拟摄影,保留并发版本与原文。 */ +let directions = directionsResult(projectId) +for (const row of directions.beats.flatMap(beat => beat.shots)) + row.direction = { + ...row.direction!, + id: 'original-' + row.shotId, + updatedAt: '2026-11-15T00:00:00.000Z', + rawJson: '原摄影原文' + } +/** 尚无画面状态的镜头允许独立摄影修订。 */ +let visuals = visualStatesResult(projectId, 1, scenario === 'complete') +/** 用于验证用户明确覆盖后的二次保护。 */ +let conflictNext = false +/** 场景的正式质量确认。 */ +const approval = preparationFixture(projectId) +/** 任务当前持久化投影,模拟停止后在途回执的保留。 */ +let task: WorkflowExecution = { + id: 'mock-derived-task', + projectId, + workflowName: 'storyboard-direction', + status: scenario === 'running' ? 'running' : 'completed', + stage: scenario === 'running' ? 'storyboardDirection' : 'completed', + current: 0, + total: 2, + currentResourceId: null, + metadata: { + derivedBatchVersion: 1, + episodeNo: 1, + shotIds: ['shot-db-1-1', 'shot-db-1-2'], + claims: [{ state: 'submitted', episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] }] + }, + result: null, + error: null, + startedAt: '2026-11-15T00:00:00Z', + completedAt: null, + createdAt: '2026-11-15T00:00:00Z', + updatedAt: '2026-11-15T00:00:00Z' +} +if (scenario === 'running') { + try { + const saved = JSON.parse(localStorage.getItem('staged-browser:task') ?? 'null') + if (saved?.projectId === projectId) task = saved + } catch { + /* 隔离数据损坏不构造正式任务。 */ + } + localStorage.setItem(`short-drama:workflow-execution:${projectId}:storyboard-direction`, task.id) +} +/** + * 全量拦截当前页面请求,未知接口拒绝,不连接正式项目、模型或资产。 + * @param input 原接口地址 + * @param init 原请求方法与正文 + * @returns 与原正式路由同形状的隔离数据 + */ +window.fetch = async (input, init) => { + const path = String(input), + method = init?.method ?? 'GET' + const body = init?.body ? JSON.parse(String(init.body)) : undefined + calls.value.push({ path, method, body }) + let data: unknown + if (path.endsWith(`/projects/${projectId}`)) + data = { + id: projectId, + title: '隔离验收剧本', + status: 'completed', + episodes: [{ episode: 1, title: '来信', content: '隔离内容' }], + characters: [] + } + else if (path.endsWith('/stage-readiness')) + data = { + projectId, + ...Object.fromEntries( + ['script', 'breakdown', 'preparation', 'visualStyle', 'identity', 'subjectAssets', 'storyboard'].map( + key => [key, { ready: true, reason: null }] + ) + ) + } + else if (path.includes('/checkpoints')) data = path.includes('view=summary') ? [] : [storyboardCheckpoint()] + else if (path.endsWith('/storyboard-quality-confirmation')) + data = { ...approval.approval, valid: true, confirmation: approval.record } + else if (path.endsWith('/storyboard-quality-confirmation/preflight')) + data = { + current: { ...approval.approval, valid: true, confirmation: approval.record }, + quality: approval.quality + } + else if (path.includes('/storyboard-directions?')) data = directions + else if (path.includes('/storyboard-visual-states?')) data = visuals + else if (path.endsWith('/storyboard/duration-audit')) data = { projectId, issues: [] } + else if (path.endsWith('/duration-budget')) data = { projectId, episodes: [] } + else if (path.endsWith('/production/entry-readiness')) + data = { + ...approval.entry, + derivedAssets: { + ...approval.entry.derivedAssets, + shotCount: 2, + directionCount: 2, + visualStateCount: visuals.visualStateCount, + staleDirectionCount: 0, + staleVisualStateCount: 0 + } + } + else if (path.endsWith('/generation-models')) data = billingCatalog + else if (path.endsWith('/creative-profile')) data = { ...billingProfile, projectId } + else if (path.includes('/keyframe-review-draft')) data = null + else if (path.endsWith('/storyboard-derived-reviews/confirm')) { + if (conflictNext && body.preview === false) { + conflictNext = false + return new Response( + JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影已由另一审核人更新,请重新核对。' }), + { status: 409 } + ) + } + if (!body.preview) + directions.beats[0]!.shots[0]!.direction = { + ...directions.beats[0]!.shots[0]!.direction!, + ...body.shots[0].direction + } + data = { + projectId, + phase: 'direction', + preview: body.preview, + sourceFingerprint: 'c'.repeat(64), + changed: !body.preview, + shots: [ + { + shotId: body.shots[0].shotId, + directionId: 'original-shot-db-1-1', + updatedAt: '2026-11-15T00:00:00.000Z', + changed: !body.preview, + alreadyApplied: false + } + ] + } + } else if ( + path.endsWith('/storyboard-directions/generate') || + path.endsWith('/storyboard-visual-states/generate') + ) { + const visual = path.includes('visual-states') + if (visual) visuals = visualStatesResult(projectId, 1, true) + else directions = directionsResult(projectId) + task = { + ...task, + id: 'mock-' + calls.value.length, + workflowName: visual ? 'storyboard-visual-state' : 'storyboard-direction', + status: 'completed', + stage: 'completed', + metadata: { ...body, claims: [{ state: 'received' }] }, + result: { + projectId, + episodeCount: 1, + completedEpisodes: 1, + skippedEpisodes: 0, + failedEpisodes: 0, + episodes: [{ episodeNo: 1, status: 'completed' }] + }, + updatedAt: new Date().toISOString() + } + data = { executionId: task.id, projectId, status: 'running' } + } else if (path.endsWith('/stop')) { + task = { + ...task, + status: 'failed', + stage: 'stopped', + result: { stoppedByUser: true, retryAutomatically: false }, + updatedAt: new Date().toISOString() + } + localStorage.setItem('staged-browser:task', JSON.stringify(task)) + setTimeout(() => { + task = { + ...task, + metadata: { ...task.metadata, claims: [{ state: 'received' }] }, + updatedAt: new Date().toISOString() + } + localStorage.setItem('staged-browser:task', JSON.stringify(task)) + }, 1000) + data = task + } else if (path.includes('/workflow-executions/')) data = task + else if (path.endsWith('/references')) data = { shotId: path.split('/').at(-2), references: [], missing: [] } + else if (path.endsWith('/production/plan')) + data = { + projectId, + configuration: { status: 'blocked', reason: '隔离项目尚未设置图片模型' }, + entryReadiness: { ready: false, reason: '仅所选镜头准备完成,项目未就绪' }, + stageReadiness: { + referenceImages: { status: 'ready', reason: null }, + keyframes: { status: 'blocked', reason: '需要核对首帧预览' }, + videos: { status: 'blocked', reason: '尚无主视频' } + }, + details: null + } + else if (path.endsWith('/production/status')) data = { projectId, completed: false } + else return new Response(JSON.stringify({ message: '隔离页面拒绝未声明接口,不连接真实服务' }), { status: 403 }) + return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } }) +} +/** 整页复用原上下文及分镜组件,只增加隔离控制栏。 */ +const Workspace = defineComponent({ + setup() { + const id = ref(projectId) + const context = useProjectData(id) + provide(projectContextKey, context) + return () => h(StoryboardPage) + } +}) +/** 主题只用于当前隔离页渲染,不更改用户存储偏好。 */ +const Preview = defineComponent({ + setup() { + const theme = useTheme() + const writes = computed( + () => calls.value.filter(call => call.method === 'POST' && /generate|confirm|stop/.test(call.path)).length + ) + return () => + h( + NConfigProvider, + { locale: zhCN, dateLocale: dateZhCN, theme: theme.theme.value, themeOverrides: theme.overrides.value }, + { + default: () => + h( + NMessageProvider, + {}, + { + default: () => + h( + ActionMessageProvider, + {}, + { + default: () => [ + h(NGlobalStyle), + h( + 'header', + { + style: 'height:70px;padding:12px;display:flex;gap:12px;flex-wrap:wrap;overflow:auto' + }, + [ + ...Object.entries({ + direction: '独立摄影', + complete: '已有结果', + running: '停止与刷新' + }).map(([key, label]) => + h( + NButton, + { + onClick: () => { + location.href = `?scenario=${key}` + } + }, + () => label + ) + ), + h( + NButton, + { + onClick: () => { + conflictNext = true + } + }, + () => '模拟一次并发冲突' + ), + h( + 'span', + { role: 'status' }, + `模拟写入 ${writes.value} 次 · 真实模型请求 0 次` + ) + ] + ), + h('div', { style: 'height:calc(100dvh - 70px);min-height:0' }, [ + h(Workspace) + ]) + ] + } + ) + } + ) + } + ) + } +}) +createApp(Preview).mount('#app') diff --git a/tests/features/projects/access.test.ts b/tests/features/projects/access.test.ts index d906d2e..d4a6bc1 100644 --- a/tests/features/projects/access.test.ts +++ b/tests/features/projects/access.test.ts @@ -1,3 +1,5 @@ +import { preparationApi } from '@/features/storyboard-preparation/api' +import { preparationFixture } from '../storyboard-preparation/fixtures' import { h } from 'vue' import { createMemoryHistory, createRouter } from 'vue-router' import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils' @@ -36,6 +38,7 @@ function readiness(id: string, ready = true): ProjectStageReadiness { } beforeEach(() => { + vi.spyOn(preparationApi, 'approval').mockImplementation(async id => preparationFixture(id).approval) vi.spyOn(workflowExecutionApi, 'latest').mockResolvedValue(null) vi.spyOn(projectsApi, 'stageReadiness').mockImplementation(async id => readiness(id)) }) @@ -115,6 +118,24 @@ async function openProject(initialPath: string) { } describe('剧本完成前的下游访问限制', () => { + it('正式分镜存在时可读查看,完整生产与素材入口仍保留原门禁', async () => { + const id = 'formal-read-only' + const state = readiness(id, false) + state.script.ready = true + vi.mocked(projectsApi.stageReadiness).mockResolvedValue(state) + vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed')) + vi.spyOn(projectsApi, 'checkpointSummaries').mockResolvedValue([]) + const fixture = preparationFixture(id) + vi.mocked(preparationApi.approval).mockResolvedValue({ + ...fixture.approval, + valid: true, + confirmation: fixture.record + }) + const { mounted } = await openProject(`/projects/${id}/storyboard`) + expect(mounted).toHaveBeenCalledWith('storyboard') + expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false) + }) + it('已知项目资产入口不受制作阶段拦截,未知工作区仍默认锁定', async () => { const id = 'independent-project-assets' vi.mocked(projectsApi.stageReadiness).mockResolvedValue(readiness(id, false)) diff --git a/tests/features/storyboard/staged-derived.test.ts b/tests/features/storyboard/staged-derived.test.ts new file mode 100644 index 0000000..2ca3689 --- /dev/null +++ b/tests/features/storyboard/staged-derived.test.ts @@ -0,0 +1,656 @@ +import { defineComponent, h } from 'vue' +import { flushPromises, mount, type VueWrapper } from '@vue/test-utils' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { NCheckbox, NInput, NTag } from 'naive-ui' +import { testProjectContext } from '@/testing/project-context' +import { projectContextKey } from '@/features/projects/context' +import { useStoryboard } from '@/features/storyboard/useStoryboard' +import { derivedBatchInput, derivedState, derivedTaskState } from '@/features/storyboard/staged-derived' +import { + designedShot, + directionsResult, + visualStatesResult, + storyboardCheckpoint +} from '@/features/storyboard/testing/fixtures' +import { preparationFixture } from '../storyboard-preparation/fixtures' +import ShotDerivedReview from '@/features/storyboard/components/ShotDerivedReview.vue' +import { imagePreviewFixture } from '../../fixtures/image-preview' +import { billingCatalog, billingProfile } from '../../fixtures/billing' +import StagedShotPreparation from '@/features/storyboard/components/StagedShotPreparation.vue' +import ConfirmAction from '@/features/workflows/ConfirmAction.vue' +import DirectionStageReview from '@/features/storyboard/components/DirectionStageReview.vue' +import WorkflowExecutionPanel from '@/features/workflows/WorkflowExecutionPanel.vue' +import type { WorkflowExecution } from '@/features/workflows/execution.types' +import { workflowExecutionApi } from '@/features/workflows/execution-api' + +/** 每个用例独立项目,避免共享活动锁污染其它范围。 */ +let serial = 0 +/** 已挂载实例统一释放轮询与取消信号。 */ +const wrappers: VueWrapper[] = [] +afterEach(() => { + wrappers.splice(0).forEach(wrapper => wrapper.unmount()) + localStorage.clear() +}) +/** + * 不接触真实数据的公开 API 响应。 + * @param data 隔离业务数据 + * @returns 公开接口形状的独立响应 + */ +function response(data: unknown) { + return new Response(JSON.stringify({ data })) +} +/** + * 构造后端持久化任务,领取信息与业务结果分别保留。 + * @param projectId 隔离项目身份 + * @param overrides 当前用例的任务状态 + * @returns 独立任务记录 + */ +function execution(projectId: string, overrides: Partial = {}): WorkflowExecution { + return { + id: 'execution-1', + projectId, + workflowName: 'storyboard-direction', + status: 'completed', + stage: 'completed', + current: 1, + total: 1, + currentResourceId: null, + metadata: { episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] }, + result: null, + error: null, + startedAt: null, + completedAt: null, + createdAt: '2026-11-15T00:00:00Z', + updatedAt: '2026-11-15T00:00:00Z', + ...overrides + } +} +/** + * 挂载真实编排 Hook,所有生产 POST 由内存模拟明确隔离。 + * @param projectId 隔离项目身份 + * @returns 编排状态与明确的模拟控制 + */ +async function harness(projectId = `staged-${++serial}`) { + const context = testProjectContext(projectId) + context.data.value!.checkpoints = [storyboardCheckpoint()] + const fixture = preparationFixture(projectId) + let directions = directionsResult(projectId) + directions.beats[1]!.shots[0]!.direction = null + directions.directionCount = 1 + let visuals = visualStatesResult(projectId) + let current = execution(projectId) + let failTransport = false + const fetcher = vi.fn(async (url, init) => { + const path = String(url) + if (path.endsWith('/storyboard-quality-confirmation')) + return response({ ...fixture.approval, valid: true, confirmation: fixture.record }) + if (path.includes('/storyboard-directions?')) return response(directions) + if (path.includes('/storyboard-visual-states?')) return response(visuals) + if (path.endsWith('/production/entry-readiness')) + return response({ + ...fixture.entry, + derivedAssets: { + ...fixture.entry.derivedAssets, + shotCount: 2, + directionCount: directions.directionCount, + staleDirectionCount: directions.staleCount, + staleVisualStateCount: visuals.staleCount + } + }) + if (path.endsWith('/stop')) { + current = { + ...current, + status: 'failed', + stage: 'stopped', + result: { stoppedByUser: true, retryAutomatically: false }, + updatedAt: '2026-11-15T00:02:00Z' + } + return response(current) + } + if (path.includes('/workflow-executions/latest')) return response(current) + if (path.includes('/workflow-executions/')) return response(current) + if (path.endsWith('/storyboard-directions/generate')) { + if (failTransport) throw new Error('断线') + directions = directionsResult(projectId) + current = execution(projectId) + return response({ executionId: current.id, projectId, status: 'running' }) + } + if (path.endsWith('/storyboard-visual-states/generate')) { + visuals = visualStatesResult(projectId, 1, true) + current = execution(projectId, { id: 'execution-vs', workflowName: 'storyboard-visual-state' }) + return response({ executionId: current.id, projectId, status: 'running' }) + } + throw new Error(`没有模拟 ${init?.method ?? 'GET'} ${path}`) + }) + vi.stubGlobal('fetch', fetcher) + let state!: ReturnType + const component = defineComponent({ + setup() { + state = useStoryboard() + return () => h('div') + } + }) + const options = { global: { provide: { [projectContextKey as symbol]: context } } } + const wrapper = mount(component, options) + wrappers.push(wrapper) + await flushPromises() + return { + state, + context, + fetcher, + wrapper, + remount: async () => { + const next = mount(component, options) + wrappers.push(next) + await flushPromises() + return state + }, + setTransportFailure: () => { + failTransport = true + }, + setCurrent: (record: WorkflowExecution) => { + current = record + } + } +} +/** + * 提取实际收费派生请求,免费读取不计入。 + * @param fetcher 隔离请求记录 + * @returns 模拟派生生成请求 + */ +function posts(fetcher: ReturnType>) { + return fetcher.mock.calls.filter( + ([url, init]) => init?.method === 'POST' && /storyboard-(directions|visual-states)\/generate/.test(String(url)) + ) +} + +describe('按正式镜头定向派生', () => { + it.each([{ ids: [] }, { ids: ['one', 'one'] }, { ids: ['outside'] }])('拒绝空、重复和跨集范围 %j', ({ ids }) => { + expect(() => derivedBatchInput('selected', ids, [designedShot('one')], 1, 1, false)).toThrow(/请选择|所选镜头/) + }) + it('旧批量省略 shotIds,所选范围保留 force=false 与正式集号', () => { + expect(derivedBatchInput('selected', ['one'], [designedShot('one')], 1, 1, false)).toEqual({ + episodeNo: 1, + shotIds: ['one'], + concurrency: 1, + force: false + }) + expect(derivedBatchInput('project', [], [], 1, 1, false)).toEqual({ concurrency: 1, force: false }) + expect(derivedBatchInput('episode', [], [], 1, 1, false)).toEqual({ + episodeNo: 1, + concurrency: 1, + force: false + }) + }) + it('正式存在、缺失、过期与无法定位的过期来源分别显示', () => { + const shot = designedShot('one') + expect(derivedState(shot, 'direction', 0)).toBe('current') + expect(derivedState({ ...shot, direction: null }, 'direction', 0)).toBe('missing') + expect(derivedState(shot, 'direction', 1)).toBe('unknown') + const entry = preparationFixture().entry + entry.derivedAssetShotGaps = [{ episode: 1, shotId: 'one', direction: 'stale', visualState: 'current' }] + expect(derivedState(shot, 'direction', 1, entry)).toBe('stale') + expect(derivedState(shot, 'visualState', 1, entry)).toBe('current') + }) + it('混合范围复用已有结果,摄影完成后仅显式提交画面状态,刷新不重复 POST', async () => { + const { state, fetcher } = await harness() + expect(state.allowed.value['direction-all']).toBe(false) + state.toggleShots(['shot-db-1-1', 'shot-db-1-2']) + expect(state.allowed.value['visual-all']).toBe(false) + await state.run('visual-all') + expect(posts(fetcher)).toHaveLength(0) + await state.run('direction-all') + await flushPromises() + expect(posts(fetcher)).toHaveLength(1) + expect(JSON.parse(String(posts(fetcher)[0]![1]?.body))).toEqual({ + episodeNo: 1, + shotIds: ['shot-db-1-1', 'shot-db-1-2'], + concurrency: 1, + force: false + }) + expect(state.allowed.value['visual-all']).toBe(true) + await state.query.refresh() + expect(posts(fetcher)).toHaveLength(1) + await state.run('visual-all') + expect(JSON.parse(String(posts(fetcher)[1]![1]?.body))).toMatchObject({ + maxRepairAttempts: 0, + force: false, + shotIds: ['shot-db-1-1', 'shot-db-1-2'] + }) + await state.run('visual-all') + expect(posts(fetcher)).toHaveLength(2) + }) + it('有效镜头默认禁用重复生成;覆盖是明确切换,切集清空选择及覆盖', async () => { + const { state, fetcher } = await harness() + state.toggleShots(['shot-db-1-1']) + expect(state.allowed.value['direction-all']).toBe(false) + state.force.value = true + expect(state.allowed.value['direction-all']).toBe(true) + await state.run('direction-all') + expect(JSON.parse(String(posts(fetcher)[0]![1]?.body)).force).toBe(true) + state.selectedEpisode.value = 2 + await flushPromises() + expect(state.checkedShotIds.value).toEqual([]) + expect(state.force.value).toBe(false) + }) + it('提交回执断线后持久保护,重新挂载只免费核对原范围,不重新 POST', async () => { + const setup = await harness() + setup.state.toggleShots(['shot-db-1-2']) + setup.setTransportFailure() + await setup.state.run('direction-all') + expect(setup.state.submissionUnknown.value).toBe(true) + setup.wrapper.unmount() + const restored = await setup.remount() + restored.toggleShots(['shot-db-1-2']) + await restored.run('direction-all') + expect(posts(setup.fetcher)).toHaveLength(1) + setup.setCurrent( + execution(restored.id.value, { + id: 'accepted-original', + metadata: { episodeNo: 1, shotIds: ['shot-db-1-2'] } + }) + ) + await restored.inspectSubmission() + expect(restored.submissionUnknown.value).toBe(false) + expect(restored.executions[1]!.observer.executionId.value).toBe('accepted-original') + expect(posts(setup.fetcher)).toHaveLength(1) + }) + it('停止后保留终态,免费刷新接收在途回执,不重新发生成', async () => { + const setup = await harness() + const current = execution(setup.state.id.value, { + status: 'running', + metadata: { + episodeNo: 1, + shotIds: ['shot-db-1-1'], + claims: [{ state: 'submitted', shotIds: ['shot-db-1-1'] }] + } + }) + setup.setCurrent(current) + const observer = setup.state.executions[1]!.observer + await observer.track(current.id, setup.state.id.value) + expect(observer.canStop.value).toBe(true) + await observer.stop() + expect(observer.query.data.value?.stage).toBe('stopped') + expect(observer.active.value).toBe(false) + setup.setCurrent({ + ...observer.query.data.value!, + metadata: { claims: [{ state: 'received' }] }, + updatedAt: '2026-11-15T00:03:00Z' + }) + await observer.query.refresh() + expect(observer.query.data.value?.metadata?.claims).toEqual([{ state: 'received' }]) + expect(observer.query.data.value?.status).toBe('failed') + expect(posts(setup.fetcher)).toHaveLength(0) + expect(setup.fetcher.mock.calls.filter(([url]) => String(url).endsWith('/stop'))).toHaveLength(1) + }) + it('已停止但原请求仍在途时,force也不能绕过所选范围费用核对', async () => { + const setup = await harness() + const record = execution(setup.state.id.value, { + status: 'failed', + stage: 'stopped', + result: { stoppedByUser: true }, + metadata: { + episodeNo: 1, + shotIds: ['shot-db-1-1'], + claims: [{ episodeNo: 1, shotIds: ['shot-db-1-1'], state: 'submitted' }] + } + }) + setup.setCurrent(record) + await setup.state.executions[1]!.observer.track(record.id, setup.state.id.value) + setup.state.toggleShots(['shot-db-1-1']) + setup.state.force.value = true + expect(setup.state.allowed.value['direction-all']).toBe(false) + await setup.state.run('direction-all') + expect(posts(setup.fetcher)).toHaveLength(0) + setup.state.toggleShots(['shot-db-1-1', 'shot-db-1-2']) + setup.state.toggleShots(['shot-db-1-1']) + expect(setup.state.allowed.value['direction-all']).toBe(true) + }) + it('停止按项目原执行 POST,未知请求与范围外镜头分开', async () => { + const record = execution('p', { + status: 'failed', + stage: 'stopped', + error: 'STORYBOARD_DERIVED_REQUEST_UNRESOLVED' + }) + expect(derivedTaskState(record, 'shot-db-1-1', 1)).toBe('unresolved') + expect(derivedTaskState(record, 'outside', 1)).toBeNull() + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(response(record))) + await workflowExecutionApi.stop('original/1', 'p') + expect(fetch).toHaveBeenCalledWith( + '/api/workflow-executions/original%2F1/stop', + expect.objectContaining({ method: 'POST', body: '{"projectId":"p"}' }) + ) + }) +}) + +describe('独立摄影沿原采用入口', () => { + /** + * 挂载原字段编辑与独立阶段,模拟端只返回正式契约。 + * @param conflict 是否制造正式采用并发冲突 + * @returns 真实编辑器与隔离请求记录 + */ + async function editor(conflict = false) { + const projectId = `direction-review-${++serial}` + const fixture = preparationFixture(projectId) + const directions = directionsResult(projectId) + directions.beats[0]!.shots[0]!.direction = { + ...directions.beats[0]!.shots[0]!.direction!, + id: 'direction-original', + updatedAt: '2026-11-15T01:00:00.000Z', + rawJson: null + } + const fetcher = vi.fn(async (url, init) => { + const path = String(url) + if (path.endsWith('/storyboard-quality-confirmation')) + return response({ ...fixture.approval, valid: true, confirmation: fixture.record }) + if (path.includes('/storyboard-directions?')) return response(directions) + if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId)) + if (path.endsWith('/storyboard-derived-reviews/confirm')) { + const body = JSON.parse(String(init?.body)) + if (conflict && !body.preview) + return new Response( + JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影版本已变化,请重新读取。' }), + { status: 409 } + ) + return response({ + projectId, + phase: 'direction', + preview: body.preview, + sourceFingerprint: 'c'.repeat(64), + changed: false, + shots: [ + { + shotId: 'shot-db-1-1', + directionId: 'direction-original', + updatedAt: '2026-11-15T01:00:00.000Z', + changed: false, + alreadyApplied: !body.preview + } + ] + }) + } + throw new Error('没有模拟 ' + path) + }) + vi.stubGlobal('fetch', fetcher) + const wrapper = mount(DirectionStageReview, { + props: { projectId, episodeNo: 1, shot: { ...designedShot(), visualState: null }, disabled: false } + }) + wrappers.push(wrapper) + await flushPromises() + return { wrapper, fetcher } + } + it('免费预检冻结完整原版本,changed=false仍可采用,同草案支持幂等回执', async () => { + const { wrapper, fetcher } = await editor() + const inputs = wrapper.findAllComponents(NInput) + inputs[0]!.vm.$emit('update:value', '修订构图,保持已绑定主体') + inputs[2]!.vm.$emit('update:value', '实际审核人') + await flushPromises() + await wrapper + .findAll('button') + .find(button => button.text() === '免费预检摄影修改')! + .trigger('click') + await flushPromises() + expect(wrapper.text()).toContain('预检通过') + expect(wrapper.vm.canAdopt).toBe(false) + wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true) + await flushPromises() + expect(wrapper.vm.canAdopt).toBe(true) + await wrapper.vm.adopt() + const calls = fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm')) + expect(calls).toHaveLength(2) + const preview = JSON.parse(String(calls[0]![1]?.body)) + const adopt = JSON.parse(String(calls[1]![1]?.body)) + expect(preview).toMatchObject({ + phase: 'direction', + preview: true, + reviewer: '实际审核人', + expectedShotFingerprint: 'b'.repeat(64), + shots: [ + { + expectedDirectionId: 'direction-original', + expectedDirectionRawJson: null, + expectedDirectionUpdatedAt: '2026-11-15T01:00:00.000Z', + direction: { shotSize: 'medium', cameraAngle: 'eye-level', composition: '修订构图,保持已绑定主体' } + } + ] + }) + expect(adopt).toEqual({ ...preview, preview: false, expectedSourceFingerprint: 'c'.repeat(64) }) + expect(preview.shots[0]).not.toHaveProperty('visualState') + expect(wrapper.emitted('adopted')).toHaveLength(1) + }) + it('修改署名或内容撤销预检;并发409保留输入且不自动覆盖', async () => { + const { wrapper, fetcher } = await editor(true) + const inputs = wrapper.findAllComponents(NInput) + inputs[2]!.vm.$emit('update:value', '审核人') + await flushPromises() + await wrapper + .findAll('button') + .find(button => button.text() === '免费预检摄影修改')! + .trigger('click') + await flushPromises() + wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true) + await flushPromises() + await wrapper.vm.adopt() + expect(wrapper.vm.canAdopt).toBe(false) + expect(wrapper.emitted('adopted')).toBeUndefined() + expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm'))).toHaveLength(2) + expect(inputs[2]!.props('value')).toBe('审核人') + await wrapper + .findAll('button') + .find(button => button.text() === '重新读取正式来源')! + .trigger('click') + await flushPromises() + await wrapper + .findAll('button') + .find(button => button.text() === '免费预检摄影修改')! + .trigger('click') + await flushPromises() + inputs[0]!.vm.$emit('update:value', '又一次修改') + await flushPromises() + expect(wrapper.text()).not.toContain('预检通过') + }) +}) + +describe('已有下游的原组合摄影修订', () => { + it('保留画面状态、原预览指纹和正式来源,不绕入独立摄影 phase', async () => { + const projectId = `combined-${++serial}` + const fixture = preparationFixture(projectId) + const shot = designedShot() + const fetcher = vi.fn(async (url, init) => { + const path = String(url) + if (path.includes('/keyframe-review-draft')) return response(null) + if (path.endsWith('/preflight')) + return response({ + current: { ...fixture.approval, valid: true, confirmation: fixture.record }, + quality: fixture.quality + }) + if (path.includes('/keyframe-spec')) + return response({ shotId: shot.shotId, formalSourceFingerprint: 'e'.repeat(64), references: [] }) + if (path.includes('/generation-spec')) return response({ shotId: shot.shotId, subjects: [] }) + if (path.includes('/storyboard-directions?')) return response(directionsResult(projectId)) + if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId, 1, true)) + if (path.endsWith('/generation-models')) return response(billingCatalog) + if (path.endsWith('/creative-profile')) return response({ ...billingProfile, projectId }) + if (path.includes('/keyframe/preview')) + return response({ + ...imagePreviewFixture(), + shotId: shot.shotId, + draftFingerprint: 'd'.repeat(64), + productionReady: false, + productionGate: { ready: false, reason: '项目尚未完成' }, + sceneSources: [] + }) + if (path.endsWith('/storyboard-derived-reviews/confirm')) + return response({ shots: [{ shotId: shot.shotId }] }) + throw new Error(`未模拟 ${init?.method ?? 'GET'} ${path}`) + }) + vi.stubGlobal('fetch', fetcher) + const wrapper = mount(ShotDerivedReview, { + attachTo: document.body, + props: { projectId, episodeNo: 1, shot, shots: [shot], disabled: false } + }) + wrappers.push(wrapper) + await wrapper.get('button').trigger('click') + await flushPromises() + expect(wrapper.findComponent(DirectionStageReview).exists()).toBe(false) + const preview = [...document.querySelectorAll('.app-drawer button')].find( + button => button.textContent?.trim() === '免费预览摄影草案' + )! + expect(preview.disabled).toBe(false) + preview.click() + await flushPromises() + const reviewer = wrapper.findAllComponents(NInput).find(input => input.attributes('aria-label') === '审核人')! + reviewer.vm.$emit('update:value', '组合审核人') + wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true) + await flushPromises() + const adopt = [...document.querySelectorAll('.app-drawer button')].find( + button => button.textContent?.trim() === '正式采用本镜' + )! + expect(adopt.disabled).toBe(false) + adopt.click() + await flushPromises() + const call = fetcher.mock.calls.find(([url]) => String(url).endsWith('/storyboard-derived-reviews/confirm'))! + const body = JSON.parse(String(call[1]?.body)) + expect(body).not.toHaveProperty('phase') + expect(body.shots[0]).toMatchObject({ + expectedDraftFingerprint: 'd'.repeat(64), + expectedCurrentFormalSourceFingerprint: 'e'.repeat(64), + draft: { visualState: { shotNo: shot.shotNo }, expectedShotFingerprint: 'b'.repeat(64) } + }) + expect(wrapper.emitted('changed')).toHaveLength(1) + }) +}) + +describe('原失败、停止及免费恢复展示', () => { + it('停止不显示普通质量失败或成功,收到结果不暗示通过', () => { + const wrapper = mount(WorkflowExecutionPanel, { + props: { + execution: execution('stopped-ui', { + status: 'failed', + stage: 'stopped', + result: { stoppedByUser: true }, + metadata: { claims: [{ state: 'submitted' }, { state: 'received' }] } + }), + loading: false, + error: '' + } + }) + wrappers.push(wrapper) + expect(wrapper.getComponent(NTag).text()).toBe('已停止') + expect(wrapper.getComponent(NTag).props('type')).toBe('default') + expect(wrapper.text()).toContain('请求结果未知 1 步') + expect(wrapper.text()).not.toContain('制作任务执行失败') + }) + it('免费恢复关联原失败历史,只有免费 GET,不出现重新生成成功', async () => { + const original = execution('recovery-ui', { + id: 'failed-original', + workflowName: 'storyboard-visual-state', + status: 'failed', + error: '原结果校验未通过' + }) + const fetcher = vi.fn().mockResolvedValue(response(original)) + vi.stubGlobal('fetch', fetcher) + const wrapper = mount(WorkflowExecutionPanel, { + props: { + execution: execution('recovery-ui', { + workflowName: 'storyboard-visual-state', + metadata: { recoveryOf: original.id }, + result: { recovered: true, actualModelRequests: 0 } + }), + loading: false, + error: '' + } + }) + wrappers.push(wrapper) + await flushPromises() + expect(wrapper.text()).toContain('新增模型请求 0 次') + expect(wrapper.text()).toContain('原失败执行仍保留为失败') + expect(wrapper.text()).toContain('原结果校验未通过') + expect(wrapper.text()).not.toContain('重新生成成功') + expect(fetcher.mock.calls.every(([, options]) => options?.method === 'GET')).toBe(true) + }) +}) + +describe('免费准备与精确范围确认', () => { + it('未点击不请求,参考、计划和资产错误分开,不把失败当尚未生成', async () => { + const fetcher = vi.fn(async url => { + if (String(url).endsWith('/references')) + return new Response(JSON.stringify({ message: '参考数据读取失败' }), { status: 500 }) + if (String(url).endsWith('/production/plan')) + return new Response(JSON.stringify({ message: '计划读取失败' }), { status: 500 }) + return response({ projectId: 'preparation-errors', completed: false }) + }) + vi.stubGlobal('fetch', fetcher) + const wrapper = mount(StagedShotPreparation, { + props: { projectId: 'preparation-errors', active: true, shots: [designedShot('one')] } + }) + wrappers.push(wrapper) + await flushPromises() + expect(fetcher).not.toHaveBeenCalled() + await wrapper.get('button').trigger('click') + await flushPromises() + expect(wrapper.text()).toContain('参考数据读取失败') + expect(wrapper.text()).toContain('计划读取失败') + expect(wrapper.text()).toContain('尚未完成') + expect(wrapper.text()).not.toContain('参考素材缺失') + expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([ + '/api/storyboard-shots/one/references', + '/api/projects/preparation-errors/production/plan', + '/api/projects/preparation-errors/production/status' + ]) + expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1) + expect(JSON.parse(String(fetcher.mock.calls[1]![1]?.body))).toEqual({}) + }) + it('关闭抽屉取消完整计划,迟到响应不回填也不再读取资产状态', async () => { + let resolvePlan!: (value: Response) => void + let planSignal: AbortSignal | null = null + const fetcher = vi.fn(async (url, init) => { + if (String(url).endsWith('/references')) return response({ shotId: 'one', references: [], missing: [] }) + planSignal = init?.signal as AbortSignal + return new Promise(resolve => { + resolvePlan = resolve + }) + }) + vi.stubGlobal('fetch', fetcher) + const wrapper = mount(StagedShotPreparation, { + props: { projectId: 'cancel-plan', active: true, shots: [designedShot('one')] } + }) + wrappers.push(wrapper) + await flushPromises() + await wrapper.get('button').trigger('click') + await flushPromises() + expect(fetcher).toHaveBeenCalledTimes(2) + await wrapper.setProps({ active: false }) + await flushPromises() + expect((planSignal as AbortSignal | null)?.aborted).toBe(true) + resolvePlan(response({ projectId: 'cancel-plan', entryReadiness: { ready: true }, stageReadiness: {} })) + await flushPromises() + expect(wrapper.text()).not.toContain('项目生产入口:已就绪') + expect(fetcher).toHaveBeenCalledTimes(2) + }) + it('同镜头数量但身份改变时撤销旧费用确认', async () => { + const wrapper = mount(ConfirmAction, { + attachTo: document.body, + props: { + label: '补齐所选 1 镜', + description: '收费文本模型与覆盖影响说明', + confirmationKey: 'shot-one', + acknowledgement: true + } + }) + wrappers.push(wrapper) + await wrapper.get('button').trigger('click') + await flushPromises() + const checkbox = document.querySelector('.app-dialog [role="checkbox"]')! + checkbox.click() + await flushPromises() + const confirm = [...document.querySelectorAll('.app-dialog button')].find( + button => button.textContent?.trim() === '确认补齐所选 1 镜' + )! + expect(confirm.disabled).toBe(false) + await wrapper.setProps({ confirmationKey: 'shot-two' }) + await flushPromises() + expect(confirm.disabled).toBe(true) + expect(wrapper.emitted('confirm')).toBeUndefined() + }) +}) diff --git a/tests/features/workflows/pages.test.ts b/tests/features/workflows/pages.test.ts index 6fa1677..2d9b97f 100644 --- a/tests/features/workflows/pages.test.ts +++ b/tests/features/workflows/pages.test.ts @@ -117,6 +117,19 @@ function stubFetch(fetcher: Mock) { const current = preparationFixture(fixture.id) return jsonResponse({ ...current.approval, valid: true, confirmation: current.record }) } + if (path.endsWith('/production/entry-readiness')) + return jsonResponse({ + ...preparationFixture(fixture.id).entry, + derivedAssets: { + shotCount: 4, + directionCount: 2, + directionCoverage: 0.5, + visualStateCount: 0, + visualStateCoverage: 0, + staleDirectionCount: 0, + staleVisualStateCount: 0 + } + }) if (path.endsWith('/generation-models')) return jsonResponse(imageCatalog) if (path.endsWith('/creative-profile')) return jsonResponse(generationProfile(fixture.id)) /** 主体与首帧表单使用原配置解析接口,不创建图片候选。 */ @@ -284,6 +297,8 @@ async function mountStoryboard() { }) await flushPromises() await expandSections() + selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'project') + await flushPromises() return provided } @@ -1830,8 +1845,8 @@ describe('工作台页面交互', () => { stubFetch(fetcher) await mountStoryboard() await flushPromises() - await confirmGeneration('补齐项目导演设计') - expect(button('补齐项目导演设计').disabled).toBe(true) + await confirmGeneration('补齐全项目摄影设计') + expect(button('补齐全项目摄影设计').disabled).toBe(true) await drawerPanel().get('.app-drawer-footer button').trigger('click') await flushPromises() expect(wrapper!.get('[data-workspace-tools]').attributes('aria-expanded')).toBe('false') @@ -1854,15 +1869,15 @@ describe('工作台页面交互', () => { await flushPromises() expect(getStoryboardSession(fixture.id).receipt).toMatchObject({ kind: 'batch', - title: '项目导演设计' + title: '摄影设计任务' }) expect(getOperation(fixture.id).pending).toBe(false) const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST') expect(posts).toHaveLength(1) - expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 2, force: false }) + expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 1, force: false }) }) - it('分镜只提供正式项目生成,逐集失败回执保留零次修复参数', async () => { + it('分镜保留显式批量范围,逐集失败回执保留零次修复参数', async () => { const fetcher = vi.fn().mockImplementation(async (url, init) => { if (init?.method === 'POST') return new Response( @@ -1899,15 +1914,18 @@ describe('工作台页面交互', () => { await flushPromises() expect(wrapper!.text()).not.toContain('生成本集导演设计') expect(wrapper!.text()).not.toContain('生成本集即时状态') - expect(button('补齐项目导演设计').disabled).toBe(false) - expect(button('补齐项目即时状态').disabled).toBe(false) + expect(button('补齐全项目摄影设计').disabled).toBe(false) + selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'episode') + await flushPromises() + expect(button('补齐第 1 集画面状态').disabled).toBe(false) expect(fetcher.mock.calls.every(([, init]) => init?.method !== 'POST')).toBe(true) await drawerPanel().get('#storyboard-repairs').setValue('0') - await confirmGeneration('补齐项目即时状态') + await confirmGeneration('补齐第 1 集画面状态') const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')! expect(JSON.parse(post[1]!.body as string)).toEqual({ - concurrency: 2, + concurrency: 1, force: false, + episodeNo: 1, maxRepairAttempts: 0 }) expect(drawerPanel().text()).toContain('本次有未完成项') @@ -1998,15 +2016,18 @@ describe('工作台页面交互', () => { stubFetch(fetcher) await mountStoryboard() await flushPromises() - await confirmGeneration('补齐项目导演设计') + await confirmGeneration('补齐全项目摄影设计') expect(drawerPanel().get('[aria-label="生成回执"] [role="alert"]').text()).toContain('本次有未完成项') expect(drawerPanel().text()).toContain('模型校验失败') - await drawerPanel().get('[role="checkbox"]').trigger('click') - await confirmGeneration('重生成全部导演设计') + await drawerPanel() + .findAll('[role="checkbox"]') + .find(item => item.text().includes('覆盖本次范围已有结果'))! + .trigger('click') + await confirmGeneration('重生成全项目摄影设计') const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST') expect(posts.map(([, init]) => JSON.parse(init!.body as string))).toEqual([ - { concurrency: 2, force: false }, - { concurrency: 2, force: true } + { concurrency: 1, force: false }, + { concurrency: 1, force: true } ]) }) @@ -2052,7 +2073,7 @@ describe('工作台页面交互', () => { /** 切换剧集只增加当前集查询,项目时长预算只在挂载时读取一次。 */ expect( fetcher.mock.calls.filter(([url]) => !String(url).endsWith('/storyboard-quality-confirmation')) - ).toHaveLength(6) + ).toHaveLength(7) expect( fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard-quality-confirmation')) ).toHaveLength(1) @@ -2076,11 +2097,11 @@ describe('工作台页面交互', () => { await mountStoryboard() await flushPromises() expect(wrapper!.text()).toContain('数据库暂不可用') - expect(button('补齐项目导演设计').disabled).toBe(true) + expect(button('补齐全项目摄影设计').disabled).toBe(true) fail = false button('重试查询').click() await flushPromises() - expect(button('补齐项目导演设计').disabled).toBe(false) + expect(button('补齐全项目摄影设计').disabled).toBe(false) /** 重试恢复正式镜头数据,内部编号仍用于业务选择。 */ expect(wrapper!.getComponent(ShotDesign).props('shot').shotId).toBe('shot-db-1-1') })