Skip to content

feat(thread-chat): 从 AI 回复直接开启无引用分叉聊天 - #84

Draft
hifizz wants to merge 2 commits into
mainfrom
codex/feat-message-fork-without-quote
Draft

feat(thread-chat): 从 AI 回复直接开启无引用分叉聊天#84
hifizz wants to merge 2 commits into
mainfrom
codex/feat-message-fork-without-quote

Conversation

@hifizz

@hifizz hifizz commented Sep 5, 2026

Copy link
Copy Markdown
Owner

当前创建分支接口及数据库约束都强制要求选区锚点,用户必须先划选文本才能分叉。本改动允许从已完成的 AI 回复直接创建新 Thread。

改动行为:

  • 列模式、画布模式均在 AI 回复下显示“开启分叉聊天”,共用消息后置区组件,并提供已创建分支的回访入口。
  • 点击只创建空分支,冻结截至来源消息的继承历史,保留来源关系;不创建引用、选区高亮、用户消息或模型生成任务。
  • 输入框保持空白,用户发送问题后复用现有生成流程;无引用时不注入选区焦点提示。
  • anchor 与 anchorText 同时提供或同时省略,持久化为成对 null;保留原有划选分叉行为。
  • 服务端限制直接分叉来源为当前时间线上已完成的 AI 回复,继续复用权限与幂等校验。
  • 无引用分支暂用“新分支”,首次提问后按问题生成标题。

验证:

  • 通过 corepack pnpm typecheck。
  • 通过变更文件 ESLint 检查和 git diff --check。
  • 通过 node --import tsx e2e/thread-chat/message-fork.test.mjs,覆盖契约、历史截止、空创建、重新加载及消息入口展示条件。
  • 通过 node --import tsx e2e/thread-chat/normalized-client-store.test.mjs。
  • 已扩充真实数据库测试,但当前环境没有数据库连接,未执行;未进行真实模型调用或浏览器端到端验收。

发布前置条件:
此 PR 保持草稿。threads_root_or_fork_shape 必须允许两个引用字段同时为空。遵循 CLAUDE.md 的迁移规则,本功能分支仅修改 schema 源码,未生成或改动 drizzle/。需要先在 develop 集成任务中生成迁移、验证旧数据库升级并运行 pnpm test:thread-chat:gate1-db,再发布入口;当前分支不能直接作为可发布版本。

行为与交接说明见 docs/message-fork-without-quote.md。
基于 main @ ae4dded

追加修复:恢复划选分叉首条用户消息的背景引用块。

  • 带首问创建分支及空分支首次发送均持久化 data-quote;前端即时展示与服务端共用消息内容构造函数。
  • 编辑/重新发送保留源消息已有引用,后续追问不重复添加引用;无引用分支保持无引用。
  • 不从 Thread 强制重建旧消息缺失或已移除的引用;历史缺失 part 的消息不自动回填。
  • 新增 fork-quote.test.mjs,验证两条入口、引用块渲染、内容序列化、编辑保留及请求失败回滚;与 message-fork.test.mjs、normalized-client-store.test.mjs 均通过。类型检查、变更文件 ESLint 和 git diff --check 通过。
  • 数据库回归已补充保存、读取、编辑及带首问分叉检查;因当前环境无数据库连接,仍未执行。此次引用修复不增加数据库结构变更,PR 原有迁移前置条件保持不变。

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
thread-chatbot Error Error Sep 5, 2026 11:53am UTC

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant