From 3408c9dc77997e6e7b142ac51cc6ea046c18aa1e Mon Sep 17 00:00:00 2001 From: wdawdwa <2864460459@qq.com> Date: Sun, 23 Aug 2026 11:37:31 +0800 Subject: [PATCH] feat: unified command ack messages with expectations (6.3) --- src/github/commandFeedback.ts | 17 +++++++++++++++++ src/review/processor.ts | 4 ++-- test/command-ack.test.ts | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/command-ack.test.ts diff --git a/src/github/commandFeedback.ts b/src/github/commandFeedback.ts index 2c5a577..fc9318c 100644 --- a/src/github/commandFeedback.ts +++ b/src/github/commandFeedback.ts @@ -14,6 +14,23 @@ export function formatPermissionDeniedMessage( ].join(" "); } +export function formatCommandAckMessage( + commenterLogin: string, + actorName: string, + command: "/recheck" | "/conflict" +): string { + if (command === "/recheck") { + return [ + `${actorName} received \`/recheck\` requested by @${commenterLogin}.`, + "The full review is running now with the repository's current strictness settings; the result will be posted in this conversation when it completes." + ].join(" "); + } + return [ + `${actorName} received \`/conflict\` requested by @${commenterLogin}.`, + "Conflict repair can take up to 45 minutes (editing, isolated validation, and a final safety confirmation). A follow-up comment will report the outcome, and nothing is pushed unless every guard passes." + ].join(" "); +} + export async function postPermissionDeniedComment( octokit: Octokit, params: { diff --git a/src/review/processor.ts b/src/review/processor.ts index c7118db..0f5a82f 100644 --- a/src/review/processor.ts +++ b/src/review/processor.ts @@ -1,7 +1,7 @@ import type { Octokit } from "@octokit/rest"; import { config } from "../config.js"; import { requiredChecksAreGreen } from "../github/checks.js"; -import { postPermissionDeniedComment } from "../github/commandFeedback.js"; +import { postPermissionDeniedComment, formatCommandAckMessage } from "../github/commandFeedback.js"; import { formatBotDisplayName } from "../github/botIdentity.js"; import { collectValidNewLines, toDiffPosition } from "../github/diff.js"; import { listPullRequestFiles } from "../github/pulls.js"; @@ -641,7 +641,7 @@ export async function processRecheckComment( owner: params.owner, repo: params.repo, issue_number: params.pullNumber, - body: `Recheck requested by @${params.commenterLogin}. Re-running the review with the repository's current strictness settings.` + body: formatCommandAckMessage(params.commenterLogin, conflictAutomationName(), "/recheck") }); }); diff --git a/test/command-ack.test.ts b/test/command-ack.test.ts new file mode 100644 index 0000000..95cba52 --- /dev/null +++ b/test/command-ack.test.ts @@ -0,0 +1,16 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { formatCommandAckMessage } from "../src/github/commandFeedback.js"; + +test("recheck ack names the requester and sets expectations", () => { + const message = formatCommandAckMessage("alice", "ghbot bot", "/recheck"); + assert.match(message, /@alice/); + assert.match(message, /`\/recheck`/); + assert.match(message, /running now/); +}); + +test("conflict ack states the time budget and push guard", () => { + const message = formatCommandAckMessage("bob", "ghbot bot", "/conflict"); + assert.match(message, /45 minutes/); + assert.match(message, /nothing is pushed unless every guard passes/); +});