Skip to content

Commit 6a5d9aa

Browse files
authored
Merge pull request microsoft#257296 from microsoft/tyriar/256552
Remove IChatTerminalToolInvocationData
2 parents a893ae5 + 5accc60 commit 6a5d9aa

File tree

14 files changed

+37
-113
lines changed

14 files changed

+37
-113
lines changed

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
18711871
LanguageModelToolExtensionSource: extHostTypes.LanguageModelToolExtensionSource,
18721872
LanguageModelToolMCPSource: extHostTypes.LanguageModelToolMCPSource,
18731873
ExtendedLanguageModelToolResult: extHostTypes.ExtendedLanguageModelToolResult,
1874-
PreparedTerminalToolInvocation: extHostTypes.PreparedTerminalToolInvocation,
18751874
LanguageModelChatToolMode: extHostTypes.LanguageModelChatToolMode,
18761875
LanguageModelPromptTsxPart: extHostTypes.LanguageModelPromptTsxPart,
18771876
NewSymbolName: extHostTypes.NewSymbolName,

src/vs/workbench/api/common/extHostLanguageModelTools.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ export class ExtHostLanguageModelTools implements ExtHostLanguageModelToolsShape
184184
options.chatRequestId = dto.chatRequestId;
185185
options.chatInteractionId = dto.chatInteractionId;
186186
options.chatSessionId = dto.context?.sessionId;
187-
188-
if (dto.toolSpecificData?.kind === 'terminal') {
189-
options.terminalCommand = dto.toolSpecificData.command;
190-
}
191187
}
192188

193189
if (isProposedApiEnabled(item.extension, 'chatParticipantAdditions') && dto.modelId) {
@@ -251,25 +247,7 @@ export class ExtHostLanguageModelTools implements ExtHostLanguageModelToolsShape
251247
chatSessionId: context.chatSessionId,
252248
chatInteractionId: context.chatInteractionId
253249
};
254-
if (isProposedApiEnabled(item.extension, 'chatParticipantPrivate') && item.tool.prepareInvocation2) {
255-
const result = await item.tool.prepareInvocation2(options, token);
256-
if (!result) {
257-
return undefined;
258-
}
259-
260-
return {
261-
confirmationMessages: result.confirmationMessages ? {
262-
title: typeof result.confirmationMessages.title === 'string' ? result.confirmationMessages.title : typeConvert.MarkdownString.from(result.confirmationMessages.title),
263-
message: typeof result.confirmationMessages.message === 'string' ? result.confirmationMessages.message : typeConvert.MarkdownString.from(result.confirmationMessages.message),
264-
} : undefined,
265-
toolSpecificData: {
266-
kind: 'terminal',
267-
language: result.language,
268-
command: result.command,
269-
},
270-
presentation: result.presentation
271-
};
272-
} else if (item.tool.prepareInvocation) {
250+
if (item.tool.prepareInvocation) {
273251
const result = await item.tool.prepareInvocation(options, token);
274252
if (!result) {
275253
return undefined;

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4839,15 +4839,6 @@ export class LanguageModelToolResultPart2 implements vscode.LanguageModelToolRes
48394839
}
48404840
}
48414841

4842-
export class PreparedTerminalToolInvocation {
4843-
constructor(
4844-
public readonly command: string,
4845-
public readonly language: string,
4846-
public readonly confirmationMessages?: vscode.LanguageModelToolConfirmationMessages,
4847-
public readonly presentation?: 'hidden'
4848-
) { }
4849-
}
4850-
48514842
export enum ChatErrorLevel {
48524843
Info = 0,
48534844
Warning = 1,

src/vs/workbench/contrib/chat/browser/chatAccessibilityProvider.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export const getToolConfirmationAlert = (accessor: ServicesAccessor, toolInvocat
2828
let input = '';
2929
if (v.toolSpecificData) {
3030
if (v.toolSpecificData.kind === 'terminal') {
31-
input = v.toolSpecificData.command;
32-
} else if (v.toolSpecificData.kind === 'terminal2') {
3331
input = v.toolSpecificData.commandLine.toolEdited ?? v.toolSpecificData.commandLine.original;
3432
} else if (v.toolSpecificData.kind === 'extensions') {
3533
input = JSON.stringify(v.toolSpecificData.extensions);

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalMarkdownProgressPart.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
88
import { ThemeIcon } from '../../../../../../base/common/themables.js';
99
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
1010
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
11-
import { IChatMarkdownContent, IChatTerminalToolInvocationData, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData2 } from '../../../common/chatService.js';
11+
import { IChatMarkdownContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData } from '../../../common/chatService.js';
1212
import { CodeBlockModelCollection } from '../../../common/codeBlockModelCollection.js';
1313
import { IChatCodeBlockInfo } from '../../chat.js';
1414
import { ICodeBlockRenderOptions } from '../../codeBlockPart.js';
@@ -27,7 +27,7 @@ export class ChatTerminalMarkdownProgressPart extends BaseChatToolInvocationSubP
2727

2828
constructor(
2929
toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
30-
terminalData: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2,
30+
terminalData: IChatTerminalToolInvocationData,
3131
context: IChatContentPartRenderContext,
3232
renderer: MarkdownRenderer,
3333
editorPool: EditorPool,
@@ -38,9 +38,7 @@ export class ChatTerminalMarkdownProgressPart extends BaseChatToolInvocationSubP
3838
) {
3939
super(toolInvocation);
4040

41-
const command = terminalData.kind === 'terminal'
42-
? terminalData.command
43-
: terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original;
41+
const command = terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original;
4442

4543
const content = new MarkdownString(`\`\`\`${terminalData.language}\n${command}\n\`\`\``);
4644
const chatMarkdownContent: IChatMarkdownContent = {

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolSubPart.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IContextKeyService } from '../../../../../../platform/contextkey/common
1717
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
1818
import { IKeybindingService } from '../../../../../../platform/keybinding/common/keybinding.js';
1919
import { ChatContextKeys } from '../../../common/chatContextKeys.js';
20-
import { IChatTerminalToolInvocationData, IChatToolInvocation, type IChatTerminalToolInvocationData2 } from '../../../common/chatService.js';
20+
import { IChatToolInvocation, type IChatTerminalToolInvocationData } from '../../../common/chatService.js';
2121
import { CancelChatActionId } from '../../actions/chatExecuteActions.js';
2222
import { AcceptToolConfirmationActionId } from '../../actions/chatToolActions.js';
2323
import { IChatCodeBlockInfo, IChatWidgetService } from '../../chat.js';
@@ -33,7 +33,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
3333

3434
constructor(
3535
toolInvocation: IChatToolInvocation,
36-
terminalData: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2,
36+
terminalData: IChatTerminalToolInvocationData,
3737
private readonly context: IChatContentPartRenderContext,
3838
private readonly renderer: MarkdownRenderer,
3939
private readonly editorPool: EditorPool,
@@ -90,7 +90,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
9090
};
9191
const langId = this.languageService.getLanguageIdByLanguageName(terminalData.language ?? 'sh') ?? 'shellscript';
9292
const model = this.modelService.createModel(
93-
terminalData.kind === 'terminal' ? terminalData.command : terminalData.commandLine.toolEdited ?? terminalData.commandLine.original,
93+
terminalData.commandLine.toolEdited ?? terminalData.commandLine.original,
9494
this.languageService.createById(langId),
9595
this._getUniqueCodeBlockUri(),
9696
true
@@ -122,11 +122,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
122122
this._onDidChangeHeight.fire();
123123
}));
124124
this._register(model.onDidChangeContent(e => {
125-
if (terminalData.kind === 'terminal') {
126-
terminalData.command = model.getValue();
127-
} else {
128-
terminalData.commandLine.userEdited = model.getValue();
129-
}
125+
terminalData.commandLine.userEdited = model.getValue();
130126
}));
131127
const element = dom.$('');
132128
dom.append(element, editor.object.element);

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationPart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ export class ChatToolInvocationPart extends Disposable implements IChatContentPa
8989
return this.instantiationService.createInstance(ChatTaskListSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData);
9090
}
9191
if (this.toolInvocation.confirmationMessages) {
92-
if (this.toolInvocation.toolSpecificData?.kind === 'terminal' || this.toolInvocation.toolSpecificData?.kind === 'terminal2') {
92+
if (this.toolInvocation.toolSpecificData?.kind === 'terminal') {
9393
return this.instantiationService.createInstance(TerminalConfirmationWidgetSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex);
9494
} else {
9595
return this.instantiationService.createInstance(ToolConfirmationSubPart, this.toolInvocation, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockModelCollection, this.codeBlockStartIndex);
9696
}
9797
}
9898
}
9999

100-
if (this.toolInvocation.toolSpecificData?.kind === 'terminal' || this.toolInvocation.toolSpecificData?.kind === 'terminal2') {
100+
if (this.toolInvocation.toolSpecificData?.kind === 'terminal') {
101101
return this.instantiationService.createInstance(ChatTerminalMarkdownProgressPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex, this.codeBlockModelCollection);
102102
}
103103

src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ class ChatResponseAccessibleProvider extends Disposable implements IAccessibleVi
7575
let input = '';
7676
if (toolInvocation.toolSpecificData) {
7777
input = toolInvocation.toolSpecificData?.kind === 'terminal'
78-
? toolInvocation.toolSpecificData.command
79-
: toolInvocation.toolSpecificData?.kind === 'terminal2'
80-
? toolInvocation.toolSpecificData.commandLine.userEdited ?? toolInvocation.toolSpecificData.commandLine.toolEdited ?? toolInvocation.toolSpecificData.commandLine.original
81-
: toolInvocation.toolSpecificData?.kind === 'extensions'
82-
? JSON.stringify(toolInvocation.toolSpecificData.extensions)
83-
: toolInvocation.toolSpecificData?.kind === 'tasks'
84-
? JSON.stringify(toolInvocation.toolSpecificData.tasks)
85-
: JSON.stringify(toolInvocation.toolSpecificData.rawInput);
78+
? toolInvocation.toolSpecificData.commandLine.userEdited ?? toolInvocation.toolSpecificData.commandLine.toolEdited ?? toolInvocation.toolSpecificData.commandLine.original
79+
: toolInvocation.toolSpecificData?.kind === 'extensions'
80+
? JSON.stringify(toolInvocation.toolSpecificData.extensions)
81+
: toolInvocation.toolSpecificData?.kind === 'tasks'
82+
? JSON.stringify(toolInvocation.toolSpecificData.tasks)
83+
: JSON.stringify(toolInvocation.toolSpecificData.rawInput);
8684
}
8785
responseContent += `${title}`;
8886
if (input) {

src/vs/workbench/contrib/chat/browser/languageModelToolsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
363363
: undefined;
364364

365365
if (prepared?.confirmationMessages) {
366-
if (prepared.toolSpecificData?.kind !== 'terminal' && prepared.toolSpecificData?.kind !== 'terminal2' && typeof prepared.confirmationMessages.allowAutoConfirm !== 'boolean') {
366+
if (prepared.toolSpecificData?.kind !== 'terminal' && typeof prepared.confirmationMessages.allowAutoConfirm !== 'boolean') {
367367
prepared.confirmationMessages.allowAutoConfirm = true;
368368
}
369369

src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { encodeBase64 } from '../../../../../base/common/buffer.js';
88
import { IMarkdownString } from '../../../../../base/common/htmlContent.js';
99
import { observableValue } from '../../../../../base/common/observable.js';
1010
import { localize } from '../../../../../nls.js';
11-
import { IChatExtensionsContent, IChatTerminalToolInvocationData, IChatToolInputInvocationData, IChatTasksContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData2 } from '../chatService.js';
11+
import { IChatExtensionsContent, IChatToolInputInvocationData, IChatTasksContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData } from '../chatService.js';
1212
import { IPreparedToolInvocation, isToolResultOutputDetails, IToolConfirmationMessages, IToolData, IToolProgressStep, IToolResult } from '../languageModelToolsService.js';
1313

1414
export class ChatToolInvocation implements IChatToolInvocation {
@@ -46,7 +46,7 @@ export class ChatToolInvocation implements IChatToolInvocation {
4646
public readonly presentation: IPreparedToolInvocation['presentation'];
4747
public readonly toolId: string;
4848

49-
public readonly toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
49+
public readonly toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
5050

5151
public readonly progress = observableValue<{ message?: string | IMarkdownString; progress: number }>(this, { progress: 0 });
5252

0 commit comments

Comments
 (0)