fix(tui): render git branch status item (#1226)
This commit is contained in:
@@ -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)",
|
||||
}
|
||||
|
||||
@@ -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<Span<'static>> {
|
||||
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<Span<'static>> {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user