From 431aebe28b612f70c046d12bdb41fe3dd307ebd5 Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega <48293249+osortega@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:18:43 -0800 Subject: [PATCH] Fix for agent session progress (#281397) --- .../agentSessions/agentSessionsViewer.ts | 31 +++++++++---------- .../chat/browser/chatSessions.contribution.ts | 30 +++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts index cc0b1d110fc..facb08beca9 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts @@ -188,23 +188,22 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer, template: IAgentSessionItemTemplate): void { - - // Support description as string - if (typeof session.element.description === 'string') { - template.description.textContent = session.element.description; - } - - // or as markdown - else if (session.element.description) { - template.elementDisposable.add(this.markdownRendererService.render(session.element.description, { - sanitizerConfig: { - replaceWithPlaintext: true, - allowedTags: { - override: allowedChatMarkdownHtmlTags, + const description = session.element.description; + if (description) { + // Support description as string + if (typeof description === 'string') { + template.description.textContent = description; + } else { + template.elementDisposable.add(this.markdownRendererService.render(description, { + sanitizerConfig: { + replaceWithPlaintext: true, + allowedTags: { + override: allowedChatMarkdownHtmlTags, + }, + allowedLinkSchemes: { augment: [this.productService.urlProtocol] } }, - allowedLinkSchemes: { augment: [this.productService.urlProtocol] } - }, - }, template.description)); + }, template.description)); + } } // Fallback to state label diff --git a/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts b/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts index 2be88113c49..cf4b7e07edb 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts @@ -953,33 +953,35 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ for (let i = responseParts.length - 1; i >= 0; i--) { const part = responseParts[i]; - if (!description && part.kind === 'confirmation' && typeof part.message === 'string') { - description = part.message; + if (description) { + break; } - if (!description && part.kind === 'toolInvocation') { + + if (part.kind === 'confirmation' && typeof part.message === 'string') { + description = part.message; + } else if (part.kind === 'toolInvocation') { const toolInvocation = part as IChatToolInvocation; const state = toolInvocation.state.get(); if (state.type !== IChatToolInvocation.StateKind.Completed) { - const pastTenseMessage = toolInvocation.pastTenseMessage; - const invocationMessage = toolInvocation.invocationMessage; - description = pastTenseMessage || invocationMessage; + description = toolInvocation.pastTenseMessage || toolInvocation.invocationMessage; if (state.type === IChatToolInvocation.StateKind.WaitingForConfirmation) { - const message = toolInvocation.confirmationMessages?.title && (typeof toolInvocation.confirmationMessages.title === 'string' - ? toolInvocation.confirmationMessages.title - : toolInvocation.confirmationMessages.title.value); - description = message ?? localize('chat.sessions.description.waitingForConfirmation', "Waiting for confirmation: {0}", typeof description === 'string' ? description : description.value); + const confirmationTitle = toolInvocation.confirmationMessages?.title; + const titleMessage = confirmationTitle && (typeof confirmationTitle === 'string' + ? confirmationTitle + : confirmationTitle.value); + const descriptionValue = typeof description === 'string' ? description : description.value; + description = titleMessage ?? localize('chat.sessions.description.waitingForConfirmation', "Waiting for confirmation: {0}", descriptionValue); } } - } - if (!description && part.kind === 'toolInvocationSerialized') { + } else if (part.kind === 'toolInvocationSerialized') { description = part.invocationMessage; - } - if (!description && part.kind === 'progressMessage') { + } else if (part.kind === 'progressMessage') { description = part.content; } } + return renderAsPlaintext(description, { useLinkFormatter: true }); }