[GH-ISSUE #509] Destroy of renderer doesn't call disableMouse #899

Open
opened 2026-03-14 08:58:58 +03:00 by kerem · 1 comment
Owner

Originally created by @Arilas on GitHub (Jan 10, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/509

I'm writing the TUI that finishes with a clear log of what is done, so I have a TUI that after destroying is logging everything important to a stdout/stderr.

The error that I have is that after I destroy the renderer, mouse events are leaking into input of the next command. After investigate I found that destroy and finalizeDestroy doesn't call disableMouse, so mouse escape sequence is not sent.

Originally created by @Arilas on GitHub (Jan 10, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/509 I'm writing the TUI that finishes with a clear log of what is done, so I have a TUI that after destroying is logging everything important to a stdout/stderr. The error that I have is that after I destroy the renderer, mouse events are leaking into input of the next command. After investigate I found that `destroy` and `finalizeDestroy` doesn't call `disableMouse`, so mouse escape sequence is not sent.
Author
Owner

@endernoke commented on GitHub (Jan 17, 2026):

I encountered an related issue while running tests.

Some tests produce a lot of garbage text in the shell after exiting, which came from mouse position reporting.
After investigation, I found the issue to be as follows:

  1. TestRenderer does not setup the terminal to prevent outputting to the terminal
  2. renderer._terminalIsSetup is false
  3. Native code skips disabling mouse during renderer destruction:
    pub fn performShutdownSequence(self: *CliRenderer) void {        logger.info("[ZIG] performShutdownSequence() called, terminalSetup = {}, terminal.state.mouse = {}", .{ self.terminalSetup, self.terminal.state.mouse });
        if (!self.terminalSetup) return;
        // cleanup

Also in this case, the usemouse state between the typescript and native layers are out-of-sync, since zig state.mouse defaults to true but is never updated via setupterminal

<!-- gh-comment-id:3763841821 --> @endernoke commented on GitHub (Jan 17, 2026): I encountered an related issue while running tests. Some tests produce a lot of garbage text in the shell after exiting, which came from mouse position reporting. After investigation, I found the issue to be as follows: 1. `TestRenderer ` does not setup the terminal to prevent outputting to the terminal 2. `renderer._terminalIsSetup` is false 3. Native code skips disabling mouse during renderer destruction: ```zig pub fn performShutdownSequence(self: *CliRenderer) void { logger.info("[ZIG] performShutdownSequence() called, terminalSetup = {}, terminal.state.mouse = {}", .{ self.terminalSetup, self.terminal.state.mouse }); if (!self.terminalSetup) return; // cleanup ``` Also in this case, the usemouse state between the typescript and native layers are out-of-sync, since zig `state.mouse` defaults to true but is never updated via setupterminal
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#899
No description provided.