Commit Graph

383 Commits

Author SHA1 Message Date
Kirill Bulatov b6ff193ba6 Stop showing worktree trust modal after "Stay in Restricted Mode" is called (#66649)
Closes https://github.com/zed-industries/zed/issues/58246

* Starts to remember "Stay in Restricted Mode" calls to avoid repeated
worktree trust pop-ups
* Uses `RemoteConnectionIdentity` instead of the prior type (removed) as
more detailed remote host identifier (has a port value now)
* Migrates worktree trust DB to that, more detailed, data format

Release Notes:

- Stopped showing worktree trust modal after "Stay in Restricted Mode"
is called
2026-11-11 21:17:08 +00:00
Ben Brandt 4ec98df500 acp: Update agent-client-protocol to 5.0.0 (#66425)
Upgrades `agent-client-protocol` from 3.6.0 (schema 1.13.0) to 5.0.0
(schema 1.15.1), and brings Zed's v1 and v2 ACP clients in line with the
spec and schema changes made since then.

## SDK 5 port

- Schema types move from `schema::v1`/`schema::v2` to
`v1::schema`/`v2::schema`, builders to `Client.v1()`, and v2 handle
types to `agent_client_protocol::v2`.
- `agent_client_protocol::Error` is now the SDK's own type, not the v1
schema error. Zed uses it at the SDK boundary, and `ProtocolErrorInfo`
also recognizes it so auth-required detection keeps working.
- Foreground dispatch helpers are generic over the protocol marker, and
v2 request IDs come straight from the handles.
- SDK 5 only matches transport-closed errors that the SDK itself
produced, so peers can't forge them. A test that built one by hand now
covers only the local disconnect case. The `agent_servers` tests still
cover real transport loss.

## Spec changes

- `session/close` and `session/delete`: a `-32002` response counts as
success, on both v1 and v2.
- Permission and elicitation requests that name an unknown session get
`-32002` with `data.sessionId` instead of `-32603`. The v2 migration
guide makes this required for Clients too.
- v2 `usage_update.cost` is a patch field: omitted leaves it unchanged,
`null` clears it. A v1 update without a cost still leaves it unchanged.
- A `plan_update` whose type Zed can't render (`file`, `markdown`, or an
unknown type) still replaces the plan with that `planId`, so the old
entries stop showing.
- A diff `patch` with an unrecognized `format` renders from `changes`,
as if `patch` were omitted.
- v2 never sends an empty prompt.
- On v2, `session/cancel` no longer answers pending permission requests
locally. They stay open until the agent cancels them with
`$/cancel_request`, because requests for background work survive a
cancel. v1, including v1 subagents, keeps answering them with
`cancelled`.

## Follow-ups

These are left for separate PRs:
- Background-work UI: the `paused` status, the `background` list, and
cancel buttons for tool calls and terminals. Until then, `paused`
displays as in progress, which the spec allows.
- Subagent `cwd` and `additionalDirectories`.
- The new unstable methods: `auth/status`, `session/set_title`,
`session/status`, `session/archive`.

Release Notes:

- Improved compatibility with the latest Agent Client Protocol,
including handling of missing sessions, plan updates, diff formats, and
cancellation of permission requests.
2026-11-02 15:26:50 +00:00
buvidk1234 e38d4ec980 Fix active repository selection after removing remote worktrees (#66299)
Removing a project folder containing the active Git repository from a
remote workspace could leave the Git panel showing “No Git Repositories”
and an “Initialize Repository” button, even when other Git repositories
remained open.

Select a remaining repository when the active repository is removed.
Preserve the current selection when removing another repository, and
clear it when the last repository is removed.

Testing:
- Added a regression test covering removal of an inactive repository,
the active repository, and the last repository.
- Confirmed the regression test fails before the fix and passes
afterward on Windows.
- Passed the existing remote worktree add/remove/re-add test.

Release Notes:

- Fixed the Git panel showing “No Git Repositories” after removing the
active repository's project folder from a remote workspace while other
repositories remain open.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-11-02 14:55:47 +00:00
max1ab 1d76f828ee Fix SVG images in remote Markdown previews (#66404)
## Summary

<img width="3024" height="1898" alt="zed-svg-ssh-after"
src="https://github.com/user-attachments/assets/d35454cc-9d27-4165-900a-00990f483e4e"
/>

Closes #64517

Fixes SVG images failing to display in remote Markdown previews by
adding content-based SVG support to ImageStore and using the existing
GPUI renderer.

## Testing

- Integration tests and Clippy passed.
- Manually verified with a macOS client connected to a Linux SSH
project.
- To verify: open a remote Markdown file containing `![](image.svg)` and
confirm the SVG displays in the preview.

## 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 SVG images failing to render in Markdown previews for remote
projects.
2026-11-02 09:16:49 +00:00
Andriy Massimilla 5a534d7b5d git: Add git auto fetch (#53089)
## Summary

Adds an opt-in periodic background `git fetch --all` for local
repositories, so remote-tracking branches and ahead/behind counts stay
current without a manual fetch.

Because the fetch runs unattended, it behaves differently from a
user-initiated fetch:

- **Trusted repositories only.** Re-checked on every tick, since a
worktree can be trusted or restricted at any point in a session.
- **Never prompts.** Credentials that need no interaction (e.g. an SSH
agent, or a credential helper answering from a keychain) still work.
Anything that would need input fails instead of blocking on a prompt
nothing will answer.
- **Silent.** No activity indicator in the status bar, since a spinner
every minute is noise. Failures are logged at debug level.
- **Stays out of the user's way.** It runs off the repository's serial
job queue, so status refreshes and staging aren't stalled behind the
network. A user-initiated fetch, pull, or push preempts an in-flight
background fetch rather than waiting for it.
- **Leaves the repository clean when stopped.** Stopping a fetch (a
settings change, preemption, closing the project) asks git to terminate
so it can remove its ref lockfiles, rather than killing it and leaving a
stale `.lock` behind that breaks every later fetch. It also never
triggers auto-maintenance on the user's behalf.

## Configuration

```json [settings]
{
  "git": {
    "auto_fetch": {
      "enabled": false,
      "interval_secs": 60
    }
  }
}
```

- `enabled` (default `false`): whether to fetch from all remotes in the
background.
- `interval_secs` (default `60`, clamped to a minimum of `15`): how
often to fetch.

Both are exposed in the settings UI under **Version Control > Git
Integration**, where the interval is only shown while auto-fetch is
enabled, and documented in `docs/src/reference/all-settings.md`.
Unrelated settings changes don't restart the timer.

## Implementation design

### `GitCaller`

The remote-capable `GitRepository` methods (`fetch`, `pull`, `push`,
`commit`) take a `GitCaller` instead of a bare `AskPassDelegate`:

```rust
pub enum GitCaller {
    /// A user started this and is waiting on it. Prompts route to the UI.
    User(AskPassDelegate),
    /// No user attached. Never prompts, and stops when the receiver resolves.
    Background(Option<oneshot::Receiver<()>>),
}
```

Every such command goes through `GitBinary::run_remote_command`, which
applies everything the caller implies. git, credential helpers, and ssh
each prompt through a different mechanism, so keeping the list in one
place means no call site can miss one. For `Background`:

| Prompt channel | Mitigation |
| --- | --- |
| git's own terminal prompt | `GIT_TERMINAL_PROMPT=0` |
| Credential helpers | `credential.interactive=false`, which is narrower
than clearing `credential.helper` so helpers that answer without
prompting keep working |
| askpass | `core.askPass=`, and `GIT_ASKPASS`/`SSH_ASKPASS` unset |
| ssh (key passphrases, host key confirmation) | `-o BatchMode=yes`
composed onto the ssh command git would otherwise use
(`GIT_SSH_COMMAND`, then `core.sshCommand`, then `ssh`), so custom ssh
commands keep working. Setups that only set the deprecated `GIT_SSH` are
left alone, since setting `GIT_SSH_COMMAND` would silently replace them.
|

`gc.auto=0` is also set, since auto-maintenance can repack the whole
repository. gpg's pinentry when signing isn't covered, as no background
caller signs.

### Cancellation

A background command is spawned with `kill_on_drop` and raced against
its cancel receiver, where a dropped sender counts as cancellation:

1. If already cancelled before spawning, git is never started.
2. On cancellation, git is sent `SIGTERM`
(`util::process::request_termination`), which runs its handlers that
remove lockfiles.
3. If it hasn't exited within a 2s grace period, it's killed.

Windows has no equivalent signal, so cancellation there is a kill.

### Scheduling

- Each repository has a timer task, restarted only when `enabled` or
`interval_secs` change.
- On each tick, the timer checks trust, then tries to acquire the
repository's `fetch_lock` semaphore and skips the tick if it's held. It
spawns a **detached** fetch task that holds the permit until the fetch
settles.
- `AutoFetchState.cancel` holds the sender, and is the only thing
bounding the fetch's lifetime. It's dropped on a settings change, on
preemption, and when the repository is dropped, so every way of stopping
a fetch goes through graceful cancellation.
- Running off the serial job queue is safe because auto-fetch mutates no
`Repository` state. It only updates remote-tracking refs, which git
guards with its own lockfiles, and the results reach the UI via the
resulting git directory rescan. Manual fetch stays on the queue, since
it also writes snapshot state via `refresh_branch_list`.
- `fetch`, `pull`, and `push` call `preempt_auto_fetch()`, which drops
the cancel sender, then wait on `fetch_lock` inside their job. That wait
is bounded by a cancelled fetch shutting down rather than by the
network, and stops them failing with "cannot lock ref" against a
background fetch.

## Test plan

`test_auto_fetch` covers:

- [x] An untrusted repository is never auto-fetched, and fetching begins
once its worktree is trusted
- [x] Timer fires on schedule, and again on the following interval
- [x] Unrelated settings change mid-interval doesn't reset the timer
- [x] Disabling `auto_fetch` stops all fetches
- [x] Re-enabling with a longer interval respects the new cadence

## Review
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

Addresses
#24611(https://github.com/zed-industries/zed/discussions/24611)

Release Notes:

- git: Added option (off-by-default) to automatically fetch upstream of
the current branch and default upstream of the project. Enable it with:
```
{
  "git": {
    "auto_fetch": {
      "enabled": false,
      "interval_secs": 60
    }
  }
}
```.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2026-10-29 10:48:05 +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
Smit Barmase eee7501970 agent: Remove checkpoints (#65989)
Closes #62283
Closes #58444
Follow-up #65304
Supersede #64000, #62301

Before every message, the agent snapshotted every Git repo in the
project and waited for it before sending the prompt, and every Git
status change during a turn took another one. In large workspaces this
took tens of seconds, and on Windows it could hang forever. #65304
already skipped it for external agents and subagents.

The snapshot only exists for "Restore Checkpoint", which very few people
use, so this removes checkpoints entirely. Putting them behind a setting
would keep the snapshot code and its maintenance around for a feature
few people use.

- Removed:
  - "Restore Checkpoint" button
  - Snapshots before, during and after each turn
  - Git, remote and proto code behind them (proto ids reserved)
  - Checkpoints docs section

- Stays:
  - Editing an earlier message
  - Rejecting the agent's edits
  - Worktree archive snapshots

Release Notes:

- Removed agent checkpoints and the "Restore Checkpoint" button. Taking
a checkpoint before every message made the agent slow to respond, or
hang, in large Git repositories. To undo the agent's changes, reject its
edits or use Git.
2026-10-26 10:10:32 +00:00
CoinMan.dev 04470cd9b5 project: Don't send a project update when no worktree was removed (#65189)
## Summary

> Machine translation of my original text (Russian, below):
>
> Zed started to freeze when opening some of the threads created by an
AI agent. After such a thread was opened, the cursor in the message
input started blinking rapidly, everything stopped, and Zed could not be
closed; the only way out was to kill the process. If several Zed windows
were open, all of them froze.
>
> This happened in Zed on Windows with projects in WSL2. Not every
thread in the same project froze, some opened fine, so it was hard to
understand why it was happening.
>
> The investigation was done with the help of an AI (Claude), and it
also prepared this fix. Its conclusions are below.

Original text:

Zed начал зависать при открытии некоторых тредов, которые создаёт
ИИ-агент. После открытия курсор в поле ввода начинал быстро мигать, всё
останавливалось, и закрыть Zed было невозможно — приходилось снимать
задачу. Причём если было открыто несколько окон Zed, зависали все.

Всё это происходило в Zed на Windows с проектами в WSL2. Не все треды в
одном и том же проекте зависали, некоторые открывались нормально, из-за
чего было непонятно, почему это происходит.

Разбор ситуации делался с помощью ИИ (Claude), он же подготовил
исправление. Его выводы ниже.

> **AI-generated (Claude):**
>
> **Cause.** In a remote project the client sends `RemoveWorktree`
whenever it releases a handle to a worktree
(`Project::on_worktree_released`). On the server,
`WorktreeStore::remove_worktree` answered every such request with
`UpdateProject`, even when the worktree was already gone. When the
client handles `UpdateProject`,
`WorktreeStore::set_worktrees_from_proto` re-creates a handle for every
listed worktree it does not hold. A remote client holds invisible
worktrees weakly (`WorktreeStore::remote(false, ..)`), so that handle is
released right away and `RemoveWorktree` is sent again. While the
request that really removes a worktree is still queued behind redundant
ones, every answer lists that worktree again and produces one more
request.
>
> Loading an agent thread triggers this because
`AcpThread::resolve_location` opens the file of every tool-call location
with `Project::open_local_buffer`, which creates an invisible worktree
for a file outside the project. When the buffer cannot be opened (an
image: "Binary files are not supported") the worktree is released at
once. A thread whose tool calls read a couple of dozen screenshots
outside the project releases that many invisible worktrees almost
simultaneously.
>
> **Change.** `remove_worktree` sends the project update only if it
removed a worktree.
>
> **Measurements.** Stock Zed 1.22.0 client (Linux, calls counted with
gdb breakpoints), remote server built from v1.22.0 with and without this
change, loading one thread that creates 21 invisible worktrees:
>
> | | without | with |
> |---|---|---|
> | `UpdateProject` handled by the client | 4,741 | 57 |
> | `Worktree::remote` handles created on the client | 4,702 | 281 |
> | `SettingsStore::clear_local_settings` calls | 9,980 | 645 |
> | UI thread busy after the thread loaded | 112 s | 6 s |
>
> In the captured part of a traced unpatched run, 2,839 of 2,840
`RemoveWorktree` requests removed nothing, and 2,565 of them were for
the same worktree. A second thread (33 tool-call locations outside the
project) went from 54 s to 6 s.
>
> The client still re-creates and drops handles for worktrees listed in
older updates, and `handle_update_project` still recomputes settings for
every listed worktree. Both are bounded now and left for follow-ups.
>
> Possibly related: #65008, #62542 (similar symptoms with WSL remotes
and agent threads). Not verified that this resolves them.

## Testing

> Machine translation of my original text (Russian, below):
>
> I checked it on my machine: Zed 1.22.0 on Windows 11, project in WSL2
(Ubuntu). I replaced the server in `~/.zed_server` with one built from
v1.22.0 with this change. The thread that used to freeze Zed every time
now opens normally.

Original text:

Проверил у себя: Zed 1.22.0 на Windows 11, проект в WSL2 (Ubuntu).
Подставил в `~/.zed_server` сервер, собранный из v1.22.0 с этим
изменением. Тред, который раньше каждый раз вешал Zed, теперь
открывается нормально.

> **AI-generated (Claude):**
>
> - New test
`test_removing_missing_worktree_does_not_send_project_update` in
`remote_editing_tests.rs` fails without the change (`left: 1, right: 0`)
and passes with it.
> - `cargo test -p remote_server --lib`: 57 passed. `cargo clippy -p
project -p remote_server --lib --tests -- -D warnings`: clean.
> - The measurements above were taken on Linux (Ubuntu in WSL2, Xvfb),
with the project opened as an SSH remote through a local stand-in for
`ssh` (client and server on the same machine).
> - In the check on Windows described above, the thread replays 710
messages; Zed's log shows it loaded three times with the patched server
running, and the connection to the server was idle afterwards.
> - To reproduce: open a remote project, let an external agent read
about 20 image files outside the project in one thread, then reopen that
thread.

## 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). (no UI
changes)
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed remote projects (SSH, WSL) becoming unresponsive when loading an
agent thread that refers to many files outside the project.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 11:47:56 +00:00
Zach August 11262f9256 project_panel: Explain when a move fails because the destination already exists (#64344)
# Objective

- Fixes #64128 dragging a file onto a folder that already contains a
file with the same name showed only Error: renaming "/a/1.json into
"1.json". The reason why was buried inside the error because the pop-up
prints only the outermost layer.

## Solution

undo.rs: 
-Extracted the existing already_exists check into a module level
pub(crate) function which walks the error chain for
io::ErrorKind::AlreadyExists with a fallback that looks for the text
"already exists." Undo's rename now calls that function so it behaves
exactly like before.
- Made project_path_display() a pub(crate) fn so the project panel can
format names the same way undo does.

project_panel.rs:
- move_worktree_entry() now hands back the destination path along with
the rename task instead of discarding it.
- drag_onto() builds (from, to) names from old_paths and the returned
destination. This hapens while the project can still be read and before
anything moves.
- explain_move_error(err, names) -> anyhow::Error when names are
available and the error is "already exists," it adds the clear message
with err.context(...), otherwise it returns the error unchanged.
- drag_onto() - both result loops (normal and folded folders) - each now
destructures three items and calls .map_err(|err|
explain_move_error(err, names.as_ref()) just before
.notify_workspace_async_err()

## Testing

- (#[gpui::test]) test_drag_onto_existing_name_shows_clear_error drags
a/1.json onto a root that already has 1.json. It checks that both files
keep their original contents and that exactly one notification appears.
- (#[test]) test_explain_move_error covers the three cases
      1. an already-exists error gets the clear message.
      2. a different error passes through untouched.
      3. with no names, the error passes through untouched.

- Both new tests pass.
- The unit test fails when detection is broken on purpose by returning
false in the new pub(crate) fn already_exists_error, so it does guard
the message logic.

## 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

## Showcase

<details>
  <summary>Click to view showcase</summary>
<img width="495" height="150" alt="before_zed_project_panel_name_error"
src="https://github.com/user-attachments/assets/735eb482-f4b9-4502-b810-782180c3b40c"
/>
<img width="495" height="150" alt="after_zed_project_panel_name"
src="https://github.com/user-attachments/assets/e7e9c30f-e171-4ce7-a3fd-c0f2690c08f5"
/>
<img width="217" height="186" alt="zed_test_panel_shot"
src="https://github.com/user-attachments/assets/8d76e18a-9695-4f4a-8231-785ae140c73e"
/>


</details>

---

Release Notes:

- Improved the error message in the project panel when moving a file or
folder onto a location where one with the same name already exists

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-10-21 15:37:28 +00:00
Sergio Ugalde 7dc397b61b remote_server: Use CreateProcess to spawn daemon on Windows (#55292)
When connecting to a Windows host over SSH, the proxy fails to start the
daemon and the user sees "failed to spawn server."

**Root cause**

`spawn_server_windows` invokes the daemon via
`shell_execute_from_explorer`, which goes through COM `ShellWindows` /
`IShellDispatch2::ShellExecute`. That path requires both:

- `explorer.exe` running in the caller's session, and
- an interactive desktop / window station.

Neither is available when `zed-remote-server proxy` is launched by sshd:
sshd-spawned processes live in a non-interactive window station with no
Explorer. The COM call fails, the `run` daemon never starts, the proxy's
10s socket-existence poll times out, and the connection fails.

A commenter on #48966 reports the connection succeeds after first
logging in via RDP, which is consistent with this diagnosis: RDP login
populates the session with `explorer.exe` and an interactive window
station.

**Fix**

Replace the COM path with a direct `Command::spawn`, matching the
non-Windows branch. Use `DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP`
creation flags so the daemon has no inherited console and is not killed
by Ctrl+C/Break broadcast to the parent's group when the proxy exits.

Bypass `util::new_command` because it presets `CREATE_NO_WINDOW`, which
Win32 disallows combining with `DETACHED_PROCESS`. Drop one layer to
`smol::process::Command` directly to keep the disallowed-methods lint
happy.

Also drop the now-unused `shell_execute_from_explorer` module and the
`windows` crate dependency it pulled in.

No automated test is included: exercising this path requires a headless
OpenSSH-Server-on-Windows host with a non-interactive window station,
which CI doesn't currently provide. Verified manually that macOS client
-> Windows host over SSH establishes the connection successfully where
it previously timed out.

Closes #48966

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 remote server failing to start when connecting to a Windows host
over SSH

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: John Tur <john-tur@outlook.com>
2026-10-14 08:56:21 +00:00
Ben Brandt 7fb155e9a2 agent: Use v2 tool events and permission choices (#65393)
Use SDK v2 tool updates and permission choices directly in the native
agent

Release Notes:

- N/A
2026-10-09 16:39:49 +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 8323e23277 Fix hanging during remote project search (#65257)
Closes https://github.com/zed-industries/zed/issues/65099

Before:


https://github.com/user-attachments/assets/36673f06-75b2-4d36-a8d9-4aaaa6bc1768

After:


https://github.com/user-attachments/assets/86a4e129-e1de-465f-9e70-fcec9d421c03

Issues:

- The host checked files that were not yet open for matches, but treated
every already-open buffer as a candidate.
Earlier queries leave thousands of buffers open, so later queries sent
all of them to the client: 3,339 buffers for 51 real matches in one
case.
Open buffers are now checked against their in-memory text first, which
also stops ordinary non-SSH searches from reporting open buffers with no
matches.

- The host queued every candidate buffer's full contents without waiting
for the client, so data from cancelled queries piled up in front of the
new query's results.
A single worker shared by all searches now sends at most 64 buffers or
about 1 MiB before waiting for the client to acknowledge them, and skips
batches from cancelled searches.

- Cancelling a search could stop a buffer transfer after the buffer was
already marked as shared, so later searches waited forever for its
contents.
`BufferStore` now owns transfers, so dropping the caller no longer
cancels them.

Release Notes:

- Fixed hanging during remote project search
2026-10-07 09:57:41 +00:00
Kirill Bulatov 72d073d642 Fix agent file link navigation (#64748)
Closes https://github.com/zed-industries/zed/issues/56633
Related to https://github.com/zed-industries/zed/issues/56067
Related to https://github.com/zed-industries/zed/issues/63968

Changes path handling to open files in the agent panel similar to what
cmd-click does: regular open for files from the project, singe-file
worktrees for files outside of the project

Release Notes:

- Fixed agent file link navigation
2026-10-06 21:35:37 +00:00
狐狸 a6169ca969 remote_server: Keep handling requests when output is blocked (#65011)
## Summary

I encountered the same issue as #48253, and it's really frustrating.

I asked GPT to analyze the potential causes, and the results suggest
this might be a contributing factor.

In the previous implementation, log writing could block RPC processing
and RPC read/write could also block each other, so I decoupled them in
this PR.

## Testing

Two new tests

## 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:

- Improved remote server responsiveness when log or RPC response writes
are blocked.
2026-10-05 13:51:52 +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
Quinn Shanahan c87632ef44 Read remote shell config when creating a terminal shell (#61451)
# Objective

- Makes shell for remote configurable.
- fixes #35226 

## Solution

- Adds rpc so client can retrieve terminal settings from remote server
- Vibe coded with codex Sol, I did my best to review it and make sure
it's the minimal changes.
- Added terminal dependency to remote_server, rather than a larger
change (e.g. adding something to project to expose terminal shell
setting to remote_server)

## Testing

- Tested and works Windows client / linux remote server

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable


---

Release Notes:

- Added support for terminal.shell in remote sessions

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2026-09-29 13:38:22 +00:00
Shuhei Kadowaki 4668a4bf09 lsp: Reference-count log streams across views (#61222)
LSP log streams can be consumed by split views and downstream clients.
Treating enablement as a single value lets one consumer disable a stream
that another consumer is still using.

Track the streams enabled by each view and reference-count each exact
server and log kind. Keep in-process view ownership separate from
downstream requests, preserve RPC capture while either has an active
consumer, and notify remote hosts only on the first enable and final
disable.

Represent log kinds independently so split views can consume logs,
traces, and RPC messages without overwriting one another.

---

This PR is a stacked follow-up to #61221. It is split out because
project isolation is independently mergeable, while reference-counting
changes the ownership and lifecycle semantics of LSP log streams and
benefits
from separate review.

---

Release Notes:

- Fixed closing one LSP Logs view stopping streams used by another view
or downstream client

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-09-23 16:15:20 +00:00
Matei Oprea 6b95ac3d33 git: Fix git info exclude action for worktrees (#63967)
# Objective

- This PR fixes #63760. According to git docs "Patterns read from
$GIT_DIR/info/exclude".

## Solution

- We were reading the directory's absolute path instead of reading the
absolute path to the repository's common .git directory.


## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] 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:

- Fixed "Add to .git/info/exclude" not working when used from a
secondary git worktree

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-09-18 10:24:51 +00:00
Kirill Bulatov 67ebcd9517 Fix insertion modes for completions without edit ranges (#64139)
Closes https://github.com/zed-industries/zed/issues/64118


https://github.com/user-attachments/assets/f2152411-6011-4d87-8c8e-d83bed0afbbc

`ty` returns completion text without a `textEdit` or a completion-list
default edit range:

```json
{"label":"value2=","insertText":"value2="}
```

The [LSP
specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem)
explicitly states:

> The `insertText` is subject to interpretation by the client side.

For the reported example, `ˇ` marks the cursor:

```py
test(value1, ˇvalue2)
```

Previously, Zed inferred only a range covering the existing `value2`.
Without an insert range, completion acceptance bypassed
`completions.lsp_insert_mode` and replaced that argument with `value2=`,
producing:

```py
test(value1, value2=)
```

The patch also infers an insert range, ending at the cursor rather than
the end of the word.
This lets the existing setting choose between inserting before `value2`
and replacing it.
When a prefix has already been typed, insertion replaces that prefix
while preserving the text after the cursor.

With the unchanged default, `"replace_suffix"`, Zed replaces text after
the cursor only when it is a suffix of the completion’s label.
Here, `value2` is not a suffix of `value2=`, so Zed inserts and
produces:

```py
test(value1, value2=value2)
```

The suffix and subsequence checks now use the raw LSP `label`, not
decorated menu text or `filterText`.
These checks select the edit range; `insertText` still supplies the
inserted text in this example.

Release Notes:

- Fixed insertion modes for completions without edit ranges
2026-09-16 16:03:26 +00:00
xiaoff 290cbcb9cb buffer_store: Fix path_to_buffer_id never update when move action occurs in remote mode (#64005)
# Objective
Fix an issue in SSH remote mode where reopening a newly created file at
a path that was previously renamed could incorrectly reuse the buffer
for the renamed file.

## Solution

When handling UpdateBufferFile, remove the buffer's previous path from
path_to_buffer_id when the file path changes.

## Testing

Tested manually on Linux using SSH remote mode.

Reproduction before the fix:

touch A
Open A from the project panel

mv A B
touch A

Open the new A from the project panel

Before the fix, opening A reused the buffer for B.

After the fix:

B continues to use the original buffer.
The recreated A opens as a separate buffer.
Renaming an opened remote file still updates the existing buffer to the
new path correctly.

## 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 an issue in SSH remote mode where reopening a newly created file
at a path that was previously renamed could incorrectly reuse the buffer
for the renamed file.

---------

Signed-off-by: xiaoff <xiaoff0019@outlook.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-10 08:27:36 +00:00
Shuhei Kadowaki 284c72404a lsp: Handle dynamic registration of textDocument/documentHighlight (#63029)
Zed did not advertise document highlight dynamic registration support or
handle `textDocument/documentHighlight` registrations. Dynamically
registered providers therefore fell through to the unhandled-capability
path, while servers with a fallback had to advertise a static provider
for every attached document.

Advertise dynamic registration support and track document highlight
registrations and unregistrations alongside the other selector-aware
dynamic text document capabilities. Refresh editors whenever the
effective document highlight registration state changes, including
selector-only changes that leave the merged provider unchanged, so
runtime registrations take effect immediately and unregistrations clear
stale or in-flight highlights.

Add coverage for the client capability, registration lifecycle with
multiple selectors sharing identical provider options, and editor
refresh behavior when an applicable selector is added or removed.

## 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:

- N/A

---------

Co-authored-by: GPT-5.6 Sol <noreply@openai.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-09 14:55:56 +00:00
Kirill Bulatov 0690433b60 Support LSP command executions and showDocument requests (#63607)
Closes https://github.com/zed-industries/zed/issues/13756
Closes https://github.com/zed-industries/zed/issues/61572

Last window client capability we were missing!
<img width="1557" height="159" alt="image"
src="https://github.com/user-attachments/assets/2cca5d92-a28e-4262-8f55-89f582782bbc"
/>

Two features are connected to each other, as most of the commands result
in opening a document:


https://github.com/user-attachments/assets/661aae88-7af9-4173-9f6a-2fd11dbec675


Release Notes:

- Added support for LSP command executions and showDocument requests
2026-09-09 13:47:28 +00:00
Pablo Fernandez 3384317a99 Fix connecting to devcontainers, ssh, or wsl, with a locally built Zed (#63827)
# Objective

Video overview of this PR, maybe it helps with the review:
https://youtu.be/-JhKcZttXp8

Fixes: #63828

Building Zed from source and opening a project in a dev container fails
with `Remote server exited with status 1`.

Zed compiles `remote_server` and uploads it into the container. The
binary loads Zed's default settings from the Zed source directory, which
doesn't exist there, and panics in `settings::init`:

```
thread 'main' panicked at crates/util/src/util.rs:729:10:
dev asset loading requires running from within the checkout
```

The build passes `--features debug-embed` to embed those assets instead,
but `remote_server/debug-embed` only enabled its own (unused)
`rust-embed` dependency. It never reached `util/debug-embed`, which is
what `fs_embed!` gates on. Regression from #63396.

SSH and WSL remotes are affected the same way. Release builds are not:
assets are embedded whenever `debug_assertions` is off.

## Solution

Forward the feature.

```diff
-debug-embed = ["dep:rust-embed"]
+debug-embed = ["dep:rust-embed", "util/debug-embed"]
```

The same one-line change is already included as a secondary fix in
#63613, whose subject is unrelated; its author offered to split it out.

## Testing

- `cargo tree --package remote_server --features debug-embed` now
resolves `util` with `debug-embed`. Before:
`rand,test-support,util_macros`.
- `cargo check -p remote_server --features debug-embed --target
x86_64-unknown-linux-musl` passes clean.
- Manually: built Zed from source on Linux x86_64, opened a project in a
dev container (`mcr.microsoft.com/devcontainers/base:ubuntu`). Before:
panic at startup. After: connects.

Not tested on macOS or Windows hosts.

No test added: this is feature wiring, and #63577 notes that nothing in
Zed's graph enables `util/debug-embed`, so CI can't exercise it.

## 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
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
2026-09-08 09:49:17 +00:00
Cole Miller db10a8dd73 fs: Refactor the code around GlobalWatcher to be more testable (#63894)
This is a pure refactoring PR to make our FS watching code more
testable. It does two things:

1. Make the `GlobalWatcher` be owned by `RealFs` or `FakeFs` instead of
being a process-wide global.
2. Delete `FakeWatcher` and its `Watcher` implementation, and instead
mock the notify crate itself in `FakeFs` tests via the existing
`WatchBackend` trait. Now all our FS watching code down to the notify
boundary runs the same in tests and production.

Release Notes:
- N/A
2026-09-07 19:01:41 +00:00
Shuhei Kadowaki 23aca9895c lsp: Honor dynamic LSP document selectors (#59243)
Zed previously discarded the documentSelector from dynamically
registered textDocument capabilities and treated those capabilities as
applicable to every buffer attached to the server. This could route
requests for documents outside a registration selector.

Track dynamic textDocument registrations by method and registration ID,
and use their selectors when routing local requests, checking
capabilities, and deriving completion triggers. Static capabilities
continue to apply to every attached buffer. Language and URI scheme
matching are supported, while unsupported pattern matching remains
fail-open.

Keep document color, symbol, link, code lens, and folding range caches
aligned with the selector-aware server set so incapable or non-matching
servers do not leave caches perpetually incomplete.

Require an advertised diagnostic provider before sending pull diagnostic
requests, and add integration coverage for selector-aware dynamic
completion registration and trigger updates.

---

Release Notes:

- Improved language server request routing to respect dynamically
registered document selectors.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-02 19:54:04 +00:00
Shuhei Kadowaki 60bf47b9f2 lsp: Scope logs and status updates to their projects (#61221)
The language registry and LSP log store are shared by every workspace in
a Zed process. The LSP Logs selector enumerated the shared log store
without filtering by project, while each activity indicator consumed
global binary status updates. This exposed servers from other windows as
"Unknown worktree" entries and surfaced their startup failures or
timeouts in unrelated status bars.

Key each logged server by its owning project or LSP store together with
its process-local language server ID. Use that identity consistently
when adding, removing, streaming, selecting, opening, and reselecting
log entries so local, remote, SSH, and supplementary servers cannot
collide across ownership domains.

Model Copilot and other servers outside the project LSP store as
project-scoped supplementary servers, while matching SSH servers by
their owning LSP store.

Tag project-originated binary status updates with the owning LSP store
entity ID. Carry that source through extension worktree delegates and
every worktree-based WASM language-server call, then let each local LSP
store forward only statuses for its project. Activity indicators rely
solely on their project LSP store, and remote projects continue to
receive host statuses through the existing protocol path instead of
subscribing to local registry events.

Own each binary-status subscription task in its local LSP store and
unregister its broadcaster sender when the store is dropped, so closing
windows cannot leave detached status tasks or stale senders behind.

Add regression coverage for duplicate process-local server IDs across
ownership domains, filtering remote, supplementary, and SSH servers from
other projects, retaining servers owned by the current project or LSP
store, preserving extension status sources, and unregistering dropped
status subscriptions.

Release Notes:

- Fixed language servers from other projects appearing in the LSP Logs
view and their statuses showing in unrelated windows' status bars
2026-09-02 18:23:27 +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
Tristam MacDonald ec312b2701 Add LSP call hierarchy modal (#53239)
<img width="1128" height="953" alt="image"
src="https://github.com/user-attachments/assets/b2017c0a-e25a-49d7-9342-d074014d085c"
/>

Closes #14203

Release Notes:
- Initial Call Hierarchy support in Zed

---------

Co-authored-by: Alexey Olshanskiy <gh@aohoy.dev>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-08-27 16:21:41 +00:00
Kirill Bulatov c595091b0a Bump dependencies to dedupe the crate graph (#63231)
Deduplicates crates with different versions from the graph, drops unused
features.

`cargo tree -d duplicate` listing: 160 -> 112 lines.

<details>
<summary>Deduplicated list</summary>

```
base64 (v0.22.1, v0.21.7 -> v0.22.1)
convert_case (v0.11.0, v0.10.0, v0.8.0 -> v0.11.0, v0.10.0)
core-foundation (v0.10.0, v0.9.4 -> v0.10.0)
cssparser (v0.36.0, v0.35.0 -> v0.37.0, v0.36.0)
fancy-regex (v0.18.0, v0.16.2 -> v0.19.0)
fixedbitset (v0.5.7, v0.4.2 -> v0.5.7)
h2 (v0.4.12, v0.3.27 -> v0.4.12)
heck (v0.5.0, v0.4.1, v0.3.3 -> v0.5.0, v0.4.1)
html5ever (v0.39.0, v0.35.0 -> v0.39.0)
hyper (v1.7.0, v0.14.32 -> v1.7.0)
hyper-rustls (v0.27.9, v0.24.2 -> v0.27.9)
mach2 (v0.6.0, v0.5.0, v0.4.3 -> v0.6.0, v0.5.0)
markup5ever (v0.39.0, v0.35.0 -> v0.39.0)
phf (v0.13.1, v0.12.1, v0.11.3 -> v0.13.1, v0.11.3)
phf_codegen (v0.13.1, v0.11.3 -> v0.13.1)
phf_generator (v0.13.1, v0.12.1, v0.11.3 -> v0.13.1, v0.11.3)
phf_macros (v0.13.1, v0.12.1, v0.11.3 -> v0.13.1, v0.11.3)
phf_shared (v0.13.1, v0.12.1, v0.11.3 -> v0.13.1, v0.11.3)
prost (v0.12.6, v0.9.0 -> v0.14.4)
prost-build (v0.12.6, v0.9.0 -> v0.14.4)
prost-derive (v0.12.6, v0.9.0 -> v0.14.4)
prost-types (v0.12.6, v0.9.0 -> v0.14.4)
rustix (v1.1.4, v0.38.44 -> v1.1.4)
rustls (v0.23.40, v0.21.12 -> v0.23.40)
rustls-native-certs (v0.8.3, v0.6.3 -> v0.8.3)
rustls-pemfile (v2.2.0, v1.0.4 -> v2.2.0)
rustls-webpki (v0.103.13, v0.101.7 -> v0.103.13)
security-framework (v3.5.1, v2.11.1 -> v3.5.1)
socket2 (v0.6.3, v0.5.10 -> v0.6.3)
string_cache (v0.9.0, v0.8.9 -> v0.9.0)
string_cache_codegen (v0.6.1, v0.5.4 -> v0.6.1)
strum (v0.28.0, v0.27.2 -> v0.28.0)
strum_macros (v0.28.0, v0.27.2 -> v0.28.0)
tendril (v0.5.1, v0.4.3 -> v0.5.1)
tokio-rustls (v0.26.4, v0.24.1 -> v0.26.4)
tungstenite (v0.28.0, v0.27.0 -> v0.28.0)
web_atoms (v0.2.6, v0.1.3 -> v0.2.6)
which (v6.0.3, v4.4.2 -> v8.0.5)
```

</details>


Release Notes:

- N/A
2026-08-26 14:33:13 +00:00
Kirill Bulatov 1475887faf Enable project search on type by default (#62506)
Closes https://github.com/zed-industries/zed/issues/9318

Most of the diff is tests.

Notable behavior changes during this mode, compared to current mode:

* unsaved changes in multi buffer won't spawn any "save or not" pop-ups
during typing — submitting the query still does it, as before.
Unsaved files will stay so after being sorted out on typing: we cannot
save them by default as file-less buffers need a save modal; Zed should
already be able to persist and restore such changes on restart.

* gutter may jump during search, if new excerpts with large line numbers
appear during query input — yet it would not shrink back to avoid
excessive flickering and rewraps

Release Notes:

- Enabled project search on type by default (use `{ "search": {
"search_on_type": false } }` to restore the previous behavior)
2026-08-26 14:33:03 +00:00
Neel 282f47a544 Switch from cargo-machete to cargo-shear (#62643)
This results in ~110 crates being removed, and some orphaned files also.

---

Release Notes:

- N/A

Signed-off-by: Neel <neel@zed.dev>
2026-08-20 10:08:48 +00:00
Smit Barmase 897ba9adf2 markdown_preview: Fix images not rendering over remote (#62490)
Closes #39860

This PR resolves relative image paths from the Markdown source file's
project path and load images through the project image store. SVG images
over remote connections remain unsupported and are left for a follow-up.

Release Notes:

- Fixed images not rendering in Markdown Preview over remote.
2026-08-12 10:44:58 +00:00
Kirill Bulatov 1271f8b0e8 Bump rustc to 1.97 (#62395)
Release Notes:

- N/A
2026-08-09 22:29:52 +00:00
Anthony Eid c16d19c94d gpui: Fix deadlock in performance profiler and reenable it (#61584)
### Summary

PR #58942 disabled the performance profiler within Zed because there was
a race condition that caused Zed to hang forever due to a deadlock
involving the foreground thread. This PR fixes the deadlock and
re-enables the performance profiler.

The deadlock happened because `ThreadTimings::drop()` locks
`GLOBAL_THREAD_TIMINGS`, and that drop could run in places where
`GLOBAL_THREAD_TIMINGS` was already locked: the collection paths
(`get_all_timings`, `take_all_stats`, `set_trace_enabled(false)`) held
the global lock while upgrading and then dropping per-thread
`Arc<GuardedTaskTimings>` handles. If a worker thread exited in that
window (e.g. GCD reclaiming an idle thread), the collector inherited the
last strong reference, and dropping it ran `ThreadTimings::drop` ->
`GLOBAL_THREAD_TIMINGS.lock()` reentrantly on the same thread. The
spinlock is not reentrant, so the thread spun forever while holding the
lock, hanging every other thread that touched the profiler.

The fix: hold `GLOBAL_THREAD_TIMINGS` only long enough to upgrade the
`Weak` handles (`upgraded_thread_timings()`), and release it before any
per-thread buffer is locked, copied, or dropped. A last-reference drop
now always runs with the global lock free. As a side benefit, the
up-to-16MiB per-thread buffer copies no longer happen under the global
lock.

### Diagram

```mermaid
sequenceDiagram
    participant C as Collector thread (get_all_timings)
    participant G as GLOBAL_THREAD_TIMINGS (spin::Mutex)
    participant T as Worker thread (exiting)

    Note over T: holds the only strong Arc<br/>in its THREAD_TIMINGS TLS
    C->>G: lock() — guard held for entire collection
    C->>C: Weak::upgrade() (strong: 1 → 2)
    T->>T: thread exits, TLS destructor drops its Arc (strong: 2 → 1)
    C->>C: temp Arc dropped at end of iteration (strong: 1 → 0)
    C->>C: ThreadTimings::drop() runs on collector thread
    C->>G: lock() again — already held by this thread
    Note over C,G: spin lock is not reentrant → spins forever,<br/>every other profiler user spins behind it

    Note over C,T: Fix: upgrade all Weaks under the lock, release it,<br/>then lock/copy/drop per-thread handles — the reentrant<br/>drop can now only ever run with the global lock free
```

Release Notes:

- Fixed a deadlock in the performance profiler and re-enabled it (`zed:
open performance profiler`)
2026-07-24 15:34:17 +00:00
Finn Evers e49d280094 language: Refactor available_languages into its own struct (#61388)
This adds a dedicated `AvailableLanguages` struct in preparation for a
more cabable language matching based on a given language config. No
functional changes, just shuffling some code around for this round.

Also made the LanguageMatcher non-cloneable in favor of wrapping it in
an Arc, since cloning is rather expensive for this and having a
reference is sufficient in all cases right now.

Release Notes:

- N/A

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-07-23 11:22:43 +00:00
Tautik Agrahari b64e5dc886 project: Track inlay hint / code lens / document symbol registrations by ID (#55340)
extends the precedent set by #43703 (thanks @reflectronic) so that
`textDocument/inlayHint`, `textDocument/codeLens`, and
`textDocument/documentSymbol` correctly track multiple dynamic
registrations by id. previously each register call overwrote the slot on
`ServerCapabilities`, and unregister either silently did nothing
(inlayHint, documentSymbol — no match arm) or wiped the entire
capability (codeLens). now each method keeps its own id-keyed map on
`DynamicRegistrations`; the field on `ServerCapabilities` is cleared
only when the last registration is removed.

textDocument-sync notifications (`didChange`/`didSave`/`willSave`) are
deliberately out of scope — their fan-out semantics are ambiguous in the
spec and were flagged on @smitbarmase's earlier exploration in #36876.

verified with `cargo check -p project -p lsp -p editor`, `cargo test -p
project --test integration -- multi_registration` (3/3 passing), and
`cargo fmt -p project`.

closes part of #37838.

Release Notes:

- Improved support for language servers that dynamically register inlay
hints, code lens, or document symbols multiple times.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-07-23 07:53:30 +00:00
Finn Evers c4c55bade4 Add wrapper type for language servers in settings (#61398)
This is in preparation for making configuration of language servers more
comfortable for users/extensions.

Release Notes:

- N/A
2026-07-22 21:48:46 +00:00
Om Chillure 775e51f95c Support loading Git commit templates when remote (#55490)
## Summary

Fixes the git commit template not loading in remote (SSH) projects. The
`load_commit_template_text` method in `git_store.rs` was a no-op for
`RepositoryState::Remote`, always returning `Ok(None)`. This patch adds
a `LoadCommitTemplate` RPC so the client can ask the remote host to read
its `commit.template` git config and return the file contents —
mirroring the existing `GetBlobContent` pattern.

## Changes

- **`crates/proto/proto/git.proto`** — new `LoadCommitTemplate` /
`LoadCommitTemplateResponse` messages.
- **`crates/proto/proto/zed.proto`** — registered envelope IDs 449/450.
- **`crates/proto/src/proto.rs`** — wired up message priority, request
pairing, and entity-message routing.
- **`crates/project/src/git_store.rs`** — added
`handle_load_commit_template` on the host side; replaced the `Ok(None)`
no-op on the remote side with the RPC call.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments — *no unsafe code
added*
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
— *no UI changes*
- [ ] Tests cover the new/changed behavior — *see "Testing notes" below*
- [x] Performance impact has been considered and is acceptable — *one
extra RPC on commit panel open for remote projects only; payload is a
single optional string*

## Testing notes — why no automated test

I did write an integration test (`test_remote_git_commit_template` in
`collab/tests/integration/git_tests.rs`, modeled after
`test_remote_git_head_sha`) along with the supporting changes to
`FakeGitRepositoryState` (adding a `commit_template` field +
`set_commit_template_for_repo` setter on `FakeFs`, since the fake
hardcoded `load_commit_template` to `None`).

The test compiled and the smaller crates (`fs`, `proto`, `project`)
checked clean, but `cargo test -p collab --test collab_tests`
cold-compile takes a very long time on my machine and I wasn't able to
confirm the test actually passed locally. Rather than push a test I
hadn't seen pass, I removed it. Happy to add it back in a follow-up PR
(or in this one if reviewers prefer) once I can run the collab suite
end-to-end — the diff is small and I can share it on request.

Verification was done end-to-end manually using a Docker dev container
as the SSH remote:

#### Closes #55265

Video : 
[Screencast from 2026-05-02
18-09-03.webm](https://github.com/user-attachments/assets/9cb7f375-57fa-4af3-bde4-871c28f61efc)

Release Notes:
- Added support for loading git commit template messages in both remote
and collab projects.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-07-22 12:01:29 +00:00
Jakub Konka e8bfce7614 Only install crash handler when a minidump endpoint is configured (#61384)
Closes FR-130

Builds compiled from source at a release tag report a non-dev release
channel, so they used to install the crash handler and write minidumps
into the shared logs directory. An official Zed launched later would
find and upload those dumps to Sentry, where they can never be
symbolicated (their debug UUID matches no uploaded debug files).

Gate the crash handler on having somewhere to send the dumps: either the
compile-time ZED_MINIDUMP_ENDPOINT baked into official builds, the
runtime ZED_MINIDUMP_ENDPOINT override, or an explicit
ZED_GENERATE_MINIDUMPS opt-in for debugging the crash pipeline locally.

Release Notes:

- N/A
2026-07-21 08:16:15 +00:00
Xiaobo Liu edeaf598c7 project: Add remote support for adding paths to .gitignore (#56368)
Release Notes:

- Fixed remote support for adding paths to .gitignore



The problem solved by this PR is: when opening a remote project,
right-clicking a new file in the git panel and clicking "Add to
.gitignore" does not work.

---------

Co-authored-by: Cole Miller <cole@zed.dev>
2026-07-18 21:39:15 +00:00
Dino b562439e93 project_panel: Add remote support for undo/redo system (#59709)
# Objective

Add remote (SSH) and collaboration support for trashing and restoring
files in the project panel, which in turn enables undo/redo of trash
operations against remote and collab projects.

Relates to #5039.

## Solution

- Updated the project panel undo system to carry `TrashId` instead of
`TrashedEntry`.
- Using `TrashedEntry` could get hairy, as it includes paths, which
wouldn't play too nicely when using, for exapmle, macOS as the client
and Windows as the host. Using a simple identifier is much easier in
this regard and simplifies implementation.
- Enabled the Trash action and context-menu entry on remote projects,
and removed the command palette filter in `ProjectPanel::new` that was
still hiding the action on remote.
- As far as I can tell, there isn't a reliable way to detect whether a
given remote actually supports the OS trash, so we expose the action
everywhere rather than guessing. On a remote without trash support the
action will fail when invoked but this is a conscious tradeoff until we
find a better way to handle this.
- `fs` now tracks trashed files in a `SlotMap<TrashId, TrashedEntry>` on
each `Fs` implementation. Trashed files are referenced by an opaque
`TrashId` instead of passing a `TrashedEntry` around, which avoids
serializing filesystem paths in remote messages.
- Split the old `delete_entry(trash: bool)` API into distinct
`trash_entry`/`trash_file` (returning a `TrashId`) and
`delete_entry`/`delete_file` across `Project`, `Worktree`,
`LocalWorktree` and `RemoteWorktree`.
- This lets us drop the optional trash result (`Option<TrashedEntry>`)
from the delete path and require a `TrashId` from the trash path.
- Added new proto messages (`TrashProjectEntry`,
`TrashProjectEntryResponse`, `RestoreProjectEntry`,
`RestoreProjectEntryResponse`) to let clients request the host to trash
or restore entries.
- This deprecates `DeleteProjectEntry::use_trash`, but the host still
honors it. An older collab peer may request trashing via that flag
instead of the newer `TrashProjectEntry`. If the host ignored it, a
newer host would permanently delete a file the user meant to send to the
trash. The field will be removed in a later PR once all supported peers
use `TrashProjectEntry`.

## Testing

The following tests were introduced to ensure the new behavior is
correctly tested:

* `remote_server::remote_editing_tests::test_remote_trash_restore` –
Tests trashing a project entry in remote
*
`remote_server::remote_editing_tests::test_remote_delete_project_entry_with_trash`
– Test to ensure we continue respecting `DeleteProjectEntry::use_trash`
until it is fully removed
* `project_panel::tests::undo::trash_directory_undo_redo` – Not related
to these changes but a nice to have as we were missing a test ensuring
that trashing and then undoing and redoing it for a directory works as
expected

Besides these, the following scenarios were manually tested against a
remote session on the same machine (macOS):

- Trashing → Undo (Restore) → Redo (Trashing)
- Batch Trashing → Undo (Batch Restore) → Redo (Batch Trashing)
- Rename → Undo (Rename) → Redo (Rename)
- Move → Undo (Move) → Redo (Move)
- Batch Move → Undo (Batch Move) → Redo (Batch Move)

## 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 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
- [ ] Performance impact has been considered and is acceptable

Release Notes:

- N/A

---------

Co-authored-by: Yara <git@yara.blue>
2026-07-16 09:41:21 +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
Tyler Benfield 503292376e Fix remote worktree picker hides "Create from origin/main" option (#59134)
This passes the `include_remote_name` flag through the remote
`GetDefaultBranch` RPC instead of dropping it at the client/host
boundary. That lets remote repositories resolve default branches as
`origin/main` when needed, so worktree creation uses a valid remote
branch name instead of falling back to `main`.

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

Closes #59121

Release Notes:

- Fixed remote worktree creation from the default branch when the
default branch requires its remote name.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-07-10 12:11:57 +00:00
Ben Kunkle 5d7d1d3f09 language_extension: Hold LspStore weakly in LspAccess::ViaLspStore (#60558)
# Objective

Fix a Windows CI flake in `extension_host
extension_store_test::test_extension_store_with_test_extension`, which
panicked in GPUI's leak detector with three leaked `LspStore` handles
([example
run](https://github.com/zed-industries/zed/actions/runs/28871529605/job/85635418351)).

## Solution

`LspAccess::ViaLspStore` held a strong `Entity<LspStore>`, cloned into
three `ExtensionHostProxy` registrations by `language_extension::init`.
The proxy sits inside an `Arc` cycle (proxy →
`LanguageServerRegistryProxy` → `LanguageRegistry` →
`ExtensionLspAdapter` → `WasmExtension` → `WasmHost` → proxy), so
whenever an extension LSP adapter was registered at app-drop time, the
cycle pinned the `LspStore` entity after its owning `Project` dropped.
The flake was purely timing: extension reload toggles the adapter
registration, and an unclean LSP pipe shutdown on Windows shifted
teardown into the pinned window.

`ViaLspStore` now holds a `WeakEntity<LspStore>`, upgraded at its sole
use site (`remove_language_server`), skipping the stop task when the
store is gone — matching the existing `ViaWorkspaces` semantics. A dead
store is the expected terminal state after the owning project drops, so
no error is logged or propagated. `Project`/`HeadlessProject` remain the
sole long-term owners of `LspStore`, which is already the convention
everywhere else (e.g. `json_schema_store`, the `lsp_store` message
handlers).

## Testing

- Ran `cargo nextest run -p extension_host
extension_store_test::test_extension_store_with_test_extension` locally:
passes.
- The flake is timing-dependent (reproduced on Windows CI), so a local
pass doesn't prove absence; the fix removes the only strong non-owner
handle, which the leak detector reported.

## 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:

- N/A

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-07-07 21:59:03 +00:00
Anant Goel ea87b05794 Fix worktree grouping for bare checkouts (#59968)
Summary

- Track whether a worktree root is itself a linked Git worktree.
- Use that metadata when computing project group keys so bare checkout
worktrees group under the repository identity path.
- Propagate the metadata through remote worktree protocols and add
local/remote regression coverage.

Background

Bare checkout layouts can place linked worktrees under the repository
identity directory, e.g. `/monty/.bare` with worktrees like
`/monty/feature-a`. We were treating those linked worktree paths as
separate project identities, which caused the sidebar to move agent
threads under the active worktree instead of the shared repository
group.
We also exclude adding this to collab intentionally, we can open a
different PR for that if we need to.

Closes #59910
Closes AI-431

Test Plan

- `cargo fmt --package project --package worktree --package
remote_server --package workspace --package collab --package proto`
- `git --no-pager diff --check`
- `cargo test -p project test_project_group_key -- --nocapture`
- `cargo test -p remote_server test_remote_root_repo_common_dir --
--nocapture`
- `cargo test -p worktree remote_worktree -- --nocapture`
- `cargo test -p workspace
test_remote_project_root_dir_changes_update_groups -- --nocapture`
- `cargo check -p collab`

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

Release Notes:

- Fixed agent thread/sidebar grouping for Git worktrees backed by bare
checkouts.

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
2026-07-02 18:14:11 +00:00
mertkanakkoc 9375695626 Project/use line hint for search (#58871)
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

This PR makes two changes:

1. detect() now returns the line number of the first match instead of
just a boolean.
2. This line number (line_hint) is threaded through the pipeline and
passed as a subrange to query.search in full buffer scan, so the full
buffer scan starts from where the first match was already found instead
of the beginning of the file.
 
 ## Scope

  - This optimization only applies to **local search** (not remote).
- It is only effective for **single-line text and single-line regex**
queries. For multiline queries, `detect()` returns `line_hint = 0`, so
the full buffer is scanned from the beginning as before.
- It does not apply to already-open buffers, which always receive
`line_hint = 0`.
  
  ## Test
i tried to search the word "typeably" in the file
"pkgs/development/haskell-modules/hackage-packages.nix" of the repo
[nixpkgs](https://github.com/NixOS/nixpkgs) given in the comment:
[comment](https://github.com/zed-industries/zed/issues/38799#issuecomment-4088491295).
Result seems promising:
 
**with line_hint: 
search: 45.21ms** 

**without line_hint:
search: 508.05ms** 

I measured the time within the function: "handle_find_all_matches"

## Assumption

The core assumption is: if the search query is long enough (after 4 or 5
chars), the probability of finding multiple matches in a single file is
low. In that case, re-scanning the content before line_hint is
unnecessary — detect() function already confirmed there is no match
there.
 
Changes maybe can make an improvement on issues #38799 and #58905

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2026-07-02 09:46:33 +00:00
Kirill Bulatov 0deb6c0dea Fix code lens not being resolved in remote workflows (#59999)
Follow-up to https://github.com/zed-industries/zed/pull/54100
Closes https://github.com/zed-industries/zed/issues/59122

Original PR overlooked that the resolve was not handled from the remote
hosts at all...
Also, fixes the re-fetch of code lens not taking new language servers
into account: before, it exit early whilst now it actually re-fetches
the lens for the new servers.

Before:

<img width="1728" height="1084" alt="before"
src="https://github.com/user-attachments/assets/9ee8205b-084b-4409-9abc-18c4ddb9c4e9"
/>

After:

<img width="1728" height="1084" alt="after"
src="https://github.com/user-attachments/assets/16ad76dc-25e1-4257-80dc-b5aeabc9a4ef"
/>


Release Notes:

- Fixed code lens not being resolved in remote workflows
2026-06-28 14:44:44 +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
Ben Brandt 8ba35e5eac acp: Update agent client protocol crate to 0.15.0 (#59593)
We finally have a cancellation mechanism to use! Made the non
side-effectful handlers stop their work if we get a cancel request
notification.

Release Notes:

- N/A
2026-06-22 09:04:29 +00:00