The best way to control Claude Code, Codex and more from any computer or phone
fix(web): streamed replies render a list's code block as the finished reply does (#28285)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Nov 1, 2026 at 16:02 UTC
d05e4f8e8f3856ffa3e4df9bccf28e7133495126
2 files changed
+6
apps/web/src/components/chat/markdownStreamBlocks.test.tsx
+2
@@ -31,6 +31,8 @@ describe("splitMarkdownBlocks", () => {
31
"| a | b |\n| - | - |\n| 1 | 2 |\n\nAfter the table.",
32
"para\n\n indented code\n\nnext",
33
"Setext\n===\n\nnext\n---\n\n- [ ] task\n- [x] done",
34
+ "- a\n\n ```\n x\n\n```\n\nb",
35
+ "- a\n\n ```\n x\n\ny\n\n ```\n\nb",
36
])("renders each block as the whole text renders it, at every streamed prefix: %j", (text) => {
37
for (let end = 0; end <= text.length; end++) {
38
const source = text.slice(0, end);
apps/web/src/components/chat/markdownStreamBlocks.ts
+4
@@ -14,10 +14,13 @@ export function splitMarkdownBlocks(text: string): string[] | null {
14
let blockStart = 0;
15
let lineStart = 0;
16
let fence: string | null = null;
17
+ let fenceIndent = 0;
18
let afterBlankLine = false;
19
for (const line of text.split("\n")) {
20
const opener = FENCE_PATTERN.exec(line)?.[1];
21
if (fence !== null) {
22
+ // A line left of an indented fence may end the list item holding it, which isn't tracked.
23
+ if (/\S/.test(line.slice(0, fenceIndent))) break;
24
if (
25
opener &&
26
opener[0] === fence[0] &&
@@ -35,6 +38,7 @@ export function splitMarkdownBlocks(text: string): string[] | null {
38
}
39
afterBlankLine = false;
40
fence = opener ?? null;
41
+ if (opener) fenceIndent = line.indexOf(opener);
42
}
43
lineStart += line.length + 1;
44
}