Skip to content

Commit 27c6eff

Browse files
authored
Merge pull request microsoft#259858 from microsoft/tyriar/258542
Ensure old terminal toolSpecificData format is supported
2 parents b26e424 + 0bf4b84 commit 27c6eff

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,23 @@ import { IChatContentPartRenderContext } from '../chatContentParts.js';
2828
import { ChatMarkdownContentPart, EditorPool } from '../chatMarkdownContentPart.js';
2929
import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js';
3030

31+
/**
32+
* @deprecated This is the old API shape, we should support this for a while before removing it so
33+
* we don't break existing chats
34+
*/
35+
interface ILegacyChatTerminalToolInvocationData {
36+
kind: 'terminal';
37+
command: string;
38+
language: string;
39+
}
40+
3141
export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSubPart {
3242
public readonly domNode: HTMLElement;
3343
public readonly codeblocks: IChatCodeBlockInfo[] = [];
3444

3545
constructor(
3646
toolInvocation: IChatToolInvocation,
37-
terminalData: IChatTerminalToolInvocationData,
47+
terminalData: IChatTerminalToolInvocationData | ILegacyChatTerminalToolInvocationData,
3848
private readonly context: IChatContentPartRenderContext,
3949
private readonly renderer: MarkdownRenderer,
4050
private readonly editorPool: EditorPool,
@@ -54,6 +64,19 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
5464
throw new Error('Confirmation messages are missing');
5565
}
5666

67+
// Migrate forward the old tool data format
68+
if ('command' in terminalData) {
69+
terminalData = {
70+
kind: 'terminal',
71+
commandLine: {
72+
original: terminalData.command,
73+
toolEdited: undefined,
74+
userEdited: undefined
75+
},
76+
language: terminalData.language
77+
} satisfies IChatTerminalToolInvocationData;
78+
}
79+
5780
const { title, message, disclaimer } = toolInvocation.confirmationMessages;
5881
const continueLabel = localize('continue', "Continue");
5982
const continueKeybinding = keybindingService.lookupKeybinding(AcceptToolConfirmationActionId)?.getLabel();

0 commit comments

Comments
 (0)