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

+10 -37
View File
@@ -1249,30 +1249,20 @@ impl App {
pub(super) async fn verify_windows_sandbox_mode_after_setup(
&mut self,
app_server: &mut AppServerSession,
requested_mode: codex_config::types::WindowsSandboxModeToml,
requested_mode: codex_app_server_protocol::WindowsSandboxSetupMode,
) -> bool {
let cwd = self.chat_widget.config_ref().cwd.display().to_string();
let mode = crate::config_update::read_effective_config(app_server.request_handle(), cwd)
.await
.ok()
.and_then(|config| windows_sandbox_mode_from_effective_config(&config));
let Some(mode) = mode else {
self.chat_widget.add_error_message(
"Windows sandbox setup completed, but Codex could not verify the effective sandbox mode."
.to_string(),
);
if !self.refresh_windows_sandbox_config(app_server).await {
return false;
};
self.config.permissions.windows_sandbox_mode = Some(mode);
if mode == requested_mode {
}
if self.chat_widget.windows_sandbox_config.mode == Some(requested_mode)
&& self
.chat_widget
.windows_sandbox_config
.allows(requested_mode)
{
return true;
}
self.chat_widget.set_windows_sandbox_mode(Some(mode));
self.propagate_windows_sandbox_turn_context();
self.chat_widget.add_error_message(
"Windows sandbox setup completed, but its mode was overridden by the effective configuration."
.to_string(),
);
self.chat_widget.add_error_message("Windows sandbox setup completed, but its mode was overridden by the effective configuration.".to_string());
false
}
@@ -1355,23 +1345,6 @@ fn features_toml_from_json(value: &serde_json::Value) -> Option<FeaturesToml> {
serde_json::from_value(value.clone()).ok()
}
#[cfg(target_os = "windows")]
fn windows_sandbox_mode_from_effective_config(
effective_config: &ConfigReadResponse,
) -> Option<codex_config::types::WindowsSandboxModeToml> {
let root_windows = effective_config
.config
.additional
.get("windows")
.and_then(windows_toml_from_json);
root_windows.and_then(|windows| windows.sandbox)
}
#[cfg(target_os = "windows")]
fn windows_toml_from_json(value: &serde_json::Value) -> Option<WindowsToml> {
serde_json::from_value(value.clone()).ok()
}
#[cfg(test)]
mod tests {
use std::sync::Arc;
+16 -16
View File
@@ -19,7 +19,7 @@ use crate::pager_overlay::TranscriptHistoryState;
use crate::session_resume::cwds_differ;
use codex_app_server_protocol::ThreadGoalStatus;
#[cfg(target_os = "windows")]
use codex_config::types::WindowsSandboxModeToml;
use codex_app_server_protocol::WindowsSandboxSetupMode as WindowsSandboxModeToml;
pub(super) const SHUTDOWN_FIRST_EXIT_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 2);
@@ -1962,6 +1962,12 @@ impl App {
self.launch_external_editor(tui).await;
}
}
AppEvent::RefreshWindowsSandbox { thread_id } => {
#[cfg(any(target_os = "windows", test))]
self.refresh_windows_sandbox_for_thread(app_server, thread_id).await;
#[cfg(not(any(target_os = "windows", test)))]
let _ = thread_id;
}
AppEvent::OpenWindowsSandboxEnablePrompt {
preset,
profile_selection,
@@ -2041,18 +2047,6 @@ impl App {
WindowsSandboxEnableMode::Legacy => WindowsSandboxModeToml::Unelevated,
};
let elevated_enabled = selected_mode == WindowsSandboxModeToml::Elevated;
if !self.chat_widget.windows_sandbox_mode_allowed(selected_mode) {
tracing::warn!(
?selected_mode,
"refusing to enable Windows sandbox mode disallowed by requirements"
);
self.chat_widget.add_info_message(
"That Windows sandbox option is disallowed by requirements."
.to_string(),
/*hint*/ None,
);
return Ok(AppRunControl::Continue);
}
if self
.verify_windows_sandbox_mode_after_setup(app_server, selected_mode)
.await
@@ -2068,9 +2062,7 @@ impl App {
self.config
.set_windows_elevated_sandbox_enabled(/*value*/ false);
}
self.chat_widget.set_windows_sandbox_mode(
self.config.permissions.windows_sandbox_mode,
);
self.chat_widget.set_windows_sandbox_mode(Some(selected_mode));
let windows_sandbox_level =
crate::windows_sandbox::level_from_config(&self.config);
if let Some(selection) = profile_selection {
@@ -2706,6 +2698,14 @@ impl App {
if self.reject_pending_permission_change() {
return Ok(AppRunControl::Continue);
}
#[cfg(any(target_os = "windows", test))]
if self.chat_widget.windows_sandbox_local_server
&& self.windows_sandbox_host() != WindowsSandboxHost::Remote
&& self.chat_widget.windows_sandbox_config.requirements.is_none()
&& !self.refresh_windows_sandbox_config(app_server).await
{
return Ok(AppRunControl::Continue);
}
if app_server.uses_remote_workspace() {
self.chat_widget.request_permission_profiles();
} else {
+83 -28
View File
@@ -7,7 +7,7 @@ use super::*;
#[cfg(all(test, not(target_os = "windows")))]
use crate::app_event::WindowsSandboxEnableMode;
#[cfg(target_os = "windows")]
use codex_config::types::WindowsSandboxModeToml;
use codex_app_server_protocol::WindowsSandboxSetupMode as WindowsSandboxModeToml;
#[cfg(any(target_os = "windows", test))]
use codex_utils_approval_presets::ApprovalPreset;
@@ -22,6 +22,8 @@ pub(crate) enum WindowsSandboxHost {
#[derive(Default)]
pub(super) struct WindowsSandboxState {
pub(super) setup_started_at: Option<Instant>,
#[cfg_attr(not(any(target_os = "windows", test)), allow(dead_code))]
pub(super) prompt_after_trust: bool,
#[cfg(any(target_os = "windows", test))]
pub(super) pending_setup: Option<(
WindowsSandboxEnableMode,
@@ -30,28 +32,6 @@ pub(super) struct WindowsSandboxState {
)>,
}
pub(super) fn windows_sandbox_host(
target: &AppServerTarget,
environment_manager: &EnvironmentManager,
) -> WindowsSandboxHost {
if target.uses_remote_workspace() {
WindowsSandboxHost::Remote
} else if environment_manager
.default_environment_ids()
.into_iter()
.filter_map(|id| environment_manager.get_environment(&id))
.any(|environment| environment.is_remote())
{
if environment_manager.try_local_environment().is_some() {
WindowsSandboxHost::Mixed
} else {
WindowsSandboxHost::Remote
}
} else {
WindowsSandboxHost::Local
}
}
#[cfg(target_os = "windows")]
pub(super) async fn windows_sandbox_ready(app_server: &mut AppServerSession) -> bool {
let request_id = app_server.next_request_id();
@@ -76,12 +56,17 @@ pub(super) async fn windows_sandbox_ready(app_server: &mut AppServerSession) ->
impl App {
pub(super) fn windows_sandbox_host(&self) -> WindowsSandboxHost {
windows_sandbox_host(&self.app_server_target, self.environment_manager.as_ref())
if self.app_server_target.uses_remote_workspace() {
WindowsSandboxHost::Remote
} else {
self.chat_widget.windows_sandbox_host
}
}
/// A local app server owns setup for both embedded and daemon connections.
pub(super) fn windows_sandbox_setup_is_local(&self) -> bool {
self.windows_sandbox_host() == WindowsSandboxHost::Local
self.chat_widget.windows_sandbox_local_server
&& self.windows_sandbox_host() == WindowsSandboxHost::Local
}
pub(super) fn windows_sandbox_blocks_thread_switch(&self) -> bool {
@@ -91,7 +76,7 @@ impl App {
&& (self.windows_sandbox.pending_setup.is_some()
|| self.windows_sandbox.setup_started_at.is_some()
|| self.chat_widget.initial_user_message.is_some()
&& self.chat_widget.required_elevated_windows_sandbox()
&& self.chat_widget.windows_sandbox_config.requires_elevated()
&& !self.chat_widget.windows_sandbox_elevated_setup_complete)
}
#[cfg(not(any(target_os = "windows", test)))]
@@ -100,6 +85,71 @@ impl App {
}
}
#[cfg(any(target_os = "windows", test))]
pub(super) async fn refresh_windows_sandbox_for_thread(
&mut self,
app_server: &mut AppServerSession,
thread_id: ThreadId,
) {
if self.chat_widget.thread_id() == Some(thread_id)
&& !self.app_server_target.uses_remote_workspace()
&& self.refresh_windows_sandbox_config(app_server).await
{
#[cfg(target_os = "windows")]
if self.windows_sandbox_setup_is_local()
&& self.chat_widget.windows_sandbox_config.requires_elevated()
&& !self.chat_widget.windows_sandbox_elevated_setup_complete
{
self.chat_widget.windows_sandbox_elevated_setup_complete =
windows_sandbox_ready(app_server).await;
}
let show_nux = std::mem::take(&mut self.windows_sandbox.prompt_after_trust)
&& self.chat_widget.windows_sandbox_config.mode.is_none()
|| self.chat_widget.windows_sandbox_config.requires_elevated();
if self.windows_sandbox_setup_is_local() {
self.chat_widget.maybe_prompt_windows_sandbox_enable(
show_nux && !self.chat_widget.windows_sandbox_elevated_setup_complete,
);
} else if self.windows_sandbox_host() == WindowsSandboxHost::Mixed && show_nux {
self.app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::StartupWarningsCell::new(vec![
"Windows sandbox setup is unavailable when local and remote executors are configured together."
.to_string(),
]),
)));
}
self.chat_widget.submit_initial_user_message_if_pending();
}
}
#[cfg(any(target_os = "windows", test))]
pub(super) async fn refresh_windows_sandbox_config(
&mut self,
app_server: &AppServerSession,
) -> bool {
match crate::windows_sandbox::WindowsSandboxConfig::read(
app_server.request_handle(),
self.chat_widget.config_ref().cwd.display().to_string(),
)
.await
{
Ok(state) => {
self.chat_widget.windows_sandbox_config = state;
self.chat_widget
.set_windows_sandbox_mode(self.chat_widget.windows_sandbox_config.mode);
true
}
Err(_) => {
self.chat_widget.windows_sandbox_config = Default::default();
self.chat_widget
.retain_input_after_failed_permission_selection();
self.chat_widget.set_windows_sandbox_mode(/*mode*/ None);
self.chat_widget.add_error_message("Could not read Windows sandbox configuration and requirements from the app server.".to_string());
false
}
}
}
#[cfg(target_os = "windows")]
pub(super) async fn begin_windows_sandbox_setup(
&mut self,
@@ -127,7 +177,12 @@ impl App {
}
return;
}
if !self.chat_widget.windows_sandbox_mode_allowed(config_mode) {
if !self.refresh_windows_sandbox_config(app_server).await {
return;
}
if !self.chat_widget.windows_sandbox_config.allows(config_mode) {
self.chat_widget
.retain_input_after_failed_permission_selection();
self.chat_widget.add_info_message(
"That Windows sandbox option is disallowed by requirements.".to_string(),
/*hint*/ None,
@@ -147,7 +202,7 @@ impl App {
request_id,
params: codex_app_server_protocol::WindowsSandboxSetupStartParams {
mode: setup_mode,
cwd: Some(self.config.cwd.clone()),
cwd: Some(self.chat_widget.config_ref().cwd.clone()),
},
}),
)
+4 -1
View File
@@ -292,7 +292,10 @@ impl App {
self.environment_manager.as_ref(),
),
);
self.chat_widget.windows_sandbox_host = self.windows_sandbox_host();
self.chat_widget.windows_sandbox_local_server =
!self.app_server_target.uses_remote_workspace()
&& app_server.app_server_platform_os() == Some("windows");
self.chat_widget.windows_sandbox_host = WindowsSandboxHost::Unknown;
self.chat_widget.cyber_policy_notice = Default::default();
self.chat_widget.requires_openai_auth = bootstrap.requires_openai_auth;
self.chat_widget.remote_connection =
+2 -1
View File
@@ -498,7 +498,8 @@ impl App {
chat_widget.remote_connection = self.chat_widget.remote_connection.clone();
chat_widget.snapshot_local_images = self.app_server_target.uses_remote_workspace();
chat_widget.set_local_worktree_operations(self.chat_widget.local_worktree_operations);
chat_widget.windows_sandbox_host = self.chat_widget.windows_sandbox_host;
chat_widget.windows_sandbox_local_server = self.chat_widget.windows_sandbox_local_server;
chat_widget.windows_sandbox_host = WindowsSandboxHost::Unknown;
#[cfg(any(target_os = "windows", test))]
{
chat_widget.windows_sandbox_elevated_setup_complete =
+15 -34
View File
@@ -682,39 +682,17 @@ impl App {
AppServerTarget::LocalDaemon { .. }
));
let thread_and_widget_ms = thread_and_widget_started_at.elapsed().as_millis();
let windows_sandbox_host =
windows_sandbox_host(&app_server_target, environment_manager.as_ref());
chat_widget.windows_sandbox_host = windows_sandbox_host;
let windows_sandbox_host_is_local = windows_sandbox_host == WindowsSandboxHost::Local;
#[cfg(target_os = "windows")]
let sandbox_ready =
if windows_sandbox_host_is_local && chat_widget.required_elevated_windows_sandbox() {
windows_sandbox_ready(&mut app_server).await
} else {
false
};
#[cfg(not(target_os = "windows"))]
let sandbox_ready = false;
#[cfg(target_os = "windows")]
if sandbox_ready {
chat_widget.windows_sandbox_elevated_setup_complete = true;
}
chat_widget.maybe_prompt_windows_sandbox_enable(
should_prompt_windows_sandbox_nux_at_startup
&& windows_sandbox_host_is_local
&& !sandbox_ready,
);
#[cfg(target_os = "windows")]
if windows_sandbox_host == WindowsSandboxHost::Mixed
&& should_prompt_windows_sandbox_nux_at_startup
{
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::StartupWarningsCell::new(vec![
"Windows sandbox setup is unavailable when local and remote executors are configured together."
.to_string(),
]),
)));
}
chat_widget.windows_sandbox_local_server = !app_server_target.uses_remote_workspace()
&& app_server.app_server_platform_os() == Some("windows");
chat_widget.windows_sandbox_host = if app_server_target.uses_remote_workspace() {
WindowsSandboxHost::Remote
} else {
initial_started_thread
.as_ref()
.map_or(WindowsSandboxHost::Unknown, |started| {
started.session.windows_sandbox_host
})
};
let file_search = FileSearchManager::new(config.cwd.to_path_buf(), app_event_tx.clone());
let runtime_keymap =
RuntimeKeymap::from_config(&local_settings.tui.keymap).map_err(|err| {
@@ -780,7 +758,10 @@ See the Codex keymap documentation for supported actions and examples."
},
pending_update_action: None,
pending_shutdown_exit_thread_id: None,
windows_sandbox: WindowsSandboxState::default(),
windows_sandbox: WindowsSandboxState {
prompt_after_trust: should_prompt_windows_sandbox_nux_at_startup,
..Default::default()
},
thread_event_channels: HashMap::new(),
pending_realtime_speech_replay: HashMap::new(),
pending_realtime_transcript_replay: HashMap::new(),
@@ -51,6 +51,7 @@ async fn pending_windows_sandbox_setup_blocks_thread_replacement() -> Result<()>
use crate::app_event::WindowsSandboxEnableMode;
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
app.chat_widget.windows_sandbox_local_server = true;
while events.try_recv().is_ok() {}
let mut app_server = start_config_write_test_app_server(&app).await?;
let mut tui = crate::tui::test_support::make_test_tui()?;
@@ -819,6 +819,7 @@ async fn command_center_new_checkout_and_worktree_preserve_source_and_default_br
let (mut app, mut events, _) = make_test_app_with_channels().await;
app.config.codex_home = home.clone().abs();
app.config.cwd = selected.cwd.clone().abs();
app.chat_widget.windows_sandbox_local_server = cfg!(target_os = "windows");
app.harness_overrides.cwd = Some(selected.cwd.clone());
app.cli_kv_overrides
.push(("features.worktrees".into(), TomlValue::Boolean(true)));
@@ -857,7 +858,7 @@ async fn command_center_new_checkout_and_worktree_preserve_source_and_default_br
// Exercise the menu's ordered events, not the separate profile-selection API.
app.chat_widget
.set_feature_enabled(Feature::GuardianApproval, /*enabled*/ true);
app.chat_widget.open_permissions_popup();
Box::pin(app.handle_event(&mut tui, &mut server, AppEvent::OpenPermissionsPopup)).await?;
app.chat_widget.handle_key_event(KeyCode::Up.into());
app.chat_widget.handle_key_event(KeyCode::Enter.into());
while let Ok(event) = events.try_recv() {
+95 -56
View File
@@ -1,3 +1,5 @@
use super::session_lifecycle_requests::recorded_params;
use super::session_lifecycle_requests::start_recording_remote_app_server;
use super::*;
use crate::ThreadParamsMode;
use crate::app_event_sender::AppEventSender;
@@ -18,6 +20,7 @@ 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;
app.chat_widget.windows_sandbox_local_server = true;
assert!(app.windows_sandbox_setup_is_local());
let endpoint = crate::RemoteAppServerEndpoint::WebSocket {
@@ -34,33 +37,48 @@ async fn windows_sandbox_setup_uses_local_app_server_connection() {
}
#[tokio::test]
async fn windows_sandbox_setup_skips_remote_default_executor() -> Result<()> {
async fn windows_sandbox_setup_uses_observed_thread_host() {
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,
);
app.chat_widget.windows_sandbox_local_server = true;
app.chat_widget.windows_sandbox_elevated_setup_complete = true;
for (ids, expected) in [
(None, WindowsSandboxHost::Unknown),
(Some(vec![]), WindowsSandboxHost::Unknown),
(
Some(vec![codex_exec_server::LOCAL_ENVIRONMENT_ID]),
WindowsSandboxHost::Local,
),
(Some(vec!["remote"]), WindowsSandboxHost::Remote),
(
Some(vec!["remote", codex_exec_server::LOCAL_ENVIRONMENT_ID]),
WindowsSandboxHost::Mixed,
),
] {
let environments = ids.map(|ids| {
ids.into_iter()
.map(|id| codex_app_server_protocol::ThreadEnvironment {
environment_id: id.to_string(),
cwd: codex_utils_absolute_path::AbsolutePathBuf::try_from(std::env::temp_dir())
.unwrap()
.into(),
runtime_workspace_roots: Vec::new(),
})
.collect::<Vec<_>>()
});
let mut session = test_thread_session(ThreadId::new(), app.config.cwd.to_path_buf());
session.windows_sandbox_host =
crate::windows_sandbox::host_from_environments(environments.as_deref());
app.chat_widget.handle_thread_session(session);
assert!(app.chat_widget.windows_sandbox_elevated_setup_complete);
assert_eq!(app.windows_sandbox_host(), expected);
assert_eq!(
app.windows_sandbox_setup_is_local(),
expected == WindowsSandboxHost::Local
);
}
app.chat_widget.windows_sandbox_host = WindowsSandboxHost::Local;
app.chat_widget.windows_sandbox_local_server = false;
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(())
}
#[tokio::test]
@@ -119,6 +137,7 @@ async fn windows_sandbox_setup_completion_requires_matching_pending_mode() -> Re
use codex_app_server_protocol::WindowsSandboxSetupMode;
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
app.chat_widget.windows_sandbox_local_server = true;
while events.try_recv().is_ok() {}
let app_server =
crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref()).await?;
@@ -1634,35 +1653,55 @@ async fn external_writer_startup_keeps_initial_prompt_as_draft() -> Result<()> {
Ok(())
}
#[test]
fn windows_sandbox_host_from_observed_environments() {
for (ids, expected) in [
(None, WindowsSandboxHost::Unknown),
(Some(vec![]), WindowsSandboxHost::Unknown),
(
Some(vec![codex_exec_server::LOCAL_ENVIRONMENT_ID]),
WindowsSandboxHost::Local,
),
(Some(vec!["remote"]), WindowsSandboxHost::Remote),
(
Some(vec!["remote", codex_exec_server::LOCAL_ENVIRONMENT_ID]),
WindowsSandboxHost::Mixed,
),
] {
let environments = ids.map(|ids| {
ids.into_iter()
.map(|id| codex_app_server_protocol::ThreadEnvironment {
environment_id: id.to_string(),
cwd: codex_utils_absolute_path::AbsolutePathBuf::try_from(std::env::temp_dir())
.unwrap()
.into(),
runtime_workspace_roots: Vec::new(),
})
.collect::<Vec<_>>()
});
assert_eq!(
crate::windows_sandbox::host_from_environments(environments.as_deref()),
expected
);
}
#[tokio::test]
async fn windows_sandbox_config_refresh_uses_connected_server() -> Result<()> {
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
let (server, requests, proxy) = start_recording_remote_app_server(&app.config).await?;
std::fs::write(
app.config.codex_home.join("config.toml"),
"[windows]\nsandbox = \"unelevated\"\n",
)?;
app.chat_widget.windows_sandbox_config.mode =
Some(codex_app_server_protocol::WindowsSandboxSetupMode::Elevated);
assert!(app.refresh_windows_sandbox_config(&server).await);
let loaded_config = crate::windows_sandbox::WindowsSandboxConfig {
mode: Some(codex_app_server_protocol::WindowsSandboxSetupMode::Unelevated),
requirements: Some(None),
};
assert_eq!(app.chat_widget.windows_sandbox_config, loaded_config);
assert_eq!(
recorded_params(&requests, "config/read")[0]["cwd"],
app.config.cwd.display().to_string()
);
assert_eq!(
recorded_params(&requests, "configRequirements/read").len(),
1
);
proxy.abort();
let _ = proxy.await;
set_test_initial_prompt(&mut app, "keep this draft".to_string());
app.chat_widget.windows_sandbox_elevated_setup_complete = true;
while events.try_recv().is_ok() {}
assert!(!app.refresh_windows_sandbox_config(&server).await);
let cell = match events.try_recv()? {
AppEvent::InsertHistoryCell(cell) => cell,
other => panic!("expected configuration error message, got {other:?}"),
};
insta::assert_snapshot!(lines_to_single_string(&cell.display_lines(/*width*/ 160)), @"■ Could not read Windows sandbox configuration and requirements from the app server.");
assert!(app.chat_widget.windows_sandbox_elevated_setup_complete);
assert_eq!(
app.chat_widget.composer_text_with_pending(),
"keep this draft"
);
assert!(app.chat_widget.initial_user_message.is_none());
let mut recovered = crate::start_embedded_app_server_for_picker(&app.config).await?;
let mut tui = crate::tui::test_support::make_test_tui()?;
app.chat_widget.windows_sandbox_local_server = true;
app.chat_widget.windows_sandbox_host = WindowsSandboxHost::Local;
Box::pin(app.handle_event(&mut tui, &mut recovered, AppEvent::OpenPermissionsPopup)).await?;
assert_eq!(app.chat_widget.windows_sandbox_config, loaded_config);
assert!(app.chat_widget.has_active_view());
recovered.shutdown().await?;
server.shutdown().await?;
Ok(())
}