feat: 生成任务取消 - API接口 + Worker取消检查点 #391

Merged
xiaoxia merged 3 commits from feat/generation-task-cancel into develop 2026-07-17 07:17:26 +08:00
Owner

变更内容

完整的生成任务取消能力,覆盖 API 层 + Worker 层。

API 层

POST /api/v1/generation/tasks/{task_id}/cancel
  • 仅 pending / running 状态可取消
  • 取消后状态变为 cancelled,记录 completed_at
  • 终态不可取消(409)
  • 权限校验:只能取消自己的任务(403)
  • 记录取消日志,便于审计

Worker 层

在剪辑计划渲染任务主流程中增加取消检查点:

  • 位置:素材下载完成后、启动 FFmpeg 渲染前
  • 检查 generation_task 状态,如果为 cancelled 则立即中止
  • 计划状态从 rendering 切回 editing,用户可继续编辑
  • 不浪费渲染资源

后续可扩展

  • FFmpeg 运行中 kill 进程(更细粒度的取消)
  • 更密集的检查点(每段素材渲染后)
## 变更内容 完整的生成任务取消能力,覆盖 API 层 + Worker 层。 ### API 层 ``` POST /api/v1/generation/tasks/{task_id}/cancel ``` - 仅 pending / running 状态可取消 - 取消后状态变为 cancelled,记录 completed_at - 终态不可取消(409) - 权限校验:只能取消自己的任务(403) - 记录取消日志,便于审计 ### Worker 层 在剪辑计划渲染任务主流程中增加取消检查点: - 位置:素材下载完成后、启动 FFmpeg 渲染前 - 检查 generation_task 状态,如果为 cancelled 则立即中止 - 计划状态从 rendering 切回 editing,用户可继续编辑 - 不浪费渲染资源 ### 后续可扩展 - FFmpeg 运行中 kill 进程(更细粒度的取消) - 更密集的检查点(每段素材渲染后)
xiaoxia changed title from feat: 生成任务取消接口 - POST /tasks/{task_id}/cancel to feat: 生成任务取消 - API接口 + Worker取消检查点 2026-07-16 10:06:36 +08:00
xiaoxia force-pushed feat/generation-task-cancel from 7060fa3124 to ea3cb02406 2026-07-16 13:52:34 +08:00 Compare
xiaoxia force-pushed feat/generation-task-cancel from 36a2cbbed3 to ea3cb02406 2026-07-16 13:57:44 +08:00 Compare
auto-approve-bot approved these changes 2026-07-16 22:08:13 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia added 3 commits 2026-07-17 00:44:09 +08:00
新增生成任务取消接口:
- 支持 pending / running 状态的任务取消
- 取消后状态变为 cancelled,记录取消日志
- 终态(completed/failed/cancelled)不可取消,返回 409
- 权限校验:只能取消自己创建的任务
- 复用领域模型已有的 mark_cancelled 方法
在渲染主流程中增加取消检查点:
- 素材下载完成后、启动FFmpeg前,检查generation_task状态
- 如果已被取消(cancelled),立即中止,不启动渲染
- 计划状态从 rendering 切回 editing,用户可继续编辑
- 与 API 层的取消接口配套

不修改 FFmpeg 运行时取消(后续迭代),覆盖排队/下载期间取消的场景
style: auto-format with black + isort (runner env)
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 6s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 31s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m30s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m22s
216a02005b
xiaoxia force-pushed feat/generation-task-cancel from b0b39094fc to 216a02005b 2026-07-17 00:44:09 +08:00 Compare
xiaoxia merged commit 92855189ad into develop 2026-07-17 07:17:26 +08:00
xiaoxia deleted branch feat/generation-task-cancel 2026-07-17 07:17:26 +08:00
Sign in to join this conversation.