Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

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

Eric Trauta3275210bd25
diff --git a/codex-rs/tui/src/app/agent_center/rows.rs b/codex-rs/tui/src/app/agent_center/rows.rs
index f9860ca0cc..8178ab1c89 100644
--- a/codex-rs/tui/src/app/agent_center/rows.rs
+++ b/codex-rs/tui/src/app/agent_center/rows.rs
@@ -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,
diff --git a/codex-rs/tui/src/app/agent_center_tests.rs b/codex-rs/tui/src/app/agent_center_tests.rs
index b371380609..2408927964 100644
--- a/codex-rs/tui/src/app/agent_center_tests.rs
+++ b/codex-rs/tui/src/app/agent_center_tests.rs
@@ -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]
diff --git a/codex-rs/tui/src/app/agents_overview_tests.rs b/codex-rs/tui/src/app/agents_overview_tests.rs
index 5c7e553757..182d7ac643 100644
--- a/codex-rs/tui/src/app/agents_overview_tests.rs
+++ b/codex-rs/tui/src/app/agents_overview_tests.rs
@@ -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);
diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_selected_status_styles.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_selected_status_styles.snap
new file mode 100644
index 0000000000..7d804f48b7
--- /dev/null
+++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_selected_status_styles.snap
@@ -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()