mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Make Command Center easier to navigate in the TUI workspace (#62990)
## Why The docked Command Center has a fixed width, and mouse clicks can focus the pane but cannot open a task. Moving between the task list and the conversation should work with the workspace shortcuts. ## What changed - Open or focus Command Center with `leader a` by default. Use the workspace pane shortcuts to move between Command Center and the conversation, with matching Agents bindings taking precedence in Command Center. - Drag the divider to resize Command Center. Show each docked task's status and Git branch, when available, on a second line. Click either line to open the task, or click **Show more** to load older tasks. - Animate the dock opening and closing. ## Testing Extend the TUI tests to cover mouse activation and workspace keyboard navigation, including preservation of the conversation draft and reading position. GitOrigin-RevId: e78aa4afb68e9971de51859221ce996b13750e13
This commit is contained in:
@@ -1006,7 +1006,7 @@ impl App {
|
||||
if self.workspace_center_owns_input() {
|
||||
match &event {
|
||||
TuiEvent::Key(key) => {
|
||||
self.handle_workspace_key(tui, *key);
|
||||
Box::pin(self.handle_workspace_key(tui, app_server, *key)).await;
|
||||
if !self.agents_overview.workspace.is_open() {
|
||||
self.cancel_cloud_inventory_refresh(app_server).await;
|
||||
if self.reconnect.presentation == reconnect::ReconnectPresentation::Overview
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
//! Navigation clamps at either end of the visible list.
|
||||
|
||||
use super::*;
|
||||
use ratatui::layout::Position;
|
||||
|
||||
pub(super) enum CenterRow {
|
||||
pub(super) enum TaskListRow {
|
||||
Group(usize),
|
||||
Task(usize),
|
||||
Context(usize),
|
||||
Gap,
|
||||
ShowMore,
|
||||
}
|
||||
@@ -15,27 +17,40 @@ pub(in crate::app::agents_overview_view) enum SectionDirection {
|
||||
Previous,
|
||||
}
|
||||
|
||||
impl TaskListRow {
|
||||
pub(super) fn selection_index(&self) -> Option<usize> {
|
||||
match self {
|
||||
Self::Task(index) => Some(*index),
|
||||
Self::ShowMore => Some(usize::MAX),
|
||||
Self::Group(_) | Self::Context(_) | Self::Gap => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AgentsOverviewView {
|
||||
pub(super) fn center_rows(
|
||||
&self,
|
||||
indices: &[usize],
|
||||
grouping: AgentsOverviewGrouping,
|
||||
) -> Vec<CenterRow> {
|
||||
) -> Vec<TaskListRow> {
|
||||
let mut entries = Vec::new();
|
||||
let mut previous = None;
|
||||
for index in indices.iter().copied() {
|
||||
if index == usize::MAX {
|
||||
entries.push(CenterRow::Gap);
|
||||
entries.push(CenterRow::ShowMore);
|
||||
entries.push(TaskListRow::Gap);
|
||||
entries.push(TaskListRow::ShowMore);
|
||||
continue;
|
||||
}
|
||||
if previous.is_none_or(|previous| !self.same_group(grouping, previous, index)) {
|
||||
if previous.is_some() {
|
||||
entries.push(CenterRow::Gap);
|
||||
entries.push(TaskListRow::Gap);
|
||||
}
|
||||
entries.push(CenterRow::Group(index));
|
||||
entries.push(TaskListRow::Group(index));
|
||||
}
|
||||
entries.push(TaskListRow::Task(index));
|
||||
if self.dock_focused.is_some() {
|
||||
entries.push(TaskListRow::Context(index));
|
||||
}
|
||||
entries.push(CenterRow::Task(index));
|
||||
previous = Some(index);
|
||||
}
|
||||
entries
|
||||
@@ -54,14 +69,17 @@ impl AgentsOverviewView {
|
||||
let mut current = None;
|
||||
for row in entries {
|
||||
match row {
|
||||
CenterRow::Group(index) => sections.push(index),
|
||||
CenterRow::Task(index) if index == self.selected => {
|
||||
TaskListRow::Group(index) => sections.push(index),
|
||||
TaskListRow::Task(index) if index == self.selected => {
|
||||
current = sections.len().checked_sub(1)
|
||||
}
|
||||
CenterRow::ShowMore if self.selected == usize::MAX => {
|
||||
TaskListRow::ShowMore if self.selected == usize::MAX => {
|
||||
current = Some(sections.len())
|
||||
}
|
||||
CenterRow::Task(_) | CenterRow::Gap | CenterRow::ShowMore => {}
|
||||
TaskListRow::Task(_)
|
||||
| TaskListRow::Context(_)
|
||||
| TaskListRow::Gap
|
||||
| TaskListRow::ShowMore => {}
|
||||
}
|
||||
}
|
||||
let target = current.and_then(|current| match direction {
|
||||
@@ -74,6 +92,37 @@ impl AgentsOverviewView {
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::app) fn click_row(&mut self, point: Position) {
|
||||
let state = self.state();
|
||||
if state.rename_target.is_some()
|
||||
|| state.help
|
||||
|| state.removal.is_some()
|
||||
|| state.creating_worktree
|
||||
{
|
||||
return;
|
||||
}
|
||||
let target = state
|
||||
.row_hits
|
||||
.iter()
|
||||
.find_map(|(target, rect)| rect.contains(point).then_some(*target));
|
||||
drop(state);
|
||||
let index = match target {
|
||||
Some(RowTarget::Thread(id)) => self
|
||||
.visible_indices()
|
||||
.into_iter()
|
||||
.find(|&index| self.rows[index].thread_id == id),
|
||||
Some(RowTarget::ShowMore) => self.state().more_available().then_some(usize::MAX),
|
||||
None => None,
|
||||
};
|
||||
if let Some(index) = index {
|
||||
self.selected = index;
|
||||
self.state().show_more_selected = index == usize::MAX;
|
||||
if self.state().connection_notice.is_none() {
|
||||
self.activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::app::agents_overview_view) fn page_selection(&mut self, action: ListAction) {
|
||||
let indices = self.selectable_indices();
|
||||
let mut state = self.state();
|
||||
@@ -85,15 +134,7 @@ impl AgentsOverviewView {
|
||||
let tasks = entries
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(position, row)| {
|
||||
if let CenterRow::Task(index) = row {
|
||||
Some((position, *index))
|
||||
} else if matches!(row, CenterRow::ShowMore) {
|
||||
Some((position, usize::MAX))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.filter_map(|(position, row)| Some((position, row.selection_index()?)))
|
||||
.collect::<Vec<_>>();
|
||||
let current = tasks
|
||||
.iter()
|
||||
|
||||
@@ -129,7 +129,8 @@ impl Renderable for AgentsOverviewView {
|
||||
let inset =
|
||||
|area: Rect| area.inner(Margin::new(/*horizontal*/ 2, /*vertical*/ 0));
|
||||
let footer_hints = self.center_footer_hints();
|
||||
let state = self.state();
|
||||
let mut state = self.state();
|
||||
state.row_hits.clear();
|
||||
let filter_keys = if state.editing_metadata() {
|
||||
String::new()
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! Full titles use the flexible column; metadata drops at narrow widths.
|
||||
//! The final cell stays blank inside the full-width selection highlight.
|
||||
|
||||
use super::navigation::CenterRow;
|
||||
use super::navigation::TaskListRow;
|
||||
use super::render::line;
|
||||
use super::render::row;
|
||||
use super::*;
|
||||
@@ -75,15 +75,11 @@ impl AgentsOverviewView {
|
||||
let entries = self.center_rows(&indices, state.grouping);
|
||||
let selected = entries
|
||||
.iter()
|
||||
.position(|row| match row {
|
||||
CenterRow::Task(index) => *index == self.selected,
|
||||
CenterRow::ShowMore => self.selected == usize::MAX,
|
||||
_ => false,
|
||||
})
|
||||
.position(|row| row.selection_index() == Some(self.selected))
|
||||
.unwrap_or_default();
|
||||
let padding = u16::from(area.height >= 3);
|
||||
let viewport = row(area, padding, area.height - padding * 2);
|
||||
if padding > 0 {
|
||||
if padding > 0 && self.dock_focused.is_none() {
|
||||
let (title, status, updated) = columns(row(area, /*offset*/ 0, /*height*/ 1));
|
||||
line("Tasks".dim(), title, buf);
|
||||
line("Status".dim(), status, buf);
|
||||
@@ -98,36 +94,65 @@ impl AgentsOverviewView {
|
||||
if selected < start {
|
||||
start = if height > 1
|
||||
&& selected > 0
|
||||
&& matches!(entries[selected - 1], CenterRow::Group(_))
|
||||
&& matches!(entries[selected - 1], TaskListRow::Group(_))
|
||||
{
|
||||
selected - 1
|
||||
} else {
|
||||
selected
|
||||
};
|
||||
}
|
||||
if selected >= start + height {
|
||||
start = selected.saturating_add(/*rhs*/ 1).saturating_sub(height);
|
||||
let last_selected_row =
|
||||
if height > 1 && matches!(entries.get(selected + 1), Some(TaskListRow::Context(_))) {
|
||||
selected + 1
|
||||
} else {
|
||||
selected
|
||||
};
|
||||
if last_selected_row >= start + height {
|
||||
start = last_selected_row.saturating_add(1).saturating_sub(height);
|
||||
}
|
||||
state.scroll = start;
|
||||
for (offset, entry) in entries.iter().skip(start).take(height).enumerate() {
|
||||
let rect = row(viewport, offset as u16, /*height*/ 1);
|
||||
let background = Rect {
|
||||
width: row_width,
|
||||
..rect
|
||||
};
|
||||
let index = match entry {
|
||||
CenterRow::Group(index) | CenterRow::Task(index) => *index,
|
||||
CenterRow::Gap => continue,
|
||||
CenterRow::ShowMore => {
|
||||
let rect = row(viewport, offset as u16, /*height*/ 1);
|
||||
TaskListRow::Group(index) | TaskListRow::Task(index) => *index,
|
||||
TaskListRow::Context(index) => {
|
||||
let task = &self.rows[*index];
|
||||
state
|
||||
.row_hits
|
||||
.push((RowTarget::Thread(task.thread_id), background));
|
||||
let style = if *index == self.selected {
|
||||
selected_style
|
||||
} else {
|
||||
Style::default().dim()
|
||||
};
|
||||
buf.set_style(background, style);
|
||||
let (status, _) = Self::status(task);
|
||||
let branch = task
|
||||
.thread
|
||||
.git_info
|
||||
.as_ref()
|
||||
.and_then(|git| git.branch.as_deref());
|
||||
let detail = match branch {
|
||||
Some(branch) => format!(" {status} · {branch}"),
|
||||
None => format!(" {status}"),
|
||||
};
|
||||
line(Line::from(detail).style(style), rect, buf);
|
||||
continue;
|
||||
}
|
||||
TaskListRow::Gap => continue,
|
||||
TaskListRow::ShowMore => {
|
||||
state.row_hits.push((RowTarget::ShowMore, background));
|
||||
let selected = self.selected == usize::MAX;
|
||||
let style = if selected {
|
||||
selected_style
|
||||
} else {
|
||||
Style::default()
|
||||
};
|
||||
buf.set_style(
|
||||
Rect {
|
||||
width: row_width,
|
||||
..rect
|
||||
},
|
||||
style,
|
||||
);
|
||||
buf.set_style(background, style);
|
||||
let label = if let Some(search) = &state.history {
|
||||
if search.loading {
|
||||
"Searching history…"
|
||||
@@ -153,8 +178,7 @@ impl AgentsOverviewView {
|
||||
}
|
||||
};
|
||||
let task = &self.rows[index];
|
||||
let rect = row(viewport, offset as u16, /*height*/ 1);
|
||||
if matches!(entry, CenterRow::Group(_)) {
|
||||
if matches!(entry, TaskListRow::Group(_)) {
|
||||
let group = match state.grouping {
|
||||
AgentsOverviewGrouping::Status => task.group.label().to_owned(),
|
||||
_ if self.is_pinned(index) => "Pinned".to_owned(),
|
||||
@@ -200,18 +224,15 @@ impl AgentsOverviewView {
|
||||
line(format!("{group} {count}").dim(), rect, buf);
|
||||
continue;
|
||||
}
|
||||
state
|
||||
.row_hits
|
||||
.push((RowTarget::Thread(task.thread_id), background));
|
||||
let style = if index == self.selected {
|
||||
selected_style
|
||||
} else {
|
||||
Style::default()
|
||||
};
|
||||
buf.set_style(
|
||||
Rect {
|
||||
width: row_width,
|
||||
..rect
|
||||
},
|
||||
style,
|
||||
);
|
||||
buf.set_style(background, style);
|
||||
let (status, mut dot) = Self::status(task);
|
||||
let idle = matches!(
|
||||
task.group,
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
//! Dashboard rows, paging, metadata clipping and status-filter regressions.
|
||||
|
||||
use super::*;
|
||||
use crate::app::owned_transcript::tests::buffer_text;
|
||||
use assert_matches::assert_matches;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
fn painted_row(text: &str, label: &str) -> u16 {
|
||||
text.lines()
|
||||
.position(|line| line.contains(label))
|
||||
.unwrap_or_else(|| panic!("missing {label:?} in rendered screen:\n{text}")) as u16
|
||||
}
|
||||
|
||||
pub(super) fn screen(view: &AgentsOverviewView, width: u16, height: u16) -> String {
|
||||
let area = Rect::new(/*x*/ 0, /*y*/ 0, width, height);
|
||||
let mut buf = ratatui::buffer::Buffer::empty(area);
|
||||
@@ -149,7 +156,8 @@ async fn failed_background_worker_only_needs_attention_for_a_pending_request() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn live_center_sorts_arrivals_and_status_transitions_by_update_time() {
|
||||
let app = make_test_app().await;
|
||||
let (app, mut events, _ops) = make_test_app_with_channels().await;
|
||||
app.agents_overview.view_state.lock().unwrap().grouping = AgentsOverviewGrouping::Status;
|
||||
let [alpha, bravo, charlie, delta, child] = [1, 2, 3, 4, 5].map(ThreadId::from_u128);
|
||||
let working = ThreadStatus::Active {
|
||||
active_flags: vec![],
|
||||
@@ -196,31 +204,79 @@ async fn live_center_sorts_arrivals_and_status_transitions_by_update_time() {
|
||||
vec![delta, alpha, bravo, charlie]
|
||||
);
|
||||
threads[1].status = ThreadStatus::Idle;
|
||||
let view = app.agents_overview_view(threads.clone(), Some(bravo));
|
||||
let mut view = app.agents_overview_view(threads.clone(), Some(bravo));
|
||||
view.dock_focused = Some(true);
|
||||
assert_eq!(view.thread_ids(), vec![delta, alpha, bravo, charlie]);
|
||||
let selected = &view.rows[view.selected_index().unwrap()];
|
||||
assert_eq!(selected.group, AgentsOverviewGroup::Ready);
|
||||
assert!(selected.details.lines.is_empty());
|
||||
// Capture the actual compact rows before the refresh moves Alpha to a different index.
|
||||
let area = Rect::new(
|
||||
/*x*/ 17, /*y*/ 8, /*width*/ 48, /*height*/ 28,
|
||||
);
|
||||
let mut buf = ratatui::buffer::Buffer::empty(area);
|
||||
view.render(area, &mut buf);
|
||||
let text = buffer_text(&buf);
|
||||
let alpha_y = painted_row(&text, "Alpha");
|
||||
assert_eq!(
|
||||
text.lines().nth(usize::from(alpha_y) + 1).unwrap().trim(),
|
||||
"Working"
|
||||
);
|
||||
let point = |y| (area.right() - 3, area.y + y).into();
|
||||
|
||||
// A request from a descendant can still bring its idle parent to the top.
|
||||
threads.last_mut().unwrap().status = ThreadStatus::Active {
|
||||
active_flags: vec![ThreadActiveFlag::WaitingOnApproval],
|
||||
};
|
||||
assert_eq!(
|
||||
app.agents_overview_view(threads.clone(), Some(bravo))
|
||||
.thread_ids(),
|
||||
vec![bravo, delta, alpha, charlie]
|
||||
let mut view = app.agents_overview_view(threads.clone(), Some(bravo));
|
||||
assert_eq!(view.thread_ids(), vec![bravo, delta, alpha, charlie]);
|
||||
// A heading and a blank row in the list don't select or activate a task.
|
||||
let heading = painted_row(&text, "Working ");
|
||||
let blank = area.height - 3;
|
||||
assert!(
|
||||
text.lines()
|
||||
.nth(usize::from(blank))
|
||||
.unwrap()
|
||||
.trim()
|
||||
.is_empty()
|
||||
);
|
||||
for y in [heading, blank] {
|
||||
view.click_row(point(y));
|
||||
}
|
||||
assert_eq!(view.rows[view.selected_index().unwrap()].thread_id, bravo);
|
||||
assert!(events.try_recv().is_err());
|
||||
|
||||
view.handle_key_event(KeyCode::Char('?').into());
|
||||
view.click_row(point(alpha_y));
|
||||
assert_eq!(view.rows[view.selected_index().unwrap()].thread_id, bravo);
|
||||
assert!(events.try_recv().is_err());
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
for y in [alpha_y, alpha_y + 1] {
|
||||
view.handle_key_event(KeyCode::Char('/').into());
|
||||
view.handle_paste("Alpha".into());
|
||||
assert_matches!(events.try_recv(), Ok(AppEvent::SearchAgentsOverview(..)));
|
||||
view.click_row(point(y));
|
||||
assert_matches!(
|
||||
events.try_recv(),
|
||||
Ok(AppEvent::SelectAgentsOverviewThread { thread_id }) if thread_id == alpha
|
||||
);
|
||||
}
|
||||
view.handle_key_event(KeyCode::Tab.into()); // Needs you hides Alpha before the next paint.
|
||||
view.click_row(point(alpha_y));
|
||||
assert_eq!(view.rows[view.selected_index().unwrap()].thread_id, bravo);
|
||||
assert!(events.try_recv().is_err());
|
||||
view.handle_key_event(KeyCode::BackTab.into());
|
||||
threads.pop();
|
||||
let view = app.agents_overview_view(threads.clone(), Some(bravo));
|
||||
assert_eq!(view.thread_ids(), vec![delta, alpha, bravo, charlie]);
|
||||
assert_eq!(view.rows[view.selected_index().unwrap()].thread_id, bravo);
|
||||
// Rediscovery restores the task to its position by update time.
|
||||
let removed = threads.remove(/*index*/ 0);
|
||||
assert_eq!(
|
||||
app.agents_overview_view(threads.clone(), Some(bravo))
|
||||
.thread_ids(),
|
||||
vec![delta, bravo, charlie]
|
||||
);
|
||||
let mut view = app.agents_overview_view(threads.clone(), Some(bravo));
|
||||
assert_eq!(view.thread_ids(), vec![delta, bravo, charlie]);
|
||||
view.click_row(point(alpha_y));
|
||||
assert_eq!(view.rows[view.selected_index().unwrap()].thread_id, bravo);
|
||||
assert!(events.try_recv().is_err());
|
||||
threads.push(removed);
|
||||
assert_eq!(
|
||||
app.agents_overview_view(threads, Some(bravo)).thread_ids(),
|
||||
@@ -978,6 +1034,7 @@ async fn live_center_show_more_navigation_search_and_loading() {
|
||||
{
|
||||
let mut state = app.agents_overview.view_state.lock().unwrap();
|
||||
state.loading = false;
|
||||
state.has_more = false;
|
||||
state.refresh_failed = true;
|
||||
}
|
||||
view.handle_key_event(KeyCode::Char('/').into());
|
||||
@@ -996,7 +1053,9 @@ async fn live_center_show_more_navigation_search_and_loading() {
|
||||
"live_center_show_more_search_retry",
|
||||
screen(&view, /*width*/ 80, /*height*/ 12)
|
||||
);
|
||||
view.handle_key_event(KeyCode::Enter.into());
|
||||
let rendered = screen(&view, /*width*/ 80, /*height*/ 12);
|
||||
let retry = painted_row(&rendered, "Show more (retry)");
|
||||
view.click_row(ratatui::layout::Position::new(/*x*/ 6, retry));
|
||||
let id = assert_matches!(rx.try_recv(), Ok(AppEvent::SearchAgentsOverview(id, _)) => id);
|
||||
app.apply_agents_overview_search_page(
|
||||
id,
|
||||
@@ -1020,6 +1079,8 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
let mut tui = crate::tui::test_support::make_test_tui_with_size(wide)?;
|
||||
tui.set_owned_screen(/*owned*/ true)?;
|
||||
app.config.features.enable(Feature::TuiWorkspace)?;
|
||||
app.keymap =
|
||||
RuntimeKeymap::for_session(&app.local_settings.tui.keymap, /*workspace*/ true).unwrap();
|
||||
app.local_settings.transcript_mode = crate::transcript_mode::TranscriptMode::Owned;
|
||||
let id = ThreadId::from_u128(/*value*/ 12);
|
||||
attach_thread(&mut app, id);
|
||||
@@ -1046,7 +1107,7 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
app.transcript_cells
|
||||
.push(Arc::new(history_cell::PlainHistoryCell::new(rows)));
|
||||
let paste = TuiEvent::Paste("Keep this draft".into());
|
||||
app.handle_tui_event(&mut tui, &mut server, paste).await?;
|
||||
crate::boxed_future!(app.handle_tui_event(&mut tui, &mut server, paste)).await?;
|
||||
|
||||
app.render_chat_widget_frame(&mut tui, wide)?;
|
||||
app.transcript_view
|
||||
@@ -1072,7 +1133,12 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
] {
|
||||
tui.terminal.resize(size)?;
|
||||
if center_focused && !app.workspace_center_owns_input() {
|
||||
Box::pin(app.handle_event(&mut tui, &mut server, AppEvent::OpenAgentsOverview)).await?;
|
||||
crate::boxed_future!(app.handle_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
AppEvent::OpenAgentsOverview
|
||||
))
|
||||
.await?;
|
||||
} else if !center_focused && app.workspace_center_owns_input() {
|
||||
let click = crossterm::event::MouseEvent {
|
||||
kind: crossterm::event::MouseEventKind::Down(crossterm::event::MouseButton::Left),
|
||||
@@ -1080,8 +1146,12 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
row: 0,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
};
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Mouse(click))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Mouse(click)
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
if size == wide && !center_focused {
|
||||
title = "Investigate retry again";
|
||||
@@ -1130,23 +1200,35 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
assert_ne!(center[2].fg, conversation[2].fg);
|
||||
assert_ne!(center[2].bg, conversation[2].bg);
|
||||
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(KeyCode::Tab.into()))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(KeyCode::Tab.into())
|
||||
))
|
||||
.await?;
|
||||
app.render_chat_widget_frame(&mut tui, wide)?;
|
||||
assert!(buffer_text(tui.terminal.previous_buffer()).contains("No matching tasks"));
|
||||
insta::assert_snapshot!("workspace_responsive_focus", screens.join("\n\n"));
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Paste("ignored".into()))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Paste("ignored".into())
|
||||
))
|
||||
.await?;
|
||||
for key in [KeyCode::BackTab, KeyCode::Enter] {
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(key.into()))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(key.into())
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
let selected = std::iter::from_fn(|| events.try_recv().ok())
|
||||
.find(|event| {
|
||||
matches!(event, AppEvent::SelectAgentsOverviewThread { thread_id } if *thread_id == id)
|
||||
})
|
||||
.expect("Enter selects the displayed task");
|
||||
Box::pin(app.handle_event(&mut tui, &mut server, selected)).await?;
|
||||
crate::boxed_future!(app.handle_event(&mut tui, &mut server, selected)).await?;
|
||||
let bottom = app.render_chat_widget_frame(&mut tui, wide)?;
|
||||
let screen = buffer_text(tui.terminal.previous_buffer());
|
||||
assert!(screen.contains(title));
|
||||
@@ -1157,7 +1239,8 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
"Keep this draft"
|
||||
);
|
||||
|
||||
Box::pin(app.handle_event(&mut tui, &mut server, AppEvent::OpenAgentsOverview)).await?;
|
||||
crate::boxed_future!(app.handle_event(&mut tui, &mut server, AppEvent::OpenAgentsOverview))
|
||||
.await?;
|
||||
app.sidebar_mut().show(
|
||||
crate::app::sidebar::SidebarContent::Chooser,
|
||||
crate::app::sidebar::PaneFocus::Sidebar,
|
||||
@@ -1191,10 +1274,14 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
use crossterm::event::MouseEventKind::Down;
|
||||
use crossterm::event::MouseEventKind::Drag;
|
||||
tui.screen_size_for_event(&TuiEvent::Resize(three_panes))?;
|
||||
app.handle_tui_event(&mut tui, &mut server, mouse(Down(Left), divider.x))
|
||||
.await?;
|
||||
app.handle_tui_event(&mut tui, &mut server, mouse(Drag(Left), divider.x - 6))
|
||||
crate::boxed_future!(app.handle_tui_event(&mut tui, &mut server, mouse(Down(Left), divider.x)))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
mouse(Drag(Left), divider.x - 6)
|
||||
))
|
||||
.await?;
|
||||
crate::app::test_support::side_frame(&mut app, &mut tui, three_panes)?;
|
||||
let preview = app
|
||||
.conversation_frame
|
||||
@@ -1202,36 +1289,109 @@ async fn workspace_navigation_preserves_the_draft_and_reading_position() -> Resu
|
||||
.expect("right divider");
|
||||
assert_eq!(preview.x, divider.x - 6);
|
||||
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(KeyCode::Enter.into()))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(KeyCode::Enter.into())
|
||||
))
|
||||
.await?;
|
||||
let selected = std::iter::from_fn(|| events.try_recv().ok())
|
||||
.find(|event| {
|
||||
matches!(event, AppEvent::SelectAgentsOverviewThread { thread_id } if *thread_id == id)
|
||||
})
|
||||
.expect("Enter selects the displayed task with the chooser open");
|
||||
Box::pin(app.handle_event(&mut tui, &mut server, selected)).await?;
|
||||
crate::boxed_future!(app.handle_event(&mut tui, &mut server, selected)).await?;
|
||||
assert_eq!(
|
||||
app.panel_focus(),
|
||||
Some(crate::app::sidebar::PaneFocus::Main)
|
||||
);
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Paste("!".into()))
|
||||
crate::boxed_future!(app.handle_tui_event(&mut tui, &mut server, TuiEvent::Paste("!".into())))
|
||||
.await?;
|
||||
assert!(app.chat_widget.composer_text_with_pending().contains('!'));
|
||||
app.handle_tui_event(
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(KeyCode::Backspace.into()),
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
|
||||
app.open_agents_overview(&server);
|
||||
app.sidebar_mut().hide();
|
||||
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(KeyCode::Esc.into()))
|
||||
.await?;
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(KeyCode::Esc.into())
|
||||
))
|
||||
.await?;
|
||||
tui.screen_size_for_event(&TuiEvent::Resize(wide))?;
|
||||
app.render_chat_widget_frame(&mut tui, wide)?;
|
||||
assert_eq!(buffer_text(tui.terminal.previous_buffer()), before);
|
||||
|
||||
app.local_settings.tui.keymap = serde_json::from_value(serde_json::json!({
|
||||
"global":{"leader":"f12","open_agents":"leader a","focus_main_composer":["leader c", "f10"]},
|
||||
"agents":{"toggle_grouping":"f11 g","new_task":"f10"},
|
||||
}))?;
|
||||
app.keymap =
|
||||
RuntimeKeymap::for_session(&app.local_settings.tui.keymap, /*workspace*/ true).unwrap();
|
||||
for key in [KeyCode::F(12), KeyCode::Char('a')] {
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(key.into())
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
assert!(app.workspace_center_owns_input());
|
||||
let repeat =
|
||||
|ch| KeyEvent::new_with_kind(KeyCode::Char(ch), KeyModifiers::NONE, KeyEventKind::Repeat);
|
||||
crate::boxed_future!(app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(repeat('a'))))
|
||||
.await?;
|
||||
assert!(
|
||||
app.agents_overview
|
||||
.view_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.removal
|
||||
.is_none()
|
||||
);
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(KeyCode::F(10).into())
|
||||
))
|
||||
.await?;
|
||||
assert!(app.workspace_center_owns_input());
|
||||
assert!(
|
||||
std::iter::from_fn(|| events.try_recv().ok())
|
||||
.any(|event| matches!(event, AppEvent::NewAgentsOverviewSession { .. }))
|
||||
);
|
||||
for key in [KeyCode::F(11), KeyCode::Char('g')] {
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(key.into())
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
assert_eq!(
|
||||
app.agents_overview.view_state.lock().unwrap().grouping,
|
||||
AgentsOverviewGrouping::Directory,
|
||||
);
|
||||
for key in [KeyCode::F(12), KeyCode::Char('c')] {
|
||||
crate::boxed_future!(app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut server,
|
||||
TuiEvent::Key(key.into())
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
assert!(!app.workspace_center_owns_input());
|
||||
crate::boxed_future!(app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(repeat('c'))))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
app.chat_widget.composer_text_with_pending(),
|
||||
"Keep this draft"
|
||||
);
|
||||
server.shutdown().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2387,7 +2387,8 @@ async fn new_session_selects_its_task_when_the_open_dock_receives_the_row() -> R
|
||||
insta::assert_snapshot!(selected_title, @"› ○ Untitled task");
|
||||
|
||||
app.open_agents_overview(&server);
|
||||
app.handle_workspace_key(&mut tui, KeyCode::Down.into());
|
||||
app.handle_workspace_key(&mut tui, &mut server, KeyCode::Down.into())
|
||||
.await;
|
||||
assert_eq!(app.overview_selected_thread_id(), Some(previous_id));
|
||||
app.focus_workspace_composer(&mut tui);
|
||||
app.repaint_agents_overview();
|
||||
|
||||
@@ -160,8 +160,16 @@ pub(super) fn directory_group_key(cwd: &Path, worktrees_enabled: bool) -> PathBu
|
||||
.unwrap_or_else(|| cwd.to_path_buf())
|
||||
}
|
||||
|
||||
/// The item painted under the pointer, identified across task-list refreshes.
|
||||
#[derive(Clone, Copy)]
|
||||
enum RowTarget {
|
||||
Thread(ThreadId),
|
||||
ShowMore,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct AgentsOverviewViewState {
|
||||
row_hits: Vec<(RowTarget, Rect)>,
|
||||
scroll: usize,
|
||||
page_height: usize,
|
||||
status_filter: usize,
|
||||
|
||||
@@ -4,17 +4,22 @@
|
||||
use super::App;
|
||||
use super::agents_overview_view::AgentsOverviewView;
|
||||
use super::sidebar::PaneFocus;
|
||||
use crate::activation_key_guard::ActivationKeySuppression;
|
||||
use crate::app_event::AppEvent;
|
||||
use crate::app_event::ExitMode;
|
||||
use crate::app_server_session::AppServerSession;
|
||||
use crate::bottom_pane::BottomPaneView;
|
||||
use crate::bottom_pane::CancellationEvent;
|
||||
use crate::key_hint::KeyBinding;
|
||||
use crate::key_hint::KeyBindingListExt;
|
||||
use crate::render::renderable::Renderable;
|
||||
use crate::tui::Tui;
|
||||
use std::time::Instant;
|
||||
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::event::KeyEvent;
|
||||
use crossterm::event::KeyModifiers;
|
||||
use crossterm::event::MouseButton;
|
||||
use crossterm::event::MouseEvent;
|
||||
use crossterm::event::MouseEventKind;
|
||||
use ratatui::layout::Constraint;
|
||||
@@ -40,6 +45,10 @@ pub(super) struct Workspace {
|
||||
pub(super) view: Option<AgentsOverviewView>,
|
||||
/// None while the dock is closed.
|
||||
focus: Option<Pane>,
|
||||
pub(super) motion: super::pane_motion::PaneMotion,
|
||||
pub(super) fraction: Option<f64>,
|
||||
width: Option<u16>,
|
||||
divider_drag_viewport: Option<Rect>,
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
@@ -73,7 +82,13 @@ impl App {
|
||||
}
|
||||
|
||||
pub(super) fn workspace_chat_area(&self, viewport: Rect) -> Rect {
|
||||
if self.agents_overview.workspace.is_open() {
|
||||
if self.agents_overview.workspace.is_open()
|
||||
|| self
|
||||
.agents_overview
|
||||
.workspace
|
||||
.fraction
|
||||
.is_some_and(|fraction| fraction > 0.0)
|
||||
{
|
||||
self.workspace_areas(viewport).1.unwrap_or_default()
|
||||
} else {
|
||||
viewport
|
||||
@@ -83,7 +98,16 @@ impl App {
|
||||
pub(super) fn workspace_areas(&self, viewport: Rect) -> (Option<Rect>, Option<Rect>) {
|
||||
if viewport.width >= MIN_SPLIT_WIDTH {
|
||||
let [center, _, conversation] = Layout::horizontal([
|
||||
Constraint::Length(CENTER_WIDTH),
|
||||
Constraint::Length(
|
||||
(f64::from(
|
||||
self.agents_overview
|
||||
.workspace
|
||||
.width
|
||||
.unwrap_or(CENTER_WIDTH)
|
||||
.min(viewport.width.saturating_sub(MIN_CHAT_WIDTH + GUTTER_WIDTH)),
|
||||
) * self.agents_overview.workspace.fraction.unwrap_or(1.0))
|
||||
.round() as u16,
|
||||
),
|
||||
Constraint::Length(GUTTER_WIDTH),
|
||||
Constraint::Min(MIN_CHAT_WIDTH),
|
||||
])
|
||||
@@ -114,7 +138,12 @@ impl App {
|
||||
self.cancel_pending_key_chord();
|
||||
}
|
||||
|
||||
pub(super) fn handle_workspace_key(&mut self, tui: &mut Tui, mut key: KeyEvent) {
|
||||
pub(super) async fn handle_workspace_key(
|
||||
&mut self,
|
||||
tui: &mut Tui,
|
||||
app_server: &mut AppServerSession,
|
||||
mut key: KeyEvent,
|
||||
) {
|
||||
if self.should_recover_vim_insert_escape(tui, key)
|
||||
&& let Some(view) = &mut self.agents_overview.workspace.view
|
||||
{
|
||||
@@ -127,6 +156,47 @@ impl App {
|
||||
if self.handle_voice_toggle_key(tui, key) {
|
||||
return;
|
||||
}
|
||||
if self
|
||||
.agents_overview
|
||||
.workspace
|
||||
.view
|
||||
.as_ref()
|
||||
.is_some_and(|view| !view.owns_nested_input())
|
||||
&& !self.agents_overview_binding_matches(key)
|
||||
{
|
||||
let bindings = &self.keymap.app;
|
||||
let main = bindings.focus_main_composer.is_pressed(key);
|
||||
if main || bindings.focus_pane_right.is_pressed(key) {
|
||||
if key.kind == crossterm::event::KeyEventKind::Press
|
||||
&& self
|
||||
.agents_overview
|
||||
.workspace
|
||||
.view
|
||||
.as_ref()
|
||||
.is_some_and(|view| view.can_return_to_chat)
|
||||
{
|
||||
let activation = self
|
||||
.routed_key_activation
|
||||
.take()
|
||||
.unwrap_or_else(|| KeyBinding::from_event(key));
|
||||
if main && let Err(err) = self.focus_main_composer(tui, app_server).await {
|
||||
self.chat_widget.add_error_message(err.to_string());
|
||||
return;
|
||||
}
|
||||
self.focus_workspace_composer(tui);
|
||||
self.chat_widget.suppress_current_view_key_until_release(
|
||||
activation,
|
||||
Instant::now(),
|
||||
ActivationKeySuppression::ViewTransition,
|
||||
);
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if bindings.open_agents.is_pressed(key) || bindings.focus_pane_left.is_pressed(key) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let Some(view) = &mut self.agents_overview.workspace.view else {
|
||||
return;
|
||||
};
|
||||
@@ -145,6 +215,7 @@ impl App {
|
||||
}
|
||||
if view.is_complete() {
|
||||
self.agents_overview.workspace.focus = None;
|
||||
self.agents_overview.workspace.divider_drag_viewport = None;
|
||||
self.focus_workspace_composer(tui);
|
||||
self.conversation_frame = Default::default();
|
||||
}
|
||||
@@ -157,10 +228,39 @@ impl App {
|
||||
|| self.overlay.is_some()
|
||||
|| self.chat_widget.has_active_view()
|
||||
{
|
||||
self.agents_overview.workspace.divider_drag_viewport = None;
|
||||
return false;
|
||||
}
|
||||
let viewport: Rect = tui.terminal.last_known_screen_size.into();
|
||||
let (center, conversation) = self.workspace_areas(viewport);
|
||||
if matches!(mouse.kind, MouseEventKind::Down(_)) {
|
||||
self.agents_overview.workspace.divider_drag_viewport = None;
|
||||
}
|
||||
if let Some(center) = center
|
||||
&& conversation.is_some()
|
||||
&& mouse.kind == MouseEventKind::Down(crossterm::event::MouseButton::Left)
|
||||
&& mouse.column == center.right()
|
||||
{
|
||||
self.agents_overview.workspace.divider_drag_viewport = Some(viewport);
|
||||
return true;
|
||||
}
|
||||
if matches!(
|
||||
mouse.kind,
|
||||
MouseEventKind::Drag(MouseButton::Left) | MouseEventKind::Up(MouseButton::Left)
|
||||
) && self.agents_overview.workspace.divider_drag_viewport.take() == Some(viewport)
|
||||
{
|
||||
let max = viewport
|
||||
.width
|
||||
.saturating_sub(MIN_CHAT_WIDTH + GUTTER_WIDTH)
|
||||
.max(24);
|
||||
self.agents_overview.workspace.width =
|
||||
Some(mouse.column.saturating_sub(viewport.x).clamp(24, max));
|
||||
if mouse.kind == MouseEventKind::Drag(MouseButton::Left) {
|
||||
self.agents_overview.workspace.divider_drag_viewport = Some(viewport);
|
||||
}
|
||||
tui.frame_requester().schedule_frame();
|
||||
return true;
|
||||
}
|
||||
let center_was_focused = self.agents_overview.workspace.focus == Some(Pane::Center);
|
||||
// The press chose the owner. Let its selection finish even outside its pane.
|
||||
if matches!(mouse.kind, MouseEventKind::Drag(_) | MouseEventKind::Up(_)) {
|
||||
@@ -173,6 +273,11 @@ impl App {
|
||||
if pressed {
|
||||
self.agents_overview.workspace.focus_center();
|
||||
self.cancel_pending_key_chord();
|
||||
if mouse.kind == MouseEventKind::Down(MouseButton::Left)
|
||||
&& let Some(view) = &mut self.agents_overview.workspace.view
|
||||
{
|
||||
view.click_row(point);
|
||||
}
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -138,7 +138,8 @@ impl App {
|
||||
(close
|
||||
&& action.context == crate::keymap::KeymapContext::Pager
|
||||
&& action.action == "close_transcript")
|
||||
|| (action.is_side_pane() && contexts.contains_action(action))
|
||||
|| ((action.is_side_pane() || action.action == "open_agents")
|
||||
&& contexts.contains_action(action))
|
||||
};
|
||||
let chord = match self.key_chord_matcher.clone().advance(
|
||||
key_event,
|
||||
@@ -167,6 +168,12 @@ impl App {
|
||||
}
|
||||
}
|
||||
let was_pending = self.key_chord_matcher.is_pending();
|
||||
if !was_pending
|
||||
&& self.workspace_center_owns_input()
|
||||
&& self.agents_overview_binding_matches(key_event)
|
||||
{
|
||||
return Some(key_event);
|
||||
}
|
||||
if !was_pending
|
||||
&& contexts.is_warnings()
|
||||
&& (crate::key_hint::plain(KeyCode::Char('k')).is_press(key_event)
|
||||
@@ -252,6 +259,19 @@ impl App {
|
||||
if !self.conversation_focus_available(tui) {
|
||||
return contexts;
|
||||
}
|
||||
if self.workspace_center_owns_input()
|
||||
&& self
|
||||
.agents_overview
|
||||
.workspace
|
||||
.view
|
||||
.as_ref()
|
||||
.is_some_and(|view| !view.owns_nested_input())
|
||||
{
|
||||
return contexts.with_pane_directions().with_main_composer_focus();
|
||||
}
|
||||
if self.workspace_center_owns_input() {
|
||||
return contexts;
|
||||
}
|
||||
if self.focused_sidebar_chooser(tui) {
|
||||
let contexts = KeymapContextSet::focused_sidebar_chooser();
|
||||
return if self.can_nudge_side_width(tui) {
|
||||
@@ -285,6 +305,15 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn agents_overview_binding_matches(&self, key: KeyEvent) -> bool {
|
||||
keymap_action_ids()
|
||||
.filter(|id| id.context == crate::keymap::KeymapContext::Agents)
|
||||
.any(|id| {
|
||||
bindings_for_action(&self.keymap, id.context.config_name(), id.action)
|
||||
.is_some_and(|bindings| bindings.is_pressed(key))
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn active_keymap_contexts(&self) -> crate::keymap::KeymapContextSet {
|
||||
if self.workspace_center_owns_input()
|
||||
&& let Some(view) = &self.agents_overview.workspace.view
|
||||
|
||||
@@ -275,12 +275,17 @@ impl App {
|
||||
pane.sync_agent_rows(&self.agent_navigation);
|
||||
}
|
||||
let viewport: Rect = screen_size.into();
|
||||
let (center, available) =
|
||||
if caller_inset.is_none() && self.agents_overview.workspace.is_open() {
|
||||
self.workspace_areas(viewport)
|
||||
} else {
|
||||
(None, Some(viewport))
|
||||
};
|
||||
let workspace = &mut self.agents_overview.workspace;
|
||||
let fraction = workspace.motion.advance(
|
||||
workspace.is_open(),
|
||||
(self.local_settings.tui.animations && viewport.width >= 86).then(|| frames.clone()),
|
||||
);
|
||||
workspace.fraction = Some(fraction);
|
||||
let (center, available) = if caller_inset.is_none() && fraction > 0.0 {
|
||||
self.workspace_areas(viewport)
|
||||
} else {
|
||||
(None, Some(viewport))
|
||||
};
|
||||
self.conversation_frame.command_center = center;
|
||||
let content = available.unwrap_or_default();
|
||||
let layout = available.and_then(|area| sidebar::paint_layout(self, tui, area));
|
||||
|
||||
@@ -687,6 +687,31 @@ impl App {
|
||||
key: KeyEvent,
|
||||
) -> bool {
|
||||
let bindings = &self.keymap.app;
|
||||
let focus_center = bindings.open_agents.is_pressed(key)
|
||||
&& self.local_settings.workspace_enabled(&self.config);
|
||||
let left_from_main = bindings.focus_pane_left.is_pressed(key)
|
||||
&& self.agents_overview.workspace.is_open()
|
||||
&& !self.sidebar_has_focus();
|
||||
if (focus_center || left_from_main) && self.conversation_focus_available(tui) {
|
||||
if key.kind == KeyEventKind::Press {
|
||||
if focus_center {
|
||||
self.open_agents_overview(app_server);
|
||||
} else {
|
||||
self.agents_overview.workspace.focus_center();
|
||||
}
|
||||
let activation = self
|
||||
.routed_key_activation
|
||||
.take()
|
||||
.unwrap_or_else(|| KeyBinding::from_event(key));
|
||||
self.chat_widget.suppress_current_view_key_until_release(
|
||||
activation,
|
||||
Instant::now(),
|
||||
ActivationKeySuppression::ViewTransition,
|
||||
);
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let panel_focus = self.panel_focus();
|
||||
let document = if panel_focus == Some(PaneFocus::Sidebar) {
|
||||
self.sidebar()
|
||||
@@ -896,7 +921,7 @@ impl App {
|
||||
true
|
||||
}
|
||||
|
||||
async fn focus_main_composer(
|
||||
pub(super) async fn focus_main_composer(
|
||||
&mut self,
|
||||
tui: &mut tui::Tui,
|
||||
app_server: &mut AppServerSession,
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@ Wide Command Center
|
||||
Agent command center Group: Pr… │ Response row 22
|
||||
All 1 Needs you 0 › │ Response row 23
|
||||
──────────────────────────────── │ Response row 24
|
||||
Tasks │ Response row 25
|
||||
│ Response row 25
|
||||
Pinned 1 │ Response row 26
|
||||
› ○ Investigate retry │ Response row 27
|
||||
│ Response row 28
|
||||
Ready · retry-fix │ Response row 28
|
||||
│ Response row 29
|
||||
│ ↓ Back to bottom · esc
|
||||
│
|
||||
|
||||
@@ -8,12 +8,12 @@ expression: "panel_text(&app, &tui)"
|
||||
c Main composer [ Select transcript
|
||||
s Hide sidebar p Presets ›
|
||||
t Open in sidebar - Hide pane
|
||||
z Zoom pane
|
||||
Move ⇧h Divider left
|
||||
← / h Pane left ⇧l Divider right
|
||||
⇧tab / ↑ / k Previous tab = Equal widths
|
||||
tab / ↓ / j Next tab r Resize panes
|
||||
, Minimum width
|
||||
a Command Center z Zoom pane
|
||||
⇧h Divider left
|
||||
Move ⇧l Divider right
|
||||
← / h Pane left = Equal widths
|
||||
⇧tab / ↑ / k Previous tab r Resize panes
|
||||
tab / ↓ / j Next tab , Minimum width
|
||||
. Maximum width
|
||||
w Close tab
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ expression: "panel_text(&app, &tui)"
|
||||
c Main composer [ Select transcript
|
||||
s Sidebar content p Presets ›
|
||||
t Open in sidebar z Zoom pane
|
||||
= Equal widths
|
||||
Move r Resize panes
|
||||
→ / l Pane right , Minimum width
|
||||
. Maximum width
|
||||
a Command Center = Equal widths
|
||||
r Resize panes
|
||||
Move , Minimum width
|
||||
→ / l Pane right . Maximum width
|
||||
|
||||
Esc cancel
|
||||
|
||||
@@ -24,7 +24,9 @@ impl App {
|
||||
{
|
||||
return pending.guide(&self.keymap.chords, |_| true);
|
||||
}
|
||||
let side = self.sidebar_has_focus();
|
||||
let center = self.workspace_center_owns_input();
|
||||
let center_open = self.agents_overview.workspace.is_open();
|
||||
let side = !center && self.sidebar_has_focus();
|
||||
let can_switch = self.panel_focus().is_some() || self.switchable_side_child().is_some();
|
||||
let can_size = super::side_pane::split_layout(self, tui, area).is_some();
|
||||
let can_resize = can_size && side && self.zoomed_thread.is_none();
|
||||
@@ -35,7 +37,7 @@ impl App {
|
||||
];
|
||||
for (action, keys) in pending.actions(&self.keymap.chords) {
|
||||
let (group, label) = match action.action {
|
||||
"focus_command_center" => (0, "Command Center"),
|
||||
"open_agents" => (0, "Command Center"),
|
||||
"focus_main_composer" => (0, "Main composer"),
|
||||
"focus_sidebar_tabs" => (0, "Open in sidebar"),
|
||||
"focus_sidebar_content" if side => (0, "Hide sidebar"),
|
||||
@@ -58,8 +60,12 @@ impl App {
|
||||
"sidebar_up" => (1, "Previous tab"),
|
||||
"sidebar_down" => (1, "Next tab"),
|
||||
"hide_pane" if side => (2, "Hide pane"),
|
||||
"focus_pane_left" if side && can_switch => (1, "Pane left"),
|
||||
"focus_pane_right" if !side && can_switch && self.open_pane_focus().is_some() => {
|
||||
"focus_pane_left" if (side && can_switch) || (!center && !side && center_open) => {
|
||||
(1, "Pane left")
|
||||
}
|
||||
"focus_pane_right"
|
||||
if center || (!side && can_switch && self.open_pane_focus().is_some()) =>
|
||||
{
|
||||
(1, "Pane right")
|
||||
}
|
||||
"hide_pane" | "focus_pane_left" | "focus_pane_right" => continue,
|
||||
@@ -74,7 +80,13 @@ impl App {
|
||||
let key = keys.join(" / ").fg(crate::style::accent_color());
|
||||
groups[group].1.push((key, label.replace('_', " ")));
|
||||
}
|
||||
let origin = if side { "Sidebar" } else { "Conversation" };
|
||||
let origin = if center {
|
||||
"Command Center"
|
||||
} else if side {
|
||||
"Sidebar"
|
||||
} else {
|
||||
"Conversation"
|
||||
};
|
||||
Some(ShortcutHud::leader(
|
||||
format!("{} · {origin}", pending.prefix.display_label()),
|
||||
groups
|
||||
|
||||
@@ -249,6 +249,7 @@ impl KeymapContextSet {
|
||||
}
|
||||
if action.context == KeymapContext::Global {
|
||||
match action.action {
|
||||
"open_agents" if self.0 & MAIN_COMPOSER_FOCUS != 0 => return true,
|
||||
"change_host" => return self.0 & BACKEND_CYCLING != 0,
|
||||
"choose_cloud_environment" => return self.0 & CLOUD_ENVIRONMENT_SELECTION != 0,
|
||||
_ => {}
|
||||
@@ -527,6 +528,9 @@ Reduce `tui.keymap.global.leader` alternatives or `leader ...` bindings."
|
||||
&& binding.action.action == "close_transcript"),
|
||||
!(contexts.0 & TRANSCRIPT_ACTIONS != 0
|
||||
&& binding.action.context == KeymapContext::Pager),
|
||||
contexts.0 & MAIN_COMPOSER_FOCUS != 0
|
||||
&& contexts.contains(KeymapContext::Agents)
|
||||
&& binding.action.context != KeymapContext::Agents,
|
||||
contexts.is_warnings() && binding.action.context != KeymapContext::List,
|
||||
contexts.is_warnings() && binding.action.context == KeymapContext::Global,
|
||||
)
|
||||
|
||||
@@ -58,6 +58,7 @@ pub(in crate::keymap) fn register(
|
||||
(Global, "sidebar_down", Char('j'), "j"),
|
||||
(Pager, "mark_markdown", Char('v'), "v"),
|
||||
(Global, "choose_cloud_environment", Char('e'), "e"),
|
||||
(Global, "open_agents", Char('a'), "a"),
|
||||
] {
|
||||
if remaining == 0 {
|
||||
break;
|
||||
@@ -66,7 +67,7 @@ pub(in crate::keymap) fn register(
|
||||
context,
|
||||
action: name,
|
||||
};
|
||||
if (!workspace && action.is_side_pane())
|
||||
if (!workspace && (action.is_side_pane() || name == "open_agents"))
|
||||
|| !matches!(
|
||||
super::configured_binding_for_action(keymap, action),
|
||||
Some(None)
|
||||
|
||||
@@ -118,7 +118,7 @@ macro_rules! define_keymap_actions {
|
||||
define_keymap_actions! {
|
||||
global "Global" {
|
||||
change_host [MultiBackend] => "Change where a new conversation runs.",
|
||||
focus_main_composer [Workspace] => "Focus the main conversation composer.",
|
||||
focus_main_composer [Workspace] => "Focus the main conversation composer. A matching Agents binding takes priority in Command Center.",
|
||||
focus_sidebar_tabs [Workspace] => "Open the sidebar tab chooser.",
|
||||
focus_sidebar_content [Workspace] => "Focus the side conversation, or hide it when already focused.",
|
||||
hide_pane [Workspace] => "Hide the focused sidebar pane.",
|
||||
@@ -134,7 +134,7 @@ define_keymap_actions! {
|
||||
move_divider_left [Workspace] => "Move the divider left when the side pane has focus.",
|
||||
move_divider_right [Workspace] => "Move the divider right when the side pane has focus.",
|
||||
toggle_pane_zoom [Workspace] => "Zoom or restore the focused pane.",
|
||||
open_agents => "Open the agent command center.",
|
||||
open_agents => "Open and focus Command Center. A matching Agents binding takes priority there.",
|
||||
open_transcript => "Open the transcript overlay.",
|
||||
find_transcript => "Find text in the full transcript.",
|
||||
// Keep the new warnings action out of shared-config writes until older strict readers
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
source: tui/src/keymap_setup.rs
|
||||
expression: snapshot
|
||||
---
|
||||
Focus Main Composer | leader c (ctrl-x c) | Global focus_main_composer Focus Main Composer Focus the main conversation composer. leader c (ctrl-x c) Default
|
||||
Focus Main Composer | leader c (ctrl-x c) | Global focus_main_composer Focus Main Composer Focus the main conversation composer. A matching Agents binding takes priority in Command Center. leader c (ctrl-x c) Default
|
||||
Focus Sidebar Tabs | leader t (ctrl-x t) | Global focus_sidebar_tabs Focus Sidebar Tabs Open the sidebar tab chooser. leader t (ctrl-x t) Default
|
||||
Focus Sidebar Content | leader s (ctrl-x s) | Global focus_sidebar_content Focus Sidebar Content Focus the side conversation, or hide it when already focused. leader s (ctrl-x s) Default
|
||||
Hide Pane | leader - (ctrl-x -) | Global hide_pane Hide Pane Hide the focused sidebar pane. leader - (ctrl-x -) Default
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ tab: Navigation (22 selectable)
|
||||
tab: Agents (13 selectable)
|
||||
tab: Approval (8 selectable)
|
||||
tab: Debug (1 selectable)
|
||||
Open Agents | unbound | Global open_agents Open Agents Open the agent command center. unbound Default
|
||||
Open Agents | unbound | Global open_agents Open Agents Open and focus Command Center. A matching Agents binding takes priority there. unbound Default
|
||||
Open Transcript | ctrl-t | Global open_transcript Open Transcript Open the transcript overlay. ctrl-t Default
|
||||
Find Transcript | f3 | Global find_transcript Find Transcript Find text in the full transcript. f3 Default
|
||||
Focus Activity | f4 | Global focus_activity Focus Activity Focus transcript activity groups to expand or collapse their details. f4 Default
|
||||
|
||||
Reference in New Issue
Block a user