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
This commit is contained in:
Felipe Coury
2026-11-26 21:08:29 +00:00
committed by copyberry
parent df06542138
commit 4e19f0f20b
2 changed files with 16 additions and 8 deletions
+5 -8
View File
@@ -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);
@@ -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");