-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Description
Description
Summary
When using TUI with --continue multiple times and exiting with CTRL+C, mouse control characters appear on subsequent runs in certain terminal emulators. The terminal enters an inconsistent state where mouse movements produce escape sequences.
Expected Behavior
Terminal should remain in consistent state after CTRL+C exit. Mouse control characters should not appear on subsequent runs.
Actual Behavior
After exiting with CTRL+C and restarting with --continue, mouse movements produce escape sequences like:
^[[<35;9734M
^[[<35;9834M
^[[<35;9934M
The characters vary depending on mouse position and movement direction.
Affected Environments
This issue only occurs in certain terminal emulators. Tested and confirmed affected:
- Windows with MinTTY
- Windows with PuTTY
- Other terminal emulators with incomplete TTY state restoration
Root Cause
The problematic commit 3ebebe0 introduced a try/finally block around tui() call that caused double cleanup:
const tuiPromise = tui({
...,
onExit: stop,
})
try {
await tui({..., onExit: stop})
} finally {
await stop() // Called again!
}When CTRL+C is pressed:
onExit: stopis called inside tui()finally { await stop() }is called outside tui()
This double cleanup corrupts the TTY state, leaving mouse tracking active when it should be disabled. Some terminal emulators are more sensitive to this TTY state corruption than others.
Related Issues
This issue prevents proper usage of the TUI across multiple sessions with --continue in certain terminal environments.
Plugins
none during debugging
OpenCode version
1.2.17, 1.2.18, 1.2.19, 1.2.20, 1.2.21, dev
Steps to reproduce
- Run opencode TUI with
--continue - Exit with CTRL+C
- Run opencode TUI again with
--continue - Observe mouse control characters appearing when moving the mouse
Screenshot and/or share link
Operating System
Debian Linux, Trixie, 64-bit
Terminal
Windows: MinTTY, PuTTY