Match agent status symbols to the selected row style (#47319)

## Why

Status symbols in the agents overview retained their status color when selected, making their styling inconsistent with the rest of the selected row.

## What changed

Apply the row's selection style to its status symbol while preserving status colors for unselected rows.

## Testing

Extend rendering tests to assert and snapshot selected status symbol styles across status variants, and verify that an unselected idle symbol retains its cyan color.

GitOrigin-RevId: a5163841bed80d6d43e7c62a7596c6e48b9dc886
This commit is contained in:
Eric Traut
2026-09-22 16:15:02 +00:00
committed by copyberry
parent d6093d3228
commit a3275210bd
4 changed files with 52 additions and 2 deletions
+4 -1
View File
@@ -153,7 +153,10 @@ impl AgentsOverviewView {
},
style,
);
let (status, dot) = Self::status(task);
let (status, mut dot) = Self::status(task);
if index == self.selected {
dot.style = style;
}
line(
Line::from(if index == self.selected { "›" } else { " " }).style(style),
rect,
+32 -1
View File
@@ -66,8 +66,39 @@ async fn live_center_columns() {
thread
})
.collect::<Vec<_>>();
let view = app.agents_overview_view(threads, Some(current));
let mut view = app.agents_overview_view(threads, Some(current));
insta::assert_snapshot!(screen(&view, /*width*/ 160, /*height*/ 22));
let mut selected_status_styles = Vec::new();
for _ in 0..fixtures.len() {
let area = Rect::new(
/*x*/ 0, /*y*/ 0, /*width*/ 160, /*height*/ 22,
);
let mut buf = ratatui::buffer::Buffer::empty(area);
view.render(area, &mut buf);
let selected_row = buf
.content
.chunks(usize::from(area.width))
.find(|row| row.iter().any(|cell| cell.symbol() == "›"))
.unwrap();
let marker = selected_row
.iter()
.position(|cell| cell.symbol() == "›")
.unwrap();
assert_eq!(
selected_row[marker + 2].style(),
selected_row[marker].style()
);
selected_status_styles.push(format!(
"{} | {:?}",
selected_row[marker + 2].symbol(),
selected_row[marker + 2].style()
));
view.handle_key_event(KeyCode::Down.into());
}
insta::assert_snapshot!(
"live_center_selected_status_styles",
selected_status_styles.join("\n")
);
}
#[tokio::test]
@@ -61,6 +61,10 @@ async fn overview_thread_colors_match_footer_and_respect_color_suppression() {
let text: String = row.iter().map(ratatui::buffer::Cell::symbol).collect();
if let Some(x) = text.find("Named task") {
let x = text[..x].chars().count();
let dot = row.iter().find(|cell| cell.symbol() == "○").unwrap();
let mut expected = ratatui::buffer::Cell::default();
expected.set_symbol("○").set_style(Style::default().cyan());
assert_eq!(dot, &expected);
snapshot.push(format!(
"{} | title style: {:?}",
normalize_agent_center_snapshot(&text),
@@ -147,6 +151,7 @@ use pretty_assertions::assert_eq;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
use ratatui::layout::Rect;
use ratatui::style::Style;
static OVERVIEW_TIMESTAMP: std::sync::LazyLock<i64> =
std::sync::LazyLock::new(|| chrono::Utc::now().timestamp() - 120);
@@ -0,0 +1,11 @@
---
source: tui/src/app/agent_center_tests.rs
assertion_line: 98
expression: "selected_status_styles.join(\"\\n\")"
---
○ | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()
○ | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()
! | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()
● | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()
● | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()
○ | Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset).bold().reversed()