Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/collect-corrections.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
name: Collect triage agent corrections
name: Submit triage agent feedback

on:
repository_dispatch:
types: [triage_feedback]
workflow_dispatch:
inputs:
issue_number:
description: "Issue number to submit feedback for"
required: true
type: string
feedback:
description: "Feedback text describing what the triage agent got wrong"
required: true
type: string

concurrency:
group: collect-corrections
Expand Down
2 changes: 1 addition & 1 deletion scripts/corrections/collect-corrections.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function maybeAssignCCA(github, owner, repo, trackingIssue, correctionCoun
*/
module.exports = async ({ github, context }) => {
const { owner, repo } = context.repo;
const payload = context.payload.client_payload ?? {};
const payload = context.payload.client_payload ?? context.payload.inputs ?? {};
const sender = context.payload.sender?.login ?? "unknown";

const correction = resolveContext(payload, sender);
Expand Down
38 changes: 37 additions & 1 deletion scripts/corrections/test/collect-corrections.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, vi } from "vitest";
import { describe, expect, it, vi } from "vitest";

const mod = await import("../collect-corrections.js");
const {
Expand Down Expand Up @@ -304,6 +304,42 @@ describe("appendCorrection", () => {
});
});

describe("module entrypoint - workflow_dispatch", () => {
it("processes feedback from workflow_dispatch inputs", async () => {
const github = mockGitHub({
listForRepo: vi.fn().mockResolvedValue({
data: [{ number: 50, assignees: [], body: trackingBodyForEntrypoint }],
}),
});
const context = {
repo: { owner: OWNER, repo: REPO },
payload: {
// workflow_dispatch has no client_payload; inputs carry the data
inputs: { issue_number: "7", feedback: "Should be enhancement" },
sender: { login: "dispatcher" },
},
};

await mod.default({ github, context });

// Verify the correction was appended referencing the right issue
expect(github.rest.issues.update).toHaveBeenCalledWith(
expect.objectContaining({
issue_number: 50,
body: expect.stringContaining("[#7]"),
}),
);
});
});

const trackingBodyForEntrypoint = [
"# Triage Agent Corrections",
"",
"| Issue | Feedback | Submitted by | Date |",
"|-------|----------|--------------|------|",
"",
].join("\n");

describe("maybeAssignCCA", () => {
it("assigns CCA when threshold is reached", async () => {
const github = mockGitHub();
Expand Down
Loading