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:
- Create
<tmp>\la\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json containing { "profiles": { "list": [] }, "actions": [] }.
- 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.
- Run
copilot in a new folder and answer the folder-trust dialog with Enter ("1. Yes").
- The "Set up terminal for multi-line input support" modal appears with "1. Yes" selected.
- 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
Describe the bug
When Copilot CLI starts inside Windows Terminal (
WT_SESSIONis 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 Terminalsettings.json(adds ashift+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_SESSIONfrom 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
LOCALAPPDATAat an empty folder with a stub Windows Terminal settings file:<tmp>\la\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.jsoncontaining{ "profiles": { "list": [] }, "actions": [] }.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.copilotin a new folder and answer the folder-trust dialog with Enter ("1. Yes").helloand press Enter, as you would for a first prompt.Result: "Updated Windows Terminal key bindings: added key binding for shift+enter." The stub
settings.jsonnow has the newactionsentry and asettings.json.<timestamp>.backupis next to it;hellonever reaches the prompt.Expected behavior
One of:
y), so a stray Enter cannot change a global config file;COPILOT_SETUP_TERMINAL=falseturns the offer off, which is what we use now, but it is not documented incopilot help environmentas far as I can see, so other hosts will hit this.Additional context
/terminal-setupinside Dev Container and Codespaces writes keybindings to wrong file #657 (/terminal-setupwriting keybindings to the wrong file in containers).