From d72e597cfb6633b24810d0be5e79beb29c80c542 Mon Sep 17 00:00:00 2001 From: Pratik Rai Date: Sun, 3 May 2026 15:37:17 +0530 Subject: [PATCH 1/2] fix(ui): Prevent stale Git branch and working directory in agent sessions (Fixes Bug 1 from #9958) --- app/src/terminal/view/tab_metadata.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/app/src/terminal/view/tab_metadata.rs b/app/src/terminal/view/tab_metadata.rs index ad27661f4..2f0331950 100644 --- a/app/src/terminal/view/tab_metadata.rs +++ b/app/src/terminal/view/tab_metadata.rs @@ -14,8 +14,8 @@ impl TerminalView { pub fn display_working_directory(&self, ctx: &AppContext) -> Option { let raw = self - .prompt_chip_value(&ContextChipKind::WorkingDirectory, ctx) - .or_else(|| self.pwd())?; + .pwd() + .or_else(|| self.prompt_chip_value(&ContextChipKind::WorkingDirectory, ctx))?; let home_dir = self .active_block_session_id() .and_then(|session_id| self.sessions.as_ref(ctx).get(session_id)) @@ -32,21 +32,18 @@ impl TerminalView { .unwrap_or(fallback_title) } - #[cfg_attr(not(feature = "local_fs"), allow(clippy::unnecessary_lazy_evaluations))] pub fn current_git_branch(&self, ctx: &AppContext) -> Option { + #[cfg(feature = "local_fs")] + { + if let Some(branch) = self + .git_status_metadata(ctx) + .map(|metadata| metadata.current_branch_name.clone()) + .filter(|branch| !branch.trim().is_empty()) + { + return Some(branch); + } + } self.prompt_chip_value(&ContextChipKind::ShellGitBranch, ctx) - .or_else(|| { - #[cfg(feature = "local_fs")] - { - self.git_status_metadata(ctx) - .map(|metadata| metadata.current_branch_name.clone()) - .filter(|branch| !branch.trim().is_empty()) - } - #[cfg(not(feature = "local_fs"))] - { - None - } - }) } pub fn last_completed_command_text(&self) -> Option { From 05616074fe656b083f08d5b5b2426cfb6d319c9f Mon Sep 17 00:00:00 2001 From: Pratik Rai Date: Sun, 3 May 2026 16:38:40 +0530 Subject: [PATCH 2/2] fix(git): ensure git status subscription is active for branch metadata --- app/src/terminal/view.rs | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/app/src/terminal/view.rs b/app/src/terminal/view.rs index 26b715863..939092d63 100644 --- a/app/src/terminal/view.rs +++ b/app/src/terminal/view.rs @@ -4610,29 +4610,16 @@ impl TerminalView { } /// Returns whether this terminal view should subscribe to git status - /// updates. We subscribe when: - /// 1. Agent mode is active and its chip list includes `GitDiffStats`, or - /// 2. Terminal mode with the Warp prompt enabled and the git stats chip - /// configured. + /// updates. + /// + /// Always returns `true` when the local_fs feature is available — the + /// caller guards on `current_repo_path` being `Some`, so we only actually + /// subscribe when there is a git repository. The vertical tabs, status bar, + /// and code review panel all need accurate per-session branch and diff + /// metadata regardless of the toolbar chip selection. #[cfg(feature = "local_fs")] - fn should_subscribe_to_git_status(&self, ctx: &AppContext) -> bool { - // Agent view: subscribe only when the configured agent footer includes git stats. - if self.agent_view_controller.as_ref(ctx).is_active() { - return SessionSettings::as_ref(ctx) - .agent_footer_chip_selection - .all_chips() - .contains(&ContextChipKind::GitDiffStats); - } - - // Terminal prompt path: the Warp prompt is active when honor_ps1 is - // off, or when UDI overrides PS1. GitDiffStats must also be in the - // configured chip list. - let is_using_warp_prompt = !*SessionSettings::as_ref(ctx).honor_ps1 - || InputSettings::as_ref(ctx).is_universal_developer_input_enabled(ctx); - is_using_warp_prompt - && Prompt::as_ref(ctx) - .chip_kinds() - .contains(&ContextChipKind::GitDiffStats) + fn should_subscribe_to_git_status(&self, _ctx: &AppContext) -> bool { + true } /// No-op when the `local_fs` feature is disabled – git status is not