Track Windows sandbox policy and per-thread executor hosts in the TUI (#45813)

## What changed

- Add `WindowsSandboxConfig` helpers to read app-server configuration and managed requirements, preserve legacy feature flag fallbacks, and select an allowed setup mode with elevated mode preferred when the configured mode is disallowed.
- Store the sandbox host classification in thread session state using reported environments across start, resume, fork, and replay paths. Classify missing or empty environments as `Unknown`, and distinguish local, remote, and mixed selections.

## Testing

Add coverage for managed setup restrictions, legacy configuration precedence, unknown policy state, environment classification, and remote host state in inactive-thread replay.

GitOrigin-RevId: ae8920d9c2a1c80b641ac90617ae607b171bd55a
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-16 00:21:49 +00:00
1 parent 58e2e8cf3c
commit 7f501cd334
22 files changed
+336 -3

No files matched your search

@@ -21,6 +21,7 @@ async fn fork_current_session_preserves_conversation_ultra() -> Result<()> {
.expect("create source rollout"),
)?;
app.chat_widget.handle_thread_session(ThreadSessionState {
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
model: "gpt-5.4".to_string(),
reasoning_effort: Some(ReasoningEffortConfig::Ultra),
..test_thread_session(source_thread_id, test_path_buf("/tmp/project"))
@@ -53,11 +54,13 @@ async fn switching_from_ultra_thread_restores_configured_plan_effort() {
app.chat_widget
.set_feature_enabled(Feature::CollaborationModes, /*enabled*/ true);
let ultra_session = ThreadSessionState {
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
model: "gpt-5.4".to_string(),
reasoning_effort: Some(ReasoningEffortConfig::Ultra),
..test_thread_session(ThreadId::new(), test_path_buf("/tmp/ultra"))
};
let normal_session = ThreadSessionState {
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
model: "gpt-5.4".to_string(),
reasoning_effort: Some(ReasoningEffortConfig::Medium),
..test_thread_session(ThreadId::new(), test_path_buf("/tmp/normal"))
+33
View File
@@ -1633,3 +1633,36 @@ 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
);
}
}