Skip to content

Commit 5e19105

Browse files
MarcoDotIOclaude
andauthored
fix(mobile): single-comment PR discussions say "1 comment", not "1 comments" (#22926)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent ba49642 commit 5e19105

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { PullRequestAvatar } from "./PullRequestPresentation";
1414
import { PullRequestMarkdown } from "./PullRequestMarkdown";
1515
import { PullRequestCommentFooter } from "./PullRequestReactions";
1616
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
17+
import { discussionCommentCountLabel } from "./pullRequestDiffComments";
1718
import { normalizedReviewState } from "./pullRequestStatus";
1819
import type { PullRequestParams } from "./usePullRequestDiff";
1920

@@ -250,7 +251,7 @@ export function pullRequestTimelineRows(
250251
<Text className="text-xs text-foreground-muted">
251252
{thread.isResolved ? "Resolved" : "Unresolved"}
252253
{thread.isOutdated ? " · Outdated" : ""} ·{" "}
253-
{thread.commentCount ?? thread.comments.length} comments
254+
{discussionCommentCountLabel(thread.commentCount ?? thread.comments.length)}
254255
</Text>
255256
</Pressable>
256257
</TimelineEvent>

‎apps/mobile/src/features/pull-requests/pullRequestDiffComments.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ describe("PR comments in continuous native diffs", () => {
9696
]);
9797
expect(annotated.commentTargetsByRowId).toBe(data.commentTargetsByRowId);
9898
});
99+
it("counts a single-comment discussion in the singular", () => {
100+
const annotated = annotatePullRequestDiff(
101+
data,
102+
[
103+
{ ...thread, commentCount: 1 },
104+
{ ...thread, id: "right", side: "right", commentCount: 2 },
105+
],
106+
[],
107+
"abc",
108+
);
109+
expect(
110+
annotated.rows
111+
.filter((row) => row.kind === "comment")
112+
.map((row) => row.commentText?.split("\n").at(-1)),
113+
).toEqual(["1 comment · Tap to open", "2 comments · Tap to open"]);
114+
});
99115
it("uses the old line number for left-side context when the line numbers differ", () => {
100116
const position = { kind: "context" as const, side: "left" as const, oldLine: 7, newLine: 8 };
101117
const annotated = annotatePullRequestDiff(

‎apps/mobile/src/features/pull-requests/pullRequestDiffComments.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export function reviewPosition(row: NativeReviewDiffRow): PullRequestReviewPosit
1818
};
1919
return null;
2020
}
21+
export function discussionCommentCountLabel(count: number) {
22+
return `${count} ${count === 1 ? "comment" : "comments"}`;
23+
}
2124
export function reviewPositionLabel(position: PullRequestReviewPosition) {
2225
const oldSide =
2326
position.kind === "deleted" || (position.kind === "context" && position.side === "left");
@@ -79,7 +82,7 @@ export function annotatePullRequestDiff(
7982
attach(
8083
anchor,
8184
`discussion:${thread.id}`,
82-
`${first?.author?.login ?? "Discussion"}${thread.isResolved ? " · Resolved" : ""}\n${first?.body ?? ""}\n${thread.commentCount ?? thread.comments.length} comments · Tap to open`,
85+
`${first?.author?.login ?? "Discussion"}${thread.isResolved ? " · Resolved" : ""}\n${first?.body ?? ""}\n${discussionCommentCountLabel(thread.commentCount ?? thread.comments.length)} · Tap to open`,
8386
thread.line === null ? "file" : String(thread.line),
8487
);
8588
}

0 commit comments

Comments
 (0)