app-server: trim environment root plumbing

This commit is contained in:
pakrym-oai
2026-07-09 20:08:27 -07:00
parent 4bc7a1042c
commit 2020f5755e
3 changed files with 11 additions and 25 deletions
@@ -969,6 +969,8 @@ impl ThreadRequestProcessor {
));
}
let runtime_workspace_roots = runtime_workspace_roots.map(resolve_runtime_workspace_roots);
let environments =
resolve_turn_environment_selections(self.thread_manager.as_ref(), environments)?;
let mut typesafe_overrides = self.build_thread_config_overrides(
model,
model_provider,
@@ -1092,7 +1094,7 @@ impl ThreadRequestProcessor {
history_mode: Option<ThreadHistoryMode>,
session_start_source: Option<codex_app_server_protocol::ThreadStartSource>,
thread_source: Option<codex_protocol::protocol::ThreadSource>,
environments: Option<Vec<codex_app_server_protocol::TurnEnvironmentParams>>,
environment_selections: Option<Vec<TurnEnvironmentSelection>>,
service_name: Option<String>,
allow_provider_model_fallback: bool,
experimental_raw_events: bool,
@@ -1105,11 +1107,6 @@ impl ThreadRequestProcessor {
.load_with_overrides(config_overrides.clone(), typesafe_overrides.clone())
.await
.map_err(|err| config_load_error(&err))?;
let environment_selections = resolve_turn_environment_selections(
listener_task_context.thread_manager.as_ref(),
environments,
)?;
// The user may have requested WorkspaceWrite or DangerFullAccess via
// the command line, though in the process of deriving the Config, it
// could be downgraded to ReadOnly (perhaps there is no sandbox
@@ -107,7 +107,6 @@ fn map_additional_context(
struct ThreadSettingsBuildParams {
method: &'static str,
environments: Option<TurnEnvironmentSelections>,
runtime_workspace_roots: Option<Vec<AbsolutePathBuf>>,
approval_policy: Option<codex_app_server_protocol::AskForApproval>,
approvals_reviewer: Option<codex_app_server_protocol::ApprovalsReviewer>,
sandbox_policy: Option<codex_app_server_protocol::SandboxPolicy>,
@@ -501,7 +500,7 @@ impl TurnRequestProcessor {
.build_environment_override(
thread.as_ref(),
cwd,
runtime_workspace_roots.clone(),
runtime_workspace_roots,
environment_selections,
)
.await;
@@ -511,7 +510,6 @@ impl TurnRequestProcessor {
ThreadSettingsBuildParams {
method: "turn/start",
environments,
runtime_workspace_roots,
approval_policy: params.approval_policy,
approvals_reviewer: params.approvals_reviewer,
sandbox_policy: params.sandbox_policy,
@@ -602,7 +600,7 @@ impl TurnRequestProcessor {
let snapshot = thread.config_snapshot().await;
let current_cwd = snapshot.cwd().clone();
let legacy_fallback_cwd = cwd.unwrap_or_else(|| snapshot.cwd().clone());
let legacy_fallback_cwd = cwd.unwrap_or_else(|| current_cwd.clone());
let workspace_roots = match workspace_roots {
Some(workspace_roots) => workspace_roots,
None => {
@@ -640,7 +638,6 @@ impl TurnRequestProcessor {
let ThreadSettingsBuildParams {
method,
environments,
runtime_workspace_roots,
approval_policy,
approvals_reviewer,
sandbox_policy,
@@ -661,7 +658,6 @@ impl TurnRequestProcessor {
let collaboration_mode =
collaboration_mode.map(|mode| self.normalize_collaboration_mode(mode));
let runtime_workspace_roots_request = runtime_workspace_roots;
let has_environment_override = environments.is_some();
// `thread/settings/update` only acknowledges that the update was queued.
// Clients that send dependent partial updates should wait for
@@ -673,7 +669,6 @@ impl TurnRequestProcessor {
};
let has_any_overrides = has_environment_override
|| runtime_workspace_roots_request.is_some()
|| approval_policy.is_some()
|| approvals_reviewer.is_some()
|| sandbox_policy.is_some()
@@ -798,7 +793,6 @@ impl TurnRequestProcessor {
ThreadSettingsBuildParams {
method: "thread/settings/update",
environments,
runtime_workspace_roots: None,
approval_policy: params.approval_policy,
approvals_reviewer: params.approvals_reviewer,
sandbox_policy: params.sandbox_policy,
+6 -11
View File
@@ -475,12 +475,10 @@ impl Session {
let mut config = Self::build_per_turn_config(
session_configuration,
session_configuration.cwd().clone(),
workspace_roots.clone(),
workspace_roots,
);
config.model = Some(session_configuration.collaboration_mode.model().to_string());
config.permissions.approval_policy = session_configuration.approval_policy.clone();
config.workspace_roots = workspace_roots.clone();
config.permissions.set_workspace_roots(workspace_roots);
config
}
@@ -699,7 +697,7 @@ impl Session {
multi_agent_runtime: TurnMultiAgentRuntime,
) -> Arc<TurnContext> {
let turn_environments = self.services.turn_environments.snapshot().await;
let primary_turn_environment = turn_environments.primary().cloned();
let primary_turn_environment = turn_environments.primary();
// TODO(anp): Migrate per-turn config and legacy TurnContext cwd consumers to PathUri so
// a foreign primary environment does not fall back to the session's host cwd.
let cwd = primary_turn_environment
@@ -707,17 +705,14 @@ impl Session {
.and_then(|turn_environment| turn_environment.cwd().to_abs_path().ok())
.unwrap_or_else(|| session_configuration.cwd().clone());
let workspace_roots = primary_turn_environment
.as_ref()
.map(TurnEnvironment::workspace_roots)
.map(|workspace_roots| {
workspace_roots
.and_then(|turn_environment| {
turn_environment
.workspace_roots()
.iter()
.map(PathUri::to_abs_path)
.collect::<std::io::Result<Vec<_>>>()
.ok()
})
.transpose()
.ok()
.flatten()
.unwrap_or_default();
let per_turn_config =
Self::build_per_turn_config(&session_configuration, cwd.clone(), workspace_roots);