[Do] refactor: 统一渲染链路,预览即所得 #1479

Merged
auto-approve-bot merged 4 commits from refactor/unified-render-pipeline into develop 2026-08-24 14:16:01 +08:00
Owner

重构目标

预览和正式生成都走同一条渲染路径(_render_from_edit_plan,基于 EditPlan 数据库),预览即最终。

核心改动

1. 删除旧内存渲染路径(generation.py -1031行)

  • _build_plan_and_clips_from_task:内存构建虚拟 plan/clips
  • _load_template_plan_config / _load_template_clip_configs / _load_template_segment_durations
  • _download_library_assets / _download_all_assets:旧路径素材下载
  • _render_video:旧路径渲染入口(含 854x480 低质量预览设置)
  • generate_video 中 DEPRECATED 旧路径代码块 → 改为 else: return error

2. 删除 custom_title 全链路

  • packages/domain/generation_task.py:移除字段
  • packages/application/generation_tasks.py:移除 command 字段
  • packages/adapters/sqlalchemy_impl/generation_task_repository.py:移除映射
  • apps/api/app/schemas/generation_task.py:移除 schema 字段
  • apps/api/app/api/routes/generation_preview.py:改用 title_config
  • apps/api/app/api/routes/generation_tasks.py:移除引用
  • apps/worker/worker_app/tasks/generation.py:移除 _load_task_info 中的字段
  • DB 列保留(需单独 migration 删除)

3. 清理旧测试(-2278行)

删除 9 个测试文件(测试已删除的函数):

  • test_full_pipeline.py / test_four_mode_rendering.py(集成)
  • test_preview_voice_ids_fallback.py / test_preview_title_render.py
  • test_generation_p3_optimizations.py / test_generation_worker_fixes.py
  • test_bool_config_defense.py / test_preview_title_config.py

编辑 5 个测试文件(移除引用已删函数的测试类):

  • test_oneclick_gen_p0_fixes.py / test_1294_preview_voice_injection.py
  • test_1280_preview_speedup.py / test_worker_cover_meta_and_status.py
  • test_confirm_generation.py / test_three_bugs_fix.py

验证

  • 单测:13647 passed, 0 failed
  • 语法:所有修改文件 AST 解析通过
  • source_edit_plan_id 为空时直接报错,不再兜底旧路径

风险评估

  • 预览时间变长:预览从几秒→几十秒(1080p 渲染)
  • 服务器资源增加:预览也用 1080p,渲染时间增加 3-5 倍
  • 历史任务兼容:旧预览任务(854x480)仍在 OSS,不影响新任务
  • DB 列 custom_title:保留在 models.py,需单独 migration 删除
## 重构目标 预览和正式生成都走同一条渲染路径(`_render_from_edit_plan`,基于 EditPlan 数据库),预览即最终。 ## 核心改动 ### 1. 删除旧内存渲染路径(generation.py -1031行) - `_build_plan_and_clips_from_task`:内存构建虚拟 plan/clips - `_load_template_plan_config` / `_load_template_clip_configs` / `_load_template_segment_durations` - `_download_library_assets` / `_download_all_assets`:旧路径素材下载 - `_render_video`:旧路径渲染入口(含 854x480 低质量预览设置) - `generate_video` 中 DEPRECATED 旧路径代码块 → 改为 `else: return error` ### 2. 删除 custom_title 全链路 - `packages/domain/generation_task.py`:移除字段 - `packages/application/generation_tasks.py`:移除 command 字段 - `packages/adapters/sqlalchemy_impl/generation_task_repository.py`:移除映射 - `apps/api/app/schemas/generation_task.py`:移除 schema 字段 - `apps/api/app/api/routes/generation_preview.py`:改用 title_config - `apps/api/app/api/routes/generation_tasks.py`:移除引用 - `apps/worker/worker_app/tasks/generation.py`:移除 _load_task_info 中的字段 - **DB 列保留**(需单独 migration 删除) ### 3. 清理旧测试(-2278行) 删除 9 个测试文件(测试已删除的函数): - test_full_pipeline.py / test_four_mode_rendering.py(集成) - test_preview_voice_ids_fallback.py / test_preview_title_render.py - test_generation_p3_optimizations.py / test_generation_worker_fixes.py - test_bool_config_defense.py / test_preview_title_config.py 编辑 5 个测试文件(移除引用已删函数的测试类): - test_oneclick_gen_p0_fixes.py / test_1294_preview_voice_injection.py - test_1280_preview_speedup.py / test_worker_cover_meta_and_status.py - test_confirm_generation.py / test_three_bugs_fix.py ## 验证 - 单测:13647 passed, 0 failed - 语法:所有修改文件 AST 解析通过 - source_edit_plan_id 为空时直接报错,不再兜底旧路径 ## 风险评估 - **预览时间变长**:预览从几秒→几十秒(1080p 渲染) - **服务器资源增加**:预览也用 1080p,渲染时间增加 3-5 倍 - **历史任务兼容**:旧预览任务(854x480)仍在 OSS,不影响新任务 - **DB 列 custom_title**:保留在 models.py,需单独 migration 删除
xiaoxia added 1 commit 2026-08-24 13:43:17 +08:00
refactor: 统一渲染链路,预览即所得
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 43s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 41s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m38s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m43s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m47s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m10s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m46s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m37s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
b37e812b1b
核心改动:
- 删除旧内存渲染路径(render_from_memory)及所有关联函数
- 预览和正式生成都走 _render_from_edit_plan(基于 EditPlan 数据库)
- source_edit_plan_id 为空时直接报错,不再兜底旧路径
- 删除 custom_title 字段全链路(domain/application/schema/route/worker)
- 统一使用 title_config 结构化字段传递标题配置

删除的函数(generation.py -1031行):
- _build_plan_and_clips_from_task:内存构建虚拟 plan/clips
- _load_template_plan_config:模板配置加载(旧路径辅助)
- _load_template_clip_configs / _load_template_segment_durations
- _download_library_assets / _download_all_assets:旧路径素材下载
- _render_video:旧路径渲染入口(854x480 低质量预览)
- generate_video 中 DEPRECATED 旧路径代码块

删除的测试文件(测试已删除函数的旧测试):
- test_full_pipeline.py / test_four_mode_rendering.py(集成测试)
- test_preview_voice_ids_fallback.py / test_preview_title_render.py
- test_generation_p3_optimizations.py / test_generation_worker_fixes.py
- test_bool_config_defense.py / test_preview_title_config.py

清理的测试(删除引用已删函数的测试类):
- test_oneclick_gen_p0_fixes.py:移除 TestDownloadLibraryAssets / TestTemplatePlanConfigLoading
- test_1294_preview_voice_injection.py:移除 TestRenderVideoVoiceInjection / TestGenerateVideoPassesVoiceIds
- test_1280_preview_speedup.py:移除 test_parallel_download_still_works
- test_worker_cover_meta_and_status.py:更新 _meta_session 断言
- test_confirm_generation.py / test_three_bugs_fix.py:移除 custom_title 断言

单测验证:13647 passed, 0 failed

🚀 预览环境已部署

项目 详情
PR号 #1479
预览链接 https://pr-1479.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1479 | | 预览链接 | [https://pr-1479.preview.xiaoxiajianji.com](https://pr-1479.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot added 1 commit 2026-08-24 13:47:43 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 35s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m15s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 46s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m35s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m46s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m28s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m30s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m55s
AI Code Review / AI Code Review (pull_request) Successful in 2m41s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m39s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m14s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 8m29s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 7s
e8c3d181b1
xiaoxia added 1 commit 2026-08-24 14:00:13 +08:00
fix: 清理删除旧路径后的 unused imports/variables 和孤儿测试
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 33s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 44s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m58s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 2m7s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m9s
AI Code Review / AI Code Review (pull_request) Successful in 2m18s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m36s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m6s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m51s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 4m24s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
70c822e54e
- generation.py: 移除 9 个 unused import (json, tempfile, Any, VirtualClip 等)
- generation.py: 注释 3 个 unused variable (asset_library_id, voice_library_id, output_name)
- generation_preview.py: 移除 unused import json
- test_oneclick_gen_p0_fixes.py: 删除 TestTemplateClipEffectMapping (10个测试)
  测试的 _apply_template_clip_effects/_extract_intro_outro_from_clip_configs 已随旧路径删除

单测 13637 passed, 0 failed
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:0 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

良好实践

  1. 字段迁移一致性:在 API 层(generation_preview.py, generation_tasks.py)和数据层(generation.py)中,彻底移除了废弃的 custom_title 字段,统一迁移至结构化的 title_config,逻辑清晰且保持一致。
  2. 代码清理:在 generation.py 中移除了不再使用的导入(如 json, tempfile)以及已被重构替代的辅助函数(如 _build_plan_and_clips_from_task, _download_library_assets),有效减少了代码冗余。
  3. 防御性编程:在 generation_preview.py 中使用 request.title_config or {} 确保传递给 Use Case 的始终是字典类型,避免了 None 引用风险。

格式检查通过 | 逻辑审查通过 | 性能无明显问题


🤖 由 AI 代码审查机器人自动生成 | 2026-08-24 06:02:30 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 1. **字段迁移一致性**:在 API 层(`generation_preview.py`, `generation_tasks.py`)和数据层(`generation.py`)中,彻底移除了废弃的 `custom_title` 字段,统一迁移至结构化的 `title_config`,逻辑清晰且保持一致。 2. **代码清理**:在 `generation.py` 中移除了不再使用的导入(如 `json`, `tempfile`)以及已被重构替代的辅助函数(如 `_build_plan_and_clips_from_task`, `_download_library_assets`),有效减少了代码冗余。 3. **防御性编程**:在 `generation_preview.py` 中使用 `request.title_config or {}` 确保传递给 Use Case 的始终是字典类型,避免了 None 引用风险。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-08-24 06:02:30 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
auto-approve-bot added 1 commit 2026-08-24 14:04:38 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 33s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 54s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m41s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m47s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m55s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m4s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m36s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 5m42s
AI Code Review / AI Code Review (pull_request) Successful in 6m45s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m16s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 8m38s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 7s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 37s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 44s
9fae480e4b
auto-approve-bot approved these changes 2026-08-24 14:10:30 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-08-24 14:10:30 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot merged commit c873bb635f into develop 2026-08-24 14:16:01 +08:00
auto-approve-bot deleted branch refactor/unified-render-pipeline 2026-08-24 14:16:01 +08:00
xiaoxia changed title from refactor: 统一渲染链路,预览即所得(-3370行) to [Do] refactor: 统一渲染链路,预览即所得 2026-08-24 14:16:10 +08:00
xiaoxia reviewed 2026-08-24 14:16:24 +08:00
xiaoxia left a comment
Author
Owner

[Do] LGTM

[Do] LGTM

🗑️ 预览环境已清理

PR #1479 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1479 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.