Use bracketed paste mode for run_in_terminal tool#304268
Merged
meganrogge merged 3 commits intomainfrom Mar 23, 2026
Merged
Conversation
8b252e3 to
936c456
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to address #296955 by ensuring terminal commands sent by the run_in_terminal chat tool use bracketed paste mode, which avoids multiline input corruption around the ~1024 byte boundary on some PTY/shell combinations.
Changes:
- Enable bracketed paste when sending command text in the “none” execute strategy.
- Extend
ITerminalInstance.runCommand/TerminalInstance.runCommandwith an optionalbracketedPasteModeparameter and incorporate it intosendTextbehavior. - Update the basic strategy’s SIGINT send path to pass
bracketedPasteMode: true(currently problematic; see comments).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts | Sends executed command text with bracketed paste enabled. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.ts | Changes SIGINT send to request bracketed paste (risky for correctness). |
| src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | Adds bracketedPasteMode to runCommand and uses it when sending text. |
| src/vs/workbench/contrib/terminal/browser/terminal.ts | Updates ITerminalInstance.runCommand signature to include bracketedPasteMode. |
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts:1018
runCommandforwardsbracketedPasteModeto the pre-execution Ctrl+C send. If callers enable bracketed paste for multiline commands, this will wrap the ETX character in bracketed paste sequences (when supported) and may prevent SIGINT from working reliably. Consider always sending Ctrl+C without bracketed paste (omit the 3rd arg or passfalse) and only usingbracketedPasteModefor the command payload itself.
await this.sendText('\x03', false, bracketedPasteMode);
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts:1024
- The comment says bracketed paste is used only when not running the command, but the new logic enables bracketed paste when
bracketedPasteModeis set even for executed commands. Update the comment to reflect the new behavior so future readers don’t assume executed commands never use bracketed paste.
// Use bracketed paste mode only when not running the command
await this.sendText(commandLine, shouldExecute, !shouldExecute || bracketedPasteMode);
936c456 to
036f860
Compare
meganrogge
commented
Mar 23, 2026
...bench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.ts
Outdated
Show resolved
Hide resolved
6f8df7e to
5e94fd5
Compare
Tyriar
previously requested changes
Mar 23, 2026
...bench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.ts
Show resolved
Hide resolved
...kbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts
Show resolved
Hide resolved
...kbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.ts
Show resolved
Hide resolved
…Command and sendText methods
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
alexdima
approved these changes
Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #296955