From dcd23464efec3b42a6dabe9238b578bf3700f956 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Fri, 8 May 2026 11:04:22 -0500 Subject: [PATCH] fix(tui): render git branch status item (#1226) --- crates/tui/src/config.rs | 4 ++-- crates/tui/src/tui/ui.rs | 13 ++++++++++++- crates/tui/src/tui/ui/tests.rs | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/crates/tui/src/config.rs b/crates/tui/src/config.rs index 8d3debe6..b557fa7f 100644 --- a/crates/tui/src/config.rs +++ b/crates/tui/src/config.rs @@ -526,7 +526,7 @@ pub enum StatusItem { Cache, /// Context-window utilisation percent ("48%"). ContextPercent, - /// Current git branch name (placeholder until wired). + /// Current git branch name. GitBranch, /// Elapsed time of the most recent tool call (placeholder until wired). LastToolElapsed, @@ -604,7 +604,7 @@ impl StatusItem { StatusItem::ReasoningReplay => "thinking tokens replayed each turn", StatusItem::Cache => "% of prompt served from cache", StatusItem::ContextPercent => "tokens used / model context window", - StatusItem::GitBranch => "current branch (placeholder)", + StatusItem::GitBranch => "current workspace branch", StatusItem::LastToolElapsed => "ms of the most recent tool call (placeholder)", StatusItem::RateLimit => "remaining requests in the budget (placeholder)", } diff --git a/crates/tui/src/tui/ui.rs b/crates/tui/src/tui/ui.rs index af5d8d4b..eed12925 100644 --- a/crates/tui/src/tui/ui.rs +++ b/crates/tui/src/tui/ui.rs @@ -6872,7 +6872,8 @@ fn render_footer_from( for item in items { let chip = match *item { S::ContextPercent => footer_context_percent_spans(app), - S::GitBranch | S::LastToolElapsed | S::RateLimit => Vec::new(), + S::GitBranch => footer_git_branch_spans(app), + S::LastToolElapsed | S::RateLimit => Vec::new(), _ => continue, }; if chip.is_empty() { @@ -6897,6 +6898,16 @@ fn render_footer_from( props } +fn footer_git_branch_spans(app: &App) -> Vec> { + let Some(branch) = workspace_git_branch(&app.workspace) else { + return Vec::new(); + }; + vec![Span::styled( + branch, + Style::default().fg(app.ui_theme.text_muted), + )] +} + /// Spans for the "context %" footer chip. Mirrors the header colour ramp so /// the two surfaces stay visually consistent when both are enabled. fn footer_context_percent_spans(app: &App) -> Vec> { diff --git a/crates/tui/src/tui/ui/tests.rs b/crates/tui/src/tui/ui/tests.rs index 361d63d0..f6952fd5 100644 --- a/crates/tui/src/tui/ui/tests.rs +++ b/crates/tui/src/tui/ui/tests.rs @@ -3840,6 +3840,27 @@ fn render_footer_from_drops_only_unselected_clusters() { ); } +#[test] +fn render_footer_from_git_branch_item_renders_workspace_branch() { + let repo = init_git_repo(); + let checkout = Command::new("git") + .args(["checkout", "-b", "feature/statusline"]) + .current_dir(repo.path()) + .output() + .expect("git checkout should run"); + assert!( + checkout.status.success(), + "git checkout failed: {}", + String::from_utf8_lossy(&checkout.stderr) + ); + + let mut app = create_test_app(); + app.workspace = repo.path().to_path_buf(); + + let props = render_footer_from(&app, &[crate::config::StatusItem::GitBranch], None); + assert_eq!(spans_text(&props.cache), "feature/statusline"); +} + /// Regression for issue #244: visible session spend must not decrease. /// Sub-agent token usage events arrive out of order and may be reconciled /// later (cache adjustments, provisional → final swap). The displayed total