Expand coop vscode into coop editor with Zed support - #416
Conversation
`coop editor` opens VS Code or Zed connected to the guest over SSH; `coop vscode` remains as an alias. `--editor` is now a clap ValueEnum (`code` | `zed`) instead of a free-form string. When omitted, coop tries VS Code first, then falls through to Zed. Zed connects with `zed ssh://coop-<name>/<path>` (macOS fallback: `open zed://ssh/...`), reusing the same `~/.ssh/config` alias block that VS Code's Remote-SSH uses — no new SSH machinery. `.cargo/mutants.toml`: the renamed `open_editor` wrapper replaces the `vscode` exclude; the pure strategy helpers (`zed_strategies`, `editor_strategies`) stay in scope and are unit-tested. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| }]; | ||
| if cfg!(target_os = "macos") { | ||
| strategies.push(LaunchStrategy { | ||
| name: "macOS open zed:// URL", |
There was a problem hiding this comment.
The macOS open zed://ssh/... fallback has no coverage — zed_strategies_first_is_zed_cli only asserts strategies[0] (the CLI form). This branch uses a different scheme/shape than the CLI arm (zed://ssh/... vs ssh://...), and since the mutation sweep runs on Linux the cfg!(target_os = "macos") arm is compiled out, so a broken URL here surfaces in neither tests nor mutants. A #[cfg(target_os = "macos")] test asserting strategies[1] is open zed://ssh/coop-test/workspace would cover it (the parallel vscode_strategies macOS arm is pre-existing but equally uncovered).
There was a problem hiding this comment.
Added zed_strategies_macos_fallback_is_open_zed_url (#[cfg(target_os = "macos")]), asserting strategies[1] is open zed://ssh/coop-test/workspace.
| host: &str, | ||
| remote_path: &GuestPath, | ||
| ) -> Vec<LaunchStrategy> { | ||
| let remote_arg = format!("ssh-remote+{host}"); |
There was a problem hiding this comment.
remote_arg is built unconditionally, but only the VS Code strategies use it (the Some(Code) and None arms). On the Some(EditorKind::Zed) arm it is a wasted allocation. Moving it into the arms that consume it (or into vscode_strategies) keeps it scoped to its users.
There was a problem hiding this comment.
Moved into vscode_strategies, which now takes host and builds remote_arg itself — both strategy helpers have the same signature and editor_strategies just dispatches. Updated vscode_strategies_first_is_code_cli to pass "coop-test".
|
|
||
| 1. Writes an SSH config block for the instance into `~/.ssh/config`. | ||
| 2. Launches VS Code with `code --remote ssh-remote+coop-{name} /workspace`. | ||
| 2. Launches VS Code with `code --remote ssh-remote+coop-{name} /workspace`, falling back to Zed with `zed ssh://coop-{name}/workspace` when `code` is not installed. |
There was a problem hiding this comment.
This says coop falls back to Zed "when code is not installed", but on macOS editor_strategies(None, ...) inserts an open -a 'Visual Studio Code' strategy between the code CLI and Zed, so VS Code can still launch via the app when the code CLI is absent — Zed is only reached after that fallback also fails. The ## The coop editor command and ### Zed sections describe the full chain correctly; only this quick-start summary glosses the macOS step.
There was a problem hiding this comment.
Reworded: the quick start now names the open -a 'Visual Studio Code' (macOS-only) step between the code CLI and Zed.
Review summary7 findings posted inline. Scope: commit Themes:
No security, convention, API-usage, or comment issues. The rename is consistent across code, docs, completions, and Coverage: ran review-correctness, review-design, review-conventions, review-security, review-api-usage, review-tests, review-docs, review-comments (all 8). None skipped. |
- Percent-encode the guest path before interpolating it into the Zed `ssh://` / `zed://` URLs. `--project` is only checked for a leading `/`, so `#` previously read as a fragment and silently opened a truncated path. Takes `percent-encoding` (already in the tree via `url`) as a direct dependency rather than hand-rolling the encoder. - Treat every spawn failure in the launch chain as a miss, not a hard stop. A non-`NotFound` error (e.g. a present-but-not-executable `code`) used to return early and skip Zed even when Zed was installed. - Split the per-editor install hints out of `launch_editor` into `install_hints`, which stays in mutation scope, and test each arm. - Build `remote_arg` inside `vscode_strategies`, its only consumer. - Add a macOS-gated test for the `open zed://` fallback, a test for path escaping, and positive assertions to `editor_strategies_explicit_choice_pins_editor` (its `all(...)` checks were vacuously true on an empty Vec). - Fix the `docs/editor.md` quick start, which skipped the macOS `open -a 'Visual Studio Code'` step in the fallback chain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
coop editoropens VS Code or Zed connected to the guest over SSH;coop vscoderemains as an alias.--editoris now a clap ValueEnum (code|zed) instead of a free-form string. When omitted, coop tries VS Code first, then falls through to Zed.