Skip to content

fix(opencode): keep TUI interactive with piped stdin#28540

Open
LordMikkel wants to merge 2 commits into
anomalyco:devfrom
LordMikkel:fix/tui-stdin-pipe
Open

fix(opencode): keep TUI interactive with piped stdin#28540
LordMikkel wants to merge 2 commits into
anomalyco:devfrom
LordMikkel:fix/tui-stdin-pipe

Conversation

@LordMikkel
Copy link
Copy Markdown

@LordMikkel LordMikkel commented May 20, 2026

Issue for this PR

Closes #28538

Related to #387, #24195 and #3930.
The root cause was never addressed. This PR includes an actual fix.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When stdin is piped, the TUI renderer was reading input from the pipe
instead of the terminal, which broke keyboard control completely,
ANSI noise, no interaction.

The run command already handled this with resolveInteractiveStdin(),
but tui was missing it. This PR applies the same fix: pass the
controlling TTY (/dev/tty on Linux, CONIN$ on Windows) to the renderer
while still consuming the piped content as the prompt.

How did you verify your code works?

  • opencode < test-prompt.txt
  • echo "hello" | opencode
  • opencode --prompt "hello"
  • opencode run < test-prompt.txt

Screenshots / recordings

with the PR:
image

image

without the PR (looh the issue):

Image image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.

TUI freeze and show stray ANSI escape codes with piped or redirected stdin

1 participant