Skip to content

Use bracketed paste mode for run_in_terminal tool#304268

Merged
meganrogge merged 3 commits intomainfrom
merogge/bracketed-paste
Mar 23, 2026
Merged

Use bracketed paste mode for run_in_terminal tool#304268
meganrogge merged 3 commits intomainfrom
merogge/bracketed-paste

Conversation

@meganrogge
Copy link
Collaborator

fixes #296955

Copilot AI review requested due to automatic review settings March 23, 2026 21:12
@meganrogge meganrogge marked this pull request as draft March 23, 2026 21:12
@meganrogge meganrogge self-assigned this Mar 23, 2026
@meganrogge meganrogge added this to the 1.113.0 milestone Mar 23, 2026
@meganrogge meganrogge force-pushed the merogge/bracketed-paste branch from 8b252e3 to 936c456 Compare March 23, 2026 21:15
@meganrogge meganrogge requested a review from Tyriar March 23, 2026 21:16
@meganrogge meganrogge modified the milestones: 1.113.0, 1.114.0 Mar 23, 2026
@meganrogge meganrogge marked this pull request as ready for review March 23, 2026 21:16
@meganrogge meganrogge enabled auto-merge (squash) March 23, 2026 21:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.runCommand with an optional bracketedPasteMode parameter and incorporate it into sendText behavior.
  • 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

  • runCommand forwards bracketedPasteMode to 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 pass false) and only using bracketedPasteMode for 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 bracketedPasteMode is 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);

@meganrogge meganrogge force-pushed the merogge/bracketed-paste branch from 936c456 to 036f860 Compare March 23, 2026 21:20
@microsoft microsoft deleted a comment from Copilot AI Mar 23, 2026
@meganrogge meganrogge requested a review from Copilot March 23, 2026 21:21
Tyriar
Tyriar previously requested changes Mar 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

meganrogge and others added 2 commits March 23, 2026 17:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@meganrogge meganrogge merged commit 5a791c6 into main Mar 23, 2026
17 of 19 checks passed
@meganrogge meganrogge deleted the merogge/bracketed-paste branch March 23, 2026 22:57
alexdima added a commit that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal tool corrupts multiline commands exceeding 1024 bytes

4 participants