mirror of
https://github.com/openai/codex.git
synced 2026-12-03 07:47:10 +00:00
Centralize thread environment selection state (#38423)
## What changed - Make `ThreadEnvironments` the source of truth for live environment selections and use it when building configuration snapshots, permission profiles, per-turn configuration, and MCP refresh inputs. - Keep settings previews side-effect free while applying accepted environment updates consistently to subsequent turns. - Move `EnvironmentConfig` into `codex-protocol` so environment ownership no longer depends on a core-only type. ## Testing - Cover environment previews and snapshots, accepted and rejected steer updates, and active-turn environment stability. GitOrigin-RevId: 7bcf8fb5df1215f720e4e9c419541a51a871aa5e
This commit is contained in:
1 parent
588e18aae5
commit
781445f7c6
16 files changed
+428
-327
No files matched your search
@@ -16,6 +16,7 @@ use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::protocol::EnvironmentConfig;
|
||||
use codex_protocol::protocol::EnvironmentConnectionEvent;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
@@ -27,7 +28,6 @@ use futures::future::BoxFuture;
|
||||
use futures::future::Shared;
|
||||
use tokio_util::task::AbortOnDropHandle;
|
||||
|
||||
use crate::environment_config::EnvironmentConfig;
|
||||
use crate::session::turn_context::ShellSnapshotTask;
|
||||
use crate::session::turn_context::TurnEnvironment;
|
||||
use crate::session::turn_context::TurnEnvironmentConfig;
|
||||
@@ -251,6 +251,38 @@ impl ThreadEnvironments {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn selections(&self) -> Vec<TurnEnvironmentSelection> {
|
||||
self.environments
|
||||
.load()
|
||||
.iter()
|
||||
.map(|environment| environment.selection.clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn primary_workspace_roots(&self) -> Vec<AbsolutePathBuf> {
|
||||
self.environments
|
||||
.load()
|
||||
.first()
|
||||
.map_or_else(Vec::new, |environment| {
|
||||
Self::primary_workspace_roots_for(std::slice::from_ref(&environment.selection))
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn primary_workspace_roots_for(
|
||||
selections: &[TurnEnvironmentSelection],
|
||||
) -> Vec<AbsolutePathBuf> {
|
||||
selections
|
||||
.first()
|
||||
.map(|selection| {
|
||||
selection
|
||||
.workspace_roots
|
||||
.iter()
|
||||
.filter_map(|workspace_root| workspace_root.to_abs_path().ok())
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) fn update_environment_configs(&self, config: &TurnEnvironmentConfig) {
|
||||
let environments = self
|
||||
.environments
|
||||
|
||||
Reference in new issue
Block a user