Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/components/pullRequest/pullRequestDetail.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading