Repository navigation
Description
Bug Description
When running opencode inside a tmux session, the TUI renders correctly but is completely unresponsive to all keyboard input. No keys register — typing, arrow keys, Enter, Escape, Ctrl+C, keyboard shortcuts all silently ignored. The UI appears frozen. Works perfectly outside tmux.
Environment
- OS: macOS (Apple Silicon, arm64)
- Terminal: Ghostty
- tmux: next-3.7
- opencode version: 0.0.0-dev-202604251526 (April 25, 2026 dev build)
- Installation: via Bun (
bunx opencode-ai@latest) - Shell: zsh
Root Cause Found
The debug log (--print-logs --log-level DEBUG) reveals the failure:
ERROR service=server-proxy e=setRawMode failed with errno: 9 exception
ERROR service=server-proxy error=setRawMode failed with errno: 9 process error
errno 9 = EBADF (Bad file descriptor). The setRawMode() call tries to operate on a file descriptor that is not a valid terminal.
Why This Happens (TTY Discrepancy)
Inside tmux, the process environment differs from outside:
stdin(fd 0): IS a TTY —[ -t 0 ]returns truestdout(fd 1): NOT a TTY —[ -t 1 ]returns falsettycommand returns/dev/ttys006(valid PTY)
Outside tmux, both stdin and stdout are TTYs.
Conclusion: setRawMode() is called on the stdout file descriptor (fd 1), which is not a TTY inside tmux, causing the EBADF failure. The correct file descriptor for raw mode is stdin (fd 0), since raw mode controls input buffering.
Reproduction Steps
- Start a tmux session:
tmux - Run opencode:
opencode - OpenCode TUI renders (UI elements visible)
- Try to type anything — no input is registered
- Run with debug logging:
OPENCODE_LOG_LEVEL=DEBUG opencode --print-logs --log-level DEBUG 2>/tmp/op-debug.log - Check the log for:
setRawMode failed with errno: 9
What Was Tested (Bisect)
- Tmux config is NOT the cause: Tested 7 progressive tmux configs (minimal → full), all produce same error
- Confirmed: A minimal Bubble Tea v1.3.10 program (
tea.WithAltScreen()) works correctly inside all tmux configs — keyboard input is received normally - Confirmed:
sttyshows terminal is in canonical mode (icanon) inside tmux, confirming raw mode was never set - Confirmed: Running outside tmux shows no
setRawModeerror
Workaround
None found. Setting extended-keys always, removing allow-passthrough, or using a minimal tmux configuration does not resolve the issue.
Possible Fix Direction
setRawMode()should use the stdin file descriptor (fd 0) instead of stdout (fd 1), since raw mode is about disabling input line buffering- Or opencode's TUI initialization should detect when stdout is not a TTY and fall back to stdin for raw mode control
- Compare with Bubble Tea v1.3.10's
NewProgramwhich works correctly inside tmux
Related Issues
- #16351 — "TUI broken in tmux after 1.2.17" (identical symptoms, regression reverted)
- OC-9232 — "setRawMode failed with errno: 5 (EIO)" when terminal disconnects
- OC-8787 — Missing SIGHUP handler causes orphaned processes
- OC-9972 — Terminal escape sequences printed on startup in tmux
- #10610 — TUI leaves terminal in raw mode after exit
Logs
Complete error log:
INFO 2026-04-25T18:07:49 +252ms service=server-proxy version=0.0.0-dev-202604251526 args=["--print-logs"] process_role=main run_id=641a2824-b437-4873-9634-5bf28b0e7e70 opencode
ERROR 2026-04-25T18:07:50 +1124ms service=server-proxy e=setRawMode failed with errno: 9 exception
ERROR 2026-04-25T18:07:50 +1ms service=server-proxy error=setRawMode failed with errno: 9 process error
Activity
github-actions commentedon Apr 25, 2026
This issue might be a duplicate of existing issues. Please check:
If your problem persists on the current version and differs from the above (e.g. different root cause or environment), please clarify so maintainers can distinguish this from prior reports.
lonelygo commentedon Apr 26, 2026
I also encountered the same problem. When starting opencode in
tmux, only theTUIis visible, but any keyboard input does not respond, and the process can only be killed withkill -9. However, it works normally in the terminal.tmux 3.6a
opencode 1.14.25
os macos 26.4.1
cmux 0.63.2
polo871209 commentedon Apr 26, 2026
I can confirm the same and 1.14.24 work for me I just downgrade
mesterM12 commentedon Apr 26, 2026
I have had the same issue. using ghostty and tmux as well as using the default terminal app both fully hang when opened to the point where the entire app is unresponsive. I have downgraded to version 1.14.24 and everything seems to be working fine in that version. tmux 3.6a , opencode 1.14.25 ( the one with the issue ) , os macos 26.4.1 .
kommander commentedon Apr 26, 2026
Did 1.14.26 improve?
mesterM12 commentedon Apr 26, 2026
Yes the issue is resolved for me! thank you so much!