Fold review details
Check / deno (pull_request) Successful in 37s

This commit is contained in:
2026-09-13 23:45:41 +09:00
parent b8d0093ef2
commit ca6c2f1378
2 changed files with 18 additions and 1 deletions
+11 -1
View File
@@ -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,
});
}