Hide sandbox wrapper from terminal command metadata#309346
Merged
dileepyavan merged 3 commits intomicrosoft:mainfrom Apr 13, 2026
Merged
Hide sandbox wrapper from terminal command metadata#309346dileepyavan merged 3 commits intomicrosoft:mainfrom
dileepyavan merged 3 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates terminal execution plumbing so that when run_in_terminal rewrites a command for sandbox execution, terminal command metadata (used for chat terminal context/“Last Command”) records the user-facing/original command instead of the internal sandbox wrapper.
Changes:
- Adds an optional
commandLineForMetadataparameter through the terminal execution stack (ITerminalExecuteStrategy,RichExecuteStrategy,ActiveTerminalExecution,ITerminalInstance.runCommand). - Updates
TerminalInstance.runCommandto usecommandLineForMetadata ?? commandLinewhen callingsetNextCommandId. - Adds a focused unit test to ensure rich execution passes separate metadata for wrapped commands.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/richExecuteStrategy.test.ts | Adds coverage verifying rich execution forwards a separate metadata command line. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts | Computes and passes a metadata command line for sandbox-enabled executions. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.ts | Threads metadata command line into ITerminalInstance.runCommand. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts | Updates strategy signature to accept (unused) metadata command line parameter. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.ts | Extends ITerminalExecuteStrategy.execute contract with commandLineForMetadata. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.ts | Updates strategy signature to accept (unused) metadata command line parameter. |
| src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | Adds commandLineForMetadata to runCommand and uses it for command ID metadata. |
| src/vs/workbench/contrib/terminal/browser/terminal.ts | Updates ITerminalInstance.runCommand signature to include commandLineForMetadata. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 1
bd73fc4 to
5530d8d
Compare
lszomoru
approved these changes
Apr 13, 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.
Summary
Fix terminal command metadata for sandboxed
run_in_terminalexecutions so chat terminal context reports the user-facing command instead of the internal sandbox wrapper.The terminal tool can rewrite a command into a sandbox-runtime invocation before sending it to the shell. Previously, that rewritten command was also passed into terminal command metadata via
setNextCommandId, causing terminal context to show values like:instead of:
This change threads an optional metadata command line through the rich terminal execution path. The terminal still executes the rewritten sandbox command, but command detection metadata records the display/original command when sandboxing is enabled.
Changes
commandLineForMetadatatoITerminalInstance.runCommand.commandLineForMetadata ?? commandLinefor terminal command metadata (setNextCommandId).ITerminalExecuteStrategy,RichExecuteStrategy, andActiveTerminalExecution.RunInTerminalToolwhen terminal sandboxing is enabled.Validation
npm run transpile-client./scripts/test.sh --run src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/richExecuteStrategy.test.ts2 passing./scripts/test.sh --run src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts154 passing, 105 pendingFixes #303713