Skip to content

Conversation

@perdream
Copy link

Fixes #6912

Problem

Mouse tracking ANSI sequences were not being disabled when exiting via /exit
command because process.exit(0) was called before the cleanup sequences
could be flushed to the terminal.

Solution

  • Added cleanupTerminal() function that synchronously writes disable mouse
    tracking sequences using fs.writeSync(1, ...) to ensure immediate execution
  • Added destroyRenderer() export for SIGINT handler to properly cleanup
  • Call cleanup before renderer.destroy() to ensure sequences are sent

Changes

  • packages/opencode/src/cli/cmd/tui/context/exit.tsx: Added terminal cleanup logic
  • packages/opencode/src/cli/cmd/tui/app.tsx: Updated SIGINT handler to use new cleanup

Testing

  1. Run bun dev
  2. Type /exit - mouse tracking is now properly disabled
  3. Press Ctrl+C - mouse tracking is also properly disabled

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found potentially related PRs:

  1. PR fix: disable SGR mouse tracking on exit to prevent ASCII codes #6709: "fix: disable SGR mouse tracking on exit to prevent ASCII codes"

  2. PR fix(tui): improve macOS terminal restoration on exit #7860: "fix(tui): improve macOS terminal restoration on exit"

These PRs appear to be addressing the same or overlapping concerns around proper terminal state restoration when exiting the TUI. Check if these are already merged or closed before proceeding with PR #8355.

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.

Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows)

1 participant