Skip to content

Commit 7d49976

Browse files
authored
Merge pull request #259897 from microsoft/tyriar/r_1_103_258542
Ensure old terminal toolSpecificData format is supported
2 parents 7c93c1f + 85b4497 commit 7d49976

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
@@ -27,13 +27,23 @@ import { IChatContentPartRenderContext } from '../chatContentParts.js';
2727
import { EditorPool } from '../chatMarkdownContentPart.js';
2828
import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js';
2929

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

3444
constructor(
3545
toolInvocation: IChatToolInvocation,
36-
terminalData: IChatTerminalToolInvocationData,
46+
terminalData: IChatTerminalToolInvocationData | ILegacyChatTerminalToolInvocationData,
3747
private readonly context: IChatContentPartRenderContext,
3848
private readonly renderer: MarkdownRenderer,
3949
private readonly editorPool: EditorPool,
@@ -52,6 +62,19 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
5262
throw new Error('Confirmation messages are missing');
5363
}
5464

65+
// Migrate forward the old tool data format
66+
if ('command' in terminalData) {
67+
terminalData = {
68+
kind: 'terminal',
69+
commandLine: {
70+
original: terminalData.command,
71+
toolEdited: undefined,
72+
userEdited: undefined
73+
},
74+
language: terminalData.language
75+
} satisfies IChatTerminalToolInvocationData;
76+
}
77+
5578
const title = toolInvocation.confirmationMessages.title;
5679
const message = toolInvocation.confirmationMessages.message;
5780
const continueLabel = localize('continue', "Continue");

0 commit comments

Comments
 (0)