[PR #8355] fix(opencode): disable mouse tracking on exit #12714

Open
opened 2026-02-16 18:17:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8355

State: open
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8355 **State:** open **Merged:** No --- 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
yindo added the pull-request label 2026-02-16 18:17:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12714