feat(settings): auto-publish cloud runs toggle in advanced settings#3217
feat(settings): auto-publish cloud runs toggle in advanced settings#3217k11kirky wants to merge 2 commits into
Conversation
Adds a default-on "Always create pull requests for cloud runs" setting. When enabled, cloud task runs are created with auto_publish, and the sandbox agent-server (via the new --autoPublish flag) prompts the agent to push its work and open a draft PR on completion instead of stopping with local changes. Generated-By: PostHog Code Task-Id: 49d73463-ec66-491c-b645-f6116972bd02
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "feat(settings): auto-publish cloud runs ..." | Re-trigger Greptile |
| delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN; | ||
| }); | ||
|
|
||
| it("returns auto-PR prompt for manual runs when the user opted into auto-publish", () => { | ||
| const s = createServer({ autoPublish: true }); | ||
| const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt(); | ||
| expect(prompt).toContain("gh pr create --draft"); | ||
| expect(prompt).not.toContain("stop with local changes ready for review"); | ||
| // Manual runs keep the PostHog Code attribution. | ||
| expect(prompt).toContain( | ||
| "Created with [PostHog Code](https://posthog.com/code?ref=pr)", | ||
| ); | ||
| }); | ||
|
|
||
| it("keeps review-first prompt when auto-publish is on but createPr is false", () => { | ||
| const s = createServer({ autoPublish: true, createPr: false }); | ||
| const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt(); | ||
| expect(prompt).toContain("stop with local changes ready for review"); | ||
| expect(prompt).not.toContain("gh pr create --draft"); | ||
| }); | ||
|
|
||
| it("auto-publishes in no-repository mode when the user opted in", () => { | ||
| const s = createServer({ repositoryPath: undefined, autoPublish: true }); | ||
| const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt(); | ||
| expect(prompt).toContain("Cloud Task Execution — No Repository Mode"); | ||
| expect(prompt).toContain("without waiting to be asked"); | ||
| expect(prompt).not.toContain("unless the user explicitly asks for that"); | ||
| }); |
There was a problem hiding this comment.
Prefer parameterised tests for similar cases
The three new tests all exercise the autoPublish: true path and share a common assertion structure (checking for/against "gh pr create --draft" and "stop with local changes ready for review"). Tests 1 and 2 are especially close — they differ only in createPr: false and expected prompt content — and could be folded into an it.each block alongside the existing origin-based parameterised tests just below. The no-repo test (test 3) shares the "draft PR" assertion with test 1 and could similarly be grouped. Using it.each here would make the full matrix of (autoPublish, createPr, mode) behaviour easier to scan and extend.
Context Used: Do not attempt to comment on incorrect alphabetica... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Inline the one-ternary getCloudAutoPublish helper, pass the option value through in the request body builder, take a single settings snapshot in useTaskCreation, and split the no-repo cloud prompt into per-mode blocks mirroring the repository branch. Generated-By: PostHog Code Task-Id: 49d73463-ec66-491c-b645-f6116972bd02
|
Reviews (2): Last reviewed commit: "chore(settings): simplify auto-publish t..." | Re-trigger Greptile |
Problem
Cloud runs are review-first by default: the sandbox agent stops with local changes and won't push or open a PR unless explicitly asked. For most users the PR is the deliverable of a cloud run, so this default costs an extra round trip on nearly every run. We want this to be user-configurable, and on by default.
Changes
autoPublishCloudRuns, default on, persisted).cloudAutoPublishonTaskCreationInput→autoPublishrun option →auto_publishin the run-creation request body), and carried across resume runs from the previous run's state likepr_authorship_mode.agent-serveraccepts a new--autoPublishflag: when set,shouldAutoPublishCloudChanges()returns true for manual (non-Slack/signal) origins too, so the cloud system prompt switches to the push-and-open-a-draft-PR variant (including no-repository mode).--createPr falsestill disables publishing, and manual runs keep the "PostHog Code" PR attribution.Requires the backend side to accept and forward the new field: PostHog/posthog#68864 adds
auto_publishto the run-creation API and passes--autoPublishto the sandbox.Known follow-up: warm-pool runs launch their agent-server before the first message arrives, so a warm-run activation currently keeps review-first behavior regardless of the setting.
How did you test this?
turbo typecheckon shared/core/ui/api-client/agent — clean.vitestfull core suite and agent-server suite pass. New tests: auto-PR prompt for manual runs withautoPublish(incl. attribution),createPr=falsestill wins, no-repo mode variant, and saga threading ofcloudAutoPublish→autoPublish.Automatic notifications
Created with PostHog Code