Skip to content

Commit d32ccf6

Browse files
MarcoDotIOclaude
andcommitted
fix(mobile): single-comment PR discussions say "1 comment", not "1 comments"
The inline discussion card in the pull request diff and the discussion row in the PR timeline always used the plural. Both now share one label that picks the singular for a count of one, matching the web client. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 680152e commit d32ccf6

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
@@ -13,6 +13,7 @@ import { relativeTime } from "../../lib/time";
1313
import { PullRequestAvatar } from "./PullRequestPresentation";
1414
import { PullRequestMarkdown } from "./PullRequestMarkdown";
1515
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
16+
import { discussionCommentCountLabel } from "./pullRequestDiffComments";
1617
import type { PullRequestParams } from "./usePullRequestDiff";
1718

1819
function TimelineEvent(props: {
@@ -227,7 +228,7 @@ export function pullRequestTimelineRows(
227228
<Text className="text-xs text-foreground-muted">
228229
{thread.isResolved ? "Resolved" : "Unresolved"}
229230
{thread.isOutdated ? " · Outdated" : ""} ·{" "}
230-
{thread.commentCount ?? thread.comments.length} comments
231+
{discussionCommentCountLabel(thread.commentCount ?? thread.comments.length)}
231232
</Text>
232233
</Pressable>
233234
</TimelineEvent>

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ describe("PR comments in continuous native diffs", () => {
8585
]);
8686
expect(annotated.commentTargetsByRowId).toBe(data.commentTargetsByRowId);
8787
});
88+
it("counts a single-comment discussion in the singular", () => {
89+
const annotated = annotatePullRequestDiff(
90+
data,
91+
[
92+
{ ...thread, commentCount: 1 },
93+
{ ...thread, id: "right", side: "right", commentCount: 2 },
94+
],
95+
[],
96+
"abc",
97+
);
98+
expect(
99+
annotated.rows
100+
.filter((row) => row.kind === "comment")
101+
.map((row) => row.commentText?.split("\n").at(-1)),
102+
).toEqual(["1 comment · Tap to open", "2 comments · Tap to open"]);
103+
});
88104
it("uses the old line number for left-side context when the line numbers differ", () => {
89105
const position = { kind: "context" as const, side: "left" as const, oldLine: 7, newLine: 8 };
90106
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");
@@ -78,7 +81,7 @@ export function annotatePullRequestDiff(
7881
attach(
7982
anchor,
8083
`discussion:${thread.id}`,
81-
`${first?.author?.login ?? "Discussion"}${thread.isResolved ? " · Resolved" : ""}\n${first?.body ?? ""}\n${thread.commentCount ?? thread.comments.length} comments · Tap to open`,
84+
`${first?.author?.login ?? "Discussion"}${thread.isResolved ? " · Resolved" : ""}\n${first?.body ?? ""}\n${discussionCommentCountLabel(thread.commentCount ?? thread.comments.length)} · Tap to open`,
8285
thread.line === null ? "file" : String(thread.line),
8386
);
8487
}

0 commit comments

Comments
 (0)