Commit 63d8481
authored
fix: Terminal escape sequence responses displayed on first prompt when starting tmux (#90)
* fix: Replace crossterm event parsing with raw stdin reading to prevent terminal escape sequence corruption
When running tmux inside bssh PTY sessions, terminal escape sequence responses
(DA1, DA2, DA3, XTGETTCAP) were appearing as raw text on the first prompt.
This occurred because crossterm::event::read() parses escape sequences,
consuming the ESC byte (0x1b) and corrupting terminal responses.
Solution:
- Keep using crossterm for terminal mode management (enable_raw_mode/disable_raw_mode)
- Replace crossterm::event::read() with direct stdin.read() using nix::poll for polling
- Add RawInputReader module for transparent byte passthrough
- Add LocalEscapeDetector for OpenSSH-style ~. disconnect handling
Changes:
- Add nix crate dependency with poll feature
- Create src/pty/session/raw_input.rs: Raw byte input reader
- Create src/pty/session/local_escape.rs: Local escape sequence detector
- Modify session_manager.rs: Use RawInputReader instead of crossterm event parsing
- Update mod.rs: Include new modules
This approach matches OpenSSH's behavior, providing transparent passthrough
of all bytes including terminal responses, arrow keys, function keys, and
other escape sequences.
Fixes #87
* docs: Add PTY escape sequence documentation for ~. disconnect
* fix: Address code review feedback - improve safety docs and suppress dead code warnings
* update: cargo fmt
* fix: Correct doc comment overindentation in raw_input.rs
Fix clippy doc_overindented_list_items warning by reducing
indentation of continued list item text from 14 to 2 spaces.
* feat: Add comprehensive unit tests for PTY session modules
Add missing test coverage for PTY-related modules:
- RawInputReader: 10 new tests for poll timeout clamping,
boundary conditions (u16::MAX), and duration handling
- TerminalModes: 18 new tests verifying control characters,
signal generation, canonical mode, echo, baud rates,
flow control, and mode completeness
- LocalEscapeDetector: 19 new edge case tests for buffer
boundaries, CR/LF handling, Unicode, and state transitions
- EscapeSequenceFilter: 32 new tests for buffer boundaries,
consecutive sequences, OSC/DCS filtering, and stress scenarios
Total: 79 new tests, 858 lines of test code added.1 parent 3c4b1a7 commit 63d8481
11 files changed
Lines changed: 1353 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | | - | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
30 | | - | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | | - | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
0 commit comments