Repository navigation
Description
Description
OpenCode CLI's TUI intermittently leaves the terminal in a corrupted state when exiting via /exit while running inside Alacritty + Zellij on Windows. No response/confirmation is needed from the maintainers below — this is a bug report.
Environment
- OS: Windows 11 (10.0.26200)
- Terminal: Alacritty 0.17.0
- Multiplexer:
arndawg.zellij-windows0.43.1-win32.5 (community fork; zellij has no official Windows support) - OpenCode version: 1.18.30
- Shell in pane: PowerShell / pwsh
Expected behavior
Exiting via /exit closes OpenCode cleanly and returns to the pane's shell, leaving the Zellij pane usable (and showing the session-reminder message so the session can be resumed). This occasionally happens — the correct behavior — but the result is unpredictable across runs.
Actual (erratic) behavior
Three different outcomes occur non-deterministically:
- Pane closes too: exiting via
/exitsometimes also drops the whole Zellij pane. - Clean exit: only OpenCode closes; the pane stays alive and usable (expected).
- Corrupted terminal state: before any exit, the app freezes and a series of strange characters appears at the bottom of the pane "as if the terminal were available when it is not". Pressing keys or moving the mouse then emits further gibberish — a mix of special characters, numbers and closing brackets (typical of leaked raw-mode sequences, e.g. raw mouse-report sequences like
ESC[<...M).
Root-cause hypothesis
The TUI renderer is acquired with Effect.acquireRelease(...) and calls destroyRenderer() on release, which exits the alternate screen buffer and restores cooked terminal mode (see packages/tui/src/app.tsx). If that cleanup is bypassed — process.exit(), SIGKILL, or the renderer release being interrupted when the multiplexer tears down the PTY — the terminal remains in raw mode on the alternate screen. Under Windows ConPTY with a second Pty layer (the zellij-windows fork), the mode reset is not propagated to the outer terminal when the process dies uncleanly, so subsequent input/output prints uninterpreted escape sequences.
Mouse reporting is enabled by default (useMouse), which accounts for the numeric/bracket garbage once the terminal state has leaked.
Steps to reproduce
- Launch Alacritty.
- Start
zellij(0.43.1-win32.5). - In a pane, run
opencode. - Use the TUI normally, then exit via
/exit. - Repeat several times (also try closing the pane while OpenCode is running).
Observe the three outcomes above. Once in the corrupted state, any keypress/mouse move prints additional raw escape sequences until the pane is force-closed.
Suggested areas to investigate
- Guarantee
destroyRenderer()runs on every exit path (clean/exit, Ctrl+C, process exit, and external PTY close). - Consider a fallback (e.g. atexit/signal handler) that force-resets the terminal (
\x1b[0m, leave alternate screen, disable mouse reporting, restore cooked mode) even on abnormal termination. - Test under a single ConPTY layer (plain Alacritty tab, no zellij) to confirm the multi-Pty ConPTY interaction.
Activity
github-actions commentedon Sep 13, 2026
This issue might be a duplicate of existing issues. Please check:
kraso commentedon Sep 13, 2026
Thanks for flagging the related issues. Confirming the duplicates noted, and consolidating the evidence here since the fix affects all of them.
Related issue family (all OPEN, no fix landed yet):
/exit/exitinside a multiplexer (rmux)kill -1) to ALL user processes, killing the whole session including the terminalWhat this issue adds (canonical Windows reproduction):
/exitkill -1bug (macOS: exit/cleanup path broadcasts SIGTERM to ALL user processes (kill -1) — kills Ghostty, Terminal, Chrome, entire session (1.18.24 & 1.18.25) #45938), which is likely the same shutdown-cleanup flaw: the renderer'sdestroyRenderer()state restore is bypassed on unclean exit, so raw mode/altscreen/mouse-tracking are never reset on the PTYHappy to close this as a duplicate in favor of whichever canonical issue the maintainers prefer — the video and Windows repro can be attached to that one instead.
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊