Remove the Windows /sandbox-add-read-dir slash command (#44259)

## What changed

Remove the TUI command introduced in https://github.com/openai/codex/pull/11512 for granting sandbox read access to additional directories, along with its event handlers and non-elevated read-root grant helper.

## Testing

Enable the existing voice command popup snapshot test on Windows as well as macOS.

GitOrigin-RevId: 8a3a06b76749420101e34aa6587a8beab8eb5fdd
This commit is contained in:
Eric Traut
2026-09-09 18:11:39 +00:00
committed by copyberry
parent 3dc1e2a584
commit a3ba42b010
7 changed files with 3 additions and 127 deletions
-57
View File
@@ -2167,63 +2167,6 @@ impl App {
let _ = (preset, profile_selection);
}
}
AppEvent::BeginWindowsSandboxGrantReadRoot { path } => {
#[cfg(target_os = "windows")]
{
self.chat_widget
.add_to_history(history_cell::new_info_event(
format!("Granting sandbox read access to {path} ..."),
/*hint*/ None,
));
let permission_profile = self.config.permissions.effective_permission_profile();
let workspace_roots = self.config.effective_workspace_roots();
let command_cwd = self.config.cwd.clone();
let env_map: std::collections::HashMap<String, String> =
std::env::vars().collect();
let codex_home = self.config.codex_home.clone();
let tx = self.app_event_tx.clone();
tokio::task::spawn_blocking(move || {
let requested_path = PathBuf::from(path);
let event = match crate::windows_sandbox::grant_read_root_non_elevated(
&permission_profile,
workspace_roots.as_slice(),
command_cwd.as_path(),
&env_map,
codex_home.as_path(),
requested_path.as_path(),
) {
Ok(canonical_path) => AppEvent::WindowsSandboxGrantReadRootCompleted {
path: canonical_path,
error: None,
},
Err(err) => AppEvent::WindowsSandboxGrantReadRootCompleted {
path: requested_path,
error: Some(err.to_string()),
},
};
tx.send(event);
});
}
#[cfg(not(target_os = "windows"))]
{
let _ = path;
}
}
AppEvent::WindowsSandboxGrantReadRootCompleted { path, error } => match error {
Some(err) => {
self.chat_widget
.add_to_history(history_cell::new_error_event(format!("Error: {err}")));
}
None => {
self.chat_widget
.add_to_history(history_cell::new_info_event(
format!("Sandbox read access granted for {}", path.display()),
/*hint*/ None,
));
}
},
AppEvent::EnableWindowsSandboxForAgentMode {
preset,
mode,
-13
View File
@@ -1231,19 +1231,6 @@ pub(crate) enum AppEvent {
profile_selection: Option<PermissionProfileSelection>,
},
/// Begin a non-elevated grant of read access for an additional directory.
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
BeginWindowsSandboxGrantReadRoot {
path: String,
},
/// Result of attempting to grant read access for an additional directory.
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
WindowsSandboxGrantReadRootCompleted {
path: PathBuf,
error: Option<String>,
},
/// Enable the Windows sandbox feature and switch to Agent mode.
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
EnableWindowsSandboxForAgentMode {
@@ -423,7 +423,6 @@ fn parent_owned_command_is_allowed(command: SlashCommand, args: &str) -> bool {
| SlashCommand::Vim
| SlashCommand::Keymap
| SlashCommand::ElevateSandbox
| SlashCommand::SandboxReadRoot
| SlashCommand::Experimental
| SlashCommand::Memories
| SlashCommand::Quit
@@ -414,7 +414,7 @@ mod tests {
insta::assert_snapshot!("command_popup_app", format!("{buf:?}"));
}
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "windows"))]
#[test]
fn voice_command_popup_snapshot() {
let mut popup = CommandPopup::new(
@@ -411,11 +411,6 @@ impl ChatWidget {
// Not supported; on non-Windows this command should never be reachable.
}
}
SlashCommand::SandboxReadRoot => {
self.add_error_message(
"Usage: /sandbox-add-read-dir <absolute-directory-path>".to_string(),
);
}
SlashCommand::Experimental => {
self.open_experimental_popup();
}
@@ -1005,10 +1000,6 @@ impl ChatWidget {
self.app_event_tx
.send(AppEvent::ResumeSessionByIdOrName(args));
}
SlashCommand::SandboxReadRoot if !trimmed.is_empty() => {
self.app_event_tx
.send(AppEvent::BeginWindowsSandboxGrantReadRoot { path: args });
}
SlashCommand::Pets
if matches!(
args.trim().to_ascii_lowercase().as_str(),
@@ -1228,7 +1219,6 @@ impl ChatWidget {
| SlashCommand::MultiAgents
| SlashCommand::Permissions
| SlashCommand::ElevateSandbox
| SlashCommand::SandboxReadRoot
| SlashCommand::Experimental
| SlashCommand::AutoReview
| SlashCommand::Memories
-8
View File
@@ -19,8 +19,6 @@ pub enum SlashCommand {
Vim,
#[strum(serialize = "setup-default-sandbox")]
ElevateSandbox,
#[strum(serialize = "sandbox-add-read-dir")]
SandboxReadRoot,
Experimental,
#[strum(to_string = "approve")]
AutoReview,
@@ -142,9 +140,6 @@ impl SlashCommand {
SlashCommand::Keymap => "remap TUI shortcuts",
SlashCommand::Vim => "toggle Vim mode for the composer",
SlashCommand::ElevateSandbox => "set up elevated agent sandbox",
SlashCommand::SandboxReadRoot => {
"let sandbox read a directory: /sandbox-add-read-dir <absolute_path>"
}
SlashCommand::Experimental => "toggle experimental features",
SlashCommand::AutoReview => "approve one retry of a recent auto-review denial",
SlashCommand::Memories => "configure memory use and generation",
@@ -187,7 +182,6 @@ impl SlashCommand {
| SlashCommand::Side
| SlashCommand::Btw
| SlashCommand::Resume
| SlashCommand::SandboxReadRoot
)
}
@@ -223,7 +217,6 @@ impl SlashCommand {
| SlashCommand::Keymap
| SlashCommand::Vim
| SlashCommand::ElevateSandbox
| SlashCommand::SandboxReadRoot
| SlashCommand::Experimental
| SlashCommand::Memories
| SlashCommand::Import
@@ -275,7 +268,6 @@ impl SlashCommand {
fn is_visible(self) -> bool {
match self {
SlashCommand::SandboxReadRoot => cfg!(target_os = "windows"),
SlashCommand::Copy => !cfg!(target_os = "android"),
SlashCommand::App => cfg!(any(target_os = "macos", target_os = "windows")),
SlashCommand::Voice => true,
+2 -37
View File
@@ -2,9 +2,8 @@
//!
//! TODO: These helpers inspect and modify the TUI host, so they do not support
//! cross-platform remote app servers. Move readiness and setup to the existing
//! `windowsSandbox/*` RPCs while preserving the pending permission profile,
//! use the server platform reported during initialization, and add a remote
//! equivalent for read-root grants.
//! `windowsSandbox/*` RPCs while preserving the pending permission profile and
//! using the server platform reported during initialization.
use crate::legacy_core::config::Config;
use codex_config::types::WindowsSandboxModeToml;
@@ -19,8 +18,6 @@ use codex_utils_absolute_path::AbsolutePathBuf;
#[cfg(target_os = "windows")]
use std::collections::HashMap;
use std::path::Path;
#[cfg(target_os = "windows")]
use std::path::PathBuf;
#[cfg(target_os = "windows")]
pub(crate) fn record_world_writable_scan_result(
@@ -113,35 +110,3 @@ pub(crate) fn elevated_setup_failure_metric_name(err: &anyhow::Error) -> &'stati
"codex.windows_sandbox.elevated_setup_failure"
}
}
#[cfg(target_os = "windows")]
pub(crate) fn grant_read_root_non_elevated(
permission_profile: &PermissionProfile,
workspace_roots: &[AbsolutePathBuf],
command_cwd: &Path,
env_map: &HashMap<String, String>,
codex_home: &Path,
read_root: &Path,
) -> anyhow::Result<PathBuf> {
if !read_root.is_absolute() {
anyhow::bail!("path must be absolute: {}", read_root.display());
}
if !read_root.exists() {
anyhow::bail!("path does not exist: {}", read_root.display());
}
if !read_root.is_dir() {
anyhow::bail!("path must be a directory: {}", read_root.display());
}
let canonical_root = dunce::canonicalize(read_root)?;
codex_windows_sandbox::run_setup_refresh_with_extra_read_roots(
permission_profile,
workspace_roots,
command_cwd,
env_map,
codex_home,
vec![canonical_root.clone()],
/*proxy_enforced*/ false,
)?;
Ok(canonical_root)
}