Skip to content

Commit d6e6775

Browse files
authored
Fix hiding all content when responseIsFiltered: true (microsoft#252050)
* Fix hiding all content when responseIsFiltered: true For microsoft/vscode-copilot-release#12599 * Respect errorDetails.level when errorDetails.confirmationButtons
1 parent 15572b1 commit d6e6775

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/vs/workbench/contrib/chat/browser/chatListRenderer.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -559,29 +559,23 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
559559
templateData.rowContainer.classList.toggle('chat-response-loading', (isResponseVM(element) && !element.isComplete));
560560

561561
const content: IChatRendererContent[] = [];
562-
// Always add the references to avoid shifting the content parts when a reference is added, and having to re-diff all the content.
563-
// The part will hide itself if the list is empty.
564-
content.push({ kind: 'references', references: element.contentReferences });
565-
content.push(...annotateSpecialMarkdownContent(element.response.value));
566-
if (element.codeCitations.length) {
567-
content.push({ kind: 'codeCitations', citations: element.codeCitations });
562+
const isFiltered = !!element.errorDetails?.responseIsFiltered;
563+
if (!isFiltered) {
564+
// Always add the references to avoid shifting the content parts when a reference is added, and having to re-diff all the content.
565+
// The part will hide itself if the list is empty.
566+
content.push({ kind: 'references', references: element.contentReferences });
567+
content.push(...annotateSpecialMarkdownContent(element.response.value));
568+
if (element.codeCitations.length) {
569+
content.push({ kind: 'codeCitations', citations: element.codeCitations });
570+
}
568571
}
569572

570573
if (element.errorDetails?.message && element.errorDetails.message !== canceledName) {
571574
content.push({ kind: 'errorDetails', errorDetails: element.errorDetails, isLast: index === this.delegate.getListLength() - 1 });
572575
}
573576

574-
const isFiltered = !!element.errorDetails?.responseIsFiltered;
575-
if (!isFiltered) {
576-
const diff = this.diff(templateData.renderedParts ?? [], content, element);
577-
this.renderChatContentDiff(diff, content, element, index, templateData);
578-
} else {
579-
dom.clearNode(templateData.value);
580-
if (templateData.renderedParts) {
581-
dispose(templateData.renderedParts);
582-
}
583-
templateData.renderedParts = [];
584-
}
577+
const diff = this.diff(templateData.renderedParts ?? [], content, element);
578+
this.renderChatContentDiff(diff, content, element, index, templateData);
585579

586580
this.updateItemHeightOnRender(element, templateData);
587581
}
@@ -991,11 +985,12 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
991985
renderedError.addDisposable(renderedError.onDidChangeHeight(() => this.updateItemHeight(templateData)));
992986
return renderedError;
993987
} else if (content.errorDetails.confirmationButtons && isLast) {
994-
const errorConfirmation = this.instantiationService.createInstance(ChatErrorConfirmationContentPart, ChatErrorLevel.Error, new MarkdownString(content.errorDetails.message), content, content.errorDetails.confirmationButtons, this.renderer, context);
988+
const level = content.errorDetails.level ?? ChatErrorLevel.Error;
989+
const errorConfirmation = this.instantiationService.createInstance(ChatErrorConfirmationContentPart, level, new MarkdownString(content.errorDetails.message), content, content.errorDetails.confirmationButtons, this.renderer, context);
995990
errorConfirmation.addDisposable(errorConfirmation.onDidChangeHeight(() => this.updateItemHeight(templateData)));
996991
return errorConfirmation;
997992
} else {
998-
const level = content.errorDetails.level ?? (content.errorDetails.responseIsFiltered ? ChatErrorLevel.Info : ChatErrorLevel.Error);
993+
const level = content.errorDetails.level ?? ChatErrorLevel.Error;
999994
return this.instantiationService.createInstance(ChatErrorContentPart, level, new MarkdownString(content.errorDetails.message), content, this.renderer);
1000995
}
1001996
}

0 commit comments

Comments
 (0)