mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Use app-server state for TUI Windows sandbox decisions (#45821)
## Why Windows sandbox setup and permission choices need to reflect the connected app server's requirements and the active thread's executors. ## What changed - Refresh sandbox configuration and requirements for the current working directory when threads or directories change, before setup, and after setup completes. - Use the thread's observed environments to determine whether sandbox setup is local, remote, mixed, or unknown. - Defer initial prompt submission while requirements load and preserve the draft if loading fails or required setup is unavailable. - Hide sandbox setup choices and elevation commands that requirements or executor selection disallow. ## Testing Add coverage for observed thread hosts, app-server configuration reads, draft preservation and recovery after read failures, deferred initial prompts, and non-admin-only setup choices. GitOrigin-RevId: d85ac66d18951b752e71d1a6bf25404eeedcad02
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
//! slash-command recall follows the same submitted-input rule as ordinary text.
|
||||
|
||||
use super::*;
|
||||
use crate::app::WindowsSandboxHost;
|
||||
use crate::app_event::ManagedWorktreeMode;
|
||||
use crate::app_event::ThreadGoalSetMode;
|
||||
use crate::bottom_pane::prompt_args::parse_slash_name;
|
||||
@@ -346,7 +347,11 @@ impl ChatWidget {
|
||||
self.app_event_tx.send(AppEvent::OpenAgentPicker);
|
||||
}
|
||||
SlashCommand::Permissions => {
|
||||
if self.remote_connection.is_some() {
|
||||
if self.remote_connection.is_some()
|
||||
|| self.windows_sandbox_local_server
|
||||
&& self.windows_sandbox_host != WindowsSandboxHost::Remote
|
||||
&& self.windows_sandbox_config.requirements.is_none()
|
||||
{
|
||||
self.app_event_tx.send(AppEvent::OpenPermissionsPopup);
|
||||
} else {
|
||||
self.open_permissions_popup();
|
||||
@@ -362,11 +367,7 @@ impl ChatWidget {
|
||||
SlashCommand::ElevateSandbox => {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let windows_sandbox_level =
|
||||
crate::windows_sandbox::level_from_config(&self.config);
|
||||
let windows_degraded_sandbox_enabled =
|
||||
matches!(windows_sandbox_level, WindowsSandboxLevel::RestrictedToken);
|
||||
if !windows_degraded_sandbox_enabled {
|
||||
if !self.builtin_command_flags().allow_elevate_sandbox {
|
||||
// This command should not be visible/recognized outside degraded mode,
|
||||
// but guard anyway in case something dispatches it directly.
|
||||
return;
|
||||
@@ -1132,8 +1133,13 @@ impl ChatWidget {
|
||||
pub(super) fn builtin_command_flags(&self) -> BuiltinCommandFlags {
|
||||
#[cfg(target_os = "windows")]
|
||||
let allow_elevate_sandbox = {
|
||||
let windows_sandbox_level = crate::windows_sandbox::level_from_config(&self.config);
|
||||
let windows_sandbox_level = self.windows_sandbox_config.level();
|
||||
matches!(windows_sandbox_level, WindowsSandboxLevel::RestrictedToken)
|
||||
&& self.windows_sandbox_local_server
|
||||
&& self.windows_sandbox_host == crate::app::WindowsSandboxHost::Local
|
||||
&& self
|
||||
.windows_sandbox_config
|
||||
.allows(WindowsSandboxSetupMode::Elevated)
|
||||
};
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let allow_elevate_sandbox = false;
|
||||
|
||||
Reference in New Issue
Block a user