Repository navigation
feat: publish remote results as GitHub PRs - #151
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds GitHub PR publication to session publishing: a mode-aware publish API and client, server-side GitHub REST PR creation with config/URL parsing and mapped statuses, CLI ChangesGitHub PR Publication
Sequence DiagramsequenceDiagram
participant CLI
participant Server as publish_session_result
participant BranchPub as publish_workspace_branch_from_config
participant GitHub as GitHub API
CLI->>Server: POST /sessions/{id}/publish {mode: "pr", branch_name}
Server->>BranchPub: publish branch (config)
BranchPub-->>Server: WorkspaceBranchPublication (remote_url, ref, commit)
alt mode == "pr"
Server->>_create_github_pull_request: create PR with publication & config
_create_github_pull_request->>_github_repo_from_remote_url: parse owner/repo
_create_github_pull_request->>GitHub: POST /repos/{owner}/{repo}/pulls (Authorization)
GitHub-->>_create_github_pull_request: 201 + html_url or error
_create_github_pull_request-->>Server: PR URL or raise GitHubPrPublicationError
Server->>Server: _publish_session_pr_response -> status (published/failed/unsupported)
end
Server-->>CLI: PublishSessionResponse {status, pr_url?, branch_ref, remote_url, commit}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@coding-agent/src/coding_agent/__main__.py`:
- Around line 1202-1265: The change to the CLI entrypoint remote_publish
(function remote_publish) alters publish behavior and must be validated by
running the full CLI test suite; run the entire tests/cli/ suite (e.g. pytest
tests/cli) and fix any failures that surface by adjusting either the
implementation around publish_remote_result handling (checks for
published_branch, commit_sha, remote_url, pr_url, status, pushed_ref and the
publish_mode == "pr" vs branch flows) or the tests to reflect intended behavior,
ensuring error messages, click.ClickException conditions and click.echo outputs
match expected tests; re-run tests/cli/ until all pass before merge.
In `@coding-agent/src/coding_agent/ui/http_server.py`:
- Around line 1876-1881: The PR path is making blocking httpx.post calls from an
async request handler; change _publish_session_pr_response and
_create_github_pull_request to async functions, replace synchronous httpx.post
calls with awaits against an httpx.AsyncClient (use either an async context
manager or a shared AsyncClient instance), update any caller
(publish_session_result) to await _publish_session_pr_response, and adjust
timeout/exception handling to work with async awaits and client.aclose()/context
management to avoid resource leaks; ensure all import references to httpx are
compatible with AsyncClient and update any synchronous helper usage accordingly.
- Around line 2010-2026: _github_repo_from_remote_url currently fails for
SCP-style remotes like "git@github.com:owner/repo.git" because urlsplit doesn't
set hostname; update the function to first detect SCP-style SSH remotes (e.g.
patterns like "git@github.com:owner/repo.git" or
"ssh://git@github.com/owner/repo.git") using a small regex or string parsing,
extract owner and repo (strip a trailing ".git"), and return them; if no
SCP-style match, continue to use urlsplit as before and keep the same
GitHubPrUnsupportedError checks and messages when hostname != "github.com" or
owner/repo can’t be derived.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c02bb09-143a-4dee-83fb-b5c425f776d0
📒 Files selected for processing (6)
coding-agent/docs/remote-sandbox-production.mdcoding-agent/src/coding_agent/__main__.pycoding-agent/src/coding_agent/remote/client.pycoding-agent/src/coding_agent/ui/http_server.pycoding-agent/tests/cli/test_remote_client.pycoding-agent/tests/ui/test_http_server.py
| @click.option( | ||
| "--pr", | ||
| "publish_mode", | ||
| flag_value="pr", | ||
| help="Create a GitHub pull request after publishing the branch.", | ||
| ) | ||
| @click.option( | ||
| "--branch-only", | ||
| "publish_mode", | ||
| flag_value="branch", | ||
| default="branch", | ||
| help="Publish the remote session changes as a Git branch only.", | ||
| ) | ||
| def remote_publish( | ||
| name: str, | ||
| session_id: str, | ||
| branch_name: str | None, | ||
| publish_mode: str, | ||
| ) -> None: | ||
| """Publish remote session results as a Git branch or PR.""" | ||
| from coding_agent.remote.client import get_remote, publish_remote_result | ||
|
|
||
| endpoint = get_remote(name) | ||
| publication = publish_remote_branch(endpoint, session_id, branch_name) | ||
| if branch_name is None: | ||
| branch_name = f"coding-agent/session-{session_id}" | ||
| publication = publish_remote_result( | ||
| endpoint, | ||
| session_id, | ||
| mode=publish_mode, | ||
| branch_name=branch_name, | ||
| ) | ||
| published_branch = publication.get("branch_name") | ||
| pushed_ref = publication.get("pushed_ref") | ||
| commit_sha = publication.get("commit_sha") | ||
| remote_url = publication.get("remote_url") | ||
| pr_url = publication.get("pr_url") | ||
| status = publication.get("status") | ||
| if not isinstance(published_branch, str) or not published_branch: | ||
| raise click.ClickException("Remote publish response missing branch_name") | ||
| if not isinstance(commit_sha, str) or not commit_sha: | ||
| raise click.ClickException("Remote publish response missing commit_sha") | ||
| if not isinstance(remote_url, str) or not remote_url: | ||
| raise click.ClickException("Remote publish response missing remote_url") | ||
| click.echo(f"Published branch {published_branch}") | ||
| if publish_mode == "pr": | ||
| if isinstance(pr_url, str) and pr_url: | ||
| click.echo(f"Published PR {pr_url}") | ||
| click.echo(f"Branch: {published_branch}") | ||
| elif status in {"unsupported", "failed"}: | ||
| error = publication.get("error") | ||
| if isinstance(error, str) and error: | ||
| click.echo(error) | ||
| click.echo(f"Branch: {published_branch}") | ||
| else: | ||
| raise click.ClickException("Remote PR publication did not complete") | ||
| else: | ||
| if status != "published": | ||
| raise click.ClickException("Remote branch publication did not complete") | ||
| click.echo(f"Published branch {published_branch}") | ||
| if isinstance(pushed_ref, str) and pushed_ref: | ||
| click.echo(f"Ref: {pushed_ref}") | ||
| click.echo(f"Commit: {commit_sha}") | ||
| click.echo(f"Remote: {remote_url}") | ||
| if publish_mode == "pr" and status == "failed": | ||
| raise click.ClickException("Remote PR publication did not complete") |
There was a problem hiding this comment.
Run the full CLI test suite for this entrypoint change.
remote publish behavior changed materially, but the listed validation only covers a targeted CLI test file. Please run the full tests/cli/ suite before merge.
As per coding guidelines, "When changing CLI/entrypoint behavior, run tests/cli/ test suite".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@coding-agent/src/coding_agent/__main__.py` around lines 1202 - 1265, The
change to the CLI entrypoint remote_publish (function remote_publish) alters
publish behavior and must be validated by running the full CLI test suite; run
the entire tests/cli/ suite (e.g. pytest tests/cli) and fix any failures that
surface by adjusting either the implementation around publish_remote_result
handling (checks for published_branch, commit_sha, remote_url, pr_url, status,
pushed_ref and the publish_mode == "pr" vs branch flows) or the tests to reflect
intended behavior, ensuring error messages, click.ClickException conditions and
click.echo outputs match expected tests; re-run tests/cli/ until all pass before
merge.
Summary
Validation
Summary by CodeRabbit
New Features
Documentation
Tests