Feat:新增支持undo/fork 功能#728
Open
supreme0597 wants to merge 7 commits into
Open
Conversation
后端:
- 新增 thread_undo_service: FOR UPDATE 防竞态 + 递归 CTE + channel/version 精确 blob 归档
- 新增 thread_fork_service: Phase1 物理克隆 + Phase2 数据库事务,DISTINCT 防 blob 主键冲突
- 新增 checkpoint_tables: LangGraph checkpoint 表反射定义(table() Core 风格)
- 新增 checkpoint_repository: 递归 CTE 构建器 + select 构建器
- chat_router: POST /thread/{id}/undo + /fork 路由
- manager: checkpoint 递归 CTE 性能索引
前端:
- AgentMessageComponent: 消息气泡 hover 显示 Undo/Fork 按钮
- AgentChatComponent: handleUndo / handleFork 事件处理
- agent_api: undoThread / forkThread API 调用
测试: 13 个单元测试覆盖入口校验全场景
原代码用 AgentRun.extra_metadata 做 jsonb_set,但 AgentRun 模型没有 extra_metadata 列,导致 AttributeError。改为用 error_message 字段 记录 'cancelled_by_user_undo'。
将 agent_runs 取消逻辑从 SQL 子查询改为 Python 侧提取: 先加载待删除消息 → 提取 request_id 列表 → 再用 IN 条件更新 AgentRun。 同时调整步骤顺序:先标记消息删除(10),再取消 agent_runs(11)。
Undo 后前端重新加载消息历史,但原 API 不过滤 is_deleted 消息, 用户仍能看到已删除消息并重复触发 undo(422 报错)。 在 get_thread_history_view 中跳过 is_deleted==true 的消息。
参数名 message 遮蔽了 ant-design-vue 的 message API, 导致 message.success() 报 undefined。改为 msg。
ff39b04 to
e3a69f8
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更描述
简要描述这个 PR 做了什么
基于pg checkpoint支持新增支持undo/fork 功能
实现 Undo/Fork 时间旅行功能(对话回退与分叉)
后端:
前端:
测试: 13 个单元测试覆盖入口校验全场景
变更类型
测试
相关日志或者截图
说明
(可选)有什么需要特别说明的吗?
💡 提示: 提交前可以运行
make lint和make format检查代码规范