Repository navigation
Web UI: the markdown renderer no longer freezes the tab on CRLF text - #637
Merged
Merged
Conversation
renderMarkdown (webui.html and desktop.html) looped forever on text with
CRLF line endings. In a JS regex "." stops at "\r", so "## Title\r"
failed the heading test while still stopping a paragraph: the paragraph
branch took no line, i never moved, and the tab froze pushing empty
paragraphs ("this page is slowing down"), and froze again on every
reload because the web UI reopens the latest chat. Same for a
"```lang\r" fence and for U+2028 / U+2029. The Delphi build's sLineBreak
is CRLF and the Anthropic provider joins a reply's text blocks with it,
so a reply whose block ended in a heading was enough. Present since
#549.
- Line endings are normalised (\r\n, \r, U+2028, U+2029 -> \n) before
splitting, in renderMarkdown and renderAssistantHTML.
- The paragraph branch always takes the line it is on (it failed every
block test, so it is paragraph text), so no line can stall the loop
whatever a future block test and the stop tests disagree on.
LF text renders byte-identically to before; CRLF renders as its LF
equivalent. The native client's Pascal renderer was checked on the same
inputs and is unaffected.
test-webui-markdown loads renderMarkdown from both pages and runs every
line ending in vm with a 2 s timeout, so a regression fails instead of
hanging the build: 32 failures on the old pages, none now. In Chromium a
CRLF reply froze main's web UI (no response for 23 s) and renders in
0.7 s with the fix.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merged
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.
The problem
A chat in the web UI froze the browser tab. Firefox first warned "this page is slowing down", then the tab stopped responding. Reloading didn't help: the web UI reopens the most recent chat on load, renders the same reply, and freezes again.
renderMarkdown(inwebui.htmland indesktop.html) looped forever on text with CRLF line endings:.stops at\r. So## Title\rfailed the heading test (^(#{1,6})\s+(.*)$) but still matched the paragraph loop's stop test (^#{1,6}\s).inever moved. The loop kept pushing empty paragraphs until the tab locked up.How a reply gets CRLF: the Delphi build's
sLineBreakis CRLF, and the Anthropic provider joins a reply's text blocks with it. So a reply whose text block ends in a heading is enough. The bug has been there since #549.The fix
Both pages, in
renderMarkdownandrenderAssistantHTML:\r\n,\r, U+2028 and U+2029 all become\n.Text with plain LF line endings renders byte-identically to before (checked against the old renderer on a corpus of headings, fences, lists, quotes, rules and inline markup). CRLF text now renders exactly like its LF equivalent.
I also ran the native client's Pascal renderer (
PasClaw.Client.Markdown) on the same inputs. It finishes on all of them and is not affected.Tests
make test-webui-markdown(new, part ofmake test):renderMarkdownfrom both pages and runs every line ending (CRLF, CR, U+2028, U+2029) through headings, fences, lists and mixed text.vmwith a 2-second timeout, so a regression fails the test instead of hanging the build.main's web UI; it gave no response for 23 s before I killed it. The fixed UI rendered it in 0.7 s, with the heading and code block correct.make test-provider-error-e2eandmake test-context-usage-e2estill pass on the rebuilt binary.Generated by Claude Code