diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index edeaef9932..1cedbf6204 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -982,13 +982,17 @@ async fn handle_function_call( ) .await; - match rx_approve.await.unwrap_or_default() { + let decision = rx_approve.await.unwrap_or_default(); + + if matches!(decision, ReviewDecision::ApprovedForSession) { + // Persist this command as pre-approved for the + // remainder of the session so future executions + // can skip the sandbox directly. + sess.add_approved_command(params.command.clone()); + } + + match decision { ReviewDecision::Approved | ReviewDecision::ApprovedForSession => { - // Persist this command as pre‑approved for the - // remainder of the session so future - // executions skip the sandbox directly. - // TODO(ragona): Isn't this a bug? It always saves the command in an | fork? - sess.add_approved_command(params.command.clone()); // Inform UI we are retrying without sandbox. sess.notify_background_event( &sub_id,