Skip to content

Commit 9d82ec2

Browse files
authored
Properly handle origin === "signal_report" (#1709)
## Changes Companion to PostHog/posthog#54553 for task origin handling.
1 parent be18c37 commit 9d82ec2

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

packages/agent/src/server/agent-server.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,16 @@ describe("AgentServer HTTP Mode", () => {
489489
delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
490490
});
491491

492+
it("returns auto-PR prompt for signal_report-origin runs", () => {
493+
process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "signal_report";
494+
const s = createServer();
495+
const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt();
496+
expect(prompt).toContain("posthog-code/");
497+
expect(prompt).toContain("Create a draft pull request");
498+
expect(prompt).toContain("gh pr create --draft");
499+
delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
500+
});
501+
492502
it("returns PR-update prompt for existing PRs on Slack-origin runs", () => {
493503
process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "slack";
494504
const s = createServer();

packages/agent/src/server/agent-server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,13 +1265,14 @@ export class AgentServer {
12651265
}
12661266

12671267
/**
1268-
* Slack-origin cloud runs auto-publish by default. Every other origin is
1268+
* Automated-origin cloud runs auto-publish by default. Every other origin is
12691269
* review-first unless the user explicitly asks, and createPr=false always
12701270
* disables publishing.
12711271
*/
12721272
private shouldAutoPublishCloudChanges(): boolean {
1273+
const origin = this.getCloudInteractionOrigin();
12731274
return (
1274-
this.getCloudInteractionOrigin() === "slack" &&
1275+
(origin === "slack" || origin === "signal_report") &&
12751276
this.config.createPr !== false
12761277
);
12771278
}

0 commit comments

Comments
 (0)