Skip to content

Windows Terminal key-binding offer is preselected "Yes", so the first Enter of a typed prompt rewrites Windows Terminal settings.json #5074

Description

@glmn

Describe the bug

When Copilot CLI starts inside Windows Terminal (WT_SESSION is set), it shows the modal "Set up terminal for multi-line input support" right after the folder-trust dialog, with "1. Yes" preselected. The modal takes focus without any keystroke from the user, so if the user (or a program driving the CLI in a pseudo-terminal) starts typing a prompt, the letters are dropped and the first Enter accepts the offer. Copilot then rewrites the user's global Windows Terminal settings.json (adds a shift+enter → sendInput "\u001b\r" action) and the typed prompt is lost.

So a global terminal config file is edited by an Enter that was meant to submit a prompt. It is easy to hit when the CLI runs in an embedded/nested terminal (an editor panel, a terminal multiplexer, or a desktop app that hosts terminals) that inherits WT_SESSION from the parent Windows Terminal. A backup file is written, but the user never saw the question.

Affected version

1.0.93

Steps to reproduce the behavior

To avoid touching a real config, point LOCALAPPDATA at an empty folder with a stub Windows Terminal settings file:

  1. Create <tmp>\la\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json containing { "profiles": { "list": [] }, "actions": [] }.
  2. In a terminal (any pty), set LOCALAPPDATA=<tmp>\la, COPILOT_HOME=<tmp>\home, WT_SESSION=<any guid>, and a BYOK provider (COPILOT_PROVIDER_BASE_URL, COPILOT_PROVIDER_API_KEY, COPILOT_MODEL) so no login is needed.
  3. Run copilot in a new folder and answer the folder-trust dialog with Enter ("1. Yes").
  4. The "Set up terminal for multi-line input support" modal appears with "1. Yes" selected.
  5. Type hello and press Enter, as you would for a first prompt.

Result: "Updated Windows Terminal key bindings: added key binding for shift+enter." The stub settings.json now has the new actions entry and a settings.json.<timestamp>.backup is next to it; hello never reaches the prompt.

Expected behavior

One of:

  • the offer defaults to "No" (or requires an explicit choice such as y), so a stray Enter cannot change a global config file;
  • the offer is shown as a non-modal hint (e.g. "run /terminal-setup to enable Shift+Enter") instead of a modal at startup;
  • the offer is skipped when stdin is not the Windows Terminal session itself (e.g. the CLI is a child of another terminal host).

COPILOT_SETUP_TERMINAL=false turns the offer off, which is what we use now, but it is not documented in copilot help environment as far as I can see, so other hosts will hit this.

Additional context

Activity

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

    area:input-keyboardKeyboard shortcuts, keybindings, copy/paste, clipboard, mouse, and text inputarea:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions