mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
d3d58c304befb285fb515c9e0420e95bcbe4f45d
40870 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d3d58c304b |
docs: Mention that new MCP server extensions will no longer be accepted (#67045)
Release Notes: - N/A |
||
|
|
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> |
||
|
|
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. |
||
|
|
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 |
||
|
|
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 |
||
|
|
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. |
||
|
|
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> |
||
|
|
89d3da6578 |
Preserve mid-conversation system prompt updates (#66490)
Release Notes: - N/A |
||
|
|
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 |
||
|
|
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.  ## 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> |
||
|
|
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. |
||
|
|
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. |
||
|
|
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> |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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> |
||
|
|
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 |
||
|
|
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> |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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. |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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. |
||
|
|
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
|
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
83df5df635 |
Add corgi to the Nix dev shell (#66940)
Release Notes: - N/A Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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 |
||
|
|
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`. |
||
|
|
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 |
||
|
|
faf97b0a0c |
Preserve structured model refusal details (#66929)
Carry provider refusal reasons, categories, and input/output stage with refusal errors. Preserve unknown Gemini categories without interpreting them. Release Notes: - N/A |
||
|
|
cb48e27ceb |
project: Prefer musl builds of ACP registry agents on musl Linux hosts (#66914)
The ACP registry now optionally publishes `linux-{arch}-musl` targets.
On a musl host (e.g. Alpine), Zed now picks that target and falls back
to `linux-{arch}` when an agent doesn't publish one.
The host libc is detected at runtime rather than with `cfg!(target_env =
"musl")`: the Linux remote server is a static musl binary that mostly
runs on glibc hosts, and the desktop build is glibc.
- Move the libc probe from the rust-analyzer adapter into
`util::libc_type::host_libc_type()` and cache the result for the process
lifetime.
- Also read `ldd --version` stderr, which is where musl prints its
version. Previously musl hosts were only detected through the `/lib`
scan.
- Use one ordered list of registry platform keys for both the "supported
on this platform" check and the archive selection, so the registry UI
and the installer agree.
Closes #66850
Release Notes:
- Improved ACP registry agent installation on musl-based Linux systems
to use musl builds when available
|
||
|
|
af7a1adb50 |
Use full context window for Copilot models without long-context surcharge (#64302)
# Objective - Some Copilot models support 1 million token context windows without any surcharge, but Zed uses their smaller context windows by default. For models where it's free to have more context, this PR uses them. - Related to #54390 (Copilot path only), #58657 (Claude/Gemini yes, GPT/Grok intentionally not), and #63123. ## Solution - Bumped the API version used for Copilot Chat. The newer version of the `/models` response reports per-tier token pricing (`billing.token_prices`) with a `default` tier and an optional `long_context` tier, each carrying its own `max_prompt_tokens`, `input_price`, and `output_price`. ## Testing Verified against the live `/models` endpoint by diffing both API versions and applying the new `max_token_count` logic. Reproducible with an authenticated `gh` (the Copilot `/models` endpoint accepts a `gh` OAuth token directly): ```bash TOKEN=$(gh auth token) models() { curl -s -H "Authorization: Bearer $TOKEN" -H "X-GitHub-Api-Version: $1" \ https://api.githubcopilot.com/models; } # /models is non-deterministic — GitHub serves one of a few different model sets # regardless of API version — so retry until both versions return the same IDs. for _ in $(seq 1 20); do old=$(models 2025-10-01); new=$(models 2026-08-01) a=$(printf '%s' "$old" | jq -r '.data[].id' | sort) b=$(printf '%s' "$new" | jq -r '.data[].id' | sort) [ "$a" = "$b" ] && break done [ "$a" = "$b" ] || { echo "could not get matching model sets" >&2; exit 1; } jq -s -r ' (.[0].data | map({(.id): .capabilities.limits.max_context_window_tokens}) | add) as $old | .[1].data[] | select(.capabilities.limits.max_context_window_tokens != null) | .capabilities.limits as $lim | (.billing.token_prices // {}) as $tp | ($tp.default // {}) as $d | ($tp.long_context // null) as $lc | (($lc != null) and (($lc.input_price > $d.input_price) or ($lc.output_price > $d.output_price))) as $surcharged | (if $surcharged and (($d.max_prompt_tokens // 0) > 0) then [$d.max_prompt_tokens + ($lim.max_output_tokens // 0), $lim.max_context_window_tokens] | min else $lim.max_context_window_tokens end) as $new | [ .id, $old[.id], $lim.max_context_window_tokens, $new, (if $surcharged then "surcharged" elif $lc then "free" else "none" end), (if $new != $old[.id] then "CHANGED" else "" end) ] | @tsv ' <(printf '%s' "$old") <(printf '%s' "$new") \ | column -t -N 'MODEL,BEFORE,FULL_WINDOW,AFTER,LONG_CTX,' ``` Result (abridged; available models vary by Copilot plan): ``` MODEL BEFORE FULL_WINDOW AFTER LONG_CTX claude-opus-5 264000 1000000 1000000 free CHANGED claude-sonnet-5 264000 1000000 1000000 free CHANGED claude-fable-5.1 264000 1000000 1000000 free CHANGED claude-opus-4.8 264000 1000000 1000000 free CHANGED gemini-3.7-flash 264000 1000000 1000000 free CHANGED gemini-3.8-flash 265536 1048576 1048576 free CHANGED gpt-5.6-luna-utility 328000 1050000 1050000 none CHANGED gpt-5.4 400000 1050000 400000 surcharged gpt-5.6-luna 328000 1050000 328000 surcharged gpt-6-astra 400000 1178000 400000 surcharged grok-4.6 328000 500000 328000 surcharged gpt-4o 128000 128000 128000 none ``` Also ran `cargo test -p copilot_chat` and it passed. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Improved GitHub Copilot models to use their full context window when the provider does not charge a long-context surcharge, and to display per-token pricing where available. Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4fd48c02ac |
Miscellaneous improvements to prepare for Rust 1.100 (#66901)
## Summary Fixes rustc and clippy warnings for a potential upcoming Rust 1.100 version bump. All changes are backwards compatible and Rust is **not** bumped in this PR. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A - [GPUI] N/A --------- Co-authored-by: Finn Evers <finn.evers@outlook.de> |
||
|
|
5a40bc8bd7 |
gpui_web: Fix safe-area insets under a strict style CSP (#66907)
## Summary gpui web uses exploratory divs to learn about the unusable deadspace on the margins of a device's screen, which it calls safe-area insets. When doing this, it uses html `style` attributes with raw css parameters. In modern web development, is typical to use a `Content-Security-Policy` to block `unsafe-inline` css in html. This feature breaks when such security settings are in use. However, while raw CSS in the style element is not permitted, even with the CSP set to block `unsafe-inline` style attributes, it still permits some direct adjustments via CSSOM with `el.style.setProperty(p, v)`. This workaround is already used by gpui web on the canvas and IME elements. See * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src-attr ## Testing I have manually reviewed this change in WebKit, Chromium, and Gecko. All modern web engines support this workaround and document it as safe. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] There are no UI changes. - [x] Tests are not relevant for this change. Release Notes: - [GPUI] Fixed safe-area insets reading as zero on pages with a strict style Content-Security-Policy. |
||
|
|
48741fd17d |
which_key: Show popup above open modals (#66838)
Follow-up to #66068 With which-key enabled, the popup didn't show while a modal was open, like the commit editor or Go to Line. It was drawn as a modal, and the modal layer holds only one. It's now drawn in its own slot on `MultiWorkspace`, deferred above the modal layer like the sidebar overlay. It doesn't take focus, so the chord still completes in the open modal. <img width="500" src="https://github.com/user-attachments/assets/2089163d-e96b-4b5e-8d2d-0ca5d9826f63" /> Release Notes: - Improved the which-key popup to also show inside open dialogs, like Go to Line and the commit editor. |
||
|
|
42fa909546 |
corgi: Support building on NixOS (#66827)
Building Zed with corgi on Linux fails because corgi hands webrtc-sys and wasmtime-c-api-impl the macOS cmake and libwebrtc. Neither tool in `corgi.toml` says which platform it's for, so corgi uses them everywhere. This gives both tools a `targets` list and adds Linux x86_64 builds of each, same as Delta's `corgi.toml`. It also forwards `PKG_CONFIG`, `PKG_CONFIG_PATH` and `CMAKE` from the environment to the build scripts that need them. NixOS needs this because build scripts run in a sandbox with no environment, so they can't find pkg-config or the libraries from a Nix shell, and the downloaded Linux cmake can't run there since it expects a standard dynamic loader. With this, Zed builds on NixOS as long as the shell sets `CORGI_RUST_TOOLCHAIN`, `CORGI_CC` and `CORGI_NATIVE_RUNTIME_ROOTS`. Nothing changes on a mac. I checked, and it picks the same tools and rebuilds nothing, unless the shell already sets `PKG_CONFIG_PATH` or `CMAKE`, in which case webrtc-sys and the crates that depend on it rebuild once. One thing still doesn't work out of the box. The Linux libwebrtc is a zip, and corgi unpacks tools with `tar`, which GNU tar can't handle. I use bsdtar as `tar` locally, but this probably wants a fix in corgi. Left out on purpose: - Linux arm64 tools. - Zed's Nix dev shell. `nix develop` still doesn't include corgi or set the `CORGI_*` variables, so for now you have to set those yourself. - Non-Nix Linux like Ubuntu. Corgi needs every system library listed under `[libraries]` there, and Zed doesn't list any yet. Release Notes: - N/A |
||
|
|
27bbbc1cc4 |
languages: Highlight C/C++ preprocessor call arguments (#66875)
## Summary Arguments of `preproc_call` nodes, like the `pack(push, 4)` in `#pragma pack(push, 4)` or the `FOO` in `#undef FOO`, had no highlight capture, so they always rendered as plain text. `#define` bodies are covered by the injection, and `#if` conditions are parsed as expressions, but nothing reached `preproc_call`'s `preproc_arg`. I added a `(preproc_call argument: (preproc_arg) @preproc)` rule to both the C and C++ highlight queries. I went with `@preproc` because every built-in theme already defines it, and it makes the whole directive line one color, like VS Code does. Happy to switch to `@constant.macro` or `@string` if you'd prefer. | Before | After | | --- | --- | | <img alt="preproc-before" src="https://github.com/user-attachments/assets/95fa0660-c41f-4433-98c7-887d9871fe1d" /> | <img alt="preproc-after" src="https://github.com/user-attachments/assets/7c4fa978-a6c1-4707-a627-6d7e32dd897a" /> | | <img alt="preproc-before-light" src="https://github.com/user-attachments/assets/3d2479ce-cd04-42ae-bfeb-e5c8c49fb9a6" /> | <img alt="preproc-after-light" src="https://github.com/user-attachments/assets/8d342f73-25e2-4dae-b984-72b88fd23287" /> | `#define FOO 1` and `#if defined(BAR)` look the same before and after. Closes #66675 ## Testing - Added a query test for C and one for C++, checking that `#pragma` and `#undef` arguments are captured as `preproc` and that a `#define` body isn't. Both fail without the query change. - `cargo test -p languages` passes (105 tests), and `./script/clippy -p languages` is clean. - Built the branch on macOS and compared it with Zed 1.28.1 on the same file, in One Dark and One Light (screenshots above). To try it: open a `.c` or `.cpp` file and type `#pragma pack(push, 4)` / `#undef FOO`. The arguments should now take the directive's color. I used Claude Code to help with this change and tested it myself. ## 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 syntax highlighting of `#pragma` and `#undef` arguments in C and C++. --------- Co-authored-by: imryanthedev <352313849+imryanthedev@users.noreply.github.com> |