diff --git a/apps/server/src/orchestration-v2/pullRequestWatch.test.ts b/apps/server/src/orchestration-v2/pullRequestWatch.test.ts index 6ab0191649490..64f3ab9c3fdd1 100644 --- a/apps/server/src/orchestration-v2/pullRequestWatch.test.ts +++ b/apps/server/src/orchestration-v2/pullRequestWatch.test.ts @@ -352,6 +352,47 @@ describe("evaluatePullRequestWatch", () => { assert.include(text, `"${"x".repeat(196)}..."`); }); + it("quotes a remark's text instead of its leading HTML, and keeps tags in prose and code", () => { + const badge = + 'Severity > `Minor`'; + const report = evaluatePullRequestWatch(watch(), detail(), [ + remark( + "coderabbitai", + "2026-10-02T12:06:00Z", + `${badge}\n\n_⚠️ Potential issue_ | _🟠 Major_\n\n**Guard the empty list.**`, + ), + remark( + "reviewer", + "2026-10-02T12:07:00Z", + "Return Promise, not Promise or Promise.", + ), + remark( + "designer", + "2026-10-02T12:08:00Z", + "Replace `
` with ````:\n~~~html\n

Done

\n~~~", + ), + remark("maintainer", "2026-10-02T12:09:00Z", "

Guard this

, and `\nCheck the retry.\n ", open + 4); + if (close === -1) { + // Like GitHub: an unclosed opener starting a line hides the rest, but one inside a paragraph is text. + const lineStart = body.lastIndexOf("\n", open - 1) + 1; + const hidesRest = /^ {0,3}$/.test(body.slice(lineStart, open)); + return text + body.slice(from, hidesRest ? open : undefined); + } + text += `${body.slice(from, open)} `; + from = close + 3; + } + return text + body.slice(from); +} + function snippet(body: string): string { - const text = body - .replaceAll(//g, " ") + const text = withoutHtmlComments(body) + .slice(0, SNIPPET_SCAN_LENGTH) + .toWellFormed() + .replaceAll(MARKUP, (match, code: string | undefined) => (code === undefined ? " " : match)) .replaceAll(/\s+/g, " ") .trim(); if (text.length <= SNIPPET_LENGTH) return text;