Conversation
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #48776
Type of change
What does this PR do?
On Windows ConPTY stacks (Alacritty + zellij), exiting opencode left the terminal
in a raw/corrupted state and, in some setups, terminated the parent shell/pane.
Two things caused it:
@opentui/core's native renderer teardown closes the shared console handle onWindows, which kills the parent shell / zellij pane. The OS releases that
handle when the process exits, so the call is skipped on
win32.\x1b[?1049l(leave alternate screen), which races withprocess teardown on ConPTY and can also kill the pane. It is replaced with
\x1b[2J\x1b[H(clear screen + home) instead.The reset now also runs synchronously via
fs.writeSyncon every exit path(
/exit, SIGHUP, SIGTERM, andprocess.on("exit")).How did you verify your code works?
bun typecheckinpackages/tui— no new errors (baseline and patched treesreport identical counts).
bun run lint(oxlint) — no new findings.opencode-windows-x64with the repo-pinned bun (script/build.ts --single),smoke test (
--version) passed.open/
/exitcycles leave zellij intact and the screen clean, and the sessionepilogue still prints.
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Recording from the earlier repro/discussion on the same stack:
https://github.com/user-attachments/assets/8c574259-de03-4b0c-a6db-089e671562dc
Checklist