Repository navigation
fix(tui): prevent piped stdin from breaking UI and keyboard input - #34242
LordMikkel wants to merge 12 commits into
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Local merge/validation note from review queue: Validated locally against current
I would not merge this yet. Remaining blockers found in review:
Also, the branch is currently stale relative to |
|
Revalidated by the merge queue on 2026-06-28 against current What passed:
Still not merging yet. The blockers from the previous review comment still apply because the head commit has not changed:
Please address those before this is merge-ready. |
|
Revalidated by the merge queue on 2026-06-28 against current What passed locally in an isolated worktree:
Still not merging. Independent review confirmed the remaining blockers:
Please address those before this is merge-ready. |
|
Revalidated by the merge queue on 2026-06-28 against current What passed locally in an isolated worktree:
Still not merging. Independent adversarial review confirmed the remaining blockers:
Please address those before this is merge-ready. |
|
@andrei-hasna Thanks for the thorough review! I addressed the blockers:
Your detailed feedback was really valuable! |
# Conflicts: # packages/tui/src/app.tsx
|
Tested the latest revision, and I can confirm this fixes the issue for me. I can now pipe stdin into the TUI without losing keyboard input. |
|
Worker review update for the current head Not merging as-is. Local synthetic merge into current
Merge blockers:
Recommendation: update/rebase the PR, fix the cleanup ordering, add focused regression coverage, and rerun CI on the updated GitHub merge ref before re-entering the merge queue. |
|
@andrei-hasna Thanks again for the careful review and feedback. Fixed the cleanup ordering: the guard cleanup now runs before closing the alternate stdin stream. Also removed a accidental scratch comment. |
Drop the stdin context in favor of renderer.stdin, and trim the win32 console helpers back to the original shape.
# Conflicts: # packages/tui/src/app.tsx
_get_osfhandle aborts the process when given a Bun-opened fd, so echo hi | opencode would crash on Windows. Open a dedicated CONIN$ handle instead; every CONIN$ handle shares the same console input buffer.
Resolve the terminal stream before the TUI try block so both handles stay const, name the win32 CreateFileW flags, and add a Windows-only test that exercises the console helpers with a separately opened CONIN$ stream.
|
Updated against the latest I also tested it on Windows this time and found that the previous version crashed with piped stdin: |
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Issue for this PR
Closes #28538
Closes #24195
Closes #3871
Closes #6220
Replaces #28540, which was closed by the automated PR cleanup bot before maintainer review.
Type of change
What does this PR do?
When stdin is piped, the TUI renderer can read keyboard input from the pipe instead of the terminal. That breaks the UI and keyboard control for a simple command like:
echo "hello" | opencodeThe
runcommand already handles this withresolveInteractiveStdin(). This PR applies the same approach to the TUI: pass the controlling terminal (/dev/ttyon Linux,CONIN$on Windows) to the renderer while still consuming piped stdin as the prompt.How did you verify your code works?
bun --cwd packages/opencode test runtime.stdinbun --cwd packages/opencode typecheckecho "hello" | opencodeScreenshots / recordings
With the fix:
Without the fix:
Checklist