mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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:
1 parent
58e2e8cf3c
commit
7f501cd334
22 files changed
+336
-3
No files matched your search
@@ -1775,6 +1775,7 @@ enabled = false
|
||||
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
|
||||
@@ -16,6 +16,7 @@ pub(crate) enum WindowsSandboxHost {
|
||||
Local,
|
||||
Mixed,
|
||||
Remote,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -4403,6 +4403,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
let primary_cwd = test_path_buf("/tmp/main").abs();
|
||||
let shared_root = test_path_buf("/tmp/shared").abs();
|
||||
let primary_session = ThreadSessionState {
|
||||
windows_sandbox_host: WindowsSandboxHost::Local,
|
||||
approval_policy: AskForApproval::OnRequest,
|
||||
permission_profile: PermissionProfile::workspace_write(),
|
||||
runtime_workspace_roots: vec![primary_cwd.clone(), shared_root.clone()],
|
||||
@@ -4427,7 +4428,11 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
ServerNotification::ThreadStarted(ThreadStartedNotification {
|
||||
thread: Thread {
|
||||
originator: None,
|
||||
environments: None,
|
||||
environments: Some(vec![codex_app_server_protocol::ThreadEnvironment {
|
||||
environment_id: "remote".to_string(),
|
||||
cwd: test_path_buf("/tmp/agent").abs().into(),
|
||||
runtime_workspace_roots: Vec::new(),
|
||||
}]),
|
||||
id: agent_thread_id.to_string(),
|
||||
extra: None,
|
||||
session_id: agent_thread_id.to_string(),
|
||||
@@ -4474,6 +4479,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
drop(store);
|
||||
|
||||
assert_eq!(session.thread_id, agent_thread_id);
|
||||
assert_eq!(session.windows_sandbox_host, WindowsSandboxHost::Remote);
|
||||
assert_eq!(session.thread_name, Some("agent thread".to_string()));
|
||||
assert_eq!(session.model, "gpt-agent");
|
||||
assert_eq!(session.model_provider_id, "agent-provider");
|
||||
@@ -5083,6 +5089,7 @@ async fn side_thread_snapshot_hides_forked_parent_transcript() {
|
||||
let side_thread_id = ThreadId::new();
|
||||
let mut store = ThreadEventStore::new(/*capacity*/ 4);
|
||||
let session = ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
forked_from_id: Some(parent_thread_id),
|
||||
fork_parent_title: None,
|
||||
..test_thread_session(side_thread_id, test_path_buf("/tmp/side"))
|
||||
@@ -5150,6 +5157,7 @@ async fn side_thread_snapshot_skips_session_header_preamble() {
|
||||
let snapshot = ThreadEventSnapshot {
|
||||
delegated_turns: Vec::new(),
|
||||
session: Some(ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
forked_from_id: Some(parent_thread_id),
|
||||
fork_parent_title: None,
|
||||
..test_thread_session(side_thread_id, test_path_buf("/tmp/side"))
|
||||
@@ -5731,6 +5739,7 @@ async fn render_clear_ui_header_after_long_transcript_for_snapshot() -> String {
|
||||
};
|
||||
let make_header = |is_first| -> Arc<dyn HistoryCell> {
|
||||
let session = ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -6277,6 +6286,7 @@ async fn replace_goal_confirmation_snapshot() {
|
||||
|
||||
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -7314,6 +7324,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
|
||||
|
||||
let make_header = |is_first| {
|
||||
let session = ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -7386,6 +7397,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
|
||||
let base_id = ThreadId::new();
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: base_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -8545,6 +8557,7 @@ async fn new_session_requests_shutdown_for_previous_conversation() {
|
||||
|
||||
let thread_id = ThreadId::new();
|
||||
let event = crate::session_state::ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -9279,6 +9292,7 @@ async fn clear_only_ui_reset_preserves_chat_session_state() {
|
||||
let thread_id = ThreadId::new();
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -661,6 +661,7 @@ mod tests {
|
||||
|
||||
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
|
||||
@@ -1366,6 +1366,9 @@ impl App {
|
||||
) -> Option<ThreadSessionState> {
|
||||
let mut session = self.primary_session_configured.clone()?;
|
||||
session.thread_id = thread_id;
|
||||
session.windows_sandbox_host = crate::windows_sandbox::host_from_environments(
|
||||
notification.thread.environments.as_deref(),
|
||||
);
|
||||
session.thread_name = notification.thread.name.clone();
|
||||
session.model_provider_id = notification.thread.model_provider.clone();
|
||||
session
|
||||
|
||||
@@ -87,6 +87,7 @@ impl App {
|
||||
session
|
||||
} else {
|
||||
ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
@@ -111,6 +112,8 @@ impl App {
|
||||
rollout_path: thread.path.clone(),
|
||||
}
|
||||
};
|
||||
session.windows_sandbox_host =
|
||||
crate::windows_sandbox::host_from_environments(thread.environments.as_deref());
|
||||
session.thread_id = thread_id;
|
||||
session.thread_name = thread.name.clone();
|
||||
session.model_provider_id = thread.model_provider.clone();
|
||||
@@ -169,6 +172,7 @@ mod tests {
|
||||
|
||||
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
forked_from_id: None,
|
||||
fork_parent_title: None,
|
||||
|
||||
Reference in new issue
Block a user