@devries-cameron20 / t3code Mirror · read-only / commits / 3808e2d77e
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 21, 13:30 UTC

fix(client-runtime): a line of inline triple-backtick code no longer breaks media in PR descriptions (#30571)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

MarcoDotIO committed Nov 14, 2026 at 18:32 UTC 3808e2d77e103f1dc510ac510157f2228d14febb
2 files changed +29 -1
packages/client-runtime/src/pullRequestMarkdown.test.ts
+22
@@ -136,6 +136,28 @@ describe("pull request body segmentation", () => {
136 ]);
137 });
138
139 + it("does not open a fence on a line of inline triple-backtick code", () => {
140 + const code = "```\nhttps://example.com/b.png\n```";
141 + expect(
142 + splitPullRequestBody(
143 + `\`\`\`npm test\`\`\` passes.\n\nhttps://example.com/demo.mp4\n\n${code}`,
144 + ),
145 + ).toEqual([
146 + { id: "markdown:0", kind: "markdown", text: "```npm test``` passes.", sourceOffset: 0 },
147 + {
148 + id: "attachment:1",
149 + kind: "attachment",
150 + url: "https://example.com/demo.mp4",
151 + media: "video",
152 + },
153 + { id: "markdown:2", kind: "markdown", text: code, sourceOffset: 54 },
154 + ]);
155 + const multilineSpan = "```foo`\nhttps://example.com/demo.mp4\nbar```";
156 + expect(splitPullRequestBody(multilineSpan)).toEqual([
157 + { id: "markdown:0", kind: "markdown", text: multilineSpan, sourceOffset: 0 },
158 + ]);
159 + });
160 +
161 it("leaves an indented code line alone even when it is only a video link", () => {
162 const body = " https://example.com/demo.mp4";
163 expect(splitPullRequestBody(body)).toEqual([
packages/client-runtime/src/pullRequestMarkdown.ts
+7 -1
@@ -261,7 +261,13 @@ function splitBodyAt(body: string, baseOffset: number): ReadonlyArray<PullReques
261 const line = lines[index]!;
262 if (markdown.length === 0) markdownStart = lineStart;
263 const fenceMatch = FENCE_PATTERN.exec(line);
264 - if (fenceMatch !== null) {
264 + // ```` ```npm test``` ```` is a code span, not an opener that would flip every later fence.
265 + // A span that runs past this line is left an opener, so its lines stay out of media.
266 + const isInlineCode =
267 + openFence === null &&
268 + fenceMatch?.[1]![0] === "`" &&
269 + (fenceMatch[2]!.match(/`+/gu) ?? []).some((run) => run.length === fenceMatch[1]!.length);
270 + if (fenceMatch !== null && !isInlineCode) {
271 const fence = fenceMatch[1]!;
272 // A fence closes only on the same marker, at least as long as the one that opened it,
273 // and with nothing after it: `~~~` cannot end a ``` block, and ```` ```ts ```` is an