@devries-cameron20 / t3code-1 / commits / b05c505b9c
Fork 0

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

fix(mobile): review comment cards keep a trailing blank line in their diff (#29629)

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

Alex Southwell committed Nov 15, 2026 at 02:15 UTC b05c505b9c72336e0f0e1b5b39b1d9811a925cc3
3 files changed +53 -24
apps/mobile/src/features/review/ReviewCommentCard.tsx
+4 -24
@@ -12,8 +12,10 @@ import { resolveNativeReviewDiffView } from "../diffs/nativeReviewDiffSurface";
12 import {
13 buildNativeReviewDiffData,
14 buildNativeReviewSnippetRows,
15 + buildReviewCommentPatch,
16 createNativeReviewDiffTheme,
17 NATIVE_REVIEW_DIFF_CONTENT_WIDTH,
18 + reviewCommentDiffText,
19 } from "./nativeReviewDiffAdapter";
20 import { buildReviewParsedDiff } from "./reviewModel";
21 import { REVIEW_MONO_FONT_FAMILY } from "./reviewDiffRendering";
@@ -86,7 +88,7 @@ export const ReviewCommentCard = memo(function ReviewCommentCard(props: {
88 theme: appearanceScheme,
89 });
90 const snippetTokens = useMarkdownCodeHighlight({
89 - code: props.comment.diff.trim(),
91 + code: reviewCommentDiffText(props.comment.diff),
92 language: props.comment.fenceLanguage ?? language,
93 enabled: compactNativeRows.length === 0,
94 theme: appearanceScheme,
@@ -234,32 +236,10 @@ export const ReviewCommentCard = memo(function ReviewCommentCard(props: {
236 </NativeText>
237 ) /* oxlint-enable react/no-array-index-key */,
238 )
237 - : props.comment.diff.trim()}
239 + : reviewCommentDiffText(props.comment.diff)}
240 </NativeText>
241 </ScrollView>
242 ) : null}
243 </View>
244 );
245 });
244 -
245 -function buildReviewCommentPatch(comment: ReviewInlineComment): string {
246 - if ((comment.fenceLanguage ?? "diff") !== "diff") {
247 - return "";
248 - }
249 - const diff = comment.diff.trim();
250 - if (!diff) {
251 - return "";
252 - }
253 -
254 - if (diff.startsWith("diff --git ")) {
255 - return diff;
256 - }
257 -
258 - const normalizedPath = comment.filePath.replaceAll("\\", "/");
259 - return [
260 - `diff --git a/${normalizedPath} b/${normalizedPath}`,
261 - `--- a/${normalizedPath}`,
262 - `+++ b/${normalizedPath}`,
263 - diff,
264 - ].join("\n");
265 -}
apps/mobile/src/features/review/nativeReviewDiffAdapter.test.ts
+23
@@ -8,7 +8,9 @@ import { combinePullRequestDiffPages } from "../pull-requests/pullRequestDiffPag
8 import { createPullRequestDiffHighlightFiles } from "../pull-requests/pullRequestDiffHighlightFiles";
9 import {
10 buildNativeReviewDiffData,
11 + buildReviewCommentPatch,
12 getCachedNativeReviewDiffData,
13 + reviewCommentDiffText,
14 } from "./nativeReviewDiffAdapter";
15 import type { ReviewInlineComment } from "./reviewCommentSelection";
16 import { buildReviewParsedDiff, type ReviewParsedDiff } from "./reviewModel";
@@ -46,6 +48,27 @@ function filesPatch(paths: ReadonlyArray<string>) {
48 .join("\n");
49 }
50
51 +describe("buildReviewCommentPatch", () => {
52 + it("keeps a selection's trailing blank line and whitespace", () => {
53 + const rows = (diff: string) =>
54 + buildNativeReviewDiffData(
55 + buildReviewParsedDiff(
56 + buildReviewCommentPatch({ ...makeComment("Insert here."), diff }),
57 + "review-comment-trailing-blank",
58 + ),
59 + ).rows.filter((row) => row.kind === "line");
60 +
61 + expect(rows("@@ -3,1 +2,2 @@\n+two\t\n ")).toMatchObject([
62 + { content: "two\t", change: "add" },
63 + { content: "", change: "context" },
64 + ]);
65 + expect(rows("@@ -4,1 +4,1 @@\n ")).toMatchObject([{ content: "", change: "context" }]);
66 + expect(reviewCommentDiffText("\n@@ -3,1 +2,2 @@\n+two\t\n \n")).toBe(
67 + "@@ -3,1 +2,2 @@\n+two\t\n ",
68 + );
69 + });
70 +});
71 +
72 describe("buildNativeReviewDiffData languages", () => {
73 it.each([
74 ["js", "javascript"],
apps/mobile/src/features/review/nativeReviewDiffAdapter.ts
+26
@@ -44,6 +44,32 @@ export function buildNativeReviewSnippetRows(
44 }));
45 }
46
47 +export function reviewCommentDiffText(diff: string): string {
48 + return diff.trimStart().replace(/\n+$/, "");
49 +}
50 +
51 +export function buildReviewCommentPatch(comment: ReviewInlineComment): string {
52 + if ((comment.fenceLanguage ?? "diff") !== "diff") {
53 + return "";
54 + }
55 + if (!comment.diff.trim()) {
56 + return "";
57 + }
58 + const diff = reviewCommentDiffText(comment.diff);
59 +
60 + if (diff.startsWith("diff --git ")) {
61 + return diff;
62 + }
63 +
64 + const normalizedPath = comment.filePath.replaceAll("\\", "/");
65 + return [
66 + `diff --git a/${normalizedPath} b/${normalizedPath}`,
67 + `--- a/${normalizedPath}`,
68 + `+++ b/${normalizedPath}`,
69 + diff,
70 + ].join("\n");
71 +}
72 +
73 function opaqueNativeHexColor(color: string, background: string): string {
74 const hex = NATIVE_HEX_COLOR.exec(color);
75 if (hex && !hex[4]) return color;