Skip to content

tui: resizing the terminal exits the session on Windows #51167

Open

Description

@cjq02

Summary

On Windows, resizing the terminal window while the full-screen TUI is running terminates the opencode session. It reproduces both in a plain Windows PowerShell console (classic conhost) and in IntelliJ IDEA's integrated terminal, so it is not specific to one terminal emulator or to ConPTY. The exit is silent: nothing is printed, and nothing is written to opencode's log.

Environment

  • opencode version: 2.0.16
  • OS: Windows 10 Pro 1909, build 10.0.18363.418 (win32 x64)
  • Terminal: classic Windows console (conhost) via Windows PowerShell; also reproduces in IntelliJ IDEA 2026.2.3 integrated terminal (pty4j WinConPtyProcess). Windows Terminal is not installed on this machine (wt.exe absent, no WindowsTerminal AppX package, WT_SESSION unset).
  • Shell: Windows PowerShell 5.1 (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe); ComSpec=C:\Windows\system32\cmd.exe
  • Install/channel: standalone Windows x64 binary (https://opencode.ai/files/bin/2.0.16/opencode-windows-x64.zip), channel latest
  • Active plugins: none configured. No opencode.json/opencode.jsonc exists in ~/.config/opencode, the project root, or .opencode/. The log's plugins=12 refers to built-in plugins.

Reproduction

  1. On Windows 10 1909, open Windows PowerShell (a plain conhost window).
  2. cd into a project and run opencode.
  3. While the TUI is running, drag the console window border to change its width or height.
  4. The opencode session terminates and control returns to the shell.

The same steps inside IntelliJ IDEA 2026.2.3's integrated terminal also terminate the session.

Expected Behavior

The TUI should handle the resize and keep running, reflowing or redrawing the layout.

Actual Behavior

The session exits immediately on resize. No error text is printed, and ~/.local/share/opencode/log/opencode.log contains no exit or error record for the CLI process — the last entries for that run are ordinary startup and plugin-reconciliation lines. Windows Error Reporting has no crash event for opencode.exe. This looks like the process is being terminated from the console layer rather than exiting on its own.

Additional Context

  • Frequency: consistent — every resize terminates the session.
  • Reproduced on v2.0.16; observed on earlier installs as well.
  • On the server side, the matching client disconnect shows up only as an interrupted event stream:
    cause="InterruptError: All fibers interrupted without error
      at ServerProcess.start (B:/~BUN/root/chunk-*.js) ... http.url=/api/event http.status=200
    
  • In the IntelliJ case, the IDE log shows the console layer failing at the same moment:
    WARN  LocalTerminalTtyConnector - Failed to send Ctrl+C to WinConPtyProcess, alive:true
          com.pty4j.windows.conpty.LastErrorExceptionEx: WriteFile stdout failed:
          GetLastError() returned 232 (the pipe is being closed)
    SEVERE com.jediterm.terminal.model.TerminalTextBuffer - Attempt to get line out of bounds: 13 >= 13
    
  • Possibly related existing reports: TUI crashes when resizing terminal window (Windows / CMD) #7943 (resize crash on Windows/CMD, closed as not planned), Change window size doesn't work in 1.0.7 + windows terminals #3676 (resize does not update the UI on Windows, works in WSL), bug: TUI exit closes terminal window on Windows #22003 (root-caused to console detachment on Windows — notes no CTRL_CLOSE_EVENT is fired and GetConsoleWindow() becomes 0x0), [FEATURE]: Add safe TUI rendering mode for old Windows conhost terminals #28324 (request for a safe rendering mode on classic conhost, closed as not planned).
  • The environment uses an old console stack: Windows 10 1909 (build 18363) predates the current ConPTY/conhost work. On the same machine the AppX/MSIX subsystem is also broken — a PowerShell 7.6 MSIX package installs but cannot activate, and winget's msstore source fails with a certificate mismatch — which suggests outdated system components.
  • Workarounds being evaluated: opencode mini, OTUI_USE_ALTERNATE_SCREEN=0, OTUI_NO_NATIVE_RENDER=1.
  • The resize exit code could not be captured: the process is terminated and no
    exit status is surfaced back to the shell.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I couldn't reproduce this here: it happens only in Windows consoles (classic conhost and IntelliJ's ConPTY terminal), and the sandbox I run in is Linux, so it needs a maintainer with a Windows machine.

    Things that would help whoever picks this up:

    • Whether it still happens on the latest 2.x release.
    • Whether any of the workarounds you listed (opencode mini, OTUI_USE_ALTERNATE_SCREEN=0, OTUI_NO_NATIVE_RENDER=1) stops the exit.
    • Any crash text you can capture. For example, run opencode from cmd.exe, resize, then run echo %ERRORLEVEL%. Or run it in another ConPTY host and look for a bun.report URL.

    Related: #54258 reports the same resize crash on v1. It includes a ConPTY harness, and its decoded stack traces point to OpenTUI's native resize call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions