Skip to content

Web UI: the markdown renderer no longer freezes the tab on CRLF text - #637

Merged
FMXExpress merged 1 commit into
mainfrom
claude/pasclaw-desktop-plan-uapzcp
Nov 13, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/pasclaw-desktop-plan-uapzcp

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

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 (in webui.html and in desktop.html) looped forever on text with CRLF line endings:

  • In a JS regex, . stops at \r. So ## Title\r failed the heading test (^(#{1,6})\s+(.*)$) but still matched the paragraph loop's stop test (^#{1,6}\s).
  • The paragraph branch therefore took no line and i never moved. The loop kept pushing empty paragraphs until the tab locked up.
  • A "```lang\r" fence line does the same, and so do U+2028 and U+2029.

How a reply gets CRLF: the Delphi build's sLineBreak is 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 renderMarkdown and renderAssistantHTML:

  • Line endings are normalised before splitting: \r\n, \r, U+2028 and U+2029 all become \n.
  • The paragraph branch always takes the line it is on. That line has already failed every block test, so it is paragraph text. Taking it guarantees the loop moves, whatever a future block test and the stop tests disagree on.

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 of make test):
    • It loads renderMarkdown from both pages and runs every line ending (CRLF, CR, U+2028, U+2029) through headings, fences, lists and mixed text.
    • Each call runs in vm with a 2-second timeout, so a regression fails the test instead of hanging the build.
    • Against the old pages it fails 32 times, each one a call that never finished. It passes now.
    • It skips cleanly where Node isn't installed.
  • Browser: in Chromium, a model reply with CRLF line endings and a heading froze 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-e2e and make test-context-usage-e2e still pass on the rebuilt binary.

Generated by Claude Code

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T07:32:43.289814Z 910f7f7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@FMXExpress
FMXExpress merged commit e200b5e into main Nov 13, 2026
@FMXExpress FMXExpress mentioned this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants