Repository navigation
fix(chat): 防止旧历史读取覆盖新的流式缓存 - #2224
Conversation
历史动作的慢读取可能在新流式消息之后返回,原逻辑无条件替换缓存。仅缓存读取期间未改变的快照,调用方仍得到完整历史用于独立校验。 Refs vastsa#2086
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review: the change adds a snapshot identity guard so a slow full-session read no longer overwrites a cache updated during the request, with a new regression test and spec updates. The guard matches the stated behavior and the test covers the late-read race, cache=false, and unchanged-cache population. No evidenced correctness defect found in the supplied diff; full verification is limited to the patch text because repository context, function contracts, surrounding callers, and the stated test results are not available here.
No evidenced findings in the supplied diff.
Head: 20cdaef
Base: ab56bfe
CI: pending; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
主线已合入停止失败时保留运行状态的修复。保留独立问题的行为说明和新增停止场景,使共享分支继续包含当前主线且不改写历史。
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only 初步审查:在 loadFullSessionMessages 中增加请求前缓存引用比较,避免慢返回的全量 transcript 覆盖期间更新的流式缓存;附回归测试与规格文档。从补丁可见的实现与新增测试相容,未发现有引用行直接支持的确定缺陷。未运行任何测试、类型检查或仓库验证,也无法核实 API 行为、并发时序或完整调用路径。
No evidenced findings in the supplied diff.
Head: 6f8ec99
Base: 215b7a9
CI: pending; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
vastsa
left a comment
There was a problem hiding this comment.
独立验证通过:保留新增回归,临时换回当前 main 215b7a9 的生产 session-runtime 实现,旧历史返回后 streaming tail 丢失,测试失败;恢复候选后缓存竞态及 session-runtime-updates 共 9/9 通过。Desktop tsc --noEmit、diff-check 通过。核对生产缓存写入及调用方,引用检查保留请求期间更新的快照,调用方仍得到完整历史,修改范围最小。此次验证证明确定的缓存竞态,不代表解决 #2086 全部症状。
最新 main 215b7a9,head 6f8ec99,实际 merge ref dbd4b49 的父提交匹配两者,源码树均为 63779ac6fe122630eedc1999a68623ae6355fd4f。六项 CI 全部 SUCCESS(含 Windows transcript cache 与 Trusted extensions Electron E2E)。本地生产 runtime/API Promise 边界回归通过;没有本地完整 Electron UI 或真实 provider 执行。
用于历史动作的全量 transcript 读取返回较慢时,原逻辑无条件覆盖 session cache,会丢掉读取期间新进入缓存的流式消息;再切回会话可能显示旧快照。
只在缓存仍是请求开始时的快照时回填。调用方仍获得完整历史并执行自身校验,新流式/编辑缓存保留。
验证:旧代码新增回归丢掉 streaming tail,修复后保留新快照。也验证未变化时可以缓存、cache=false 不写入。共 9 项缓存/流式回归与 Desktop TypeScript 检查通过;使用生产 session runtime 和受控 API Promise,无 provider 执行。完整 Electron E2E 未运行。基线 ab56bfe,候选 20cdaef。
Refs #2086。修复会话缓存的一种竞态,不声称解决该 issue 所有内存、粘贴和分支问题。
同步候选验证(2026-11-09):普通 merge 主线 215b7a9,候选 6f8ec99;文档双方段落均保留。缓存/streaming 与 Stop/terminal 回归 22/22、Desktop TypeScript 和样式检查通过。GitHub merge ref dbd4b49 的源码树与已测试候选相同。完整 Electron E2E 未运行。2026-11-09 22:40 复查:以上最新候选的六项 CI 全部 SUCCESS,无 pending、无失败;包含 JS build/typecheck/lint/architecture/test、Docs、最新基线、Rust、Windows transcript cache E2E 和 Trusted extensions Electron E2E。最新 AIUO diff-only 初审没有确定发现,但不是人工批准。