fix(terminals): normalize bare LF to CRLF in piped readonly output#104
Merged
Conversation
A piped child process has no controlling TTY, so its stdout/stderr carry bare \n line endings that xterm renders as a staircase (no cursor return to column 0). Translate lone \n to \r\n in spawnPipe, mirroring the kernel's ONLCR translation, while leaving existing \r\n untouched.
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Problem
Readonly terminal sessions render output as a staircase — each new line starts at the column where the previous line ended instead of at column 0.
Cause
Readonly sessions spawn through `spawnPipe` (a `child_process` with piped stdio), not a PTY. A piped child has no controlling TTY, so the kernel's `ONLCR` line discipline never runs and its stdout/stderr arrive with bare `\n` line endings. xterm.js only returns the cursor to column 0 on `\r`, so a bare `\n` drops the cursor down a row at its current column. Interactive PTY sessions are unaffected because the kernel translates `\n`→`\r\n` for them.
Fix
`spawnPipe` now normalizes its output before forwarding, mimicking `ONLCR`:
Only the pipe backend is touched, so PTY fidelity (progress bars, bare `\r`, TUIs) is preserved.
Verification
Added a test asserting `a\nb\r\nc` renders as `a\r\nb\r\nc` with no doubled `\r\r\n`. All terminals tests pass; lint and typecheck clean.
This PR was created with the help of an agent.