Repository navigation
Conversation
流式期间每帧整文重解析,长答案是 O(n²)。新增保守的块切分器 markdownBlocks.ts:只在不改变语义的空行处切分——围栏内(含空行)、 松散列表、多行引用块都不拆;文档使用链接引用定义或含原始 HTML 块时 整体回退为单块(HTML 块可跨空行直到闭合标签,拆开就会渲染出整文 解析本会丢弃的内容)。 MarkdownContent 流式时按块渲染,已完成块 memo 化,每帧只重解析正在 到达的尾块;流结束后仍走整文渲染,最终 DOM 与静态渲染逐字符一致 (块间复现 react-markdown 顶层块的 \n 分隔符,既有等价测试锁定)。 fixtures 新增两个回归用例:围栏内含空行、松散列表跨空行;新增 burst 合帧与 6KB 长答案流式测试(帧等待按合帧间隔 3 倍余量设置, 断言基于提交计数与 DOM 结构,无墙钟阈值)。
useAutoScrollFollow + 纯函数 distanceFromBottom / shouldFollowStream, 24px 阈值语义显式化。回归测试:贴底持续跟随;用户滚离底部后新内容 不抢回视口;回到底部重新武装。AgentPanel 内联实现改为调用该 hook, 行为不变。
7 tasks
helsome
requested changes
Oct 18, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
独立运行已复现 Markdown 语义回归。markdownBlocks.ts 在普通缩进代码块的内部空行处 flush;输入 " const a = 1;\n\n const b = 2;",真实 MarkdownContent 流式渲染产生两个 pre,整文渲染只有一个 pre。因此流式期间代码块结构/内容与最终结果不一致。请保留缩进代码块连续性,并补 streaming/static DOM 与 code textContent 等价回归。现有测试通过并未覆盖此输入,当前暂不合入。
review 复现:markdownBlocks 在缩进代码块内部空行处 flush,流式渲染产生两个 pre 而整文渲染只有一个。新增 CODE_INDENT 状态机:空行处若下一非空行仍缩进 ≥4 列则保留空行在当前块内;惰性段落延续不会误标为代码。补单元回归(原始输入、 tab 变体、非缩进关闭、惰性延续)与 DOM 等价回归(pre 数量 / code textContent / 容器 textContent 与静态渲染一致)。
Contributor
Author
|
感谢复现和清晰的定位,已修复。 根因: 修法(
回归(按你要求的 streaming/static DOM 与 code textContent 等价):
新提交 |
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.
改了什么
#28 的一个独立子范围:流式渲染性能与 auto-scroll 跟随策略,按“一个 commit 一个目的”拆成两个 commit。
1.
perf(ui): 流式 Markdown 按稳定块增量渲染packages/ui/src/components/chat/markdownBlocks.ts:保守的块切分器。只在不改变语义的空行处切分——围栏内(含空行)、松散列表、多行引用块都不会被拆开;文档使用链接引用定义或含原始 HTML 块时整体回退为单块。MarkdownContent流式时按块渲染:每个块是 memo 化的独立ReactMarkdown,token 爆发时每帧只重解析正在到达的尾块;流结束后仍走整文渲染。\n分隔文本节点,保证流式路径与整文路径textContent完全等价。2.
refactor(agent): 抽取 auto-scroll 跟随策略并补回归测试packages/ui/src/components/agent/autoScroll.ts:useAutoScrollFollow+ 纯函数distanceFromBottom/shouldFollowStream,24px 阈值语义显式化。为什么要改
#28 验收标准中 1-4 已被既有测试覆盖;本 PR 补齐可测试部分:标准 5(离开底部不被拉回)+ 标准 6(长回答流式不逐 token 全页重建 + 可重复性能测试)。
对应 Issue
#28(子范围,不关闭母 Issue)。
验证
环境:Windows 11 / Bun 1.3.14。新测试 40/0 fail、16+ 连跑无 flaky;
bun test packages/ui355–363 pass、tsc --noEmitexit 0。注:本机bun test packages/ui非 isolate 下存在 Bun 1.3.14 存量竞态(main 上 12 轮 8 轮触发),与本次改动无关。已知未完成项