[PR #764] [MERGED] fix(mouse): honor enableMouseMovement during mouse mode enable/restore #1542

Closed
opened 2026-03-14 09:42:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/764
Author: @aarcamp
Created: 3/2/2026
Status: Merged
Merged: 3/2/2026
Merged by: @kommander

Base: mainHead: fix-enable-mouse-movement


📝 Commits (3)

  • 18d2740 fix(mouse): honor enableMouseMovement during mouse mode enable/restore
  • 43cd956 Merge branch 'main' into fix-enable-mouse-movement
  • 3f2ad95 Clean up comments in restoreTerminalModes function

📊 Changes

3 files changed (+90 additions, -8 deletions)

View changed files

📝 packages/core/src/zig/renderer.zig (+2 -3)
📝 packages/core/src/zig/terminal.zig (+24 -5)
📝 packages/core/src/zig/tests/terminal_test.zig (+64 -0)

📄 Description

Currently, the boolean enableMouseMovement value is ignored as passed to the createCliRenderer() function. This change set solves the issue by carrying the setting through to the setMouseMode() routine, saving it to the mouse state, and writing the appropriate ANSI sequence to disable or enable "any-event" tracking. restoreTerminalModes() is also updated to send the right sequences.

Basic unit tests are included to test the desired behaviors.

I noticed this when running an OpenTUI application on a remote server through SSH and the connection was lost while the app was running. Afterward, as soon as I moved the mouse, I saw a bunch of garbage in my terminal and iTerm2 began complaining about mouse reporting left on. I was anticipating this to happen only for mouse clicks, not mouse movement, so I kept digging until I found the missing handling.

Tested the fix with both iTerm2 Build 3.6.6 and Ghostty Version 1.2.3. I was not able to identify any existing GitHub issues covering this problem.

Test output:

~/src/opentui/packages/core ▸ bun run test:native -- -Dtest-filter="setMouseMode"
$ cd src/zig && zig build test --summary all "-Dtest-filter=setMouseMode"

Build Summary: 7/7 steps succeeded; 2/2 tests passed
test success
└─ run test 2 passed 1ms MaxRSS:2M
   └─ compile test Debug native success 234ms MaxRSS:146M
      ├─ options cached
      ├─ run exe uucode_build_tables (tables.zig) cached
      │  └─ compile exe uucode_build_tables Debug native cached 6ms MaxRSS:39M
      │     └─ WriteFile build_config.zig cached
      └─ WriteFile build_config.zig (reused)

~/src/opentui/packages/core ▸ bun run test:native -- -Dtest-filter="restoreTerminalModes"
$ cd src/zig && zig build test --summary all "-Dtest-filter=restoreTerminalModes"

Build Summary: 7/7 steps succeeded; 1/1 tests passed
test success
└─ run test 1 passed 1ms MaxRSS:2M
   └─ compile test Debug native cached 5ms MaxRSS:39M
      ├─ options cached
      ├─ run exe uucode_build_tables (tables.zig) cached
      │  └─ compile exe uucode_build_tables Debug native cached 6ms MaxRSS:40M
      │     └─ WriteFile build_config.zig cached
      └─ WriteFile build_config.zig (reused)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/764 **Author:** [@aarcamp](https://github.com/aarcamp) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@kommander](https://github.com/kommander) **Base:** `main` ← **Head:** `fix-enable-mouse-movement` --- ### 📝 Commits (3) - [`18d2740`](https://github.com/anomalyco/opentui/commit/18d2740dc020c95af0244d9a00c1b03cd39bde8d) fix(mouse): honor enableMouseMovement during mouse mode enable/restore - [`43cd956`](https://github.com/anomalyco/opentui/commit/43cd9561d31a23726a7802e0e9af37d7404978a0) Merge branch 'main' into fix-enable-mouse-movement - [`3f2ad95`](https://github.com/anomalyco/opentui/commit/3f2ad95dfe8136d86c11e5870b20dd62025f69f6) Clean up comments in restoreTerminalModes function ### 📊 Changes **3 files changed** (+90 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/zig/renderer.zig` (+2 -3) 📝 `packages/core/src/zig/terminal.zig` (+24 -5) 📝 `packages/core/src/zig/tests/terminal_test.zig` (+64 -0) </details> ### 📄 Description Currently, the boolean `enableMouseMovement` value is ignored as passed to the createCliRenderer() function. This change set solves the issue by carrying the setting through to the setMouseMode() routine, saving it to the mouse state, and writing the appropriate ANSI sequence to disable or enable "any-event" tracking. restoreTerminalModes() is also updated to send the right sequences. Basic unit tests are included to test the desired behaviors. I noticed this when running an OpenTUI application on a remote server through SSH and the connection was lost while the app was running. Afterward, as soon as I moved the mouse, I saw a bunch of garbage in my terminal and iTerm2 began complaining about mouse reporting left on. I was anticipating this to happen only for mouse clicks, not mouse movement, so I kept digging until I found the missing handling. Tested the fix with both iTerm2 Build 3.6.6 and Ghostty Version 1.2.3. I was not able to identify any existing GitHub issues covering this problem. Test output: ``` ~/src/opentui/packages/core ▸ bun run test:native -- -Dtest-filter="setMouseMode" $ cd src/zig && zig build test --summary all "-Dtest-filter=setMouseMode" Build Summary: 7/7 steps succeeded; 2/2 tests passed test success └─ run test 2 passed 1ms MaxRSS:2M └─ compile test Debug native success 234ms MaxRSS:146M ├─ options cached ├─ run exe uucode_build_tables (tables.zig) cached │ └─ compile exe uucode_build_tables Debug native cached 6ms MaxRSS:39M │ └─ WriteFile build_config.zig cached └─ WriteFile build_config.zig (reused) ~/src/opentui/packages/core ▸ bun run test:native -- -Dtest-filter="restoreTerminalModes" $ cd src/zig && zig build test --summary all "-Dtest-filter=restoreTerminalModes" Build Summary: 7/7 steps succeeded; 1/1 tests passed test success └─ run test 1 passed 1ms MaxRSS:2M └─ compile test Debug native cached 5ms MaxRSS:39M ├─ options cached ├─ run exe uucode_build_tables (tables.zig) cached │ └─ compile exe uucode_build_tables Debug native cached 6ms MaxRSS:40M │ └─ WriteFile build_config.zig cached └─ WriteFile build_config.zig (reused) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:42:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1542
No description provided.