fix(message): render markdown while streaming assistant output#3337
fix(message): render markdown while streaming assistant output#3337SuMuxi66 wants to merge 2 commits into
Conversation
SivanCola
left a comment
There was a problem hiding this comment.
Thanks, this is the right direction and the scope is much cleaner than the broader streaming-markdown work in #3140. I think this PR should be the main path for the focused assistant streaming markdown fix.
Before merging, please fix the streaming cursor placement. Markdown renders a block-level .md wrapper, so rendering <span className="cursor" /> as a sibling after <Markdown /> places the cursor after the markdown block rather than at the end of the rendered text. For normal paragraphs this will show the cursor on the next line, not after the last token.
Please make the cursor render as part of the final rendered markdown content, then verify paragraphs, lists, tables, and code blocks while streaming.
Once this is addressed and verification stays green, I will consider merging it into main-v2.
2118ea7 to
0c8a0a4
Compare
|
Updated. Changes addressed:
Verified:
|
|
更新一下当前 PR 状态: 因为 #3444 已经合并到 当前这个 PR 不再重复实现 streaming Markdown 主逻辑,只保留一个剩余问题修复:
当前最终范围:
验证结果:
所以现在这个 PR 可以理解为基于 #3444 之后的 cursor placement follow-up,不是和 #3444 重复的 streaming Markdown PR。 |
SivanCola
left a comment
There was a problem hiding this comment.
Thanks for narrowing this PR down. I still need changes before merge:
-
In
Markdown.tsx,renderCursorChildrenandstripSentinelunwrap every React element they encounter by returning onlyprops.children. Because the newp/li/td/threnderers run for all Markdown, this regresses normal rendered output too: emphasis, strong text, links, inline code wrappers, task-list checkboxes, and nested list/table structure can lose their element type and props even whenshowCursoris false. Please preserve the original element with transformed children, for example viacloneElement, instead of returning only the descendants. -
For an in-progress fenced code block, the appended sentinel is part of the code children. The
coderenderer callsstripSentineland then rendersCodeViewerwithout any cursor, so the streaming cursor disappears while the assistant is inside an unfinished code block. Please keep the copied/highlighted code text pure while still rendering a visible cursor in the code-block streaming state.
Reviewed/verified:
git diff --check origin/main-v2...origin/pr/3337passed.pnpm --dir desktop/frontend testpassed.pnpm --dir desktop/frontend typecheckcould not complete in a clean review worktree because the generated Wails modules are absent there; the errors are outside this diff.
Once these are addressed and verification stays green, I will consider merging this into main-v2.
SivanCola
left a comment
There was a problem hiding this comment.
Thanks for the update. I re-ran the cursor cases against the current head. The cloneElement fix moves this in the right direction, but there are still Markdown correctness regressions that need to be addressed before merge.
7b0bf00 to
76c943e
Compare
|
已经做了最新的修改了,可以审核了 |
Summary
This PR is now a focused follow-up on top of the merged streaming Markdown work in #3444.
It keeps the streaming cursor rendered inside the Markdown flow instead of outside the rendered block, so the cursor placement remains visually consistent while Markdown content is streaming.
Scope
After rebasing onto the latest
main-v2, this PR contains only:Markdown.tsxMessage.tsxThe original broader streaming Markdown changes are no longer included because #3444 has already landed.
Validation
origin/main-v2npx tsc --noEmitpasses with 0 errorsfix(message): keep streaming cursor inside markdownNotes
This PR also preserves inline Markdown elements such as
<strong>and<em>via thecloneElementpath.