Preserve sidebar clicks when the terminal gains focus (#63999)

## Why

A terminal can report a focus gain between mouse-down and mouse-up.
Clearing the pending sidebar press on that event causes the release to
be ignored, so clicking the tab chooser's close button can fail to open
the confirmation dialog.

## What changed

Keep the pending sidebar press on `TuiEvent::FocusGained` so the mouse
release can complete the click.

## Testing

Extend the tab chooser test to send a focus gain between the press and
release and check that the close confirmation dialog appears.

GitOrigin-RevId: 4173292c50383304e9ef62104251434be7580789
This commit is contained in:
Felipe Coury
2026-11-25 22:45:11 +00:00
committed by copyberry
parent fd95d89146
commit b420c7ca54
2 changed files with 9 additions and 7 deletions
+2
View File
@@ -903,7 +903,9 @@ impl App {
self.chat_widget.rendered_selection.borrow_mut().end_drag();
}
match &event {
// A terminal can report focus between mouse-down and mouse-up.
TuiEvent::Draw
| TuiEvent::FocusGained
| TuiEvent::Mouse(crossterm::event::MouseEvent {
kind: MouseEventKind::Up(_) | MouseEventKind::Moved,
..
+7 -7
View File
@@ -5660,13 +5660,13 @@ async fn handle_start_side_seeds_navigation_before_thread_started() -> Result<()
let buffer = tui.terminal.previous_buffer();
let style = |x| buffer[(x, chooser.y)].style();
assert_eq!([close_x - 1, close_x + 1].map(style), [style(close_x); 2]);
for kind in [down, release] {
boxed_future!(app.handle_tui_event(
&mut tui,
&mut app_server,
mouse(kind, close_x + 1, chooser.y)
))
.await?;
// Rex reports focus again between the press and release of a single click.
for event in [
mouse(down, close_x + 1, chooser.y),
TuiEvent::FocusGained,
mouse(release, close_x + 1, chooser.y),
] {
boxed_future!(app.handle_tui_event(&mut tui, &mut app_server, event)).await?;
}
let frame = side_frame(&mut app, &mut tui, even)?;
let dialog = frame