From 66ab8fb43dd7f86b8b51f0aea1b263b0cefdd812 Mon Sep 17 00:00:00 2001 From: Daniel Edrisian Date: Sun, 31 Aug 2025 14:11:17 -0700 Subject: [PATCH] handle patch requests too --- codex-rs/tui/src/bottom_pane/mod.rs | 23 +++++++++++++++++++++++ codex-rs/tui/src/chatwidget.rs | 4 ---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index 6f757e3b3e..711afd4e20 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use crate::app_event_sender::AppEventSender; +use crate::notifications; use crate::tui::FrameRequester; use crate::user_approval_widget::ApprovalRequest; use bottom_pane_view::BottomPaneView; @@ -383,6 +384,28 @@ impl BottomPane { /// Called when the agent requests user approval. pub fn push_approval_request(&mut self, request: ApprovalRequest) { + // Send a system notification whenever an approval dialog is about to be shown. + match &request { + ApprovalRequest::Exec { command, .. } => { + let preview = command.join(" "); + let msg = format!("Approve \"{preview}\"?"); + notifications::send_os_notification(&msg); + } + ApprovalRequest::ApplyPatch { reason, grant_root, .. } => { + let msg = if let Some(root) = grant_root { + format!( + "Approve patch changes? Grant write to {}", + root.display() + ) + } else if let Some(r) = reason { + format!("Approve patch changes? {r}") + } else { + "Approve patch changes?".to_string() + }; + notifications::send_os_notification(&msg); + } + } + let request = if let Some(view) = self.active_view.as_mut() { match view.try_consume_approval_request(request) { Some(request) => request, diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 8c5a3034fc..de6196b595 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -505,10 +505,6 @@ impl ChatWidget { pub(crate) fn handle_exec_approval_now(&mut self, id: String, ev: ExecApprovalRequestEvent) { self.flush_answer_stream_with_separator(); - // Send an OS notification summarizing the command requiring approval. - let preview = ev.command.join(" "); - let msg = format!("Approve \"{preview}\"?"); - notifications::send_os_notification(&msg); let request = ApprovalRequest::Exec { id,