Skip to content

Expand coop vscode into coop editor with Zed support - #416

Open
DarkaMaul wants to merge 3 commits into
mainfrom
dm/zed-editor
Open

Expand coop vscode into coop editor with Zed support#416
DarkaMaul wants to merge 3 commits into
mainfrom
dm/zed-editor

Conversation

@DarkaMaul

Copy link
Copy Markdown

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.

`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>
Comment thread src/workspace.rs Outdated
Comment thread src/workspace.rs
}];
if cfg!(target_os = "macos") {
strategies.push(LaunchStrategy {
name: "macOS open zed:// URL",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added zed_strategies_macos_fallback_is_open_zed_url (#[cfg(target_os = "macos")]), asserting strategies[1] is open zed://ssh/coop-test/workspace.

Comment thread src/workspace.rs Outdated
Comment thread src/workspace.rs
Comment thread src/workspace.rs Outdated
host: &str,
remote_path: &GuestPath,
) -> Vec<LaunchStrategy> {
let remote_arg = format!("ssh-remote+{host}");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment thread src/workspace.rs
Comment thread docs/editor.md Outdated

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded: the quick start now names the open -a 'Visual Studio Code' (macOS-only) step between the code CLI and Zed.

@hbrodin

hbrodin commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Review summary

7 findings posted inline. Scope: commit e60cfa3 (the coop vscodecoop editor / Zed change). The other commit in range (0c825e1, review tooling + docs restructure) was already reviewed via #409/#410 and is excluded.

Themes:

  • Zed URL construction — guest path interpolated into ssh:///zed:// URLs with no percent-encoding (the VS Code path is argv-safe); auto-detect fallthrough aborts on any non-NotFound spawn error, so Zed can be skipped even when installed.
  • Test coverage — the per-editor install-hint selection and the macOS open zed:// fallback are untested (and the hint logic sits in mutation-excluded launch_editor); editor_strategies_explicit_choice_pins_editor asserts only absence (all(...)), which is vacuously true on an empty Vec.
  • Minorremote_arg allocated unconditionally but unused on the Zed arm; the docs/editor.md quick-start glosses the macOS open -a step in the fallback chain.

No security, convention, API-usage, or comment issues. The rename is consistent across code, docs, completions, and .cargo/mutants.toml; the #[command(alias = "vscode")] preserves the old invocation; EditorKind as a clap::ValueEnum is the right enum-over-string move; Zed's ssh://host/path CLI form and ~/.ssh/config reuse were verified against current Zed docs.

Coverage: ran review-correctness, review-design, review-conventions, review-security, review-api-usage, review-tests, review-docs, review-comments (all 8). None skipped.

DarkaMaul and others added 2 commits August 4, 2026 15:09
- 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>
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.

2 participants