cli: Respect --new when opening URLs from the CLI#54408
Merged
Conversation
--new when opening URLs from the CLI--new when opening URLs from the CLI
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CLI URL-opening behavior so that --new (and other open-behavior flags like --reuse, -a, -e) are honored uniformly for URL-shaped arguments (e.g. ssh://..., file://...) instead of silently reusing an existing matching workspace/window.
Changes:
- Thread
open_behaviorthroughRawOpenRequest→OpenRequestparsing so URL opens retain the requested behavior. - Introduce
open_options_for_behaviorto consistently translatecli::OpenBehaviorintoworkspace::OpenOptions(workspace matching, sidebar behavior, and reuse target window). - Update
handle_open_requestto pass the derivedOpenOptionsintoopen_remote_projectandopen_paths_with_positions, plus add regression/unit tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/zed/src/zed/open_listener.rs | Adds open_behavior to open request types, centralizes behavior→options translation, and adds tests/regression coverage. |
| crates/zed/src/main.rs | Ensures URL-based open handling uses the translated OpenOptions (fixing --new reuse for SSH/file URLs). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c6c11ed to
6090959
Compare
6090959 to
71ac213
Compare
84076a6 to
8bfc8c7
Compare
`zed --new ssh://host/path/to/file` only created a new window on the first call. Subsequent invocations silently reused the existing SSH workspace for the same host, which then tried to open the new path against the existing worktree and surfaced a `DevServerProjectPathDoesNotExist` popup when the path didn't belong to any open worktree. The CLI correctly translated `--new` to `OpenBehavior::AlwaysNew`, but the URL branch of `handle_cli_connection` dropped the `open_behavior`. `handle_open_request` then called `open_remote_project` (and `open_paths_with_positions` for `file://`) with `OpenOptions::default()`, which is `WorkspaceMatching::MatchExact`, so any existing SSH window for the same host won the match. The issue applies to `file://` URLs and `-a` / `-e` / `--reuse` for URL-shaped arguments in general; `--new` was just the most visible symptom. The fix is making sure the translation of `OpenRequest` is uniform across plain paths and URL-shaped arguments. Closes #52679. Release Notes: - Fixed `zed --new` flag being ignored when opening file, SSH, and Git commit URLs
8bfc8c7 to
8a2e6c1
Compare
probably-neb
approved these changes
May 19, 2026
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
May 20, 2026
…4408) `zed --new ssh://host/path/to/file` only created a new window on the first call. Subsequent invocations silently reused the existing SSH workspace for the same host, which then tried to open the new path against the existing worktree and surfaced a `DevServerProjectPathDoesNotExist` popup when the path didn't belong to any open worktree. The CLI correctly translated `--new` to `OpenBehavior::AlwaysNew`, but the URL branch of `handle_cli_connection` dropped the `open_behavior`. `handle_open_request` then called `open_remote_project` (and `open_paths_with_positions` for `file://`) with `OpenOptions::default()`, which is `WorkspaceMatching::MatchExact`, so any existing SSH window for the same host won the match. The issue applies to `file://` URLs and `-a` / `-e` / `--reuse` for URL-shaped arguments in general; `--new` was just the most visible symptom. The fix is making sure the translation of `OpenRequest` is uniform across plain paths and URL-shaped arguments. Closes zed-industries#52679. Release Notes: - Fixed `zed --new ssh://host/path` reusing an existing SSH window instead of opening a new one. This also applied to other URL-shaped path arguments.
This was referenced May 27, 2026
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 2, 2026
…4408) `zed --new ssh://host/path/to/file` only created a new window on the first call. Subsequent invocations silently reused the existing SSH workspace for the same host, which then tried to open the new path against the existing worktree and surfaced a `DevServerProjectPathDoesNotExist` popup when the path didn't belong to any open worktree. The CLI correctly translated `--new` to `OpenBehavior::AlwaysNew`, but the URL branch of `handle_cli_connection` dropped the `open_behavior`. `handle_open_request` then called `open_remote_project` (and `open_paths_with_positions` for `file://`) with `OpenOptions::default()`, which is `WorkspaceMatching::MatchExact`, so any existing SSH window for the same host won the match. The issue applies to `file://` URLs and `-a` / `-e` / `--reuse` for URL-shaped arguments in general; `--new` was just the most visible symptom. The fix is making sure the translation of `OpenRequest` is uniform across plain paths and URL-shaped arguments. Closes zed-industries#52679. Release Notes: - Fixed `zed --new ssh://host/path` reusing an existing SSH window instead of opening a new one. This also applied to other URL-shaped path arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zed --new ssh://host/path/to/fileonly created a new window on the first call. Subsequent invocations silently reused the existing SSH workspace for the same host, which then tried to open the new path against the existing worktree and surfaced aDevServerProjectPathDoesNotExistpopup when the path didn't belong to any open worktree.The CLI correctly translated
--newtoOpenBehavior::AlwaysNew, but the URL branch ofhandle_cli_connectiondropped theopen_behavior.handle_open_requestthen calledopen_remote_project(andopen_paths_with_positionsforfile://) withOpenOptions::default(), which isWorkspaceMatching::MatchExact, so any existing SSH window for the same host won the match. The issue applies tofile://URLs and-a/-e/--reusefor URL-shaped arguments in general;--newwas just the most visible symptom.The fix is making sure the translation of
OpenRequestis uniform across plain paths and URL-shaped arguments.Closes #52679.
Release Notes:
zed --new ssh://host/pathreusing an existing SSH window instead of opening a new one. This also applied to other URL-shaped path arguments.