Problem / Background
When running Neovim after connecting via SSH, strange text appears at the bottom of the screen:
:159c/16e0/18490+r54631+r524742=380+r736574726762660+r736574726762621$r0;48:2:1:1:2:3m1+r4D73=1B5D35323B25703125733B257032257307
This occurs because terminal escape sequence responses are not being properly handled.
Root Cause Analysis
The displayed text consists of raw terminal escape sequence responses:
+r pattern: XTGETTCAP response (terminal capability query response)
736574726762 -> hex decoded: "setrgb" (true color support query)
48:2:1:1:2:3m: SGR true color escape sequence
1B5D35323B...: OSC (Operating System Command) sequence
When Neovim starts, it sends several queries to detect terminal capabilities:
- XTGETTCAP (terminfo capability query)
- DA1/DA2/DA3 (Device Attributes)
- Kitty keyboard protocol support
- True color support
When PTY is not properly configured in SSH sessions, or terminal responses are mixed with stdout, raw sequences appear on screen.
Proposed Solution
- Properly configure terminal modes during PTY allocation (raw mode, echo settings, etc.)
- Correctly pass terminal type (TERM environment variable)
- Properly handle terminal query/response cycles in SSH channel
- Improve PTY settings for interactive sessions
Acceptance Criteria
Technical Considerations
- Review PTY allocation in
src/ssh/ modules
- Ensure proper terminal mode flags (ECHO, ICANON, etc.) are set
- Consider handling XTGETTCAP and DA responses at the SSH client level
- May need to buffer and filter terminal responses before display
Implementation (PR #77)
The fix adds an escape sequence filter module (escape_filter.rs) that uses a state machine to:
- Filter XTGETTCAP responses (
\x1bP+r...)
- Filter DA1/DA2/DA3 responses (
\x1b[?...c)
- Filter OSC responses (
\x1b]...)
- Filter DCS responses (
\x1bP...)
- Preserve valid escape sequences for colors, cursor movement, etc.
Additionally, TERM and COLORTERM environment variables are now set before PTY allocation.
Additional Context
Related closed issues:
This issue may require revisiting the PTY implementation to ensure proper terminal emulation.
Problem / Background
When running Neovim after connecting via SSH, strange text appears at the bottom of the screen:
This occurs because terminal escape sequence responses are not being properly handled.
Root Cause Analysis
The displayed text consists of raw terminal escape sequence responses:
+rpattern: XTGETTCAP response (terminal capability query response)736574726762-> hex decoded: "setrgb" (true color support query)48:2:1:1:2:3m: SGR true color escape sequence1B5D35323B...: OSC (Operating System Command) sequenceWhen Neovim starts, it sends several queries to detect terminal capabilities:
When PTY is not properly configured in SSH sessions, or terminal responses are mixed with stdout, raw sequences appear on screen.
Proposed Solution
Acceptance Criteria
Technical Considerations
src/ssh/modulesImplementation (PR #77)
The fix adds an escape sequence filter module (
escape_filter.rs) that uses a state machine to:\x1bP+r...)\x1b[?...c)\x1b]...)\x1bP...)Additionally, TERM and COLORTERM environment variables are now set before PTY allocation.
Additional Context
Related closed issues:
This issue may require revisiting the PTY implementation to ensure proper terminal emulation.