Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions app/src/terminal/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 12 additions & 15 deletions app/src/terminal/view/tab_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ impl TerminalView {

pub fn display_working_directory(&self, ctx: &AppContext) -> Option<String> {
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))
Expand All @@ -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<String> {
#[cfg(feature = "local_fs")]
{
if let Some(branch) = self
.git_status_metadata(ctx)
Comment thread
PratikRai0101 marked this conversation as resolved.
.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<String> {
Expand Down