Skip to content

feat(workflow-run): implement resumable generation orchestration - #86

Open
xyh202131 wants to merge 21 commits into
1024XEngineer:mainfrom
xyh202131:feat/workflow-run-core-clean
Open

feat(workflow-run): implement resumable generation orchestration#86
xyh202131 wants to merge 21 commits into
1024XEngineer:mainfrom
xyh202131:feat/workflow-run-core-clean

Conversation

@xyh202131

@xyh202131 xyh202131 commented Aug 3, 2026

Copy link
Copy Markdown

目的

实现可恢复的 WorkflowRun 前端核心,并让数据结构与即将接入的 Workflow Editor 卡片语义保持一致。

当前设计

  • 一个根节点对应一个 WorkflowRun;角色与动作生成是同一 Run 下的多个 GenerationTask
  • 删除 driver,运行模型不感知 Quick Start 是自动推进还是用户手动推进
  • WorkflowStep 与编辑器卡片一一对应,生成、选择、审核等卡片内部过程由 phase 表达
  • 恢复最小 WorkflowRevision:Editor 从某张卡片重做时追加执行分支,旧 Revision 只读
  • Revision 保存自己的节点输入、角色/造型结果和动作配置,重做不会覆盖旧分支上下文
  • 旧 Revision 的异步结果晚到时会被拒绝,不能污染当前 Revision
  • WorkflowRevision 是执行分支,不等于 GenerationTask,也不取代未来 WorkflowDefinition 的定义版本
  • Repository 的 create/get/list/save 全部异步,并删除 subscribe/subscribeAll
  • WorkflowRunService 只负责 create/get,返回绑定具体 Run 的实例
  • 普通本地状态修改可显式 save();远程任务 ID 等恢复检查点及时持久化
  • Generation 的状态推送继续由 Generation SSE 负责

业务链路

  • 角色卡片生成 4 张临时候选,只把用户确认的一张交给后端保存
  • 同一个 Run 随后进入动作卡片,生成 4 张首帧候选
  • 用户选择首帧后生成完整动画,审核通过后写回 Character
  • WorkflowRun 只保存 GenerationTask ID,不持久化临时候选 URL
  • Quick Start 默认只有初始 Revision;只有 Editor 从卡片重做时才追加 Revision

范围

  • WorkflowRun 的 model / store / service、公开出口、测试和模块 README
  • 仅调整 Generation 注释以及 WorkflowController 的 Revision 防串线类型
  • 不包含页面、Playtest、HTTP 适配器或后端代码

验证

  • npm run typecheck:通过
  • npm run lint:通过
  • npm run test:17 项通过
  • npm run build:通过
  • WorkflowRun 涉及文件格式检查与 git diff --check:通过
  • dist/node_modules/ 未提交

本 PR 仅供审核,不执行合并。替代已关闭且未合并的 #85

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
windup Ready Ready Preview Aug 6, 2026 10:29am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found in this review.

Verified:

  • npm test -- --run src/entities/workflow-run/store.test.ts
  • npm run typecheck

Note: dependency installation completed with a Node engine warning because this sandbox uses Node 20 while react-router@8.3.0 declares Node >=22.22.0.

@xyh202131 xyh202131 changed the title feat(workflow-run): add versioned history store feat(workflow-run): implement resumable generation orchestration Aug 3, 2026
Comment thread frontend/src/entities/workflow-run/model/constants.ts Outdated

/**
* 一个 Run 只有一个目标。新建角色和追加动作可在同一界面连续操作,
* 但是两次独立任务,因此使用两个 WorkflowRun。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来我们这里的理解并不一致,我以为一个根节点对应的就是一个 workflow run,你这里的设定似乎是:一个像“生成角色并为之添加动作”的过程会包含两个或更多的 workflow run,这么设定的考虑是?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想的是,生成图片为一次任务,然后再据此生成动作资产为另一次任务,后面任务失败不影响前面任务成功,前面图片仍然能被保存

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成图片为一次任务,然后再据此生成动作资产为另一次任务

你说的这个“任务”更接近服务端的 generation-task 概念?

按我们昨天跟服务端同学的讨论看,generation-task 跟 workflow-run 是两个独立的概念,数据也是各自独立的;只是由前端的逻辑同时负责构造 generation-task 和维护 workflow-run 状态,一个 workflow-run 可以对应 1 个或多个(甚至 0 个)generation task,同样地,一个 workflow-run 中的 step 也可以对应 1 个或多个(甚至 0 个)generation task

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是,因为图片生成和动作资产生成,本身就是不同的generation task

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我以为一个根节点对应的就是一个 workflow run,你这里的设定似乎是:一个像“生成角色并为之添加动作”的过程会包含两个或更多的 workflow run

那再回头考虑下这个设定?可能有这几个问题要回答:

  • workflow editor 的对象不是一个 workflow-run,而是多个 workflow-run 了,那么它们怎么被关联起来?
  • workflow editor 的 URL 参数是什么?
  • 后续用户在检查台希望重新生成某一个 action 的话,回来 workflow editor 应该是带着什么样的 URL 参数回来以便定位到这个 action 的重新生成?
  • 跟上一条类似,如果后续用户在资产库中一个已经存在的 character 页面,希望给这个 character 添加新的 action,应该是带着什么样的 URL 参数去 workflow editor 以定位到添加 action 的动作?


/**
* Revision 级状态。用户从旧步骤重做时,旧 Revision 变为 abandoned,
* 并追加新 Revision;不覆盖历史,才能说清“这个结果从哪次重做而来”。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用户从旧步骤重做的时候,为什么要保留历史?

才能说清“这个结果从哪次重做而来”。

这个没理解

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刚才我们已经和后端对齐过,因为后端采用树状纯存储模型,不提供回退或 Revision 历史能力。因此用户从旧步骤重做时,前端不再保留被废弃结果的历史链路,也不支持回退,当前 Quick Start 会移除这部分 revision 设计。
这样 ok 吗

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

减少概念或机制我没问题,只要能实现你们想提供的用户功能就好

add_action: [
'action-setup',
'first-frame',
'first-frame-candidate',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first-frame-candidate 和 first-frame 什么区别?以及

  • character-template vs template-candidate
  • complete-animation vs review

我也有相同的困惑

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

character-template:调用生成接口,产生四张角色候选图。
template-candidate:用户从四张图中选择一张。
first-frame:调用接口生成四张动作首帧。
first-frame-candidate:用户选择其中一张首帧。
complete-animation:根据选中首帧生成完整动画。
review:用户审核完整动画。
主要是有一个选择过程

@nighca nighca Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

character-template:调用生成接口,产生四张角色候选图。
template-candidate:用户从四张图中选择一张。

从 workflow editor 里看,这两个操作对应的应该是同一个“卡片”(只是卡片内部状态会因为用户做了选择而发生变化);所以你定义的 step 跟 UI 上表达步骤的“卡片”不是同一个概念?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以这样理解,就是同一个卡片因为选择不同导致了变化

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那你可能要考虑:是继续保持现在 step 数据跟 UI 上的卡片不一一对应的做法,还是做成一一对应

不一一对应的话,在展示层就需要额外的逻辑来将 step 列表转化为按卡片组织的列表数据?

}

/**
* 验证 Revision 历史链,防止伪造或悬空引用。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉我们需要单独对下 revision,这里似乎围绕 revision 实现了一整套机制,但是我没太理解

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revision其实我们当前quick start应该不需要,真正需要的是work editor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们当前quick start应该不需要

这个没关系,对于 workflow editor,revision 具体是怎么解决、解决了什么问题我也还需要理解下

*/
export interface WorkflowRunStore {
create(input: CreateWorkflowRunInput): WorkflowRun
get(runId: WorkflowRun['id']): WorkflowRun | null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既然考虑对接服务端接口,那这里的接口 cretea、get、list、save 等就不能假设是同步的?

另外不应该会有 subscribe / subscribeAll 接口吧?它们是什么用途?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前的话受当前 localStorage 同步实现影响了,如果它要作为后续服务端持久化的抽象边界,create/get/list/save 应该统一定义为异步接口。subscribe/subscribeAll 原本分别用于创作页面监听单个 Run、历史列表监听全部 Run 的本地变化

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscribe/subscribeAll 原本分别用于创作页面监听单个 Run、历史列表监听全部 Run 的本地变化

所有的 workflow-run 状态变更都是前端逻辑自己驱动的,它自己应该能知道什么时候状态变更了,而不需要专门的监听接口;就像我们不会有监听 project、asset 数据变更的接口一样

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的


export interface WorkflowRunService {
/** 暂停进行中的 Run;当前 Revision 和 active 步骤保持不变。 */
interruptRun(runId: string): WorkflowRun

@nighca nighca Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉把一个 workflow-run 内的操作/状态迁移也作为 WorkflowRunService 的方法并不好用?像这样去定义可能会更合适:

interface WorkflowRun {
  interrupt(): ...
  continue(): ...
  start(): ...
  resumeCharacterCandidates(): ...
}

interface WorkflowRunService {
  create(): WorkflowRun
  get(): WorkflowRun
}

这个好处是大部分的逻辑不需要同时持有一个 WorkflowRunService 实例和一个 runId,而是持有一个 WorkflowRun 实例就好了,另外我们也可以做到把 WorkflowRun 上边的单次操作跟 WorkflowRun 整体的持久化(如保存到服务端)解耦,不一定每次对 WorkflowRun 做什么操作都立刻保存到服务端

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

马上改

…ore-clean

# Conflicts:
#	README.md
#	frontend/README.md
@huyanxius

Copy link
Copy Markdown
Collaborator

@fennoai /review

@fennoai

fennoai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Complete

Submitted a non-blocking PR review with one low-severity documentation finding: frontend/src/pages/home/index.tsx:32 still references the removed eight-step WORKFLOW_STEP_ORDER vocabulary after this PR moved WorkflowRun to card-aligned character / action steps with phases.

Verified locally:

  • npm run test passed: 5 files, 17 tests
  • npm run typecheck passed
  • npm run lint passed
  • npm run build passed
  • git diff --check 023bf0f86e8089681ae9a09427a12306b3c0b3dc...014e83a958d3b965b4ec5738e95ae805f9d188de passed

Note: npm ci emitted an engine warning because this sandbox uses Node v20.20.2 while react-router@8.3.0 declares Node >=22.22.0.

View job run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review findings:

  • Low: frontend/src/pages/home/index.tsx:32 still documents the old eight-step WORKFLOW_STEP_ORDER model (character-setup, template-candidate, complete-animation, etc.), but this PR replaces that public vocabulary with card-aligned WORKFLOW_STEP_ORDERS containing character / action steps and phase-based internals. Anyone updating the home workflow copy from this comment will now be pointed at deleted names and the wrong model shape. Please update or remove this comment alongside the WorkflowRun model change.

Verification run locally: npm run test, npm run typecheck, npm run lint, npm run build, and git diff --check 023bf0f86e8089681ae9a09427a12306b3c0b3dc...014e83a958d3b965b4ec5738e95ae805f9d188de. Note: npm ci emitted an engine warning because this sandbox uses Node v20.20.2 while react-router@8.3.0 declares Node >=22.22.0.

@huyanxius

Copy link
Copy Markdown
Collaborator

@fennoai /compact 根据当前PR 现状和评论列出未定事项,不要删除任何评论

@fennoai

fennoai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

未定事项

  • WorkflowRun 到底保持“一个根节点 = 一个 run”,还是按评论里提到的思路拆成多个 run 由 Workflow Editor 关联
  • 如果继续用单个 WorkflowRun,URL 参数如何表达“从哪个卡片重做”以及“给已有 character 追加 action”
  • restartFromStep 的历史保留语义是否最终保留;评论里明确提过后端是树状纯存储,不提供回退 / revision 历史,这一点和当前实现还要再对齐
  • home/index.tsx 里的旧 WORKFLOW_STEP_ORDER 说明是否要同步删改,避免继续引用已删除的流程词汇

当前 PR 仍是 open,GitHub 侧未给出 review decision。

View job run

@fennoai

fennoai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

未定事项

  • restartFromStep 的历史保留语义是否最终保留;当前实现保留了 Revision 链,但评论里提过后端是树状纯存储、不提供回退 / revision 历史,这两种模型还没完全对齐
  • frontend/src/pages/home/index.tsx 里的旧 WORKFLOW_STEP_ORDER 说明是否要同步删改,避免继续引用已经被这次 PR 替换掉的流程词汇

PR 目前仍是 open,GitHub 侧没有新的 review decision。

View job run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants