Ptyxis prints raw SGR mouse escape sequences after exiting opencode

Description:

I’m seeing what appears to be a mouse handling issue in GNOME Terminal.

I’m on Ubuntu 26.04 LTS / Wayland using Ptyxis:

ps -e | grep -E “ptyxis|gnome-terminal|kgx|tilix|foot|kitty”
109911 ? 00:00:09 ptyxis
109920 ? 00:00:00 ptyxis-agent

Environment:
TERM=xterm-256color
XDG_SESSION_TYPE=wayland
SHELL=/bin/bash

Steps to reproduce

  1. Open GNOME Terminal.

  2. Run opencode.

  3. Exit opencode.

Expected behavior

The terminal should return to normal shell input after the application exits.

Actual behavior

Instead of behaving normally, the terminal prints raw escape sequences like:

wathi@wathi:~/Downloads$ opencode
^[[<51;89;23Mwathi@wathi:~/Downloads$ 51;89;23M

These appear to be SGR mouse reporting escape sequences being sent directly to the shell.

Additional information

  • This only happens after running opencode.

  • An OpenCode maintainer suggested:

“Yeah, the terminal isn’t handling mouse events well.”

To be clear, GNOME Terminal and Ptyxis are seperate apps.