# cli: Defer app activation until after open-behavior prompt \(\#53915\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/11edacfd0f8adde4f8d554598b405b65ac8b7605)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 11edacfd0f8adde4f8d554598b405b65ac8b7605

Requested commit: 11edacfd0f8adde4f8d554598b405b65ac8b7605

Commit: 11edacfd0f8adde4f8d554598b405b65ac8b7605

Tree: 3e86c3396c20e6a48205c4d523240d219764cc08

Author: Eric Holk

Committer: GitHub

## Message

```
cli: Defer app activation until after open-behavior prompt (#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.
```

## Parents

- [c8b3da6ed9b2ab5a7f9ed1e71442168d3f151e41](https://git.cafe/gitcafe/zed/commit/c8b3da6ed9b2ab5a7f9ed1e71442168d3f151e41?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/11edacfd0f8adde4f8d554598b405b65ac8b7605?format=markdown)
