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:
Eric Traut authored and copyberry committed 2026-09-16 01:01:26 +00:00
1 parent f2b5b81f39
commit 73db60e71f
27 files changed
+476 -341

No files matched your search

+8 -4
View File
@@ -116,11 +116,11 @@ use codex_app_server_protocol::TurnCompletedNotification;
use codex_app_server_protocol::TurnPlanStepStatus;
use codex_app_server_protocol::TurnStatus;
use codex_app_server_protocol::UserInput;
use codex_app_server_protocol::WindowsSandboxSetupMode;
use codex_config::Constrained;
use codex_config::ConstraintResult;
use codex_config::types::ApprovalsReviewer;
use codex_config::types::Notifications;
use codex_config::types::WindowsSandboxModeToml;
use codex_connectors::AppInfo;
use codex_features::Feature;
#[cfg(test)]
@@ -142,7 +142,7 @@ use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::Settings;
#[cfg(any(target_os = "windows", test))]
#[cfg(target_os = "windows")]
use codex_protocol::config_types::WindowsSandboxLevel;
use codex_protocol::items::AgentMessageContent;
use codex_protocol::items::AgentMessageItem;
@@ -600,6 +600,8 @@ pub(crate) struct ChatWidget {
pub(crate) snapshot_local_images: bool,
pending_image_submission: Option<image_submission::PendingImageSubmission>,
pub(crate) local_worktree_operations: bool,
pub(crate) windows_sandbox_local_server: bool,
pub(crate) windows_sandbox_config: crate::windows_sandbox::WindowsSandboxConfig,
pub(crate) windows_sandbox_host: crate::app::WindowsSandboxHost,
#[cfg(any(target_os = "windows", test))]
pub(crate) windows_sandbox_elevated_setup_complete: bool,
@@ -1063,8 +1065,10 @@ impl ChatWidget {
let snapshot = self.feedback.snapshot(self.thread_id);
#[cfg(target_os = "windows")]
let include_windows_sandbox_log =
codex_windows_sandbox::current_log_file_path_for_codex_home(&self.config.codex_home)
.is_file();
codex_windows_sandbox::current_log_file_path_for_codex_home(
&self.local_settings.codex_home,
)
.is_file();
#[cfg(not(target_os = "windows"))]
let include_windows_sandbox_log = false;
let params = crate::bottom_pane::feedback_upload_consent_params(