The best way to control Claude Code, Codex and more from any computer or phone
fix(server): streamed replies keep updating after a line that starts with inline triple-backtick code (#30966)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
MarcoDotIO committed
Nov 14, 2026 at 20:38 UTC
96ffe454cdb5d1e4707b198fd2834731b042d1c1
4 files changed
+9
-2
apps/server/src/orchestration-v2/assistantStreaming.test.ts
+4
@@ -14,6 +14,10 @@ describe("V2 assistant streaming", () => {
14
ready: "```ts\nx()\n```\n",
15
rest: "rest",
16
});
17
+ expect(splitBufferedAssistantText("```a``` is inline.\n\n```\ncode\n\nmore\n")).toEqual({
18
+ ready: "```a``` is inline.\n\n",
19
+ rest: "```\ncode\n\nmore\n",
20
+ });
21
});
22
});
23
apps/server/src/orchestration-v2/assistantStreaming.ts
+2
-1
@@ -2,7 +2,8 @@ import type { ResponseStreamingMode } from "@t3tools/contracts";
2
import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
3
4
// List fences can open at any indentation; closers may be at most three spaces deeper.
5
-const MARKDOWN_FENCE_PATTERN = /^( *)(`{3,}|~{3,})/;
5
+// A backtick fence's info string cannot contain a backtick, so "```npm test``` runs" is inline code.
6
+const MARKDOWN_FENCE_PATTERN = /^( *)(`{3,}(?![^`\r\n]*`)|~{3,})/;
7
// CommonMark blank lines contain only spaces and tabs.
8
const BLANK_LINE_PATTERN = /^[ \t]*$/;
9
// Require trailing space so partial list markers cannot match during streaming.
apps/web/src/components/chat/markdownStreamBlocks.test.tsx
+1
@@ -34,6 +34,7 @@ describe("splitMarkdownBlocks", () => {
34
"Setext\n===\n\nnext\n---\n\n- [ ] task\n- [x] done",
35
"- a\n\n ```\n x\n\n```\n\nb",
36
"- a\n\n ```\n x\n\ny\n\n ```\n\nb",
37
+ "```a``` is inline.\n\nprose\n\n```\none\n\ntwo\n```\n\nafter",
38
"intro\n\n★ Insight ─────\nfirst\n\n```\n─────\n```\n\n- point\n─────\n\nafter\n\n`★ Insight ─────`\nsecond\n`─────`\n\nend",
39
])("renders each block as the whole text renders it, at every streamed prefix: %j", (text) => {
40
for (let end = 0; end <= text.length; end++) {
apps/web/src/components/chat/markdownStreamBlocks.ts
+2
-1
@@ -1,6 +1,7 @@
1
// Definitions, footnotes, raw HTML, container directives and display math can tie blocks together.
2
const DOCUMENT_WIDE_SYNTAX = /^ {0,3}(?:\[[^\]\n]+\]:|<[A-Za-z!?/]|:::|\$\$)|\[\^/m;
3
-const FENCE_PATTERN = /^ {0,3}(`{3,}|~{3,})/;
3
+// A backtick fence's info string cannot contain a backtick, so "```a``` is inline" is a code span.
4
+const FENCE_PATTERN = /^ {0,3}(`{3,}(?![^`\n]*`)|~{3,})/;
5
// After a blank line these still continue the previous block: a list item or indented content.
6
const CONTINUATION_PATTERN = /^(?:[ \t]|(?:[-*+]|\d{1,9}[.)])(?:[ \t]|$))/;
7
// Claude insight fences render as one callout, so they stay in one block until the closing rule.