Commit Graph

310 Commits

Author SHA1 Message Date
tidely c31063a050 rust: Adopt trim_{prefix,suffix} (#67367)
## Summary

Remove verbose syntax pattern by adopting `trim_{prefix,suffix}`, which
sometimes saves clones or other work.

`value.strip_suffix(pattern).unwrap(value)` ->
`value.trim_suffix(pattern)`
`value.strip_prefix(pattern).unwrap(value)` ->
`value.trim_prefix(pattern)`

I also found a common pattern of `.starts_with` before `strip_prefix`,
which the latter already checks for implicitly.

## Testing

Tests pass, no behavior changes.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- N/A
- [GPUI] N/A
2026-11-23 14:40:35 +00:00
Kirill Bulatov f126950f9d Stop two clients from fighting over one remote server (#67336)
Opening a remote project while its workspace was still reconnecting
started a second client with the same `workspace-{id}` server
identifier. The new proxy killed the old server, the old client's
reconnect attached to the new server, and each reconnect killed the SSH
master that both clients shared, so neither connection settled. The new
client then waited out the full 60s initial timeout although its proxy
had already exited with 255.

- `open_remote_project` now focuses a workspace that is reconnecting and
waits for the reconnect to end, instead of starting a second client.
- A new `RemoteClient` stops any older live client with the same
identifier and cancels its reconnect loop, which covers the entry points
that skip workspace matching.
- The initial connection fails as soon as the proxy exits, instead of
after the 60s timeout.

Release Notes:

- Improved remote server reconnect for the same workspace
2026-11-22 20:21:18 +00:00
tidely 4fd48c02ac Miscellaneous improvements to prepare for Rust 1.100 (#66901)
## Summary

Fixes rustc and clippy warnings for a potential upcoming Rust 1.100
version bump. All changes are backwards compatible and Rust is **not**
bumped in this PR.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- N/A
- [GPUI] N/A

---------

Co-authored-by: Finn Evers <finn.evers@outlook.de>
2026-11-13 11:45:35 +00:00
Ivan K. 73ad8e3ed0 Fix opening ssh:// links with a drive letter on Windows remotes (#66814)
## Summary

Closes #66813

`ssh://host/C:/project` (and `zed://ssh/host/C:/...`) sends
`/C:/project` to the remote, because a URL path keeps a `/` before a
Windows drive letter. A Windows remote server cannot canonicalize that
path (os error 123), so the project fails to open with
`DevServerProjectPathDoesNotExist`.

This is a follow-up to #66497, which fixed the same leading `/` for
local `file://` and `zed://file` links. That fix could not be reused
here: it checks the local OS while the URL is parsed, and for SSH the
remote's OS is only known after connecting. This change strips the slash
in `determine_paths_with_positions`, which runs after the connection and
can ask the remote for its path style. Paths on Unix remotes and `/~`
paths are left alone.

Before (Zed 1.27.0):

<img width="420" height="225" alt="zed-ssh-drive-letter-error"
src="https://github.com/user-attachments/assets/ee33b4e7-4dae-43a1-8bfa-8b85c8302ebe"
/>

After (this branch, same URL):

<img width="620" height="140" alt="zed-ssh-drive-letter-fixed"
src="https://github.com/user-attachments/assets/a937839c-f8ba-4f2e-9fb0-9ca1a91380be"
/>

## Testing

- Windows 11 Pro with OpenSSH Server, connected to itself over
`localhost` (setup in #66813).
- Zed 1.27.0: `zed
ssh://zed-win-repro/C:/Users/<user>/zed-ssh-repro/project` fails with
`DevServerProjectPathDoesNotExist path=/C:/...`.
- This branch, debug build, with the remote server built from the same
commit: the same URL opens the project, and the worktree is
`C:\Users\<user>\zed-ssh-repro\project`.
- `cargo test -p recent_projects --lib remote_connections`: 6 passed,
including the new `test_strip_slash_before_drive_letter`, which covers
both path styles and the paths that must stay unchanged.
- `cargo clippy -p recent_projects --tests`: no warnings.

To test a debug build against a Windows remote: the debug remote server
panics outside the checkout ("dev asset loading requires running from
within the checkout"), so build it with `cargo build -p remote_server
--features util/debug-embed` and set `ZED_COPY_REMOTE_SERVER` to
`target/debug/remote-server.exe`.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist). (No UI
changes.)
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed `ssh://` links with a drive letter (for example
`ssh://user@host/C:/project`) failing to open a project on a Windows
remote.
2026-11-12 21:00:35 +00:00
Kirill Bulatov cebd5fc600 remote: Retry the POSIX environment probe without stdin (#66737)
Closes https://github.com/zed-industries/zed/issues/66587
Follow-up to https://github.com/zed-industries/zed/pull/66097

Release Notes:

- Fixed SSH connections failing with "Missing remote shell" when the
remote shell's startup reads from stdin
2026-11-09 11:17:34 +00:00
Azeem Shaik 2311b2497c git_ui: Stop remote branch switches resending the full commit graph (#65436)
## Summary

Closes #64605

Switching branches in a remote project streams the entire commit graph
from the server to the client, even with the History tab closed. On the
reporter's 313k-commit clone that is about 27 MB per switch, on the same
SSH connection the terminal and file-open requests are waiting on. The
same transfer happens once on every remote project open.

The Git panel reacts to every repository change with
`preload_commit_history`, which asks the repository for `0..0` commits
so the data is ready if the user opens History. The range only limits
what is read back from the cache. If the cache is empty, because
`HeadChanged` just cleared it, a full `git log` starts anyway, and for a
remote project `GetInitialGraphData` streams every commit regardless of
range.

`preload_commit_history` now returns early when the project is not
local. Local projects keep the preload, where it is a background `git
log` and no bytes cross a wire. Remote projects load history when the
user opens the History tab, through `load_commit_history`, which already
does that.

This trades a remote stall for a remote delay on first open: the first
time History is opened over SSH it shows the loading state while the
graph streams, instead of being ready. That is the same transfer that
happens today, moved to the moment the user asks for it, and skipped if
they never do.

The preload was not achieving readiness on remote projects anyway. A
branch switch reaches the client as a head change followed by a
branch-list change, and the branch-list change clears the cache the
preload just filled. When the two arrive together the fetch is cancelled
before its request leaves. When they arrive apart, the request has
already gone out and the host streams the full graph into a cache entry
that no longer exists.

The follow-up that pages the remote graph transfer, so the History tab
and Git graph load incrementally, is open as a draft in #65442.

## Testing

Added
`collab::git_tests::test_ssh_branch_switch_does_not_fetch_history`, an
SSH project built with `build_ssh_project` against a headless server:

1. Opens the project with the Git panel on Changes and checks no history
fetch started.
2. Switches the host to another branch, checks the client sees it, and
checks no history fetch started.
3. Opens History through `ActivateHistoryTab` and checks exactly one
fetch ran and the panel lists the host's commits.

Fetches are counted where they start on the client, through a test-only
counter on `Repository`, not by inspecting the cache, because the
branch-list update after a switch clears the cache and would hide a
fetch that had already started. With the fix removed, the test fails at
step 1 with `opening the project with Changes selected should not fetch
history`, and with that check relaxed it fails at step 2 with `switching
branches with Changes selected should not fetch history`.

Green: `cargo test -p collab --test collab_tests git_tests` (14), `cargo
test -p git_ui` (180), `cargo test -p project --lib git_store` (25),
`./script/clippy -p project -p git_ui -p collab --tests`.

To reproduce by hand: open a large repository over SSH, leave the Git
panel on Changes, switch branches in the terminal, and watch the
connection; after this change nothing is transferred.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist). No UI
changes.
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed branch switches in remote projects resending the full Git
history over SSH, which stalled the terminal and file opening until the
transfer finished

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-11-09 06:08:18 +00:00
Xin Zhao 784374c679 remote: Fix Windows SSH commands when the default shell is Nushell (#65580)
## Summary

Closes #65575

When connecting over SSH to a Windows remote server, Zed forwards
commands that need to be executed (for example terminals and tasks)
through `ssh`. The logic lives in `build_command_windows()` in
`crates/remote/src/transport/ssh.rs`. The command built on the client
looks like this:

```
ssh -t <remote_server> powershell -E <command_base64>
```

Zed passes `powershell -E <command_base64>` to `ssh` as the remote
command. The Windows OpenSSH server appends it as-is to
`<ssh_remote_shell> <shell_command_option>`, so the command that
actually runs on the remote server is:

```
<ssh_remote_shell> <shell_command_option> powershell -E <command_base64>
```

For `cmd.exe`, which is the default Windows OpenSSH server shell, the
final command is:

```
cmd.exe /c powershell -E <command_base64>
```

This works fine. However, if the default shell is changed to `nu`, the
final command becomes:

```
nu -c powershell -E <command_base64>
```

Here `nu` treats `powershell` as the only command to execute and passes
`-E <command_base64>` to itself as flags. `-E` is not a flag of `nu`, so
we get the following error:

```
The nu command doesn't have the flag '-E'
```

To fix this, the command is now wrapped in literal quotes when it is
sent, so that the command line executed on the remote server becomes:

```
<ssh_remote_shell> <shell_command_option> "powershell -E <command_base64>"
```

This way, `powershell -E <command_base64>` is always interpreted as a
single command, regardless of the shell.

## Testing

I checked the process creation on the Windows remote with Procmon:

- Before the change, `nu` was launched as `nu -c powershell -E
<command_base64>`.
- After the change, it is launched as `nu -c "powershell -E
<command_base64>"`, which runs successfully.

I also manually tested `nu`, `pwsh`, `powershell`, and `cmd` as the
Windows OpenSSH server default shell. Terminals and tasks work correctly
with all of them.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [ ] Tests cover the new or changed behavior.

Release Notes:

- Fixed the remote terminal and tasks failing on Windows SSH servers
whose default shell is Nushell
2026-11-04 14:08:18 +00:00
Yossi Eliaz 6569db7470 remote: Accept shell-quoted ssh executable in SSH command lines (#66360)
## Why

Remote Projects accepts either a bare destination or a full `ssh ...`
command. Commands that tools print with every token shell-quoted (for
example `'ssh' '-p' '64042' 'user@127.0.0.1'`) work in a shell but Zed
rejects them with `unsupported argument`. The goal is that any valid SSH
command pasted into **Connect New Server** parses the same way whether
or not its tokens are quoted.

Closes #61101

## Summary

`SshConnectionOptions::parse_command_line` stripped a literal, unquoted
`ssh ` prefix from the raw string before tokenizing. With a quoted
`'ssh'`, the prefix didn't match, so after tokenizing `ssh` became the
hostname and the real destination was rejected as an extra argument.

This change tokenizes first and then drops a leading `ssh` token when
more tokens follow. A lone `ssh` is still treated as a hostname, as
before.

## Testing

- Added `test_parse_command_line_with_ssh_executable` covering unquoted,
single-quoted (including an identity path with spaces), and
double-quoted `ssh` executables, plus `ssh` used as a host. It fails on
`main` with `unsupported argument: "user@127.0.0.1"` and passes with
this change.
- `cargo test -p remote`: 56 passed
- `cargo fmt -p remote -- --check`
- `./script/clippy -p remote`

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist). (No UI
changes.)
- [x] Tests cover the new or changed behavior.

AI disclosure: this change was AI-assisted. I reviewed the diff and the
test.

Release Notes:

- Fixed Remote Projects rejecting SSH commands whose `ssh` executable is
shell-quoted.
2026-11-02 12:01:06 +00:00
Lukas Wirth 2c2f737ab2 gpui: Add sendable foreground execution for web HTTP clients (#66165)
## Summary

This cleans up the gpui_platform code a bit, and in combination the way
we set up the http client for the web. This does introduce a
`ForegroundExecutor` variant that it itself is Send-able, allowing to
dispatch foreground futures from background workers (by requiring the
future to be Send, unlike `ForegroundExecutor`), which is a requirement
for web fetch.

a31c7b54c60738b82524e4e4c12aec2f6caf101d fixes a bunch of warnings with
our binary names

Release Notes:

- [gpui] N/A
2026-10-29 09:12:10 +00:00
狐狸 fae4b2ea4f workspace: Fix local file opens with remote workspaces (#65771)
## Summary

Closes #58773

While working on this, I noticed that project grouping and workspace
lookup used different connection comparisons. I unified them around the
existing `RemoteConnectionIdentity`.

I also simplified the relevant code, removing redundant lookup and
comparison helpers and borrowing values instead of cloning them when the
caller only needs to read the data.

## Testing

Added corresponding test coverage

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed local files opening as empty buffers in remote workspaces.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-10-28 15:21:57 +00:00
Kirill Bulatov 18f9d7e731 Fix pwsh-related issues with local and remote env variables detection (#66097)
Closes https://github.com/zed-industries/zed/issues/65931
Closes https://github.com/zed-industries/zed/issues/66021
Closes https://github.com/zed-industries/zed/issues/66094

Follow-up to https://github.com/zed-industries/zed/pull/65065

Release Notes:

- Fixed pwsh-related issues with local and remote env variables
detection
2026-10-25 08:21:37 +00:00
Ryan Brue 42c4caa474 remote: Stop URL-encoding SSH usernames (#64744)
The username was percent-encoded when building the SSH destination, a
leftover from when the destination was an `ssh://` URL (#25314). Since
the destination is now passed as a plain argument, the encoding turned
domain usernames like `DOMAIN\user` into `DOMAIN%5Cuser`, and
authentication failed.

Pass the username verbatim instead. So that a username beginning with
`-` can't be parsed as an option, `ssh` now receives it via `-l
<username> -- <host>` rather than a `username@host` string, and
`scp`/`sftp` (which have no username option, and forward it to `ssh` via
`-l` themselves) get `--` before their operands. Options that used to
follow the destination (`-T`, and `-t` for the Windows master process)
are moved before `--` so they aren't sent as part of the remote command.

Fixes #63709
Closes #63722

Assisted-by: LLM

NOTE: This is a continuation of #63722. I chose to leave Shaik Shahid
Afridi as the primary author, because I'm just resolving the review
comments from that PR.

In responding to the review comments, we also improve SSH/SCP for
usernames starting with `-`, because we now use `-l` for SSH and `--`
for SFTP/SCP, though I'm not sure if OpenSSH would accept a username
starting with `-` anyways. Nevertheless, an improvement over what came
before.

# Objective

When attempting to connect to a remote with a backslash in the username
(or any other character that results in URL encoding), Zed would mangle
the resulting SSH command and the remote would not be usable.

## Solution

- Describe the solution used to achieve the objective above.
URL encoding in the SSH field is an artifact of when `ssh://` was used,
and is no longer needed.

## Testing

Tested by running Zed and attempting to connect to a remote with a
backslash in the user field (a Windows domain account). SSH succeeded,
but then I ran into a separate bug with `%PROCESSOR_ARCHITECTURE%` not
being expanded. I'll be looking into that in a separate PR.

```sh
2026-09-24T16:09:24-05:00 INFO  [remote::transport::ssh] Remote is windows: true
2026-09-24T16:09:38-05:00 ERROR [remote::transport] $SHELL is not set, falling back to cmd.exe
2026-09-24T16:09:38-05:00 INFO  [remote::transport::ssh] Remote shell discovered: cmd.exe
2026-09-24T16:09:39-05:00 ERROR [workspace::notifications] Prebuilt remote servers are not yet available for windows-%PROCESSOR_ARCHITECTURE%. See https://zed.dev/docs/remote-development
```

Tested on Linux x86_64, attempting to connect to a Windows x86_64
machine.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments **(N/A)**
- [ ] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines) **(N/A)**
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

**NOTE:** I mentioned it above, but just in case it was missed, there is
a separate bug with Zed not expanding `%PROCESSOR_ARCHITECTURE%`. I'll
probably look into that next, since I'm trying to get remote development
set up for my Windows machine.


[Screencast_20260924_160804.webm](https://github.com/user-attachments/assets/ce6c77fb-eea5-4cda-944e-50539bece61d)

---

Release Notes:

- Fixed an issue where SSH usernames containing `/` or `\` were
percent-encoded, preventing successful connections.

Co-authored-by: Shaik Shahid Afridi <81465960+Yooosless@users.noreply.github.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-10-21 19:10:22 +00:00
狐狸 b25dc09370 remote: Separate handshake and resync timeouts during remote reconnection (#65457)
## Summary

Remote reconnection previously reusing the heartbeat timeout (5 secs),
and started the resync timeout before the new connection completed its
handshake. As a result, the timeout could expire before the handshake
finished.

Refactored the code to introduce separate timeouts for the handshake and
resync, with the resync timeout starting after the handshake completes.

Also moved the tests previously located in the middle of the file to the
end.

## Testing

A new integration test.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Improved timeout handling for SSH reconnections
2026-10-14 16:08:57 +00:00
狐狸 4882254fae remote: Batch SSH environment queries (#65065)
## Summary

Connecting to my server I regularly use takes about 4 seconds. Previous
implementation used 3 sequential commands to detect the remote
environment, since windows does not support multiplexing, these queries
alone could take around 12 seconds.

This change batches those queries into a single script.

## Testing

Added some unit tests for the parsing logic, although they are still
fairly example-based. I tested the changes on my own machines as well.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Batch SSH environment queries

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-10-07 15:39:18 +00:00
Kirill Bulatov 7ca96c2a58 Keep remote agent secrets out of launcher arguments (#65174)
Closes https://github.com/zed-industries/zed/issues/64511

Release Notes:

- Fixed remote agent secrets exposed in the launcher arguments
2026-10-07 15:35:34 +00:00
Kirill Bulatov d544470d1d Reduce the dependency footprint (#65176)
Follows-up https://github.com/zed-industries/zed/pull/64862 with similar
fixes:

* replaces a few dependencies that are almost not used, removes unused
dependencies
* removed unused features
* removes `test-support` dependencies from the regular tree
* cleans up build scripts

Despite the large diff, the changes are rather mechanical, split by
commits.
Result:
<img width="1172" height="77" alt="image"
src="https://github.com/user-attachments/assets/7d8aeb58-7cec-4246-8157-d07fc585f81f"
/>

Release Notes:

- N/A
- [GPUI] N/A
2026-10-05 12:44:26 +00:00
狐狸 e4945b5d09 remote: Reuse the known OS when reconnecting over SSH (#65024)
## Summary

The OS should not be re-probed during remote reconnection.

## Testing

Just a simple refactoring.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [ ] Tests cover the new or changed behavior.

Release Notes:

- Reuse the known OS when reconnecting over SSH

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-10-05 07:30:35 +00:00
Xin Zhao 64406cc2a8 remote: Use cargo-xwin to cross build Windows remote server on Unix system (#64787)
## Summary

When running the dev version of Zed and trying to connect to a remote
server, Zed triggers a local build of `remote_server` and uploads it to
the remote. When the local host is different from the remote, Zed uses
`cargo-zigbuild` to cross-build the `remote_server` binary. When the
local host is Windows and the remote is a Unix system, it just works,
but in reverse, it does not.

The truth is, I have never been able to cross-build the Windows
`remote_server` binary on my Linux machine; it always throws an error in
the linking stage. Apart from that, even when using some dirty hacks, I
can have the binary built and uploaded, but there are still two
problems:
- the `remote_server` binary size is very big, larger than 1.0 GB
- it is very unstable, always exiting shortly after the connection.
Partly it is because we are cross-building a gnu version binary:

https://github.com/zed-industries/zed/blob/e52ab15eac51e5644da6a3c9e1fac9bb2330b000/crates/remote/src/transport.rs#L293-L307

So in the past, to test if a remote fix works, I needed to first push
the fix, ssh to the remote Windows server, pull the changes, and build
the `remote_server` directly on that Windows machine, then manually copy
the binary to the directory where Zed stores remote servers. Not a fan
of this at all anymore.

So here, instead of using `cargo-zigbuild` to cross-build the Windows
`remote_server` on Unix-like platforms, we change to `cargo-xwin`, which
is designed to cross-build the msvc version of Windows programs from
Unix-like systems. From my local test, it can do the work perfectly, and
the produced binary size is about 200 MB, the same as the binary built
directly on a Windows machine, and more importantly, it is very stable,
with no dropped connections or crashes.

I suspect there are some concerns:
1. When first running `cargo xwin`, some Windows-sdk files are
downloaded and cached.
2. If we need to use `cargo-xwin`, we need to accept the Microsoft
license: https://go.microsoft.com/fwlink/?LinkId=2086102
3. In the final linking process, there are always some warnings,
typically:
```
         lld-link: Cannot use debug info for 'libcmt.lib(dyn_tls_dtor.obj)' [LNK4099]
         >>> failed to load reference 'D:\a\_work\1\s\binaries\amd64ret\lib\amd64\libcmt.amd64.pdb': No such file or directory

         lld-link: Cannot use debug info for 'libcmt.lib(initsect.obj)' [LNK4099]
         >>> failed to load reference 'D:\a\_work\1\s\binaries\amd64ret\lib\amd64\libcmt.amd64.pdb': No such file or directory

         lld-link: Cannot use debug info for 'libvcruntime.lib(softmemtag.obj)' [LNK4099]
         >>> failed to load reference 'D:\a\_work\1\s\binaries\amd64ret\lib\amd64\libvcruntime.amd64.pdb': No such file or directory
```

## Testing

You can just run the following commands on a Linux or Mac machine to
test the `cargo-xwin` build of `remote_server`:
```bash
rustup target add x86_64-pc-windows-msvc

cargo install --locked cargo-xwin

cargo xwin build -p remote_server --target x86_64-pc-windows-msvc
```

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [ ] Tests cover the new or changed behavior.

Release Notes:

- N/A

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-26 11:49:59 +00:00
Kirill Bulatov 20fa2fa809 Reduce LLVM IR bloat one last time (#63882)
I think this is the final attempt of mine to do anything about the
binary size, as those fixes become relatively intricate and I like them
less and less.

Each commit has its own improvement stats and mainly reduce generic-code
duplication through shared non-generic helpers and `#[inline(never)]`
boundaries.

Total reduction stats:

With sccache disabled, `cargo clean` and `cargo build --release -p zed`:
Before: zed binary 396716472 bytes
After: zed binary 359416504 bytes (-9.40%, -37.29MB)

Release Notes:

- N/A

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-09-07 15:18:49 +00:00
Jake Nelson ba6b83f89d workspace: Add configurable window title formatting (#54379)
## Summary
- Add `window_title_format` and `window_title_separator` settings for
customizing the window title
- Expose `${projectName}`, `${fileName}`, `${filePath}`,
`${relativePath}`, `${fileStem}`, `${remoteName}`, `${remoteHost}`,
`${appName}`, and `${separator}` as the native Zed window-title
variables
- Keep the collab `↗/↙` indicator hard-appended
- Translate VS Code `window.title` / `window.titleSeparator` aliases
into Zed's canonical variables during settings import, including
`${appName}` passthrough support and mapping VS Code's
`${activeEditorMedium}` onto Zed's `${relativePath}`
- Gate path-, remote-, and release-channel-derived lookups on whether
the active template references the corresponding variable, so the
default template avoids the extra work and still uses the existing
`last_window_title` cache to skip redundant platform updates

An alternative approach is at #49638. I went with `${variable}` names
over `$ZED_*`, canonical Zed variable names with VS Code aliases handled
at import time, kept `${separator}` as the only structural token, and
left `${dirty}` out of scope.

## Implementation reasoning and notes

### Variables considered but not included
- **collab/shared indicator variable**: kept hard-appended instead.
Folding it into the template would need whitespace/separator logic the
other variables don't need, and I'd rather not bake those semantics in
without a concrete need for it.
- **dirty variable**: The glyph choice and interaction with OS-level
edited indicators (like macOS's titlebar dot via `set_window_edited`)
felt like a separate design call I wasn't confident making here.

A separator-style config for each of collab/shared/dirty would solve the
above, but I didn't want to add too many additional settings initially.

### Performance
`update_window_title` is on a hot path, so two short-circuits apply:
- Path-, remote-, and release-channel-derived lookups (`absolute_path`,
relative-path string, `file_stem`, `remote_connection_options`,
`ReleaseChannel::try_global`) are gated on `template.contains(...)` via
`WindowTitleNeeds::from_template`, so the default template avoids the
extra work.
- The existing `last_window_title` cache still skips the platform call
when the rendered title is unchanged.

## Screenshots

Settings Editor entries for `window_title_format` and
`window_title_separator`:
<img width="774" height="324" alt="Settings Editor screenshot"
src="https://github.com/user-attachments/assets/b3378ec7-5649-4de3-9de6-164a42bce3fd"
/>

Customized Zed window titles in AltTab app switcher (remote, local,
empty):
<img width="774" height="324" alt="AltTab app switcher screenshot"
src="https://github.com/user-attachments/assets/a189945e-fc68-41b9-aab9-6dc04d5ef4ab"
/>

## Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #14534

Release Notes:

- Added configurable window title formatting with `window_title_format`
/ `window_title_separator`, including `${appName}` / `${remoteName}` /
`${remoteHost}` variables and VS Code `window.title` import support

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-04 13:48:58 +00:00
Coinleft LFT 1057c2cf3d Redact environment secrets from dev container docker exec logs (#63606)
# Objective

Fixes #63569

`run_docker_command` Debug-formatted the whole `docker exec` command, so
every `-e NAME=VALUE` pair forwarded into a dev container was written to
`Zed.log` in plaintext: once at DEBUG, and again in the error message
that `remote_client.rs` logs at ERROR on a failed reconnect.

## Solution

Render the command with `redact_arguments`, which replaces the value of
every `-e NAME=VALUE` argument with `<redacted>` before the arguments
are flattened, and pass the remaining arguments and stderr through
`util::redact::redact_command`.
Validate `containerEnv` and `remoteEnv` keys in `spawn_dev_container`
before any container is reused or built, because an empty key produced
`-e =VALUE`, which the Docker CLI rejects while echoing the value
verbatim to stderr.
Skip invalid names in `remote` as well, since `remote_env` is also
rehydrated from the workspace database.
The shared predicate lives in `util::redact::is_valid_environment_name`.

The DEBUG line now logs the redacted command and exit status only; the
previous stdout and stderr byte dumps are gone.

## Testing

`cargo test -p remote -p dev_container --lib`.
Unit tests cover redaction of forwarded env, argument boundaries,
assignments inside program arguments and stderr, invalid-name skipping
and rejection, and the podman CLI.

Release Notes:

- Fixed dev container environment variables being logged in full

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-04 03:02:13 +00:00
Conrad Irwin ee6badf4b0 Support building with corgi (#63396)
[corgi](https://github.com/ConradIrwin/corgi) is a cargo-compatible
build tool that runs `build.rs` scripts and proc-macros in a sandbox (no
network, no ambient env, reads limited to a package's own `.rs` sources
unless declared). This makes Zed buildable under it. Cargo builds (dev
and release) are unaffected.

### Changes

- **`scratch` patch**: patch `scratch` to a small local copy
(`corgi-patches/scratch`) that reads `OUT_DIR` at runtime instead of
baking it in at compile time. `cxx-build` writes its shared cxxbridge
headers into `scratch::path(...)`; upstream returns a single global dir
(outside any action's `OUT_DIR`) that the sandbox can't grant, while
this patch gives each build script a private, writable dir in its own
entry. webrtc-sys is self-contained, so per-crate scratch dirs are
sufficient. Kept local rather than a cxx git fork because a git checkout
of cxx needs symlink support that Windows cargo CI lacks.
- **Dev asset loading**: add `util::dev_fs_embed!` and switch dev-mode
`rust_embed` asset sources (`assets`, `settings`, `grammars`, `agent`,
`edit_prediction_cli`) to read from the checkout at runtime, locating
the repo root by walking from the executable up to the enclosing `.git`.
This avoids baking `CARGO_MANIFEST_DIR` into the binary (corgi rejects
artifacts that embed the build-time checkout path, and it's wrong in any
other worktree). Release builds still embed via `#[derive(RustEmbed)]`.
- **Stop baking checkout paths into artifacts**: drop
`gpui::GPUI_MANIFEST_DIR`; resolve `../gpui` from `gpui_apple`'s build
script; stage the metal shader into `OUT_DIR` before compiling so the
`.metallib` records the output dir, not the checkout; resolve the repo
root at runtime in `remote` and `inspector_ui` (removing
`inspector_ui`'s `build.rs` / `ZED_REPO_DIR`).
- **corgi.toml**: declare the pinned tools (`cmake`, prebuilt libwebrtc
via `LK_CUSTOM_WEBRTC`), a release-only `ZED_COMMIT_SHA` probe, and the
non-`.rs` / cross-package reads each package performs.

### Validation

- `corgi check` + `corgi build`, dev and release, for `zed` (plus `cli`,
`remote_server`, `ep`) with a warm C++ cache — clean; built binaries
embed no checkout path.
- `corgi fmt --check`, `corgi clippy`, and `corgi test` on the changed
crates (922 tests pass).
- `cargo check -p util` locally; relying on CI for the full cargo
build/test matrix.

### Notes for the reviewer

- Per the repo rule, the first two lines of `README.md` are the
review-confirmation marker; remove them before merging (this is what
Danger is failing on).
- `remote_server` cross-compilation (linux-musl via zigbuild) is not yet
covered by `corgi.toml` — host (macOS arm64) only for now.

### Suggested .rules additions

Only if the team wants corgi guidance in `.rules` (it recurred several
times here): dev builds must not bake the checkout path into artifacts —
no `env!("CARGO_MANIFEST_DIR")` or `file!()`-derived absolute paths in
library/binary output. Resolve the repo root at runtime via
`util::dev_repo_root()` (walks to `.git`), and use `util::dev_fs_embed!`
for dev-mode `rust_embed` sources.

Release Notes:

- N/A

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2026-08-31 17:37:00 +00:00
Vance 1e2e422c7b Fix settings schema missing extension-provided LSP settings on remote (#62355)
## Objective

Fixes an issue where language servers provided by extensions are not
included in the settings schemas served by remote servers. When
connecting to a remote server via the
`open_remote_project_with_existing_connection` flow (dev servers,
multi-workspace reopen, git worktree picker), setup-N servers never
received any extension sync, so their schemas omitted extension-provided
language servers, breaking language support for remote development.

## Solution

Three changes ensure that language servers provided by extensions are
included in the settings schemas served by remote servers:

1. **Register connections opened via
`open_remote_project_with_existing_connection` with the extension
store**: dev servers, multi-workspace reopen, and the git worktree
picker now register their connections with the extension store so that
extensions are synced to those servers. Previously only the
`open_remote_project` flow did this, so setup-N servers never received
any extension sync and their schemas omitted extension language servers.

2. **Emit `ExtensionsInstalledChanged` from `HeadlessExtensionStore`
after sync and install complete**: this allows the remote process to
invalidate its cached settings schemas. The local `ExtensionStore`
already emitted this event; without it, the remote schema cache stayed
stale for the lifetime of the server process.

3. **Include available LSP adapters in the project settings schema**:
this matches the user settings schema (this was fixed for `settings` in
#46766 but never applied to `project_settings`).

## Testing

- Manually verified that after connecting to a remote server via the
`open_remote_project_with_existing_connection` flow (including dev
servers and the git worktree picker), extension language servers appear
in the schema served by the remote server.
- Verified that `ExtensionsInstalledChanged` is emitted after sync and
install complete, and that the remote schema cache is correctly
invalidated and rebuilt.
- Verified that the `project_settings` schema includes the available LSP
adapters, matching the behavior of the user settings schema.
- Reviewers should focus on the multi-workspace reopen and git worktree
picker flows (the two previously unregistered flows) to confirm that
extension language servers are correctly synced and appear in the
schema.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase
**Server / Project** — before the fix
<img width="1061" height="749" alt="image"
src="https://github.com/user-attachments/assets/d6c5459f-58fb-4769-a701-f6fb317adc37"
/>
**Local**
<img width="1119" height="449" alt="image"
src="https://github.com/user-attachments/assets/fb30a1e2-74f0-4439-a25f-1022ed164074"
/>

---

Release Notes:

- Fixed an issue where language servers provided by extensions were
missing from settings schemas served by remote servers.

---------

Co-authored-by: vancez <vancez@users.noreply.github.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-08-27 17:09:28 +00:00
tidely fdad9186b8 git_ui: Dismiss askpass prompts when requests end (#61292)
# Objective

Fixes #47623

- When authenticating git commands using a security key through
`askpass`. The modal which asks for user presence does not get dismissed
even after the git command finishes successfully.

## Solution

Add a cancellation task to the `AskPassModal`, which gets dropped when
the requested operation completes. This cancellation task then dismisses
the modal.

## Testing

- I've tried authentication through `askpass` using my own security key.
Testing both successful and failed authentication.
- I've added tests which confirm that the modal gets dismissed when a
task is cancelled, and that the cancellation is triggered when
`ask_password` Task gets dropped.

Willing to pair on review, message me on Slack. Showcase video left out
because it would leak private information.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed authentication prompts not dismissing automatically when using
security keys with ssh
2026-08-18 10:02:20 +00:00
Tom daec37bdc5 remote: Fix missing path escaping in SFTP upload (#62239)
# Objective

- Fixes #62238
- Properly escapes paths in the sftp PUT line

## Solution

- 10-line wrapper function that escapes paths as sftp expects. Namely:
paths in quotes with `\\` and `"` escaped.

## Testing

- Did you test these changes? If so, how? `cargo check`
- Are there any parts that need more testing? Up to you, this is a
simple change and I dont think sftp with default install paths ever
worked on MacOS
- How can other people (reviewers) test your changes? Is there anything
specific they need to know? Just connect to a remote on OSX and see if
the logs had an sftp upload failure in there
- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fix remote uploads over sftp where the paths contain spaces

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-08-11 19:38:35 +00:00
Kirill Bulatov 1271f8b0e8 Bump rustc to 1.97 (#62395)
Release Notes:

- N/A
2026-08-09 22:29:52 +00:00
Travis McHenry e717010c82 Remote: Stream remote server into WSL on /mnt copy failure (#57624)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #47375


The current `crates/remote/src/transport/wsl.rs` remote transport code
tries to copy the remote-server from /mnt/c/* from within WSL. This
fails if you have automount disabled, or otherwise have your drive
unmounted.

How to reproduce this error:

Prerequisites: Windows with WSL2 and a WSL distro installed.

1. Inside the WSL distro, disable Windows automount — edit
`/etc/wsl.conf`:
```ini
[automount]
enabled = false
```

2. From a Windows shell: `wsl --shutdown`
3. Open the distro shell again and confirm `mount | grep /mnt/c` returns
nothing.
4. From Zed (any version before this PR), open a remote WSL project on
that distro for the first time (no cached
`~/.zed_server/zed-remote-server-*` inside the distro — `rm` it if
present).

The solution was to pipe the server in over stdin if the copy fails.
This is a fallback path similar to how ssh.rs has a fallback path if the
download fails there.

With this PR the logs look like this:
```
2026-05-24T18:51:37-07:00 INFO  [remote::transport::wsl] uploading remote server to WSL ".zed_server/download-72808-remote_server" (441187kb)
2026-05-24T18:51:37-07:00 WARN  [remote::transport::wsl] failed to upload remote server via /mnt, falling back to wsl.exe stdin: Command 'Command("wsl.exe" "--distribution" "Ubuntu" "--cd" "~" "--exec" "wslpath" "-u" "C:/Users/<user>/Documents/GitHub/zed/target/remote_server/x86_64-unknown-linux-musl/debug/remote_server")' failed: wslpath: C:/Users/<user>/Documents/GitHub/zed/target/remote_server/x86_64-unknown-linux-musl/debug/remote_server: Command 'Command("wsl.exe" "--distribution" "Ubuntu" "--cd" "~" "wslpath" "-u" "C:/Users/<user>/Documents/GitHub/zed/target/remote_server/x86_64-unknown-linux-musl/debug/remote_server")' failed: wslpath: C:/Users/<user>/Documents/GitHub/zed/target/remote_server/x86_64-unknown-linux-musl/debug/remote_server
2026-05-24T18:51:38-07:00 INFO  [remote::transport::wsl] uploaded remote server in 945.899ms
```

I considered making wsl just use curl/wget to download as a fallback, as
docker/ssh do, but that would lose the 'cache' effect of downloading
once on windows and sending to multiple WSL distros. Which seems to have
been the intent of the copy method in the first place.

I also considered using the network-drive style UNC mount to copy from
Windows to the WSL distro, but that could run into similar issues where
the user may have that disabled. It also seems to copy as WSL's default
user, rather than the --user specified to Zed for the distro. Currently
--user is not passed by default to wsl.exe, so that ends up being the
default user. However, it is settable through the settings.json, so some
rare users may still have an issue with ownership of the copied files.

I chose to make the new stdin option the fallback instead of the default
because the current code is working for most people, and it seemed like
a much larger change to replace the default.

For the tests there don't seem to be any tests for wsl.rs currently that
I can find, so it seemed like a lot of extra code needed to satisfy that
PR checkbox. wsl.rs and docker.rs have zero inline tests, and the ones
that are in ssh.rs don't cover the ensure/upload/download portion. The
integration tests seem to use RemoteClient::fake_server and bypass the
real transports.

For manual testing I tested these scenarios:
1. WSL distro with automount **on** AND existing binary: **still works**
2. WSL distro with automount **on** AND **no** existing binary: **still
works**
3. WSL distro with automount **off** AND existing binary: **still
works**
4. WSL distro with automount **off** AND **no** existing binary: **now
works**

I'm not all that proficient with rust so I used a coding agent to help,
but I reviewed every line and it all makes sense to me. Please let me
know if something looks off, I'm trying to learn.


Release Notes:

- Fixed remote server installation failing in WSL when automount is
disabled.

---------

Co-authored-by: Lukas Wirth <lukas@zed.dev>
2026-08-04 08:54:56 +00:00
cocool97 ce6f3af5f7 remote: Fix incorrect arguments passed to SCP & SFTP (#56080)
All arguments passed to the initial remote connection command were
initially blindly passed to `scp` or `sftp` command line.
This is an issue with some arguments like "-X" or "-Y" that either does
not exist, or have a different semantic.
This PR introduces a denylist of arguments before crafting the command
to execute.

Reproduce steps:

1. Create a new remote connection, e.g `ssh -X user@192.168.1.1`
2. Expect the upload of the remote server to fail with a message saying
that '-X' is not a valid argument for `ssh` / `sftp` depending on your
setup.

Self-Review Checklist:

- [X] I've reviewed my own diff for quality, security, and reliability
- [X] Unsafe blocks (if any) have justifying comments
- [X] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [X] Performance impact has been considered and is acceptable

Release Notes:

- Fixed wrong arguments that may be passed to scp or sftp command when
pushing remote files.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Lukas Wirth <lukas@zed.dev>
2026-08-02 09:09:11 +00:00
Duncan Ogilvie 6aed696155 Fix Devcontainer bugs/spec mismatches (#59020)
When testing Zed on our team's Devcontainer I found some missing
features/bugs/spec mismatches. Commit messages were written by hand,
code reviewed and tested manually, but everything was written by
Claude/Codex based on:

- https://github.com/devcontainers/cli
- https://github.com/devcontainers/spec

The main use case of the metadata is that you can `devcontainer exec`
and `devcontainer up` into a container Zed started (and vice versa). The
same with VSCode, it will reuse Zed's created devcontainer correctly
now. This is useful when using LLMs so they can run commands in the same
devcontainer you have open.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed Dev Container compatibility and lifecycle behavior.
2026-07-21 14:15:32 +00:00
Smit Barmase 2a983bca86 git: Fix operations timing out and commit-msg hook being skipped (#61185)
Closes #44926
Closes #43157
Closes #29903

We have an askpass 17s timeout that races against Git operations and
results in "Connecting to host timed out". It came along in #25953 when
we extracted askpass out of remoting, where it was used for SSH.

I think, for SSH connection, no prompt and no connection after 17
seconds means the host is unreachable, so the timeout is a reliable
signal there. But for Git, silence is pretty normal. Cases like hook
running, pack transferring, an ssh-agent waiting on a fingerprint are
all senarios where we should not be dependent on timeout which kills
these healthy operations.

#43285 worked around this for commits by running the pre-commit hook
manually and passing `--no-verify` to `git commit`. But, there are more
problems to address, which I reproduced on my machine:

1. A slow `post-commit` hook fails, since `--no-verify` doesn't skip it.
2. A slow `pre-push` hook fails too, and a workaround like #43285 needs
a lot more handling. See
https://github.com/zed-industries/zed/pull/42946#issuecomment-3550570438.
3. This is the tough one: due to `--no-verify`, we are also skipping the
`commit-msg` hook. There is no direct way to call that hook since, Git
hands this hook its in-progress message file, commits whatever the hook
leaves in it, and aborts if the hook exits non-zero. Reproducing that
outside `git commit` means reimplementing that.
4. An ssh-agent waiting for user approval fails after the timeout, like
if you have 1Password set up.
5. It doesn't solve large fetches. Fetching
`git@github.com:torvalds/linux.git` just dies at the 17s timeout
mid-download.

This PR fix keep the timeout only on the SSH transport and drop it for
Git, which is less of a behavior change and more of a restoring its
original scope. If Git in a terminal doesn't time out, we shouldn't
either. This way, we let Git handle all types of hooks, which solves the
hooks issue along with the timeout issue. _This follows how VS Code does
it. It does not have any kind of timeout on git child process, and hooks
are handled by Git itself._

Edit: I also think working towards way to cancel long going operations
is better way forward. See
https://github.com/microsoft/vscode/issues/171353.

Hooks still don't run for untrusted repositories, the existing
`core.hooksPath=/dev/null` clamp covers that. The `RunGitHook` proto
handler is kept for compatibility with older remote clients.




Release Notes:

- Fixed git operations failing with a misleading "Connecting to host
timed out" error when they took longer than 17 seconds (large fetches,
slow hooks, or waiting on agent-based authentication like 1Password
Touch ID).
- Fixed `commit-msg` hooks being silently skipped on commit.
2026-07-17 13:38:09 +00:00
Lukas Wirth f181a2f47b Split out RelPath into a separate crate (#61029)
This is necessary to remove some `util` dependencies from crates, as
well as better sharing for our projects. This also includes the WIP
AbsPath abstraction as well as some bug fixes from internal tooling.


Release Notes:

- N/A or Added/Fixed/Improved ...
2026-07-15 08:33:25 +00:00
Tom Houlé 2ab35c6b7d Consistently use context() to preserve sources for anyhow errors (#59112)
When you use `anyhow::anyhow!("{error}")` to convert a preexisting error
to an `anyhow::Error`, the error source can be lost (depending on the
`Display` impl of the error). Anyhow errors can display the whole source
chain when printed. This commit makes us consistently use `context()`
instead to preserve the underlying error's source.

Release Notes:

- N/A
2026-07-08 12:20:52 +00:00
Kirill Bulatov 632dcae287 Restore remote binary dev build output (#59997)
Follow-up of https://github.com/zed-industries/zed/pull/46695

cargo outputs to stderr, so if we do not inherit it, we do not see it,
yet this can be useful to understand what broke and see the progress.
I am not sure if there was a reason to remove it, hence creating the PR
to discuss — want to add at least a comment there for the future if we
decide to keep things as is.

Before:

<img width="1731" height="1022" alt="before"
src="https://github.com/user-attachments/assets/92bb0969-e495-41b0-8cac-1f85a83440a0"
/>

After:
<img width="1728" height="1086" alt="after"
src="https://github.com/user-attachments/assets/c733fb8b-adbe-44dc-84a5-48e2c9e63a38"
/>

Release Notes:

- N/A
2026-06-27 09:21:37 +00:00
Lukas Wirth 479bce0995 Implement telemetry for the remote server (#59692)
# Objective

Telemetry events generated **on a remote server** were silently dropped,
and all remote telemetry that *was* reported got attributed to the local
client's OS.

## Solution

This PR makes server-originated events flow to the telemetry pipeline
and attributes them to the actual remote host (connection type, OS,
version, architecture), plus adds a transport-agnostic connection event.

## Additional Notes

This removes the "SSH Project Opened" event and replaces it with a
"Remote Connection Established" one that has more structured info and is
also more useful in where it gets invoked.

The server unconditionally sends back telemetry to the client, the
client is then responsible for filtering on whether telemetry is enabled
by the user or not as the server does not have knowledge of those
settings itself.

Release Notes:

- N/A
2026-06-23 05:53:33 +00:00
Richard Feldman 29622911de Prevent archival of manually-created worktrees (#58275)
This fixes archive cleanup for agent threads so Zed only removes
worktrees it explicitly created, rather than treating every linked
worktree under the configured managed directory as safe to delete. When
Zed creates a worktree, it now records it in the local database along
with the creation time of the worktree's git metadata directory
(`.git/worktrees/<name>/`). Archive planning requires that record, and
right before deleting anything, Zed re-stats the directory and compares
creation times: if the worktree was removed and recreated outside Zed
(or the time can't be read at all), deletion is skipped and the stale
record is dropped. Every failure mode fails safe by leaving the
directory untouched.

For remote (SSH) projects, the stat runs on the remote host via a new
`GitWorktreeCreatedAt` request. Worktrees created by a different Zed
install (another release channel, or another machine connecting to the
same host) have no record in the local database and are therefore never
auto-archived, which is the intended conservative behavior.

Closes https://github.com/zed-industries/zed/issues/57155

Closes AI-352

Release Notes:

- Fixed archiving an agent thread incorrectly deleting manually-created
git worktrees.
2026-06-16 15:36:59 +00:00
Zaenalos 2b2536de0f Fix SSH askpass on Windows by invoking cli.exe directly (#52491)
On Windows, Zed generated a .ps1 askpass script and set **SSH_ASKPASS**
to 'powershell.exe -ExecutionPolicy Bypass -File ...'. SSH calls exec()
on SSH_ASKPASS which cannot exec a command string, causing:

error: ssh_askpass: exec(powershell.exe ...): No such file or directory

Fix by pointing **SSH_ASKPASS** directly to cli.exe and passing the
socket path via **ZED_ASKPASS_SOCKET** env var, which cli.exe reads
before clap parses arguments.

---
> Compiling Zed almost blew up my computer.
---

Related #29048 

Release Notes:

- Fixed some ssh issues on windows that prevented from connecting to a
remote
2026-06-08 09:37:00 +00:00
Lukas Wirth 55d5713de9 remote: Do not swallow ssh errors (#58780)
Release Notes:

- Fixed non-descriptive error messages when remote agent processed
disconnected
2026-06-08 08:48:09 +00:00
Nathan Sobo c30d18b10d scheduler: Add spawn_dedicated for single-threaded actors with !Send state (#57609)
Adds `scheduler::spawn_dedicated_thread` (and inherent `spawn_dedicated`
methods on `PlatformScheduler` and `TestScheduler`) so single-threaded
actors that own `!Send` state can run on their own OS thread and freely
do blocking I/O without disturbing any other executor.

### Why

A single-threaded actor that needs to do blocking syscalls is currently
stuck: it can't run on the shared foreground executor (blocking would
stall every other foreground session), and it can't move to the
background pool because its state isn't `Send`. `spawn_dedicated` gives
each such actor its own thread and its own `LocalExecutor`, while still
participating in the same testable scheduler infrastructure as
everything else.

### Shape

- `pub fn spawn_dedicated_thread(session_id, scheduler, f) -> Task<_>`
in `scheduler`. Owns the OS thread, the per-session runnable channel,
and the `LocalExecutor` setup.
- Inherent `spawn_dedicated` on `PlatformScheduler` (allocates its own
`SessionId`, delegates to the free function).
- Inherent `spawn_dedicated` on `TestScheduler` (no real thread — runs
as a fresh local session driven by the test scheduler's run loop, so
determinism under `many` is preserved).
- Renames `Scheduler::schedule_foreground` → `schedule_local` and
`scheduler::ForegroundExecutor` → `scheduler::LocalExecutor` to reflect
that these are session-pinned queues rather than "the main thread" (a
dedicated session runs on its own thread). GPUI's wrapper
`gpui::ForegroundExecutor` and the `foreground_executor` field/method
names are unchanged to keep blast radius small.
- `LocalExecutor::new` now takes an explicit dispatch closure, so the
routing decision (default session, dedicated thread, or something else)
lives at the construction site.

### Tests

- `TestScheduler` side: round-trip, `!Send` future, `Send` closure
capturing shared state, inner `executor.spawn`, determinism under `many`
seeds, drop-cancels-future, detached child runs after root completes.
- `PlatformScheduler` side: real separate thread (blocking syscalls
don't stall the test), `!Send` future output, drop-cancels-future,
thread tears down after work completes, detached child outlives root.

cc @as-cii

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2026-05-29 15:58:02 +00:00
Ben Kunkle 1dac14c53a Remove CRLF line endings (#57680)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-05-26 12:59:21 +00:00
Conrad Irwin be705e677b Merge gpui::Task and scheduler::Task (#53674)
Release Notes:

- N/A or Added/Fixed/Improved ...
2026-05-05 22:41:13 +00:00
Anthony Eid 149cd4e2bc git_graph: Add remote support for search operations (#55167)
### Motivation 

This is the second of three PRs to add remote/collab support for the git
graph and is a follow-up to #54468. I'm adding remote support for the
search because it's not user accessible without the initial graph fetch
having remote support, so it allows us to merge this without having to
add full remote support. Collab guest support will be added in a
follow-up PR.

#### Summary

For large repos, searching can take a while to fully stream in all
matched results. For example, running a basic search on the Linux repo
took over 10s for me. Because of that, we want to stream search results
in chunks to downstream users to keep the time-to-first-match low. After
this change, the first chunk gets sent back after ~50ms on the Linux
repo from receiving the request.

In order to accomplish that, I added a new proto client API that allows
for a request to map to n responses. e.g.

```/dev/null/example.rs#L1-1
client.add_entity_stream_request_handler(Self::handle_search_commits);
```

Note: The proto API isn't supported over collab yet, that will be
another PR

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
2026-05-04 16:38:14 +00:00
Nico a8cdff3739 remote: Reuse existing SSH ControlMaster sessions (#51604)
Closes #45271

Zed hardcodes `ControlMaster=yes` with a `ControlPath` in a random temp
directory, so it can never find a ControlMaster session the user already
has open. This means you get prompted for credentials again even if
you're already authenticated.

This patch checks for an existing master before spawning a new one. It
runs `ssh -G` to resolve the user's configured `controlpath` (with `%h`,
`%p`, etc. already expanded), then `ssh -O check` to verify it's alive.
If it is, Zed skips askpass and uses the existing socket. If not, the
current behavior is unchanged. Both commands are local and don't hit the
network.

Also adds a `killed: AtomicBool` to `SshRemoteConnection` because
`has_been_killed()` was using `master_process.is_none()` as a proxy for
"connection is dead." When reusing an external master, `master_process`
starts as `None`, so the connection pool would discard it immediately.

Tested against a university SSH setup with `ControlMaster auto`
configured. The reuse path connects without prompting, and the fallback
path works normally when no master exists. Windows is unaffected.

Release Notes:

- Zed now reuses existing SSH ControlMaster sessions instead of
prompting for credentials again (#45271).
2026-04-21 07:44:24 +00:00
Toni Alatalo ac02b1bf24 remote: Set current_dir for cargo zigbuild cross-compilation (#53951)
## Summary

- The cross-compile path for building `remote_server` via `cargo
zigbuild` was missing `.current_dir()`, causing it to inherit the
process cwd
- This fails with "cannot specify features for packages outside of
workspace" when Zed is launched from outside its source tree
- The native build path at the same location already sets
`.current_dir()` correctly — this aligns the cross-compile path

Closes #53950

## Test plan

- [x] Build Zed from source
- [x] Launch from `/tmp`: `cd /tmp && /path/to/zed some-project
--dev-container`
- [x] Verify dev container cross-compilation succeeds

Release Notes:

- Fixed dev container cross-compilation failing when Zed is launched
from outside its source directory

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-15 09:07:53 +00:00
Anthony Eid 0bbe9bff86 sidebar: Filter thread groups by remote host identity (#53918)
### Summary 

Follow up on: https://github.com/zed-industries/zed/pull/53550

Threads in the sidebar are now filtered by remote connection in addition
to path list. Previously, two different machines with the same absolute
project paths (e.g. both at `/home/user/project`) would have their
threads merged into a single sidebar group. Now each remote host gets
its own group.

To support this, this PR introduces `RemoteConnectionIdentity`, a
normalized subset of `RemoteConnectionOptions` that includes only the
fields relevant for identity matching (e.g. SSH host + username + port,
but not nickname or connection timeout). All remote host comparisons in
the sidebar, thread metadata store, and workspace persistence now go
through `same_remote_connection_identity()` instead of raw `==` on
`RemoteConnectionOptions`.

#### Follow Up on remoting for sidebar

1. Make the neighbor in archive thread fallback to the main git worktree
instead of the next thread
2. Start implementing remote git operations that archive feature depends
on
3. Make remote connection pool equality use `RemoteConnectionIdentity`

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2026-04-14 18:40:36 +00:00
KyleBarton 6143af13a3 Use stored home_dir in Docker struct, not literal $HOME (#53642)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A
2026-04-10 10:56:48 -07:00
Eric Holk d812adc833 sidebar: Better handling for threads in remote workspaces (#53451)
This PR greatly improves our handling of remote threads in the sidebar.

One primary issue was that many parts of the sidebar were only looking
at a thread's path list and not its remote connection information. The
fix here is to use `ProjectGroupKey` more consistently throughout the
sidebar which also includes remote connection information.

The second major change is to extend the MultiWorkspace with the ability
to initiate the creation of remote workspaces when needed. This involved
refactoring a lot of our remote workspace creation paths to share a
single code path for better consistency.

Release Notes:

- (Preview only) Fixed remote project threads appearing as a separate
local project in the sidebar

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2026-04-09 06:56:28 +00:00
Nitin K. M. 64b93202f8 Removal of mold/wild scripts and mentions in docs (#53078)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable


Release Notes:

- N/A

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 21:20:02 +03:00
Conrad Irwin ac6117a9d8 Fix shell escaping in getting current env (#53335)
Credit to Dario Weißer for bringing this to our attention.

Self-Review Checklist:

- [ ] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- Fixed a bug where a cleverly crafted directory name could lead to
remote code execution
2026-04-08 02:56:06 +00:00
Saketh eeb87cb177 remote: Use SSH nicknames in display names (#53103)
Closes #52943

## Summary
- Prefer SSH nicknames over raw hosts in remote connection display names
- Add regression tests for nickname and host fallback behavior

## Why
The `nickname` field is documented as the user-facing label for SSH
connections, but `RemoteConnectionOptions::display_name()` always
returned the raw host. That meant recent-projects UI surfaces kept
ignoring nicknames even when they were configured.

## Validation
- `cargo test -p remote ssh_display_name`
- `cargo test -p remote`

Release Notes:

- Fixed SSH recent-project labels to show configured nicknames instead
of raw hosts when available.
2026-04-03 18:55:40 -04:00
Eric Holk 45d6a9595f Track project groups in MultiWorkspace (#53032)
This PR adds tracking of project groups to the MultiWorkspace and
serialization/restoration of them. This will later be used by the
sidebar to provide reliable reloading of threads across Zed reloads.

Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2026-04-03 16:23:52 +00:00