Skip to content

feat(pi): add Cloud Code Review mode and rename Cloud to Cloud PR#5577

Open
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
feature/pi-cloud-code-review
Open

feat(pi): add Cloud Code Review mode and rename Cloud to Cloud PR#5577
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
feature/pi-cloud-code-review

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • Rename the Pi Cloud UI label to Cloud PR (stored mode id stays cloud for backward compatibility)
  • Add Cloud Code Review mode that checks out an existing PR in an E2B sandbox and posts a GitHub review with optional inline comments
  • Extend github_create_pr_review to support an inline comments[] array
  • Extract shared E2B helpers into cloud-shared.ts for Cloud PR and Cloud Code Review

Test plan

  • Unit tests pass for pi-handler, cloud-backend, cloud-review-backend, keys, and create_pr_review
  • Cloud PR still clones, edits, pushes, and opens a PR
  • Cloud Code Review on a real PR posts a summary review and at least one inline comment
  • Local mode is unchanged
  • Cloud options only appear when NEXT_PUBLIC_E2B_ENABLED is set

Made with Cursor

@gitguardian

gitguardian Bot commented Jul 10, 2026

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@vercel

vercel Bot commented Jul 10, 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, Comment Jul 10, 2026 11:15pm

Request Review

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

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Cloud Code Review support for the Pi block. The main changes are:

  • Cloud mode is renamed in the UI to Cloud PR.
  • A new Cloud Code Review mode checks out an existing PR in E2B.
  • The Pi handler routes Cloud Code Review runs through a new backend.
  • GitHub PR review creation now accepts inline comments.
  • Shared E2B helper code is extracted for cloud backends.
  • Docs and tests are updated for the new mode.

Confidence Score: 4/5

The Cloud Code Review submission path needs fixes before merging.

  • A PR update during the agent run can make the backend submit against stale commit metadata.
  • Invalid agent-generated line ranges can make GitHub reject the entire review.
  • The mode wiring, key handling, and shared cloud helper imports otherwise look consistent with the changed code.

apps/sim/executor/handlers/pi/cloud-review-backend.ts

Important Files Changed

Filename Overview
apps/sim/executor/handlers/pi/cloud-review-backend.ts Adds the Cloud Code Review backend, including PR checkout, prompt/context setup, review JSON parsing, and GitHub review submission.
apps/sim/tools/github/create_pr_review.ts Extends the GitHub create-review tool so it can submit inline review comments with a review body.
apps/sim/executor/handlers/pi/pi-handler.ts Adds Cloud Code Review mode validation, input parsing, backend dispatch, and output mapping.
apps/sim/executor/handlers/pi/keys.ts Treats Cloud Code Review as a cloud sandbox mode for BYOK-only model key resolution.
apps/sim/blocks/blocks/pi.ts Adds Cloud Code Review fields and outputs while keeping the existing Cloud PR mode id for compatibility.
apps/sim/executor/handlers/pi/cloud-shared.ts Moves shared E2B paths, timeouts, abort handling, marker parsing, and git-secret scrubbing into a common module.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Sim as Pi handler
  participant GH as GitHub API tools
  participant E2B as E2B sandbox
  participant Pi as Pi CLI

  Sim->>GH: Fetch PR metadata and files
  GH-->>Sim: PR head SHA and diff context
  Sim->>E2B: Clone and fetch PR head
  E2B-->>Sim: Checked-out head SHA
  Sim->>E2B: Write prompt and PR context
  E2B->>Pi: Run review agent
  Pi-->>E2B: Write pi-review.json
  E2B-->>Sim: Return review JSON
  Sim->>GH: Submit PR review with body and comments
  GH-->>Sim: Review URL or creation error
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Sim as Pi handler
  participant GH as GitHub API tools
  participant E2B as E2B sandbox
  participant Pi as Pi CLI

  Sim->>GH: Fetch PR metadata and files
  GH-->>Sim: PR head SHA and diff context
  Sim->>E2B: Clone and fetch PR head
  E2B-->>Sim: Checked-out head SHA
  Sim->>E2B: Write prompt and PR context
  E2B->>Pi: Run review agent
  Pi-->>E2B: Write pi-review.json
  E2B-->>Sim: Return review JSON
  Sim->>GH: Submit PR review with body and comments
  GH-->>Sim: Review URL or creation error
Loading

Reviews (1): Last reviewed commit: "feat(pi): add Cloud Code Review mode and..." | Re-trigger Greptile

totals.finalText = findings.body
}

const { reviewUrl, commentsPosted } = await submitReview(params, pr.headSha, findings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Stale Review Commit

When the PR head changes while the agent is running, this submits the review with the headSha fetched before checkout and ignores the actual clonedHead. The review comments are based on the old checkout/context, so GitHub can reject the review with an invalid commit_id error or attach feedback to an outdated diff.

Comment on lines +183 to +188
if (typeof comment.line === 'number') normalized.line = comment.line
if (comment.side === 'LEFT' || comment.side === 'RIGHT') normalized.side = comment.side
if (typeof comment.start_line === 'number') normalized.start_line = comment.start_line
if (comment.start_side === 'LEFT' || comment.start_side === 'RIGHT') {
normalized.start_side = comment.start_side
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Invalid Comment Coordinates

The agent output accepts any numeric line and start_line, including 0, negative numbers, fractions, or ranges where start_line >= line. Those values are forwarded to GitHub and can make the whole Cloud Code Review run fail with a review creation error instead of posting the valid summary or valid comments.

Comment on lines +164 to +167
if (record.comments !== undefined) {
if (!Array.isArray(record.comments)) {
throw new Error('Pi review output comments must be an array when present')
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Null Comments Abort Review

If the agent writes "comments": null, this branch treats the optional field as present and throws because it is not an array. That prevents the backend from submitting an otherwise valid review body, even though the guidance says comments are optional and the natural no-comments value can be null from JSON-producing agents.

Introduce a third Pi mode that reviews an existing GitHub PR in an E2B sandbox and posts a structured review with optional inline comments. Keep the stored cloud id for backward compatibility, extend github_create_pr_review for inline comments, and harden review submission against stale SHAs and invalid comment payloads.

Co-authored-by: Cursor <cursoragent@cursor.com>
@BillLeoutsakosvl346 BillLeoutsakosvl346 force-pushed the feature/pi-cloud-code-review branch from 2760fad to c8d7b57 Compare July 10, 2026 23:11

@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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c8d7b57. Configure here.


if (!result.success) {
throw new Error(`Failed to fetch PR #${params.pullNumber}: ${result.error ?? 'unknown error'}`)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Files fetch failure blocks review

Medium Severity

Cloud Code Review treats any github_pr_v2 failure as fatal before starting the sandbox. That tool returns success: false when only the pull files request fails, even though PR metadata was loaded and the sandbox could still clone the PR branch and review via local git.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8d7b57. Configure here.

const comment = item as Record<string, unknown>
if (typeof comment.path !== 'string' || !comment.path.trim()) continue
if (typeof comment.body !== 'string' || !comment.body.trim()) continue
if (!isPositiveInt(comment.line)) continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String line numbers silently dropped

Low Severity

parseReviewFindings only accepts line values that are already JavaScript numbers. If the agent writes valid JSON with numeric strings (e.g. "line": "12"), those inline comments are skipped without error while the summary review still posts, so commentsPosted can be zero despite the agent believing it left inline notes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8d7b57. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Demo of PR issue vs PR review

Screen.Recording.2026-07-10.at.5.58.24.PM.mov

@icecrasher321

Copy link
Copy Markdown
Collaborator

@BillLeoutsakosvl346 the goal is for the agent to leave comments on your PR in github directly since it has all the credentials and everything similar to Greptile or Bugbot

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.

2 participants