Repository navigation
feat(remote): add --no-workspace session creation to remote CLI (D3) - #675
Conversation
The remote CLI required --repo or --empty-workspace, both of which need server-side cloud_workspace.enabled=true. Servers with cloud workspace disabled (the o6n production config) could only get workspace-less sessions via raw POST /sessions — the webui path — never via the CLI. Add --no-workspace to remote repl/run: mutually exclusive with --repo/--empty-workspace, rejects --runtime/--download combinations before any network call, and sends POST /sessions without a workspace_source field, exactly matching the webui request shape without probing cloud_workspace config. When session creation fails with the server's cloud-workspace-disabled error, the CLI error now suggests --no-workspace. create_remote_session payload building verified path-by-path equivalent for all pre-existing paths (incl. snapshot + runtime_profile, now pinned by a dedicated regression test). Error-hint tests parametrized with the real server error strings. 2-round subagent review to 0 P1/P2; full suite 4063 passed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds a ChangesNo-workspace remote session support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as remote_commands.py
participant Client as create_remote_session
participant Server as Remote Server
User->>CLI: remote run --no-workspace
CLI->>CLI: validate exactly one of repo/empty-workspace/no-workspace
CLI->>Client: create_remote_session(no_workspace=True)
Client->>Client: validate no conflicting workspace options
Client->>Server: POST session (workspace_ref_kind="none")
alt provisioning disabled on server
Server-->>Client: error detail indicating disabled
Client-->>CLI: ClickException with --no-workspace guidance
else success
Server-->>Client: session created
Client-->>CLI: session id
end
CLI-->>User: result or error message
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
🧹 Nitpick comments (2)
coding-agent/src/coding_agent/remote/client.py (1)
1719-1736: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFragile coupling: hint gated on exact action string.
action == "create remote session"ties the hint to freeform display text also passed at the sole call site (line 302). Renaming that string later silently drops the--no-workspaceguidance with no signal beyond a test failure.Consider a dedicated flag instead of string matching:
♻️ Suggested refactor
-def _raise_remote_http_error(response: httpx.Response, action: str) -> None: +def _raise_remote_http_error( + response: httpx.Response, action: str, *, suggest_no_workspace: bool = False +) -> None: try: _ = response.raise_for_status() except httpx.HTTPStatusError as exc: detail = _response_error_detail(response) - if action == "create remote session" and _looks_like_cloud_workspace_disabled( - detail - ): + if suggest_no_workspace and _looks_like_cloud_workspace_disabled(detail): detail = ( f"{detail}. Use --no-workspace to create a session without " "server-side workspace provisioning." ) raise click.ClickException(f"Failed to {action}: {detail}") from excSeparately,
_looks_like_cloud_workspace_disableddepends on matching the server's exact error wording, which isn't defined in this file. Worth confirming this matches the actual production error string, not just the test fixtures.🤖 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 1719 - 1736, The `action == "create remote session"` check in the `ClickException` path is fragile because the `--no-workspace` hint depends on freeform display text; replace it with an explicit indicator passed through the remote session error-handling flow from the `create remote session` call site into the exception formatter. Keep `_looks_like_cloud_workspace_disabled` as the trigger for the hint, but confirm the matching strings reflect the real server error wording rather than only fixture text.coding-agent/src/coding_agent/cli/remote_commands.py (1)
253-290: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test coverage for new validation branches.
The
workspace_mode_countexactly-one-of check and the new--repo/--no-workspacecombo are tested, but two new validation branches introduced here aren't covered by any test in the provided diff:
no_workspace and runtime_profile is not None(Lines 287-290, "Pass --runtime only when creating a remote workspace.")--empty-workspace+--no-workspacecombo hittingworkspace_mode_count > 1Since these are new business rules enforced before any network call, a couple of small parametrized tests would lock in the behavior.
🤖 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/cli/remote_commands.py` around lines 253 - 290, Add test coverage for the new validation branches in the remote command flow: the `workspace_mode_count` guard in the CLI entrypoint and the `no_workspace`/`runtime_profile` check. Update the existing tests around `remote_commands` (the command that performs the exactly-one-of validation before network calls) to include parametrized cases for `--empty-workspace` plus `--no-workspace` raising the exact-one-of `ClickException`, and for `no_workspace=True` with a non-None `runtime_profile` raising the runtime-only-with-workspace error. Keep the assertions focused on the command’s validation behavior and error messages so these rules stay locked in.
🤖 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/cli/remote_commands.py`:
- Around line 253-290: Add test coverage for the new validation branches in the
remote command flow: the `workspace_mode_count` guard in the CLI entrypoint and
the `no_workspace`/`runtime_profile` check. Update the existing tests around
`remote_commands` (the command that performs the exactly-one-of validation
before network calls) to include parametrized cases for `--empty-workspace` plus
`--no-workspace` raising the exact-one-of `ClickException`, and for
`no_workspace=True` with a non-None `runtime_profile` raising the
runtime-only-with-workspace error. Keep the assertions focused on the command’s
validation behavior and error messages so these rules stay locked in.
In `@coding-agent/src/coding_agent/remote/client.py`:
- Around line 1719-1736: The `action == "create remote session"` check in the
`ClickException` path is fragile because the `--no-workspace` hint depends on
freeform display text; replace it with an explicit indicator passed through the
remote session error-handling flow from the `create remote session` call site
into the exception formatter. Keep `_looks_like_cloud_workspace_disabled` as the
trigger for the hint, but confirm the matching strings reflect the real server
error wording rather than only fixture text.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e03217aa-9ce3-4622-aac8-8b4ee85a34b0
📒 Files selected for processing (4)
coding-agent/docs/remote-sandbox-production.mdcoding-agent/src/coding_agent/cli/remote_commands.pycoding-agent/src/coding_agent/remote/client.pycoding-agent/tests/cli/test_remote_client.py
Problem (defect D3 from o6n live dogfood)
remote repl/remote runrequire--repoor--empty-workspace, and both need server-sidecloud_workspace.enabled=true. On servers with cloud workspace disabled (o6n production), the CLI cannot create sessions at all — the only path was rawPOST /sessions(the webui request shape).Change (additive)
--no-workspaceflag onremote replandremote run: sendsPOST /sessionswithout aworkspace_sourcefield, matching the webui path; never probes cloud-workspace config--repo/--empty-workspace(all 8 flag combinations validated);--runtime/--downloadcombinations rejected before any network call--no-workspace(matcher verified against the actualhttp_server.pyerror strings; phantom branch removed)create_remote_sessionpayload building reviewed path-by-path: byte-equivalent for every pre-existing path, incl. snapshot +runtime_profile(now pinned by a dedicated regression test)Verification
--no-workspacetests failed with "No such option" before implementationPOST /sessionswith onlyapproval_policyshort-circuits before the cloud-workspace check (http_server.py:1916-1922)🤖 Generated with Claude Code
Summary by CodeRabbit
--no-workspaceoption for remote run and REPL commands to start sessions without workspace provisioning.--repo,--empty-workspace, or--no-workspacecan be used at a time.--no-workspace.