opentui
opentui copied to clipboard
bug: Does not switch to correct screen after suspend
Reproducible with opencode:
https://github.com/user-attachments/assets/58ed1ff4-9efa-47c7-8e41-02b7c165a015
Cause:
Editors like neovim, emacs, etc switch to the alternate screen. If this screen doesn't match the configured screen of the CliRenderer (determined by useAlternateScreen), the terminal clearing commands in performShutdownSequence are applied to the wrong screen.
Fix:
Ensure the correct screen (determined by useAlternateScreen) before starting the render loop, by emitting the appropriate ANSI sequences.
Related to https://github.com/sst/opencode/issues/3648.