Skip to content

feat: use Git source for remote run - #150

Merged
delete-cloud merged 2 commits into
mainfrom
feat/remote-run-git-source
May 13, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
feat/remote-run-git-source

Conversation

@delete-cloud

@delete-cloud delete-cloud commented May 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • make remote run --repo create Git-backed workspace sources for clean pushed Git repos
  • add explicit --snapshot-fallback for local-only, dirty, detached, or unpublished repos
  • update production docs and CLI tests for Git-backed publish workflow

Validation

  • uv run pytest tests/cli/test_remote_client.py -q
  • uv run pytest tests/ui/test_http_server.py tests/ui/test_http_server_workspace_transfer.py tests/cli/test_remote_client.py tests/coding_agent/environment/ -k "git_workspace or session_result or workspace_diff or workspace_patch or publish or remote_run" -q
  • uv run basedpyright --level error src/coding_agent/ui/schemas.py src/coding_agent/ui/http_server.py src/coding_agent/remote/client.py src/coding_agent/main.py src/coding_agent/environment/workspace_provider.py src/coding_agent/environment/init.py src/coding_agent/environment/docker_workspace_provider.py tests/ui/test_http_server.py tests/cli/test_remote_client.py tests/coding_agent/environment/test_docker_workspace_provider.py
  • uv run ruff format --check src/coding_agent/main.py src/coding_agent/remote/client.py tests/cli/test_remote_client.py
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added a snapshot-fallback option for remote run to support local-only repos, dirty worktrees, detached HEADs, or unpublished commits.
    • Remote run now selects Git-backed execution for clean repos and conditionally shows "Publish review branch" when applicable.
  • Documentation

    • Updated remote operations guide with clearer Git-backed workspace guidance, snapshot limitations, and snapshot-fallback usage/examples.
  • Tests

    • Added tests covering Git-backed runs, dirty-worktree behavior, missing-Git handling, and snapshot-fallback archive uploads.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6814da24-5d66-44be-8afa-bcba94941d22

📥 Commits

Reviewing files that changed from the base of the PR and between 0827548 and eb5bc34.

📒 Files selected for processing (2)
  • coding-agent/src/coding_agent/__main__.py
  • coding-agent/tests/cli/test_remote_client.py

📝 Walkthrough

Walkthrough

Adds Git-backed workspace_source support for remote run --repo and a --snapshot-fallback flag; CLI chooses Git publication input when repo state permits or uploads a snapshot archive when fallback is enabled. Client, Git helpers, docs, and tests updated to reflect the new flow.

Changes

Git-backed Remote Workspace Source with Snapshot Fallback

Layer / File(s) Summary
Client contract for workspace_source
coding-agent/src/coding_agent/remote/client.py
create_remote_session adds optional workspace_source, disallows providing both workspace_source and snapshot_archive_base64, defaults to {"kind":"docker"} when neither is provided, and conditionally injects runtime_profile.
CLI flag, imports, and validation
coding-agent/src/coding_agent/__main__.py
Adds subprocess import, introduces --snapshot-fallback to remote run, forwards it into _remote_run_once (default true), and updates validation error wording for incompatible --repo/--empty-workspace cases.
Workspace source selection and next-steps wiring
coding-agent/src/coding_agent/__main__.py
Refactors _remote_run_once to either upload a snapshot archive (when fallback enabled) or compute a Git-backed workspace_source (remote_url, base_ref, base_sha, optional runtime_profile); sets can_publish_branch for next-steps output.
Git state validation and metadata extraction
coding-agent/src/coding_agent/__main__.py
Adds Git helper functions to validate worktree root, require a clean working tree and proper branch/origin, compute base ref/sha and ancestry constraints, run Git commands with timeout, and map Git failures to user-facing errors.
User-facing documentation for Git workspace and snapshot fallback
coding-agent/docs/remote-sandbox-production.md
Clarifies remote run --repo uses Git-backed workspace when conditions are met, notes snapshots exclude .git and cannot be published, documents --snapshot-fallback usage and example, and updates --download example to pair with --snapshot-fallback.
Client tests and git helpers
coding-agent/tests/cli/test_remote_client.py
Adds subprocess-based Git helpers and a unit test asserting create_remote_session sends workspace_source.kind="git" with remote_url, base_ref, base_sha, and forwards runtime_profile and approval_policy, plus Authorization header checks.
CLI tests for snapshot-fallback and git-state handling
coding-agent/tests/cli/test_remote_client.py
Updates assertions to ensure remote publish is not shown where appropriate, adjusts validation error strings, adds --snapshot-fallback to tests, and adds tests for clean repos, dirty repos requiring fallback, missing git failure, and snapshot-fallback archive upload for local-only repos.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I found a branch and a fallback, too,

If Git is tidy, publish will do.
When trees are messy, snapshots fly,
Flag the fallback—upload and try.
A hoppity push, a clean review sky.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: enabling Git as a source for the remote run command when working with clean Git repositories.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/remote-run-git-source

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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 827-887: The code currently lets FileNotFoundError bubble up when
git is missing; update _run_git_for_remote_source to catch FileNotFoundError
around the subprocess.run invocation and re-raise a click.ClickException with a
clear message (e.g., "git not found; please install git or adjust PATH") (raise
from the original exception) so the caller code that expects ClickException
receives a CLI-friendly error; keep the existing subprocess.CalledProcessError
handling and return the subprocess output as before.
🪄 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: 287d5733-45af-44fc-89a1-a856eadbd555

📥 Commits

Reviewing files that changed from the base of the PR and between 772c8b6 and 0827548.

📒 Files selected for processing (4)
  • coding-agent/docs/remote-sandbox-production.md
  • coding-agent/src/coding_agent/__main__.py
  • coding-agent/src/coding_agent/remote/client.py
  • coding-agent/tests/cli/test_remote_client.py

Comment thread coding-agent/src/coding_agent/__main__.py Outdated
@delete-cloud
delete-cloud merged commit 7ac2d26 into main May 13, 2026
1 check passed
@delete-cloud
delete-cloud deleted the feat/remote-run-git-source branch June 1, 2026 14:31
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