fix: batch SSE events in use-convert to survive fast reasoning streams - #159
Open
ChHsiching wants to merge 4 commits into
Open
ChHsiching wants to merge 4 commits into
ChHsiching wants to merge 4 commits into
Conversation
nettee
requested changes
Sep 28, 2026
nettee
left a comment
There was a problem hiding this comment.
The prior terminal-error issue remains for an error-then-done stream. The inline comment has the concrete failure path and regression coverage needed.
🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.
nettee
approved these changes
Sep 28, 2026
nettee
left a comment
There was a problem hiding this comment.
@ChHsiching I verified the repair-frontier update for the SSE batching change: an error frame now remains terminal when OpenClaw subsequently emits its unconditional done, preserving the prior diff-edit baseline and surfacing the run as failed. The added regression covers that producer sequence, and the app test suite and TypeScript check pass locally. Thanks for carefully closing the lifecycle gap and adding focused coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
打开思考模式的模型把思考内容按 token 级小帧推送,经 SSE 到达前端实测峰值每秒 240 条 meta 事件,见 #158。use-convert 的接收循环每解析出一个事件就同步写一次 store,PreviewPane 和日志面板跟着整体重渲染一遍。事件来得比渲染快时处理落后于到达,积压的连接缓冲和更新队列把渲染进程内存耗尽,标签页变成「喔唷,崩溃啦!」错误页,错误代码 Out of Memory。issue 里用离线回放验证:每秒 240 条时主线程占用约 100%,每秒 36 条时 92% 但勉强跟上。
Fix
Verification
next/src/lib/__tests__/use-convert.test.ts新增 13 个用例:7 个纯函数用例,覆盖窗口投递保序、首个 delta 直通、终态直通并先清缓冲、无重复投递、flush 与 dispose;6 个用 fetch 桩驱动 run(),覆盖断连转错误、正常完成、错误终态置任务为 error 且不提交 diff-edit 基线、error 后跟 done 仍按失败收尾、取消不误报;最后一个突发用例在单次网络读取里携带 200 条 meta 帧,断言 200 条全部落地且订阅组件的渲染次数不超过 10 次。新增文件的 13 个用例全部通过。Fixes #158