Skip to content

Commit d45db6f

Browse files
authored
Only showing n files where n is the number of files changed in turn (microsoft#258180)
only showing n files
1 parent 3f2e04c commit d45db6f

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

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

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,9 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
696696
if (element.model.response === element.model.entireResponse && element.errorDetails?.message && element.errorDetails.message !== canceledName) {
697697
content.push({ kind: 'errorDetails', errorDetails: element.errorDetails, isLast: index === this.delegate.getListLength() - 1 });
698698
}
699-
if (this.shouldShowFileChangesSummary(element)) {
700-
const fileChanges: IChatChangesSummary[] = [];
701-
for (const part of element.model.entireResponse.value) {
702-
if (part.kind === 'textEditGroup') {
703-
fileChanges.push({
704-
kind: 'changesSummary',
705-
reference: part.uri,
706-
sessionId: element.sessionId,
707-
requestId: element.requestId,
708-
});
709-
}
710-
}
711-
if (fileChanges.length) {
712-
content.push({ kind: 'changesSummary', fileChanges });
713-
}
699+
const fileChangesSummaryPart = this.getChatFileChangesSummaryPart(element);
700+
if (fileChangesSummaryPart) {
701+
content.push(fileChangesSummaryPart);
714702
}
715703

716704
const diff = this.diff(templateData.renderedParts ?? [], content, element);
@@ -719,6 +707,29 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
719707
this.updateItemHeightOnRender(element, templateData);
720708
}
721709

710+
private getChatFileChangesSummaryPart(element: IChatResponseViewModel): IChatChangesSummaryPart | undefined {
711+
if (!this.shouldShowFileChangesSummary(element)) {
712+
return undefined;
713+
}
714+
const consideredFiles: Set<string> = new Set();
715+
const fileChanges: IChatChangesSummary[] = [];
716+
for (const part of element.model.entireResponse.value) {
717+
if (part.kind === 'textEditGroup' && !consideredFiles.has(part.uri.toString(true))) {
718+
fileChanges.push({
719+
kind: 'changesSummary',
720+
reference: part.uri,
721+
sessionId: element.sessionId,
722+
requestId: element.requestId,
723+
});
724+
consideredFiles.add(part.uri.toString(true));
725+
}
726+
}
727+
if (!fileChanges.length) {
728+
return undefined;
729+
}
730+
return { kind: 'changesSummary', fileChanges };
731+
}
732+
722733
private renderChatRequest(element: IChatRequestViewModel, index: number, templateData: IChatListItemTemplate) {
723734
templateData.rowContainer.classList.toggle('chat-response-loading', false);
724735
if (element.id === this.viewModel?.editing?.id) {
@@ -1019,21 +1030,9 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
10191030
const isPaused = element.model.isPaused.get();
10201031
partsToRender.push({ kind: 'working', isPaused, setPaused: p => element.model.setPaused(p) });
10211032
}
1022-
if (this.shouldShowFileChangesSummary(element)) {
1023-
const fileChanges: IChatChangesSummary[] = [];
1024-
for (const part of element.model.entireResponse.value) {
1025-
if (part.kind === 'textEditGroup') {
1026-
fileChanges.push({
1027-
kind: 'changesSummary',
1028-
reference: part.uri,
1029-
sessionId: element.sessionId,
1030-
requestId: element.requestId,
1031-
});
1032-
}
1033-
}
1034-
if (fileChanges.length > 0) {
1035-
partsToRender.push({ kind: 'changesSummary', fileChanges });
1036-
}
1033+
const fileChangesSummaryPart = this.getChatFileChangesSummaryPart(element);
1034+
if (fileChangesSummaryPart) {
1035+
partsToRender.push(fileChangesSummaryPart);
10371036
}
10381037

10391038
return { content: partsToRender, moreContentAvailable };

0 commit comments

Comments
 (0)