Skip to content

Commit cf33ba1

Browse files
committed
Add workflow_dispatch trigger to collect-corrections workflow
The triage feedback slash command is a preview feature only available in private repos. Add a workflow_dispatch trigger with issue_number and feedback inputs so the workflow can be dispatched manually from the Actions UI. - Add workflow_dispatch trigger with required inputs to collect-corrections.yml - Fall back to context.payload.inputs when client_payload is absent - Add integration test for the workflow_dispatch payload path
1 parent f7fd757 commit cf33ba1

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

.github/workflows/collect-corrections.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ name: Collect triage agent corrections
33
on:
44
repository_dispatch:
55
types: [triage_feedback]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: "Issue number to submit feedback for"
10+
required: true
11+
type: string
12+
feedback:
13+
description: "Feedback text describing what the triage agent got wrong"
14+
required: true
15+
type: string
616

717
concurrency:
818
group: collect-corrections

scripts/corrections/collect-corrections.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async function maybeAssignCCA(github, owner, repo, trackingIssue, correctionCoun
203203
*/
204204
module.exports = async ({ github, context }) => {
205205
const { owner, repo } = context.repo;
206-
const payload = context.payload.client_payload ?? {};
206+
const payload = context.payload.client_payload ?? context.payload.inputs ?? {};
207207
const sender = context.payload.sender?.login ?? "unknown";
208208

209209
const correction = resolveContext(payload, sender);

scripts/corrections/test/collect-corrections.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, vi } from "vitest";
1+
import { describe, expect, it, vi } from "vitest";
22

33
const mod = await import("../collect-corrections.js");
44
const {
@@ -304,6 +304,42 @@ describe("appendCorrection", () => {
304304
});
305305
});
306306

307+
describe("module entrypoint - workflow_dispatch", () => {
308+
it("processes feedback from workflow_dispatch inputs", async () => {
309+
const github = mockGitHub({
310+
listForRepo: vi.fn().mockResolvedValue({
311+
data: [{ number: 50, assignees: [], body: trackingBodyForEntrypoint }],
312+
}),
313+
});
314+
const context = {
315+
repo: { owner: OWNER, repo: REPO },
316+
payload: {
317+
// workflow_dispatch has no client_payload; inputs carry the data
318+
inputs: { issue_number: "7", feedback: "Should be enhancement" },
319+
sender: { login: "dispatcher" },
320+
},
321+
};
322+
323+
await mod.default({ github, context });
324+
325+
// Verify the correction was appended referencing the right issue
326+
expect(github.rest.issues.update).toHaveBeenCalledWith(
327+
expect.objectContaining({
328+
issue_number: 50,
329+
body: expect.stringContaining("[#7]"),
330+
}),
331+
);
332+
});
333+
});
334+
335+
const trackingBodyForEntrypoint = [
336+
"# Triage Agent Corrections",
337+
"",
338+
"| Issue | Feedback | Submitted by | Date |",
339+
"|-------|----------|--------------|------|",
340+
"",
341+
].join("\n");
342+
307343
describe("maybeAssignCCA", () => {
308344
it("assigns CCA when threshold is reached", async () => {
309345
const github = mockGitHub();

0 commit comments

Comments
 (0)