feat: 预览渲染进度实时上报(#1197 E2E 验证发现的进度卡 0% 问题修复) #1221

Closed
xiaoxia wants to merge 0 commits from feat/preview-progress-reporting into develop
Owner

问题

预览渲染任务从创建到完成期间,generation_tasks.progress 始终为 0,直到 mark_completed 才跳到 100。前端轮询只能看到 0%→100% 的跳变,无法展示真实渲染进度。

根因

apps/worker/worker_app/tasks/generation.py_update_task_status 只在 mark_processing(progress=0)和 mark_completed(progress=100)之间切换,中间无任何进度更新。

修复

  • 新增 _update_task_progress(task_id, progress, description) 辅助函数
    • 使用独立 DB session 更新 GenerationTaskModel.progress
    • 异常只 log.warning 不抛出,不影响主渲染流程
  • 在 6 个关键节点插入进度上报:
    • 10% — 任务启动
    • 30% — 素材下载完成
    • 40% — 开始渲染(FFmpeg)
    • 80% — 渲染完成
    • 85% — 开始上传 OSS
    • 95% — 上传完成
    • 100% — mark_completed(原有逻辑)

验证

staging 手动部署后创建测试任务 5933b49a,进度 10→30→40→80→85→95→100 完整流转,Worker 日志确认 6 个节点全部打出。

关联

  • 关联 #1197(预览生成功能)
  • 关联 #1219(渲染失败检测,本分支基于其 commit)
## 问题 预览渲染任务从创建到完成期间,`generation_tasks.progress` 始终为 0,直到 mark_completed 才跳到 100。前端轮询只能看到 0%→100% 的跳变,无法展示真实渲染进度。 ## 根因 `apps/worker/worker_app/tasks/generation.py` 中 `_update_task_status` 只在 mark_processing(progress=0)和 mark_completed(progress=100)之间切换,中间无任何进度更新。 ## 修复 - 新增 `_update_task_progress(task_id, progress, description)` 辅助函数 - 使用独立 DB session 更新 `GenerationTaskModel.progress` - 异常只 log.warning 不抛出,不影响主渲染流程 - 在 6 个关键节点插入进度上报: - 10% — 任务启动 - 30% — 素材下载完成 - 40% — 开始渲染(FFmpeg) - 80% — 渲染完成 - 85% — 开始上传 OSS - 95% — 上传完成 - 100% — mark_completed(原有逻辑) ## 验证 staging 手动部署后创建测试任务 `5933b49a`,进度 10→30→40→80→85→95→100 完整流转,Worker 日志确认 6 个节点全部打出。 ## 关联 - 关联 #1197(预览生成功能) - 关联 #1219(渲染失败检测,本分支基于其 commit)

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1221 | | 预览链接 | [https://pr-1221.preview.xiaoxiajianji.com](https://pr-1221.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia closed this pull request 2026-08-02 20:07:03 +08:00

🗑️ 预览环境已清理

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

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

🗑️ **预览环境已清理** PR #1221 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m5s
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Validate - Code Quality (push) Failing after 5m14s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 52s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 44s
CI/CD Pipeline / Unit Tests (push) Successful in 8m52s
CI/CD Pipeline / Integration Tests (push) Successful in 1m25s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m18s
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m19s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m32s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m24s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m37s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 7m19s
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Failing after 7m27s
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 / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (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 / Check if frontend-only change (pull_request) Successful in 47s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 48s
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
AI Code Review / AI Code Review (pull_request) Successful in 54s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m41s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 24s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 26s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m31s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m3s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m25s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m4s
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 6s

Pull request closed

Sign in to join this conversation.