Skip to content

Commit

Permalink
fix: fire onDidChangeContentHeight when attaching context (#221486)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl authored Jul 11, 2024
1 parent 8287595 commit 44d09d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<void> {
Expand Down
9 changes: 1 addition & 8 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/chat/browser/media/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 44d09d3

Please sign in to comment.