Skip to content

feat: add remote diff and patch commands - #147

Merged
delete-cloud merged 2 commits into
mainfrom
feat/remote-result-cli-exports
May 13, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
feat/remote-result-cli-exports

Conversation

@delete-cloud

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

Copy link
Copy Markdown
Owner

Summary

  • add remote client helpers for workspace diff and patch APIs
  • add coding-agent remote diff to print changed-file summaries
  • add coding-agent remote patch to print unified patches

Validation

  • uv run pytest tests/cli/test_remote_client.py -k "remote_diff or remote_patch or remote_run or remote_repl_with_repo or download" -q
  • uv run basedpyright --level error src/coding_agent/__main__.py src/coding_agent/remote/client.py tests/cli/test_remote_client.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

Release Notes

  • New Features

    • Added remote diff command to download and display changes in remote session workspaces with per-file summaries
    • Added remote patch command to retrieve and display unified patch files for remote session workspaces
  • Tests

    • Added test coverage for new remote workspace CLI commands

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: a2969927-6174-4178-bf10-f291fc04ab6f

📥 Commits

Reviewing files that changed from the base of the PR and between 292668c and 5771c63.

📒 Files selected for processing (1)
  • coding-agent/src/coding_agent/remote/client.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • coding-agent/src/coding_agent/remote/client.py

📝 Walkthrough

Walkthrough

This PR adds two remote workspace inspection CLI subcommands. remote diff downloads a session's workspace changes and displays a per-file summary with rename tracking and binary file indicators. remote patch downloads and prints the session's unified diff directly. Both use new remote client helper functions with HTTP request and JSON validation logic.

Changes

Remote workspace diff and patch CLI

Layer / File(s) Summary
Remote client download helpers
coding-agent/src/coding_agent/remote/client.py
Adds download_workspace_diff and download_workspace_patch that fetch from remote HTTP endpoints, validate response schema (files list and integer totals for diff; format and patch string for patch), and return validated results. Also returns _get_remote_json result directly in get_remote_session.
CLI remote diff and patch commands
coding-agent/src/coding_agent/__main__.py
Adds remote_diff and remote_patch CLI commands that call the download helpers, format per-file output with rename paths and binary indicators, and print workspace changes to stdout.
Tests for remote diff and patch
coding-agent/tests/cli/test_remote_client.py
test_remote_diff_prints_changed_files validates CLI output formatting and HTTP endpoint calls with auth headers. test_remote_patch_prints_unified_diff validates unified diff output and endpoint verification.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#143: Implements server-side schemas and HTTP stubs for the /sessions/{session_id}/workspace/diff and /workspace/patch endpoints that this PR's client calls.
  • delete-cloud/Coding-Agent-Loop#146: Implements the backend provider diff/patch contracts and HTTP endpoint handlers that this PR's remote client functions fetch from.

Poem

🐰 I hopped to fetch the distant patch and diff,
I nibbled headers, checked each filename swift,
With tiny paws I print the rename trace,
And show the unified patch, no trailing space,
A rabbit's cheer for remote workspace bliss.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.00% 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 'feat: add remote diff and patch commands' clearly and concisely summarizes the main change: adding two new remote CLI commands (diff and patch).
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-result-cli-exports

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.

🧹 Nitpick comments (2)
coding-agent/src/coding_agent/remote/client.py (1)

272-287: 💤 Low value

Optional: Remove redundant dict() call.

Line 287 calls dict(data) but data is already a dict[str, object] returned by _get_remote_json (line 321), making the conversion redundant.

♻️ Simplify return statement
-    return dict(data)
+    return data
🤖 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/remote/client.py` around lines 272 - 287, The
return uses dict(data) redundantly in download_workspace_diff even though
_get_remote_json already returns a dict; simply return the existing data object
instead (replace "return dict(data)" with "return data") to remove the
unnecessary copy while keeping the validation checks for files, additions, and
deletions intact.
coding-agent/src/coding_agent/__main__.py (1)

920-929: 💤 Low value

Optional: Remove redundant validation.

Lines 922-929 re-validate fields (files, additions, deletions) that were already validated in download_workspace_diff at lines 280-286 of client.py. The client function already raises click.ClickException for invalid responses, making this duplication unnecessary.

♻️ Remove redundant checks
     endpoint = get_remote(name)
     diff = download_workspace_diff(endpoint, session_id)
     files = diff.get("files")
-    if not isinstance(files, list):
-        raise click.ClickException("Remote workspace diff response missing files")
     workspace_id = diff.get("workspace_id")
     workspace_label = workspace_id if isinstance(workspace_id, str) else "unknown"
     additions = diff.get("additions")
     deletions = diff.get("deletions")
-    if not isinstance(additions, int) or not isinstance(deletions, int):
-        raise click.ClickException("Remote workspace diff response missing totals")
 
     click.echo(

The client-side validation guarantees these types.

🤖 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 920 - 929, Remove
duplicated validation in the caller after using download_workspace_diff: delete
the type checks and ClickException raises for files, additions, and deletions
(the block that inspects files, additions, deletions and raises
click.ClickException) since download_workspace_diff already validates and
raises; keep only retrieval of workspace_id and setting of workspace_label from
the diff. Ensure references to variables files, additions, deletions,
workspace_id/workspace_label remain consistent with the rest of the function and
do not re-check types or re-raise click.ClickException.
🤖 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.

Nitpick comments:
In `@coding-agent/src/coding_agent/__main__.py`:
- Around line 920-929: Remove duplicated validation in the caller after using
download_workspace_diff: delete the type checks and ClickException raises for
files, additions, and deletions (the block that inspects files, additions,
deletions and raises click.ClickException) since download_workspace_diff already
validates and raises; keep only retrieval of workspace_id and setting of
workspace_label from the diff. Ensure references to variables files, additions,
deletions, workspace_id/workspace_label remain consistent with the rest of the
function and do not re-check types or re-raise click.ClickException.

In `@coding-agent/src/coding_agent/remote/client.py`:
- Around line 272-287: The return uses dict(data) redundantly in
download_workspace_diff even though _get_remote_json already returns a dict;
simply return the existing data object instead (replace "return dict(data)" with
"return data") to remove the unnecessary copy while keeping the validation
checks for files, additions, and deletions intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25108d64-5cb4-40e6-9fbc-1e1a17054128

📥 Commits

Reviewing files that changed from the base of the PR and between 26f8eea and 292668c.

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

@delete-cloud
delete-cloud merged commit 91b7a58 into main May 13, 2026
1 check passed
@delete-cloud
delete-cloud deleted the feat/remote-result-cli-exports branch May 13, 2026 08:04
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