Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fire onDidChangeContentHeight when attaching context #221486

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading