diff --git a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts index 216ed63768a..4be5c86b6d4 100644 --- a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts +++ b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts @@ -29,7 +29,7 @@ import { IChatAgentHistoryEntry, IChatAgentImplementation, IChatAgentRequest, IC import { IChatEditingService, IChatRelatedFileProviderMetadata } from '../../contrib/chat/common/chatEditingService.js'; import { ChatRequestAgentPart } from '../../contrib/chat/common/chatParserTypes.js'; import { ChatRequestParser } from '../../contrib/chat/common/chatRequestParser.js'; -import { IChatContentInlineReference, IChatContentReference, IChatFollowup, IChatNotebookEdit, IChatProgress, IChatService, IChatTask, IChatWarningMessage } from '../../contrib/chat/common/chatService.js'; +import { IChatContentInlineReference, IChatContentReference, IChatFollowup, IChatNotebookEdit, IChatProgress, IChatService, IChatTask, IChatTaskSerialized, IChatWarningMessage } from '../../contrib/chat/common/chatService.js'; import { ChatAgentLocation, ChatMode } from '../../contrib/chat/common/constants.js'; import { IExtHostContext, extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js'; import { IExtensionService } from '../../services/extensions/common/extensions.js'; @@ -72,6 +72,14 @@ export class MainThreadChatTask implements IChatTask { this.progress.push(progress); this._onDidAddProgress.fire(progress); } + + toJSON(): IChatTaskSerialized { + return { + kind: 'progressTaskSerialized', + content: this.content, + progress: this.progress + }; + } } @extHostNamedCustomer(MainContext.MainThreadChatAgents2) diff --git a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.ts b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.ts index 6c5c13e045e..35057aaff35 100644 --- a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.ts @@ -13,7 +13,7 @@ import { URI } from '../../../../../base/common/uri.js'; import { MarkdownRenderer } from '../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { localize } from '../../../../../nls.js'; import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; -import { IChatProgressMessage, IChatTask } from '../../common/chatService.js'; +import { IChatProgressMessage, IChatTask, IChatTaskSerialized } from '../../common/chatService.js'; import { IChatRendererContent, IChatWorkingProgress, isResponseVM } from '../../common/chatViewModel.js'; import { ChatTreeItem } from '../chat.js'; import { InlineAnchorWidget } from '../chatInlineAnchorWidget.js'; @@ -27,7 +27,7 @@ export class ChatProgressContentPart extends Disposable implements IChatContentP private readonly isHidden: boolean; constructor( - progress: IChatProgressMessage | IChatTask, + progress: IChatProgressMessage | IChatTask | IChatTaskSerialized, renderer: MarkdownRenderer, context: IChatContentPartRenderContext, forceShowSpinner: boolean | undefined, diff --git a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.ts b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.ts index 310130ec951..8ce898d086e 100644 --- a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.ts @@ -9,7 +9,7 @@ import { Disposable, IDisposable } from '../../../../../base/common/lifecycle.js import { MarkdownRenderer } from '../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; import { IChatProgressRenderableResponseContent } from '../../common/chatModel.js'; -import { IChatTask } from '../../common/chatService.js'; +import { IChatTask, IChatTaskSerialized } from '../../common/chatService.js'; import { IChatContentPart, IChatContentPartRenderContext } from './chatContentParts.js'; import { ChatProgressContentPart } from './chatProgressContentPart.js'; import { ChatCollapsibleListContentPart, CollapsibleListPool } from './chatReferencesContentPart.js'; @@ -21,7 +21,7 @@ export class ChatTaskContentPart extends Disposable implements IChatContentPart private isSettled: boolean; constructor( - private readonly task: IChatTask, + private readonly task: IChatTask | IChatTaskSerialized, contentReferencesListPool: CollapsibleListPool, renderer: MarkdownRenderer, context: IChatContentPartRenderContext, @@ -36,8 +36,9 @@ export class ChatTaskContentPart extends Disposable implements IChatContentPart this.domNode.appendChild(refsPart.domNode); this.onDidChangeHeight = refsPart.onDidChangeHeight; } else { - // #217645 - const isSettled = task.isSettled?.() ?? true; + const isSettled = task.kind === 'progressTask' ? + task.isSettled() : + true; this.isSettled = isSettled; const showSpinner = !isSettled && !context.element.isComplete; const progressPart = this._register(instantiationService.createInstance(ChatProgressContentPart, task, renderer, context, showSpinner, true, undefined)); @@ -47,9 +48,16 @@ export class ChatTaskContentPart extends Disposable implements IChatContentPart } hasSameContent(other: IChatProgressRenderableResponseContent): boolean { - return other.kind === 'progressTask' - && other.progress.length === this.task.progress.length - && other.isSettled() === this.isSettled; + if ( + other.kind === 'progressTask' && + this.task.kind === 'progressTask' && + other.isSettled() !== this.isSettled + ) { + return false; + } + + return other.kind === this.task.kind && + other.progress.length === this.task.progress.length; } addDisposable(disposable: IDisposable): void { diff --git a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts index eec6156d468..053797cfae4 100644 --- a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts +++ b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts @@ -48,7 +48,7 @@ import { IChatAgentMetadata } from '../common/chatAgents.js'; import { ChatContextKeys } from '../common/chatContextKeys.js'; import { IChatRequestVariableEntry, IChatTextEditGroup } from '../common/chatModel.js'; import { chatSubcommandLeader } from '../common/chatParserTypes.js'; -import { ChatAgentVoteDirection, ChatAgentVoteDownReason, ChatErrorLevel, IChatConfirmation, IChatContentReference, IChatExtensionsContent, IChatFollowup, IChatMarkdownContent, IChatTask, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop } from '../common/chatService.js'; +import { ChatAgentVoteDirection, ChatAgentVoteDownReason, ChatErrorLevel, IChatConfirmation, IChatContentReference, IChatExtensionsContent, IChatFollowup, IChatMarkdownContent, IChatTask, IChatTaskSerialized, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop } from '../common/chatService.js'; import { IChatCodeCitations, IChatReferences, IChatRendererContent, IChatRequestViewModel, IChatResponseViewModel, IChatWorkingProgress, isRequestVM, isResponseVM } from '../common/chatViewModel.js'; import { getNWords } from '../common/chatWordCounter.js'; import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js'; @@ -905,7 +905,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer