mirror of
https://github.com/openai/codex.git
synced 2026-04-30 11:21:34 +03:00
Prompt to turn on windows sandbox when auto mode selected. (#6618)
- stop prompting users to install WSL - prompt users to turn on Windows sandbox when auto mode requested. <img width="1660" height="195" alt="Screenshot 2025-11-17 110612" src="https://github.com/user-attachments/assets/c67fc239-a227-417e-94bb-599a8ed8f11e" /> <img width="1684" height="168" alt="Screenshot 2025-11-17 110637" src="https://github.com/user-attachments/assets/d18c3370-830d-4971-8746-04757ae2f709" /> <img width="1655" height="293" alt="Screenshot 2025-11-17 110719" src="https://github.com/user-attachments/assets/d21f6ce9-c23e-4842-baf6-8938b77c16db" />
This commit is contained in:
@@ -86,7 +86,7 @@ mod wrapping;
|
||||
#[cfg(test)]
|
||||
pub mod test_backend;
|
||||
|
||||
use crate::onboarding::WSL_INSTRUCTIONS;
|
||||
use crate::onboarding::TrustDirectorySelection;
|
||||
use crate::onboarding::onboarding_screen::OnboardingScreenArgs;
|
||||
use crate::onboarding::onboarding_screen::run_onboarding_app;
|
||||
use crate::tui::Tui;
|
||||
@@ -389,20 +389,13 @@ async fn run_ratatui_app(
|
||||
);
|
||||
let login_status = get_login_status(&initial_config);
|
||||
let should_show_trust_screen = should_show_trust_screen(&initial_config);
|
||||
let should_show_windows_wsl_screen =
|
||||
cfg!(target_os = "windows") && !initial_config.windows_wsl_setup_acknowledged;
|
||||
let should_show_onboarding = should_show_onboarding(
|
||||
login_status,
|
||||
&initial_config,
|
||||
should_show_trust_screen,
|
||||
should_show_windows_wsl_screen,
|
||||
);
|
||||
let should_show_onboarding =
|
||||
should_show_onboarding(login_status, &initial_config, should_show_trust_screen);
|
||||
|
||||
let config = if should_show_onboarding {
|
||||
let onboarding_result = run_onboarding_app(
|
||||
OnboardingScreenArgs {
|
||||
show_login_screen: should_show_login_screen(login_status, &initial_config),
|
||||
show_windows_wsl_screen: should_show_windows_wsl_screen,
|
||||
show_trust_screen: should_show_trust_screen,
|
||||
login_status,
|
||||
auth_manager: auth_manager.clone(),
|
||||
@@ -421,21 +414,12 @@ async fn run_ratatui_app(
|
||||
update_action: None,
|
||||
});
|
||||
}
|
||||
if onboarding_result.windows_install_selected {
|
||||
restore();
|
||||
session_log::log_session_end();
|
||||
let _ = tui.terminal.clear();
|
||||
if let Err(err) = writeln!(std::io::stdout(), "{WSL_INSTRUCTIONS}") {
|
||||
tracing::error!("Failed to write WSL instructions: {err}");
|
||||
}
|
||||
return Ok(AppExitInfo {
|
||||
token_usage: codex_core::protocol::TokenUsage::default(),
|
||||
conversation_id: None,
|
||||
update_action: None,
|
||||
});
|
||||
}
|
||||
// if the user acknowledged windows or made any trust decision, reload the config accordingly
|
||||
if should_show_windows_wsl_screen || onboarding_result.directory_trust_decision.is_some() {
|
||||
// if the user acknowledged windows or made an explicit decision ato trust the directory, reload the config accordingly
|
||||
if onboarding_result
|
||||
.directory_trust_decision
|
||||
.map(|d| d == TrustDirectorySelection::Trust)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
load_config_or_exit(cli_kv_overrides, overrides).await
|
||||
} else {
|
||||
initial_config
|
||||
@@ -584,7 +568,7 @@ async fn load_config_or_exit(
|
||||
/// show the trust screen.
|
||||
fn should_show_trust_screen(config: &Config) -> bool {
|
||||
if cfg!(target_os = "windows") && get_platform_sandbox().is_none() {
|
||||
// If the experimental sandbox is not enabled, Native Windows cannot enforce sandboxed write access without WSL; skip the trust prompt entirely.
|
||||
// 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 {
|
||||
@@ -599,12 +583,7 @@ fn should_show_onboarding(
|
||||
login_status: LoginStatus,
|
||||
config: &Config,
|
||||
show_trust_screen: bool,
|
||||
show_windows_wsl_screen: bool,
|
||||
) -> bool {
|
||||
if show_windows_wsl_screen {
|
||||
return true;
|
||||
}
|
||||
|
||||
if show_trust_screen {
|
||||
return true;
|
||||
}
|
||||
@@ -628,7 +607,6 @@ mod tests {
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::ConfigToml;
|
||||
use codex_core::config::ProjectConfig;
|
||||
use codex_core::set_windows_sandbox_enabled;
|
||||
use serial_test::serial;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -643,7 +621,7 @@ mod tests {
|
||||
)?;
|
||||
config.did_user_set_custom_approval_policy_or_sandbox_mode = false;
|
||||
config.active_project = ProjectConfig { trust_level: None };
|
||||
set_windows_sandbox_enabled(false);
|
||||
config.set_windows_sandbox_globally(false);
|
||||
|
||||
let should_show = should_show_trust_screen(&config);
|
||||
if cfg!(target_os = "windows") {
|
||||
@@ -670,7 +648,7 @@ mod tests {
|
||||
)?;
|
||||
config.did_user_set_custom_approval_policy_or_sandbox_mode = false;
|
||||
config.active_project = ProjectConfig { trust_level: None };
|
||||
set_windows_sandbox_enabled(true);
|
||||
config.set_windows_sandbox_globally(true);
|
||||
|
||||
let should_show = should_show_trust_screen(&config);
|
||||
if cfg!(target_os = "windows") {
|
||||
|
||||
Reference in New Issue
Block a user