Repository navigation
Add remote attach CLI - #116
Conversation
|
ℹ️ 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 CLI commands and a client library to manage named remote endpoints, create/attach to remote sessions, and stream prompts over SSE. Implements persistent remotes storage, session creation via HTTP, SSE event parsing (including approval flow), and tests covering CRUD, session flows, errors, and permissions. ChangesRemote Session Management
Sequence DiagramsequenceDiagram
participant User
participant CLI as "Coding Agent CLI"
participant Client as "Remote Client"
participant API as "Remote API Server"
participant SSE as "SSE Stream"
User->>CLI: remote repl --name myremote --goal "fix bug"
CLI->>Client: get_remote("myremote")
Client-->>CLI: RemoteEndpoint
CLI->>Client: create_remote_session(endpoint, repo?, empty_workspace?)
Client->>API: POST /sessions (Authorization header)
API-->>Client: { "session_id": "sess123" }
CLI->>Client: stream_prompt(base_url, session_id, prompt)
Client->>API: GET /sessions/sess123/prompt (SSE)
activate SSE
API-->>SSE: event: StreamDelta (data)
SSE-->>Client: data
Client->>User: print delta
API-->>SSE: event: ApprovalRequest (data)
SSE-->>Client: approval request
Client->>User: prompt confirm
User-->>Client: confirm/no
Client->>API: POST /sessions/sess123/approve
API-->>Client: approval ack
API-->>SSE: event: TurnEnd (status)
SSE-->>Client: turn end
deactivate SSE
Client-->>CLI: exit code
CLI-->>User: exit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ 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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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/remote/client.py`:
- Around line 36-38: When parsing remotes.json (the expression raw =
cast(object, json.loads(path.read_text(encoding="utf-8"))) ) and the other
json.loads usage around lines 262-264, wrap the json.loads call in a try/except
that catches json.JSONDecodeError and re-raises a click.ClickException with a
clear message including the path or context and the original error text; import
json.JSONDecodeError if needed and use "raise click.ClickException(f'Invalid
remotes file: {path}: {e}') from e" (and the analogous message for the
SSE/payload parse) so malformed/truncated JSON produces Click errors instead of
tracebacks.
- Around line 59-62: The code in save_remotes uses path.parent.chmod(0o700)
unconditionally which may change permissions on an arbitrary existing directory
(e.g., /tmp); change the logic to only set permissions when we actually created
the parent directory. In save_remotes (and using remotes_file_path()), check
whether path.parent.exists() (or is_dir()) before creating it; if it does not
exist, create it (mkdir(parents=True, exist_ok=False) or create and catch
exceptions) and then call chmod(0o700); if it already exists, do not chmod the
existing directory. Ensure any race conditions are handled with appropriate
try/except so we only mutate permissions for directories we created.
- Around line 117-128: create_remote_session, stream_prompt, and related remote
calls currently let httpx.RequestError and indefinite connection waits leak to
callers and don't validate SSE responses; wrap all httpx network operations
(e.g., in create_remote_session and stream_prompt) in try/except that catches
httpx.RequestError and re-raises a ClickException with a clear message, replace
timeout=None in stream_prompt with an httpx.Timeout instance that has finite
connect/write/pool timeouts and read=None (so only read/inactivity is
unlimited), and before iterating SSE events call
event_source.response.raise_for_status() to validate the HTTP response; finally,
change the stream_prompt end-of-stream handling so that if no TurnEnd event is
observed it raises a ClickException (or returns a non-zero error indicator)
instead of returning 0 to avoid silently treating truncated streams as success.
🪄 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: 9135ab82-7776-477c-bfd6-cd2e18150b3f
📒 Files selected for processing (4)
coding-agent/src/coding_agent/__main__.pycoding-agent/src/coding_agent/remote/__init__.pycoding-agent/src/coding_agent/remote/client.pycoding-agent/tests/cli/test_remote_client.py
Summary
coding-agent remote add/list/remove.coding-agent remote replandcoding-agent attachfor creating/attaching remote HTTP sessions and streaming prompt SSE events.Verification
uv run pytest tests/cli/ -k "remote or attach" -quv run pytest tests/cli/ -quv run python -m compileall -q src/coding_agent/remote src/coding_agent/__main__.pylsp_diagnosticsclean for changed filesmanual remote CLI cloud-session smoke okreal docker HTTP cloud workspace smoke okSummary by CodeRabbit