Repository navigation
fix(tui): stop piped stdin from breaking UI and keyboard input - #54539
Open
LordMikkel wants to merge 1 commit into
Open
LordMikkel wants to merge 1 commit into
LordMikkel wants to merge 1 commit into
Conversation
With piped stdin the default TUI read keys from the pipe, so typing did nothing. Reuse resolveInteractiveStdin() from mini to open the terminal and pass it to the renderer and to /editor. Windows is left as is: Bun can't put a reopened CONIN$ in raw mode.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Author
|
@simonklee this reuses |
This branch has not been deployed
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.
Issue for this PR
Closes #42234
Closes #28538
Closes #24195
Closes #3871
Closes #6220
Related to #387 and #3930.
This is my third attempt at this fix. #28540 was closed by the stale PR bot and #34242 by the V1 cleanup, both before a maintainer review. The bug is still there in V2: I reproduced it with the current release binary and on
dev. This is the port to V2.Type of change
What does this PR do?
When stdin is piped (
echo "hello" | opencode), the TUI renderer reads input from the pipe instead of the terminal. Keyboard control breaks completely: ANSI noise, no interaction.opencode minialready handles this withresolveInteractiveStdin(), but the default TUI was missing it. This PR applies the same fix: open the controlling terminal (/dev/tty) and pass it to the renderer./editorhad the same problem, since the editor inherited the pipe, so it now uses the renderer's stdin too.With no terminal at all (
opencode </dev/nullindocker execwithout-t), it now exits withopencode requires a controlling terminal for inputinstead of hanging forever.On Windows, Bun can't put a reopened
CONIN$in raw mode (setRawModefails on any fd but stdin), so this leaves Windows unchanged for now.How did you verify your code works?
bun typecheckinpackages/cliandpackages/tuiecho "hello" | bun devin a real terminal: keys reach the TUI with the fix and don't without it.setsid bun dev </dev/null(no controlling terminal): exits with code 1 and the error above; without the fix it keeps running.Screenshots / recordings
From the previous PRs.
With the fix:
Without the fix:
Checklist