fix(ssh): restore exitAlternateScreenBuffer to prevent character loss on session open#138
Open
rlagentflowbeta[bot] wants to merge 1 commit intomainfrom
Open
fix(ssh): restore exitAlternateScreenBuffer to prevent character loss on session open#138rlagentflowbeta[bot] wants to merge 1 commit intomainfrom
rlagentflowbeta[bot] wants to merge 1 commit intomainfrom
Conversation
… on session open Characters were being lost at the start of an SSH session due to two issues introduced in a previous refactor: 1. exitAlternateScreenBuffer() was removed from releaseTerminal(), causing SSH to run inside Ink's alternate screen buffer. Any Ink re-renders during the connection setup wrote ANSI sequences to the same buffer, corrupting terminal state and swallowing early keystrokes. 2. setRawMode(false) was called before spawning SSH, which invokes tcsetattr(TCSAFLUSH) under the hood. TCSAFLUSH discards pending kernel input and switches the terminal to canonical (line-buffered) mode. Characters typed during the SSH connection handshake were therefore either discarded or held until Enter was pressed, never reaching SSH. Fix: call exitAlternateScreenBuffer() first in releaseTerminal() so SSH runs in the normal screen buffer (isolated from Ink's rendering), and remove the setRawMode(false) call so the terminal stays in raw mode throughout the transition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Root Cause
Two related issues were introduced when `exitAlternateScreenBuffer()` was removed from the spawn flow (in a previous refactor aimed at eliminating the brief visual flash on SSH exit):
SSH ran inside Ink's alternate screen buffer. Any Ink re-renders during the SSH connection setup wrote ANSI escape sequences to the same buffer SSH was using, corrupting terminal state and causing initial keystrokes to be swallowed.
`setRawMode(false)` was called before spawning SSH. Node.js's `setRawMode` uses `tcsetattr(TCSAFLUSH)` internally. `TCSAFLUSH` discards all pending kernel input and switches the terminal to canonical (line-buffered) mode. Characters typed during the SSH connection handshake were therefore either discarded or held until Enter was pressed — never reaching the remote shell.
Fix
Test plan
🤖 Generated with Claude Code