mirror of
https://github.com/openai/codex.git
synced 2026-05-01 20:02:05 +03:00
Promote Windows Sandbox (#11341)
1. Move Windows Sandbox NUX to right after trust directory screen 2. Don't offer read-only as an option in Sandbox NUX. Elevated/Legacy/Quit 3. Don't allow new untrusted directories. It's trust or quit 4. move experimental sandbox features to `[windows] sandbox="elevated|unelevatd"` 5. Copy tweaks = elevated -> default, non-elevated -> non-admin
This commit is contained in:
@@ -473,6 +473,7 @@ async fn run_ratatui_app(
|
||||
let should_show_trust_screen_flag = should_show_trust_screen(&initial_config);
|
||||
let should_show_onboarding =
|
||||
should_show_onboarding(login_status, &initial_config, should_show_trust_screen_flag);
|
||||
let mut trust_decision_was_made = false;
|
||||
|
||||
let config = if should_show_onboarding {
|
||||
let show_login_screen = should_show_login_screen(login_status, &initial_config);
|
||||
@@ -499,6 +500,7 @@ async fn run_ratatui_app(
|
||||
exit_reason: ExitReason::UserRequested,
|
||||
});
|
||||
}
|
||||
trust_decision_was_made = onboarding_result.directory_trust_decision.is_some();
|
||||
// If this onboarding run included the login step, always refresh cloud requirements and
|
||||
// rebuild config. This avoids missing newly available cloud requirements due to login
|
||||
// status detection edge cases.
|
||||
@@ -674,6 +676,9 @@ async fn run_ratatui_app(
|
||||
set_default_client_residency_requirement(config.enforce_residency.value());
|
||||
let active_profile = config.active_profile.clone();
|
||||
let should_show_trust_screen = should_show_trust_screen(&config);
|
||||
let should_prompt_windows_sandbox_nux_at_startup = cfg!(target_os = "windows")
|
||||
&& trust_decision_was_made
|
||||
&& WindowsSandboxLevel::from_config(&config) == WindowsSandboxLevel::Disabled;
|
||||
|
||||
let Cli {
|
||||
prompt,
|
||||
@@ -697,6 +702,7 @@ async fn run_ratatui_app(
|
||||
session_selection,
|
||||
feedback,
|
||||
should_show_trust_screen, // Proxy to: is it a first run in this directory?
|
||||
should_prompt_windows_sandbox_nux_at_startup,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -881,12 +887,6 @@ async fn load_config_or_exit_with_fallback_cwd(
|
||||
/// or if the current cwd project is already trusted. If not, we need to
|
||||
/// show the trust screen.
|
||||
fn should_show_trust_screen(config: &Config) -> bool {
|
||||
if cfg!(target_os = "windows")
|
||||
&& WindowsSandboxLevel::from_config(config) == WindowsSandboxLevel::Disabled
|
||||
{
|
||||
// If the experimental sandbox is not enabled, Native Windows cannot enforce sandboxed write access; skip the trust prompt entirely.
|
||||
return false;
|
||||
}
|
||||
if config.did_user_set_custom_approval_policy_or_sandbox_mode {
|
||||
// Respect explicit approval/sandbox overrides made by the user.
|
||||
return false;
|
||||
@@ -941,7 +941,7 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn windows_skips_trust_prompt_without_sandbox() -> std::io::Result<()> {
|
||||
async fn windows_shows_trust_prompt_without_sandbox() -> std::io::Result<()> {
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut config = build_config(&temp_dir).await?;
|
||||
config.did_user_set_custom_approval_policy_or_sandbox_mode = false;
|
||||
@@ -949,17 +949,10 @@ mod tests {
|
||||
config.set_windows_sandbox_enabled(false);
|
||||
|
||||
let should_show = should_show_trust_screen(&config);
|
||||
if cfg!(target_os = "windows") {
|
||||
assert!(
|
||||
!should_show,
|
||||
"Windows trust prompt should always be skipped on native Windows"
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
should_show,
|
||||
"Non-Windows should still show trust prompt when project is untrusted"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
should_show,
|
||||
"Trust prompt should be shown when project trust is undecided"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user