PR-2: 消息窗口正确性 + Reply/Edit 互斥 - #55
Conversation
- mergeMessageWindow 纯函数:统一 addMessage/prependHistory/setHistory/ addSystemMessage 窗口策略,MESSAGE_CAP=500(append 从头部截断), HISTORY_CAP=1000(prepend 从尾部截断) - 修复 prependHistory 旧 bug: 截断方向正确保留 - 修复 setHistory/addSystemMessage 无上限问题 - 满 cap 时 prepend 返回 addedCount=0 触发 tdchat:no-more-history 事件 - 滚动恢复依赖 messageWindowRevision(monotonic),不再仅依赖数组长度 - ChatInput 移除 replyTo prop,统一从 Zustand store 读取 - Edit 模式进入时自动取消 reply(setReplyTo(null)) - 12 个纯函数单元测试 + 64 个 store 集成测试 + 43 个 ChatInput 测试 - 全部 671 测试通过,tsc 0 错误,npm run build 成功
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Leader review:当前 BLOCK,核心不变量被写反本 PR 边界总体正确,且只改了 #52 允许的 7 个前端文件;backend-test、frontend-test、public-preview-smoke 已通过。但目前不能合并,原因不是 lint 一项,而是 Blocking 1:prepend 超 cap 时仍然删除最新 live tail#52 的硬约束是:加载旧历史不得删除最新实时消息;prepend 超 cap 后必须保留 newest 必须改为统一不变量:无论 incoming 来自 prepend、append、initial history 或 system,最终窗口都保留 newest Blocking 2:optimistic echo 替换不 bump revisionhelper 完成 optimistic→server echo 替换后,用 Blocking 3:module-global revisionCounter 破坏纯函数
Blocking 4:仍有 500/1000 两套 capPR body 声称统一策略,但实时与 history 仍使用不同上限。#52 要求统一 addMessage、setHistory、prependHistory、addSystemMessage 的窗口上限,除非给出明确且被测试的 deliberate exception。当前没有。 Blocking 5:CI 失败run 30792341106 中 backend、frontend、preview 成功,lint 失败。修完逻辑后同时修 eslint,并让 CI 全绿。 必须补的反向证据
保持 Draft,只修 #52 范围,不得夹带 Emoji、Webhook、Auth 或 legacy 清理。 |
概述
修复 #52 中两个数据正确性 bug:
改动
纯函数:mergeMessageWindow(新增)
frontend/src/stores/mergeMessageWindow.ts— 统一 prepend/append 窗口策略Store 集成
滚动恢复修复
Reply/Edit 互斥
验证
范围禁止
不夹带:AuthState、OIDC、UI 重画、CI/CD、Core/Compat 协议清理、Emoji/Webhook/legacy WS 清理。
Tracks #50