From 5f9f5ed558ae5e59db8382a7ee8e895d19f8ab09 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sat, 9 May 2026 02:17:22 -0500 Subject: [PATCH] fix(tui): re-arm mouse capture on FocusGained MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-existing gap exposed during v0.8.24 testing: when the user clicks away (Cmd+Tab, opens the screenshot tool, etc.) and clicks back, some terminals drop the application's mouse-tracking mode. The \`FocusGained\` handler at \`ui.rs::1599\` already re-pushed keyboard enhancement flags to recover IME state — extend the same recovery to \`EnableMouseCapture\` so wheel scroll keeps working after a focus round-trip. Gated on \`app.use_mouse_capture\` so explicit \`--no-mouse-capture\` users aren't re-enabled against their will. --- CHANGELOG.md | 8 +++++++- crates/tui/src/tui/ui.rs | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e88c866b..5e282dd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.8.24] - 2026-05-08 +## [0.8.24] - 2026-05-09 A bugfix + refactor release picking up the backlog after the v0.8.23 security release. ### Fixed +- **Mouse-wheel scroll survives focus toggles** — on macOS, switching away + (Cmd+Tab, opening the screenshot tool, etc.) and back can drop the + terminal's mouse-tracking mode, leaving wheel scroll dead until restart. + The TUI now re-arms `EnableMouseCapture` on `FocusGained` alongside the + existing keyboard-mode recapture, so wheel events keep flowing after a + focus round-trip. - **Workspace-local slash commands are now loaded (#1259)** — user command files placed in `/.deepseek/commands/`, `/.claude/commands/`, and `/.cursor/commands/` are diff --git a/crates/tui/src/tui/ui.rs b/crates/tui/src/tui/ui.rs index 06354a02..9993864c 100644 --- a/crates/tui/src/tui/ui.rs +++ b/crates/tui/src/tui/ui.rs @@ -1596,8 +1596,14 @@ async fn run_event_loop( // terminal's keyboard mode, which breaks IME compositor state. // Acknowledging FocusGained and re-pushing the flags restores // the IME so CJK input methods work after a focus toggle. + // The same reset can drop the terminal's mouse-tracking mode, + // leaving wheel scroll dead until restart — re-arm mouse + // capture on focus-gain so wheel events keep flowing. if terminal_event_needs_viewport_recapture(&evt) { push_keyboard_enhancement_flags(terminal.backend_mut()); + if app.use_mouse_capture { + let _ = execute!(terminal.backend_mut(), EnableMouseCapture); + } force_terminal_repaint = true; app.needs_redraw = true; }