Skip to content

Commit 9654314

Browse files
authored
Merge pull request #6254 from github/aaronpowell-approved-review-comments
Require suggested comments for every Open PR Board review
2 parents bed84ed + 5ce16ff commit 9654314

9 files changed

Lines changed: 261 additions & 28 deletions

File tree

‎.github/extensions/open-pr-board/README.md‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,26 @@ Results arriving after a manual move, reset, or replacement review are rejected.
142142
addressing the PR author, with concrete evidence and actionable changes or a clear
143143
decision. Maintainer-only advice stays in internal fields such as `rationale`,
144144
`risks`, and `checkNext`; board terminology and claims of completed GitHub actions
145-
do not belong in the comment. Uncertainty must remain explicit. If there is no
146-
useful author-facing feedback, the field is omitted or empty. Existing stored
147-
comments are not rewritten; re-review a PR to generate a new suggestion.
145+
do not belong in the comment. Uncertainty must remain explicit. Every AI review
146+
must include a non-empty `suggestedComment` in every bucket; `record_review` skips
147+
results without one. When there is no corrective feedback, the comment is a brief,
148+
courteous message limited to what the evidence supports. Existing stored reviews
149+
are not rewritten; re-review a PR to generate a new suggestion.
150+
151+
For an empty draft in the **Approve** bucket (for example a legacy review, a
152+
manually moved card, or a cleared draft),
153+
**Add suggested comment** offers an optional, explicitly labelled generic thank-you
154+
template. It does not claim individualized feedback, completed validation, approval,
155+
or merging. Nothing is inserted automatically, and existing non-empty suggestions
156+
or edited drafts are never replaced. Queued, actioned, and busy items cannot use
157+
the helper.
158+
159+
Adding the template only stages text in the existing editable Draft comment box;
160+
it makes no GitHub request and does not change the stored AI review. Edit it or
161+
clear it to approve without a comment. Clearing does not reinsert the template.
162+
Drafts, including explicit empty drafts, survive card switches and board refreshes
163+
in the current browser session, not page reloads. Individual and column actions
164+
continue to use the staged draft and require their existing explicit confirmation.
148165

149166
## Regression tests
150167

‎.github/extensions/open-pr-board/lib/review-prompt.mjs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ export const RECOMMENDATION_GUIDE = [
66
].join("\n");
77

88
const PUBLIC_COMMENT_GUIDE = [
9-
"`suggestedComment` is public text ready to post verbatim as the maintainer addressing the PR author directly, in a natural maintainer voice, not an agent report to the maintainer.",
9+
"`suggestedComment` is required for every recommendation and must contain non-whitespace public text ready to post verbatim as the maintainer addressing the PR author directly, in a natural maintainer voice, not an agent report to the maintainer.",
1010
"State concrete evidence (files, lines, or links where available) and actionable changes the author can make, or a clear evidence-backed decision about the contribution.",
1111
"Keep maintainer-only advice, verification tasks, and uncertainty about how to act in internal fields such as `rationale`, `risks`, and `checkNext`, not in the public comment.",
1212
"Do not tell the maintainer what to do: avoid phrases such as 'I recommend closing this submission', 'Have a maintainer confirm...', or 'Confirm the required approval'. Do not mention board buckets, queue tokens, internal calibration, or internal recommendation labels.",
1313
"Preserve uncertainty: distinguish observed facts from unresolved questions, ask the author only for information they can reasonably provide, and do not turn a tentative internal recommendation into a settled public decision.",
1414
"Do not invent claims of completed remote actions (for example, 'I closed this PR', 'approved', or 'enabled auto-merge'); recording a review performs none of them.",
15-
"If there is no useful author-facing feedback, omit `suggestedComment` or use an empty string; do not manufacture a comment merely to fill the field.",
15+
"When there is no corrective feedback, write a brief courteous author-facing comment that thanks the author and states only what the evidence supports. For an `approve` recommendation, encourage the contributor without claiming the PR has been approved or merged. Do not invent individualized praise, validation, or feedback.",
1616
].join("\n");
1717

1818
/** Shared schema for a single recorded review. Reused directly as the `record_review` input schema. */
1919
export const REVIEW_FIELDS_SCHEMA = {
2020
type: "object",
21-
required: ["number", "queueId", "recommendation", "rationale"],
21+
required: ["number", "queueId", "recommendation", "rationale", "suggestedComment"],
2222
properties: {
2323
number: { type: "integer", description: "Pull request number." },
2424
queueId: {
@@ -47,7 +47,7 @@ export const REVIEW_FIELDS_SCHEMA = {
4747
validation: { type: "string", description: "Evidence the contributor tested or validated the change." },
4848
confidence: { type: "string", enum: ["low", "medium", "high"], description: "Confidence in the recommendation." },
4949
checkNext: { type: "string", description: "Internal: what a maintainer should verify by hand before acting; not instructions for the PR author." },
50-
suggestedComment: { type: "string", description: PUBLIC_COMMENT_GUIDE },
50+
suggestedComment: { type: "string", minLength: 1, pattern: "\\S", description: PUBLIC_COMMENT_GUIDE },
5151
},
5252
additionalProperties: false,
5353
};
@@ -124,7 +124,7 @@ function knowledgeUpliftRules() {
124124
function recordingRules(instanceId) {
125125
return [
126126
`Record every result by calling \`invoke_canvas_action\` with instanceId \`${instanceId}\`, actionName \`record_review\`, and input \`{ "reviews": [ ... ] }\`.`,
127-
"Each review object needs `number`, `queueId`, `recommendation`, and `rationale`; fill in `summary`, `repoFit`, `compliance`, `differentiation`, `risks`, `validation`, `confidence`, `checkNext`, and `suggestedComment` whenever you have something real to say.",
127+
"Each review object needs `number`, `queueId`, `recommendation`, `rationale`, and a non-empty `suggestedComment`; fill in `summary`, `repoFit`, `compliance`, `differentiation`, `risks`, `validation`, `confidence`, and `checkNext` whenever you have something real to say.",
128128
PUBLIC_COMMENT_GUIDE,
129129
"You may record in batches as you go. If the canvas is closed, re-open it first with `open_canvas` using canvasId `open-pr-board` and that same instanceId.",
130130
"Check `gh pr view <number> --json state` before recording: closed or merged PRs are dropped from the board and `record_review` skips them as \"not on the board\". A \"stale review result\" skip means the queueId was already consumed; call `get_pr` to see what is stored rather than re-recording.",

‎.github/extensions/open-pr-board/lib/state.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ export class BoardStore {
239239
if (!RECOMMENDATIONS.includes(payload.recommendation)) {
240240
return { number: payload.number, status: "skipped", reason: `unknown recommendation "${payload.recommendation}"` };
241241
}
242+
if (typeof payload.suggestedComment !== "string" || !payload.suggestedComment.trim()) {
243+
return { number: payload.number, status: "skipped", reason: "missing suggestedComment" };
244+
}
242245
const { number, queueId, recommendation, ...fields } = payload;
243246
item.review = {
244247
recommendation,

‎.github/extensions/open-pr-board/public/app.js‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const TOKEN = document.querySelector('meta[name="board-token"]')?.content ?? "";
22
const CONFIRM_MS = 6000;
3+
const APPROVAL_COMMENT_TEMPLATE = "Thanks for contributing to Awesome Copilot! We appreciate the time and effort you've put into this contribution.";
34

45
const COLUMN_HINTS = {
56
unreviewed: "Not reviewed yet",
@@ -71,6 +72,8 @@ const el = {
7172
rereviewStart: document.getElementById("rereview-start"),
7273
rereviewCancel: document.getElementById("rereview-cancel"),
7374
comment: document.getElementById("decision-comment"),
75+
commentSuggestion: document.getElementById("approval-comment-suggestion"),
76+
addSuggestedComment: document.getElementById("add-suggested-comment"),
7477
toasts: document.getElementById("toasts"),
7578
};
7679

@@ -363,6 +366,18 @@ function stagedComment(item) {
363366
return stagedComments.get(item.number) ?? item.review?.suggestedComment ?? "";
364367
}
365368

369+
function canSuggestApprovalComment(item) {
370+
return item?.column === "approve" && !item.decision && item.reviewStatus !== "queued" &&
371+
!bulkBusy && !decisionsInFlight.has(item.number) && !el.comment.value.trim() && !stagedComment(item).trim();
372+
}
373+
374+
function stageDraftComment() {
375+
if (selectedNumber !== null) stagedComments.set(selectedNumber, el.comment.value);
376+
clearTimeout(pendingConfirm?.timer);
377+
pendingConfirm = null;
378+
if (currentItem()) renderDrawerHeader();
379+
}
380+
366381
function renderColumnActions(column) {
367382
const count = columnItems(column.id).length;
368383
const rejectKind = column.id === "close" ? "close" : "request-changes";
@@ -395,6 +410,7 @@ async function bulkAction(columnId, kind) {
395410
"Submits approvals and enables auto-merge with a merge commit." : "Uses each PR's staged comment on GitHub."}\n\n${preview}`)) return;
396411
bulkBusy = true;
397412
renderBoard();
413+
if (currentItem()) renderDrawerHeader();
398414
let completed = 0;
399415
const failures = [];
400416
let handoff = false;
@@ -664,6 +680,9 @@ function renderDrawerHeader() {
664680
el.drawerColumn.value = item.column;
665681
el.drawerColumn.disabled = Boolean(item.decision);
666682
el.rereviewToggle.disabled = Boolean(item.decision) || item.reviewStatus === "queued";
683+
const canSuggest = canSuggestApprovalComment(item);
684+
el.commentSuggestion.hidden = !canSuggest;
685+
el.addSuggestedComment.disabled = !canSuggest;
667686

668687
for (const button of el.drawer.querySelectorAll("[data-decision]")) {
669688
button.disabled = bulkBusy || Boolean(item.decision) || decisionsInFlight.has(item.number);
@@ -960,11 +979,13 @@ for (const button of el.drawer.querySelectorAll("[data-decision]")) {
960979
button.addEventListener("click", () => submitDecision(button, button.dataset.decision));
961980
}
962981

963-
el.comment.addEventListener("input", () => {
964-
if (selectedNumber !== null) stagedComments.set(selectedNumber, el.comment.value);
965-
clearTimeout(pendingConfirm?.timer);
966-
pendingConfirm = null;
967-
if (currentItem()) renderDrawerHeader();
982+
el.comment.addEventListener("input", stageDraftComment);
983+
984+
el.addSuggestedComment.addEventListener("click", () => {
985+
if (!canSuggestApprovalComment(currentItem())) return;
986+
el.comment.value = APPROVAL_COMMENT_TEMPLATE;
987+
stageDraftComment();
988+
el.comment.focus();
968989
});
969990

970991
function applySnapshot(snapshot) {

‎.github/extensions/open-pr-board/public/index.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ <h2 id="drawer-title"></h2>
6969
<footer class="drawer-footer">
7070
<label class="footer-label" for="decision-comment">Draft comment</label>
7171
<textarea id="decision-comment" rows="4" placeholder="Prefilled from the AI's suggested comment."></textarea>
72+
<p class="footer-note" id="approval-comment-suggestion" hidden>
73+
<button class="btn btn-small" id="add-suggested-comment" type="button" aria-describedby="approval-comment-template-note">Add suggested comment</button>
74+
<span id="approval-comment-template-note">Generic thank-you template. Edit or clear the draft before confirming an action.</span>
75+
</p>
7276
<p class="footer-note">
7377
These actions use your authenticated GitHub CLI account. Each requires a second
7478
click to confirm. Approval also enables auto-merge using a merge commit.

‎.github/extensions/open-pr-board/review-guidance.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ For every pull request:
103103
- `rationale`, `risks`, and `checkNext` are internal review fields. Keep advice about
104104
what the maintainer should do or verify there; `checkNext` is the next verification
105105
before acting.
106-
- `suggestedComment` is public text prefilled into the board's comment box and may be
106+
- `suggestedComment` is required for every recommendation and must not be empty.
107+
It is public text prefilled into the board's comment box and may be
107108
posted verbatim. Write as the maintainer addressing the PR author directly, in a
108109
natural maintainer voice, not as an agent reporting to the maintainer. State concrete
109110
evidence (files, lines, or links where available) and actionable changes the author
@@ -115,8 +116,10 @@ For every pull request:
115116
- Preserve uncertainty: separate observed facts from unresolved questions. Ask the
116117
author only for information they can reasonably provide. A tentative recommendation
117118
is not a settled public decision; a maintainer-only judgement belongs in `checkNext`.
118-
If there is no useful author-facing feedback, omit `suggestedComment` or use an
119-
empty string rather than manufacturing a comment.
119+
When there is no corrective feedback, write a brief courteous comment that thanks
120+
the author and states only what the evidence supports. For `approve`, encourage the
121+
contributor without claiming the PR has been approved or merged. Do not invent
122+
individualized praise, validation, or feedback.
120123
- Do not claim completed remote actions such as closing, approving, or enabling
121124
auto-merge. Recording a review performs none of those actions.
122125
- `confidence` is `low`, `medium`, or `high`. Use `low` freely; it is a signal, not a
@@ -130,7 +133,7 @@ For example (only when supported by the actual evidence):
130133
| --------------- | ----------------------------- |
131134
| `rationale`: Recommend closing because this is an off-topic marketing workflow. | We cannot accept this contribution because its ad-campaign workflow is outside this repository's focus on GitHub Copilot development workflows. |
132135
| `checkNext`: Confirm whether the author tested in Copilot. | The validation notes describe only a Claude Code run. Please test this skill in GitHub Copilot and include the steps and observed result. |
133-
| `checkNext`: Have a maintainer resolve the policy question before deciding. | Omit the field or use `""` if there is no useful question or change for the author. |
136+
| `checkNext`: Have a maintainer resolve the policy question before deciding. | Thanks for the contribution. We need to consider how this fits the repository's current direction before deciding on next steps. |
134137

135138
## Recording mechanics
136139

‎eng/board-bulk-actions.test.mjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ for (const boardName of ["open-pr-board", "external-plugin-review-board"]) {
5555
});
5656
const payload = (args) => isPR ? args[1].body : args[2];
5757

58+
if (isPR) test("open-pr-board: bulk approval preserves opt-in staged feedback and explicitly cleared drafts", async () => {
59+
const ui = await createUI(boardName, [item(1), item(2)]);
60+
vm.runInContext(`
61+
stagedComments.set(1, APPROVAL_COMMENT_TEMPLATE);
62+
stagedComments.set(2, "");
63+
`, ui.context);
64+
await ui.context.bulkAction("test", "approve");
65+
assert.deepEqual(ui.calls.map(args => payload(args).comment), [
66+
"Thanks for contributing to Awesome Copilot! We appreciate the time and effort you've put into this contribution.",
67+
"",
68+
]);
69+
assert.match(ui.confirmations[0], /Thanks for contributing to Awesome Copilot!/);
70+
assert.match(ui.confirmations[0], /#2: \(no comment\)/);
71+
});
72+
5873
test(`${boardName}: bulk rejection uses each staged comment, including hidden search results`, async () => {
5974
const ui = await createUI(boardName, [item(1), item(2)]);
6075
vm.runInContext('stagedComments.set(1, "Edited feedback"); filterText = filter = "no matches";', ui.context);

‎eng/board-periodic-refresh.test.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ for (const id of ["open-pr-board", "external-plugin-review-board"]) {
243243
number: 3, queueId: "current-token",
244244
recommendation: id === "open-pr-board" ? "approve" : "accept",
245245
rationale: "Finished while fetching.",
246+
...(id === "open-pr-board" ? { suggestedComment: "Thanks for the contribution." } : {}),
246247
}] });
247248
finish([1, 2, 3, 4, 5, 6].map(item));
248249
await manual;

0 commit comments

Comments
 (0)