Skip to content

feat(pr-review): progress comment + session link in review body#267

Closed
all-hands-bot wants to merge 2 commits into
mainfrom
feat/pr-review-session-link-and-progress-comment
Closed

feat(pr-review): progress comment + session link in review body#267
all-hands-bot wants to merge 2 commits into
mainfrom
feat/pr-review-session-link-and-progress-comment

Conversation

@all-hands-bot
Copy link
Copy Markdown
Contributor

Summary

Two related UX improvements to the pr-review plugin that let reviewers trace every automated review back to its execution session.


Changes

1. get_session_url() — auto-detect the execution environment

Added to agent_script.py. Detects which environment the script is running in and returns the appropriate link, with no manual configuration needed:

Environment Source env vars URL produced
GitHub Actions GITHUB_SERVER_URL + GITHUB_REPOSITORY + GITHUB_RUN_ID {server}/{repo}/actions/runs/{run_id}
OpenHands Cloud Automation OPENHANDS_CLOUD_API_URL + SANDBOX_ID {cloud_url}/conversations/{sandbox_id}
Explicit override REVIEW_RUN_URL (existing) used as-is (backward-compatible)

2. Progress comment — post before / update after

🔍 Review in progress… · View session          ← posted before agent starts
✅ Review complete. · View session              ← patched after run_review() returns

post_progress_comment() and update_progress_comment() are non-fatal — if the GitHub API call fails (e.g. token lacks issue comment write), the review still proceeds.

3. Session link in the review body

Added _SESSION_LINK_SECTION to prompt.py and wired session_url through format_prompt(). When a session URL is available, the agent is instructed to append:

This review was generated by an AI agent (OpenHands). View session

to the end of the top-level review body. Skipped when collect_feedback=True to avoid duplicating the URL that already appears in the feedback footer.


Behavior by scenario

Trigger Progress comment Session link in review
GitHub Actions workflow ✅ with Actions run link ✅ Actions run link
OpenHands Cloud Automation ✅ with conversation link ✅ conversation link
Local / other ✅ without link ❌ omitted

This PR was created by an AI agent (OpenHands) on behalf of the user.

@all-hands-bot can click here to continue refining the PR

all-hands-bot and others added 2 commits May 26, 2026 12:30
Adds a _SESSION_LINK_SECTION template and session_url parameter. When a
session URL is provided and collect_feedback is False, the agent is
instructed to include an attribution line linking to the session at the
end of the review body.

Co-authored-by: openhands <openhands@all-hands.dev>
- get_session_url(): auto-detects GitHub Actions (GITHUB_RUN_ID) or
  OpenHands Cloud Automation (SANDBOX_ID + OPENHANDS_CLOUD_API_URL);
  REVIEW_RUN_URL explicit override still works.
- post_progress_comment(): posts 'Review in progress' on the PR before
  the agent starts, with a link to the session.
- update_progress_comment(): patches that comment to 'Review complete'
  after run_review() returns.
- session_url wired into format_prompt() so the agent includes the link
  in the review body via the new _SESSION_LINK_SECTION in prompt.py.

Co-authored-by: openhands <openhands@all-hands.dev>
@xingyaoww
Copy link
Copy Markdown
Member

Closing this PR — the session URL and progress comment functionality is no longer needed in the plugin.

What changed: The session URL is now injected by sdk_main.py in the automation service (OpenHands/automation#142) via conversation.update_secrets({"AUTOMATION_SESSION_URL": url}). The SDK auto-exports secrets as env vars in the agent's bash session, so the automation prompt's ${AUTOMATION_SESSION_URL} picks it up directly.

The progress comment posting/updating and the session link in the review body are handled entirely by the automation prompt (Steps 1, 3, 4, 5) — no plugin-side changes are needed.

Specifically, this PR's get_session_url() relied on SANDBOX_ID + OPENHANDS_CLOUD_API_URL, but:

  • SANDBOX_IDconversation_id (they're different identifiers)
  • Those env vars aren't reliably available in the agent's bash subprocess

The correct approach in PR #142 builds the URL from conversation.id after Conversation(...) is created, which is the authoritative source for the conversation UUID.

This comment was posted by an AI agent (OpenHands) on behalf of the user.

@xingyaoww xingyaoww closed this May 26, 2026
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