fix: disable mouse tracking on Windows terminal exit#153
fix: disable mouse tracking on Windows terminal exit#153Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Conversation
Add explicit terminal state reset sequences after renderer cleanup to ensure
SGR mouse tracking is properly disabled on exit. On Windows, the terminal may
still report mouse events as raw escape sequences if mouse tracking wasn't
fully disabled. This fix adds:
1. resetTerminalState() function that writes disable sequences for:
- Normal and button-event mouse tracking
- Any-event mouse tracking (all movement)
- SGR extended mouse mode
- RXVT mouse mode
- Kitty keyboard protocol
- Text attributes
2. Calls resetTerminalState() in three exit paths:
- Normal exit via ExitProvider (exit/quit/:q commands)
- Error boundary Ctrl+C handler
- process.on('exit') safety net for all other exits
Fixes #151
|
Hi! Thank you for taking the time to contribute to this project—we really appreciate it. 🙏 We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, and the moment has come to promote this repository to become the main repository. To do that, we moved the code from this repository to the kilocode repository. This unfortunately means we cannot merge this branch here anymore. Please add https://github.com/Kilo-Org/kilocode.git as a remote, and push your branch there and create a new PR in https://github.com/Kilo-Org/kilocode . We unfortunately cannot do this for you as then the PR would not be in your name anymore. If you need any help, feel free to ask on our Discord in #kilo-dev-contributors Sorry for the inconvenience and thank you for contributing to Kilo! |
|
Can I get Champions Program credits for this PR? |
|
Hi @Ashwinhegde19 , without a review, the PR is not ready to merge. I'm sorry for causing the extra work, but you should be able to recreate these PRs on the kilocode repository without extra programming; just add the kilocode repository as a remote, push your branch, and create the PR again. Since that repository has the same git history as this one no rebasing/merging or whatever will even be necessary. So locally in your branch: |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Summary
Fixes GitHub Issue Kilo-Org/kilocode#6328: After closing the CLI on Windows, mouse movement inserts raw escape sequences like
[555;27;21Minto the terminal. These are SGR mouse tracking events that should have been disabled on exit.Solution
Added explicit terminal state reset sequences after renderer cleanup to ensure all mouse tracking modes are properly disabled, regardless of the exit path:
New
resetTerminalState()function that writes disable sequences for:\x1b[?1000l)\x1b[?1002l)\x1b[?1003l)\x1b[?1006l)\x1b[?1015l)\x1b[<u)\x1b[0m)Three exit path handlers:
/exit,quit,:qcommands)process.on('exit')safety net for all other exit pathsTest Plan
Test on your Windows machine by:
bun dev/exitcommand, typingexit/quit/:q