Respect execution hosts in Windows sandbox setup (#44939)

## Why

The Windows TUI cannot configure a remote executor's sandbox. Required elevated sandbox setup also needs to reflect the local app server's readiness rather than the TUI's local setup files.

## What changed

- Restrict setup prompts and actions to local connections with local executors, including local daemon connections. Let remote servers own Agent permission selection, and warn when local and remote executors are configured together.
- Query `WindowsSandboxReadiness` at startup when elevated sandboxing is required locally, and track successful setup across chat widget replacement and reconnects.
- Restore pending initial input to the composer when mixed executors prevent required setup or a local connection goes offline.

## Testing

Add regression coverage for local, remote, and mixed host selection, remote Agent permission selection, pending input restoration with mixed executors, and setup state preservation during daemon reconnects.

GitOrigin-RevId: bd45b308ac3ae4c2489b0bd2ac5d7e12a7fc35d6
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-11 23:44:29 +00:00
1 parent 2e572378f4
commit c210f4c222
17 files changed
+278 -32

No files matched your search

@@ -170,6 +170,9 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
app.app_server_target = AppServerTarget::LocalDaemon {
endpoint: endpoint.clone(),
};
if previous_thread.is_none() {
app.chat_widget.windows_sandbox_elevated_setup_complete = true;
}
let available = Arc::new(std::sync::atomic::AtomicBool::new(false));
let server_available = Arc::clone(&available);
let restored_previous = previous_thread
@@ -314,6 +317,9 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
CODEX_CLI_VERSION,
)
.await?;
if previous_thread.is_none() {
assert!(app.chat_widget.windows_sandbox_elevated_setup_complete);
}
assert!(!app.reconnect.offline);
assert_eq!(app.current_displayed_thread_id(), previous_thread);
+48
View File
@@ -15,6 +15,54 @@ use pretty_assertions::assert_eq;
use tokio::sync::mpsc::UnboundedReceiver;
use tokio::sync::mpsc::unbounded_channel;
#[tokio::test]
async fn windows_sandbox_setup_uses_local_app_server_connection() {
let mut app = make_test_app().await;
assert!(app.windows_sandbox_setup_is_local());
let endpoint = crate::RemoteAppServerEndpoint::WebSocket {
websocket_url: "ws://127.0.0.1:4500".to_string(),
auth_token: None,
};
app.app_server_target = crate::AppServerTarget::LocalDaemon {
endpoint: endpoint.clone(),
};
assert!(app.windows_sandbox_setup_is_local());
app.app_server_target = crate::AppServerTarget::Remote { endpoint };
assert!(!app.windows_sandbox_setup_is_local());
}
#[tokio::test]
async fn windows_sandbox_setup_skips_remote_default_executor() -> Result<()> {
let mut app = make_test_app().await;
app.environment_manager = Arc::new(
EnvironmentManager::create_for_tests(
Some("ws://127.0.0.1:8765".to_string()),
Some(codex_exec_server::ExecServerRuntimePaths::new(
std::env::current_exe()?,
/*codex_linux_sandbox_exe*/ None,
)?),
)
.await,
);
assert!(!app.windows_sandbox_setup_is_local());
app.environment_manager = Arc::new(
EnvironmentManager::create_for_tests_with_local(
Some("ws://127.0.0.1:8765".to_string()),
codex_exec_server::ExecServerRuntimePaths::new(
std::env::current_exe()?,
/*codex_linux_sandbox_exe*/ None,
)?,
)
.await,
);
assert_eq!(app.windows_sandbox_host(), WindowsSandboxHost::Mixed);
assert!(!app.windows_sandbox_setup_is_local());
Ok(())
}
fn startup_bottom_pane() -> (BottomPane, UnboundedReceiver<AppEvent>) {
let (app_event_tx, app_event_rx) = unbounded_channel();
(