Support multi-environment apply_patch selection

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-05-07 16:43:32 -07:00
parent 99016ec732
commit ebf66ae577
27 changed files with 871 additions and 213 deletions

View File

@@ -44,6 +44,7 @@ use crate::mcp_tool_call::lookup_mcp_tool_metadata;
use crate::session::Codex;
use crate::session::CodexSpawnArgs;
use crate::session::CodexSpawnOk;
use crate::session::PatchApprovalRequest;
use crate::session::SUBMISSION_CHANNEL_CAPACITY;
use crate::session::emit_subagent_session_started;
use crate::session::session::Session;
@@ -520,6 +521,8 @@ async fn handle_patch_approval(
) {
let ApplyPatchApprovalRequestEvent {
call_id,
environment_id,
cwd,
changes,
reason,
grant_root,
@@ -529,7 +532,7 @@ async fn handle_patch_approval(
let guardian_decision = if routes_approval_to_guardian(parent_ctx) {
let files = changes
.keys()
.map(|path| parent_ctx.cwd.join(path))
.map(|path| cwd.join(path))
.collect::<Vec<_>>();
let review_cancel = cancel_token.child_token();
let patch = changes
@@ -565,7 +568,8 @@ async fn handle_patch_approval(
new_guardian_review_id(),
GuardianApprovalRequest::ApplyPatch {
id: approval_id.clone(),
cwd: parent_ctx.cwd.clone(),
environment_id: environment_id.clone(),
cwd: cwd.clone(),
files,
patch,
},
@@ -590,7 +594,17 @@ async fn handle_patch_approval(
decision
} else {
let decision_rx = parent_session
.request_patch_approval(parent_ctx, call_id, changes, reason, grant_root)
.request_patch_approval(
parent_ctx,
PatchApprovalRequest {
call_id,
environment_id,
cwd,
changes,
reason,
grant_root,
},
)
.await;
await_approval_with_cancel(
async move { decision_rx.await.unwrap_or_default() },