Skip to content

fix: PTY proxy for local mode stdin corruption#553

Open
mfazekas wants to merge 2 commits intoslopus:mainfrom
mfazekas:fix/pty-proxy-stdin-corruption
Open

fix: PTY proxy for local mode stdin corruption#553
mfazekas wants to merge 2 commits intoslopus:mainfrom
mfazekas:fix/pty-proxy-stdin-corruption

Conversation

@mfazekas
Copy link

@mfazekas mfazekas commented Feb 7, 2026

After local→remote→local mode switch, Node.js children spawned with stdio:'inherit' stop receiving stdin.

Fix: spawn local-mode children via node-pty in their own PTY (child never inherits parent's fd 0), and give Ink a separate /dev/tty fd so it never touches process.stdin.

Investigation details

Native binaries (e.g. cat) using raw read() 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.stdin between spawns:

Fixes #527
Fixes #423

…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>
@mfazekas mfazekas force-pushed the fix/pty-proxy-stdin-corruption branch from 4108d55 to 91e3f8b Compare February 7, 2026 18:26
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>
@mfazekas mfazekas marked this pull request as ready for review February 8, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moving from remote mode to local mode removes the history and harm the writing in local mode Terminal input stuck after exit (raw mode not restored)

1 participant