feat(pi): add Cloud Code Review mode and rename Cloud to Cloud PR#5577
feat(pi): add Cloud Code Review mode and rename Cloud to Cloud PR#5577BillLeoutsakosvl346 wants to merge 1 commit into
Conversation
️✅ 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. 🦉 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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds Cloud Code Review support for the Pi block. The main changes are:
Confidence Score: 4/5The Cloud Code Review submission path needs fixes before merging.
apps/sim/executor/handlers/pi/cloud-review-backend.ts Important Files Changed
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
%%{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
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) |
There was a problem hiding this comment.
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.
| 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 | ||
| } |
There was a problem hiding this comment.
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.
| if (record.comments !== undefined) { | ||
| if (!Array.isArray(record.comments)) { | ||
| throw new Error('Pi review output comments must be an array when present') | ||
| } |
There was a problem hiding this comment.
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>
2760fad to
c8d7b57
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ 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'}`) | ||
| } |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit c8d7b57. Configure here.
|
Demo of PR issue vs PR review Screen.Recording.2026-07-10.at.5.58.24.PM.mov |
|
@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 |


Summary
cloudfor backward compatibility)github_create_pr_reviewto support an inlinecomments[]arraycloud-shared.tsfor Cloud PR and Cloud Code ReviewTest plan
NEXT_PUBLIC_E2B_ENABLEDis setMade with Cursor