Fix Windows backspace and initial prompt - #53
Closed
l1a wants to merge 2 commits into
Closed
Conversation
Two fixes for connecting to a Unix etrs from a Windows etr client, both invisible over plain ssh from the same machine: - Backspace behaved like a stray/delete key. The Windows console hands raw byte reads legacy key codes (Backspace as 0x08), whereas a Unix PTY expects the xterm conventions (Backspace as 0x7f/DEL, matching stty erase). The client now switches the console into virtual-terminal mode after enabling raw mode (ENABLE_VIRTUAL_TERMINAL_INPUT on stdin, plus ENABLE_VIRTUAL_TERMINAL_PROCESSING on stdout for ANSI rendering), so it emits the same key bytes a real terminal does. No-op on Unix. New Windows-only dependency: windows-sys (Console). - Blank screen until the first Enter. etrs started reading the shell's PTY at session start, before any client connected, so the initial prompt could be produced in the window between snapshotting replay data and installing the live PTY channel: it was recorded to history but neither replayed nor sent on the first connection. The PTY reader task is now started lazily on the first connection, after the client's PTY channel is live (mirrors how ssh emits shell output only once the channel exists). Replay-on-reconnect is unchanged. Validated: clippy -D warnings + cargo test green on both Windows (x86_64-pc-windows-msvc) and Linux (WSL Fedora); man pages rebuilt at 0.6.3. Assisted-By: Claude Opus 4.8 (1M context)
Bump crossbeam-epoch 0.9.18->0.9.20 (RUSTSEC-2026-0204, dev-only via criterion) and anyhow 1.0.102->1.0.103 (RUSTSEC-2026-0190 unsoundness) so the CI security audit passes. Both advisories were published against pre-existing transitive deps while this branch was in flight; neither was introduced by this work. Assisted-By: Claude Opus 4.8 (1M context)
Owner
Author
|
Superseded by #55, which keeps only the confirmed-working Windows Backspace fix plus the dependency-advisory bumps. The server-side deferred-PTY-reader change and the crossterm-events input rewrite from this branch were experiments targeting the 'first line not echoed until Enter' bug; that bug is still unresolved and is now tracked in #54. Closing in favor of #55. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Two fixes for connecting from a Windows
etrclient to a Unixetrshost. Both were invisible over plainsshfrom the same Windows machine, which is why they looked likeetr-specific regressions.Backspace behaved like a delete / didn't erase. The Windows console delivers legacy key codes to raw byte reads (Backspace as
0x08), whereas a Unix PTY expects the xterm convention0x7f(DEL) to match the defaultstty erase.etrforwarded the raw0x08verbatim, so the remote never saw the erase char it expected. The client now switches the console into virtual-terminal mode after enabling raw mode —ENABLE_VIRTUAL_TERMINAL_INPUTon stdin (keys become the same VT byte sequences a real terminal emits: Backspace → DEL, arrows → escape sequences) andENABLE_VIRTUAL_TERMINAL_PROCESSINGon stdout (renders the remote's ANSI). No-op on Unix. New Windows-only dependency:windows-sys(Console).Blank screen until the first Enter.
etrsspawned the shell and started reading its PTY at session start, before any client connected. The shell's initial prompt could be produced in the window between the server snapshotting replay data and installing the live PTY channel — so on the first connection it was recorded to history but neither replayed nor sent, and pressing Enter forced a fresh prompt. The PTY reader task is now started lazily on the first connection, after the client's PTY channel is live (mirrors how SSH emits shell output only once the channel exists). Replay-on-reconnect is unchanged — the reader persists across reconnects and picks up each new outbound channel.Also bumped two transitive deps to clear RustSec advisories published while this branch was in flight (neither introduced here):
crossbeam-epoch0.9.18→0.9.20 (RUSTSEC-2026-0204, dev-only viacriterion, not in the shipped binaries) andanyhow1.0.102→1.0.103 (RUSTSEC-2026-0190 unsoundness).Version bumped 0.6.2 → 0.6.3; NOTES.md, man pages, and the wiki Troubleshooting page updated.
Test plan
cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test(110) — green on Windows (x86_64-pc-windows-msvc) and Linux (WSL Fedora; the#[cfg(unix)]etrspath compiles, lints, and tests clean).etron Windows; deployetrs0.6.3 to a Linux host.etr user@hostfrom a native Windows console (PowerShell/Windows Terminal).stty -ashould showerase = ^?.🤖 Generated with Claude Code