Streamline agent command-center shortcuts and layout (#46882)

## What changed

- Group shortcut help into Navigate, Tasks, and View sections using the shared shortcut renderer, adapting to one, two, or three columns and indicating when more height is needed.
- Show movement hints in the footer, move the new-worktree hint into help, and remove the idle search row. Give task-list column headers consistent styling.
- Change the default task-deletion binding from `Delete` to `Backspace`, while preserving text editing in search and rename inputs.

## Testing

Add snapshots for responsive help layouts, custom bindings, and active search. Add regression coverage for `Backspace` editing without deleting tasks, and update keymap conflict tests for the new default.

GitOrigin-RevId: 45d7f122c9474f1c054450800dcca5a9b2bbbcc5
This commit is contained in:
Eric Traut
2026-09-20 20:20:00 +00:00
committed by copyberry
parent 282d655def
commit 93b44c3a73
38 changed files with 569 additions and 286 deletions
+73 -47
View File
@@ -2,6 +2,8 @@
use super::*;
use crate::key_hint;
use crate::shortcut_help::Group;
use crate::shortcut_help::Shortcut;
use crate::style::footer_hint_label_style;
pub(super) fn hint_line(items: &[(String, String)]) -> Line<'static> {
@@ -51,50 +53,72 @@ impl AgentsOverviewView {
.join("/")
}
pub(super) fn center_task_hints(&self) -> Vec<(String, String)> {
let mut hints = vec![(self.center_filter_hint(), "filter".into())];
pub(super) fn center_help_lines(&self, width: u16) -> Vec<Line<'static>> {
let mut navigate = Group {
title: "Navigate",
entries: Vec::new(),
};
for (action, label) in [
(ListAction::MoveUp, "Up"),
(ListAction::MoveDown, "Down"),
(ListAction::Accept, "Open"),
(ListAction::PageUp, "Page up"),
(ListAction::PageDown, "Page down"),
] {
navigate.push(self.center_list_hint(action), label);
}
navigate
.entries
.push(Shortcut::new(key_hint::ctrl(KeyCode::Char('c')), "Quit"));
let mut tasks = Group {
title: "Tasks",
entries: Vec::new(),
};
for (action, bindings, label) in [
("new_task", &self.agents_keymap.new_task, "new"),
("new_task", &self.agents_keymap.new_task, "New"),
(
"new_worktree",
&self.agents_keymap.new_worktree,
"new worktree",
"New worktree",
),
("resume", &self.agents_keymap.resume, "resume"),
("search", &self.agents_keymap.search, "search"),
("resume", &self.agents_keymap.resume, "Resume"),
("rename", &self.agents_keymap.rename, "Rename"),
("stop", &self.agents_keymap.stop, "Stop"),
("archive", &self.agents_keymap.archive, "Archive"),
("hide", &self.agents_keymap.hide, "Hide"),
("delete", &self.agents_keymap.delete, "Delete"),
] {
if action != "new_worktree" || self.worktrees_enabled {
tasks.push(self.agents_keymap.primary_hint(action, bindings), label);
}
}
let mut view = Group {
title: "View",
entries: Vec::new(),
};
let filter = self.center_filter_hint();
if !filter.is_empty() {
view.entries.push(Shortcut {
key: filter,
action: "Filter",
});
}
for (action, bindings, label) in [
("search", &self.agents_keymap.search, "Search"),
(
"toggle_grouping",
&self.agents_keymap.toggle_grouping,
"group",
"Group",
),
("rename", &self.agents_keymap.rename, "rename"),
("stop", &self.agents_keymap.stop, "stop"),
("archive", &self.agents_keymap.archive, "archive"),
("hide", &self.agents_keymap.hide, "hide"),
("delete", &self.agents_keymap.delete, "delete"),
] {
if (action != "new_worktree" || self.worktrees_enabled)
&& let Some(hint) = self.agents_keymap.primary_hint(action, bindings)
{
hints.push((hint.display_label(), label.into()));
}
view.push(self.agents_keymap.primary_hint(action, bindings), label);
}
for (action, label) in [
(ListAction::MoveUp, "up"),
(ListAction::MoveDown, "down"),
(ListAction::Accept, "open"),
(ListAction::PageUp, "page up"),
(ListAction::PageDown, "page down"),
] {
if let Some(hint) = self.center_list_hint(action) {
hints.push((hint.display_label(), label.into()));
}
}
hints.push((
key_hint::ctrl(KeyCode::Char('c')).display_label(),
"quit".into(),
let mut lines = vec!["Task shortcuts".bold().into(), Line::default()];
lines.extend(crate::shortcut_help::group_lines(
[navigate, tasks, view],
width,
));
hints
crate::wrapping::word_wrap_lines(lines, usize::from(width.max(/*other*/ 1)))
}
pub(super) fn center_footer_hints(&self) -> Vec<(String, String)> {
@@ -125,6 +149,17 @@ impl AgentsOverviewView {
if state.help {
return hints;
}
if !state.editing_metadata() {
let navigation = [ListAction::MoveUp, ListAction::MoveDown]
.into_iter()
.filter_map(|action| self.center_list_hint(action))
.map(ShortcutHint::display_label)
.collect::<Vec<_>>()
.join("/");
if !navigation.is_empty() {
hints.push((navigation, "move".into()));
}
}
if let Some(hint) = self.center_list_hint(ListAction::Accept) {
hints.push((
hint.display_label(),
@@ -136,21 +171,12 @@ impl AgentsOverviewView {
.into(),
));
}
if !state.editing_metadata() {
for (action, bindings, label) in [
("new_task", &self.agents_keymap.new_task, "new"),
(
"new_worktree",
&self.agents_keymap.new_worktree,
"new worktree",
),
] {
if (action != "new_worktree" || self.worktrees_enabled)
&& let Some(hint) = self.agents_keymap.primary_hint(action, bindings)
{
hints.push((hint.display_label(), label.into()));
}
}
if !state.editing_metadata()
&& let Some(hint) = self
.agents_keymap
.primary_hint("new_task", &self.agents_keymap.new_task)
{
hints.push((hint.display_label(), "new".into()));
}
hints
}
+8 -26
View File
@@ -65,11 +65,7 @@ impl AgentsOverviewView {
} else {
[body, Rect::default(), Rect::default()]
};
let search = row(
list,
/*offset*/ 0,
u16::from(list.height >= 3 || state.editing_metadata()),
);
let search = row(list, /*offset*/ 0, u16::from(state.editing_metadata()));
let list = row(
list,
search.height,
@@ -123,11 +119,6 @@ impl Renderable for AgentsOverviewView {
let inset =
|area: Rect| area.inner(Margin::new(/*horizontal*/ 2, /*vertical*/ 0));
let footer_hints = self.center_footer_hints();
let search_key = self
.agents_keymap
.primary_hint("search", &self.agents_keymap.search)
.map(ShortcutHint::display_label)
.unwrap_or_default();
let state = self.state();
let filter_keys = if state.editing_metadata() {
String::new()
@@ -202,13 +193,6 @@ impl Renderable for AgentsOverviewView {
layout.search,
buf,
);
} else {
let search_label = if search_key.is_empty() {
"Search unavailable".to_owned()
} else {
format!("Search tasks · {search_key}")
};
line(search_label.dim(), layout.search, buf);
}
let notice = state
.connection_notice
@@ -236,15 +220,13 @@ impl Renderable for AgentsOverviewView {
layout.footer.y - layout.header.bottom(),
);
Clear.render(inset(body), buf);
let lines = crate::wrapping::word_wrap_lines(
vec![
"Task shortcuts".bold().into(),
Line::default(),
hint_line(&self.center_task_hints()),
],
usize::from(inset(body).width),
);
Paragraph::new(lines).render(inset(body), buf);
let body = inset(body);
let mut lines = self.center_help_lines(body.width);
if lines.len() > usize::from(body.height) {
lines.truncate(usize::from(body.height.saturating_sub(/*rhs*/ 1)));
lines.push("… resize to see all".dim().into());
}
Paragraph::new(lines).render(body, buf);
return;
}
for y in layout.gap.y..layout.gap.bottom() {
+1 -9
View File
@@ -74,15 +74,7 @@ impl AgentsOverviewView {
let viewport = row(area, padding, area.height - padding * 2);
if padding > 0 {
let (title, status, updated) = columns(row(area, /*offset*/ 0, /*height*/ 1));
line(
if !state.editing_metadata() {
"Tasks".cyan().bold()
} else {
"Tasks".dim()
},
title,
buf,
);
line("Tasks".dim(), title, buf);
line("Status".dim(), status, buf);
Line::from("Updated".dim())
.right_aligned()
+99 -2
View File
@@ -279,10 +279,17 @@ async fn live_center_navigation_and_complete_hints() {
KeyEvent::new_with_kind(KeyCode::Char('?'), KeyModifiers::NONE, KeyEventKind::Repeat);
view.handle_key_event(KeyCode::Char('?').into());
view.handle_key_event(repeat_help);
insta::assert_snapshot!(screen(&view, /*width*/ 40, /*height*/ 24));
for (name, width, height) in [
("live_center_help_three_columns", 100, 24),
("live_center_help_two_columns", 60, 24),
("live_center_help_one_column", 40, 32),
("live_center_navigation_and_complete_hints", 40, 24),
] {
insta::assert_snapshot!(name, screen(&view, width, height));
}
view.handle_key_event(KeyCode::Esc.into());
view.handle_key_event(repeat_help);
assert!(screen(&view, /*width*/ 40, /*height*/ 24).contains("Search tasks"));
assert!(screen(&view, /*width*/ 40, /*height*/ 24).contains("Tasks"));
assert!(!view.is_complete());
view.handle_key_event(KeyCode::Esc.into());
assert!(view.is_complete());
@@ -376,3 +383,93 @@ async fn live_center_fixed_shortcuts_yield_to_configured_actions() {
assert!(rx.try_recv().is_err());
}
}
#[tokio::test]
async fn live_center_hints_follow_configured_bindings() {
let mut app = make_test_app().await;
app.config.features.disable(Feature::Worktrees).unwrap();
let config: TuiKeymap = toml::from_str(
r#"
[list]
move_up = 'k'
move_down = 'j'
page_up = []
[agents]
archive = []
rename = 'z r'
"#,
)
.unwrap();
app.keymap = RuntimeKeymap::from_config(&config).unwrap();
let mut view = app.agents_overview_view(Vec::new(), /*selected_thread_id*/ None);
insta::assert_snapshot!(
"live_center_custom_footer",
screen(&view, /*width*/ 100, /*height*/ 12)
);
view.handle_key_event(KeyCode::Char('?').into());
insta::assert_snapshot!(
"live_center_custom_help",
screen(&view, /*width*/ 100, /*height*/ 24)
);
}
#[tokio::test]
async fn live_center_search_row_appears_only_while_editing() {
let app = make_test_app().await;
let mut view = app.agents_overview_view(
vec![overview_thread(
ThreadId::from_u128(/*value*/ 42),
/*parent_thread_id*/ None,
"Task to find",
ThreadStatus::Idle,
)],
/*selected_thread_id*/ None,
);
let area = Rect::new(
/*x*/ 0, /*y*/ 0, /*width*/ 88, /*height*/ 16,
);
let mut buf = ratatui::buffer::Buffer::empty(area);
view.render(area, &mut buf);
let header = &buf.content[3 * 88..4 * 88];
let text = header
.iter()
.map(ratatui::buffer::Cell::symbol)
.collect::<String>();
let styles =
["Tasks", "Status", "Updated"].map(|label| header[text.find(label).unwrap()].style());
assert_eq!(styles, [styles[0]; 3]);
let idle = screen(&view, area.width, area.height);
view.handle_key_event(KeyCode::Char('f').into());
view.handle_paste("find".into());
insta::assert_snapshot!(
"live_center_search_active",
screen(&view, area.width, area.height)
);
view.handle_key_event(KeyCode::Esc.into());
assert_eq!(screen(&view, area.width, area.height), idle);
}
#[tokio::test]
async fn backspace_edits_search_and_rename_without_deleting_tasks() {
let mut app = make_test_app().await;
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
app.app_event_tx = AppEventSender::new(tx);
let mut view = app.agents_overview_view(
vec![overview_thread(
ThreadId::new(),
/*parent_thread_id*/ None,
"Task",
ThreadStatus::Idle,
)],
/*selected_thread_id*/ None,
);
for key in ['f', 'r'] {
view.handle_key_event(KeyCode::Char(key).into());
let initial = screen(&view, /*width*/ 88, /*height*/ 16);
view.handle_paste("!".into());
view.handle_key_event(KeyCode::Backspace.into());
assert_eq!(screen(&view, /*width*/ 88, /*height*/ 16), initial);
assert!(rx.try_recv().is_err());
view.handle_key_event(KeyCode::Esc.into());
}
}
@@ -406,7 +406,7 @@ async fn lifecycle_removes_background_and_current_tasks_without_losing_the_dashb
] {
let key = match action {
AgentsOverviewAction::Archive => KeyEvent::new(KeyCode::Char('a'), KeyModifiers::NONE),
AgentsOverviewAction::Delete => KeyCode::Delete.into(),
AgentsOverviewAction::Delete => KeyCode::Backspace.into(),
};
let (mut app, mut rx, _op_rx) =
Box::pin(crate::app::tests::make_test_app_with_channels()).await;
@@ -5,10 +5,10 @@ expression: normalize_agent_center_snapshot(&cached)
" Agent command center Group: Project g "
" All 1 Needs you 0 Working 0 Ready 1 Inactive 0 tab/shift+tab filter "
" ──────────────────────────────────────────────────────────────────────────────────────────── "
" Search tasks · f │ Task details "
" Tasks │ "
" /tmp/project 1 │ Review parser "
" › ○ Review parser │ ○ Ready "
" Tasks │ Task details "
" /tmp/project 1 │ "
" › ○ Review parser │ Review parser "
" │ ○ Ready "
" │ "
" │ Last message "
" │ ## Findings "
@@ -41,4 +41,4 @@ expression: normalize_agent_center_snapshot(&cached)
" │ "
" │ "
" │ "
" ? help esc back enter open n new w new worktree "
" ? help esc back ↑/↓ move enter open n new "
@@ -5,10 +5,10 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
Agent command center Group: Project g
All 1 Needs you 0 Working 0 Ready 1 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 1 │ Review parser
› ○ Review parser │ ○ Ready
Tasks │ Task details
/tmp/project 1 │
› ○ Review parser │ Review parser
│ ○ Ready
│
│ Last message
│ let explanation = "A long code line
@@ -25,4 +25,4 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,10 +5,10 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
Agent command center Group: Project g
All 1 Needs you 0 Working 0 Ready 1 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 1 │ Review parser
› ○ Review parser │ ○ Ready
Tasks │ Task details
/tmp/project 1 │
› ○ Review parser │ Review parser
│ ○ Ready
│
│ Last message
│ Check Result
@@ -25,4 +25,4 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,17 +5,17 @@ expression: "render_bottom_popup(&app.chat_widget,\n100).replace(&test_path_disp
Agent command center Group: Model g
All 4 Needs you 0 Working 0 Ready 4 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
Unknown 1 │ Legacy task
› ○ Legacy task │ ○ Ready
│
model-a 2 │ Project
○ Recent task │ /tmp/project
○ Older task │ Model: Unknown
│
model-b 1 │ Prompt
○ Other model │ Legacy task
Tasks │ Task details
Unknown 1 │
› ○ Legacy task │ Legacy task
│ ○ Ready
model-a 2 │
○ Recent task │ Project
○ Older task │ /tmp/project
│ Model: Unknown
model-b 1 │
○ Other model │ Prompt
│ Legacy task
│
│
│
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n100).replace(&test_path_disp
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,7 +5,6 @@ expression: "age.replace_all(&rendered, \" [age]\")"
Agent command center Group: Project g
All 10 Needs you 0 Working 0 Ready 0 Inactive 10
────────────────────────────────────────────────────────────────────────────
Search tasks · f
Tasks Status Updated
/ 10
› ○ Task 12 Inactive [age]
@@ -25,4 +24,5 @@ expression: "age.replace_all(&rendered, \" [age]\")"
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,15 +5,15 @@ expression: "screen(&view, 160, 22)"
Agent command center Group: Project g
All 6 Needs you 2 Working 1 Ready 2 Inactive 1 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks Status Updated │
/tmp/project 6 │ Current task
› ○ Current task current Ready now │ ○ Ready
○ A longer task title that uses the available column Ready 5m ago │
! Failed task Error 1h ago │ Project
● Needs an answer Needs input 2h ago │ /tmp/project
● Working task Working 1d ago │ Model: Unknown
○ Unloaded task Inactive 2d ago │
Tasks Status Updated │ Task details
/tmp/project 6 │
› ○ Current task current Ready now │ Current task
○ A longer task title that uses the available column Ready 5m ago │ ○ Ready
! Failed task Error 1h ago │
● Needs an answer Needs input 2h ago │ Project
● Working task Working 1d ago │ /tmp/project
○ Unloaded task Inactive 2d ago │ Model: Unknown
│
│ Prompt
│ Current task
│
@@ -23,4 +23,4 @@ expression: "screen(&view, 160, 22)"
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -0,0 +1,16 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, 100, 12)"
---
Agent command center Group: Project g
All 0 Needs you 0 Working 0 Ready 0 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────
No tasks yet │
│
│
│
│
│
│
│
? help esc back k/j move enter open n new
@@ -0,0 +1,28 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, 100, 24)"
---
Agent command center Group: Project g
All 0 Needs you 0 Working 0 Ready 0 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────
Task shortcuts
Navigate Tasks View
k Up n New tab/shift+tab Filter
j Down o Resume f Search
enter Open z r Rename g Group
pgdn Page down x Stop
ctrl+c Quit h Hide
backspace Delete
esc back
@@ -0,0 +1,36 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, width, height)"
---
Agent command center Group: Projec…
All 3 Needs you 1 Working 0 ›
────────────────────────────────────
Task shortcuts
Navigate
↑ Up
↓ Down
enter Open
pgup Page up
pgdn Page down
ctrl+c Quit
Tasks
n New
w New worktree
o Resume
r Rename
x Stop
a Archive
h Hide
backspace Delete
View
tab/shift+tab Filter
f Search
g Group
esc back
@@ -0,0 +1,28 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, width, height)"
---
Agent command center Group: Project g
All 3 Needs you 1 Working 0 Ready 1 Inactive 1 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────
Task shortcuts
Navigate Tasks View
↑ Up n New tab/shift+tab Filter
↓ Down w New worktree f Search
enter Open o Resume g Group
pgup Page up r Rename
pgdn Page down x Stop
ctrl+c Quit a Archive
h Hide
backspace Delete
esc back
@@ -0,0 +1,28 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, width, height)"
---
Agent command center Group: Project g
All 3 Needs you 1 Working 0 Ready 1 Inactive 1
────────────────────────────────────────────────────────
Task shortcuts
Navigate Tasks
↑ Up n New
↓ Down w New worktree
enter Open o Resume
pgup Page up r Rename
pgdn Page down x Stop
ctrl+c Quit a Archive
h Hide
backspace Delete
View
tab/shift+tab Filter
f Search
g Group
esc back
@@ -1,28 +1,28 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, 40, 24)"
expression: "screen(&view, width, height)"
---
Agent command center Group: Projec…
All 3 Needs you 1 Working 0 ›
────────────────────────────────────
Task shortcuts
tab/shift+tab filter n new w new
worktree o resume f search g
group r rename x stop a archive
h hide del delete ↑ up ↓ down
enter open pgup page up pgdn page
down ctrl+c quit
Navigate
↑ Up
↓ Down
enter Open
pgup Page up
pgdn Page down
ctrl+c Quit
Tasks
n New
w New worktree
o Resume
r Rename
x Stop
a Archive
h Hide
backspace Delete
… resize to see all
esc back
@@ -0,0 +1,20 @@
---
source: tui/src/app/agent_center_tests.rs
expression: "screen(&view, area.width, area.height)"
---
Agent command center Group: Project g
All 1 Needs you 0 Working 0 Ready 1 Inactive 0
────────────────────────────────────────────────────────────────────────────────────
Search › find
Tasks Status Updated
/tmp/project 1
› ○ Task to find Ready 2m ago
esc back enter open
@@ -5,7 +5,6 @@ expression: "screen(&view, 40, 12)"
Agent command center Group: Projec…
‹ Working 0 Ready 1 Inactive 1
────────────────────────────────────
Search tasks · f
Tasks
/tmp/project 1 of 3
› ○ Unloaded task
@@ -13,4 +12,5 @@ expression: "screen(&view, 40, 12)"
? help esc back enter open n new…
? help esc back ↑/↓ move enter o…
@@ -5,7 +5,6 @@ expression: "render_bottom_popup(&app.chat_widget, 12)"
Agent c…
All … ›
────────
Search …
No tas…
@@ -25,4 +24,5 @@ expression: "render_bottom_popup(&app.chat_widget, 12)"
Service…
@@ -2,5 +2,5 @@
source: tui/src/app/agents_overview_tests.rs
expression: "snapshot.join(\"\\n\")"
---
○ Named task │ ○ Ready | title style: Style::new().fg(Color::Rgb(242, 205, 205)).bg(Color::Reset).underline_color(Color::Reset)
○ Named task │ ○ Ready | title style: Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset)
○ Named task │ Selected task | title style: Style::new().fg(Color::Rgb(242, 205, 205)).bg(Color::Reset).underline_color(Color::Reset)
○ Named task │ Selected task | title style: Style::new().fg(Color::Reset).bg(Color::Reset).underline_color(Color::Reset)
@@ -5,7 +5,6 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
Agent command center Group: Project g
All 0 Needs you 0 Working 0 Ready 0 Inactive 0
────────────────────────────────────────────────────────────────────────────
Search tasks · f
No tasks yet
@@ -25,4 +24,5 @@ expression: "normalize_agent_center_snapshot(render_bottom_popup(&app.chat_widge
Creating worktree…
@@ -5,11 +5,11 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
Agent command center Group: Project g
All 2 Needs you 1 Working 0 Ready 1 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 2 │ Review parser
› ● Review parser │ ● Needs input
○ Other task │
Tasks │ Task details
/tmp/project 2 │
› ● Review parser │ Review parser
○ Other task │ ● Needs input
│
│ Needs attention
│ Which dependency version should I use?
│ Open task to review.
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,11 +5,11 @@ expression: "render_bottom_popup(&app.chat_widget, 100)"
Agent command center Group: Project g
All 2 Needs you 0 Working 1 Ready 1 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 2 │ New task
› ● New task │ ● Working
○ Selected task │
Tasks │ Task details
/tmp/project 2 │
› ● New task │ New task
○ Selected task │ ● Working
│
│ Project
│ /tmp/project
│ Model: Unknown
@@ -6,7 +6,8 @@
use super::footer::FooterProps;
use crate::key_hint;
use crate::key_hint::ShortcutHint;
use crate::shortcut_help::Group;
use crate::shortcut_help::Shortcut;
use crate::style::accent_color;
use crate::style::secondary_text_style;
use crate::wrapping::word_wrap_lines;
@@ -17,55 +18,9 @@ use ratatui::layout::Rect;
use ratatui::style::Styled;
use ratatui::style::Stylize;
use ratatui::text::Line;
use ratatui::text::Span;
use ratatui::widgets::Paragraph;
use ratatui::widgets::Widget;
const COLUMN_GAP: usize = 4;
struct Shortcut {
key: String,
action: &'static str,
}
impl Shortcut {
fn new(key: impl Into<ShortcutHint>, action: &'static str) -> Self {
Self {
key: key.into().display_label(),
action,
}
}
}
struct Group {
title: &'static str,
entries: Vec<Shortcut>,
}
impl Group {
fn push(&mut self, key: Option<ShortcutHint>, action: &'static str) {
if let Some(key) = key {
self.entries.push(Shortcut::new(key, action));
}
}
fn lines(&self) -> Vec<Line<'static>> {
let key_width = self
.entries
.iter()
.map(|entry| Span::raw(&entry.key).width())
.max()
.unwrap_or(/*default*/ 0);
let mut lines = vec![self.title.bold().into()];
for entry in &self.entries {
let key = entry.key.clone().fg(accent_color());
let padding = " ".repeat(key_width.saturating_sub(key.width()) + 2);
lines.push(vec![key, padding.into(), entry.action.into()].into());
}
lines
}
}
pub(super) fn lines(props: &FooterProps, width: u16) -> Vec<Line<'static>> {
let hints = props.key_hints;
let mut compose = Group {
@@ -163,31 +118,12 @@ pub(super) fn lines(props: &FooterProps, width: u16) -> Vec<Line<'static>> {
},
]);
let groups = [compose.lines(), session.lines(), transcript.lines()];
let widths: Vec<usize> = groups
.iter()
.map(|group| group.iter().map(Line::width).max().unwrap_or(/*default*/ 0))
.collect();
let width = usize::from(width.max(/*other*/ 1));
let mut result = vec![Line::from("Keyboard shortcuts").bold(), Line::default()];
if widths.iter().sum::<usize>() + COLUMN_GAP * 2 <= width {
result.extend(columns(&groups, &widths));
} else if widths[0] + COLUMN_GAP + widths[1].max(widths[2]) <= width {
let mut right = groups[1].clone();
right.push(Line::default());
right.extend(groups[2].clone());
result.extend(columns(
&[groups[0].clone(), right],
&[widths[0], widths[1].max(widths[2])],
));
} else {
for (index, group) in groups.into_iter().enumerate() {
if index > 0 {
result.push(Line::default());
}
result.extend(group);
}
}
result.extend(crate::shortcut_help::group_lines(
[compose, session, transcript],
width,
));
let width = usize::from(width.max(/*other*/ 1));
result.push(Line::default());
result.extend(footer_lines(width));
word_wrap_lines(&result, width)
@@ -218,24 +154,6 @@ fn footer_lines(width: usize) -> Vec<Line<'static>> {
)
}
fn columns(groups: &[Vec<Line<'static>>], widths: &[usize]) -> Vec<Line<'static>> {
let height = groups.iter().map(Vec::len).max().unwrap_or(/*default*/ 0);
(0..height)
.map(|row| {
let mut line = Line::default();
for (column, group) in groups.iter().enumerate() {
let entry = group.get(row).cloned().unwrap_or_default();
let padding = widths[column].saturating_sub(entry.width()) + COLUMN_GAP;
line.extend(entry.spans);
if column + 1 < groups.len() {
line.push_span(" ".repeat(padding));
}
}
line
})
.collect()
}
pub(super) fn render(props: &FooterProps, area: Rect, buf: &mut Buffer) {
let mut lines = lines(props, area.width);
let height = usize::from(area.height);
+2
View File
@@ -93,6 +93,8 @@ impl KeyBinding {
}
}
let key = match self.key {
#[cfg(test)]
KeyCode::Backspace => "backspace".to_string(),
#[cfg(test)]
KeyCode::Delete => "del".to_string(),
KeyCode::Enter => "enter".to_string(),
+9 -3
View File
@@ -1373,7 +1373,11 @@ impl RuntimeKeymap {
(keymap.agents.rename.as_ref(), &mut agents.rename, "r"),
(keymap.agents.stop.as_ref(), &mut agents.stop, "x"),
(keymap.agents.archive.as_ref(), &mut agents.archive, "a"),
(keymap.agents.delete.as_ref(), &mut agents.delete, "delete"),
(
keymap.agents.delete.as_ref(),
&mut agents.delete,
"backspace",
),
(keymap.agents.hide.as_ref(), &mut agents.hide, "h"),
(
keymap.agents.toggle_grouping.as_ref(),
@@ -1912,7 +1916,7 @@ impl RuntimeKeymap {
rename: default_bindings![plain(KeyCode::Char('r'))],
stop: default_bindings![plain(KeyCode::Char('x'))],
archive: default_bindings![plain(KeyCode::Char('a'))],
delete: default_bindings![plain(KeyCode::Delete)],
delete: default_bindings![plain(KeyCode::Backspace)],
hide: default_bindings![plain(KeyCode::Char('h'))],
toggle_grouping: default_bindings![plain(KeyCode::Char('g'))],
chord_hints: Arc::default(),
@@ -2317,7 +2321,9 @@ impl RuntimeKeymap {
}
if bindings.iter().any(|binding| {
let (code, modifiers) = binding.normalized_parts();
(code == KeyCode::Backspace && modifiers == KeyModifiers::NONE)
(action != "delete"
&& code == KeyCode::Backspace
&& modifiers == KeyModifiers::NONE)
|| (matches!(code, KeyCode::Char(_)) && crate::key_hint::is_altgr(modifiers))
}) {
return Err(format!(
+7 -4
View File
@@ -42,7 +42,7 @@ See the Codex keymap documentation for supported actions and examples."
fn new_agents_defaults_preserve_existing_custom_bindings() {
for (action, alias) in [
("archive", "a"),
("delete", "delete"),
("delete", "backspace"),
("hide", "h"),
("new_worktree", "w"),
] {
@@ -54,14 +54,17 @@ fn new_agents_defaults_preserve_existing_custom_bindings() {
("list", "move_down", " f12"),
] {
// Plain keys are allowed in the dashboard, but global actions and list
// chord prefixes still share text-entry surfaces.
if alias != "delete" && (context == "global" || context == "list" && !suffix.is_empty())
// chord prefixes still share text-entry surfaces. Backspace is reserved
// for editing task input except when bound to task deletion.
if (alias == "backspace" && context == "agents")
|| (alias != "backspace"
&& (context == "global" || context == "list" && !suffix.is_empty()))
{
continue;
}
let keymap: TuiKeymap = serde_json::from_value(
json!({context: {existing: format!("{alias}{suffix}")}, "approval": {"open_fullscreen": "f12", "approve_for_session": []},
"editor": {"move_line_start": [], "move_line_end": [], "delete_backward_word": [], "delete_forward": []}}),
"editor": {"move_line_start": [], "move_line_end": [], "delete_backward": [], "delete_backward_word": [], "delete_forward": []}}),
)
.unwrap();
let runtime =
+1
View File
@@ -194,6 +194,7 @@ mod session_queue_commands;
mod session_resume;
mod session_start;
mod session_state;
mod shortcut_help;
mod skills_helpers;
mod slash_command;
mod startup_draft;
+100
View File
@@ -0,0 +1,100 @@
//! Shared shortcut groups align keys and flow into three, two, or one column.
//! Surface owners provide runtime bindings and handle titles, footers, and height limits.
use crate::key_hint::ShortcutHint;
use crate::style::accent_color;
use ratatui::style::Stylize;
use ratatui::text::Line;
use ratatui::text::Span;
const COLUMN_GAP: usize = 4;
pub(crate) struct Shortcut {
pub(crate) key: String,
pub(crate) action: &'static str,
}
impl Shortcut {
pub(crate) fn new(key: impl Into<ShortcutHint>, action: &'static str) -> Self {
Self {
key: key.into().display_label(),
action,
}
}
}
pub(crate) struct Group {
pub(crate) title: &'static str,
pub(crate) entries: Vec<Shortcut>,
}
impl Group {
pub(crate) fn push(&mut self, key: Option<ShortcutHint>, action: &'static str) {
if let Some(key) = key {
self.entries.push(Shortcut::new(key, action));
}
}
fn lines(&self) -> Vec<Line<'static>> {
let key_width = self
.entries
.iter()
.map(|entry| Span::raw(&entry.key).width())
.max()
.unwrap_or(/*default*/ 0);
let mut lines = vec![self.title.bold().into()];
for entry in &self.entries {
let key = entry.key.clone().fg(accent_color());
let padding = " ".repeat(key_width.saturating_sub(key.width()) + 2);
lines.push(vec![key, padding.into(), entry.action.into()].into());
}
lines
}
}
pub(crate) fn group_lines(groups: [Group; 3], width: u16) -> Vec<Line<'static>> {
let groups = groups.map(|group| group.lines());
let widths: Vec<usize> = groups
.iter()
.map(|group| group.iter().map(Line::width).max().unwrap_or(/*default*/ 0))
.collect();
let width = usize::from(width.max(/*other*/ 1));
let mut result = Vec::new();
if widths.iter().sum::<usize>() + COLUMN_GAP * 2 <= width {
result.extend(columns(&groups, &widths));
} else if widths[0] + COLUMN_GAP + widths[1].max(widths[2]) <= width {
let mut right = groups[1].clone();
right.push(Line::default());
right.extend(groups[2].clone());
result.extend(columns(
&[groups[0].clone(), right],
&[widths[0], widths[1].max(widths[2])],
));
} else {
for (index, group) in groups.into_iter().enumerate() {
if index > 0 {
result.push(Line::default());
}
result.extend(group);
}
}
result
}
fn columns(groups: &[Vec<Line<'static>>], widths: &[usize]) -> Vec<Line<'static>> {
let height = groups.iter().map(Vec::len).max().unwrap_or(/*default*/ 0);
(0..height)
.map(|row| {
let mut line = Line::default();
for (column, group) in groups.iter().enumerate() {
let entry = group.get(row).cloned().unwrap_or_default();
let padding = widths[column].saturating_sub(entry.width()) + COLUMN_GAP;
line.extend(entry.spans);
if column + 1 < groups.len() {
line.push_span(" ".repeat(padding));
}
}
line
})
.collect()
}
@@ -5,12 +5,12 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
Agent command center Group: Project g
All 3 Needs you 1 Working 1 Ready 0 Inactive 1 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 3 │ Build the dashboard
› ● Build the dashboard current │ ● Needs input
● Repair authentication │
○ Review yesterday's changes │ Agent: Inspect keyboard shortcuts
Tasks │ Task details
/tmp/project 3 │
› ● Build the dashboard current │ Build the dashboard
● Repair authentication │ ● Needs input
○ Review yesterday's changes │
│ Agent: Inspect keyboard shortcuts
│ Open task to review.
│ Waiting for approval.
│
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,11 +5,11 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
Agent command center Group: Project g
All 2 Needs you 1 Working 0 Ready 0 Inactive 1 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 2 │ Repair authentication
› ● Repair authentication │ ● Needs input
○ Investigate parser │
Tasks │ Task details
/tmp/project 2 │
› ● Repair authentication │ Repair authentication
○ Investigate parser │ ● Needs input
│
│ Agent: Check dependencies
│ Which dependency version should I use?
│ Open task to review.
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,7 +5,6 @@ expression: rendered
Agent command center Group: Project g
All 0 Needs you 0 Working 0 ›
────────────────────────────────────────────
Search tasks · f
No tasks yet
@@ -25,4 +24,5 @@ expression: rendered
? help esc back enter open n new w new …
? help esc back ↑/↓ move enter open n n…
@@ -5,11 +5,11 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
Agent command center Group: Project g
All 2 Needs you 1 Working 0 Ready 0 Inactive 1 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 2 │ Investigate parser
● Repair authentication │ ○ Inactive
› ○ Investigate parser │
Tasks │ Task details
/tmp/project 2 │
● Repair authentication │ Investigate parser
› ○ Investigate parser │ ○ Inactive
│
│ Last message
│ Found the regression in the parser.
│ Found the regression in the parser.
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
│ Prompt
│ Investigate parser
│ …
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,10 +5,10 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
Agent command center Group: Project g
All 1 Needs you 0 Working 1 Ready 0 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f │ Task details
Tasks │
/tmp/project 1 │ Check startup performance
› ● Check startup performance │ ● Working
Tasks │ Task details
/tmp/project 1 │
› ● Check startup performance │ Check startup performance
│ ● Working
│
│ Latest activity
│ Checking cold-start regressions
@@ -25,4 +25,4 @@ expression: "render_bottom_popup(&app.chat_widget,\n96).replace(&format!(\"{proj
│
│
│
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -5,7 +5,6 @@ expression: normalize_agent_center_snapshot(grouping)
Agent command center Group: Project g
All 4 Needs you 0 Working 0 Ready 4 Inactive 0 tab/shift+tab filter
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Search tasks · f
Tasks Status Updated
/tmp/worktree-root/primary 2
› ○ Task Ready 2m ago
@@ -25,4 +24,5 @@ expression: normalize_agent_center_snapshot(grouping)
? help esc back enter open n new w new worktree
? help esc back ↑/↓ move enter open n new
@@ -9,6 +9,6 @@ New Worktree | w | Agents new_worktree New Worktree Open a new session in a work
Rename | r | Agents rename Rename Rename the selected task. r Default
Stop | x | Agents stop Stop Stop the selected running task. x Default
Archive | a | Agents archive Archive Archive the selected task and its child agents. a Default
Delete | delete | Agents delete Delete Permanently delete the selected task and its child agents. delete Default
Delete | backspace | Agents delete Delete Permanently delete the selected task and its child agents. backspace Default
Hide | h | Agents hide Hide Hide the selected task until explicitly resumed. h Default
Toggle Grouping | g | Agents toggle_grouping Toggle Grouping Cycle task grouping by project, status, or model. g Default
+2 -2
View File
@@ -162,12 +162,12 @@ async fn connected_trust_cancellation_and_acceptance_control_task_creation() ->
(prompt, b"\x1b"),
("n new", b"n"),
("Folder access", b"\x1b"),
("Search tasks", b"o"),
("Agent command center", b"o"),
("Resume a previous session", b"\x1b[C"),
("Untrusted saved task", b"\r"),
("Open existing task", b"\r"),
("moved-folder", b"\x1b"),
("Search tasks", b"n"),
("Agent command center", b"n"),
(prompt, b"\r"),
] {
let is_consent = expected == prompt