fix: disable mouse tracking on abnormal exit to prevent terminal garbage#1503
Open
Ivaloz wants to merge 3 commits into
Open
fix: disable mouse tracking on abnormal exit to prevent terminal garbage#1503Ivaloz wants to merge 3 commits into
Ivaloz wants to merge 3 commits into
Conversation
added 3 commits
July 1, 2026 09:06
Add signal handlers for SIGINT, SIGTERM, and beforeExit to ensure terminal cleanup (raw mode, alternate screen buffer) happens even when the process is killed by model errors or external signals. Fixes: Terminal scrolling persists after CTRL+C exit, and session resume crashes due to corrupted terminal state.
When MiMo-Code exits abnormally (crash, external kill, Ctrl+C), the
terminal mouse tracking modes (X10, VT200, button-event, any-event, SGR)
were not being reset. This caused the terminal to continuously output
SGR mouse coordinate sequences like [555;106;49M when moving the mouse
after exit.
Fix by:
1. Adding a cross-platform disableMouseTracking() function that sends
the appropriate CSI sequences to turn off all mouse tracking modes
2. Registering a process.on('exit') handler to ensure cleanup runs
even on abnormal exits
3. Calling disableMouseTracking() in the normal shutdown path as well
Fixes XiaomiMiMo#1458
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
When MiMo-Code exits abnormally (crash, external kill, Ctrl+C), the terminal mouse tracking modes were not being reset. This caused the terminal to continuously output SGR mouse coordinate sequences like [555;106;49M\ when moving the mouse after exit, making the terminal unusable.
Test Plan
Fixes #1458