mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
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
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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 › 界 界 界 界 界 界 界 日 本 語 é 👩💻
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-2
@@ -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 ›
|
||||
────────────────────────────────
|
||||
|
||||
|
||||
+1
-1
@@ -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…
|
||||
|
||||
Reference in New Issue
Block a user