cli: Defer app activation until after open-behavior prompt#53915
Merged
Conversation
On macOS, the CLI uses LSOpenFromURLSpec to deliver the zed-cli:// URL to the running Zed app. With kLSLaunchDefaults, Launch Services activates (brings to foreground) the Zed app as a side effect of URL delivery. This happens before the IPC handshake completes and before the user can answer the terminal prompt asking whether to open in a new window or existing workspace, forcing them to manually switch back to the terminal. Fix this by adding kLSLaunchDontSwitch to the launch flags so macOS delivers the URL without activating the app. Then add cx.activate(true) in handle_cli_connection after the prompt resolves (or immediately for the URL-only path), so the app comes to the foreground at the right time.
Member
|
@zed-zippy approve |
loadingalias
pushed a commit
to loadingalias/zed
that referenced
this pull request
Apr 14, 2026
…tries#53915) On macOS, the CLI uses `LSOpenFromURLSpec` to deliver the `zed-cli://` URL to the running Zed app. With `kLSLaunchDefaults`, Launch Services activates (brings to foreground) the Zed app as a side effect of URL delivery. This happens before the IPC handshake completes and before the user can answer the terminal prompt asking whether to open in a new window or existing workspace, forcing them to manually switch back to the terminal. ## Fix **CLI side** (`crates/cli/src/main.rs`): Add `kLSLaunchDontSwitch` to the launch flags so macOS delivers the URL without activating the app. **App side** (`crates/zed/src/zed/open_listener.rs`): Add `cx.activate(true)` in `handle_cli_connection` after the prompt resolves (or immediately for the URL-only path), so the app comes to the foreground at the right time. Linux and Windows are unaffected — they use Unix sockets and named pipes respectively, which don't have activation side effects. Release Notes: - Fixed the Zed CLI activating the app window before the user answers the open-behavior prompt in the terminal.
eholk
added a commit
that referenced
this pull request
Apr 14, 2026
On macOS, the CLI uses `LSOpenFromURLSpec` to deliver the `zed-cli://` URL to the running Zed app. With `kLSLaunchDefaults`, Launch Services activates (brings to foreground) the Zed app as a side effect of URL delivery. This happens before the IPC handshake completes and before the user can answer the terminal prompt asking whether to open in a new window or existing workspace, forcing them to manually switch back to the terminal. ## Fix **CLI side** (`crates/cli/src/main.rs`): Add `kLSLaunchDontSwitch` to the launch flags so macOS delivers the URL without activating the app. **App side** (`crates/zed/src/zed/open_listener.rs`): Add `cx.activate(true)` in `handle_cli_connection` after the prompt resolves (or immediately for the URL-only path), so the app comes to the foreground at the right time. Linux and Windows are unaffected — they use Unix sockets and named pipes respectively, which don't have activation side effects. Release Notes: - Fixed the Zed CLI activating the app window before the user answers the open-behavior prompt in the terminal.
eholk
added a commit
that referenced
this pull request
Apr 14, 2026
Cherry-picks three PRs that add the CLI first-run open behavior prompt to the v0.232.x release branch: 1. #53663 — cli: Add first-run prompt for default open behavior and abstract IPC transport 2. #53839 — Guard CLI first-run prompt with agents-v2 flag 3. #53915 — cli: Defer app activation until after open-behavior prompt The fourth commit is a fixup that: - Adds `AgentV2FeatureFlag` to `feature_flags`, since it was added to main after the v0.232.x branch point - Bumps storybook's `dialoguer` dep from a pinned 0.11.0 to the workspace version (0.12), unifying the duplicate `dialoguer` and `console` crate versions in Cargo.lock Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <[email protected]>
piper-of-dawn
pushed a commit
to piper-of-dawn/zed
that referenced
this pull request
Apr 25, 2026
…tries#53915) On macOS, the CLI uses `LSOpenFromURLSpec` to deliver the `zed-cli://` URL to the running Zed app. With `kLSLaunchDefaults`, Launch Services activates (brings to foreground) the Zed app as a side effect of URL delivery. This happens before the IPC handshake completes and before the user can answer the terminal prompt asking whether to open in a new window or existing workspace, forcing them to manually switch back to the terminal. ## Fix **CLI side** (`crates/cli/src/main.rs`): Add `kLSLaunchDontSwitch` to the launch flags so macOS delivers the URL without activating the app. **App side** (`crates/zed/src/zed/open_listener.rs`): Add `cx.activate(true)` in `handle_cli_connection` after the prompt resolves (or immediately for the URL-only path), so the app comes to the foreground at the right time. Linux and Windows are unaffected — they use Unix sockets and named pipes respectively, which don't have activation side effects. Release Notes: - Fixed the Zed CLI activating the app window before the user answers the open-behavior prompt in the terminal.
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.
On macOS, the CLI uses
LSOpenFromURLSpecto deliver thezed-cli://URL to the running Zed app. WithkLSLaunchDefaults, Launch Services activates (brings to foreground) the Zed app as a side effect of URL delivery. This happens before the IPC handshake completes and before the user can answer the terminal prompt asking whether to open in a new window or existing workspace, forcing them to manually switch back to the terminal.Fix
CLI side (
crates/cli/src/main.rs): AddkLSLaunchDontSwitchto the launch flags so macOS delivers the URL without activating the app.App side (
crates/zed/src/zed/open_listener.rs): Addcx.activate(true)inhandle_cli_connectionafter the prompt resolves (or immediately for the URL-only path), so the app comes to the foreground at the right time.Linux and Windows are unaffected — they use Unix sockets and named pipes respectively, which don't have activation side effects.
Release Notes: