@devries-cameron20 / t3code Mirror · read-only / commits / 4821696509
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 03:15 UTC

fix(client-runtime): pull request bodies with CRLF line endings keep their code blocks whole (#30352)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

MarcoDotIO committed Nov 5, 2026 at 23:25 UTC 4821696509d268eac35a8c3fa04cb4211d68a504
2 files changed +23 -1
packages/client-runtime/src/pullRequestMarkdown.test.ts
+21
@@ -80,6 +80,27 @@ describe("pull request body segmentation", () => {
80 ]);
81 });
82
83 + // GitHub keeps CRLF in a body written in its web editor.
84 + it("recognizes fences in a body with CRLF line endings", () => {
85 + const body = "```\r\nhttps://example.com/demo.mp4\r\n```";
86 + expect(splitPullRequestBody(body)).toEqual([
87 + { id: "markdown:0", kind: "markdown", text: body, sourceOffset: 0 },
88 + ]);
89 + });
90 +
91 + it("closes a CRLF fence, so a video after it still lifts out", () => {
92 + const code = '```html\r\n<video src="https://example.com/example.mp4"></video>\r\n```';
93 + expect(splitPullRequestBody(`${code}\r\n\r\nhttps://example.com/demo.mp4\r\n`)).toEqual([
94 + { id: "markdown:0", kind: "markdown", text: code, sourceOffset: 0 },
95 + {
96 + id: "attachment:1",
97 + kind: "attachment",
98 + url: "https://example.com/demo.mp4",
99 + media: "video",
100 + },
101 + ]);
102 + });
103 +
104 it("does not let a different fence marker close an open fence", () => {
105 const body = "```\n~~~\nhttps://example.com/demo.mp4\n```";
106 expect(splitPullRequestBody(body)).toEqual([
packages/client-runtime/src/pullRequestMarkdown.ts
+2 -1
@@ -16,7 +16,8 @@ export type PullRequestBodySegment =
16 readonly media: "video" | "image" | "unknown";
17 };
18
19 -const FENCE_PATTERN = /^\s{0,3}((?:`{3,})|(?:~{3,}))(.*)$/u;
19 +// `.` stops at the `\r` of a CRLF body, which is how GitHub stores one written in its web editor.
20 +const FENCE_PATTERN = /^\s{0,3}((?:`{3,})|(?:~{3,}))(.*)\r?$/u;
21 /**
22 * How far a `<video>` tag may reach for its closing tag. Real embeds are one to three lines,
23 * and the bound keeps an unclosed tag from making each one rescan the rest of the body.