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
+7
View File
@@ -25,6 +25,13 @@ fixes exactly when it is not `Yes`, and Minor issues alone never block. For UI
changes, check that the result is aligned, clean, and pixel-perfect, and that changes, check that the result is aligned, clean, and pixel-perfect, and that
included screenshots prove the intended result was achieved. included screenshots prove the intended result was achieved.
The review must read at a glance: everything outside `<details>` blocks totals
under 512 bytes. Keep only the assessment line, the section headings, and a
one-line `@bot` instruction visible. Put each strength, each issue, and each
recommendation in its own top-level `<details>` block, never inside a list item,
with a `<summary>` of the `file:line` and a few words and the what, why, and how
inside. The template's `**Reasoning:**` goes in a `<details>` block too.
For an `issue_comment` or `pull_request_review_comment` event, treat the `body` For an `issue_comment` or `pull_request_review_comment` event, treat the `body`
in the triggering comment payload below as the user's exact instruction. in the triggering comment payload below as the user's exact instruction.
+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: // 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 // changes are requested when the agent asked @bot to fix something, a failed
// run only comments, and anything else approves. // run only comments, and anything else approves.
@@ -63,7 +73,7 @@ async function postResult(body: string): Promise<void> {
? "COMMENT" ? "COMMENT"
: "APPROVED"; : "APPROVED";
await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, { await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, {
body: stripAnsi(body), body: fold(stripAnsi(body)),
event, event,
}); });
} }