You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: TUI exit closes terminal window on Windows #22003
On Windows (Windows Terminal + cmd.exe), exiting the TUI via Ctrl+D, /exit, or /quit causes the terminal window to close instead of returning to the shell prompt.
Steps to reproduce
Open Windows Terminal with cmd.exe
Run opencode (or bun run dev from source)
Press Ctrl+D to exit the TUI
Expected: Terminal stays open, shell prompt appears, user can type
Actual: Terminal window closes after a few seconds
Root cause
The worker's graceful shutdown process kills MCP server subprocesses (e.g. appliance-sql-guard, logic_guard). On Windows, these subprocess exits detach the main process from its console (GetConsoleWindow() transitions from a valid handle to 0x0). This causes cmd.exe to lose its console and exit, which closes the Windows Terminal tab.
Both worker.terminate() and await client.call("shutdown") trigger this — the former crashes the console immediately, the latter destroys it during MCP subprocess cleanup.
Diagnosed using kernel32 FFI monitoring (SetConsoleCtrlHandler + GetConsoleWindow polling). No CTRL_CLOSE_EVENT is fired — the console is silently detached.
Activity
suqiernb commentedon May 21, 2026
ec36339 commentedon Jul 3, 2026
Similar behavior with 1.17.13 and Bash in Windows Terminal.
github-actions commentedon Sep 2, 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.
Elvin-zhujunde commentedon Sep 14, 2026
If you are PowerShell, before starting, try setting $env:OTUI_USE_ALTERNATE_SCREEN=0 and then restart. The same applies to other terminals.