fix tool call and progress part not rendering (#316464)

* fix tool call and progress part not rendering

* address comments
This commit is contained in:
Justin Chen
2026-05-14 15:58:45 -07:00
committed by GitHub
parent 6d58e1120d
commit d032b988cf
2 changed files with 20 additions and 5 deletions

View File

@@ -41,7 +41,7 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
private createProgressPart(): HTMLElement {
const isComplete = IChatToolInvocation.isComplete(this.toolInvocation);
if (isComplete && this.toolIsConfirmed && this.toolInvocation.pastTenseMessage) {
if (isComplete && this.toolIsConfirmed && (this.toolInvocation.pastTenseMessage || this.toolInvocation.invocationMessage)) {
const key = this.getAnnouncementKey('complete');
const completionContent = this.toolInvocation.pastTenseMessage ?? this.toolInvocation.invocationMessage;
// Don't render anything if there's no meaningful content
@@ -49,7 +49,7 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
return document.createElement('div');
}
const shouldAnnounce = this.toolInvocation.kind === 'toolInvocation' && this.hasMeaningfulContent(completionContent) ? this.computeShouldAnnounce(key) : false;
const part = this.renderProgressContent(completionContent, shouldAnnounce);
const part = this.renderProgressContent(completionContent!, shouldAnnounce);
this._register(part);
return part.domNode;
} else {
@@ -65,8 +65,8 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
if (state.type === IChatToolInvocation.StateKind.Cancelled && state.reasonMessage) {
progressContent = state.reasonMessage;
} else if (state.type === IChatToolInvocation.StateKind.Executing) {
const progress = state.progress.read(reader);
progressContent = progress?.message ?? this.toolInvocation.invocationMessage;
const progressMessage = state.progress.read(reader)?.message;
progressContent = this.hasMeaningfulContent(progressMessage) ? progressMessage : this.toolInvocation.invocationMessage;
} else {
progressContent = this.toolInvocation.invocationMessage;
}
@@ -80,7 +80,7 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
return;
}
const shouldAnnounce = this.toolInvocation.kind === 'toolInvocation' && this.hasMeaningfulContent(progressContent) ? this.computeShouldAnnounce(key) : false;
const part = reader.store.add(this.renderProgressContent(progressContent, shouldAnnounce));
const part = reader.store.add(this.renderProgressContent(progressContent!, shouldAnnounce));
dom.reset(container, part.domNode);
}));
return container;

View File

@@ -1237,6 +1237,21 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
}
private updateWorkingProgressForPendingConfirmations(templateData: IChatListItemTemplate): void {
// Defer mutation of `templateData.renderedParts` (via `removeWorkingProgressContentPart`)
// to a microtask. This method is invoked from tool autoruns, which fire synchronously inside
// `renderChatContentDiff` while the array is being iterated — splicing it mid-render would
// orphan subsequent parts and leave detached DOM nodes referenced from `renderedParts`.
// Capture the originating element so we bail out if the template was recycled for a different one.
const originalElement = templateData.currentElement;
queueMicrotask(() => {
if (templateData.currentElement !== originalElement) {
return;
}
this.doUpdateWorkingProgressForPendingConfirmations(templateData);
});
}
private doUpdateWorkingProgressForPendingConfirmations(templateData: IChatListItemTemplate): void {
const element = templateData.currentElement;
if (!isResponseVM(element)) {
return;