From 4e19f0f20b487c9c38c3b4bc6cc5551730d62b26 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Thu, 26 Nov 2026 20:54:55 +0000 Subject: [PATCH] Focus the sidebar chooser when clicking empty space (#64219) ## Why With the composer focused, clicking below the sidebar file list left keyboard focus in the composer. This made it harder to resume keyboard navigation from the current selection. ## What changed An unmodified left-click on a non-interactive area of the chooser now moves focus from the composer to the sidebar. ## Testing Extend the sidebar file path test to click below the file list and verify that the sidebar regains focus and the path shortcut still works for the selected file. GitOrigin-RevId: dbae18a87bc6516dcb8672c0c8c7bb4b9b9ea505 --- codex-rs/tui/src/app/sidebar_input.rs | 13 +++++-------- .../tui/src/app/tests/sidebar_file_path_tests.rs | 11 +++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/codex-rs/tui/src/app/sidebar_input.rs b/codex-rs/tui/src/app/sidebar_input.rs index 2720fc93c0..2e7ac65777 100644 --- a/codex-rs/tui/src/app/sidebar_input.rs +++ b/codex-rs/tui/src/app/sidebar_input.rs @@ -4,7 +4,6 @@ use super::sidebar::PaneFocus; use super::sidebar::SidebarContent; use super::*; -use crate::sidebar_chooser; use crate::sidebar_chooser::ChooserAction; use crate::sidebar_tab_strip::SidebarTab; use crate::sidebar_tab_strip::TabTarget; @@ -160,7 +159,8 @@ impl App { .sidebar_targets .iter() .find(|(_, area)| area.contains(point)); - let candidate = if frame.sidebar_input == current && self.pane_resize.is_none() { + let can_press = frame.sidebar_input == current && self.pane_resize.is_none(); + let candidate = if can_press { hit.zip(current) .map(|(&(target, area), state)| SidebarPress { parent: self.sidebar_parent(), @@ -178,12 +178,9 @@ impl App { if button == MouseButton::Left && mouse.modifiers.is_empty() && self.chooser_focus() == Some(PaneFocus::Main) - && self.sidebar().is_some_and(|pane| pane.showing_file_path) - && frame.sidebar_input == current - && self.pane_resize.is_none() - && frame.panel_area().is_some_and(|area| { - sidebar_chooser::file_path_areas(area)[0].contains(point) - }) + && over_chooser + && can_press + && hit.is_none() { self.sidebar_mut() .show(SidebarContent::Chooser, PaneFocus::Sidebar); diff --git a/codex-rs/tui/src/app/tests/sidebar_file_path_tests.rs b/codex-rs/tui/src/app/tests/sidebar_file_path_tests.rs index 7c5eda8318..afc910b5ed 100644 --- a/codex-rs/tui/src/app/tests/sidebar_file_path_tests.rs +++ b/codex-rs/tui/src/app/tests/sidebar_file_path_tests.rs @@ -70,6 +70,17 @@ async fn sidebar_file_path_escape_requires_focus_but_mouse_back_does_not() -> Re Ok(()) }; click_back(&mut app, &mut tui, &mut server).await?; + + // Click below the file list to resume keyboard navigation on the selected file. + app.focus_workspace_composer(&mut tui); + side_frame(&mut app, &mut tui, size)?; + let panel = app.conversation_frame.panel_area().unwrap(); + let left = MouseButton::Left; + for kind in [MouseEventKind::Down(left), MouseEventKind::Up(left)] { + let event = mouse(kind, panel.right() - 1, panel.bottom() - 2); + boxed_future!(app.handle_tui_event(&mut tui, &mut server, event)).await?; + } + assert_eq!(app.chooser_focus(), Some(PaneFocus::Sidebar)); Box::pin(press(&mut app, &mut tui, &mut server, path)).await?; let frame = side_frame(&mut app, &mut tui, size)?; insta::assert_snapshot!(footer(&frame), @"esc back · ↓ scroll");