From 779c35d256a320ddc7611706cb54c2df93618e68 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Fri, 31 Jul 2026 15:48:46 +0200 Subject: [PATCH] acp_thread: Disable Git's configured pager in agent terminals (#61732) Applies the same fix as #43277 to Zed's native agent, which indeed fixes this issue for me locally (which I could only reproduce when specifically telling the agent to not use `--no-pager`, FWIW). Closes #42943 ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed hang when the Zed Agent runs a `git` command with a pager configured. --------- Co-authored-by: MrSubidubi --- crates/acp_thread/src/acp_thread.rs | 5 +++-- crates/acp_thread/src/terminal.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 38a9be3294..6091c47561 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -4404,8 +4404,9 @@ impl AcpThread { }; let env = cx.spawn(async move |_, _| { let mut env = env.await.unwrap_or_default(); - // Disables paging for `git` and hopefully other commands - env.insert("PAGER".into(), "".into()); + + disable_pagers_through_env(&mut env); + for var in extra_env { env.insert(var.name, var.value); } diff --git a/crates/acp_thread/src/terminal.rs b/crates/acp_thread/src/terminal.rs index e52a3367a8..c3e8653fba 100644 --- a/crates/acp_thread/src/terminal.rs +++ b/crates/acp_thread/src/terminal.rs @@ -630,10 +630,7 @@ pub async fn create_terminal_entity( Default::default() }; - // Disable pagers so agent/terminal commands don't hang behind interactive UIs - env.insert("PAGER".into(), "".into()); - // Override user core.pager (e.g. delta) which Git prefers over PAGER - env.insert("GIT_PAGER".into(), "cat".into()); + disable_pagers_through_env(&mut env); env.extend(env_vars); // Use remote shell or default system shell, as appropriate @@ -666,6 +663,13 @@ pub async fn create_terminal_entity( .await } +// Disable pagers so agent/terminal commands don't hang behind interactive UIs +pub(crate) fn disable_pagers_through_env(env: &mut collections::HashMap) { + env.insert("PAGER".into(), "".into()); + // Override user core.pager (e.g. delta) which Git prefers over PAGER + env.insert("GIT_PAGER".into(), "cat".into()); +} + #[cfg(all(test, target_os = "linux"))] mod linux_tests { use super::*; -- knotmirror 0.0.1