fix: PTY proxy for local mode stdin corruption#553
Open
mfazekas wants to merge 2 commits intoslopus:mainfrom
Open
fix: PTY proxy for local mode stdin corruption#553mfazekas wants to merge 2 commits intoslopus:mainfrom
mfazekas wants to merge 2 commits intoslopus:mainfrom
Conversation
…ode switch
After local→remote→local switch, Ink's setEncoding('utf8') permanently corrupts
process.stdin's libuv TTYWrap, breaking stdin for subsequent Node.js children.
Fix: spawn local-mode children via node-pty in their own PTY, and give Ink a
separate /dev/tty fd so it never touches process.stdin.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
4108d55 to
91e3f8b
Compare
mfazekas
pushed a commit
to mfazekas/happy
that referenced
this pull request
Feb 7, 2026
Detailed code review of PR slopus#553 which fixes stdin corruption after local→remote→local mode switches by using node-pty isolation and a separate /dev/tty fd for Ink. https://claude.ai/code/session_01GAHHRpAb2Rkxx1USTzZQpw
Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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.
After local→remote→local mode switch, Node.js children spawned with
stdio:'inherit'stop receiving stdin.Fix: spawn local-mode children via
node-ptyin their own PTY (child never inherits parent's fd 0), and give Ink a separate/dev/ttyfd so it never touchesprocess.stdin.Investigation details
Native binaries (e.g.
cat) using rawread()are unaffected — only Node.js children break.The remote mode code and Ink both manipulate
process.stdin(flowing mode,setEncoding,setRawMode) between child spawns. After cleanup (pause(),removeAllListeners()), something in the libuv TTY handle state remains dirty, preventing subsequent Node.js children from reading stdin.E2e tests reproducing the issue:
test/pty-proxy-e2e(test file)Code that touches
process.stdinbetween spawns:Fixes #527
Fixes #423