From 8a537b21f5c4df1cc25a806effec23cecc89a642 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Mon, 29 Jul 2024 15:09:12 -0700 Subject: [PATCH] feat: render confirmation actions nicely in chat history --- .../chatConfirmationContentPart.ts | 1 + .../contrib/chat/browser/chatListRenderer.ts | 15 +++++++++++++-- src/vs/workbench/contrib/chat/common/chatModel.ts | 12 +++++++++--- .../workbench/contrib/chat/common/chatService.ts | 5 +++++ .../contrib/chat/common/chatServiceImpl.ts | 2 +- .../contrib/chat/common/chatViewModel.ts | 5 +++++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.ts b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.ts index 3748611876266..a3957178e5708 100644 --- a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.ts @@ -48,6 +48,7 @@ export class ChatConfirmationContentPart extends Disposable implements IChatCont { acceptedConfirmationData: [e.data] }; data.agentId = element.agent?.id; data.slashCommand = element.slashCommand?.name; + data.confirmation = e.label; if (await this.chatService.sendRequest(element.sessionId, prompt, data)) { confirmation.isUsed = true; confirmationWidget.setShowButtons(false); diff --git a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts index 86d10a0d80a40..a1be658f261bc 100644 --- a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts +++ b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts @@ -62,7 +62,7 @@ import { CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_REQUEST, CONTEXT import { IChatRequestVariableEntry, IChatTextEditGroup } from 'vs/workbench/contrib/chat/common/chatModel'; import { chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes'; import { ChatAgentVoteDirection, IChatConfirmation, IChatContentReference, IChatFollowup, IChatTask, IChatTreeData } from 'vs/workbench/contrib/chat/common/chatService'; -import { IChatCodeCitations, IChatReferences, IChatRendererContent, IChatResponseViewModel, IChatWelcomeMessageViewModel, isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel'; +import { IChatCodeCitations, IChatReferences, IChatRendererContent, IChatRequestViewModel, IChatResponseViewModel, IChatWelcomeMessageViewModel, isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel'; import { getNWords } from 'vs/workbench/contrib/chat/common/chatWordCounter'; import { annotateSpecialMarkdownContent } from '../common/annotations'; import { CodeBlockModelCollection } from '../common/codeBlockModelCollection'; @@ -366,6 +366,10 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer('IChatService'); diff --git a/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts index 68a88c6c79193..a149c0cc1f3ea 100644 --- a/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts @@ -482,7 +482,7 @@ export class ChatService extends Disposable implements IChatService { const history = getHistoryEntriesFromModel(model, agentPart?.agent.id); const initVariableData: IChatRequestVariableData = { variables: [] }; - request = model.addRequest(parsedRequest, initVariableData, attempt, agent, agentSlashCommandPart?.command); + request = model.addRequest(parsedRequest, initVariableData, attempt, agent, agentSlashCommandPart?.command, options?.confirmation); completeResponseCreated(); const variableData = await this.chatVariablesService.resolveVariables(parsedRequest, options?.attachedContext, model, progressCallback, token); model.updateRequest(request, variableData); diff --git a/src/vs/workbench/contrib/chat/common/chatViewModel.ts b/src/vs/workbench/contrib/chat/common/chatViewModel.ts index fc34fce7ec324..d690473b11b67 100644 --- a/src/vs/workbench/contrib/chat/common/chatViewModel.ts +++ b/src/vs/workbench/contrib/chat/common/chatViewModel.ts @@ -72,6 +72,7 @@ export interface IChatRequestViewModel { readonly variables: IChatRequestVariableEntry[]; currentRenderedHeight: number | undefined; readonly contentReferences?: ReadonlyArray; + readonly confirmation?: string; } export interface IChatResponseMarkdownRenderData { @@ -381,6 +382,10 @@ export class ChatRequestViewModel implements IChatRequestViewModel { return this._model.response?.contentReferences; } + get confirmation() { + return this._model.confirmation; + } + currentRenderedHeight: number | undefined; constructor(