Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions app/workflows/autopilot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ async function autopilot(claim: Claim, input: TriageInput, deps: AutopilotDeps,
workflow: { task: TaskDefinition<[raw: unknown], TaskResult<Data>> },
): ((input: Input) => Promise<TaskResult<Data>>) => {
if (override) return override;
const run = ctx.run;
if (!run) throw new Error("autopilot requires a Workflows task context");
return (stageInput) => run(workflow.task, stageInput);
if (!ctx.run) throw new Error("autopilot requires a Workflows task context");
return (stageInput) => ctx.run?.(workflow.task, stageInput) as Promise<TaskResult<Data>>;
};

const runTriage = child(deps.triage, triageWorkflow);
Expand Down
6 changes: 4 additions & 2 deletions tests/autopilot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ describe("autopilot", () => {
const names: string[] = [];
const workflowCtx = {
metadata: ctx.metadata,
run: vi.fn(async (definition: { name: string }, stageInput: unknown) => {
bound: true,
async run(this: { bound: boolean }, definition: { name: string }, stageInput: unknown) {
expect(this.bound).toBe(true);
names.push(definition.name);
if (definition.name === "triage") {
return result<TriageHandoff>("trn-triage", "drafted", {
Expand All @@ -123,7 +125,7 @@ describe("autopilot", () => {
}
expect(stageInput).toMatchObject({ pr: 34, workflowIssue: 12 });
return result("trn-review", "reviewed");
}),
},
} as unknown as Pick<TaskContext, "metadata" | "run">;

const output = await runAutopilot(workflowCtx, input, { gh: asClient(gh) });
Expand Down
Loading