Skip to content

Conversation

@simonklee
Copy link
Contributor

The destroy path was not explicitly disabling mouse tracking before tearing down native resources. While the zig-side
performShutdownSequence() checks terminal.state.mouse, this relies on state synchronization that can fail silently in edge cases.

Add explicit disableMouse() call in finalizeDestroy(), same as we do in suspend(), to send disable mouse escape sequence to the terminal before the renderer is freed.

Fixes: #509

The destroy path was not explicitly disabling mouse tracking before
tearing down native resources. While the zig-side
performShutdownSequence() checks terminal.state.mouse, this relies
on state synchronization that can fail silently in edge cases.

Add explicit disableMouse() call in finalizeDestroy(), same as we do
in suspend(), to send disable mouse escape sequence to the terminal
before the renderer is freed.

Fixes: anomalyco#509
@kommander
Copy link
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
Contributor 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
Collaborator

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

@simonklee
Copy link
Contributor 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
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

2 participants