fix: disable mouse tracking on terminal exit (#838)#841
Open
MrRealORG wants to merge 1 commit into
Open
Conversation
When MiMo Code is killed by an external process (SIGTERM, another TUI
tool, etc.), the renderer may not complete its teardown, leaving the
terminal in mouse-tracking mode. This causes garbage escape sequences
like [555;row;colM on every mouse movement.
Fix:
- Add mouse tracking disable sequences to the async exit handler's
ANSI cleanup string (modes 1000, 1002, 1003, 1005, 1006, 1015)
- Register a synchronous process.on('exit') hook as a safety net —
this runs even when the async exit cannot complete (e.g. SIGTERM
from an external process), ensuring cleanup always happens
Summary
ProblemWhen MiMo Code is killed by signal (e.g. another TUI tool like Qoder terminates it), the terminal's mouse event tracking is not properly disabled. This leaves the terminal in mouse-tracking mode, producing garbage escape sequences on every mouse move. Root Cause
FixPrepend TEST Closes #838 |
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.
Summary
Fixes #838: terminal mouse tracking not cleaned up on abnormal exit.
Problem
When MiMo Code is killed by an external process (e.g. another TUI tool), the terminal mouse event tracking escape sequences are not disabled. This leaves the terminal in mouse-tracking mode, causing garbage output like
[555;row;colMon every mouse movement.Root Cause
The exit handler in
exit.tsxwrites SGR reset + cursor show + OSC color resets, but does not send mouse tracking disable sequences. Therenderer.destroy()should handle this during normal exit, but on abnormal exit (SIGTERM from external process), the renderer teardown may not complete.Fix
Two-layer defense:
Async exit handler: Added mouse tracking disable sequences (modes 1000, 1002, 1003, 1005, 1006, 1015) to the ANSI cleanup string that runs during the normal exit flow.
Synchronous
process.on("exit")hook: A safety net that runs even when the async exit handler cannot complete (e.g. SIGTERM from an external process). Node.js guaranteesprocess.on("exit")callbacks run synchronously before the process exits, regardless of how the process was signaled.Mouse modes disabled
Test Plan
kill -TERM <pid>from another terminal → verify no garbage on mouse moveCloses #838