You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#234 restores ordinary local-shell input after a remote PTY leaks Kitty keyboard
progressive-enhancement state. Its best-effort teardown intentionally drains the
Kitty mode stacks and clears the active flags on both the current and main
screens.
That fallback is correct for the common case where bssh is launched from an
ordinary shell, but it cannot preserve an enhanced keyboard mode already owned
by an outer local TUI. If that TUI launches bssh, returning from the SSH
session may leave the outer application expecting CSI-u input while the terminal
has been reset to legacy keyboard reporting.
This limitation is documented in src/pty/terminal.rs and docs/architecture/interactive-mode.md. It was explicitly deferred by #234
because crossterm 0.29 exposes support detection but not the active Kitty
keyboard flags, and a naïve /dev/tty query can race the PTY input reader.
Goal
Preserve and restore the local terminal's pre-existing enhanced-keyboard state
across an interactive bssh PTY session without racing or consuming user input.
Proposed Investigation
Determine whether a newer crossterm API can expose the active Kitty keyboard
flags, or whether the necessary query support should be contributed upstream.
If bssh must issue CSI ? u itself, design a bounded query/response phase
before the PTY input task starts so the response cannot race ordinary input.
Record the state independently for the main and alternate screens where
required by the Kitty protocol.
Normal EOF, abrupt transport loss, local ~., input-send failure, and
forced cleanup paths preserve the captured state consistently.
Automated tests cover successful queries, timeouts/malformed replies,
unsupported terminals, exact restore bytes, and the legacy fallback.
A real-TTY test covers an outer TUI in Ghostty and at least one additional
Kitty-keyboard-compatible terminal.
Implementation Note
The implementation captures the effective Kitty flags on each screen. The Kitty protocol does not expose the contents of an application's private mode stack, so cleanup drains remote-owned stack entries and restores the captured effective values.
DEC 1049 has a separate protocol limitation: setting it clears the alternate buffer and overwrites a single saved-cursor slot. When bssh starts inside an outer alternate-screen TUI and the remote resets 1049, cleanup therefore reselects the preserved buffer with non-clearing mode 47 instead of claiming it can reconstruct the 1049 mode bit, cursor slot, and outer contents simultaneously.
Problem / Background
#234 restores ordinary local-shell input after a remote PTY leaks Kitty keyboard
progressive-enhancement state. Its best-effort teardown intentionally drains the
Kitty mode stacks and clears the active flags on both the current and main
screens.
That fallback is correct for the common case where
bsshis launched from anordinary shell, but it cannot preserve an enhanced keyboard mode already owned
by an outer local TUI. If that TUI launches
bssh, returning from the SSHsession may leave the outer application expecting CSI-u input while the terminal
has been reset to legacy keyboard reporting.
This limitation is documented in
src/pty/terminal.rsanddocs/architecture/interactive-mode.md. It was explicitly deferred by #234because crossterm 0.29 exposes support detection but not the active Kitty
keyboard flags, and a naïve
/dev/ttyquery can race the PTY input reader.Goal
Preserve and restore the local terminal's pre-existing enhanced-keyboard state
across an interactive
bsshPTY session without racing or consuming user input.Proposed Investigation
flags, or whether the necessary query support should be contributed upstream.
CSI ? uitself, design a bounded query/response phasebefore the PTY input task starts so the response cannot race ordinary input.
required by the Kitty protocol.
cleanup, while retaining fix: restore enhanced keyboard modes after PTY disconnect #234's legacy-baseline reset as a fallback when
querying is unsupported or fails.
modifyOtherKeys.Acceptance Criteria
bsshfrom an outer Kitty-keyboard-aware TUI does not change theouter application's effective keyboard protocol after bssh exits.
and alternate screens.
remote PTY traffic.
the ordinary-shell cleanup introduced by fix: restore enhanced keyboard modes after PTY disconnect #234.
~., input-send failure, andforced cleanup paths preserve the captured state consistently.
unsupported terminals, exact restore bytes, and the legacy fallback.
Kitty-keyboard-compatible terminal.
Implementation Note
The implementation captures the effective Kitty flags on each screen. The Kitty protocol does not expose the contents of an application's private mode stack, so cleanup drains remote-owned stack entries and restores the captured effective values.
DEC 1049 has a separate protocol limitation: setting it clears the alternate buffer and overwrites a single saved-cursor slot. When bssh starts inside an outer alternate-screen TUI and the remote resets 1049, cleanup therefore reselects the preserved buffer with non-clearing mode 47 instead of claiming it can reconstruct the 1049 mode bit, cursor slot, and outer contents simultaneously.
Related