diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index dd5d4de670..fa86dc5fde 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -384,24 +384,26 @@ 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); + if !self.has_input_focus { + // 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); + } } }