Skip to content

Terminal left with mouse-tracking/focus-reporting enabled after CLI crashes #5120

Open

Description

@elneilios

Describe the bug

When Copilot CLI crashes or exits abruptly, it doesn't restore the terminal modes it enabled. The parent shell then echoes every mouse movement and focus change as raw escape sequences, which leaves the tab unusable.

PS C:\...> [555;50;35M[555;49;34M[555;48;34M[555;48;35M ... 1M[O[I[O[I[104;20m ...

These modes are left on after the process has exited:

Mode DECSET Symptom
Mouse tracking 1000 / 1002 / 1003 / 1006 / 1015 [555;x;yM on every mouse move
Focus reporting 1004 [I / [O on focus in/out
Image

Affected version

GitHub Copilot CLI 1.0.93

Steps to reproduce the behavior

  1. Start copilot in PowerShell 7 inside Windows Terminal.
  2. Use it normally until the CLI crashes or exits abruptly. This is intermittent and I don't have a reliable trigger.
  3. At the PowerShell prompt, move the mouse or switch focus away from the window and back.
  4. Escape sequences are typed into the prompt.

Workaround: reset the modes manually:

Write-Host -NoNewline "`e[?1000l`e[?1002l`e[?1003l`e[?1005l`e[?1006l`e[?1015l`e[?1004l"

Expected behavior

Terminal modes are restored on every exit path, including crashes, unhandled errors and forced termination, so the parent shell is left usable.

Additional context

OS Windows 11 (10.0.26200), x86_64
Terminal Windows Terminal 1.24.12741.0
Shell PowerShell 7.6.6

The session's process log ends abruptly with routine INFO entries. There's no error, panic or shutdown entry, which suggests a hard crash rather than a handled exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions