@devries-cameron20 / t3code-1 / commits / 523145993e
Fork 0

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

fix(web): review comments keep a trailing blank line in their diff (#29575)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 01:38 UTC 523145993e28cd9bf46ea0b7292f5e4c0968751a
4 files changed +59 -3
apps/web/src/reviewCommentContext.test.ts
+33
@@ -5,6 +5,7 @@ import { describe, expect, it } from "vite-plus/test";
5 import {
6 buildDiffReviewComment,
7 buildFileReviewComment,
8 + buildReviewCommentRenderablePatch,
9 formatReviewCommentFence,
10 resolveDiffReviewAnchor,
11 resolveDiffReviewPosition,
@@ -75,6 +76,38 @@ describe("review comment context parsing", () => {
76 );
77 });
78
79 + it("keeps a selection's trailing blank line and whitespace in the rendered excerpt", () => {
80 + const fileDiff = parsePatchFiles(
81 + [
82 + "diff --git a/src/app.ts b/src/app.ts",
83 + "--- a/src/app.ts",
84 + "+++ b/src/app.ts",
85 + "@@ -1,4 +1,4 @@",
86 + " one",
87 + "-two",
88 + "+two\t",
89 + " ",
90 + " four",
91 + ].join("\n"),
92 + "review-comment-trailing-blank",
93 + )[0]!.files[0]!;
94 + const comment = (end: number) =>
95 + buildDiffReviewComment({
96 + id: "comment-blank",
97 + sectionId: "turn:1",
98 + sectionTitle: "Turn 1",
99 + filePath: "src/app.ts",
100 + fileDiff,
101 + range: { start: 2, side: "additions", end, endSide: "additions" },
102 + text: "Insert here.",
103 + })!;
104 +
105 + expect(buildReviewCommentRenderablePatch(comment(2))).toMatch(/\n\+two\t$/);
106 + expect(buildReviewCommentRenderablePatch(comment(3))).toMatch(
107 + /\n@@ -3,1 \+2,2 @@\n\+two\t\n $/,
108 + );
109 + });
110 +
111 it("restores Pierre line selections from persisted diff comment row indexes", () => {
112 const fileDiff = parsePatchFiles(
113 [
apps/web/src/reviewCommentContext.ts
+2 -2
@@ -512,10 +512,10 @@ export function buildReviewCommentRenderablePatch(comment: ReviewCommentContext)
512 if ((comment.fenceLanguage ?? "diff") !== "diff") {
513 return "";
514 }
515 - const diff = comment.diff.trim();
516 - if (diff.length === 0) {
515 + if (comment.diff.trim().length === 0) {
516 return "";
517 }
518 + const diff = comment.diff.trimStart().replace(/\n+$/, "");
519 if (diff.startsWith("diff --git ")) {
520 return diff;
521 }
packages/shared/src/composerContextReferences.test.ts
+23
@@ -225,6 +225,29 @@ describe("provider projection", () => {
225 expect(project("a\n")).toContain("3 | a\n4 | \n</context>");
226 });
227
228 + it("keeps a review excerpt's trailing blank line and whitespace", () => {
229 + const projected = projectComposerContextForProvider({
230 + text: "[Comment](t3-context://v1/review-comment/ctx_r)",
231 + records: [
232 + {
233 + version: 1,
234 + contextId: ctx("ctx_r"),
235 + kind: "review-comment",
236 + label: "Comment",
237 + sectionId: "turn:1",
238 + sectionTitle: "Turn 1",
239 + filePath: "src/app.ts",
240 + startIndex: 1,
241 + endIndex: 2,
242 + rangeLabel: "2 to 3",
243 + text: "Insert here.",
244 + diff: "@@ -3,1 +2,2 @@\n+two\t\n \n",
245 + },
246 + ],
247 + });
248 + expect(projected).toContain("diff:\n @@ -3,1 +2,2 @@\n +two\t\n \n</context>");
249 + });
250 +
251 it("emits no terminal lines when the captured range is inverted", () => {
252 const projected = projectComposerContextForProvider({
253 text: "[log](t3-context://v1/terminal/ctx_t)",
packages/shared/src/composerContextReferences.ts
+1 -1
@@ -293,7 +293,7 @@ function formatComposerContextProviderPayload(record: KnownComposerContextRecord
293 ];
294 if (record.text.trim()) lines.push("comment:", indent(record.text.trim()));
295 if (record.diff.trim()) {
296 - lines.push(`${record.fenceLanguage ?? "diff"}:`, indent(record.diff.trimEnd()));
296 + lines.push(`${record.fenceLanguage ?? "diff"}:`, indent(record.diff.replace(/\n+$/, "")));
297 }
298 return lines.join("\n");
299 }