Skip to content

fix(thread-chat): 恢复划选分叉首问引用并保留编辑引用 - #92

Merged
hifizz merged 1 commit into
mainfrom
codex/fix-fork-first-message-quote
Sep 6, 2026
Merged

fix(thread-chat): 恢复划选分叉首问引用并保留编辑引用#92
hifizz merged 1 commit into
mainfrom
codex/fix-fork-first-message-quote

Conversation

@hifizz

@hifizz hifizz commented Sep 6, 2026

Copy link
Copy Markdown
Owner

划选后先创建空 Thread、稍后再发送首问时,用户消息没有保存引用 part,导致气泡内的背景引用块缺失;纯文本编辑/重试也会丢失已有引用。

本 PR 单独移植 #84 中的引用修复 commit 9cc61eac421f93f1baff79a8fd0e33a4b1e2c79f,基于 main@9277d919ed25ac24d7ac3c7735d7f78643a3bd56 适配。main 已合入统一 cache,命令已改为 parts,带首问分叉也已生成 V1 Quote,因此没有直接套用旧补丁。

改动:

  • 保持带首问分叉的 V1 Quote,补齐先分叉后发送,以及接口直接带首问但未附 Quote 的路径;客户端即时消息和服务端持久化使用同一构造逻辑。
  • 首问保存带来源信息的 thread-quote-v1,并由现有 msg-quote 样式展示背景引用块。显式 Quote 不重复添加,已有 parts 顺序保持不变;后续追问不重复附加。
  • 纯文本编辑/重试保留已有 V1 Quote、批注和相对顺序;旧版引用仅从已保存消息保留。不会从 Thread 重建旧消息已缺失的引用。
  • 编辑继续用 assertEditQuoteSemantics 校验旧快照,拒绝新增、复制、替换来源。移除按当前 Thread 重新验证旧来源的检查,避免父 Thread 的分叉引用被误拒;API 显式删除 V1 Quote 仍然有效。
  • 同步演示运行时与回归用例。

验证通过:

  • corepack pnpm typecheck
  • 变更文件 ESLint(无警告)及 git diff --check
  • node --import tsx e2e/thread-chat/fork-quote.test.mjs:两条入口、前后端内容一致、序列化恢复、背景引用块、编辑保留、旧引用兼容、拒绝伪造/复制、显式删除、失败回滚。
  • node --import tsx e2e/thread-chat/normalized-client-store.test.mjs
  • node --import tsx e2e/thread-chat/prompt-cache-contract.test.mjs

验证限制:新增 e2e/thread-chat/fork-quote-db.test.mjs 使用当前 parts 契约,覆盖真实保存、读取、编辑和两条分叉入口;当前环境没有数据库连接,未执行。未进行浏览器或真实模型端到端验收。

范围:不包含 #84 的“AI 消息直接开启无引用分叉”入口及数据库约束修改;不改数据库结构、drizzle/、System Prompt 或 cache 逻辑;历史缺失引用的消息不自动回填。

移植 9cc61ea 的引用修复,适配 main 的 parts 命令和 thread-quote-v1 结构。
@vercel

vercel Bot commented Sep 6, 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 6, 2026 5:48am UTC

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 1203fc11-6eaa-4e41-8dd6-59b7ab5d87e7


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.

@hifizz
hifizz merged commit eddf7c3 into main Sep 6, 2026
4 of 5 checks passed
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