diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts index d23c4fdfae43..64ee0b6bd851 100644 --- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts +++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts @@ -692,6 +692,12 @@ describe("fix findings handoff", () => { }); expect(handoff.reviewComments[1]?.text).toHaveLength(1_000); expect(handoff.reviewComments[1]?.text.endsWith("...")).toBe(true); + const emojiAtCut = buildFixFindingsHandoff({ + ...base, + reviewThreads: [thread(`${"x".repeat(986)}😀 and more of the review.${"y".repeat(100)}`)], + checks: [], + }); + expect(emojiAtCut.reviewComments[1]?.text).toBe(`reviewer: ${"x".repeat(986)}...`); }); it("keeps the newest threads and the failing checks when it has to cut", () => { diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts index bcc46b63a047..537de10a2a8c 100644 --- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts +++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts @@ -799,9 +799,14 @@ const FINDING_BODY_MAX_LENGTH = 1_000; function bounded(value: string): string { const trimmed = value.trim(); - return trimmed.length <= FINDING_BODY_MAX_LENGTH - ? trimmed - : `${trimmed.slice(0, FINDING_BODY_MAX_LENGTH - 3)}...`; + if (trimmed.length <= FINDING_BODY_MAX_LENGTH) return trimmed; + let end = FINDING_BODY_MAX_LENGTH - 3; + const previous = trimmed.charCodeAt(end - 1); + const next = trimmed.charCodeAt(end); + if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) { + end -= 1; + } + return `${trimmed.slice(0, end)}...`; } function boundedField(value: string): string {