Skip to content

Add Windows terminal sandboxing via WSL - #58971

Merged
MartinYe1234 merged 32 commits into
mainfrom
sandbox-windows
Jun 17, 2026
Merged

Add Windows terminal sandboxing via WSL#58971
MartinYe1234 merged 32 commits into
mainfrom
sandbox-windows

Conversation

@MartinYe1234

@MartinYe1234 MartinYe1234 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Windows agent terminal sandboxing by routing commands through WSL and Bubblewrap.
  • Supports native Windows and WSL project paths, including elevated write grants for WSL paths.
  • Shows a confirmation prompt to turn off sandboxing when WSL sandbox setup is unavailable.

This builds on the work in the sandbox-linux branch.

Closes AI-376

Release Notes:

  • Added Windows terminal sandboxing for agent commands when sandboxing is enabled.

@MartinYe1234 MartinYe1234 self-assigned this Jun 9, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 9, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 9, 2026
@cla-bot cla-bot Bot removed the cla-signed The user has signed the Contributor License Agreement label Jun 10, 2026
The hardcoded /mnt/<drive> mapping breaks when /etc/wsl.conf changes
the automount root. Ask wslpath inside the chosen distro instead, and
keep the structural mapping as a fallback when translation fails.
@zed-industries zed-industries deleted a comment from cla-bot Bot Jun 10, 2026
@zed-industries zed-industries deleted a comment from cla-bot Bot Jun 10, 2026
@zed-industries zed-industries deleted a comment from cla-bot Bot Jun 10, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 10, 2026
Wrapping a sandboxed command probed WSL with smol::block_on on the
foreground thread, freezing the UI for the duration of a WSL VM boot
and hanging Zed forever if wsl.exe wedged.

Make the windows_wsl functions async, run the wrap via
background_spawn, and race it against a 60-second gpui timer.
kill_on_drop ensures a timed-out or cancelled wrap also kills the
in-flight wsl.exe child. Timeout errors carry the unavailable-prefix
so the existing turn-off-sandboxing prompt handles a wedged WSL.
wsl.exe is a console-subsystem binary, so the sandbox probe and path
resolution spawns flashed a conhost window. Set CREATE_NO_WINDOW,
defined locally since the sandbox crate doesn't depend on util.
Base automatically changed from sandbox-linux to main June 16, 2026 12:21
# Conflicts:
#	crates/agent/src/thread.rs
#	crates/agent/src/tools/terminal_tool.rs
Parity with the Linux Bubblewrap NixOS tests, for the Windows WSL sandbox. Adds a feature-gated wsl_sandbox_test_helper bin that drives the real windows_wsl::wrap_invocation, spawns the produced wsl.exe command, and asserts the sandbox's grants and restrictions hold end-to-end (including the Windows-specific interop-escape block), plus a cargo xtask wsl-sandbox-tests subcommand and a script/test-wsl-sandbox.ps1 that provisions bwrap and unprivileged user namespaces before running. Developer/self-hosted-runner invoked, matching the Linux tests, which aren't wired into CI either.
@MartinYe1234
MartinYe1234 marked this pull request as ready for review June 17, 2026 21:06
@MartinYe1234
MartinYe1234 added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit dfd44a4 Jun 17, 2026
34 checks passed
@MartinYe1234
MartinYe1234 deleted the sandbox-windows branch June 17, 2026 21:10
This was referenced Jun 18, 2026
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Summary

- Adds Windows agent terminal sandboxing by routing commands through WSL
and Bubblewrap.
- Supports native Windows and WSL project paths, including elevated
write grants for WSL paths.
- Shows a confirmation prompt to turn off sandboxing when WSL sandbox
setup is unavailable.

This builds on the work in the sandbox-linux branch.

Closes AI-376

Release Notes:

- Added Windows terminal sandboxing for agent commands when sandboxing
is enabled.

---------

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
paschaldev pushed a commit to paschaldev/zed that referenced this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants