Skip to content

Commit beb499b

Browse files
authored
fix(approvals): interpolate request id in fallback command
Fix approval fallback text so exec and plugin approval messages render a concrete request id in the chat copy-paste command instead of the literal <id> placeholder. This makes the Reply with: /approve ... line directly usable for owners while keeping the existing approval resolver contract unchanged. Proof: - git diff --check origin/main...HEAD - pnpm test src/infra/exec-approval-forwarder.test.ts src/infra/plugin-approval-forwarder.test.ts src/plugin-sdk/approval-renderers.test.ts - .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main - CI run 26720052738 passed Thanks @itsuzef.
1 parent 7617d06 commit beb499b

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/infra/exec-approval-forwarder.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ describe("exec approval forwarder", () => {
602602
expect(text).toContain("🔒 Exec approval required");
603603
expect(text).toContain("Command: `echo hello`");
604604
expect(text).toContain("Expires in: 5s");
605-
expect(text).toContain("Reply with: /approve <id> allow-once|allow-always|deny");
605+
expect(text).toContain("Reply with: /approve req-1 allow-once|allow-always|deny");
606606
});
607607

608608
it("includes command analysis warnings in fallback delivery text", () => {
@@ -639,7 +639,7 @@ describe("exec approval forwarder", () => {
639639
).resolves.toBe(true);
640640
await Promise.resolve();
641641
const text = getFirstDeliveryText(deliver);
642-
expect(text).toContain("Reply with: /approve <id> allow-once|deny");
642+
expect(text).toContain("Reply with: /approve req-1 allow-once|deny");
643643
expect(text).not.toContain("allow-once|allow-always|deny");
644644
expect(text).toContain("Allow Always is unavailable");
645645
});

src/infra/exec-approval-forwarder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export function buildExecApprovalRequestMessage(request: ExecApprovalRequest, no
286286
? "Background mode note: non-interactive runs cannot wait for chat approvals; use pre-approved policy (allow-always or ask=off)."
287287
: "Background mode note: non-interactive runs cannot wait for chat approvals; the effective policy still requires per-run approval unless ask=off.",
288288
);
289-
lines.push(`Reply with: /approve <id> ${decisionText}`);
289+
lines.push(`Reply with: /approve ${request.id} ${decisionText}`);
290290
if (!allowedDecisions.includes("allow-always")) {
291291
lines.push(
292292
"Allow Always is unavailable because the effective policy requires approval every time.",

src/infra/plugin-approval-forwarder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe("plugin approval forwarding", () => {
190190
expect(result).toBe(true);
191191
await flushPendingDelivery();
192192
const payload = firstDeliveredPayload(deliver);
193-
expect(payload?.text).toContain("Reply with: /approve <id> allow-once|deny");
193+
expect(payload?.text).toContain("Reply with: /approve plugin-req-1 allow-once|deny");
194194
expect(payload?.text).not.toContain("allow-always");
195195
expect(payload?.presentation).toEqual({
196196
blocks: [

src/infra/plugin-approvals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ export function buildPluginApprovalRequestMessage(
108108
const expiresIn = Math.max(0, Math.round((request.expiresAtMs - nowMsValue) / 1000));
109109
lines.push(`Expires in: ${expiresIn}s`);
110110
lines.push(
111-
`Reply with: /approve <id> ${resolvePluginApprovalRequestAllowedDecisions(request.request).join(
112-
"|",
113-
)}`,
111+
`Reply with: /approve ${request.id} ${resolvePluginApprovalRequestAllowedDecisions(
112+
request.request,
113+
).join("|")}`,
114114
);
115115
return lines.join("\n");
116116
}

src/plugin-sdk/approval-renderers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe("plugin-sdk/approval-renderers", () => {
142142
nowMs: 1_000,
143143
}),
144144
textExpected: (text: string) =>
145-
expect(text).toContain("Reply with: /approve <id> allow-once|deny"),
145+
expect(text).toContain("Reply with: /approve plugin-approval-123 allow-once|deny"),
146146
presentationExpected: {
147147
blocks: [
148148
{

0 commit comments

Comments
 (0)