Commit Graph

40878 Commits

Author SHA1 Message Date
Cameron Mcloughlin 3dcdee6d2b sandbox: New linux sandbox (#67062)
Note: this PR does not change any behaviour of zed itself. The old
sandbox implementation is still in use. The code in this PR is not
considered secure. I'll need more time to torture it before I'm
confident :)

The old sandbox used `bwrap` to set up mounts to restrict FS access, and
an in-sandbox network proxy to forward HTTP requests. It has significant
limitations however:
- it cannot restrict FS access to paths that don't exist at sandbox
creation time. This means that files that become available while a
command is running are unprotected
- it cannot restrict FS access based on a glob - each individual mount
must be specified explicitly
- it cannot restrict network access that is not HTTP (i.e. SSH traffic).
- it cannot change permissions while a sandboxed command is running -
the grants given at the start of the execution are fixed. Agents can
request to re-run the app with broader permissions, which is fine, but
not great UX
- it cannot detect whether a command failed because it hit the sandbox
boundary or not. Again, agents can guess, but we'd like something more
robust
- it cannot dynamically prompt the user to escalate privileges

The new sandbox has a different different design which solves these
problems:
- all restrictions go through seccomp user notifications
- this allows us to register a supervisor process with the kernel to
validate the syscalls of another program. This supervisor can run
arbitrary userspace code to inspect syscalls before
allowing/denying/modifying them
- we create and upload a policy object to this supervisor which checks
syscalls against this policy
- if the policy says that the operation requires "ask"-ing, the
supervisor will ask zed to show a prompt to the user and report a
decision

This design is a lot more unified, and since it is much more flexible,
is also potentially suitable for sandboxing more parts of zed (user
terminals, LSP servers, etc.).

Release Notes:

- N/A
2026-11-17 12:43:21 +00:00
Likeai e5be9608dd worktree: Only treat a directory as a bare repository when HEAD and config are files (#67024)
## Summary

`is_dot_git` decides whether a directory is a bare repository by
checking that a
`HEAD` and a `config` entry exist inside it. The check only tests for
existence,
so any directory that happens to contain entries with those names is
treated as
a bare repository.

A small Rust crate is enough to trigger this:

    exp/
    ├── Cargo.toml
    └── src/
        ├── main.rs
        └── exp/
            ├── mod.rs
            ├── head/
            │   └── mod.rs
            └── config/
                └── mod.rs

where `src/exp/mod.rs` simply declares the two modules:

    pub mod config;
    pub mod head;

On case-insensitive filesystems (macOS by default), `src/exp/HEAD`
resolves to
the `head` module directory, and `src/exp/config` exists, so `src/exp`
matches
the bare-repository heuristic. Zed then registers its parent, the
ordinary
source directory `src/`, as a Git repository. That repository has no
working
directory, so opening it fails in `Repository::check_access` with `bare
repositories do not have a working directory`. The Git panel maps any
access
failure to `GitAccess::No` and shows the "detected dubious ownership"
empty
state, where **Trust Directory** cannot help, since the real problem is
not
ownership.

Because the Git panel follows the repository of the active file, opening
`src/exp/config/mod.rs` silently switches away from the real repository
to the
bogus `src` entry. The stale entry survives restarts until the project
root is
reopened. This is unrelated to linked worktrees; the same layout
reproduces in a
plain checkout. On case-sensitive filesystems the directory must
literally be
named `HEAD` to match.

This change requires both entries to be files rather than merely
present, so
directories named `HEAD`/`head` or `config` no longer register as Git
metadata.
The `.git` fast path is untouched, and real bare repositories still
match because
their `HEAD` and `config` are files (symlinked `HEAD` included, as
`Fs::is_file`
resolves symlinks).

## Testing

Reproduced and manually verified on macOS with a case-insensitive
volume:

1. Create a crate named `exp` with modules `exp::head` and `exp::config`
   (`src/exp/head/mod.rs`, `src/exp/config/mod.rs`) and commit it.
2. Open the crate in Zed and then open `src/exp/config/mod.rs`.
3. Before: the repository selector lists two repositories, `exp` and a
bogus
`src`, and the Git panel for `src` shows the dubious-ownership empty
state.
Selecting `exp` restores Git, but opening the file again switches back
to
`src`. After: only `exp` is listed, and status, staging and committing
work
   for files under `src/exp/`.
4. Confirm no regression for real bare repositories by opening a bare
clone and
a linked worktree of it; both are still detected and their Git features
work.

No automated test was added for this case.

## 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 Git repository detection treating any directory containing
`HEAD` and
  `config` entries as a bare repository.
  

<img width="2040" height="1122" alt="截图Zed 1116101115"
src="https://github.com/user-attachments/assets/0629d47b-7cf1-41b2-95e3-0e9b631ca4ba"
/>

**After fixed**
  
<img width="1830" height="994" alt="截图zed 1116111127"
src="https://github.com/user-attachments/assets/fd1081c9-353e-48b0-b61a-eaf26ec6eb8e"
/>

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-11-17 09:14:48 +00:00
Christopher Eades 6e7c5d3ae8 agent: Accept stringified line numbers in read_file tool (#67072)
## Summary

This addresses when agents send strings for `start_line` and `end_line`
which cause an error:
> string "300", expected u32
The agent can go pathological and blow the context out which causes it
to fail the assigned task worst case, but wastes a lot of tokens
otherwise.

Closes #67071

## Testing

Unit tests have been updated such that testing the string serialized
`start_line` and `end_line`, as well as integers, are now both parsed by
serde. Agent testing with local models, qwen3.8:27b via ollama, no
longer run into the serialization problem.

I've been running a dev compiled binary for about a week with this
change and have used the agent several times in many projects, including
to address another issue with the `terminal` tool leaking instructions
to the agent when the `terminal` has been denied (which I'll open
separately) and the agent is performing well with the dev binary
containing the change to the `read_file` tool.

See the attached screenshots for the previous behavior:

<img width="1257" height="1748" alt="image"
src="https://github.com/user-attachments/assets/0ab948a9-8d8e-40ba-9997-21f6dcccbca3"
/>

The new behavior:

<img width="1610" height="1802" alt="image"
src="https://github.com/user-attachments/assets/4a410892-402b-4702-84d3-3268d7e78a33"
/>

## 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 the agent's `read_file` tool failing when models pass
`start_line`/`end_line` as strings.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-11-17 07:17:22 +00:00
Jasper 482e76524b fix(git_graph): match log_source to CommitViewOptions reveal_file (#67042)
## Summary

closes #67003

Opening the git graph of a selected file will persist the scope of the
selected file to the commit view and position that file in view
automatically. Other files in the commit are still available to view and
are in the same order as if there was no selected file.

### Before


https://github.com/user-attachments/assets/237292dc-3a56-4f3e-a180-ef702c5a0a88

### After


https://github.com/user-attachments/assets/8bdc5735-2159-46c7-9347-3187f85f5f5d

## Testing

- Open a file in the editor
- Open the context menu on the file and select "View File History"
- Open any commit that has the selected file + any number of additional
files that were changed

The current behavior is that the commit view will open to the first file
rather than the file selected from the editor.

After making the minor updates the behavior of selecting a file to open
it's commit view results in that file being shown on the initial render
of the view.

## 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
2026-11-16 20:50:25 +00:00
Ted Robertson 4191aeaf50 agent_ui: Check only the clicked pattern in pipeline permission dropdown (#56492)
Closes #55523

When the agent proposes a [chained
command](https://github.com/zed-industries/zed/issues/55523) like `ls &&
git status && git log`, the permission dropdown lists an "Always for `X`
commands" checkbox per sub-command. Clicking one checkbox activates
pattern mode with *all* patterns pre-checked, so the user appeared to be
approving every command in the pipeline even though they had only
clicked one. Pressing Allow then allow-listed every sub-command.

Fix: the first click activates pattern mode with only the clicked
pattern checked. Additional patterns require explicit checks.

**Note**: I've rebased onto `main` after #65039, which moved the
dropdown's selection state into `Conversation`. The dropdown's click
handler and the `ToggleCommandPattern` action handler now both call
`Conversation::toggle_permission_pattern`, so the fix lives in one
place. The duplicated fix and the one-click-behind workaround from the
previous version of this PR are gone.

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

- Fixed the agent's permission dropdown for chained terminal commands
checking every command when you clicked only one.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-11-16 19:20:21 +00:00
Jakub Konka 5709f329dc Support Corgi builds on FHS Linux (#67055)
Upgrade Corgi and the Nix development input to 0.1.107, which supplies a
pinned libstdc++ runtime for Linux builds. Declare the x86_64 native
libraries required to build Zed without host development packages.

Release Notes:

- N/A
2026-11-16 18:14:09 +00:00
Jakub Konka 9925feb84c gpui_web: Drop Shift from symbol keystrokes (#67052)
Browsers report the shifted character as the key, so Shift+1 arrived as
`shift-!` and never matched a `!` binding. Match the Linux platform's
convention and keep Shift only on letters and named keys.

Release Notes:

- [GPUI] Fixed handling of shifted characters to correctly drop the
modifier.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:34:29 +00:00
Remco Smits d833d4689d fs: Optimize filesystem watcher path matching by adding fast path for normalizing path (#66990)
## Summary

While I was creating https://github.com/zed-industries/zed/pull/66973 I
still thought that Zed wasn't keeping up at times as fast as I expected,
so I started looking into more in the performance issue and found with
profiling the most time was spend inside the **watcher_ids_covering**
method as you can see inside the profile:

**Before** (before fast path):
<img width="1278" height="465" alt="Screenshot 2026-11-14 at 20 29 22"
src="https://github.com/user-attachments/assets/0f5e5296-7d78-4650-8c0a-5535e62156b8"
/>

**After** (after fast path, see that it only shows that we spend around
900ms normalizing paths for a cargo build now)

<img width="1277" height="462" alt="Screenshot 2026-11-14 at 20 41 25"
src="https://github.com/user-attachments/assets/bfc39454-be94-4b97-a6a1-f55bbd825dee"
/>

My profile shows the following 2 things:

1. We seem to spend alot of time hashing the `WatchKey`.
2. We seem to spend alot of time inside the `folded_path` method to
normalize the path.

The second one is partially addressed in this PR, since most of the time
the path is ASCII case we can just call `to_ascii_lowercase` on the
lossy string. That removes the overhead of looping over every char of
the path, and normalizing it to lowercase.

This reduces the total time spend inside the `watcher_ids_covering`
method by **~31%** (~9s) from **~31.30s** to **~21.50s**.

| Metric | Before fast path | After 1 | After 2 | Average reduction |
|---|---:|---:|---:|---:|
| Notifications received | 213,761 | 214,054 | 213,686 | Comparable
(+0.05%) |
| Average routing/event | 133.4 µs | 90.0 µs | **87.0 µs** | **33.7%** |
| Total routing wall time | 28.51 s | 19.26 s | **18.59 s** | **33.6%**
|
| Total dispatch wall time | 31.32 s | 21.86 s | **21.20 s** | **31.2%**
|
| Observed queue peak | 1,131 | 663 | **359** | 54.8% |
| Average queue wait | 8.20 ms | 4.11 ms | **3.06 ms** | 56.3% |
| Maximum queue wait | 207 ms | 166 ms | **136 ms** | 27.1% |


## Testing

There is already test coverage for normalizing the paths, so didin't add
a test since it feld like adding a test for having a test. but happy to
add a test if thats really wanted!?

## 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 responsiveness during heavy filesystem activity by reducing
filesystem watcher path-matching overhead.
2026-11-16 16:42:28 +00:00
Finn Evers d3d58c304b docs: Mention that new MCP server extensions will no longer be accepted (#67045)
Release Notes:

- N/A
2026-11-16 16:33:37 +00:00
Parker Loflin 7b5cc722a1 vim: Fix substitute without the g flag replacing the wrong matches (#67015)
## Summary

`SearchQuery::search` searches a slice of the buffer and returns offsets
into that slice. With `one_match_per_line`, it found each match's row by
passing the slice offset to `buffer.offset_to_point`, which takes a
buffer offset. When the slice started after the first line, matches got
the rows of lines nearer the top of the buffer, so the wrong matches
were kept. It now adds `range_offset`.

Only Vim's `:s` sets `one_match_per_line`, when it replaces the first
match on each line. It searches only the lines in its range, so it was
correct only when the range started on the first line. With `x` on line
1 and `aaaa` on line 2, `:s/a/b/` on line 2 gave `baba` instead of
`baaa`.

## Testing

- `test_replace_without_g_after_first_line` is new and fails without the
fix.
- `cargo test -p vim --lib` and `cargo test -p search --lib` pass.
- `cargo test -p project --features test-support --test integration
search` passes.
- `./script/clippy -p project -p vim` passes.

## 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 Vim's `:s` without the `g` flag replacing the wrong matches when
used after the first line

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-11-16 16:03:37 +00:00
Yann Defretin 917559da35 sidebar: Add keyboard navigation to the thread switcher (#66951)
## Summary

The thread switcher only cycles: `ctrl-tab` steps forward,
`ctrl-shift-tab` steps back, and releasing the modifier confirms. Its
view only handles `menu::Confirm`, `menu::Cancel` and
`agents_sidebar::ToggleThreadSwitcher`, so the global `menu::SelectNext`
/ `menu::SelectPrevious` bindings – arrow keys, `ctrl-n` / `ctrl-p` –
and `menu::SelectFirst` / `menu::SelectLast` do nothing while it is
open. With threads from several workspaces in the list, reaching the nth
entry costs n−1 presses of the trigger.

This PR makes the switcher handle those four actions, like the other
modal lists in Zed:

- Next and previous wrap around and preview the selected thread without
confirming it, the same way the cycle bindings do.
- `ctrl-up` / `ctrl-down` are bound in the `ThreadSwitcher` context,
mirroring the tab switcher, so the selection can move while the modifier
that opened the switcher is still held.

On macOS, `ctrl-up` / `ctrl-down` are taken by Mission Control and App
Exposé by default, so they may never reach Zed – `ctrl-n` / `ctrl-p`
still work with `ctrl` held. The thread switcher paragraph in
`docs/src/ai/parallel-agents.md` mentions the new keys.

Proposed in discussion #66923.


https://github.com/user-attachments/assets/b5138dab-3e16-4e2a-a99a-a5b7708a66bc


## Testing

- `test_thread_switcher_menu_navigation_wraps_without_confirming` covers
wrapping in both directions, `SelectFirst` / `SelectLast`, and checks
that stepping previews a thread without confirming it or recording an
access – only `menu::Confirm` does.
- `cargo test -p sidebar` and `./script/clippy -p sidebar` pass locally.
- Tested manually on macOS: open the switcher with `ctrl-tab`, keep
`ctrl` held and step with `ctrl-n` / `ctrl-p`, release to confirm.

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

- Added keyboard navigation to the thread switcher: arrow keys, `ctrl-n`
/ `ctrl-p`, Home / End, and `ctrl-up` / `ctrl-down` while the switcher's
modifier is held.
2026-11-16 14:20:13 +00:00
Parker Loflin 52b0e43064 editor: Don't write empty selections to the primary selection (#66986)
Closes #64446

## Summary

On Linux, each local selection change copies the selected text to the
primary selection and joins multiple selections with newlines. It
skipped the write only when the joined text was empty. With two or more
cursors and nothing selected, the text is one newline per extra cursor,
so every cursor move or keystroke replaced the primary selection with
newlines.

It now skips the write when every selection is empty.

## Testing

`cargo test -p editor --lib` passes on Linux.
`test_empty_selections_keep_primary_selection` is new, compiled only on
Linux and FreeBSD, and fails without the fix.

## 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 multiple cursors overwriting the primary selection with newlines
on Linux
2026-11-16 13:59:16 +00:00
Parker Loflin f89b22bbea zlog: Count module filters toward the enabled log level (#66985)
## Summary

Log filters keyed by a module path, such as `"project::lsp_store":
"debug"`, are stored separately from scope filters.
`refresh_from_settings` computed the most verbose enabled level from the
scope filters only. Records more verbose than that level are rejected
before any filter is consulted, so a module filter could not enable
`debug` or `trace` records unless a scope filter or `ZED_LOG` already
allowed that level.

The level now includes module filters.

## Testing

`cargo test -p zlog` passes.
`test_refresh_from_settings_with_module_filter` is new and fails without
the fix.

## 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 `log` settings keyed by module path (such as
`project::lsp_store`) not enabling `debug` or `trace` logs
2026-11-16 13:58:55 +00:00
Shreehitha Arushan 15ea61ea39 tab_switcher: Remove closed terminals from the open switcher (#66943)
## Summary

Closes #66654

When the tab switcher is opened from the terminal panel and a terminal
is closed from the list, its row stayed in the list until the switcher
was reopened.

The cause: the tab switcher only refreshed on the workspace's
`ItemAdded` / `ItemRemoved` events, and the workspace only emits those
for panes in the center area. The terminal panel has its own pane, so
its item changes never reached the switcher.

The fix: `TabSwitcher::open` already finds the focused dock panel's
pane. I now pass that pane to the delegate and subscribe to its
`AddItem` / `RemovedItem` events directly. Center panes still use the
existing workspace subscription, so nothing refreshes twice. I moved the
shared refresh code into a small `refresh_matches` helper so both
subscriptions use it.

Before: see the recording attached to #66654.

After:


https://github.com/user-attachments/assets/2e664c88-a7f4-43c1-b770-787354a4a471



## Testing

- Added `test_close_item_in_dock_pane`: opens the switcher on a pane
outside the workspace center, closes an item, and checks the list
updates.
- `cargo test -p tab_switcher` passes, and clippy is clean.
- Manually tested on Windows 11: opened 3 terminals in the terminal
panel, focused the panel, pressed ctrl-tab, and closed one with ×. The
row now disappears immediately while the switcher stays open.

To test: open 2+ terminals in the terminal panel, focus it, hold ctrl
and press tab, then click × on a row.

## 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 closed terminals staying in the tab switcher until it was
reopened.
2026-11-16 13:48:28 +00:00
David Jensen d39178f6c9 agent_ui: Keep focus when background threads auto-send queued messages (#66787)
## Summary

Typing in one conversation no longer loses keyboard focus when a
different, background conversation finishes a turn and automatically
sends its next queued follow-up. Sending a queued message yourself (Send
Now, or fast-tracking the next queued message by pressing Send in the
empty composer) still returns focus to that thread's composer.

The focus decision stays in the shared queued-entry dispatch. Each
caller now passes an explicit source (automatic or manual), and the
dispatch focuses the composer only for manual sends. Queue validation,
cancellation, sending and error recovery are unchanged.

Closes #66416

## Testing

Automated checks run locally on the initial fixed implementation:

- New regression test for automatic sends failed without the fix (at the
foreground composer focus assertion) and passes with it. A second new
test covers manual sends keeping focus. Both passed scheduler seeds
0-19.
- All `agent_ui` and `gpui_apple` tests passed, `cargo fmt --check` and
`./script/clippy -p agent_ui -p gpui_apple` passed, and a full
development build succeeded.
- The full workspace suite and Windows/Linux validation were not run
locally.

Automated native desktop UI test on macOS with a local simulated ACP
agent (not a real external agent or model, and not a human manual test):
thread A had two queued follow-ups, and numbered chunks 01-18 were typed
into thread B one character at a time. A's turns completed mid-typing
and each follow-up auto-submitted, with no clicks, refocuses or window
activations. B's draft was then submitted and received exactly `Typing
in B: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18`.

After the follow-up change that passes an explicit dispatch source (an
internal refactor of the same behavior), all `agent_ui` and `gpui_apple`
tests, both focus tests across seeds 0-19, Clippy and formatting were
rerun and passed. The development app and the desktop test above were
not rebuilt or repeated for that change, and the screenshots come from
the initial implementation.

To reproduce:

1. Open two threads, A and B, in the same window.
2. In A, send a message and, while it generates, queue two follow-ups.
3. Switch to B and start typing continuously.
4. When A's turn finishes, its next follow-up is sent. Typing in B
should continue uninterrupted.

AI assistance was used to prepare this change and its description.

## Self-review

- [ ] 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.

## Screenshots

<img width="800" height="125" alt="Image"
src="https://github.com/user-attachments/assets/69e7a496-d379-40de-bd0f-9febd5786ff7"
/>

Thread A – Queued followups

<img width="800" height="155" alt="Image"
src="https://github.com/user-attachments/assets/67a5b79c-de25-48f6-9f9b-eeec534b2398"
/>


Thread B – Typing focus retained

Release Notes:

- Fixed typing in an agent thread losing focus when another thread
automatically sends its queued messages.

---------

Co-authored-by: David Jensen <288440181+daejey@users.noreply.github.com>
2026-11-16 13:29:34 +00:00
Bennet Bo Fenner 89d3da6578 Preserve mid-conversation system prompt updates (#66490)
Release Notes:

- N/A
2026-11-16 13:07:38 +00:00
Lena 99dd426cba Highlight high-merge-rate authors on the community PRs board (#67038)
Pull in the list of authors with high clean merge rates from Snowflake
(clean merge rate means we are not counting a quick self-closed PR
mistake as a rejected PR), store the list in the GitHub project board's
readme (it's a hacky place, for simplicity), and show those authors as
"High MR" (not just "Returning") on the board with the community PRs.

Release Notes:

- N/A
2026-11-16 12:54:14 +00:00
Felipe Arthur 430a781076 Fix duplicate language server notifications (#67021)
## Summary

Repeated language server messages could stack identical notifications
while previewing themes.

- Skip an actionless prompt when a visible prompt has the same server
name, level, and message.
- Compare those fields directly while retaining per-request numeric IDs
and keeping action-bearing prompts independent.
- Preserve the existing notification and its dismissal timer when
discarding a duplicate.
- Move LSP-specific auto-dismiss setup into the prompt instead of
generic notification handling.

Implementation:
[`show_language_server_prompt`](https://github.com/zed-industries/zed/blob/ffaa5fbe8c30bc819c3d118e688b28c1f1a64fe1/crates/workspace/src/notifications.rs#L228-L253)
and
[`LanguageServerPrompt::new`](https://github.com/zed-industries/zed/blob/ffaa5fbe8c30bc819c3d118e688b28c1f1a64fe1/crates/workspace/src/notifications.rs#L274-L303).

This changes visible-notification handling, not the upstream
settings-to-LSP configuration refresh path.

![Original reproduction
screenshot](https://github.com/user-attachments/assets/c3cce22e-e1b8-4047-ad44-8eda72bca659)

## Testing

### Automated validation

- `cargo test --offline -p workspace --lib`: 309 tests passed on the
updated PR branch.
- The notification tests also passed across 20 scheduler seeds before
the cleanup was moved onto the PR branch.
- The new deduplication tests failed on `main` with only the tests and
their dev-dependency added, confirming coverage of the original stacking
bug.
- Coverage includes server and severity differences, delimiter
collisions, empty/Unicode/64-KiB messages, mixed action/no-action
prompts, dismissal, suppression, disabled auto-dismiss, and a duplicate
arriving 999 microseconds into a 1 ms timeout.
- Scoped Rust formatting and `git diff --check` passed.

The follow-up cleanup was validated with automated tests, not a visual
app run.

### Original contributor's manual testing

The original contributor reported manual testing on Linux (X11, XFCE),
using ZLS 0.17.0 with Zig 0.18.0-dev to produce a version-mismatch
warning.
They also supplied this alternative rust-analyzer configuration for
triggering a warning:

```json
{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "checkOnSave": "invalid"
      }
    }
  }
}
```

1. Open a file handled by the affected language server and wait for its
warning notification.
2. Run `theme selector: toggle` and move through several themes.
3. Check that identical actionless notifications do not stack.

## Original contributor's 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 duplicate language server notifications appearing when switching
themes.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-11-16 10:57:46 +00:00
Ben Brandt 12c1fc907f agent: Prompt for always_confirm patterns on in-project file edits (#67037)
`edit_file` and `write_file` skip the permission prompt for files inside
the project whenever the settings decision is `Confirm`. That is
intended for a `confirm` default, where in-project edits are reviewed
after the agent makes them. It also swallowed explicit `always_confirm`
patterns, which the docs say always prompt.

- `authorize_file_edit` now prompts when an `always_confirm` pattern
matches the path. It checks both the raw path and its normalized form,
so a `..` segment can't sidestep a pattern.
- A `confirm` default is unchanged: in-project edits still don't prompt.
- The docs, `default.json` and the `ToolPermissionMode::Confirm` doc
comment described `confirm` as "always prompt". They now describe what
the edit tools do with a `confirm` default and point to `always_confirm`
for prompting on specific files.

Related to #62276. This is an alternative to #66684, which would prompt
on every in-project edit under the default settings.

Release Notes:

- Fixed `always_confirm` patterns for the `edit_file` and `write_file`
agent tools not prompting for files inside the project.
2026-11-16 10:41:11 +00:00
Remco Smits 6c7508a133 fs: Reduce time spend for hashing WatchKey in watcher_ids_covering (#67008)
## Summary

follow-up on https://github.com/zed-industries/zed/pull/66973 and
https://github.com/zed-industries/zed/pull/66990

While working on https://github.com/zed-industries/zed/pull/66973 and
https://github.com/zed-industries/zed/pull/66990 I noticed that we spend
alot of time hashing the WatchKey. This was for a clean `cargo build`
around **~11s** which is alot, it was half of the time we spend inside
`watcher_ids_covering` before
https://github.com/zed-industries/zed/pull/66990 which removed the other
**~8s** overhead to around **~900ms**.

This PR uses the faster hasher `FxHasher` instead of the default one.
This reduces the time spend hashing for the **WatchKey** by around
**~3s**.

| Sampled operation | Standard hasher | Fx hasher | Reduction |
|---|---:|---:|---:|
| Ancestor matching overall | 14.42 s | **11.14 s** | **22.7%** |
| Hash-map lookups | 10.75 s | **7.49 s** | **30.3%** |
| Hash construction within lookups | 10.30 s | **7.14 s** | **30.7%** |
| Dispatch batch overall | 16.42 s | **13.16 s** | **19.9%** |

**Before**:
<img width="1277" height="462" alt="Screenshot 2026-11-14 at 20 41 25"
src="https://github.com/user-attachments/assets/28292e1d-2d8c-441c-bbee-70e0af5a741e"
/>

**After**:

<img width="1277" height="463" alt="Screenshot 2026-11-15 at 17 37 36"
src="https://github.com/user-attachments/assets/acee4ba5-7e9e-4c00-bc9b-39e9b6e47f47"
/>

## Testing

No behavior changes are expected and should be there, just a pure
performance boost for handling FS events :).

## 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 responsiveness during heavy filesystem activity by reducing
filesystem watcher path-matching overhead.
2026-11-16 09:45:06 +00:00
Sha1rholder a57e2fdc38 Unifying agent instructions to AGENTS.md (#66716)
## Summary

Closes #66715

It's a follow-up of #45939

## Testing

This PR includes two commits. The first commit only removes CLAUDE.md
and GEMINI.md, and the second involves changes to
[dangerfile.ts](https://github.com/zed-industries/zed/blob/main/script/danger/dangerfile.ts).

Reset the second if not favored.

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

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-11-16 06:53:33 +00:00
Parker Loflin 053d91cb14 agent_ui: Check for an empty message without copying the text (#67020)
## Summary

`MessageEditor::is_empty` copied the whole draft with `text(cx)` to
check whether it was blank. It now reads characters from the buffer
until one isn't whitespace. `str::trim` removes exactly the characters
that `char::is_whitespace` matches, so the result is the same.

The thread view calls it on every render, through `render_send_button`.
The thread view's observer on the message editor also copied the text
each time the editor notified, to check for an empty draft. It now uses
`Editor::is_empty`, which reads the buffer length.

Both `is_empty` checks timed on a `rope::Rope` in a release build,
median per call:

| Draft size | Before | After | Speedup |
|---|---|---|---|
| 1 KB | 112 ns | 22 ns | 5x |
| 16 KB | 1.1 µs | 24 ns | 46x |
| 256 KB | 16.6 µs | 28 ns | 590x |
| 4 MB | 271 µs | 33 ns | 8,200x |

## Testing

- `cargo test -p agent_ui --lib message_editor` passes.
- `cargo test -p agent_ui --lib conversation_view` passes.
- `./script/clippy -p agent_ui` passes.

## 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
2026-11-16 01:11:44 +00:00
Parker Loflin 125ca8672e util: Avoid allocating when sorting paths by extension (#67019)
## Summary

With `"sort_order": "extension"`, `compare_rel_paths_by` compared
extensions with `to_lowercase()`, which allocates two `String`s for each
pair of file names it compares. `compare_lowercase` compares ASCII
strings by their lowercased bytes and falls back to `to_lowercase()`
otherwise. For ASCII, `to_lowercase()` only lowercases each byte, so the
order is unchanged.

The project panel sorts its visible entries with this comparator, on a
background thread, each time it rebuilds them.

`cargo bench -p project_panel --bench sorting`, which sorts 96k entries
from a Linux checkout, in extension order:

| Sort mode | Before | After |
|---|---|---|
| `DirectoriesFirst` | 39.7 ms | 14.7 ms |
| `Mixed` | 38.6 ms | 12.4 ms |
| `FilesFirst` | 35.4 ms | 11.6 ms |

The other sort orders don't run this code. They measured 1 to 3% faster,
as did Unicode order, which this change can't affect, so that difference
is noise.

## Testing

- `cargo test -p util --lib paths` passes.
- `cargo test -p project_panel` passes.
- `./script/clippy -p util` passes.
- Outside Zed, `compare_lowercase` matched
`a.to_lowercase().cmp(&b.to_lowercase())` on 6 million random pairs of
ASCII and non-ASCII strings, and on every pair of the 252 extensions in
the benchmark snapshot.

## 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
2026-11-16 00:05:19 +00:00
Parker Loflin 310bba2f2f util: Return early from natural_sort for equal strings (#67016)
## Summary

`compare_rel_paths_by` compares paths one component at a time. In the
default `DirectoriesFirst` mode it calls `natural_sort` on each pair of
components, including the parent directories the two paths share.
`natural_sort` walked equal strings character by character before
returning `Equal`. It now checks `a == b` first. For equal strings the
loop already returned `Equal`, so results are unchanged.

The project panel sorts its visible entries with this comparator, on a
background thread, each time it rebuilds them.

`cargo bench -p project_panel --bench sorting`, which sorts 96k entries
from a Linux checkout, in `DirectoriesFirst` mode:

| Sort order | Before | After |
|---|---|---|
| Default | 12.5 ms | 10.1 ms |
| Upper | 11.8 ms | 9.5 ms |
| Lower | 13.2 ms | 10.7 ms |
| Extension | 40.0 ms | 36.9 ms |
| Unicode | 8.4 ms | 8.3 ms |

Unicode order doesn't call `natural_sort`. `Mixed` and `FilesFirst` are
unchanged, because they go through `natural_sort_no_tiebreak`, which
already returns early for names that are equal ignoring ASCII case.

## Testing

- `cargo test -p util --lib paths` passes.
- `cargo test -p project_panel` passes.
- `./script/clippy -p util` passes.

## 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
2026-11-16 00:02:04 +00:00
Parker Loflin 6b72097302 terminal_view: Avoid cloning text runs before shaping (#67013)
## Summary

`BatchedTextRun::paint` passed `self.text.clone().into()` to
`shape_line`. That cloned the `String`, then copied it again into the
`SharedString`. `self.text.as_str().into()` copies it once. Runs of 23
bytes or less are stored inline and no longer allocate.

`TerminalElement::paint` calls it for every text run. A run is a span of
adjacent cells on one line with the same style.

The two expressions timed outside Zed in a release build, median per
call including the drop:

| Run length | `text.clone().into()` | `text.as_str().into()` |
|---|---|---|
| 8 bytes | 13.5 ns | 4.8 ns |
| 16 bytes | 13.2 ns | 4.5 ns |
| 40 bytes | 22.6 ns | 12.8 ns |
| 80 bytes | 22.0 ns | 13.0 ns |
| 200 bytes | 22.6 ns | 13.2 ns |

That is about 9 ns per run. Paint time in the terminal was not measured.

## Testing

- `cargo test -p terminal_view --lib terminal_element` passes.
- `./script/clippy -p terminal_view` passes.

## 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
2026-11-15 22:50:49 +00:00
Parker Loflin 021c7d4c4f language: Split buffer operations in linear time (#67014)
## Summary

`split_operations` took each 100-operation chunk with `Vec::drain(..n)`,
which shifts every remaining operation, so splitting was quadratic in
the number of operations. This iterates the operations once. The chunks
are unchanged, including the trailing empty chunk that
`create_buffer_for_peer` sends as the last one.

`create_buffer_for_peer` splits a buffer's full operation history when a
guest or remote client opens the buffer. Reconnecting projects and
channel buffers split the operations the other side is missing.

Time to split one list of edit operations, outside Zed in a release
build:

| Operations | Before | After |
|---|---|---|
| 10,000 | 192 µs | 12 µs |
| 100,000 | 25.8 ms | 123 µs |
| 250,000 | 171 ms | 502 µs |

## Testing

- `cargo test -p language --lib` passes.
- `cargo test -p remote_server --lib` passes.
- The collab `integration_tests`, `channel_buffer_tests` and
`remote_editing_collaboration_tests` pass.
- `./script/clippy -p language` passes.

## 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
2026-11-15 22:49:03 +00:00
Remco Smits 24d3772111 fs: Fix wrong cfg guard for fast path for macos only (#67006)
## Summary

In https://github.com/zed-industries/zed/pull/66973 I introduced a
faster path for matching on macos, but I actually guarded it for linux
also, but that is not correct. Since the following code (what expensive
is on macos) was only guarded on macos.

So we should make the parent also guard for macos only.. this was a
mistake from me.


https://github.com/zed-industries/zed/blob/596dfdcf32d85d4d8d17a8887b4d0979ec7c5e14/crates/fs/src/fs_watcher.rs#L561-L577

## Testing

This changes nothing for macos, just so we don't also do the same path
for linux.

## 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
2026-11-15 18:34:23 +00:00
Parker Loflin 596dfdcf32 language: Reset max start depth on pooled query cursors (#66983)
## Summary

`QueryCursorHandle` returns its cursor to a shared pool on drop. It
reset the cursor's byte and point ranges but not `max_start_depth`, and
tree-sitter keeps that setting across executions.

Only `SyntaxMapMatches` sets a depth, and it sets one on every query.
The other pool users never set it: highlight captures, injection
queries, `SyntaxLayer::override_id`, and `with_query_cursor`. After a
depth-limited matches query, the next of those to take the same cursor
matched only nodes within that depth. `Drop` now clears it.

The depth-limited queries are the text object queries behind Vim's
method, section, and comment motions (`] m`, `] ]`, `] /`), with depths
of 3 to 6. Missing highlights after those motions are inferred from the
code; only the syntax map is tested.

## Testing

`cargo test -p language --lib` passes.
`test_max_start_depth_does_not_carry_over_to_later_queries` is new and
fails without the fix.

## 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 syntax highlighting sometimes going missing after Vim method,
section, and comment motions
2026-11-15 09:13:15 +00:00
Parker Loflin 5f27a0a02a fuzzy: Move segment results instead of cloning them (#66982)
## Summary

The string and path-set matchers in `fuzzy` and `fuzzy_nucleo` collect
matches per segment. They merged the segments with
`segment_results.concat()`, which clones every element. Each match was
copied (a `String` and a `Vec` for `fuzzy::StringMatch`) and the
original dropped, before the results were truncated to `max_results`.
This moves the matches.

`cargo bench -p fuzzy_nucleo --bench match_benchmark`, string matching
with 1-word queries:

| Benchmark | Before | After |
|---|---|---|
| `1-word/fuzzy/1000` | 67.9 µs | 58.4 µs |
| `1-word/fuzzy/10000` | 532 µs | 444 µs |
| `1-word/nucleo/1000` | 67.2 µs | 62.0 µs |
| `1-word/nucleo/10000` | 472 µs | 406 µs |

The 2- and 4-word groups match fewer candidates and improved by 2% to
22%. The path groups in that benchmark use `match_fixed_path_set`, which
this does not change.

A copy of the merge step outside Zed, merging 10,000 `StringMatch`
values from 16 segments: 412 µs before, 75 µs after.

## Testing

`cargo test -p fuzzy --features path/test-support`, `cargo test -p
fuzzy_nucleo`, and `cargo test -p file_finder --lib` pass.

## 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 fuzzy matching performance when many candidates match
2026-11-15 09:13:12 +00:00
Parker Loflin fb62376caa agent: Read buffer length without copying the text (#66981)
## Summary

`get_buffer_content_or_outline` chooses between a file's full text and
its outline by size. It measured the size with `buffer.text().len()`,
which copies the whole buffer into a `String`. `buffer.len()` reads the
same length from the rope's summary.

This runs on the main thread when the read file tool reads a file
without a line range and when a file is mentioned as context.

Both expressions timed on a `text::Buffer` in a release build:

| Buffer size | `text().len()` | `len()` |
|---|---|---|
| 16 KB | 1.8 µs | < 0.1 µs |
| 256 KB | 25 µs | < 0.1 µs |
| 4 MB | 398 µs | < 0.1 µs |
| 64 MB | 22 ms | < 0.1 µs |

## Testing

`cargo test -p agent --lib outline` passes.

## 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
2026-11-15 09:13:10 +00:00
肆意妄为 e2f00a41ac Fix antialiased outline compositing on Windows (#66972)
## Summary

Antialiased rounded outlines can show dark spots on Windows when the
quad background is transparent black. The shader interpolates
straight-alpha colors at the inner edge, which mixes the transparent
background's RGB into partially covered border pixels.

Apply inner-edge coverage to the border alpha before compositing. Handle
zero combined alpha without dividing by zero.

## Testing

Windows 11 at 100% display scaling. I compared screenshots from the
original and patched Direct3D shaders using agent-desktop.

**Zed**  
The built-in onboarding page was pixel-identical before and after the
fix with the normal renderer configuration. To reproduce the affected
path in Zed, I applied the same temporary probe to both shaders to set
the RGB of transparent bordered backgrounds to black. I then measured
the default state of the two outlined buttons under **Import Settings**.

| Button | Corner pixels darker than both the straight border and the
page background |
| --- | ---: |
| VS Code | 8 → 0 |
| Cursor | 16 → 0 |

The top and bottom borders remained one physical pixel wide. This check
used an existing Zed debug build, which compiles the HLSL at startup.

**Material Gallery**  
On the **Loading indicator** page, I compared the **Start loading**
outlined button at rest and while held down. For the held state, a
temporary Gallery build dispatched a mouse-down event and captured the
rendered frame before mouse-up.

| State | Corner pixels darker than the straight border |
| --- | ---: |
| Default | 68 → 0 |
| Held | 24 → 0 |

All four straight edges remained one physical pixel wide in both states.
The held state retained its smaller corner radius and darker fill. The
Windows quad shaders also compiled successfully with Direct3D.

Release Notes:

- [GPUI] Fixed dark spots on antialiased rounded outlines.

---------

Co-authored-by: John Tur <john-tur@outlook.com>
2026-11-15 05:20:14 +00:00
Ben Brandt 703b5ac3f4 Update ACP SDK to 5.3.0 and follow schema 1.18 rule changes (#66979)
Updates `agent-client-protocol` to 5.3.0 (schema 1.18.0) and brings what
Zed already implements in line with the rules that changed.

- **Plan operations: the `file` plan type is removed.** Markdown plans
carry an optional absolute `path` instead, and the client always renders
`content`. A markdown plan with a `path` keeps the collapsible plan row
and gets an "Open Plan File" button. A relative `path` is ignored, so
the plan has no file. Naming or changing the file counts as a change to
the plan, so it re-shows a dismissed plan, as a new URI did for file
plans.
- **Unknown v2 command types are no longer offered as slash commands.**
The spec used to let a client show a command type it doesn't understand
as a plain command. It now says the client must not. The composer only
offers `command` entries for completion, input hints, validation, and
the "/ for commands" placeholder. `AcpThread` still keeps the full list.
This also covers the new `skill` entries, which Zed doesn't advertise
support for.
- **The new `speed` config option category converts from v1.** The
`unstable` SDK feature now parses `speed` as a known category. The v1
conversion rejected categories it didn't list, so one `speed` option
would have failed the agent's whole option list.

Checked against the 1.18 docs, no change needed:

- `replay_complete` (v2) is ignored. Zed still treats the
`session/resume` response as the end of replay and discards the thread
when a resume fails, and the RFD keeps the subagent freshness boundary
at the response.
- The subagent clarifications already hold. An `unknown` state shows as
unconfirmed, and a session message without a sender renders as a message
from another session.
- Zed doesn't send `tool_call/cancel` or `terminal/cancel` once the tool
call is final or the terminal has exited.
- Zed doesn't call `session/options` or `session/fork`, so the new rules
for them don't apply.

Not adopted yet: prompt suggestions, Agent Skills, placing `speed`
options next to the model selector, and using `replay_complete` to show
replayed history before the resume response.

Release Notes:

- N/A
2026-11-14 22:52:04 +00:00
Bennet Bo Fenner 15d136bf8e Fix R extension recommendations for unsupported file types (#66928)
Remove `.qmd`, `.Rmd`, and `.rmd` from the R extension recommendation
table, retaining `.r` and `.R`.

## Root cause

#63211 expanded the recommendation table using the language
configurations in extension source repositories. For R, those sources
already included a separate RMarkdown language with `path_suffixes =
["Rmd", "rmd", "qmd"]`, introduced in ocsmit/zed-r#42 and included in
version 0.2.6.

However, the extension registry still publishes R 0.2.5, which only
registers `.r` and `.R`. The recommendation therefore offers an
extension that cannot provide a language for the file that triggered it.
The source configuration was ahead of the published package; the
mappings were not valid for the version users could install.

The registry update in
https://github.com/zed-industries/extensions/pull/7288 remains blocked
on extension CI. Remove these recommendations for now rather than
suggest unavailable support. They can be restored once a working release
with RMarkdown support is published.

Release Notes:

- Fixed incorrect R extension installation suggestions for Quarto and R
Markdown files.

---------

Co-authored-by: Finn Evers <finn@zed.dev>
2026-11-14 19:33:53 +00:00
Parker Loflin 56a157e5b0 language: Reset unused-code state when seeking buffer chunks (#66977)
## Summary

`BufferChunks::seek` rebuilds the diagnostic endpoints and zeroes the
severity depths, but it left `unnecessary_depth` alone. After a seek
from inside an unnecessary-code diagnostic, every later chunk reported
`is_unnecessary`. `initialize_diagnostic_endpoints` now zeroes it with
the other depths.

`FoldChunks` seeks when it skips a fold, so text after a fold that
starts in unused code could render faded. That symptom is inferred from
the code; only the iterator is tested.

`seek` also called `initialize_diagnostic_endpoints` twice when the
iterator used cached highlights. The first call is removed.

A standalone release binary linked against `language` timed `seek` on an
iterator with cached highlights. The buffer is 4,000 lines of Rust with
a diagnostic on each of the first 2,000 lines. Each seek stays inside
the iterator's current range so highlights are not re-fetched.

Median time per seek:

| Diagnostics in seek range | Before | After |
|---|---|---|
| 0 | 210 ns | 114 ns |
| 1 | 0.77 µs | 0.40 µs |
| 10 | 1.28 µs | 0.68 µs |
| 100 | 6.7 µs | 3.4 µs |
| 1,000 | 59 µs | 29 µs |

## Testing

`cargo test -p language -- chunk diagnostic` passes.
`test_chunks_seek_out_of_unnecessary_diagnostic` is new and fails
without the fix.

## 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 unused-code fading sometimes extending past the unused code
2026-11-14 16:22:22 +00:00
Parker Loflin 62cb1ac7b1 editor: Avoid cloning line text before shaping (#66978)
## Summary

`LineWithInvisibles::from_chunks` passed `line.clone().into()` to
`shape_line` at each line break. That cloned the `String`, then copied
it again into the `SharedString`. `line.as_str().into()` copies it once,
as the other `shape_line` call in this function already does.

The two expressions timed outside Zed in a release build, median per
call including the drop:

| Line length | `line.clone().into()` | `line.as_str().into()` |
|---|---|---|
| 16 bytes | 11 ns | 7 ns |
| 40 bytes | 25 ns | 11 ns |
| 80 bytes | 17 ns | 12 ns |
| 120 bytes | 17 ns | 12 ns |
| 400 bytes | 22 ns | 15 ns |

That is 4 to 14 ns per row, about 1 µs per 100 rows laid out. Layout
time in the editor was not measured.

## Testing

`cargo test -p editor --lib element::tests` passes.

## 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
2026-11-14 16:21:50 +00:00
Parker Loflin 4cc3e27d9d editor: Build completion sort keys once per match (#66959)
## Summary

The completions menu sorts its matches on the main thread on every
keystroke while it is open. `sort_unstable_by_key` builds the sort key
twice per comparison, and the key clones the match positions and scans
the candidate. `sort_by_cached_key` builds each key once.

The sort is now stable: ties keep the fuzzy matcher order.

A copy of the key function outside Zed, sorting 1000 synthetic matches:
1.75 ms before, 0.13 ms after (about 20,500 key builds down to 1,000).

## Testing

`cargo test -p editor --lib completion` passes, including the sort-order
tests in `code_completion_tests.rs`.

## Self-review

- [x] I have 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 responsiveness of the completions menu with many matches
2026-11-14 16:03:17 +00:00
Remco Smits 99c890d39d fs: Optimize filesystem watcher path matching (#66973)
## Summary

While working on https://github.com/zed-industries/zed/pull/66835 and
https://github.com/zed-industries/zed/discussions/66325 I noticed some
`ERROR [fs::fs_watcher] Native filesystem watcher requested rescan:
reason="rescan: user dropped"` error messages. While looking into the
root cause which is hard to find because there is no known reason the
`user dropped` message occurs, I noticed with some profiling code & the
`dev: debug filesystem watching` panel that while you are doing a clean
`cargo build` the **FS** queue builds up to around **68.000** events
which is bad, because Zed should be able to keep up with those FS events
that are produced by **cargo**.

So I went ahead and looked into this performance issue, and found that
one major bottleneck was filesystem event routing repeatedly normalizing
and lowercasing the same path prefixes for every ancestor lookup. This
was particularly expensive for deeply nested build output paths, that
cargo produces when you do a cargo build for the Zed repo.

By processing each event path once and reusing its ancestors for
case-insensitive lookups, average routing time per event dropped by
approximately **76%** across three before-and-after clean `cargo build`
runs, substantially reducing the event backlog :).

| Metric | Before 1 | Before 2 | Before 3 | After 1 | After 2 | After 3
| Average performance gain |
|---|---:|---:|---:|---:|---:|---:|---:|
| Notifications received | 213,209 | 213,237 | 213,222 | 213,613 |
213,507 | 213,603 | Comparable (+0.16%) |
| Average routing/event | 562 µs | 559 µs | 565 µs | 143 µs | 130 µs |
135 µs | **75.8% lower** |
| Total routing wall time | 119.85 s | 119.16 s | 120.46 s | 30.48 s |
27.66 s | 28.90 s | **75.8% lower** |
| Total dispatch wall time | 123.30 s | 122.56 s | 124.13 s | 33.34 s |
30.32 s | 31.71 s | **74.2% lower** |
| Observed queue peak | 67,122 | 68,058 | 67,933 | 6,269 | 1,566 | 4,653
| **93.9% lower** |
| Average queue wait | 16.58 s | 16.96 s | 17.35 s | 132 ms | 23 ms |
104 ms | **99.5% lower** |
| Maximum queue wait | 47.57 s | 46.95 s | 50.43 s | 1.45 s | 339 ms |
983 ms | **98.1% lower** |

## Testing

**Note**: I didn't add a test since there is already tests covering this
part and there should be no behavior changes, just a pure performance
gain :).

You can test the performance gain by opening Zed via a second a Zed repo
clone, remove the **target** folder & its files and run cargo build
inside the build in terminal, and open the `dev: debug filesystem
watching` notice the **before** and **after** peak queue size for
example.

## 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 responsiveness during heavy filesystem activity by reducing
filesystem watcher path-matching overhead.
2026-11-14 13:43:29 +00:00
TORANOSUKE TANIGAKI 2568d560f1 settings_content: Fix outdated defaults in setting doc comments (#66974)
## Summary

> In the doc comments inside Zed's settings code, there were 11 settings
where the default value written after "Default:" differs from the actual
default value (`default.json`).
>
> For `terminal.bell`, the description of the PR that added it (#53752)
says it is "enabled by default", but the merged value is `"off"`, and
the release note also says "can be enabled by setting `terminal.bell` to
`"system"`", so I judged that `"off"` is correct.
>
> This is related to #53323, but I did not fix the settings mentioned in
that issue (such as `proxy`), so I did not use "Closes".

(Machine-translated from Japanese. Original:)

Zed
の設定のコード内にある説明コメントで、「Default:」に書かれた既定値が、実際の既定値(`default.json`)と違うものが11個ありました。

`terminal.bell` は、追加したPR(#53752)の本文に「既定で有効」とありますが、マージされた値は
`"off"`、リリースノートも「`"system"` にすると有効になる」となっていたので、`"off"` が正しいと判断。

#53323 に関連しますが、この issue で挙げられている設定(`proxy` など)は直していないので、Closes にはしていない。

| Setting | Doc comment said | `default.json` |
| --- | --- | --- |
| `expand_excerpt_lines` | `3` | `5` |
| `diagnostics_max_severity` | `warning` | `all` |
| `terminal.line_height` | `comfortable` | `standard` |
| `terminal.bell` | `"system"` | `"off"` |
| `pane_split_direction_horizontal` | `"up"` | `"down"` |
| `pane_split_direction_vertical` | `"left"` | `"right"` |
| `tabs.show_close_button` | `false` | `hover` |
| `git.branch_picker.show_author_name` | `false` | `true` |
| `file_finder.prefill_query_from_selection` | `true` | `false` |
| `base_keymap` | `VSCode` | `Zed` |
| `agent.thinking_display` | `automatic` | `auto` |

## Testing
> In the installed Zed, when I wrote `"expand_excerpt_lines": 5` in
settings.json and hovered over it, it showed "Default: 3" even though
the actual default is 5. For settings with a fixed set of values (such
as `bell`), hovering only shows the description of the value, so the
`Default:` line is only visible for number and true/false settings.

(Machine-translated from Japanese. Original:)

インストール版の Zed で settings.json に `"expand_excerpt_lines": 5`
を書いてホバーすると、実際の既定値は 5 なのに「Default: 3」と表示された。選択肢の設定(`bell`
など)はホバーで値の説明しか出ないので、`Default:` の行が見えるのは数値や true/false の設定だけだった。

<img width="890" height="223" alt="zed-hover-default"
src="https://github.com/user-attachments/assets/d43170df-610c-4d74-bd5c-3e1e5391ad9f"
/>

Doc comments only; no code changes.

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

- N/A
2026-11-14 13:43:14 +00:00
Ben Brandt 0cfc4a483d Switch async-task back to upstream (#66968)
Replace the Zed fork of `async-task` with upstream now that
https://github.com/smol-rs/async-task/pull/108 has merged.

Pin the upstream merge commit `41fd3359c75e221bd8b187a8ee361aa309c1714c`
to preserve the task waker identity fix. The latest crates.io release is
still 4.7.1 and does not include the fix, so retain the crates.io patch
until a release is available. Update the lockfile without changing other
dependencies.

Release Notes:

- N/A
2026-11-14 11:41:42 +00:00
Parker Loflin 0d3c40e1b9 worktree: Sort removed entry ids once (#66962)
## Summary

`remove_path_from_snapshot` kept `removed_ids` sorted by inserting each
id at its sorted position. Entries are visited in path order but ids are
assigned in scan order, so most inserts shift part of the `Vec`, and
removing a large subtree is quadratic. This pushes the ids and sorts
once and the resulting `Vec` is the same.

The function runs under the scanner state lock whenever a path is
removed or recursively refreshed. For a directory, that is its whole
loaded subtree.

Times for just the loop:

| Entries | Ids | Before | After |
|---|---|---|---|
| 17,645 | from the scanner | 8.8 ms | 0.19 ms |
| 20,018 | synthetic | 9.1 ms | 0.20 ms |
| 100,010 | synthetic | 195 ms | 1.1 ms |
| 500,005 | synthetic | 5.0 s | 7.0 ms |

The scanner ids were dumped in path order from a scan in a test. The
synthetic ids are assigned breadth-first to a random tree.

## Testing

- The `worktree` integration tests pass
- `./script/clippy -p worktree` passes.

## Self-review

- [x] I have 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 worktree scanner performance when large directories are
removed or rescanned
2026-11-14 11:34:40 +00:00
Parker Loflin f53c9ae3d6 proto: Split worktree updates in linear time (#66961)
## Summary

`split_worktree_update` took each 256-entry chunk with
`Vec::drain(..n)`, which shifts every remaining entry, so splitting was
quadratic in the number of entries. The first update for a worktree
carries every entry. It is split when a project is shared or served by a
remote server, and by collab when a guest joins.

This iterates the entries once, as `split_repository_update` already
does. The chunks are unchanged.

Time to split one update:

| Entries | Before | After |
|---|---|---|
| 100,000 | 71 ms | 2.8 ms |
| 500,000 | 1.6 s | 22 ms |
| 1,000,000 | 7.2 s | 46 ms |

## Testing

- The four `worktree` integration tests that relay chunked updates into
a remote worktree pass.
- `./script/clippy -p proto` passes.

## Self-review

- [x] I have 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 the time to share or remotely open projects with very many
files
2026-11-14 11:34:22 +00:00
Parker Loflin d0400aaf03 gpui: Match keystrokes before context predicates (#66634)
## Summary

`Keymap::resolve_bindings_for_input` now matches keystrokes before
evaluating context predicates. Keystroke matching is cheaper and rejects
most bindings. Both checks are just pure filters so lookup results are
identical.

Avg time per `Keymap::bindings_for_input` call over 48 common keystrokes
in editor context. Windows 11 Ryzen 7 9800X3D.

| Keymap | Before | After |
|---|---|---|
| Linux | 15.5 µs | 1.26 µs |
| Linux + vim (normal mode) | 41.4 µs | 3.05 µs |
| Windows | 14.6 µs | 1.20 µs |
| Windows + vim (normal mode) | 41.5 µs | 2.97 µs |

## Testing

Windows 11, with and without vim mode: typing, `ctrl-s`, `ctrl-shift-p`
hints, `ctrl-k ctrl-c`, `ctrl-k z`, buffer search `enter` and `escape`,
and vim `i`, `escape`, `dd`, `gg`, `G`, `ciw`, `v d`. No issues found.

- `cargo test -p gpui --features test-support`: pass.
- `cargo test -p vim -p which_key`: pass.
- `cargo test -p zed -- keymap emacs keybinding`: pass.
- Lookup results match before and after for every bound keystroke
sequence and prefix, across 13 context stacks and the Linux, Windows,
and macOS keymaps, with and without vim.

## 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] Improved keybinding lookup performance.
2026-11-14 11:34:19 +00:00
Joshua Moon f0fa51bb51 gpui: Fix unused import warning with bench-support (#66905)
## Summary

Building gpui with `bench-support` alone without `test-support`, as
`cargo check -p gpui --features bench-support` and
script/gpui-bench-compare do, warns:

    warning: unused import: `DisplayId`
     --> crates/gpui/src/platform/test/platform.rs:7:32

Fix gates the import on `test-support`, like the neighboring imports
that are only used by `test-support` code.

#63039 added `bench-support` as a test dependency, and then #65059 added
the `DisplayId` imports without the same `#[cfg(...)]` its users have.

## Testing
Before

    # cargo check -p gpui --features bench-support
    [...]
    warning: unused import: `DisplayId`
     --> crates/gpui/src/platform/test/platform.rs:7:32
      |
7 | CursorStyle, DevicePixels, DisplayId, DummyKeyboardMapper,
ForegroundExecutor, Keymap,
      |                                ^^^^^^^^^
      |
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by
default
    
warning: `gpui` (lib) generated 1 warning (run `cargo fix --lib -p gpui`
to apply 1 suggestion)

After

    # cargo check -p gpui --features bench-support
    Checking gpui v0.2.2 (/home/josh/Source/zed/crates/gpui)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.14s

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

- [GPUI] N/A
2026-11-14 01:23:01 +00:00
Gregor Panek 5bd59e2e43 open_ai: Add GPT-6.1 Terra (#66659)
## Summary

Make GPT-6.1 Terra available for openai models


Release Notes:

- open_ai: Added support for GPT 6.1 Terra

---------

Co-authored-by: Anant Goel <anant@zed.dev>
2026-11-14 01:07:10 +00:00
Nikhil Sood 06999050d6 agent: Stream thread saves into zstd instead of buffering the JSON (#66683)
## Summary

Closes #65622

`ThreadsDatabase::save_thread_sync` serialized the whole thread into a
JSON `String` and then compressed it with `zstd::encode_all` into a
second buffer, so every save held the full uncompressed JSON and the
compressed output at the same time. For long threads with large tool
outputs that's tens of MB per save.

This change serializes through a `BufWriter` straight into a
`zstd::stream::Encoder`, so the uncompressed JSON is never held in
memory. The `BufWriter` is flushed explicitly so write errors propagate.
Serialization and compression now both happen before taking the database
lock (serialization already did), so the lock is only held for the
insert. The stored format is unchanged: same compression level, same
JSON including the flattened `version` field, so existing rows and the
load path are unaffected.

I measured it with a standalone program (not part of this PR) on a
synthetic thread with about 54 MB of JSON, 5 runs each:

| | extra peak heap during save | serialize + compress (median) |
| --- | --- | --- |
| before | 64.2 MiB | 42.6 ms |
| after | 0.23 MiB | 31.1 ms |

The synthetic data compresses very well, so on real threads the saving
is roughly the size of the uncompressed JSON per save. The `BufWriter`
matters: without it, streaming was about 2x slower than before because
`serde_json` makes many tiny writes.

Not in this PR: the save on scroll (`ui_scroll_position` and
`draft_prompt` are part of `DbThread`, so scrolling still triggers a
full save). That seems like a separate design question. I'm happy to
look at it as a follow-up. This change also doesn't touch save ordering.
Saves for a session still go through the save worker one at a time, and
#62698 is the separate fix for stale saves.

## Testing

- Added `test_save_thread_stores_versioned_json`, which saves a thread
with a long summary (quotes, backslashes, newlines, Unicode), reads the
raw row, decompresses it, checks the `version` field, and checks that
`DbThread::from_json` restores the same value. It guards the on-disk
format, so it passes before and after the change.
- `cargo test -p agent db::` (22 tests), `./script/clippy -p agent` and
`cargo fmt --check -p agent` pass. I ran these on Linux (arm64). I
haven't tested it manually in the app.

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

- Improved memory usage when saving long agent threads.

Co-authored-by: Nikhil Sood <206686452+founderinaction@users.noreply.github.com>
2026-11-14 00:21:14 +00:00
Ben Kunkle dc93abce2f gpui: Keep macOS notification service calls off the UI thread (#66934)
## Problem

macOS notification APIs can synchronously wait for the notification
service, even when they expose completion handlers. A captured
main-thread stack showed notification dismissal blocked in
`removePendingNotificationRequestsWithIdentifiers:` →
`__NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__`. GPUI called
that API on the UI thread while holding its platform-state mutex,
freezing the interface until macOS replied.

## Changes

- Lazily start one dedicated notification thread that owns the
notification center, delegate, authorization state, and registered
categories.
- Queue posting and dismissal in FIFO order so a delayed dismissal
cannot overtake a replacement notification. Initialization and native
calls happen on the worker; notification responses still return through
the foreground executor.
- Return a `Task<()>` from `dismiss_system_notification`, allowing
callers to await completion without blocking the UI. Completion means
the platform calls returned, not that asynchronous OS work finished.
Dropping the task does not cancel dismissal. Update the other platform
implementations, example, and tests for the return type.
- Keep the unbundled-binary guard and use autorelease pools around
native work.

A stalled notification service can still delay later notification
commands, but no longer stalls the UI.

## Verification

Ran on macOS:

```sh
corgi test -p gpui -p gpui_macos --lib 'system_notification'
```

All five tests passed. The new regression test submits show/dismiss/show
commands without advancing a consumer, checks their order, and verifies
completion remains pending until acknowledgement.

The source published here is identical to that tested revision; the
subsequent commit only records the human removal of the README review
marker. No live macOS-service stall was induced, and
Linux/Windows/browser workflows were not run.

Release Notes:

- [GPUI] Fixed macOS system notification operations blocking the UI
thread while waiting for the notification service.

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2026-11-13 19:46:43 +00:00
Jakub Konka 83df5df635 Add corgi to the Nix dev shell (#66940)
Release Notes:

- N/A

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:11:44 +00:00
Anthony Eid aff99ecc32 gpui: Animate SVG transformations without re-rendering views (#66896)
## Summary

Ref #21146, #23479, #51597

One common problem that I've been working towards fixing by adding a
retained mode is Zed's high battery usage, caused by invalidating clean
entities because a single ancestor is dirty. While looking closer into
this problem I realized that a ton of the invalidations we run into are
due to animations, which can be fixed separately from retained mode.

My solution is adding a `TimedTransformation` struct and a new animation
API that uses it.

```rust
// A spinner: one full turn every two seconds.
svg()
    .path("icons/load_circle.svg")
    .with_timed_transformation(TimedTransformation::rotation(
        Duration::from_secs(2),
        Transformation::default(),
    ))

// A pulsing ring: grows to 1.5x while fading out, each value with its own easing.
svg()
    .path("icons/ring.svg")
    .with_timed_transformation(
        TimedTransformation::new(Duration::from_millis(1750))
            .from(Transformation::alpha(0.6))
            .to(Transformation::scale(size(1.5, 1.5)).with_alpha(0.))
            .with_scale_easing(Easing::EaseOutQuint),
    )
```

Because most of our animations are an SVG sprite with simple matrix
operations applied to it, such as rotation, alpha changes and size
changes, that change based on elapsed time, we can avoid invalidating
the view by extracting the before and after transformations and deriving
a function that takes elapsed time and computes what the animated sprite
should look like.

The extracted function lives in a table on the scene, and each animated
sprite points at its entry. This lets GPUI advance animations right
before presenting a frame, without dirtying the view or recomputing the
scene from scratch. This should save a lot of CPU usage and battery life
for end users of GPUI apps that use animations.

`Icon` and `Vector` in `ui` now use this for `with_rotate_animation`, so
Zed's existing spinners get it with no call site changes. With reduced
motion on, the SVG is drawn at its starting transformation and nothing
animates.

### Results

Main-thread CPU instructions for one animated frame, from a headless
benchmark on macOS with the Metal renderer (not included in this PR):

| | 200 animated SVGs | 60 rows of text + 5 spinners |
|---|---|---|
| Re-render with `with_animation` | 6.07 M | 7.34 M |
| `with_timed_transformation` | 162 K | 100 K |
| Improvement | 37x | 73x |

The `svg_animation` example (`cargo run --release -p gpui --example
svg_animation`, 200 animated SVGs in a window, Apple M4 Max), as
reported by `top`:

| | CPU | Energy impact |
|---|---|---|
| Re-render with `with_animation` | 21% | 21.5 |
| `with_timed_transformation` | 6% | 7.5 |
| `with_timed_transformation`, capped at 15 fps | 1.9% | 3.0 |

That is about 3.5x less CPU and 3x less energy impact uncapped, and
about 11x less CPU and 7x less energy impact with the cap.

### Follow ups

- Allow animating more primitives, such as glyphs, instead of only SVG
sprites
- Lower the fixed cost of presenting a frame, which is most of what
remains after this change
- Retained layers, so a whole subtree can be moved or faded without
re-rendering

Release Notes:

- Improved battery life by animating spinners without re-rendering the
views that contain them
- [GPUI] Added `TimedTransformation` and
`Svg::with_timed_transformation` to animate SVGs without re-rendering a
view
2026-11-13 16:33:49 +00:00
Fusora 563319c3f4 Sync Neovim default key mappings (#66759)
## Summary

Sync a few missing keymaps from Neovim.

## References

- https://neovim.io/doc/user/lsp/#gra
- https://neovim.io/doc/user/treesitter/#v_%5Dn

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

- Added `g r t` keymap for `editor: go to type definition`.
- Added `] n` and `[ n` keymaps for `vim: select next/previous syntax
node`.
2026-11-13 16:24:06 +00:00
Danilo Leal 69239eb540 ui: Add an icon-only variant to the toggle button component (#66937)
We didn't support having a toggle button group component with just icons
in each button, but now we do :)

## 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
2026-11-13 15:12:37 +00:00