Skip to content

fix(renderer): disable mouse tracking on destroy#515

Merged
simonklee merged 1 commit intoanomalyco:mainfrom
simonklee:destroy-disable-mouse
Apr 8, 2026
Merged

fix(renderer): disable mouse tracking on destroy#515
simonklee merged 1 commit intoanomalyco:mainfrom
simonklee:destroy-disable-mouse

Conversation

@simonklee
Copy link
Copy Markdown
Member

@simonklee simonklee commented Jan 12, 2026

The destroy path was not explicitly disabling mouse tracking before tearing down native resources.

Best-effort mouse cleanup now lives in native terminal shutdown instead of
TypeScript destroy state. Track whether mouse was ever enabled so teardown
still emits disable sequences after state drift, while skipping unnecessary
resets when mouse was never active.# Please enter the commit message for your
changes.

Fixes: #509

@kommander
Copy link
Copy Markdown
Collaborator

Interesting. Just out of curiosity, do you know in what edge cases that would happen? I wonder because other states might be out of sync then as well.

@simonklee
Copy link
Copy Markdown
Member Author

Interesting. Just out of curiosity, do you know in what edge cases that would happen? I wonder because other states might be out of sync then as well.

No specific repro beyond #509, but the class of edge cases is 'write didn't reach the TTY.' errors are swallowed, so if stdout is closed/piped or a write fails, the terminal can still be in mouse mode while state says false. This just sends a best‑effort disable before teardown. Other state flags could drift under the same failure mode, but i haven't looked into it extensively.

@kommander
Copy link
Copy Markdown
Collaborator

Got it. But the native teardown is called always, so it could just unconditionally disable mouse?

@simonklee
Copy link
Copy Markdown
Member Author

Got it. But the native teardown is called always, so it could just unconditionally disable mouse?

Let me go through the call paths again to make sure i understand it.

@simonklee simonklee marked this pull request as draft January 12, 2026 19:41
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 2, 2026

@opentui/core

npm i https://pkg.pr.new/@opentui/core@515

@opentui/react

npm i https://pkg.pr.new/@opentui/react@515

@opentui/solid

npm i https://pkg.pr.new/@opentui/solid@515

@opentui/core-darwin-arm64

npm i https://pkg.pr.new/@opentui/core-darwin-arm64@515

@opentui/core-darwin-x64

npm i https://pkg.pr.new/@opentui/core-darwin-x64@515

@opentui/core-linux-arm64

npm i https://pkg.pr.new/@opentui/core-linux-arm64@515

@opentui/core-linux-x64

npm i https://pkg.pr.new/@opentui/core-linux-x64@515

@opentui/core-win32-arm64

npm i https://pkg.pr.new/@opentui/core-win32-arm64@515

@opentui/core-win32-x64

npm i https://pkg.pr.new/@opentui/core-win32-x64@515

commit: 081cc87

@erikjoachim
Copy link
Copy Markdown

hey! found this while tracking and figuring a mouse escape sequence issue in opencode.

noticed the fix checks this._useMouse which only covers click tracking (?1000). since enableMouse() passes both _useMouse AND enableMouseMovement to the native lib, should the destroy cleanup also handle both?

mouse movements also leak escape sequences after exit, so maybe just call disableMouse() unconditionally?

- if (this._useMouse) {
-   this.disableMouse()
- }
+ this.disableMouse()

also looks like this is in draft - any plans to move it forward? 😄

@simonklee simonklee force-pushed the destroy-disable-mouse branch 2 times, most recently from 51f08c3 to dab23e5 Compare April 8, 2026 19:58
@simonklee simonklee marked this pull request as ready for review April 8, 2026 19:58
@simonklee simonklee force-pushed the destroy-disable-mouse branch from dab23e5 to e97726d Compare April 8, 2026 20:13
Best-effort mouse cleanup now lives in native terminal shutdown instead of
TypeScript destroy state. Track whether mouse was ever enabled so teardown
still emits disable sequences after state drift, while skipping unnecessary
resets when mouse was never active.# Please enter the commit message for your
changes.

Fixes: anomalyco#509
@simonklee simonklee force-pushed the destroy-disable-mouse branch from e97726d to 96d681e Compare April 8, 2026 20:47
@simonklee simonklee merged commit 7b71b44 into anomalyco:main Apr 8, 2026
14 checks passed
@simonklee simonklee deleted the destroy-disable-mouse branch April 8, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Destroy of renderer doesn't call disableMouse

3 participants