From 717dbefdb93874a1f0b877b9f39ba25a29cf6148 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Fri, 27 Nov 2026 23:43:25 +0000 Subject: [PATCH] Fit the Agent Command Center grouping header to the panel (#64411) ## Why The full header can clip the current grouping and its shortcut in narrow panels. ## What changed Use shorter header labels as space runs out and show just the grouping in the narrowest layout. Account for the longest grouping name and the configured shortcut when choosing a layout so the title stays stable as users cycle groupings or move focus. Show the shortcut when it is available and fits. ## Testing Add snapshot coverage for Directory grouping with a custom `f11 g` shortcut at 24, 36, and 60 columns. GitOrigin-RevId: 9d4efe8d483d9431ff75c163a1a0ce96b7886894 --- codex-rs/tui/src/app/agent_center/render.rs | 43 ++++++++++++++----- codex-rs/tui/src/app/agent_center_tests.rs | 22 +++++++++- ...d_center__live_center_help_one_column.snap | 2 +- ...and_center__live_center_narrow_rename.snap | 2 +- ..._center_navigation_and_complete_hints.snap | 2 +- ...and_center__live_center_status_filter.snap | 2 +- ...nd_center__workspace_responsive_focus.snap | 2 +- ...__initial_discovery_with_current_task.snap | 3 +- ...__tests__older_server_narrow_overview.snap | 2 +- 9 files changed, 60 insertions(+), 20 deletions(-) diff --git a/codex-rs/tui/src/app/agent_center/render.rs b/codex-rs/tui/src/app/agent_center/render.rs index ec5eb66f1d..69a492da42 100644 --- a/codex-rs/tui/src/app/agent_center/render.rs +++ b/codex-rs/tui/src/app/agent_center/render.rs @@ -142,24 +142,47 @@ impl Renderable for AgentsOverviewView { } else { String::new() }; + const DIRECTORY: &str = "Directory"; let grouping = match state.grouping { AgentsOverviewGrouping::Project => "Project", - AgentsOverviewGrouping::Directory => "Directory", + AgentsOverviewGrouping::Directory => DIRECTORY, AgentsOverviewGrouping::Status => "Status", AgentsOverviewGrouping::Model => "Model", }; - let group_key = self + let hint = self .agents_keymap - .primary_hint("toggle_grouping", &self.agents_keymap.toggle_grouping) - .filter(|_| header_active && !state.task_actions_blocked()) - .filter(|hint| self.editing_allows_hint(&state, *hint)) - .map(ShortcutHint::display_label) + .primary_hint("toggle_grouping", &self.agents_keymap.toggle_grouping); + let key = hint + .map(|hint| format!(" {}", hint.display_label())) .unwrap_or_default(); + let width = usize::from(inset(layout.header).width); + // Reserve the longest group and the configured hint even when parked. Cycling + // groups or moving focus should keep the title in place. + let label = |key_width| { + [ + ("Agent command center", " Group: "), + ("Command Center", " by "), + ("Command Center", " "), + ("Group:", " "), + ] + .into_iter() + .find(|(title, prefix)| { + title.width() + prefix.width() + DIRECTORY.width() + key_width <= width + }) + }; + let (title, mut group_label) = match label(key.width()).or_else(|| label(0)) { + Some((title, prefix)) => (title, format!("{prefix}{grouping}")), + None => (grouping, String::new()), + }; + if header_active + && !state.task_actions_blocked() + && hint.is_some_and(|hint| self.editing_allows_hint(&state, hint)) + && title.width() + group_label.width() + key.width() <= width + { + group_label.push_str(&key); + } line( - vec![ - "Agent command center".bold(), - format!(" Group: {grouping} {group_key}").dim(), - ], + vec![title.bold(), group_label.dim()], inset(layout.header), buf, ); diff --git a/codex-rs/tui/src/app/agent_center_tests.rs b/codex-rs/tui/src/app/agent_center_tests.rs index 76779b33b1..4ba1ee216f 100644 --- a/codex-rs/tui/src/app/agent_center_tests.rs +++ b/codex-rs/tui/src/app/agent_center_tests.rs @@ -1344,13 +1344,13 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu let side = app.conversation_frame.panel_area().unwrap(); let middle = app.conversation_area(Rect::new(0, 0, 185, 18)); assert!(center.right() <= middle.x && middle.right() <= side.x && !middle.is_empty()); - let labels = ["Agent command center", "Keep this draft", "Open in sidebar"].map(|label| { + let labels = ["Command Center", "Keep this draft", "Open in sidebar"].map(|label| { combined .lines() .find_map(|line| line.find(label)) .map(|_| label) }); - insta::assert_snapshot!(format!("{labels:?}"),@"[Some(\"Agent command center\"), Some(\"Keep this draft\"), Some(\"Open in sidebar\")]"); + insta::assert_snapshot!(format!("{labels:?}"),@"[Some(\"Command Center\"), Some(\"Keep this draft\"), Some(\"Open in sidebar\")]"); let divider = app .conversation_frame .divider_area() @@ -1569,6 +1569,24 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu Ok(()) } +#[tokio::test] +async fn grouping_header_fits_directory_and_a_custom_chord_in_the_dock() { + let mut app = make_test_app().await; + let config = toml::from_str("[agents]\ntoggle_grouping = 'f11 g'").unwrap(); + app.keymap = RuntimeKeymap::from_config(&config).unwrap(); + app.agents_overview.view_state.lock().unwrap().grouping = AgentsOverviewGrouping::Directory; + let view = app.agents_overview_view(Vec::new(), /*selected_thread_id*/ None); + let headers = [24, 36, 60].map(|width| { + let screen = screen(&view, width, /*height*/ 16); + format!("{width} columns: {}", screen.lines().next().unwrap().trim()) + }); + insta::assert_snapshot!(headers.join("\n"), @" + 24 columns: Group: Directory + 36 columns: Command Center Directory f11 g + 60 columns: Agent command center Group: Directory f11 g + "); +} + #[tokio::test] async fn search_sort_tab_respects_configured_list_bindings_and_rename() { use crate::app::agents_overview_discovery::HistorySort; diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_help_one_column.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_help_one_column.snap index 2ce0ae1723..9dbfcfe1e6 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_help_one_column.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_help_one_column.snap @@ -2,7 +2,7 @@ source: tui/src/app/agent_center_tests.rs expression: "screen(&view, width, height)" --- - Agent command center Group: Projec… + Command Center by Project All 3 Needs you 1 Working 0 › ──────────────────────────────────── Task shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_narrow_rename.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_narrow_rename.snap index 799cf7c984..053a090f63 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_narrow_rename.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_narrow_rename.snap @@ -2,7 +2,7 @@ source: tui/src/app/agent_center_tests.rs expression: rendered --- - Agent command center Group: Projec… + Command Center by Project All 1 Needs you 0 Working 0 › ──────────────────────────────────── Rename › 界 界 界 界 界 界 界 日 本 語 é 👩‍💻 diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_navigation_and_complete_hints.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_navigation_and_complete_hints.snap index 44c7bd0a0c..8c9c43a78c 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_navigation_and_complete_hints.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_navigation_and_complete_hints.snap @@ -2,7 +2,7 @@ source: tui/src/app/agent_center_tests.rs expression: "screen(&view, width, height)" --- - Agent command center Group: Projec… + Command Center by Project All 3 Needs you 1 Working 0 › ──────────────────────────────────── Task shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_status_filter.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_status_filter.snap index dc0c326e51..148e13f725 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_status_filter.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__live_center_status_filter.snap @@ -2,7 +2,7 @@ source: tui/src/app/agent_center_tests.rs expression: "screen(&view, 40, 12)" --- - Agent command center Group: Projec… + Command Center by Project g ‹ Working 0 Ready 1 Inactive 1 ──────────────────────────────────── Tasks diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__workspace_responsive_focus.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__workspace_responsive_focus.snap index 9128e8f3f7..20e9459583 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__workspace_responsive_focus.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__command_center__workspace_responsive_focus.snap @@ -3,7 +3,7 @@ source: tui/src/app/agent_center_tests.rs expression: "screens.join(\"\\n\\n\")" --- Wide Command Center - Agent command center Group: Pr… │ Response row 22 + Command Center by Project g │ Response row 22 All 1 Needs you 0 › │ Response row 23 ──────────────────────────────── │ Response row 24 │ Response row 25 diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__discovery__initial_discovery_with_current_task.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__discovery__initial_discovery_with_current_task.snap index c1e40dd3d7..30072c042a 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__discovery__initial_discovery_with_current_task.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__discovery__initial_discovery_with_current_task.snap @@ -1,9 +1,8 @@ --- source: tui/src/app/agents_overview_discovery_tests.rs -assertion_line: 127 expression: screen --- - Agent command center Group: Pr… + Command Center by Project g All 1 Needs you 0 › ──────────────────────────────── diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__older_server_narrow_overview.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__older_server_narrow_overview.snap index b510eed9e7..09c3f0622a 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__older_server_narrow_overview.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__agents_overview__tests__older_server_narrow_overview.snap @@ -2,7 +2,7 @@ source: tui/src/app/agents_overview_tests.rs expression: "render_bottom_popup(&app.chat_widget, 12)" --- - Agent c… + Project All … › ──────── No tas…