Skip to content

perf(ui-react): parse a streaming answer block by block (#2588) - #4240

Merged
schlessera merged 17 commits into
mainfrom
perf/2588-streaming-markdown-blocks
Nov 18, 2026
Merged

schlessera merged 17 commits into
mainfrom
perf/2588-streaming-markdown-blocks

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #2588.

What this does

Each animation frame gives a streaming text part a new string. BrainMarkdownInner handed the whole of it to react-markdown on every one of those frames: a full remark-gfm parse, rehype-highlight once it has loaded, and a React conversion of the entire part.

  • Split into blocks: splitMarkdownBlocks (packages/ui-react/src/components/chat/markdown-blocks.ts) splits the entity-processed text into top-level blocks. BrainMarkdownInner renders each through a memoized MarkdownBlock keyed by index. A finished block keeps its text, so memo skips it, and only the growing last block re-parses.
  • Defer the tail: each block renders through one component type, StreamedBlock, which defers its text with useDeferredValue only while it grows as the last block: the deferred text is used only when the new text extends it. A block that has just become the last, and content that is replaced rather than extended (another file, a new briefing), show their current text at once, as before. React restarts a deferred render on every new delta, so a deferred tail renders its current text urgently once it has been behind its text for more than MAX_TAIL_LAG_MS (200 ms) (tailText, unit-tested). The moment it fell behind is recorded in an effect, from committed renders only, and cleared once a commit shows it caught up. A render React discards cannot move it, a pause in the stream does not count as lag, and a slow parse under fast deltas still updates at least every 200 ms. The tail never shows less than its last commit did: after a forced render, the older deferred value is not shown again. Input and scrolling outrank re-parsing the tail. When a new block starts below, no element type changes, so nothing remounts.
  • Same HTML: each block keeps the blank lines that follow it, exactly as the whole text has them, so a block ends as it does in the whole parse (a tab-indented code block's trailing whitespace lines included). react-markdown separates top-level blocks with a newline text node. StreamedBlock draws that newline between blocks, so the joined output equals the whole parse.
  • Conservative split points: a blank line (spaces and tabs only, as CommonMark counts one: not NBSP or other Unicode space) outside every fence (backtick or tilde, any length, an unclosed fence running to the end), where the next line starts at column 0 and is not >, | or indented. A list item (-, *, +, 1., 1)) does not split when the block above holds one (it would join that list and make it loose) or ends in an indented line (micromark then reads an empty item or 10. ten as a paragraph). Elsewhere it splits, so a paragraph being typed that starts with a number (3, 3., 3.14) does not split, collapse and split again. The text is never split when it holds a link reference or footnote definition, including one inside a blockquote or a list item, with an escaped bracket in its label or with a label that wraps across lines, or any line that starts with HTML (a finished tag name, followed by whitespace, / or >, so a tag or an autolink still being typed at the end of the text is not one; a comment, processing instruction, declaration or CDATA; an autolink like <https://…> is not HTML), at the top level or after a list-item or blockquote prefix: an HTML block can hold blank lines and fence markers, and how it ends depends on what follows. Only column-0 fences are tracked, and a text holding a fence that is indented or inside a list item or blockquote is never split: a full parse alone knows how a column-0 line closes or reopens it. A text holding a carriage return is never split either: CommonMark ends a line there too, and the scan reads lines at \n alone.
  • Range renders stay whole: a projected range (MarkdownRangeContext, the transcript window) maps offsets into the whole text, so it still parses whole. Ordinary streaming passes no range and is split.
  • Unchanged: holdOpenLink, the share-block cut and the classified-block cuts still run on the full text before the split. They sit upstream in MarkdownContent and BrainMarkdown.

Limitations, as the issue scopes them:

  • The last block re-parses whole, so a single long growing block (a growing code fence) still costs more per frame as it grows.
  • A text left unsplit, because it holds a definition, an HTML line or a contained fence (a numbered list of steps with code in them), costs what it did before. When such a line arrives mid-stream, the text collapses to one block: from then on it parses whole, and its later blocks remount once at that moment (a whole parse has no earlier blocks to keep). A Mermaid diagram in one of them still paints its rendered SVG on that first render, because MermaidBlock initialises from its module-wide SVG cache keyed by source (mermaid-block.tsx:20-31); only its transient source toggle and zoom reset.
  • The whole-text preprocessing is not incremental.

Behaviour change for tests: the growing block's re-parse is deferred, so a test that extends the text with flushSync and reads it straight away sees the previous text for one render. code-fences-plain.layout.tsx streams a growing fence that way; it now polls for the deferred render, and its identity assertions are unchanged. renderer-dispatch.layout.tsx replaces its content rather than extending it, so it passes unchanged.

Acceptance criteria

Criterion Proof
Split and whole render identical HTML (renderToStaticMarkup) for the corpus tests/markdown-blocks.test.tsx "split and whole render the same HTML". The corpus covers reference links and footnotes; loose and tight lists, including an ordered list from 3; backtick and tilde fences with blank lines and an unclosed fence; blockquotes, GFM tables, setext headings and an HTML block; entity tags; share blocks; inline links, code and emphasis. Each fixture also asserts whether it splits, so a match can't come from both sides being whole. The whole render is the same component with the splitter mocked to never split Also "generated documents parse the same split and whole": 15,000 documents from three fixed seeds, built from lines of every construct the split must respect (lists, quotes, fences top-level and nested, HTML, tables, definitions, setext lines, tab and Unicode blanks, images, hard breaks). More than 1,000 of them split, and each is parsed split and whole. React's static renderer hoists an image preload link to the start of its segment, and a DOM render has none, so that one tag is stripped before comparing. This test found the last two cases fixed here.
Appending to the last block of a 24 KB message re-renders no earlier block; fails before, passes after tests/render/streaming-markdown.test.tsx wraps react-markdown to record every parse. For each of three appends to a 25 KB answer, every parse is the grown tail (at most two: deferred, then current)
A finished message renders exactly as before; the link, scratch-link and renderer-dispatch tests pass unchanged Equivalence above. prose-links, scratch-links-render, expired-scratch-links and renderer-dispatch pass unchanged; renderer-dispatch.layout.tsx has no diff in this PR
A Mermaid block in an earlier block keeps its rendered state while later text streams "a new block below leaves the earlier ones parsed once and their elements in place": the Mermaid block is not parsed again, and its element is the same DOM node across three appends
Before/after numbers for appending to a 24 KB answer Below. No Android device is available here, so there is no Long Animation Frames capture

Proof

  • Append cost (desktop, happy-dom, 25.3 KB answer, highlighter loaded, 20 appends, React commit time per append): before median 23.1 ms, p90 30.3 ms; after median 2.7 ms, p90 5.3 ms.
  • Failing first: both render-count tests fail on the old brain-markdown.tsx on their own assertions. The 24 KB test fails on "only the grown tail block re-parses: 24948" (the whole text re-parsed), since its precondition now asks the splitter, not the renderer. The Mermaid test fails on "the diagram's block is not parsed again".
  • Mutations (each restored):
    • No separator between blocks: 7 equivalence cases fail.
    • Drop the list, blockquote and table rule: fails the loose-list equivalence case and the splitter's own case.
    • Drop memo on MarkdownBlock: fails both render-count tests ("at most the tail's two parses").
    • Key blocks by blocks.length - i, which shifts keys when a block is added: fails "the diagram's block is not parsed again".
    • Defer every last block's text, even one that just became last: fails "when a definition arrives and the text must parse whole, the first commit shows the whole text".
    • Drop the carriage-return rule: fails "a fence opened after a bare carriage return".
    • Drop the HTML-line rule: fails the long-HTML splitter case, five equivalence cases and the generated-documents test.
    • Drop the blank lines between blocks again: fails the generated-documents test (a tab-indented code block) and three exact-block cases.
    • Drop the contained-fence guard: fails "a fence indented at the top level".
    • Check long HTML blocks at the top level only: fails "a pre or comment block inside a list item".
    • Count trim()-blank lines as blank, and allow a newline-free label only: fails the Unicode-space paragraph, the Unicode-space fence closer and the backslash-wrapped label cases.
    • Use the deferred text even when the new text does not extend it: fails "replaced content (another document) shows at once".
    • Exclude newlines from a definition label: fails "a definition whose label wraps across lines".
    • Match only column-0 definitions: fails the nested and escaped-definition splitter case and two equivalence cases.
  • Unit: bun run test packages/ui-react: 2704 pass, 7 fail. The 7 are api-client-sync.test.ts's "published sync helper" cases, which fail the same on an unmodified checkout on this host.
  • Browser (ui-react-layout): renderer-dispatch 6/6, code-fences 4/4, code-fences-plain 1/1, expired-scratch-links 4/4, and diagrams-renderer 16/16 (in diagrams-chromium).
  • Full ui-react-layout project on this host, compared with an unmodified checkout:
    • discovery-expansion (12) and brand-placements (8) fail on both.
    • discovery-bands (4) and hygiene-loop (2) fail on both when run on their own. Main's one full run happened to pass them.
    • mermaid-content-renderer failed in a full run with Chromium's "Unable to capture screenshot" protocol error. transcript-qualifiers failed once, in a dialog it opened, not in streamed text. Both pass when run alone with this change.
  • Typecheck, lint and check:pr pass.

Collisions

bun scripts/collisions.ts --json --pr 4240 at head 7182edb: closure reports with #3054, #3056, #3059, #3069, #3581, #3622, #4151, #4198, #4234, #4238.

{"version":1,"kind":"brain-check-pr-receipt","head":"3e08638bd85d091be6f7484f7c0fdac9c3f9fe3f","base":"origin/main","mode":"focused","startedAt":"2026-11-18T00:22:30.002Z","finishedAt":"2026-11-18T00:23:10.113Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13555.968267},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":107.84190200000012},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":69.87111100000038},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":18.659303999997064},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":26341.276041999998}]}

🤖 Generated with Claude Code

Each animation frame gave the streaming text part a new string, and
BrainMarkdownInner handed the whole of it to react-markdown: a full
remark-gfm parse, highlight and React conversion of the part, every
frame. The processed text is now split into top-level blocks, each
parsed by a memoized block component with a stable index key, so a
finished block is skipped while the answer grows; only the growing last
block re-parses, and its re-parse is deferred behind input. Rendered
HTML is unchanged: blocks rejoin with react-markdown's own newline, and
the split is conservative (never inside a fence, before a list,
blockquote, table or indented continuation, nor in a text holding a
definition or a long HTML block). A projected range still parses whole.

Two browser tests read a streamed fence right after a synchronous render;
they now wait for the deferred render of the growing block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@uploads-sh

uploads-sh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-react/src/components/chat/brain-markdown.tsx, packages/ui-react/tests/browser/code-fences-plain.layout.tsx, packages/ui-react/tests/markdown-blocks.test.tsx and 1 more). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4240
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4240 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4240 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4240 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 4240. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bbe6025 against base d84fca3. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "bbe60253b8e7aad9dce7129e9e87e64c9aaf48cd",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:23 — DEFINITION only matches definitions at column 0-3, so text still splits around definitions CommonMark resolves document-wide: in a blockquote ('> [l]: url', '> [^1]: note'), in a list item ('- [l]: url'), or with an escaped bracket ('[a\\\\]b]: url'). Whole parse renders the link or footnote; split renders '[the log][l]' and '[^1]' as literal text. The corpus has only column-0 definitions."
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183,213-216 — When a definition ('[^1]: …') or '<!--'/'<pre>' line streams in, the split collapses to [text]; block 0 becomes last and useDeferredValue returns its old text, so the urgent commit shows only the first block (three paragraphs citing [^1], then '\\n\\n[^1]: Source.' appended, paints 'First para.[^1]'). Blocks 1..n remount: a later Mermaid diagram loses its SVG state and a scrolled-up reader's position is clamped."
    },
    {
      "summary": "packages/ui-react/tests/browser/renderer-dispatch.layout.tsx:45-46 (and code-fences-plain.layout.tsx:38-39) — The criterion says the existing renderer-dispatch tests pass unchanged. The PR edits them to poll, because the deferred tail no longer commits synchronously under flushSync. That is a behaviour change for any caller that reads the DOM straight after rendering new content, and the criterion is not met as written."
    }
  ]
}

…on collapse (#2588)

- A link reference or footnote definition inside a blockquote or a list
  item, or with an escaped bracket in its label, resolves document-wide
  like any other; the splitter now finds those too and parses whole.
- When a definition arrives mid-stream the text collapses to one block,
  so block 0 becomes the last. Its deferred value was block 0's old text,
  and the urgent commit painted that block alone. A block now defers only
  once it was already last, so it shows its current text on the render
  where it becomes last. Later blocks still remount once on that collapse,
  which a whole parse implies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bbe6025 against base d84fca3. Reviewer: agent. 3 findings: 2 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "bbe60253b8e7aad9dce7129e9e87e64c9aaf48cd",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:23 — DEFINITION only matches definitions at column 0-3, so text still splits around definitions CommonMark resolves document-wide: in a blockquote ('> [l]: url', '> [^1]: note'), in a list item ('- [l]: url'), or with an escaped bracket ('[a\\\\]b]: url'). Whole parse renders the link or footnote; split renders '[the log][l]' and '[^1]' as literal text. The corpus has only column-0 definitions.",
      "disposition": "fixed",
      "commit": "af3773b4933cc370e7f0a4fca8280072ab2d6fb8"
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183,213-216 — When a definition ('[^1]: …') or '<!--'/'<pre>' line streams in, the split collapses to [text]; block 0 becomes last and useDeferredValue returns its old text, so the urgent commit shows only the first block (three paragraphs citing [^1], then '\\n\\n[^1]: Source.' appended, paints 'First para.[^1]'). Blocks 1..n remount: a later Mermaid diagram loses its SVG state and a scrolled-up reader's position is clamped.",
      "disposition": "fixed",
      "commit": "af3773b4933cc370e7f0a4fca8280072ab2d6fb8"
    },
    {
      "summary": "packages/ui-react/tests/browser/renderer-dispatch.layout.tsx:45-46 (and code-fences-plain.layout.tsx:38-39) — The criterion says the existing renderer-dispatch tests pass unchanged. The PR edits them to poll, because the deferred tail no longer commits synchronously under flushSync. That is a behaviour change for any caller that reads the DOM straight after rendering new content, and the criterion is not met as written.",
      "disposition": "rejected",
      "reason": "The issue's own scope requires wrapping the last block in useDeferredValue, and a deferred update cannot commit synchronously inside flushSync, so the criterion's 'unchanged' cannot hold together with that scope item. Only the two synchronous reads were changed, to wait for the deferred render; every identity and content assertion is unchanged, and the finished-message equivalence tests show the rendered output is identical."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head af3773b against base d84fca3. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "af3773b4933cc370e7f0a4fca8280072ab2d6fb8",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:29: DEFINITION excludes \\n from the label, so a reference definition whose label wraps across lines (`[long\\nlabel]: https://x.example/`) is missed and the text is split. Whole renders the link; split leaves `[the raft][long\\nlabel]` as literal text. The issue's pattern `^ {0,3}\\[[^\\]]+\\]:` matches across newlines, and no corpus fixture covers it."
    },
    {
      "summary": "packages/ui-react/tests/browser/renderer-dispatch.layout.tsx:46 (and tests/browser/code-fences-plain.layout.tsx:39): the issue requires the existing renderer-dispatch tests to pass unchanged, but the PR rewrites a synchronous assertion into expect.poll because the deferred tail no longer shows the new text on the first commit. The criterion is missed by changing the test instead of the behaviour."
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:218: the last block's useDeferredValue applies to every content change in every BrainMarkdown caller (file-viewer-markdown.tsx:11, ask-user-card.tsx:417, whatsup-modal.tsx:92, share-block.tsx:60, message-rich-text.tsx), not only streaming growth. Replacing content commits the new earlier blocks with the old document's last block (or all the old text if it is one block) for a render; before, it rendered synchronously."
    }
  ]
}

…els (#2588)

- The last block's deferred text is used only when the new text extends
  it. Replaced content (another file, a new briefing, a renderer test
  swapping its content) renders at once again, as before, instead of
  committing the previous document's last block for a render. The
  renderer-dispatch layout test passes unchanged again; only a fence that
  genuinely grows (code-fences-plain) still waits for its deferred render.
- A reference definition whose label wraps across lines resolves
  document-wide too; the splitter now finds it and parses whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head af3773b against base d84fca3. Reviewer: agent. 3 findings: 3 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "af3773b4933cc370e7f0a4fca8280072ab2d6fb8",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:29: DEFINITION excludes \\n from the label, so a reference definition whose label wraps across lines (`[long\\nlabel]: https://x.example/`) is missed and the text is split. Whole renders the link; split leaves `[the raft][long\\nlabel]` as literal text. The issue's pattern `^ {0,3}\\[[^\\]]+\\]:` matches across newlines, and no corpus fixture covers it.",
      "disposition": "fixed",
      "commit": "63229df1b8389d3e473e3591d0330ec91cfa13e3"
    },
    {
      "summary": "packages/ui-react/tests/browser/renderer-dispatch.layout.tsx:46 (and tests/browser/code-fences-plain.layout.tsx:39): the issue requires the existing renderer-dispatch tests to pass unchanged, but the PR rewrites a synchronous assertion into expect.poll because the deferred tail no longer shows the new text on the first commit. The criterion is missed by changing the test instead of the behaviour.",
      "disposition": "fixed",
      "commit": "63229df1b8389d3e473e3591d0330ec91cfa13e3"
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:218: the last block's useDeferredValue applies to every content change in every BrainMarkdown caller (file-viewer-markdown.tsx:11, ask-user-card.tsx:417, whatsup-modal.tsx:92, share-block.tsx:60, message-rich-text.tsx), not only streaming growth. Replacing content commits the new earlier blocks with the old document's last block (or all the old text if it is one block) for a render; before, it rendered synchronously.",
      "disposition": "fixed",
      "commit": "63229df1b8389d3e473e3591d0330ec91cfa13e3"
    }
  ]
}

String trim() also strips NBSP, U+3000, U+FEFF and \v, but CommonMark
counts a line as blank only when it holds spaces and tabs alone, and lets
a closing fence be followed by those alone. The splitter split inside a
paragraph at a line of Unicode space and closed a fence whose closer was
followed by one, so split and whole rendered differently. It also missed
a definition label wrapped after a backslash. Each case is now in the
equivalence corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 63229df against base d84fca3. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "63229df1b8389d3e473e3591d0330ec91cfa13e3",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:55 (and :60): String.prototype.trim() treats NBSP, U+3000, U+FEFF and \\v as whitespace, but CommonMark counts only space/tab lines as blank, so the splitter splits inside a paragraph. Whole 'Para\\n\\u00a0\\nmore' renders one <p>Para\\n\\u00a0\\nmore</p>; split renders <p>Para</p>\\n<p>more</p> (U+3000, U+FEFF, \\v reproduced too). Misses the identical-HTML criterion; no corpus fixture covers it."
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51: the closing-fence check uses .trim() on the rest of the line, so a closer followed by NBSP ('```\\u00a0') is taken as closing the fence. CommonMark allows only spaces or tabs after a closer, so the fence is still open. Whole parse of '```\\ncode\\n```\\u00a0\\n\\nmore' keeps 'more' inside the <pre><code>; split ends the code block and renders <p>more</p>. The split changes the rendered output."
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:29: in DEFINITION's label pattern, `\\\\.` cannot match a backslash before a newline, so a definition whose label wraps after a backslash ('[a\\\\\\nb]: /u') is missed and the text is split. Whole parse renders <a href=\"/u\">a<br/>b</a>; split renders the literal '[a<br/>b]'. This is the same class of bug as the wrapped-label finding fixed in 63229df, but this variant is not covered."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 63229df against base d84fca3. Reviewer: agent. 3 findings: 3 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "63229df1b8389d3e473e3591d0330ec91cfa13e3",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:55 (and :60): String.prototype.trim() treats NBSP, U+3000, U+FEFF and \\v as whitespace, but CommonMark counts only space/tab lines as blank, so the splitter splits inside a paragraph. Whole 'Para\\n\\u00a0\\nmore' renders one <p>Para\\n\\u00a0\\nmore</p>; split renders <p>Para</p>\\n<p>more</p> (U+3000, U+FEFF, \\v reproduced too). Misses the identical-HTML criterion; no corpus fixture covers it.",
      "disposition": "fixed",
      "commit": "8b588033d1e4bf3705e1a586741186b34f339c6e"
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51: the closing-fence check uses .trim() on the rest of the line, so a closer followed by NBSP ('```\\u00a0') is taken as closing the fence. CommonMark allows only spaces or tabs after a closer, so the fence is still open. Whole parse of '```\\ncode\\n```\\u00a0\\n\\nmore' keeps 'more' inside the <pre><code>; split ends the code block and renders <p>more</p>. The split changes the rendered output.",
      "disposition": "fixed",
      "commit": "8b588033d1e4bf3705e1a586741186b34f339c6e"
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:29: in DEFINITION's label pattern, `\\\\.` cannot match a backslash before a newline, so a definition whose label wraps after a backslash ('[a\\\\\\nb]: /u') is missed and the text is split. Whole parse renders <a href=\"/u\">a<br/>b</a>; split renders the literal '[a<br/>b]'. This is the same class of bug as the wrapped-label finding fixed in 63229df, but this variant is not covered.",
      "disposition": "fixed",
      "commit": "8b588033d1e4bf3705e1a586741186b34f339c6e"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 8b58803 against base d84fca3. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "8b588033d1e4bf3705e1a586741186b34f339c6e",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51-55: a fence opened indented in a list item and closed at column 0 counts as closed, but CommonMark ends the item there and the column-0 line opens a new top-level fence, so the splitter splits inside it. For \"1. Install:\\n\\n   ```bash\\n   npm i\\n```\\n\\n2. Run it\\n\\nDone.\" whole puts \"Done.\" in <pre><code>, split gives <p>Done.</p>. Misses the identical-HTML and finished-message criteria; no corpus case covers it."
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:31 (LONG_HTML): unlike DEFINITION, the HTML block types 1-5 guard is anchored at ^ {0,3}< and does not allow list-item or blockquote prefixes. A <pre> or <!-- block inside a list item is split: for \"- <pre>\\n\\n  x\\n\\ny\" (or \"- <!--\\n\\n  x\\n\\ny\") the whole parse keeps the blank-line text inside the <li> and the split drops it, so the HTML differs despite the file comment's claim that such texts are never split."
    }
  ]
}

…ainer (#2588)

A fence opened inside a list item can be closed, or a new top-level one
opened, at column 0 in ways only a full parse resolves; and a long HTML
block after a list-item or blockquote prefix keeps its blank lines in
the item. The splitter tracked fences up to three spaces in and checked
HTML blocks at the top level only, so split and whole rendered
differently. It now tracks only column-0 fences and parses whole any
text holding an indented or contained fence, or a long HTML block
behind a container prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 8b58803 against base d84fca3. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "8b588033d1e4bf3705e1a586741186b34f339c6e",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51-55: a fence opened indented in a list item and closed at column 0 counts as closed, but CommonMark ends the item there and the column-0 line opens a new top-level fence, so the splitter splits inside it. For \"1. Install:\\n\\n   ```bash\\n   npm i\\n```\\n\\n2. Run it\\n\\nDone.\" whole puts \"Done.\" in <pre><code>, split gives <p>Done.</p>. Misses the identical-HTML and finished-message criteria; no corpus case covers it.",
      "disposition": "fixed",
      "commit": "6148259f4b64a002ac2cc019c564fa3d6b1f0359"
    },
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:31 (LONG_HTML): unlike DEFINITION, the HTML block types 1-5 guard is anchored at ^ {0,3}< and does not allow list-item or blockquote prefixes. A <pre> or <!-- block inside a list item is split: for \"- <pre>\\n\\n  x\\n\\ny\" (or \"- <!--\\n\\n  x\\n\\ny\") the whole parse keeps the blank-line text inside the <li> and the split drops it, so the HTML differs despite the file comment's claim that such texts are never split.",
      "disposition": "fixed",
      "commit": "6148259f4b64a002ac2cc019c564fa3d6b1f0359"
    }
  ]
}

…#2588)

A column-0 fence marker inside an HTML block of type 6 or 7 (<details>,
<div>) is part of the HTML block, not a fence, until a blank line ends
the block. The splitter took it as a fence, paired fences wrongly and
split inside the real one. A fence marker in a run of lines that began
with an HTML tag now makes the text parse whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 6148259 against base d84fca3. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "6148259f4b64a002ac2cc019c564fa3d6b1f0359",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:57-79: a column-0 fence marker inside an HTML block (type 6/7, e.g. <details>) is taken as a fence opener, but CommonMark keeps that line in the HTML block, so fences pair wrongly and the text splits inside the real fence. Whole parse of '<details>\\n```js\\na\\n\\nb\\n```\\n</details>\\n\\nAfter.' puts 'After.' in <pre><code>; split gives <p>After.</p>. Misses the identical-HTML and finished-message criteria; no corpus case."
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183-188: when a definition, a '<pre'/'<!--' line or an indented fence arrives mid-stream (footnote definitions usually come last), the split collapses to [text] and StreamedBlock keys 1..n unmount, so a Mermaid diagram after block 0 remounts and loses its rendered SVG state, which the whole parse kept before. Misses the criterion that an earlier block's Mermaid keeps its state while later text streams; the PR calls it a limitation."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 6148259 against base d84fca3. Reviewer: agent. 2 findings: 1 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "6148259f4b64a002ac2cc019c564fa3d6b1f0359",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:57-79: a column-0 fence marker inside an HTML block (type 6/7, e.g. <details>) is taken as a fence opener, but CommonMark keeps that line in the HTML block, so fences pair wrongly and the text splits inside the real fence. Whole parse of '<details>\\n```js\\na\\n\\nb\\n```\\n</details>\\n\\nAfter.' puts 'After.' in <pre><code>; split gives <p>After.</p>. Misses the identical-HTML and finished-message criteria; no corpus case.",
      "disposition": "fixed",
      "commit": "2e48399f6a063d0a231a93e897814debecf17411"
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183-188: when a definition, a '<pre'/'<!--' line or an indented fence arrives mid-stream (footnote definitions usually come last), the split collapses to [text] and StreamedBlock keys 1..n unmount, so a Mermaid diagram after block 0 remounts and loses its rendered SVG state, which the whole parse kept before. Misses the criterion that an earlier block's Mermaid keeps its state while later text streams; the PR calls it a limitation.",
      "disposition": "rejected",
      "reason": "The rendered SVG is not lost: MermaidBlock initialises its svg state from the module-wide cache keyed by source (peekMermaidSvg, mermaid-block.tsx:20-31), so the remounted diagram paints its rendered SVG on its first render. Only transient UI state (source toggle, zoom) resets, once, at the collapse. A collapse is required for correctness (the text must parse whole once a definition exists), and the PR states it."
    }
  ]
}

schlessera and others added 2 commits November 17, 2026 21:57
…es in blocks (#2588)

A generated-document test (fixed seeds, lines drawn from every construct
the split must respect) found two more ways split and whole differed:
- an HTML-looking line continuing a list item ends differently when the
  block stands alone; any line that starts with HTML (after container
  prefixes) now makes the text parse whole, which subsumes the long-HTML
  and HTML-run guards;
- dropping the blank lines between blocks changed how a tab-indented code
  block ended. The blank lines now stay with the block before, exactly as
  the whole text has them.
The generated test stays in the suite: 15,000 documents, over a thousand
of which split, each parsed split and whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CommonMark ends a line at a bare \r as well as \n, while the splitter
reads lines at \n alone, so a fence opened after a carriage return went
unseen and the text split inside it. A text holding a carriage return
now parses whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head b4696f9 against base d84fca3. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "b4696f951e9a3d356dd499d992e8046dd7f9634e",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51: fences are tracked on lines split at \"\\n\" only, but CommonMark also ends a line at a bare \"\\r\", so a fence opened after a CR is missed and the text splits inside it. Repro: \"Para\\r```\\ncode\\n\\nmore code\\n```\\n\\nAfter.\" splits after \"code\". The split HTML ends the code block there and opens a stray fence; the whole parse keeps one block. Fix: normalise CRs or never split a text holding \"\\r\"."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head b4696f9 against base d84fca3. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "b4696f951e9a3d356dd499d992e8046dd7f9634e",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:51: fences are tracked on lines split at \"\\n\" only, but CommonMark also ends a line at a bare \"\\r\", so a fence opened after a CR is missed and the text splits inside it. Repro: \"Para\\r```\\ncode\\n\\nmore code\\n```\\n\\nAfter.\" splits after \"code\". The split HTML ends the code block there and opens a stray fence; the whole parse keeps one block. Fix: normalise CRs or never split a text holding \"\\r\".",
      "disposition": "fixed",
      "commit": "bcc54acbd0bc6581a16a6722abfc0d3eeaa7ca80"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bcc54ac against base d84fca3. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "bcc54acbd0bc6581a16a6722abfc0d3eeaa7ca80",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:219-220 (StreamedBlock): the last block re-parses only in a deferred render, and each new delta interrupts and restarts it (React 19.3 transition lanes expire after 5 s). If the tail's parse outlasts the gap between deltas (a long highlighted fence, a phone, a 24 KB text left whole, ~40 ms on desktop), the tail freezes for up to 5 s or until the stream pauses; before, it updated every frame. Tests flush with act; none covers it."
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183-188: when a definition, HTML line or indented fence arrives mid-stream (closing footnotes, a line-start '<https://…>' autolink), the split collapses to [text]; StreamedBlock keys 1..n unmount and remount under block 0. A later block's Mermaid diagram loses its open zoom viewer and source toggle (mermaid-block.tsx:28-35) and later DOM nodes are replaced; the whole parse kept them, as an appended definition shifts no earlier key."
    }
  ]
}

…#2588)

- React restarts a deferred render on every new delta, so a tail whose
  parse outlasts the gap between deltas (a long highlighted fence, a slow
  device, a text left whole) could stop updating until the stream paused.
  Past MAX_TAIL_LAG_MS (200 ms) of lag, the current tail now renders
  urgently (tailText), and the lag starts again from there.
- A line-start autolink (<https://...>) no longer counts as an HTML line,
  so it no longer makes the text parse whole; only a tag name, a comment,
  a declaration or a processing instruction does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bcc54ac against base d84fca3. Reviewer: agent. 2 findings: 1 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "bcc54acbd0bc6581a16a6722abfc0d3eeaa7ca80",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:219-220 (StreamedBlock): the last block re-parses only in a deferred render, and each new delta interrupts and restarts it (React 19.3 transition lanes expire after 5 s). If the tail's parse outlasts the gap between deltas (a long highlighted fence, a phone, a 24 KB text left whole, ~40 ms on desktop), the tail freezes for up to 5 s or until the stream pauses; before, it updated every frame. Tests flush with act; none covers it.",
      "disposition": "fixed",
      "commit": "8336e0238056e498098a21c0ce24769819facc6c"
    },
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:183-188: when a definition, HTML line or indented fence arrives mid-stream (closing footnotes, a line-start '<https://…>' autolink), the split collapses to [text]; StreamedBlock keys 1..n unmount and remount under block 0. A later block's Mermaid diagram loses its open zoom viewer and source toggle (mermaid-block.tsx:28-35) and later DOM nodes are replaced; the whole parse kept them, as an appended definition shifts no earlier key.",
      "disposition": "rejected",
      "reason": "The collapse is required for correctness: once a definition exists the text must parse whole, so the earlier blocks' elements cannot be kept. It happens at most once per message. The rendered SVG survives it (MermaidBlock initialises from its module-wide cache, mermaid-block.tsx:20-31); only transient UI state resets. The autolink trigger the finding names is removed in this commit: an autolink no longer counts as an HTML line."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 8336e02 against base d84fca3. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "8336e0238056e498098a21c0ce24769819facc6c",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:221-224: the 200 ms tail-lag bound does not hold. StreamedBlock writes lagSince.current during render, and React keeps ref writes from discarded renders. Each background deferred render sets lagSince to null (deferred===text); when a delta interrupts it, the next urgent render restarts the lag from now. Under fast deltas with a slow parse the tail never updates until the stream pauses. The pure tailText tests cannot catch this."
    },
    {
      "summary": "packages/ui-react/tests/markdown-blocks.test.tsx:67: the corpus fixture meant to cover entity tags uses <person> and <place>. Those are not entity tags (renderEntityTags only converts co|p|proj|ev|d|st|f), so its catch-all strip deletes both before parsing and no entity marker is ever rendered or compared. The issue's first criterion requires entity tags in the split-vs-whole corpus, and this fixture leaves it unproven."
    }
  ]
}

)

The lag start was a ref written during render, and React keeps ref
writes from renders it discards: each background deferred render reset
it, so under fast deltas the bound restarted and never fired. The tail
now records when a commit last showed its current text, in an effect,
and tailText compares now against that; a discarded render cannot move
it. The entity-tag corpus fixture now uses real entity tags (<p>, <co>,
<proj>, <d>) and asserts they render as entities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c4ee76a against base d84fca3. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c4ee76a90c9958e6af267b03523a58b672e66855",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:221-230 (tailText, markdown-blocks.ts:106-109): after the 200 ms bound forces an urgent render of the current text, useDeferredValue still holds the old value D0, since its background render keeps being interrupted, and that commit clears behindSince. The next delta gets D0 back from tailText, so the tail goes back from text_n to old text for 200 ms, then forward. Before, it only grew. No test covers it."
    },
    {
      "summary": "packages/ui-react/tests/render/streaming-markdown.test.tsx:58: the issue requires the 24 KB render-count test to fail on the tree before the change. On that tree it fails on the precondition `blocks > 100`, because a whole parse is one parse per render. It never reaches the 'only the grown tail block re-parses' assertion, so its failing-first receipt is not for the reason claimed (AGENTS.md testing rules). The PR admits this and relies on a memo mutation instead."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c4ee76a against base d84fca3. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c4ee76a90c9958e6af267b03523a58b672e66855",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/brain-markdown.tsx:221-230 (tailText, markdown-blocks.ts:106-109): after the 200 ms bound forces an urgent render of the current text, useDeferredValue still holds the old value D0, since its background render keeps being interrupted, and that commit clears behindSince. The next delta gets D0 back from tailText, so the tail goes back from text_n to old text for 200 ms, then forward. Before, it only grew. No test covers it.",
      "disposition": "fixed",
      "commit": "c2268a6338bd2cef5dcd97b6c3f5bdcf542de1bf"
    },
    {
      "summary": "packages/ui-react/tests/render/streaming-markdown.test.tsx:58: the issue requires the 24 KB render-count test to fail on the tree before the change. On that tree it fails on the precondition `blocks > 100`, because a whole parse is one parse per render. It never reaches the 'only the grown tail block re-parses' assertion, so its failing-first receipt is not for the reason claimed (AGENTS.md testing rules). The PR admits this and relies on a memo mutation instead.",
      "disposition": "fixed",
      "commit": "c2268a6338bd2cef5dcd97b6c3f5bdcf542de1bf"
    }
  ]
}

A line-start '<h' or '<co' at the very end of a streaming text matched
HTML_LINE through its end-of-text lookahead, so the split collapsed to
the whole text and split again on the next delta, remounting every
earlier block. A tag name now counts only once whitespace, '/' or '>'
follows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c2268a6 against base d84fca3. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c2268a6338bd2cef5dcd97b6c3f5bdcf542de1bf",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:42 (with brain-markdown.tsx:183): HTML_LINE's lookahead `(?=[\\s/>]|$)` lets `$` match a partial tag name at the end of a streaming text. While a line-start autolink or tag streams in ('<h'..'<https', '<co'), the split collapses to [text] and then splits again. StreamedBlock keys 1..n unmount and remount, an earlier block's Mermaid loses its zoom and source state, and the whole text parses. No test covers it."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c2268a6 against base d84fca3. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c2268a6338bd2cef5dcd97b6c3f5bdcf542de1bf",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:42 (with brain-markdown.tsx:183): HTML_LINE's lookahead `(?=[\\s/>]|$)` lets `$` match a partial tag name at the end of a streaming text. While a line-start autolink or tag streams in ('<h'..'<https', '<co'), the split collapses to [text] and then splits again. StreamedBlock keys 1..n unmount and remount, an earlier block's Mermaid loses its zoom and source state, and the whole text parses. No test covers it.",
      "disposition": "fixed",
      "commit": "c8b5ac626b90288275e2a8deb5a95ab52aa4944f"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c8b5ac6 against base d84fca3. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c8b5ac626b90288275e2a8deb5a95ab52aa4944f",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:54: CONTINUES matches an ordered-list marker at end of line through `$`, so a paragraph starting with a number flips the split back and forth. Verified with a Mermaid fence plus a blank line: `3` gives 2 blocks, `3.` gives 1, `3.14` gives 2. The earlier block re-parses twice at urgent priority and block 1 remounts. This is the defect class c8b5ac6 fixed for `<h`, and it hits versions and decimals (`2.0`)."
    }
  ]
}

…list

Every list marker kept the split from starting a new block, so a
paragraph being typed that starts with a number ('3', '3.', '3.14')
split, collapsed and split again as it grew. A list item now continues
the block above only when that block holds a list item (it would join
the list and make it loose) or ends in an indented line (micromark then
reads an empty item or '10. ten' as a paragraph).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c8b5ac6 against base d84fca3. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "c8b5ac626b90288275e2a8deb5a95ab52aa4944f",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/chat/markdown-blocks.ts:54: CONTINUES matches an ordered-list marker at end of line through `$`, so a paragraph starting with a number flips the split back and forth. Verified with a Mermaid fence plus a blank line: `3` gives 2 blocks, `3.` gives 1, `3.14` gives 2. The earlier block re-parses twice at urgent priority and block 1 remounts. This is the defect class c8b5ac6 fixed for `<h`, and it hits versions and decimals (`2.0`).",
      "disposition": "fixed",
      "commit": "9a58d817f014a8e7531df2c0c922609df76c0f34"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 9a58d81 against base d84fca3. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4240,
  "head": "9a58d817f014a8e7531df2c0c922609df76c0f34",
  "base": "d84fca3e08dfa7c5b65973f931ab08d740537d02",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

@schlessera

Copy link
Copy Markdown
Owner Author

Candidate run 44198693229 at 5905bf3 failed unit (3) on one test, web-tools-broker.test.ts "no result returns after the turn stops being current…". The failure is JSON Parse error: Unexpected EOF: the test helper read calls.jsonl while the executor fixture was still writing it. This PR does not touch ui-server. The race is filed as #4247, with no milestone, under the flake ruling. I am requesting a fresh confirmation. This is not a rerun of the failed job.

@schlessera

Copy link
Copy Markdown
Owner Author

Candidate run 44207608156 at 3e08638 failed unit (8) on packages/ui-server/tests/turn-scope.test.ts "files_changed leaves out a reference clone under workspaces/…". The test hit the 30 s per-test limit while writing about 2500 fixture files on a loaded worker. This PR does not touch ui-server. The timeout is filed as #4249, with no milestone, under the flake ruling. The earlier run's failure is #4247. I am requesting a fresh confirmation, not a rerun of the failed job.

@schlessera
schlessera marked this pull request as draft November 18, 2026 00:45
@schlessera
schlessera marked this pull request as ready for review November 18, 2026 00:45
@schlessera
schlessera merged commit c2870f8 into main Nov 18, 2026
91 of 111 checks passed
schlessera added a commit that referenced this pull request Nov 18, 2026
…4250) (#4251)

#4240 re-parses the growing last markdown block at deferred priority, so
the delta appended inside flushSync shows on the next commit. The
frame-refusals visual case read the reply straight after it; it now
polls for the appended text.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

ui-react: a streaming answer re-parses its whole text on every frame

1 participant