Commit c0abcffbc3fb

Vincent Demeester <vincent@sbr.pm>
2026-02-11 12:17:10
feat(pi/github): improve approval confirmations
Added PR title to pr-ready and pr-close confirmation dialogs and show explicit '(none)' indicator when a review has no comment body (e.g. bare approvals).
1 parent 5d9a3e4
Changed files (3)
dots
pi
agent
extensions
dots/pi/agent/extensions/github/actions/pr.ts
@@ -537,9 +537,13 @@ export async function handlePRReady(
 
 	// APPROVAL GATE
 	if (ctx.hasUI) {
+		const title = await getPRTitle(pi, params.number, signal);
+		const description = title
+			? `"${truncate(title, 80)}"\n\nThis will mark the draft PR as ready for review.`
+			: "This will mark the draft PR as ready for review.";
 		const confirmed = await ctx.ui.confirm(
 			`Mark PR #${params.number} as ready?`,
-			"This will mark the draft PR as ready for review.",
+			description,
 		);
 		if (!confirmed) {
 			ctx.ui.notify("Cancelled", "info");
@@ -588,9 +592,13 @@ export async function handlePRClose(
 
 	// APPROVAL GATE
 	if (ctx.hasUI) {
+		const title = await getPRTitle(pi, params.number, signal);
+		const description = title
+			? `"${truncate(title, 80)}"\n\nThis will close the pull request without merging.`
+			: "This will close the pull request without merging.";
 		const confirmed = await ctx.ui.confirm(
 			`Close PR #${params.number}?`,
-			"This will close the pull request without merging.",
+			description,
 		);
 		if (!confirmed) {
 			ctx.ui.notify("Cancelled", "info");
@@ -617,6 +625,23 @@ export async function handlePRClose(
 	};
 }
 
+/**
+ * Helper: get the title for a PR (used in confirmation dialogs)
+ */
+async function getPRTitle(
+	pi: ExtensionAPI,
+	prNumber: number,
+	signal?: AbortSignal,
+): Promise<string | null> {
+	const result = await pi.exec(
+		"gh",
+		["pr", "view", String(prNumber), "--json", "title", "--jq", ".title"],
+		{ signal, timeout: 15000 },
+	);
+	if (result.code !== 0 || !result.stdout.trim()) return null;
+	return result.stdout.trim();
+}
+
 /**
  * Helper: get the HEAD commit SHA for a PR (needed for line comments API)
  */
dots/pi/agent/extensions/github/github.test.ts
@@ -601,6 +601,13 @@ describe("Confirmation Builders", () => {
 		expect(msg).toContain("LGTM");
 	});
 
+	test("buildReviewConfirmation shows no comment when body is absent", () => {
+		const msg = buildReviewConfirmation({ number: 789, reviewAction: "approve" });
+		expect(msg).toContain("#789");
+		expect(msg).toContain("approve");
+		expect(msg).toContain("(none)");
+	});
+
 	test("buildIssueCreateConfirmation includes all fields", () => {
 		const msg = buildIssueCreateConfirmation({
 			title: "Bug report",
dots/pi/agent/extensions/github/utils.ts
@@ -332,6 +332,8 @@ export function buildReviewConfirmation(params: any): string {
 	if (params.body) {
 		const preview = params.body.length > 200 ? params.body.slice(0, 197) + "..." : params.body;
 		msg += `Comment: ${preview}\n`;
+	} else {
+		msg += `Comment: (none)\n`;
 	}
 	msg += "\nThis will submit a review on the pull request.";
 	return msg;