diff --git a/docs/changelog.rst b/docs/changelog.rst index 37878e017..9192d9d92 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -81,6 +81,8 @@ Detailed list of changes - MacOS Intel: Fix a crash in the choose-fonts kitten when displaying previews of variable fonts (:iss:`7734`) +- Remote control: Fix a regression causing an escape code to leak when using @ launch with ``--no-response`` over the TTY (:iss:`7752`) + 0.36.0 [2024-08-17] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/cmd/at/tty_io.go b/tools/cmd/at/tty_io.go index bfd2e7ca0..b82205142 100644 --- a/tools/cmd/at/tty_io.go +++ b/tools/cmd/at/tty_io.go @@ -27,7 +27,11 @@ func is_stream_response(serialized_response []byte) bool { func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error) { serialized_response = make([]byte, 0) - lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors) + // we cant do inbandresize notification as in the --no-response case the + // command can cause a resize and the loop can quit before the notification + // arrives, leading to the notification being sent to whatever is executed + // after us. + lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.NoInBandResizeNotifications) if io_data.on_key_event != nil { lp.FullKeyboardProtocol() } else { diff --git a/tools/tui/loop/api.go b/tools/tui/loop/api.go index 1ac92c8fd..406d36931 100644 --- a/tools/tui/loop/api.go +++ b/tools/tui/loop/api.go @@ -196,6 +196,10 @@ func NoRestoreColors(self *Loop) { self.terminal_options.restore_colors = false } +func NoInBandResizeNotifications(self *Loop) { + self.terminal_options.in_band_resize_notification = false +} + func (self *Loop) DeathSignalName() string { if self.death_signal != SIGNULL { return self.death_signal.String() diff --git a/tools/tui/loop/run.go b/tools/tui/loop/run.go index 89172adc7..a12fad510 100644 --- a/tools/tui/loop/run.go +++ b/tools/tui/loop/run.go @@ -26,6 +26,7 @@ func new_loop() *Loop { l := Loop{controlling_term: nil} l.terminal_options.Alternate_screen = true l.terminal_options.restore_colors = true + l.terminal_options.in_band_resize_notification = true l.terminal_options.kitty_keyboard_mode = DISAMBIGUATE_KEYS | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES | REPORT_TEXT_WITH_KEYS l.escape_code_parser.HandleCSI = l.handle_csi l.escape_code_parser.HandleOSC = l.handle_osc diff --git a/tools/tui/loop/terminal-state.go b/tools/tui/loop/terminal-state.go index 24c70a50f..7014c5017 100644 --- a/tools/tui/loop/terminal-state.go +++ b/tools/tui/loop/terminal-state.go @@ -100,6 +100,7 @@ type TerminalStateOptions struct { Alternate_screen, restore_colors bool mouse_tracking MouseTracking kitty_keyboard_mode KeyboardStateBits + in_band_resize_notification bool } func set_modes(sb *strings.Builder, modes ...Mode) { @@ -128,7 +129,10 @@ func (self *TerminalStateOptions) SetStateEscapeCodes() string { reset_modes(&sb, IRM, DECKM, DECSCNM, BRACKETED_PASTE, FOCUS_TRACKING, MOUSE_BUTTON_TRACKING, MOUSE_MOTION_TRACKING, MOUSE_MOVE_TRACKING, MOUSE_UTF8_MODE, MOUSE_SGR_MODE) - set_modes(&sb, DECARM, DECAWM, DECTCEM, INBAND_RESIZE_NOTIFICATION) + set_modes(&sb, DECARM, DECAWM, DECTCEM) + if self.in_band_resize_notification { + set_modes(&sb, INBAND_RESIZE_NOTIFICATION) + } if self.Alternate_screen { set_modes(&sb, ALTERNATE_SCREEN) sb.WriteString(CLEAR_SCREEN)