mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
Make agent center help scrollable and status tabs clickable (#64807)
## Why Short terminals can cut off agent center shortcuts and require a resize to read them. Status filter tabs and their overflow arrows are visible but require keyboard navigation. ## What changed - Scroll help with the configured list navigation keys or mouse wheel. Show a scroll hint when help extends beyond the viewport. - Click a status tab to filter tasks, or click an overflow arrow to select the adjacent hidden tab. Overflow arrows also work in Analytics. - Display `/` as the primary search shortcut and retain `F3` as a binding. ## Testing Extend regression tests for help scrolling, task paging after resizing in help, and mouse clicks on filter tabs and overflow arrows. GitOrigin-RevId: b01b465626a681ca48a6e20547a24cf715a9a406
This commit is contained in:
@@ -24,11 +24,14 @@ fn mouse_at(view: &mut AnalyticsView, kind: MouseEventKind, area: Rect) {
|
||||
async fn mouse_routing_keeps_clipped_tabs_and_refresh_targets_account_scoped() {
|
||||
let mut view = fixture::view(models::AccountKind::Consumer);
|
||||
screen(&mut view, /*width*/ 100, /*height*/ 24);
|
||||
let (_, tab) = view
|
||||
.tab_hits
|
||||
.iter()
|
||||
.find(|(section, _)| *section == Section::Plugins)
|
||||
.unwrap();
|
||||
let plugins = |view: &AnalyticsView| {
|
||||
view.tab_hits
|
||||
.iter()
|
||||
.find(|(section, _)| *section == Section::Plugins)
|
||||
.unwrap()
|
||||
.1
|
||||
};
|
||||
let tab = plugins(&view);
|
||||
let mut tui = crate::tui::test_support::make_test_tui().unwrap();
|
||||
view.handle_event(
|
||||
&mut tui,
|
||||
@@ -42,9 +45,13 @@ async fn mouse_routing_keeps_clipped_tabs_and_refresh_targets_account_scoped() {
|
||||
.unwrap();
|
||||
assert_eq!(view.section, Section::Plugins);
|
||||
screen(&mut view, /*width*/ 20, /*height*/ 12);
|
||||
let (_, tab) = view.tab_hits[0];
|
||||
let tab = plugins(&view);
|
||||
mouse_at(&mut view, MouseEventKind::Down(MouseButton::Left), tab);
|
||||
assert_eq!(view.section, Section::Plugins);
|
||||
screen(&mut view, /*width*/ 20, /*height*/ 12);
|
||||
let (_, chevron) = view.tab_hits[0];
|
||||
mouse_at(&mut view, MouseEventKind::Down(MouseButton::Left), chevron);
|
||||
assert_eq!(view.section, Section::Activity);
|
||||
|
||||
screen(&mut view, /*width*/ 100, /*height*/ 24);
|
||||
let targets = view.control_hits.clone();
|
||||
|
||||
@@ -151,7 +151,8 @@ impl AgentsOverviewView {
|
||||
pub(super) fn center_footer_hints(&self) -> Vec<(String, String)> {
|
||||
let state = self.state();
|
||||
let mut hints = Vec::new();
|
||||
if !state.help
|
||||
let help = state.help_top.is_some();
|
||||
if !help
|
||||
&& !state.editing_metadata()
|
||||
&& ![KeyModifiers::NONE, KeyModifiers::SHIFT]
|
||||
.into_iter()
|
||||
@@ -172,7 +173,7 @@ impl AgentsOverviewView {
|
||||
format!("sort ({})", state.search_sort.label()),
|
||||
));
|
||||
}
|
||||
let cancel = if state.help {
|
||||
let cancel = if help {
|
||||
self.keymap.primary_hint(ListAction::Cancel)
|
||||
} else if state.editing_metadata() || self.can_return_to_chat {
|
||||
self.center_list_hint(ListAction::Cancel)
|
||||
@@ -182,20 +183,26 @@ impl AgentsOverviewView {
|
||||
if let Some(hint) = cancel.filter(|hint| self.editing_allows_hint(&state, *hint)) {
|
||||
hints.push((hint.display_label(), "back".into()));
|
||||
}
|
||||
if state.help {
|
||||
return hints;
|
||||
}
|
||||
if !state.editing_metadata() {
|
||||
if !state.editing_metadata() && (!help || state.scroll_limit > 0) {
|
||||
let navigation = [ListAction::MoveUp, ListAction::MoveDown]
|
||||
.into_iter()
|
||||
.filter_map(|action| self.center_list_hint(action))
|
||||
.filter_map(|action| {
|
||||
if help {
|
||||
self.keymap.primary_hint(action)
|
||||
} else {
|
||||
self.center_list_hint(action)
|
||||
}
|
||||
})
|
||||
.map(ShortcutHint::display_label)
|
||||
.collect::<Vec<_>>()
|
||||
.join("/");
|
||||
if !navigation.is_empty() {
|
||||
hints.push((navigation, "move".into()));
|
||||
hints.push((navigation, if help { "scroll" } else { "move" }.into()));
|
||||
}
|
||||
}
|
||||
if help {
|
||||
return hints;
|
||||
}
|
||||
if let Some(hint) = self
|
||||
.center_list_hint(ListAction::Accept)
|
||||
.filter(|hint| self.editing_allows_hint(&state, *hint))
|
||||
|
||||
@@ -126,31 +126,35 @@ impl AgentsOverviewView {
|
||||
return false;
|
||||
}
|
||||
let mut state = self.state();
|
||||
if state.help && self.keymap.action_for(key) == Some(ListAction::Cancel) {
|
||||
state.help = false;
|
||||
return true;
|
||||
}
|
||||
if state.help {
|
||||
if key.code == KeyCode::Char('?')
|
||||
&& key.kind == KeyEventKind::Press
|
||||
&& !key
|
||||
.modifiers
|
||||
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT)
|
||||
{
|
||||
state.help = false;
|
||||
let toggle_help = key.code == KeyCode::Char('?')
|
||||
&& key.kind == KeyEventKind::Press
|
||||
&& !key
|
||||
.modifiers
|
||||
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT);
|
||||
if let Some(top) = state.help_top {
|
||||
let action = self.keymap.action_for(key);
|
||||
if toggle_help || action == Some(ListAction::Cancel) {
|
||||
state.help_top = None;
|
||||
let area = state.list_area;
|
||||
drop(state);
|
||||
self.layout_task_viewport(area);
|
||||
} else if let Some(action) = action {
|
||||
state.help_top = Some(crate::bottom_pane::scroll_offset(
|
||||
top,
|
||||
state.scroll_limit,
|
||||
usize::from(state.help_area.height),
|
||||
action,
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if self.center_shortcut_keys.is_pressed(key) {
|
||||
return false;
|
||||
}
|
||||
if key.code == KeyCode::Char('?')
|
||||
&& key.kind == KeyEventKind::Press
|
||||
&& !key
|
||||
.modifiers
|
||||
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT)
|
||||
{
|
||||
state.help = !state.help;
|
||||
if toggle_help {
|
||||
let area = state.help_area;
|
||||
drop(state);
|
||||
self.layout_center_help(area, /*top*/ 0);
|
||||
return true;
|
||||
}
|
||||
if key.code == KeyCode::Tab
|
||||
@@ -163,10 +167,9 @@ impl AgentsOverviewView {
|
||||
} else {
|
||||
1
|
||||
};
|
||||
state.status_filter = (state.status_filter + step) % TASK_FILTERS.len();
|
||||
state.scroll = 0;
|
||||
let filter = (state.status_filter + step) % TASK_FILTERS.len();
|
||||
drop(state);
|
||||
self.reconcile_command_center_selection();
|
||||
self.select_filter(filter);
|
||||
return true;
|
||||
}
|
||||
false
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//! Navigation clamps at either end of the visible list.
|
||||
|
||||
use super::*;
|
||||
use crossterm::event::MouseEvent;
|
||||
use ratatui::layout::Position;
|
||||
use std::ops::Range;
|
||||
|
||||
@@ -40,7 +41,7 @@ pub(super) fn visible_page(
|
||||
.iter()
|
||||
.position(|row| row.selection_index() == Some(selected_index))
|
||||
.unwrap_or_default();
|
||||
let height = state.page_height.max(1);
|
||||
let height = usize::from(state.scroll_area.height).max(1);
|
||||
let mut start = state.scroll.min(entries.len().saturating_sub(height));
|
||||
if selected <= start {
|
||||
start = selected;
|
||||
@@ -75,7 +76,7 @@ impl AgentsOverviewView {
|
||||
entries.push(TaskListRow::Group(index));
|
||||
}
|
||||
entries.push(TaskListRow::Task(index));
|
||||
if state.list_width < STATUS_COLUMNS_MIN_WIDTH && state.page_height > 1 {
|
||||
if state.list_width < STATUS_COLUMNS_MIN_WIDTH && state.scroll_area.height > 1 {
|
||||
entries.push(TaskListRow::Context(index));
|
||||
}
|
||||
previous = Some(index);
|
||||
@@ -131,15 +132,49 @@ impl AgentsOverviewView {
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::app) fn scroll_mouse(&self, event: MouseEvent) -> bool {
|
||||
let mut state = self.state();
|
||||
let Some(top) = state.help_top else {
|
||||
return false;
|
||||
};
|
||||
let Some(rows) = crate::bottom_pane::wheel_rows_in(event, state.scroll_area) else {
|
||||
return false;
|
||||
};
|
||||
let height = state.scroll_area.height as isize;
|
||||
let next = top
|
||||
.saturating_add_signed(isize::from(rows).clamp(-height, height))
|
||||
.min(state.scroll_limit);
|
||||
state.help_top = Some(next);
|
||||
next != top
|
||||
}
|
||||
|
||||
pub(super) fn select_filter(&mut self, filter: usize) {
|
||||
let mut state = self.state();
|
||||
state.status_filter = filter;
|
||||
state.scroll = 0;
|
||||
drop(state);
|
||||
self.reconcile_command_center_selection();
|
||||
}
|
||||
|
||||
pub(in crate::app) fn click_row(&mut self, point: Position) {
|
||||
let state = self.state();
|
||||
if state.rename_target.is_some()
|
||||
|| state.help
|
||||
|| state.help_top.is_some()
|
||||
|| state.removal.is_some()
|
||||
|| state.creating_worktree
|
||||
{
|
||||
return;
|
||||
}
|
||||
if !state.editing_metadata()
|
||||
&& let Some(&(filter, _)) = state
|
||||
.filter_hits
|
||||
.iter()
|
||||
.find(|(_, rect)| rect.contains(point))
|
||||
{
|
||||
drop(state);
|
||||
self.select_filter(filter);
|
||||
return;
|
||||
}
|
||||
let target = state
|
||||
.row_hits
|
||||
.iter()
|
||||
@@ -189,7 +224,7 @@ impl AgentsOverviewView {
|
||||
// Leave one row of overlap in case the destination needs its heading.
|
||||
let start = page
|
||||
.start
|
||||
.saturating_sub(state.page_height.saturating_sub(1));
|
||||
.saturating_sub(usize::from(state.scroll_area.height.saturating_sub(1)));
|
||||
entries[start..selected]
|
||||
.iter()
|
||||
.rev()
|
||||
|
||||
@@ -46,6 +46,7 @@ fn visible_suffix(input: &str, available: usize) -> &str {
|
||||
|
||||
struct CenterLayout {
|
||||
header: Rect,
|
||||
body: Rect,
|
||||
list: Rect,
|
||||
gap: Rect,
|
||||
details: Rect,
|
||||
@@ -80,6 +81,7 @@ impl AgentsOverviewView {
|
||||
);
|
||||
CenterLayout {
|
||||
header,
|
||||
body,
|
||||
list,
|
||||
gap,
|
||||
details,
|
||||
@@ -87,6 +89,16 @@ impl AgentsOverviewView {
|
||||
footer,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn layout_center_help(&self, area: Rect, top: usize) -> Paragraph<'static> {
|
||||
let lines = self.center_help_lines(area.width);
|
||||
let mut state = self.state();
|
||||
state.scroll_area = area;
|
||||
state.scroll_limit = lines.len().saturating_sub(usize::from(area.height));
|
||||
let top = top.min(state.scroll_limit);
|
||||
state.help_top = Some(top);
|
||||
Paragraph::new(lines).scroll((top as u16, 0))
|
||||
}
|
||||
}
|
||||
|
||||
impl Renderable for AgentsOverviewView {
|
||||
@@ -133,10 +145,21 @@ impl Renderable for AgentsOverviewView {
|
||||
let layout = self.center_layout(area);
|
||||
let inset =
|
||||
|area: Rect| area.inner(Margin::new(/*horizontal*/ 2, /*vertical*/ 0));
|
||||
let help_top = {
|
||||
let mut state = self.state();
|
||||
state.list_area = layout.list;
|
||||
state.help_area = layout.body;
|
||||
state.help_top
|
||||
};
|
||||
let help = help_top.is_some();
|
||||
if let Some(top) = help_top {
|
||||
self.layout_center_help(layout.body, top)
|
||||
.render(layout.body, buf);
|
||||
}
|
||||
let footer_hints = self.center_footer_hints();
|
||||
let mut state = self.state();
|
||||
state.row_hits.clear();
|
||||
let header_active = self.hint_focus.is_active() && !state.help;
|
||||
let header_active = self.hint_focus.is_active() && !help;
|
||||
let filter_keys = if header_active && !state.editing_metadata() {
|
||||
self.center_filter_hint()
|
||||
} else {
|
||||
@@ -186,7 +209,6 @@ impl Renderable for AgentsOverviewView {
|
||||
inset(layout.header),
|
||||
buf,
|
||||
);
|
||||
let history = state.history.as_ref();
|
||||
let labels = TASK_FILTERS
|
||||
.iter()
|
||||
.map(|(label, group)| {
|
||||
@@ -209,14 +231,17 @@ impl Renderable for AgentsOverviewView {
|
||||
);
|
||||
tabs.width = tabs.width.saturating_sub(hint_width + 2);
|
||||
}
|
||||
let targets = render_filled_tab_bar(
|
||||
state.filter_hits = render_filled_tab_bar(
|
||||
&labels.iter().map(String::as_str).collect::<Vec<_>>(),
|
||||
state.status_filter,
|
||||
tabs,
|
||||
buf,
|
||||
);
|
||||
if self.dock_focused == Some(false)
|
||||
&& let Some((_, tab)) = targets.iter().find(|(id, _)| *id == state.status_filter)
|
||||
&& let Some((_, tab)) = state
|
||||
.filter_hits
|
||||
.iter()
|
||||
.find(|(id, _)| *id == state.status_filter)
|
||||
{
|
||||
buf.set_style(*tab, crate::style::quiet_workspace_style());
|
||||
}
|
||||
@@ -249,6 +274,7 @@ impl Renderable for AgentsOverviewView {
|
||||
);
|
||||
}
|
||||
}
|
||||
let history = state.history.as_ref();
|
||||
let notice = state
|
||||
.connection_notice
|
||||
.map(str::to_owned)
|
||||
@@ -273,7 +299,7 @@ impl Renderable for AgentsOverviewView {
|
||||
})
|
||||
.or_else(|| state.server_version_notice.clone());
|
||||
let footer = inset(layout.footer);
|
||||
let progress = if state.help || state.connection_notice.is_some() || footer.is_empty() {
|
||||
let progress = if help || state.connection_notice.is_some() || footer.is_empty() {
|
||||
None
|
||||
} else if let Some(opening) = state.opening_task {
|
||||
Some(("Opening task…", opening.started_at))
|
||||
@@ -305,7 +331,7 @@ impl Renderable for AgentsOverviewView {
|
||||
footer,
|
||||
buf,
|
||||
);
|
||||
} else if let Some(notice) = notice.filter(|_| !state.help) {
|
||||
} else if let Some(notice) = notice.filter(|_| !help) {
|
||||
line(notice.dim(), footer, buf);
|
||||
} else {
|
||||
let hints = footer_hints
|
||||
@@ -314,22 +340,8 @@ impl Renderable for AgentsOverviewView {
|
||||
let row = self.hint_focus.render_row(hints, footer.width);
|
||||
line(row.line, footer, buf);
|
||||
}
|
||||
let help = state.help;
|
||||
drop(state);
|
||||
if help {
|
||||
let body = row(
|
||||
area,
|
||||
layout.header.height,
|
||||
layout.footer.y - layout.header.bottom(),
|
||||
);
|
||||
Clear.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() {
|
||||
|
||||
@@ -35,16 +35,17 @@ fn columns(area: Rect, widths: Option<(u16, u16)>) -> (Rect, Rect, Rect) {
|
||||
(title, status, updated)
|
||||
}
|
||||
|
||||
pub(super) struct TaskListLayout {
|
||||
area: Rect,
|
||||
padding: u16,
|
||||
heading: &'static str,
|
||||
indices: Vec<usize>,
|
||||
}
|
||||
|
||||
impl AgentsOverviewView {
|
||||
pub(super) fn render_center_rows(
|
||||
&self,
|
||||
area: Rect,
|
||||
buf: &mut Buffer,
|
||||
progress_in_footer: bool,
|
||||
) {
|
||||
let row_width = area.width;
|
||||
pub(super) fn layout_task_viewport(&self, area: Rect) -> TaskListLayout {
|
||||
let area = Rect {
|
||||
width: row_width.saturating_sub(/*rhs*/ 1),
|
||||
width: area.width.saturating_sub(/*rhs*/ 1),
|
||||
..area
|
||||
};
|
||||
let indices = self.selectable_indices();
|
||||
@@ -52,8 +53,33 @@ impl AgentsOverviewView {
|
||||
let padding = u16::from(area.height >= 3);
|
||||
state.list_width = area.width;
|
||||
let top_padding = padding;
|
||||
let heading = "Tasks";
|
||||
let viewport = row(area, top_padding, area.height - top_padding - padding);
|
||||
state.page_height = usize::from(viewport.height);
|
||||
state.scroll_area = viewport;
|
||||
state.scroll_limit = 0;
|
||||
TaskListLayout {
|
||||
area,
|
||||
padding,
|
||||
heading,
|
||||
indices,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn render_center_rows(
|
||||
&self,
|
||||
area: Rect,
|
||||
buf: &mut Buffer,
|
||||
progress_in_footer: bool,
|
||||
) {
|
||||
let row_width = area.width;
|
||||
let TaskListLayout {
|
||||
area,
|
||||
padding,
|
||||
heading,
|
||||
indices,
|
||||
} = self.layout_task_viewport(area);
|
||||
let mut state = self.state();
|
||||
let viewport = state.scroll_area;
|
||||
let entries = self.center_rows(&indices, &state);
|
||||
if area.is_empty() {
|
||||
return;
|
||||
@@ -122,7 +148,6 @@ impl AgentsOverviewView {
|
||||
});
|
||||
if padding > 0 && self.dock_focused.is_none() {
|
||||
let (title, status, updated) = columns(row(area, /*offset*/ 0, /*height*/ 1), widths);
|
||||
let heading = "Tasks";
|
||||
line(heading.dim(), title, buf);
|
||||
line("Status".dim(), status, buf);
|
||||
Line::from(sort.label().dim())
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
use super::*;
|
||||
use crate::app::owned_transcript::tests::buffer_text;
|
||||
use assert_matches::assert_matches;
|
||||
use crossterm::event::MouseEvent;
|
||||
use crossterm::event::MouseEventKind::ScrollDown;
|
||||
use crossterm::event::MouseEventKind::ScrollUp;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
const WHEEL_DOWN: MouseEvent = MouseEvent {
|
||||
kind: ScrollDown,
|
||||
column: 6,
|
||||
row: 5,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
};
|
||||
|
||||
fn painted_row(text: &str, label: &str) -> u16 {
|
||||
text.lines()
|
||||
.position(|line| line.contains(label))
|
||||
@@ -593,10 +603,19 @@ async fn live_center_pages_full_task_rows_and_restores_the_first_heading() {
|
||||
let mut view = app.agents_overview_view(threads, Some(ids[0]));
|
||||
let initial = screen(&view, /*width*/ 80, /*height*/ 16);
|
||||
view.handle_key_event(KeyCode::PageDown.into());
|
||||
assert!(screen(&view, /*width*/ 80, /*height*/ 16).contains('↑'));
|
||||
let second_page = screen(&view, /*width*/ 80, /*height*/ 16);
|
||||
assert!(second_page.contains('↑'));
|
||||
view.handle_key_event(KeyCode::PageUp.into());
|
||||
assert_eq!(selected(&view), ids[0]);
|
||||
assert_eq!(screen(&view, /*width*/ 80, /*height*/ 16), initial);
|
||||
|
||||
// Resize in help, then page tasks before they have been painted at the new size.
|
||||
screen(&view, /*width*/ 40, /*height*/ 12);
|
||||
view.handle_key_event(KeyCode::Char('?').into());
|
||||
screen(&view, /*width*/ 80, /*height*/ 16);
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
view.handle_key_event(KeyCode::PageDown.into());
|
||||
assert_eq!(screen(&view, /*width*/ 80, /*height*/ 16), second_page);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -811,6 +830,24 @@ async fn live_center_navigation_and_complete_hints() {
|
||||
Some(ready),
|
||||
);
|
||||
let selected = |view: &AgentsOverviewView| view.rows[view.selected_index().unwrap()].thread_id;
|
||||
// A narrow filter strip can reach the offscreen status using its chevron.
|
||||
let click_filter = |view: &mut AgentsOverviewView, width, label: &str| {
|
||||
let frame = screen(view, width, /*height*/ 12);
|
||||
let row = frame.lines().nth(1).unwrap();
|
||||
let x = row
|
||||
.find(label)
|
||||
.unwrap_or_else(|| panic!("missing {label} in {row}"));
|
||||
view.click_row(ratatui::layout::Position::new(
|
||||
row[..x].chars().count() as u16,
|
||||
/*y*/ 1,
|
||||
));
|
||||
};
|
||||
click_filter(&mut view, /*width*/ 23, "›");
|
||||
assert_eq!(selected(&view), needs_you);
|
||||
click_filter(&mut view, /*width*/ 23, "‹");
|
||||
click_filter(&mut view, /*width*/ 100, "Inactive");
|
||||
assert_eq!(selected(&view), unloaded);
|
||||
click_filter(&mut view, /*width*/ 100, "All");
|
||||
view.handle_key_event(KeyCode::Tab.into());
|
||||
assert_eq!(selected(&view), needs_you);
|
||||
view.handle_key_event(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT));
|
||||
@@ -824,7 +861,11 @@ async fn live_center_navigation_and_complete_hints() {
|
||||
|
||||
let repeat_help =
|
||||
KeyEvent::new_with_kind(KeyCode::Char('?'), KeyModifiers::NONE, KeyEventKind::Repeat);
|
||||
screen(&view, /*width*/ 40, /*height*/ 24);
|
||||
view.handle_key_event(KeyCode::Char('?').into());
|
||||
view.handle_key_event(KeyCode::End.into());
|
||||
let first_open_end = screen(&view, /*width*/ 40, /*height*/ 24);
|
||||
view.handle_key_event(KeyCode::Home.into());
|
||||
view.handle_key_event(repeat_help);
|
||||
for (name, width, height) in [
|
||||
("live_center_help_three_columns", 100, 24),
|
||||
@@ -834,6 +875,21 @@ async fn live_center_navigation_and_complete_hints() {
|
||||
] {
|
||||
insta::assert_snapshot!(name, screen(&view, width, height));
|
||||
}
|
||||
let top = screen(&view, /*width*/ 40, /*height*/ 24);
|
||||
assert!(view.scroll_mouse(WHEEL_DOWN));
|
||||
assert_ne!(screen(&view, /*width*/ 40, /*height*/ 24), top);
|
||||
view.handle_key_event(KeyCode::PageDown.into());
|
||||
let bottom = screen(&view, /*width*/ 40, /*height*/ 24);
|
||||
assert!(bottom.contains("/ Search") && bottom.contains("g Group"));
|
||||
assert_eq!(first_open_end, bottom);
|
||||
assert!(!view.scroll_mouse(WHEEL_DOWN));
|
||||
assert!(view.scroll_mouse(MouseEvent {
|
||||
kind: ScrollUp,
|
||||
..WHEEL_DOWN
|
||||
}));
|
||||
assert_ne!(screen(&view, /*width*/ 40, /*height*/ 24), bottom);
|
||||
screen(&view, /*width*/ 100, /*height*/ 24);
|
||||
assert_eq!(screen(&view, /*width*/ 40, /*height*/ 24), top);
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
view.handle_key_event(repeat_help);
|
||||
assert!(screen(&view, /*width*/ 40, /*height*/ 24).contains("Tasks"));
|
||||
|
||||
@@ -176,13 +176,19 @@ pub(super) struct OpeningTask {
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct AgentsOverviewViewState {
|
||||
filter_hits: Vec<(usize, Rect)>,
|
||||
workspace_groups: WorkspaceGroups,
|
||||
row_hits: Vec<(RowTarget, Rect)>,
|
||||
// The two layout regions from the last frame. A key can switch views
|
||||
// and another can page the destination before the next frame.
|
||||
list_area: Rect,
|
||||
help_area: Rect,
|
||||
scroll: usize,
|
||||
page_height: usize,
|
||||
scroll_area: Rect,
|
||||
scroll_limit: usize,
|
||||
list_width: u16,
|
||||
status_filter: usize,
|
||||
help: bool,
|
||||
help_top: Option<usize>,
|
||||
pub(super) input: TextArea,
|
||||
pub(super) vim_enabled: bool,
|
||||
pub(super) creating_worktree: bool,
|
||||
@@ -365,7 +371,10 @@ impl AgentsOverviewView {
|
||||
|
||||
pub(super) fn owns_nested_input(&self) -> bool {
|
||||
let state = self.state();
|
||||
state.editing_metadata() || state.help || state.removal.is_some() || state.creating_worktree
|
||||
state.editing_metadata()
|
||||
|| state.help_top.is_some()
|
||||
|| state.removal.is_some()
|
||||
|| state.creating_worktree
|
||||
}
|
||||
|
||||
/// Follow a newly displayed task once its row arrives. Ordinary refreshes keep the browse position.
|
||||
|
||||
@@ -283,6 +283,15 @@ impl App {
|
||||
{
|
||||
view.click_row(point);
|
||||
}
|
||||
}
|
||||
if pressed
|
||||
|| self
|
||||
.agents_overview
|
||||
.workspace
|
||||
.view
|
||||
.as_ref()
|
||||
.is_some_and(|view| view.scroll_mouse(mouse))
|
||||
{
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ expression: "screen(&view, 100, 24)"
|
||||
|
||||
Navigate Tasks View
|
||||
k Up n New tab/⇧tab Filter
|
||||
j Down w New worktree f3 Search
|
||||
j Down w New worktree / Search
|
||||
enter Open o Resume g Group
|
||||
pgdn Page down f Fork
|
||||
⇧j Next group z r Rename
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ expression: "screen(&view, width, height)"
|
||||
|
||||
View
|
||||
tab/⇧tab Filter
|
||||
f3 Search
|
||||
/ Search
|
||||
g Group
|
||||
|
||||
esc back
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ expression: "screen(&view, width, height)"
|
||||
|
||||
Navigate Tasks View
|
||||
↑ Up n New tab/⇧tab Filter
|
||||
↓ Down w New worktree f3 Search
|
||||
↓ Down w New worktree / Search
|
||||
enter Open o Resume g Group
|
||||
pgup Page up f Fork
|
||||
pgdn Page down r Rename
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ expression: "screen(&view, width, height)"
|
||||
|
||||
View
|
||||
tab/⇧tab Filter
|
||||
f3 Search
|
||||
/ Search
|
||||
g Group
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -24,5 +24,5 @@ expression: "screen(&view, width, height)"
|
||||
f Fork
|
||||
r Rename
|
||||
x Stop
|
||||
… resize to see all
|
||||
esc back
|
||||
a Archive
|
||||
esc back · ↑/↓ scroll
|
||||
|
||||
@@ -227,6 +227,8 @@ pub(crate) use picker_option::picker_option_row;
|
||||
pub(crate) mod popup_consts;
|
||||
mod scroll_state;
|
||||
pub(crate) use scroll_state::ScrollState;
|
||||
pub(crate) use scroll_state::scroll_offset;
|
||||
pub(crate) use scroll_state::wheel_rows_in;
|
||||
mod selection_popup_common;
|
||||
pub(crate) use selection_popup_common::RenderedRows;
|
||||
pub(crate) use selection_popup_common::menu_surface_padding_height;
|
||||
|
||||
@@ -5,7 +5,7 @@ use ratatui::layout::Position;
|
||||
use ratatui::layout::Rect;
|
||||
|
||||
/// An unmodified wheel tick moves three rows within the painted region.
|
||||
pub(super) fn wheel_rows_in(event: MouseEvent, area: Rect) -> Option<i16> {
|
||||
pub(crate) fn wheel_rows_in(event: MouseEvent, area: Rect) -> Option<i16> {
|
||||
if !event.modifiers.is_empty() || !area.contains(Position::new(event.column, event.row)) {
|
||||
return None;
|
||||
}
|
||||
@@ -16,6 +16,22 @@ pub(super) fn wheel_rows_in(event: MouseEvent, area: Rect) -> Option<i16> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigate a text viewport with the configured list keys, stopping at either end.
|
||||
pub(crate) fn scroll_offset(top: usize, limit: usize, height: usize, action: ListAction) -> usize {
|
||||
let top = top.min(limit);
|
||||
match action {
|
||||
ListAction::MoveUp => top.saturating_sub(1),
|
||||
ListAction::MoveDown => (top + 1).min(limit),
|
||||
ListAction::PageUp => top.saturating_sub(height),
|
||||
ListAction::PageDown => (top + height).min(limit),
|
||||
ListAction::JumpTop => 0,
|
||||
ListAction::JumpBottom => limit,
|
||||
ListAction::MoveLeft | ListAction::MoveRight | ListAction::Accept | ListAction::Cancel => {
|
||||
top
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generic scroll/selection state for a vertical list menu.
|
||||
///
|
||||
/// Encapsulates the common behavior of a selectable list that supports:
|
||||
|
||||
@@ -38,7 +38,7 @@ pub(super) fn render_tab_bar(
|
||||
render_filled_tab_bar(&labels, active_idx, area, buf);
|
||||
}
|
||||
|
||||
/// Render a fixed-height tab strip and return the visible tab hit targets.
|
||||
/// Render a tab strip and map its labels and overflow arrows to destination indices.
|
||||
pub(crate) fn render_filled_tab_bar(
|
||||
labels: &[&str],
|
||||
active_idx: usize,
|
||||
@@ -71,14 +71,14 @@ pub(crate) fn render_filled_tab_bar(
|
||||
let show_left = start > 0 && area.width >= 5;
|
||||
let show_right = end < labels.len() && area.width >= 7;
|
||||
let mut x = area.x;
|
||||
let mut regions = Vec::new();
|
||||
if show_left {
|
||||
Line::from("‹")
|
||||
.dim()
|
||||
.render(Rect::new(x, area.y, /*width*/ 1, /*height*/ 1), buf);
|
||||
let tab = Rect::new(x, area.y, /*width*/ 1, /*height*/ 1);
|
||||
Line::from("‹").dim().render(tab, buf);
|
||||
regions.push((start - 1, tab));
|
||||
x += 2;
|
||||
}
|
||||
let right = area.right().saturating_sub(u16::from(show_right) * 2);
|
||||
let mut regions = Vec::new();
|
||||
for idx in start..end {
|
||||
let width = widths[idx].min(usize::from(right.saturating_sub(x))) as u16;
|
||||
let line = Line::from(format!(" {} ", labels[idx]));
|
||||
@@ -94,15 +94,14 @@ pub(crate) fn render_filled_tab_bar(
|
||||
x = x.saturating_add(width).saturating_add(/*rhs*/ 1);
|
||||
}
|
||||
if show_right {
|
||||
Line::from("›").dim().render(
|
||||
Rect::new(
|
||||
area.right() - 1,
|
||||
area.y,
|
||||
/*width*/ 1,
|
||||
/*height*/ 1,
|
||||
),
|
||||
buf,
|
||||
let tab = Rect::new(
|
||||
area.right() - 1,
|
||||
area.y,
|
||||
/*width*/ 1,
|
||||
/*height*/ 1,
|
||||
);
|
||||
Line::from("›").dim().render(tab, buf);
|
||||
regions.push((end, tab));
|
||||
}
|
||||
regions
|
||||
}
|
||||
|
||||
@@ -2206,7 +2206,7 @@ impl RuntimeKeymap {
|
||||
next_group: default_bindings![shift(KeyCode::Down), shift(KeyCode::Char('j'))],
|
||||
previous_group: default_bindings![shift(KeyCode::Up), shift(KeyCode::Char('k'))],
|
||||
resume: default_bindings![plain(KeyCode::Char('o'))],
|
||||
search: default_bindings![plain(KeyCode::F(3)), plain(KeyCode::Char('/'))],
|
||||
search: default_bindings![plain(KeyCode::Char('/')), plain(KeyCode::F(3))],
|
||||
new_task: default_bindings![plain(KeyCode::Char('n'))],
|
||||
new_worktree: default_bindings![plain(KeyCode::Char('w'))],
|
||||
fork: default_bindings![plain(KeyCode::Char('f'))],
|
||||
|
||||
@@ -594,16 +594,7 @@ pub(crate) fn file_path_key_available(keymap: &RuntimeKeymap) -> bool {
|
||||
pub(crate) fn scroll_file_path(body: Rect, path: &str, top: usize, action: ListAction) -> usize {
|
||||
let (path_rows, height) = file_path_layout(body, path);
|
||||
let limit = path_rows.len().saturating_sub(height);
|
||||
let top = top.min(limit);
|
||||
match action {
|
||||
ListAction::MoveUp => top.saturating_sub(1),
|
||||
ListAction::MoveDown => (top + 1).min(limit),
|
||||
ListAction::PageUp => top.saturating_sub(height),
|
||||
ListAction::PageDown => (top + height).min(limit),
|
||||
ListAction::JumpTop => 0,
|
||||
ListAction::JumpBottom => limit,
|
||||
_ => top,
|
||||
}
|
||||
crate::bottom_pane::scroll_offset(top, limit, height, action)
|
||||
}
|
||||
|
||||
pub(crate) fn file_path_areas(area: Rect) -> [Rect; 2] {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ expression: agents
|
||||
Next Group | shift-down, shift-j | Agents next_group Next Group Select the first task in the next group. shift-down, shift-j Default
|
||||
Previous Group | shift-up, shift-k | Agents previous_group Previous Group Select the first task in the previous group. shift-up, shift-k Default
|
||||
Resume | o | Agents resume Resume Open the session resume picker. o Default
|
||||
Search | f3, / | Agents search Search Search the available agent tasks. f3, / Default
|
||||
Search | /, f3 | Agents search Search Search the available agent tasks. /, f3 Default
|
||||
New Task | n | Agents new_task New Task Open a new session in the selected checkout. n Default
|
||||
New Worktree | w | Agents new_worktree New Worktree Open a new session in a worktree from the project default branch. w Default
|
||||
Fork | f | Agents fork Fork Fork the selected conversation and open the new session. f Default
|
||||
|
||||
Reference in New Issue
Block a user