fix: handle heredoc/multiline commands in terminal tool execution#307960
Open
maruthang wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: handle heredoc/multiline commands in terminal tool execution#307960maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…crosoft#288896) Update sendToTerminalTool and execute strategies to properly handle heredoc statements and multiline commands that were failing during file write operations.
b1e84db to
cdbf3cb
Compare
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.
Summary
Fixes #288896
When the Copilot agent sends heredoc or multiline commands to the terminal,
normalizeCommandForExecution()collapses all newlines to spaces, destroying the heredoc structure. The shell then receives a single line instead of the multi-line heredoc, causing file write failures.Changes
sendToTerminalTool.ts: Detect multiline commands (containing\nor\r) and send them with bracketed paste mode enabled, bypassingnormalizeCommandForExecution. This preserves newlines so the shell treats the input as a single paste.Execute strategies (
basicExecuteStrategy.ts,noneExecuteStrategy.ts,richExecuteStrategy.ts): Force bracketed paste mode for multiline commands on all platforms (previously only forced on macOS).How to test