Skip to content

feat(pi): add update PR mode - #6031

Merged
BillLeoutsakosvl346 merged 10 commits into
stagingfrom
feat/pi-update-branch-mode
Jul 30, 2026
Merged

feat(pi): add update PR mode#6031
BillLeoutsakosvl346 merged 10 commits into
stagingfrom
feat/pi-update-branch-mode

Conversation

@BillLeoutsakosvl346

@BillLeoutsakosvl346 BillLeoutsakosvl346 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Stacked PR

This PR is stacked on #5962 and intentionally targets feature/pi-babysit. PR #5962 remains unchanged and targets staging.

Do not merge this PR before #5962. After #5962 merges, this branch will be rebased onto the merged Babysit tree on staging, retargeted to staging, and revalidated.

Summary

Add Update PR (cloud_branch) as the fourth Pi mode, with Create PR permission and Babysit parity.

  • Check out one exact existing remote branch and push HEAD back with a normal non-force refspec.
  • Find the exact open same-repository PR for that branch; update it when found and create it when missing.
  • Reuse Base Branch, PR Title, PR Body, and a tri-state PR State control (preserve, draft, ready). Blank metadata preserves an existing PR and is generated for a new PR.
  • Reuse Create PR memory, skills, search, BYOK, streaming, authoring, Babysit, budgets, outputs, and GitHub permission model.
  • Complete the initial non-force push before any PR mutation. A rejected push prevents PR changes and Babysit; a no-change run still creates or updates the PR.
  • With Babysit, ensure the PR is ready, create it if missing, and feed its number into the existing continuation.
  • Fail closed on ambiguous, forked, closed, moved, or mismatched PRs. Never merge, rebase, retry, or force-push at runtime.

Security Boundaries

  • The GitHub token is used only by host GitHub operations and sandbox clone/push commands; it is absent from Pi and commit/diff preparation.
  • Model and optional search keys are scoped to Pi and absent from clone, commit/diff preparation, push, and host PR operations.
  • PR coordinates are validated before and after authoring, and surfaced text/errors are scrubbed against all sandbox credentials.
  • Existing Babysit pinning, reviewer trust, budgets, and lifetime limits are reused unchanged.

Permissions

Create PR and Update PR require the same GitHub permissions:

  • Fine-grained token: Contents: Read and write and Pull requests: Read and write.
  • Classic token: repo scope, with organization SSO authorization when required.
  • Babysit additionally needs the existing issue-comment, review-thread, Actions, commit-status, and check reads/writes documented for Create PR.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other

Testing

  • All Pi suites: 20 files / 293 tests passed before the final two focused regression additions; the final focused suites pass 67 tests.
  • Sim TypeScript type-check passed.
  • Biome passed for all touched TypeScript files.
  • Fumadocs MDX generation passed.
  • Monorepo boundary and API validation audits passed.

Review focus: exact PR discovery/revalidation, push-before-PR sequencing, missing-PR creation, metadata/draft transitions, no-op finalization, non-fast-forward failure, Babysit reuse, and credential isolation.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement

Screenshots/Videos

Not included: this is a cloud-gated block option and behavior is covered by block visibility and handler/backend tests.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 30, 2026 1:11am

Request Review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

cursor review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New GitHub write paths (branch push, PR create/update, draft transitions) and sandbox credential handling; mitigated by push-before-PR ordering, strict PR matching, secret scrubbing, and broad tests.

Overview
Adds a fourth Pi Coding Agent mode, Update PR (cloud_branch), for continuing work on an existing remote branch instead of always creating a new one.

The sandbox checks out that branch, runs Pi, non-force pushes HEAD back, then finds or creates the matching open same-repo PR. Host logic updates title/body/base when set, applies PR State (preserve / draft / ready) via GraphQL where needed, and re-validates PR identity after authoring (ambiguous, fork, or moved-head cases fail closed). A failed push blocks PR changes and Babysit; a no-op edit can still create or update the PR.

Create PR and Update PR now share sandbox authoring, BYOK for the model key, skills/memory/search, Babysit controls/outputs, and the same GitHub token permission model. Babysit copy is generalized from “after Create PR” to “after authoring.” Standalone babysit mode is rejected with a migration message.

Reviewed by Cursor Bugbot for commit 4d22771. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Update PR (cloud_branch) as a fourth Pi mode with Create PR parity for sandbox authoring, non-force push, PR create/update, and Babysit.

  • New cloud_branch mode in the Pi block UI with Target Branch, PR State, shared Base/Title/Body, skills, memory, search, and Babysit controls.
  • Cloud backend checks out an existing branch, pushes without force, then finds or creates the exact open same-repo PR and applies metadata/draft transitions.
  • GitHub helpers add open-PR-by-branch lookup and GraphQL draft/ready transitions; docs and tests cover discovery, no-op finalization, push failures, and Babysit reuse.

Confidence Score: 5/5

The PR appears safe to merge from this follow-up pass; no prior Greptile findings remain outstanding and no eligible new inline issues were identified.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/pi/cloud-backend.ts Shared authoring path for Create/Update PR with push-before-PR sequencing, ensure/update PR finalization, and Babysit handoff.
apps/sim/executor/handlers/pi/github-pr.ts Open-PR-by-branch discovery with same-repo revalidation and GraphQL draft/ready state changes.
apps/sim/blocks/blocks/pi.ts Exposes Update PR mode and field conditions for target branch, PR state, and shared authoring/Babysit controls.
apps/sim/executor/handlers/pi/pi-handler.ts Parses cloud_branch inputs (targetBranch, prState) and routes BYOK/authoring like Create PR.

Sequence Diagram

sequenceDiagram
  participant Block as Pi block (cloud_branch)
  participant Host as cloud-backend
  participant SB as Sandbox
  participant GH as GitHub

  Block->>Host: run Update PR
  Host->>GH: findOpenPrForBranch (preflight)
  Host->>SB: clone target branch
  Host->>SB: Pi authoring (no GitHub token)
  Host->>SB: prepare commit/diff
  alt has changes
    Host->>SB: non-force push HEAD
    SB->>GH: push refs/heads/target
  end
  Host->>GH: findOpenPrForBranch (post-push)
  alt open PR found
    Host->>GH: update metadata / draft state
  else none
    Host->>GH: create PR
  end
  opt Babysit enabled
    Host->>GH: ready PR + continuation
  end
Loading

Reviews (13): Last reviewed commit: "fix(pi): preserve update PR BYOK after s..." | Re-trigger Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0fc8bd1. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 marked this pull request as ready for review July 29, 2026 00:09
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Demo:

Screen.Recording.2026-07-28.at.5.26.08.PM.mov

@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the feat/pi-update-branch-mode branch from 0fc8bd1 to 5fa94fe Compare July 29, 2026 01:22
@BillLeoutsakosvl346
BillLeoutsakosvl346 changed the base branch from staging to feature/pi-babysit July 29, 2026 01:22
@BillLeoutsakosvl346
BillLeoutsakosvl346 marked this pull request as draft July 29, 2026 01:23
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

@BillLeoutsakosvl346
BillLeoutsakosvl346 marked this pull request as ready for review July 29, 2026 01:28
@BillLeoutsakosvl346 BillLeoutsakosvl346 changed the title feat(pi): add update branch mode feat(pi): add update PR mode Jul 29, 2026
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/cloud-backend.ts
Comment thread apps/sim/executor/handlers/pi/cloud-backend.ts Outdated
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the feat/pi-update-branch-mode branch from 8906140 to 217ea51 Compare July 29, 2026 03:12
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/github-pr.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/github-pr.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/cloud-backend.ts Outdated
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/cloud-backend.ts Outdated
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread apps/sim/executor/handlers/pi/cloud-backend.ts Outdated
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5aaf5fd. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 changed the base branch from feature/pi-babysit to staging July 30, 2026 00:59
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the feat/pi-update-branch-mode branch from 5aaf5fd to 4d22771 Compare July 30, 2026 01:05
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4d22771. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 merged commit 94778eb into staging Jul 30, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/pi-update-branch-mode branch July 30, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant