Files
memind/docs/pending-fixes/h5-finish-before-run-gate-20260706.md
john 08feae8bef feat(h5-session): Session Broker、run SSE replay 与 Finish 竞态修复
落地 H5 Session 架构 Patch 1–5(Broker 收口、Router decision、SSE taxonomy、goosed 边界检查),
并新增可选 MEMIND_RUN_STREAM_REPLAY run 事件回放与 H5 假交付 guard;修复 Finish 先于 agent-run
gate 导致 UI 永久 loading 的竞态,接入 verify:h5-session-patches 回归脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 14:19:48 +08:00

1012 B
Raw Permalink Blame History

Finish 先于 agent-run gate 的 UI 竞态(已修复,禁止 merge main / 上 103

状态:已修复 + 单测(2026-07-06

现象

用户发消息后:

  • assistant 回复已显示
  • 底部三个点(streaming)一直转,无法输入下一条

根因

H5 双 SSE 通道时序竞态:

  1. subscribeSessionEvents 收到 goosed FinishchatState = idle
  2. waitForAgentRun 稍后才 succeeded 返回
  3. 旧逻辑 unconditionally setChatState('streaming')Finish 已错过,永久卡住

修复

文件 说明
chat-agent-run-gate.mjs 纯函数 resolvePostAgentRunChatState / shouldPromoteSessionIdToStreaming
chat-agent-run-gate.test.mjs 回归单测
src/hooks/useTKMindChat.ts run gate 完成后若已是 idle 则保持 idle

验证

node --test chat-agent-run-gate.test.mjs
npm run verify:h5-session-patches

手工:本地 pnpm devhi,确认回复完成后 loading 点消失。