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
17 changes: 17 additions & 0 deletions apps/server/src/orchestration-v2/pullRequestWatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { assert, describe, it } from "@effect/vitest";
import {
PULL_REQUEST_WATCH_WAKE_LIMIT,
evaluatePullRequestWatch as evaluate,
pullRequestWatchMessage,
} from "./pullRequestWatch.ts";

// These cases read the head once or at one moment, so the no-checks notice never comes due.
Expand Down Expand Up @@ -335,6 +336,22 @@ describe("evaluatePullRequestWatch", () => {
assert.deepEqual(evaluatePullRequestWatch(report.next, detail(), comments).changes, []);
});

it("cuts a long remark in the wake message without splitting an emoji", () => {
const body = `${"x".repeat(196)}🚀 and more`;
const report = evaluatePullRequestWatch(watch(), detail(), [
remark("reviewer", "2026-10-02T12:06:00Z", body),
]);
const { text } = pullRequestWatchMessage({
number: 1,
url: "https://github.com/o/r/pull/1",
baseBranch: "main",
headSha: null,
report,
});
assert.isTrue(text.isWellFormed());
assert.include(text, `"${"x".repeat(196)}..."`);
});

it("reports a conflict once, until the branch is clean again", () => {
const conflicting = detail({ mergeability: "conflicting" });
const first = evaluatePullRequestWatch(watch(), conflicting, noRemarks);
Expand Down
6 changes: 5 additions & 1 deletion apps/server/src/orchestration-v2/pullRequestWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ function snippet(body: string): string {
.replaceAll(/<!--[\s\S]*?-->/g, " ")
.replaceAll(/\s+/g, " ")
.trim();
return text.length <= SNIPPET_LENGTH ? text : `${text.slice(0, SNIPPET_LENGTH - 3)}...`;
if (text.length <= SNIPPET_LENGTH) return text;
// Half an emoji serializes to a lone surrogate escape, which provider JSON parsers reject.
const last = text.charCodeAt(SNIPPET_LENGTH - 4);
const end = last >= 0xd800 && last <= 0xdbff ? SNIPPET_LENGTH - 4 : SNIPPET_LENGTH - 3;
return `${text.slice(0, end)}...`;
}

function listed<T>(items: ReadonlyArray<T>, line: (item: T) => string): Array<string> {
Expand Down
Loading