Repository navigation
opencode (default mode) closes entire terminal window on Linux / i3wm #24077
Description
Description
Summary
Running the opencode command in its default mode (which starts both the server and the TUI in the same process) causes the entire terminal window to close — not just the opencode process exiting, but the emulator window itself disappearing. Running opencode serve and opencode attach <url> as two separate processes works perfectly, which strongly suggests the bug is in the combined server+TUI startup path.
Environment
- opencode version: 1.14.21
- OS: Ubuntu (Linux)
- Window manager: i3wm
- Shell: zsh with oh-my-zsh
- Terminal emulators tested (all reproduce the bug): xterm, Terminator, GNOME Terminal
- Installation path:
~/.opencode/bin/opencode - Installation method: curl installer (
curl -fsSL https://opencode.ai/install | bash) — inferred from binary location at~/.opencode/bin/opencode
Steps to reproduce
- Open any terminal emulator (xterm, Terminator, GNOME Terminal — all reproduce).
- Run
opencode(default mode, no subcommand). - The TUI briefly appears, then the entire terminal window closes.
Expected behavior
The TUI should start and remain running until the user exits it. The terminal emulator window itself should never be closed by opencode.
Actual behavior
The terminal emulator window disappears entirely. The shell process and the emulator process both terminate. On the next session, running opencode reproduces the same crash.
What works (workaround)
Splitting the server and TUI into two separate processes works reliably:
# Terminal 1
opencode serve --port 4096
# prints: http://127.0.0.1:4096
# Terminal 2
opencode attach http://127.0.0.1:4096In this mode, the TUI runs normally and the terminal does not close. This strongly suggests the bug is in the code path that launches server + TUI in a single process.
Diagnostic work already done
I ran an extensive elimination pass. The following were all tested and ruled out as causes:
| Hypothesis | Test | Result |
|---|---|---|
| Out-of-memory (OOM killer) | free -h, dmesg | grep -i oom |
20 GB RAM free, no OOM records |
| Terminal emulator bug (VTE) | Tested in xterm (non-VTE) | Crash reproduces |
| GPU/renderer issue | Multiple emulators tested | Crash reproduces in all |
| Wrong binary architecture | file $(which opencode) + uname -m |
Correct architecture |
| Corrupted SQLite database | Moved ~/.local/share/opencode/opencode.db* aside |
No change |
| Corrupted config/cache | Moved ~/.config/opencode/, ~/.local/share/opencode/, ~/.cache/opencode/ aside |
No change |
| Shell environment (zsh, oh-my-zsh, fnm, nvm) | env -i HOME=$HOME PATH=/usr/local/bin:/usr/bin:/bin TERM=xterm /bin/bash --noprofile --norc -c '~/.opencode/bin/opencode' |
Crash reproduces |
| External plugins | opencode --pure |
Crash reproduces |
| Server alone | opencode serve |
Works fine |
| TUI alone attaching to external server | opencode attach http://127.0.0.1:PORT |
Works fine |
Strace findings
Running strace -f -o /tmp/opencode-strace.log opencode and grepping for fatal signals showed no SIGSEGV, SIGABRT, SIGKILL, SIGTERM, or SIGHUP delivered to the main opencode process. Child processes exit cleanly with exit_group(0) (one exited with exit_group(1), a grep subprocess whose command resolution I couldn't reconstruct from the log alone). The process disappears without any visible crash signature.
The strace does show child processes resetting job-control signal handlers (SIGTSTP, SIGTTIN, SIGTTOU set to SIG_DFL) and redirecting stdin via dup2(3, 0) — consistent with opencode spawning shell subprocesses for tool calls during startup.
My guess at the mechanism (not confirmed): the process that starts both server and TUI may be reparenting or detaching in a way that causes the controlling-TTY session leader to die, which then propagates up to the emulator. But this is speculation — someone familiar with the opentui integration would be far better placed to diagnose the real cause.
Additional notes
- "Reinstalling" appeared to fix it temporarily in earlier sessions. After full diagnosis, this was likely coincidental timing rather than a real fix — the crash reproduces consistently from a clean state.
- The attach-based workaround is stable and usable indefinitely, so this is not blocking me personally, but the default
opencodecommand being unusable on a common Linux configuration (Ubuntu + i3wm) seems worth fixing.
Plugins
linear (disabled)
OpenCode version
1.14.21
Steps to reproduce
I installed in the morning, and at night or in the next day the problem occurs when I open the opencode. The last times I just reinstalled, but this time I was able to build this workaround.
Screenshot and/or share link
No response
Operating System
Ubuntu 24.04.4 LTS
Terminal
xterm, Terminator, GNOME Terminal
Activity
srivenkateswaran6002 commentedon May 9, 2026
Hi! I noticed this issue open, and I would love to take a look and submit a PR if no one else is currently working on it. Mind if I give it a try?
ernierasta commentedon Jun 3, 2026
The same behavior here (Artix Linux, foot terminal) after update to latest version, 1.14.x (do no remember exact version I had) was ok.
marenamat commentedon Jun 13, 2026
For me, now with 1.17.4 running in a podman container, even if i run
opencode servein one terminal andopencode attachfrom another terminal in the same container,opencode attachcloses thefootterminal emulator.github-actions commentedon Aug 21, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.