-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Description
Currently the run in terminal tool lives in the copilot chat repo, meaning all communication is done over the extension host API. This includes terminal tool specific proposed APIs such as PreparedTerminalToolInvocation
and the overhead associated with them. I think we should move this tool to core as that way we don't need to incur the overhead of adding ext APIs for terminal-specific things (special terminal tool renderer and confirmation messages), don't need to work against the limitations of the ext API (eg. no terminal buffer API) and generally have a lot more control.
Here's an example of a tool in core:
vscode/src/vs/workbench/contrib/extensions/common/installExtensionsTool.ts
Lines 41 to 71 in bc29a4e
export class InstallExtensionsTool implements IToolImpl { | |
constructor( | |
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService, | |
) { } | |
async prepareToolInvocation(context: IToolInvocationPreparationContext, token: CancellationToken): Promise<IPreparedToolInvocation | undefined> { | |
const parameters = context.parameters as InputParams; | |
return { | |
confirmationMessages: { | |
title: localize('installExtensionsTool.confirmationTitle', 'Install Extensions'), | |
message: new MarkdownString(localize('installExtensionsTool.confirmationMessage', "Review the suggested extensions and click the **Install** button for each extension you wish to add. Once you have finished installing the selected extensions, click **Continue** to proceed.")), | |
}, | |
toolSpecificData: { | |
kind: 'extensions', | |
extensions: parameters.ids | |
} | |
}; | |
} | |
async invoke(invocation: IToolInvocation, _countTokens: CountTokensCallback, _progress: ToolProgress, token: CancellationToken): Promise<IToolResult> { | |
const input = invocation.parameters as InputParams; | |
const installed = this.extensionsWorkbenchService.local.filter(e => input.ids.some(id => areSameExtensions({ id }, e.identifier))); | |
return { | |
content: [{ | |
kind: 'text', | |
value: installed.length ? localize('installExtensionsTool.resultMessage', 'Following extensions are installed: {0}', installed.map(e => e.identifier.id).join(', ')) : localize('installExtensionsTool.noResultMessage', 'No extensions were installed.'), | |
}] | |
}; | |
} | |
} |
This blocks most of the improvements I'd like to make to the terminal tool, such as improving hanging cases #255396 and moving the terminal into the chat view #257468.