Skip to content

Commit

Permalink
Optionally accept previous request entries (microsoft/vscode-copilot#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed May 17, 2024
1 parent 8a5f332 commit afee943
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -70,10 +79,16 @@ class OpenChatGlobalAction extends Action2 {
override async run(accessor: ServicesAccessor, opts?: string | IChatViewOpenOptions): Promise<void> {
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);
Expand Down

0 comments on commit afee943

Please sign in to comment.