fix(tui): pop keyboard flags on suspend paths too (#443 follow-up)

`main.rs` (process panic) and the normal TUI shutdown both pop
keyboard enhancement flags before handing the terminal back to
the child shell. The two suspend paths — `pause_terminal`
(Ctrl+Z and shell-suspend) and
`external_editor::spawn_editor_for_input` (composer `$EDITOR`
launch) — were missing the same defensive pop.

Today this is dormant: the TUI doesn't push keyboard
enhancement flags explicitly, so there's nothing to pop. The
fix is defence-in-depth: the day a future code path enables
the flags (kitty keyboard protocol for sub-second-precision
modifier reporting, say), the suspend handlers won't leak the
half-configured input mode to Vim / less / a shell child.

Aligns the four terminal-handoff sites (shutdown, panic,
suspend, editor) so they all do the same thing.
This commit is contained in:
Hunter Bown
2026-05-03 05:29:11 -05:00
parent ac0c16996e
commit 5deaf97253
3 changed files with 21 additions and 1 deletions
+8
View File
@@ -148,6 +148,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
the user-level array wholesale (the typical "merge" pattern is
for users who want both — they list `~/global.md` inside the
project array). Documented in `config.example.toml`.
- **Keyboard-enhancement flags pop on suspend paths too** (#443
follow-up) — `pause_terminal` (Ctrl+Z / shell-suspend) and
`external_editor::spawn_editor_for_input` (composer `$EDITOR`
launch) now pop the flags before handing the terminal to the
child process, matching the existing shutdown and panic-hook
paths. Defense-in-depth: if a future code path enables the
flags explicitly, the suspend handlers won't leak them to a
Vim / less / shell child that hasn't asked for them.
- **RLM tool family** (#512) — `rlm` tool cards map to
`ToolFamily::Rlm` and render `rlm`, not `swarm`. Stale "swarm"
wording cleaned out of docs / comments / tests.
+8 -1
View File
@@ -15,7 +15,10 @@ use std::io::{self, Stdout, Write};
use std::process::Command;
use crossterm::{
event::{DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture},
event::{
DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture,
PopKeyboardEnhancementFlags,
},
execute,
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
};
@@ -125,6 +128,10 @@ pub fn spawn_editor_for_input(
current: &str,
) -> io::Result<EditorOutcome> {
// 1. Suspend.
// #443: pop keyboard enhancement flags first so the editor
// process doesn't inherit a half-configured input mode. Best-
// effort — matches the shutdown / panic paths in main.rs.
let _ = execute!(terminal.backend_mut(), PopKeyboardEnhancementFlags);
let _ = disable_raw_mode();
if use_bracketed_paste {
let _ = execute!(terminal.backend_mut(), DisableBracketedPaste);
+5
View File
@@ -5162,6 +5162,11 @@ fn pause_terminal(
use_mouse_capture: bool,
use_bracketed_paste: bool,
) -> Result<()> {
// #443: pop keyboard enhancement flags before handing the terminal
// to a child process so it doesn't inherit a half-configured input
// mode. Best-effort — terminals that didn't accept the flags
// silently ignore the pop. Matches the shutdown and panic paths.
let _ = execute!(terminal.backend_mut(), PopKeyboardEnhancementFlags);
disable_raw_mode()?;
if use_alt_screen {
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;