# Introduce worktree trust mechanism \(\#44887\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f21cec7cb1d961a0956b97046001117da3bc17f2)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f21cec7cb1d961a0956b97046001117da3bc17f2

Requested commit: f21cec7cb1d961a0956b97046001117da3bc17f2

Commit: f21cec7cb1d961a0956b97046001117da3bc17f2

Tree: 4e486dc09acc6bf1df2e4c26390bdb9045b904f4

Author: Kirill Bulatov

Committer: GitHub

## Message

````
Introduce worktree trust mechanism (#44887)

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

Forces Zed to require user permissions before running any basic
potentially dangerous actions: parsing and synchronizing
`.zed/settings.json`, downloading and spawning any language and MCP
servers (includes `prettier` and `copilot` instances) and all
`NodeRuntime` interactions.
There are more we can add later, among the ideas: DAP downloads on
debugger start, Python virtual environment, etc.

By default, Zed starts in restricted mode and shows a `! Restricted
Mode` in the title bar, no aforementioned actions are executed.
Clicking it or calling `workspace::ToggleWorktreeSecurity` command will
bring a modal to trust worktrees or dismiss the modal:

<img width="1341" height="475" alt="1"
src="https://github.com/user-attachments/assets/4fabe63a-6494-42c7-b0ea-606abb1c0c20"
/>

Agent Panel shows a message too:

<img width="644" height="106" alt="2"
src="https://github.com/user-attachments/assets/0a4554bc-1f1e-455b-b97d-244d7d6a3259"
/>

This works on local, SSH and WSL remote projects, trusted worktrees are
persisted between Zed restarts.
There's a way to clear all persisted trust with
`workspace::ClearTrustedWorktrees`, this will restart Zed.

This mechanism can be turned off with settings:
```jsonc
"session": {
  "trust_all_worktrees": true
}
```
in this mode, all worktrees will be trusted by default, allowing all
actions, but no auto trust will be persisted: hence, when the setting is
changed back, auto trusted worktrees will require another trust
confirmation.

This settings switch was added to the onboarding view also.

Release Notes:

- Introduced worktree trust mechanism, can be turned off with
`"session": { "trust_all_worktrees": true }`

---------

Co-authored-by: Matt Miller <mattrx@gmail.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: John D. Swanson <swanson.john.d@gmail.com>
````

## Parents

- [93d79f3862ea56b5c445b534285f843ce6868ea2](https://git.cafe/gitcafe/zed/commit/93d79f3862ea56b5c445b534285f843ce6868ea2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f21cec7cb1d961a0956b97046001117da3bc17f2?format=markdown)
