-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Prompt to turn on windows sandbox when auto mode selected. #6618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3d1c25f
Prompt to turn on windows sandbox when auto mode selected.
iceweasel-oai a249f47
also prompt for sandbox when auto mode request in flags/config
iceweasel-oai ad3990c
only enable Auto after the world-writable warning has been confirmed
iceweasel-oai 43b0b9a
fix clippy issue
iceweasel-oai a0e3638
fix build error
iceweasel-oai 7b3af7a
fix clippy issue
iceweasel-oai eadeb99
reusable method for setting/clearing windows sandbox
iceweasel-oai 2a8d9cb
Merge branch 'main' into dev/iceweasel/windows-sandbox-nux
iceweasel-oai 3bde36a
copy updates
iceweasel-oai 56c9e39
remove unused function
iceweasel-oai c8feb5d
move world-writable warning formatting into audit.rs for reusability
iceweasel-oai b986da3
fix non-windows clippy
iceweasel-oai d9a8024
remove /approvals line about sandbox feature
iceweasel-oai 7564e13
second round of copy updates
iceweasel-oai bde97dc
ignore test that is timing-out
iceweasel-oai c4bb309
Merge branch 'main' into dev/iceweasel/windows-sandbox-nux
iceweasel-oai d06f3c8
fix merge conflict
iceweasel-oai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,12 @@ use codex_core::AuthManager; | |
| use codex_core::ConversationManager; | ||
| use codex_core::config::Config; | ||
| use codex_core::config::edit::ConfigEditsBuilder; | ||
| #[cfg(target_os = "windows")] | ||
| use codex_core::features::Feature; | ||
| use codex_core::model_family::find_family_for_model; | ||
| use codex_core::protocol::FinalOutput; | ||
| #[cfg(target_os = "windows")] | ||
| use codex_core::protocol::Op; | ||
| use codex_core::protocol::SessionSource; | ||
| use codex_core::protocol::TokenUsage; | ||
| use codex_core::protocol_config_types::ReasoningEffort as ReasoningEffortConfig; | ||
|
|
@@ -220,7 +224,7 @@ impl App { | |
|
|
||
| let enhanced_keys_supported = tui.enhanced_keys_supported(); | ||
|
|
||
| let chat_widget = match resume_selection { | ||
| let mut chat_widget = match resume_selection { | ||
| ResumeSelection::StartFresh | ResumeSelection::Exit => { | ||
| let init = crate::chatwidget::ChatWidgetInit { | ||
| config: config.clone(), | ||
|
|
@@ -263,6 +267,8 @@ impl App { | |
| } | ||
| }; | ||
|
|
||
| chat_widget.maybe_prompt_windows_sandbox_enable(); | ||
|
|
||
| let file_search = FileSearchManager::new(config.cwd.clone(), app_event_tx.clone()); | ||
| #[cfg(not(debug_assertions))] | ||
| let upgrade_version = crate::updates::get_upgrade_version(&config); | ||
|
|
@@ -534,8 +540,71 @@ impl App { | |
| AppEvent::OpenFeedbackConsent { category } => { | ||
| self.chat_widget.open_feedback_consent(category); | ||
| } | ||
| AppEvent::ShowWindowsAutoModeInstructions => { | ||
| self.chat_widget.open_windows_auto_mode_instructions(); | ||
| AppEvent::OpenWindowsSandboxEnablePrompt { preset } => { | ||
| self.chat_widget.open_windows_sandbox_enable_prompt(preset); | ||
| } | ||
| AppEvent::EnableWindowsSandboxForAuto { preset } => { | ||
| #[cfg(target_os = "windows")] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use |
||
| { | ||
| let profile = self.active_profile.as_deref(); | ||
| let feature_key = Feature::WindowsSandbox.key(); | ||
| match ConfigEditsBuilder::new(&self.config.codex_home) | ||
| .with_profile(profile) | ||
| .set_feature_enabled(feature_key, true) | ||
| .apply() | ||
| .await | ||
| { | ||
| Ok(()) => { | ||
| self.config.set_windows_sandbox_globally(true); | ||
| self.chat_widget.clear_forced_auto_mode_downgrade(); | ||
| if let Some((sample_paths, extra_count, failed_scan)) = | ||
| self.chat_widget.world_writable_warning_details() | ||
| { | ||
| self.app_event_tx.send( | ||
| AppEvent::OpenWorldWritableWarningConfirmation { | ||
| preset: Some(preset.clone()), | ||
| sample_paths, | ||
| extra_count, | ||
| failed_scan, | ||
| }, | ||
| ); | ||
| } else { | ||
| self.app_event_tx.send(AppEvent::CodexOp( | ||
| Op::OverrideTurnContext { | ||
| cwd: None, | ||
| approval_policy: Some(preset.approval), | ||
| sandbox_policy: Some(preset.sandbox.clone()), | ||
| model: None, | ||
| effort: None, | ||
| summary: None, | ||
| }, | ||
| )); | ||
| self.app_event_tx | ||
| .send(AppEvent::UpdateAskForApprovalPolicy(preset.approval)); | ||
| self.app_event_tx | ||
| .send(AppEvent::UpdateSandboxPolicy(preset.sandbox.clone())); | ||
| self.chat_widget.add_info_message( | ||
| "Enabled the Windows sandbox feature and switched to Auto mode." | ||
| .to_string(), | ||
| None, | ||
| ); | ||
| } | ||
| } | ||
| Err(err) => { | ||
| tracing::error!( | ||
| error = %err, | ||
| "failed to enable Windows sandbox feature" | ||
| ); | ||
| self.chat_widget.add_error_message(format!( | ||
| "Failed to enable the Windows sandbox feature: {err}" | ||
| )); | ||
| } | ||
| } | ||
| } | ||
| #[cfg(not(target_os = "windows"))] | ||
| { | ||
| let _ = preset; | ||
| } | ||
| } | ||
| AppEvent::PersistModelSelection { model, effort } => { | ||
| let profile = self.active_profile.as_deref(); | ||
|
|
@@ -590,6 +659,13 @@ impl App { | |
| | codex_core::protocol::SandboxPolicy::ReadOnly | ||
| ); | ||
|
|
||
| self.config.sandbox_policy = policy.clone(); | ||
| #[cfg(target_os = "windows")] | ||
| if !matches!(policy, codex_core::protocol::SandboxPolicy::ReadOnly) | ||
| || codex_core::get_platform_sandbox().is_some() | ||
iceweasel-oai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| self.config.forced_auto_mode_downgraded_on_windows = false; | ||
| } | ||
| self.chat_widget.set_sandbox_policy(policy); | ||
|
|
||
| // If sandbox policy becomes workspace-write or read-only, run the Windows world-writable scan. | ||
|
|
@@ -865,7 +941,6 @@ mod tests { | |
| fn make_test_app() -> App { | ||
| let (chat_widget, app_event_tx, _rx, _op_rx) = make_chatwidget_manual_with_sender(); | ||
| let config = chat_widget.config_ref().clone(); | ||
|
|
||
| let server = Arc::new(ConversationManager::with_auth(CodexAuth::from_api_key( | ||
| "Test API Key", | ||
| ))); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this consistently timing out?