Repository navigation
fix(markdown): stream Markdown cheaply and converge with one parse - #66
Merged
Merged
Conversation
Port of upstream `iced-rs#3465`, keeping our TeX math option and adapting its code-highlighter commit fix to our `Highlighter`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
agentos-chat-panel feeds every streamed LLM delta to
markdown::Content::push_str. Each push re-parses the whole last block, so a long list gets slower with every token. The streamed result can also differ from parsing the finished text: an image shows twice, a reference link stays broken, or a closed metadata block is not swallowed.Fix
push_strre-parses only the last bullet of a list, so a push costs about the same however long the list is.ENABLE_MATH) stays on.iced-rs/iced#3465, adapted to our highlighter.Testing
widget/tests/markdown.rs: upstream's convergence tests and fuzzer, plus math cases and a highlighter case. 42 pass (43 withhighlighter). Againstmaster, 21 of the 42 fail.cargo lintandcargo fmt --checkpass.masterat the image line. The check waits on chat-panel'stest/streamed-markdownbranch until chat-panel moves to this iced.markdown::Content.To try it:
cargo test -p iced_widget --test markdowncargo test -p iced_widget --features highlighter --test markdown highlight🤖 Generated with Claude Code