In sandbox mode for chatUI, the command should be displayed without sandbox command and environment variables (#291395)

changes
This commit is contained in:
dileepyavan
2026-01-29 13:14:59 -08:00
committed by GitHub
parent acfc362937
commit 9fbb7b8708
5 changed files with 10 additions and 2 deletions
@@ -274,7 +274,7 @@ export class ChatTerminalToolProgressPart extends BaseChatToolInvocationSubPart
]);
this._titleElement = elements.title;
const command = (terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original).trimStart();
const command = (terminalData.commandLine.forDisplay ?? terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original).trimStart();
this._commandText = command;
this._terminalOutputContextKey = ChatContextKeys.inChatTerminalToolOutput.bindTo(this._contextKeyService);
@@ -413,6 +413,8 @@ export interface IChatTerminalToolInvocationData {
original: string;
userEdited?: string;
toolEdited?: string;
// command to show in the chat UI (potentially different from what is actually run in the terminal)
forDisplay?: string;
};
/** The working directory URI for the terminal */
cwd?: UriComponents;
@@ -22,4 +22,6 @@ export interface ICommandLineRewriterOptions {
export interface ICommandLineRewriterResult {
rewritten: string;
reasoning: string;
//for scenarios where we want to show a different command in the chat UI than what is actually run in the terminal
forDisplay?: string;
}
@@ -29,7 +29,8 @@ export class CommandLineSandboxRewriter extends Disposable implements ICommandLi
const wrappedCommand = this._sandboxService.wrapCommand(options.commandLine);
return {
rewritten: wrappedCommand,
reasoning: 'Wrapped command for sandbox execution'
reasoning: 'Wrapped command for sandbox execution',
forDisplay: options.commandLine, // show the command that is passed as input. In this case, the output from CommandLinePreventHistoryRewriter
};
}
}
@@ -456,6 +456,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
const terminalCommandId = `tool-${generateUuid()}`;
let rewrittenCommand: string | undefined = args.command;
let forDisplayCommand: string | undefined = undefined;
for (const rewriter of this._commandLineRewriters) {
const rewriteResult = await rewriter.rewrite({
commandLine: rewrittenCommand,
@@ -465,6 +466,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
});
if (rewriteResult) {
rewrittenCommand = rewriteResult.rewritten;
forDisplayCommand = rewriteResult.forDisplay;
this._logService.info(`RunInTerminalTool: Command rewritten by ${rewriter.constructor.name}: ${rewriteResult.reasoning}`);
}
}
@@ -476,6 +478,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
commandLine: {
original: args.command,
toolEdited: rewrittenCommand === args.command ? undefined : rewrittenCommand,
forDisplay: forDisplayCommand,
},
cwd,
language,