fix(opencode): avoid TTY corruption from double cleanup#16565
fix(opencode): avoid TTY corruption from double cleanup#16565nexxeln merged 2 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: I found several related PRs that address similar TTY/terminal corruption issues, though none appear to be exact duplicates of #16565. However, these are worth noting: Related PRs:
These PRs address similar issues (terminal corruption, mouse tracking, CTRL+C handling on Windows), but PR #16565 appears to be focused on a specific double cleanup bug introduced in a particular commit rather than a duplicate of these existing fixes. |
01ef9d7 to
e853c74
Compare
|
Same problem here. I just updated to 1.2.22, and OpenCode in the CLI is completely unusable. I don’t understand how this issue has been going on for a week and nobody noticed, when you can’t even use OpenCode at all. In my case nothing run cleanly. Once you open opencode and press ctrl + p, everything goes does the hill. |
) Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com> (cherry picked from commit 13a68f3)
Issue for this PR
Closes #16564
Type of change
What does this PR do?
When using
--continuemultiple times and exiting with CTRL+C, the terminal enters an inconsistent state where mouse movements produce escape sequences (e.g.^[[<35;9734M). This affects terminal emulators like MinTTY (Git Bash) and PuTTY on Windows.The root cause was a double cleanup introduced in commit 3ebebe0: the
tui()call had bothonExit: stopas a callback and afinally { await stop() }block outside it. On CTRL+C,stop()was called twice, corrupting the TTY state and leaving mouse tracking active.Fix: Either set
onExit: undefinedor remote it (I've done so) so the exit callback no longer callsstop()on its own. Thefinallyblock remains as the single cleanup point, ensuringstop()is called exactly once — both on normal exit and on errors.How did you verify your code works?
Tested manually with multiple
--continueruns and CTRL+C exits:Screenshots / recordings
Checklist