Commit graph

479 commits

Author SHA1 Message Date
Richard Feldman
fe9f956460
Restrict tools from editing sensitive agents folders (#56456)
Treat `.agents/skills/` (project-local) and `~/.agents/skills/` (global)
as **sensitive paths**, on par with `.zed/` and the global config
directory. The agent's built-in editing tools (`edit_file`,
`write_file`, `create_directory`, `delete_path`, `move_path`,
`copy_path`) now require explicit user authorization before modifying
anything inside those paths, because the contents of skill files control
agent behavior.

This protection is worth landing on its own, ahead of Zed adding its own
skills support: other agents (e.g. Claude Code) already write skill
files into these locations, so a Zed installation may already have
skills on disk that should not be silently editable by the agent.

Also tightens the **pre-existing `.zed/` check** to compare path
components case-insensitively. macOS and Windows use case-insensitive
filesystems by default, so without this fix a malicious settings author
could bypass the local-settings classifier with `.ZED/settings.json`
(the canonicalized inode would match, but the path-component comparison
would miss it). The new `.agents/skills/` check has the same hazard and
now shares a single `component_matches_ignore_ascii_case` helper with
the `.zed/` check.

Introduces the `agent_skills` crate, scoped for now to just the path
constants and helpers (`global_skills_dir`,
`project_skills_relative_path`, `SKILL_FILE_NAME`) so the
tool-permission machinery can recognize the agent skills tree without
depending on a skill discovery / parsing / loading layer. Those will
land in follow-up PRs.

Closes AI-217

Release Notes:

- Agent: Require user confirmation before letting tools modify files
inside `.agents/skills/` (per-project) or `~/.agents/skills/` (global),
so skills installed by any agent are protected from unsolicited edits

---------

Co-authored-by: MartinYe1234 <52641447+MartinYe1234@users.noreply.github.com>
Co-authored-by: Martin Ye <martinye022@gmail.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2026-05-12 22:47:51 +00:00
hayatosc
7b2acab040
Fix remote worktree path separators (#55486)
Self-Review Checklist:

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

Closes #54641

Release Notes:

- Fixed creating git worktrees in WSL remote projects from Windows.

## Summary

- Preserve the repository `PathStyle` when constructing git worktree
paths.
- Avoid using local OS path separators when creating worktrees for
remote Posix projects such as WSL.
- Keep worktree archive path checks aligned with the same
path-style-aware worktree directory calculation.

## Root Cause

Remote repository paths are stored as `PathBuf`s, but `PathBuf::join`
and related path operations use the client OS separator. On Windows
clients connected to WSL, this could turn a remote Linux path into a
mixed path like `/home/<user>/\home\<user>\dev\worktrees\...`, causing
worktree creation and opening to fail.

## Validation

- `cargo fmt --all --check`
- `git diff --check`
- `cargo test -p project
test_new_worktree_path_uses_posix_style_for_remote_paths`
- `cargo test -p project test_worktree_directory_uses_remote_path_style`
- `cargo test -p project test_join_path_for_style_uses_remote_separator`

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2026-05-06 00:06:51 +00:00
Anthony Eid
e5b98a5f19
Accept shell environment after non-zero shell exit (#55175)
Summary:

When a user shell hook returned an error, Zed would fail to load the
shell environment even if the captured environment output was still
valid. This could prevent the terminal panel and other shell-dependent
features, such as the debugger and agent panel, from creating terminals
or running commands. That is especially disruptive when the shell
environment is valid and a terminal could otherwise still be used.

Zed now ignores the non-zero shell exit in this case when it can still
parse a valid shell environment, allowing those features to continue
working.

Self-Review Checklist:

- [x] I have 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 shell environment loading when login shells exit non-zero after
printing environment variables.
2026-04-29 11:56:56 +00:00
Finn Evers
9b40411c6a
Fix bad GitHub merge queue merge (#54721)
No, sadly, the title is not a typo. See
https://www.githubstatus.com/incidents/zsg1lk7w13cf for the context.
I'll read with joy and popcorn through that root cause analysis.

It makes literally zero sense what happened here, but for some completly
bonkers reason GitHub completely messed up the merge queue with
https://github.com/zed-industries/zed/pull/54632.

I have no idea how it happened. It makes literally zero sense. A PR
going into the merge queue should have the same LoC when getting out of
it. GitHub obviously does not check this. GitHub causes extra work with
a feature that is supposed to save time.

Thanks, I guess.

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2026-04-23 23:47:30 +00:00
Danilo Leal
0ab64d6414
branch_picker: Add button to filter remote branches (#54632)
This PR brings back the button to filter remote branches when accessing
the title bar's branch picker with the mouse. It was unintentionally
removed when we introduced the new worktree picker.

Release Notes:

- N/A
2026-04-23 18:26:44 +00:00
Kirill Bulatov
5f68479937
Stop showing backtraces in default logging (#54660)
When using `.log_err()` or `.detach_and_log_err(cx)` or similar.

See also https://github.com/zed-industries/zed/pull/36404,
https://github.com/zed-industries/zed/pull/46383,
https://github.com/zed-industries/zed/pull/44896,
https://github.com/zed-industries/zed/pull/43917 and many more.

Before, a
62bd61a679/crates/languages/src/go.rs (L568)
line would show a backtrace even for `.context("no cached binary")?;`
case, same as many other usages around the code:

<img width="2032" height="1162" alt="before"
src="https://github.com/user-attachments/assets/ef2188b3-74c9-4c86-82b8-9fdaed3c26ae"
/>

After:

<img width="1896" height="157" alt="after"
src="https://github.com/user-attachments/assets/a1067d9f-61f4-4833-aeab-9f1042d2514a"
/>



To show a backtrace as before, use `log_err_with_backtrace`.

Release Notes:

- Improved Zed's log output on errors
2026-04-23 14:14:11 +00:00
Wuji Chen
2c49900c6a
terminal: Fix heredoc commands failing in agent shell (#49106)
Release Notes:

- Fixed heredoc commands failing with "syntax error: unexpected end of
file" in AI Agent shell execution

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2026-04-22 18:19:40 +00:00
Thomas Jensen
2542b71a24
extension_host: Fix Windows manifest paths when uploading extensions to WSL remote (#50653)
Closes #42731 

Before you mark this PR as ready for review, make sure that you have:
- [X] Added a solid test coverage and/or screenshots from doing manual
testing
- [X] Done a self-review taking into account security and performance
aspects
- [X] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

<img width="1440" height="900" alt="Screenshot 2026-03-09 at 5 10 46 PM"
src="https://github.com/user-attachments/assets/bf124481-dc10-44e9-aaab-3e562d71e41e"
/>

Release Notes:

- Fixed Windows path handling in extension manifests to ensure
extensions upload correctly to remote environments like WSL.

---------

Co-authored-by: John Tur <john-tur@outlook.com>
2026-04-21 17:32:54 -04:00
Richard Feldman
5d32b56e07
Disambiguate project names (#52848)
Disambiguate project names in the sidebar (and project picker) so that
we don't show e.g. `zed, zed` but rather `foo/zed, bar/zed` if the last
path component is the same but they are different absolute paths.

Release Notes:

- N/A
2026-04-09 14:11:55 -04:00
Dong
b150663d45
markdown_preview: Support anchor link for headings (#53184)
## What does this PR did

- Generate [GitHub-flavored heading
slugs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links)
for markdown headings
- Handle `[label](#heading)` same-document anchor links that scroll the
preview and editor to the target heading
- Handle `[label](./file.md#heading)` cross-file anchor links that open
the file, scroll the preview, and move the editor cursor to the heading


https://github.com/user-attachments/assets/ecc468bf-bed0-4543-a988-703025a61bf8

## What to test

- [ ] Create a markdown file with `[Go to section](#section-name)`
links, verify clicking scrolls preview and editor
- [ ] Create two markdown files with cross-file links like `[See
other](./other.md#heading)`, verify file opens and preview scrolls to
heading
- [ ] Verify duplicate headings produce correct slugs (`heading`,
`heading-1`)
- [ ] Verify external URLs (`https://...`) are unaffected

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content 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
- [ ] Performance impact has been considered and is acceptable

Closes #18699

Release Notes:

- Added support for anchor links for headings in Markdown Preview.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-09 21:43:51 +05:30
Dionys Steffen
320cef37f8
project_panel: Add sort_order settings (#50221)
_(Feature Requests #24962)_

_"Before you mark this PR as ready for review, make sure that you
have:"_

* [x] Added a solid test coverage and/or screenshots from doing manual
testing
* [x] Done a self-review taking into account security and performance
aspects
* [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Added a `sort_order` to `project_panel` settings which dictates how
files and directories are sorted relative to each other in a
`sort_mode`.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-08 18:33:00 +05:30
Conrad Irwin
ac6117a9d8
Fix shell escaping in getting current env (#53335)
Credit to Dario Weißer for bringing this to our attention.

Self-Review Checklist:

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

Closes #ISSUE

Release Notes:

- Fixed a bug where a cleverly crafted directory name could lead to
remote code execution
2026-04-08 02:56:06 +00:00
Max Brunsfeld
1ebcde8164
Update more sidebar interactions to use the MultiWorkspace's explicit project groups (#53174)
* Don't require a workspace to be loaded in order to render the group
header menu.
* When adding or removing root folders, do it to *every* workspace in
the group.
* When activating a thread, never open a different window, and never
open it in a workspace that's part of a different groupw with a superset
of the thread's worktrees. Find or create a workspace with the exact
right group of root folders.

Release Notes:

- N/A
2026-04-05 11:12:02 -07:00
Eric Holk
45d6a9595f
Track project groups in MultiWorkspace (#53032)
This PR adds tracking of project groups to the MultiWorkspace and
serialization/restoration of them. This will later be used by the
sidebar to provide reliable reloading of threads across Zed reloads.

Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2026-04-03 16:23:52 +00:00
Amaan
4eb7ae8108
util: Fix failed to load env variables on Windows when users have custom terminal shell args (#51787)
Closes #46933 

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] NO UI CHANGES


Release Notes:
- Fixed `Failed to load shell environment` errors on Windows when users
have custom terminal shell arguments configured (e.g., cmd.exe with `/k
echo Hello` or similar startup commands)
2026-04-02 08:39:19 +02:00
KyleBarton
3eadd41b5d
Dev containers native implementation (#52338)
## Context

Closes #11473

In-house Zed implementation of devcontainers. Replaces the dependency on
the [reference implementation](https://github.com/devcontainers/cli) via
Node.

This enables additional features with this implementation:
1. Zed extensions can be specified in the `customizations` block, via
this syntax in `devcontainer.json:
```
...
  "customizations": {
    "zed": {
      "extensions": ["vue", "ruby"],
    },
  },

```
2.
[forwardPorts](https://containers.dev/implementors/json_reference/#general-properties)
are supported for multiple ports proxied to the host

## How to Review

<!-- Help reviewers focus their attention:
- For small PRs: note what to focus on (e.g., "error handling in
foo.rs")
- For large PRs (>400 LOC): provide a guided tour — numbered list of
files/commits to read in order. (The `large-pr` label is applied
automatically.)
     - See the review process guidelines for comment conventions -->

## Self-Review Checklist

<!-- Check before requesting review: -->
- [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:

- Improved devcontainer implementation by moving initialization and
creation in-house
2026-04-01 08:16:27 -07:00
Bennet Bo Fenner
f051677010
sidebar: Rework archive feature (#52534)
## Context

<!-- What does this PR do, and why? How is it expected to impact users?
     Not just what changed, but what motivated it and why this approach.

Link to Linear issue (e.g., ENG-123) or GitHub issue (e.g., Closes #456)
     if one exists — helps with traceability. -->

## How to Review

<!-- Help reviewers focus their attention:
- For small PRs: note what to focus on (e.g., "error handling in
foo.rs")
- For large PRs (>400 LOC): provide a guided tour — numbered list of
files/commits to read in order. (The `large-pr` label is applied
automatically.)
     - See the review process guidelines for comment conventions -->

## Self-Review Checklist

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

Release Notes:

- N/A

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-03-30 10:17:48 +00:00
Lukas Wirth
354bc35974
Cut fs dependency from theme (#52482)
Trying to clean up the deps here for potential use of the ui crate in
web

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-03-27 08:17:30 +00:00
Eric Holk
d0baf212d3
Make PathList equality ignore display order (#52052)
`PathList` stores both sorted paths and the original insertion order
(for display in the project panel). Previously, `PartialEq`, `Eq`, and
`Hash` were derived, which meant two `PathList` values with the same
paths but different display orderings were considered unequal.

This change replaces the derived impls with manual ones that only
compare
the sorted `paths` field, matching the semantic intent: a `PathList`
identifies a set of directories, and the display order is not part of
that identity.

Release Notes:

- N/A
2026-03-24 15:25:35 -07:00
Artemiy
a9a85e572f
Use -e instead of -c when getting environment from nushell (#51420)
Closes #38200

Applied
[suggestion](https://github.com/zed-industries/zed/issues/38200#issuecomment-3354159899)
from issue to use `-l -e` instead of `-l -i -c` when running on nushell
because of how it treats `-l` as implying interactive session. Using
`-e` also means that command needs to end with `exit` to terminate shell
manually. With this changes everything now works fine in my testing.

Before, zed fails to load environment variables and there is error in
logs:

<img width="367" height="92" alt="image"
src="https://github.com/user-attachments/assets/9ef08d06-a509-4c96-85fe-8291bfc95b39"
/>

<img width="1711" height="115" alt="image"
src="https://github.com/user-attachments/assets/fe3a6248-6f73-4773-a2c8-db55a95aaec1"
/>

With this patch everything works fine and all language servers and stuff
loads fine:

<img width="565" height="73" alt="image"
src="https://github.com/user-attachments/assets/7477913d-42f9-41b0-a7b6-92831f406be4"
/>

Tested on nixos unstable. Nushell version 0.110.0 and 0.111.0. Zed
version 0.223.3+stable and compiled from main fail. Zed from this branch
works.

Release Notes:

- Fixed loading environment variables when nushell is used as shell
2026-03-19 09:15:34 +00:00
Bennet Bo Fenner
015225196d
Store ACP thread metadata (#51657)
Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-03-16 17:23:02 +01:00
Alex Mihaiuc
cbc39669b4
Remove std::fs::read_link in fs (#50974)
Closes #46307

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [X] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Improved compatibility with mounted VHDs on Windows.

---------

Co-authored-by: John Tur <john-tur@outlook.com>
2026-03-14 20:02:34 -04:00
hagz0r
d1a323b4ac
Fix parsing of filenames like main (1).log (#50770)
## Summary
Fixes Windows file-open parsing for names like `main (1).log`.

`PathWithPosition::parse_str` could treat `(1)` in a normal filename as
a position suffix and drop the extension/path tail. The regex is now
anchored so parenthesized row/column parsing only applies at the end of
the filename (with optional trailing `:` and optional range suffix).

## Testing
- `cargo test -p util path_with_position_parse_`

Closes #50597

Release Notes:

- Fixed opening files with names like `main (1).log` on Windows.
2026-03-10 06:57:43 +00:00
Piotr Osiewicz
97421c670e
Remove unreferenced dev dependencies (#51093)
This will help with test times (in some cases), as nextest cannot figure
out whether a given rdep is actually an alive edge of the build graph

Closes #ISSUE

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [ ] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
2026-03-09 13:22:12 +01:00
Mikayla Maki
9afeb4e11d
Implement new Multi Agent UI (#50534)
Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: Eric <eric@zed.dev>
Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Anthony Eid <anthony@zed.dev>
Co-authored-by: John Tur <john-tur@outlook.com>
2026-03-05 20:22:28 +00:00
Amaan
c091c90faf
util: Fix env load issues on Windows due to quoting (#50782)
Closes #47823 

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] No UI changes
 
Release Notes:

- Solves the issue where env variables failed to load when a project
with dir path had `'`(single quote) in them, for example:
`C:\Temp\O'Brien\project_1`.
- added a zed pre-quote for directory paths and zed executable 
- handled pwsh, nushell, cmd, fish, posix, csh, tcsh, rc, xonsh, elvish
based terminals
-  uses `try_quote` for quoting shell paths
2026-03-05 08:33:44 +00:00
Mikayla Maki
f1c5ed324b
Add folder_paths for project grouping (#50249)
Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
2026-02-26 22:32:48 +00:00
Lukas Wirth
14f37ed502
GPUI on the web (#50228)
Implements a basic web platform for the wasm32-unknown-unknown target
for gpui

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: John Tur <john-tur@outlook.com>
2026-02-26 18:36:50 +01:00
Peter Tripp
ae53f5651e
Redact environment variables from debugger errors (#50008)
Closes #50007

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

Release Notes:

- Improved redaction of sensitive environment variables from debugger
error logs.
2026-02-25 16:18:42 +01:00
Lukas Wirth
aa91fd4a96
Reduce amount of closure monomorphizations part 2 (#49688)
Release Notes:

- N/A *or* Added/Fixed/Improved ...
2026-02-20 08:32:45 +00:00
Richard Feldman
5b0a3de01c
Add agent worktree directory setting + worktree info persistence (#49139)
Add `agent_worktree_directory` to `GitSettings` for configuring where
agent worktrees are stored (default: Zed data dir). Remove `Copy` derive
from `GitSettings`/`GitContentSettings` (incompatible with String field)
and fix downstream `.as_ref().unwrap()` call sites.

Define `AgentGitWorktreeInfo` (branch, worktree_path, base_ref) and add
it to `DbThread` + `DbThreadMetadata` for persistence and session list
display.

Closes AI-33

Release Notes:

- N/A
2026-02-18 22:20:31 +00:00
John Tur
d168301c5d
Reuse existing remote workspaces when opening files from the CLI (#49307)
Re-lands https://github.com/zed-industries/zed/pull/48891, which was
reverted due to conflicts with multi-workspace.

Before you mark this PR as ready for review, make sure that you have:
- [X] Added a solid test coverage and/or screenshots from doing manual
testing
- [X] Done a self-review taking into account security and performance
aspects

Release Notes:

- N/A
2026-02-16 18:03:18 -05:00
Luis
27ab898e65
project_panel: Fix mixed sort with incorrect ordering when same file and dir name (#47863)
Closes #47678

When using mixed sort mode in the project panel, a folder and file with
the same name but different case (e.g., `hello` folder and `Hello.txt`
file) would sort incorrectly. The file could appear between an expanded
folder and its contents.

The issue was in `compare_rel_paths_mixed`: the tie-breaker logic used
case-sensitive comparison (`a == b`) to decide directory-before-file
ordering, but `natural_sort_no_tiebreak` already considers entries equal
case-insensitively. Changed to use `eq_ignore_ascii_case` to match.

Release Notes:

- Fixed project panel mixed sort mode ordering incorrectly when a file
and folder share the same name with different casing.
2026-02-16 19:08:13 +05:30
Jakub Konka
16dfc60ad2
util: Always use posix_spawn on macOS even with pre_exec hooks (#49090)
Here's some backstory:
* on macOS, @cole-miller and I noticed that since roughly Oct 2025, due
to some changes to latest macOS Tahoe, for any spawned child process we
needed to reset Mach exception ports
(https://github.com/zed-industries/zed/issues/36754 +
6e8f2d2ebe)
* the changes in that PR achieve that via `pre_exec` hook on
`std::process::Command` which then abandons `posix_spawn` syscall for
`fork` + `execve` dance on macOS (we tracked it down in Rust's std
implementation)
* as it turns out, `fork` + `execve` is pretty expensive on macOS
(apparently way more so than on other OSes like Linux) and `fork` takes
a process-wide lock on the allocator which is bad
* however, since we wanna reset exception ports on the child, the only
official way supported by Rust's std is to use `pre_exec` hook
* posix_spawn on macOS exposes this tho via a macOS specific extension
to that syscall `posix_spawnattr_setexceptionports_np` but there is no
way to use that via any standard interfaces in `std::process::Command`
* thus, it seemed like a good idea to instead create our own custom
Command wrapper that on non-macOS hosts is a zero-cost wrapper of
`smol::process::Command`, while on macOS we reimplement the minimum to
achieve `smol::process::Command`  with `posix_spawn` under-the-hood

Notably, this changeset improves git-blame in very large repos
significantly.

Release Notes:

- Fixed performance spawning child processes on macOS by always forcing
`posix_spawn` no matter what.

---------

Co-authored-by: Cole Miller <cole@zed.dev>
2026-02-13 20:16:11 +01:00
Mikayla Maki
83de8a25e0
Revert PRs for landing in main (#48969)
We're going to re-apply these after landing the multiworkspace branch.

Release Notes:

- N/A
2026-02-12 00:28:17 +00:00
John Tur
8e3e6b8129
Fix path handling regressions on Windows (#48905)
https://github.com/zed-industries/zed/pull/48891 changed `find_worktree`
to use `PathStyle::strip_prefix`, which exposed this bug.

- [ ] Tests or screenshots needed?
- [X] Code Reviewed
- [X] Manual QA

Release Notes:

- N/A
2026-02-11 03:23:13 +00:00
Mikayla Maki
695fcde635
Canonicalize extension paths (#48632)
Release Notes:

- N/A
2026-02-10 10:38:47 -08:00
Richard Feldman
7cb4d75139
Housekeeping: Improve error handling and small fixes (#48552)
A collection of small independent fixes:

- **Visual test runner**: Replace ~20 instances of `.ok()` and `let _ =`
with `.log_err()` to avoid silently discarding errors per project
guidelines.
- **recent_projects**: Add missing `remote_connection/test-support` to
the `test-support` feature gate.
- **util/shell.rs**: Add doc comment on `supports_posix_chaining()`
explaining its relationship to tool permission pattern matching.

Release Notes:

- N/A
2026-02-05 22:58:55 -05:00
Mikayla Maki
e8030aea4a
Improve extension installation (#48518)
Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Piotr <piotr@zed.dev>
2026-02-05 21:37:18 +00:00
Richard Feldman
54588a1e7d
Allow always_allow for nushell, elvish, and rc (#48395)
`brush-parser` handles `;` (sequential execution) and `|` (piping) which
all these shells use, so we can safely parse their commands for
`always_allow` pattern matching.

(No release notes because granular tool permissions haven't been
released yet.)

Release Notes:

- N/A
2026-02-04 19:49:56 +00:00
Joseph T. Lyons
72b151e3aa
Revert "Allow always_allow patterns for Nushell, Elvish, and Rc shells" (#48050)
Reverts zed-industries/zed#47908

This PR inadvertently caused a regression:

- https://github.com/zed-industries/zed/issues/48047
2026-01-30 21:26:13 +00:00
Richard Feldman
b7e11b38f4
Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908)
## Summary

This PR extends the `always_allow` tool permission patterns to work with
Nushell, Elvish, and Rc shells. Previously, these shells were
incorrectly excluded because they don't use `&&`/`||` operators for
command chaining. However, brush-parser can safely parse their command
syntax since they all use `;` for sequential execution.

## Changes

- Add `ShellKind::Nushell`, `ShellKind::Elvish`, and `ShellKind::Rc` to
`supports_posix_chaining()`
- Split `ShellKind::Unknown` into `ShellKind::UnknownWindows` and
`ShellKind::UnknownUnix` to preserve platform-specific fallback behavior
while still denying `always_allow` patterns for unrecognized shells
- Add comprehensive tests for the new shell support
- Clarify documentation about shell compatibility

## Shell Notes

- **Nushell**: Uses `;` for sequential execution. The `and`/`or`
keywords are boolean operators on values, not command chaining.
- **Elvish**: Uses `;` to separate pipelines. Does not have `&&` or `||`
operators. Its `and`/`or` are special commands operating on values.
- **Rc (Plan 9)**: Uses `;` for sequential execution and `|` for piping.
Does not have `&&`/`||` operators.

## Security

Unknown shells still return `false` from `supports_posix_chaining()`, so
`always_allow` patterns are denied for safety when we can't verify the
shell's syntax.

(No release notes because granular tool permissions are still
feature-flagged.)

Release Notes:

- N/A

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-01-29 06:08:05 +00:00
Richard Feldman
dbeb0af9ad
Fix shell injection vulnerability in terminal tool permissions (#47807)
<img width="1110" height="280" alt="Screenshot 2026-01-28 at 3 35 52 PM"
src="https://github.com/user-attachments/assets/4d467e2c-2e7b-4ec7-bc87-6f0df8e667f0"
/>

<img width="1094" height="411" alt="Screenshot 2026-01-28 at 3 40 54 PM"
src="https://github.com/user-attachments/assets/f559df93-e72e-4457-ba1b-f7d6239f3285"
/>


Previously, if a user configured `^ls` as an always-allow pattern, an
attacker could craft a command like `ls && rm -rf /` which would be
auto-approved because the regex only matched the beginning of the
command string.

Now the command is parsed into individual sub-commands (`ls`, `rm -rf
/`) and EACH sub-command must match an allow pattern for auto-approval.
This prevents shell injection attacks using operators like:
- `&&` and `||` (boolean operators)
- `;` and `&` (sequential/background execution)
- `|` (pipes)
- Newlines
- Command substitution (`$()` and backticks)
- Process substitution (`<()` and `>()`)

## Matching Logic

- **always_deny**: if ANY sub-command matches, deny the entire command
- **always_confirm**: if ANY sub-command matches, require confirmation
(unless always_deny matched, in which case deny)
- **always_allow**: ALL sub-commands must match for auto-approval
(unless always_confirm or always_deny matched, in which case defer to
those)
- If parsing fails, or if the shell is unsupported, then always_allow is
disabled for this command

As usual, `always_allow_tool_actions` supercedes all of these. If it is
`true`, then we always allow all tool calls, no questions asked.

## Shell Compatibility

The shell parser only supports POSIX-like command chaining syntax (`&&`,
`||`, `;`, `|`).

**Supported shells:** Posix (sh, bash, dash, zsh), Fish 3.0+, PowerShell
7+/Pwsh, Cmd, Xonsh, Csh, Tcsh

**Unsupported shells:** Nushell (uses `and`/`or` keywords), Elvish (uses
`and`/`or` keywords), Rc (Plan 9 shell - no `&&`/`||` operators)

For unsupported shells:
- The "Always allow" UI options are hidden for the terminal tool
- If the user has `always_allow` patterns configured in settings, they
will see a `Deny` with an explanatory error message

(No release notes because granular tool permissions are behind a feature
flag.)

Release Notes:

- N/A

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-01-28 20:51:39 +00:00
John Tur
17d34db366
Fix issues with Windows SSH support (#47822)
- Remove the newlines in the unzip command string, which made it not
work.
- Fix spawning the terminal and tasks. Unfortunately, the Windows
OpenSSH server has limitations that require rather ugly workarounds.

Release Notes:

- N/A
2026-01-28 02:37:26 +00:00
Lukas Wirth
9da3f2db47
util: Implement host independent Url to PathBuf conversion (#47474)
We might interface with the LSP using URL heres across remotes that have
differing path styles which then breaks every now and then when we have
windows to unix connections. This should helps us fix these occurences
more correctly

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2026-01-23 14:10:40 +00:00
Lukas Wirth
3d0222a5af
remote: Support opening builtin host files in remote workspaces on wsl (#46910)
Release Notes:

- Opening bundled files, keymap, and local release notes now opens in
remote windows instead of opening a new local zed window
- Opening the settings files, keymap files, task files, debug files and
logs will now open within wsl windows instead of opening a new local zed
window
2026-01-15 15:21:57 +00:00
Martin Pool
271bcf65ef
Fix Failed to load environment variables error message after self-update on Linux (#46367)
Closes #46365

The behavior I'm trying to handle here is documented in
https://man7.org/linux/man-pages/man5/proc_pid_exe.5.html.

[@merlinz01

](https://github.com/zed-industries/zed/issues/46365#issuecomment-3723996684)
points to some other alternatives but they don't seem necessary or
justified here.

# Testing

I've manually replaced the binary of a process running this build, to
simulate an update, and then opened a new tree and I don't see the error
message.

I don't know if there's a reasonable way to unit-test this? Let me know.
It seems like it would require using something like rusty-fork to spawn
a specific binary for the test, which I don't think I see already in the
Zed tree and perhaps it would be overkill to add just for this?


Release Notes:

- Fixed "Failed to load environment variables" after applying an update
2026-01-13 07:56:02 +01:00
Martin Pool
306a38aae8
Fix test_extract_zip_sets_default_permissions umask dependency (#46369)
I saw that this test is failing at head, with what turns out to be a
dependency on the test environment umask.

This removes the over-strict assertions about permissions from extracted
zips when permissions aren't preserved. I tested locally that it passes
with 022, 002, 077.

Also, some of the comments and variable names seemed to be out of date
for this test, in which the file is not executable, so I changed/removed
them.

cc @MrSubidubi 

follows on from #45515


Before:

```
mbp@amorfati ~/s/zed> umask 002
mbp@amorfati ~/s/zed> cargo nextest run -p util archive::tests::test_extract_zip_sets_default_permissions
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.21s
────────────
 Nextest run ID de9e0712-0db1-4e4e-8c9f-421bb68ed23c with nextest profile: default
    Starting 1 test across 1 binary (71 tests skipped)
        FAIL [   0.003s] util archive::tests::test_extract_zip_sets_default_permissions
  stdout ───

    running 1 test
    test archive::tests::test_extract_zip_sets_default_permissions ... FAILED

    failures:

    failures:
        archive::tests::test_extract_zip_sets_default_permissions

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 71 filtered out; finished in 0.00s

  stderr ───

    thread 'archive::tests::test_extract_zip_sets_default_permissions' (755934) panicked at crates/util/src/archive.rs:290:13:
    assertion `left == right` failed: Expected default set of permissions for unzipped file with no permissions set.
      left: 436
     right: 420
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```


Closes #ISSUE

Release Notes:

- N/A
2026-01-09 14:52:48 +01:00
Mikayla Maki
06bd9005ab
agent: Add turn statistics to agent panel (#46390)
I really enjoyed this feature in Claude Code. Helps me get a sense of
how effortful something is.

Release Notes:

- Added a "show_turn_stats" setting, default to false, that shows the
timer and the number of tokens down.
2026-01-09 00:33:38 +00:00
rari404
466c7008e0
terminal: Skip SHLVL when loading login shell environment (#46273)
Fixes #33958

## Problem

PR #44835 attempted to fix SHLVL starting at 2 by removing it from the
`env` HashMap passed to alacritty. However, that HashMap is only an
**overlay** — alacritty uses the parent process environment as a base
and applies the overlay on top. Since alacritty never calls
`env_remove("SHLVL")`, the terminal shell still inherits `SHLVL` from
Zed's process environment.

## Root Cause

The real issue is in `load_login_shell_environment()`:

1. `shell_env::capture()` spawns a login shell to capture environment
variables
2. That login shell increments `SHLVL` (from 0→1 or n→n+1)
3. The captured env (including the incremented `SHLVL`) is written to
Zed's **process environment** via `env::set_var`
4. When you open a terminal, the shell inherits Zed's `SHLVL` and
increments it again → starts at 2
5. On reload, `shell_env::capture()` runs again with the
already-elevated `SHLVL`, incrementing it further → +2 per reload

## Fix

Skip `SHLVL` when setting Zed's process environment in
`load_login_shell_environment()`. This prevents the login-shell capture
from polluting Zed's env, so terminals start fresh with the correct
`SHLVL`.
2026-01-08 10:02:25 +00:00