@@ -52,6 +52,16 @@ async function postComment(body: string): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
// A review must read at a glance: when the agent left more than VISIBLE_BYTES
|
||||
// outside <details> blocks, the whole review folds under its verdict line.
|
||||
const VISIBLE_BYTES = 512;
|
||||
function fold(body: string): string {
|
||||
const visible = body.replace(/<details>[\s\S]*?<\/details>/g, "");
|
||||
if (new TextEncoder().encode(visible).length <= VISIBLE_BYTES) return body;
|
||||
const verdict = body.match(/\*\*Ready to merge\?\*\*.*/)?.[0] ?? "Review";
|
||||
return `${verdict}\n\n<details>\n<summary>Details</summary>\n\n${body}\n\n</details>`;
|
||||
}
|
||||
|
||||
// A pull request event is a review request, so the response becomes a review:
|
||||
// changes are requested when the agent asked @bot to fix something, a failed
|
||||
// run only comments, and anything else approves.
|
||||
@@ -63,7 +73,7 @@ async function postResult(body: string): Promise<void> {
|
||||
? "COMMENT"
|
||||
: "APPROVED";
|
||||
await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, {
|
||||
body: stripAnsi(body),
|
||||
body: fold(stripAnsi(body)),
|
||||
event,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user