From 3874e481348871a953d459a995e3baad9f66d84e Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 11 Jul 2024 10:15:26 -0700 Subject: [PATCH] fix: fire `onDidChangeContentHeight` when attaching context --- .../workbench/contrib/chat/browser/chatInputPart.ts | 11 ++++++++++- src/vs/workbench/contrib/chat/browser/chatWidget.ts | 9 +-------- src/vs/workbench/contrib/chat/browser/media/chat.css | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts index 59de53a6c775e..ca83d3676b7db 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts @@ -347,7 +347,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge } } - attachContext(contentReferences: IChatRequestVariableEntry[]): void { + attachContext(overwrite: boolean, ...contentReferences: IChatRequestVariableEntry[]): void { + if (overwrite) { + this._attachedContext.clear(); + } + if (contentReferences.length > 0) { for (const reference of contentReferences) { this._attachedContext.add(reference); @@ -489,6 +493,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge } private initAttachedContext(container: HTMLElement) { + const oldHeight = container.offsetHeight; dom.clearNode(container); this.attachedContextDisposables.clear(); dom.setVisibility(Boolean(this.attachedContext.size), this.attachedContextContainer); @@ -547,6 +552,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge }); this.attachedContextDisposables.add(disp); }); + + if (oldHeight !== container.offsetHeight) { + this._onDidChangeHeight.fire(); + } } async renderFollowups(items: IChatFollowup[] | undefined, response: IChatResponseViewModel | undefined): Promise { diff --git a/src/vs/workbench/contrib/chat/browser/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/chatWidget.ts index 6664ebecd2a94..4d3461c484858 100644 --- a/src/vs/workbench/contrib/chat/browser/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatWidget.ts @@ -792,14 +792,7 @@ export class ChatWidget extends Disposable implements IChatWidget { setContext(overwrite: boolean, ...contentReferences: IChatRequestVariableEntry[]) { - if (overwrite) { - this.inputPart.clearContext(); - } - this.inputPart.attachContext(contentReferences); - - if (this.bodyDimension) { - this.layout(this.bodyDimension.height, this.bodyDimension.width); - } + this.inputPart.attachContext(overwrite, ...contentReferences); } getCodeBlockInfosForResponse(response: IChatResponseViewModel): IChatCodeBlockInfo[] { diff --git a/src/vs/workbench/contrib/chat/browser/media/chat.css b/src/vs/workbench/contrib/chat/browser/media/chat.css index aaf3f574c4817..271fbb0dbacf0 100644 --- a/src/vs/workbench/contrib/chat/browser/media/chat.css +++ b/src/vs/workbench/contrib/chat/browser/media/chat.css @@ -534,6 +534,7 @@ .interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-icon-label .monaco-button.codicon.codicon-close, .interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-button.codicon.codicon-close { color: var(--vscode-descriptionForeground); + cursor: pointer; } .interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-icon-label .codicon {