From afee94319da81972a3b5ef449331b6813b7815cc Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Fri, 17 May 2024 17:26:12 +0200 Subject: [PATCH] Optionally accept previous request entries (microsoft/vscode-copilot#5006) --- .../contrib/chat/browser/actions/chatActions.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts index 03cd71f82e2cc..fa695e9d75705 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts @@ -47,6 +47,15 @@ export interface IChatViewOpenOptions { * Whether the query is partial and will await more input from the user. */ isPartialQuery?: boolean; + /** + * Any previous chat requests and responses that should be shown in the chat view. + */ + previousRequests?: IChatViewOpenRequestEntry[]; +} + +export interface IChatViewOpenRequestEntry { + request: string; + response: string; } class OpenChatGlobalAction extends Action2 { @@ -70,10 +79,16 @@ class OpenChatGlobalAction extends Action2 { override async run(accessor: ServicesAccessor, opts?: string | IChatViewOpenOptions): Promise { opts = typeof opts === 'string' ? { query: opts } : opts; + const chatService = accessor.get(IChatService); const chatWidget = await showChatView(accessor.get(IViewsService)); if (!chatWidget) { return; } + if (opts?.previousRequests?.length && chatWidget.viewModel) { + for (const { request, response } of opts.previousRequests) { + chatService.addCompleteRequest(chatWidget.viewModel.sessionId, request, undefined, 0, { message: response }); + } + } if (opts?.query) { if (opts.isPartialQuery) { chatWidget.setInput(opts.query);