From 1c4428cb823fbd91f77969db2dba0dedccd878c4 Mon Sep 17 00:00:00 2001 From: Logan Johnson Date: Mon, 7 Sep 2026 15:16:49 -0400 Subject: [PATCH] fix(desktop): restore captured session policy command writer Post-policy CI found the shared launcher calls the pure captured-policy helper removed with the obsolete live-app wrapper. Restore only the command writer; keep captured preflight authority and no live state reads. Cover both policies overriding inherited environment. Signed-off-by: Logan Johnson --- .../src/managed_agents/session_policy.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/desktop/src-tauri/src/managed_agents/session_policy.rs b/desktop/src-tauri/src/managed_agents/session_policy.rs index fe4251761b..6c903860d9 100644 --- a/desktop/src-tauri/src/managed_agents/session_policy.rs +++ b/desktop/src-tauri/src/managed_agents/session_policy.rs @@ -67,6 +67,14 @@ pub(crate) fn acp_session_policy(state: &AppState) -> AcpSessionPolicy { ) } +/// Apply the captured launch policy after inherited and user environment. +pub(crate) fn apply_acp_session_policy_env( + command: &mut std::process::Command, + policy: AcpSessionPolicy, +) { + command.env(ACP_SESSION_POLICY_ENV_VAR, policy.as_str()); +} + pub(crate) fn insert_acp_session_policy_env( policy_env: &mut BTreeMap, policy: AcpSessionPolicy, @@ -118,4 +126,14 @@ mod tests { assert_eq!(command_policy(&command), Some("thread")); } + + #[test] + fn captured_local_policy_overrides_user_env_without_reading_live_state() { + for policy in [AcpSessionPolicy::Channel, AcpSessionPolicy::Thread] { + let mut command = std::process::Command::new("true"); + command.env(ACP_SESSION_POLICY_ENV_VAR, "ambient"); + apply_acp_session_policy_env(&mut command, policy); + assert_eq!(command_policy(&command), Some(policy.as_str())); + } + } }