mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Fix broken chat view after receiving a progressTask (#248749)
Fix #217645
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Ch
|
||||
return this.renderTreeData(content, templateData, context);
|
||||
} else if (content.kind === 'progressMessage') {
|
||||
return this.instantiationService.createInstance(ChatProgressContentPart, content, this.renderer, context, undefined, undefined, undefined);
|
||||
} else if (content.kind === 'progressTask') {
|
||||
} else if (content.kind === 'progressTask' || content.kind === 'progressTaskSerialized') {
|
||||
return this.renderProgressTask(content, templateData, context);
|
||||
} else if (content.kind === 'command') {
|
||||
return this.instantiationService.createInstance(ChatCommandButtonContentPart, content, context);
|
||||
@@ -1051,7 +1051,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
|
||||
return part;
|
||||
}
|
||||
|
||||
private renderProgressTask(task: IChatTask, templateData: IChatListItemTemplate, context: IChatContentPartRenderContext): IChatContentPart | undefined {
|
||||
private renderProgressTask(task: IChatTask | IChatTaskSerialized, templateData: IChatListItemTemplate, context: IChatContentPartRenderContext): IChatContentPart | undefined {
|
||||
if (!isResponseVM(context.element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import { CellUri, ICellEditOperation } from '../../notebook/common/notebookCommo
|
||||
import { IChatAgentCommand, IChatAgentData, IChatAgentResult, IChatAgentService, reviveSerializedAgent } from './chatAgents.js';
|
||||
import { IChatEditingService, IChatEditingSession } from './chatEditingService.js';
|
||||
import { ChatRequestTextPart, IParsedChatRequest, reviveParsedChatRequest } from './chatParserTypes.js';
|
||||
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, IChatAgentMarkdownContentWithVulnerability, IChatCodeCitation, IChatCommandButton, IChatConfirmation, IChatContentInlineReference, IChatContentReference, IChatEditingSessionAction, IChatExtensionsContent, IChatFollowup, IChatLocationData, IChatMarkdownContent, IChatNotebookEdit, IChatPrepareToolInvocationPart, IChatProgress, IChatProgressMessage, IChatResponseCodeblockUriPart, IChatResponseProgressFileTreeData, IChatTask, IChatTextEdit, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop, IChatUsedContext, IChatWarningMessage, isIUsedContext } from './chatService.js';
|
||||
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, IChatAgentMarkdownContentWithVulnerability, IChatCodeCitation, IChatCommandButton, IChatConfirmation, IChatContentInlineReference, IChatContentReference, IChatEditingSessionAction, IChatExtensionsContent, IChatFollowup, IChatLocationData, IChatMarkdownContent, IChatNotebookEdit, IChatPrepareToolInvocationPart, IChatProgress, IChatProgressMessage, IChatResponseCodeblockUriPart, IChatResponseProgressFileTreeData, IChatTask, IChatTaskSerialized, IChatTextEdit, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop, IChatUsedContext, IChatWarningMessage, isIUsedContext } from './chatService.js';
|
||||
import { IChatRequestVariableValue } from './chatVariables.js';
|
||||
import { ChatAgentLocation, ChatMode } from './constants.js';
|
||||
|
||||
@@ -311,11 +311,11 @@ export type IChatProgressHistoryResponseContent =
|
||||
| IChatCommandButton
|
||||
| IChatWarningMessage
|
||||
| IChatTask
|
||||
| IChatTaskSerialized
|
||||
| IChatTextEditGroup
|
||||
| IChatNotebookEditGroup
|
||||
| IChatConfirmation
|
||||
| IChatExtensionsContent
|
||||
| IChatPrepareToolInvocationPart;
|
||||
| IChatExtensionsContent;
|
||||
|
||||
/**
|
||||
* "Normal" progress kinds that are rendered as parts of the stream of content.
|
||||
@@ -324,9 +324,10 @@ export type IChatProgressResponseContent =
|
||||
| IChatProgressHistoryResponseContent
|
||||
| IChatToolInvocation
|
||||
| IChatToolInvocationSerialized
|
||||
| IChatUndoStop;
|
||||
| IChatUndoStop
|
||||
| IChatPrepareToolInvocationPart;
|
||||
|
||||
const nonHistoryKinds = new Set(['toolInvocation', 'toolInvocationSerialized']);
|
||||
const nonHistoryKinds = new Set(['toolInvocation', 'toolInvocationSerialized', 'undoStop', 'prepareToolInvocation']);
|
||||
function isChatProgressHistoryResponseContent(content: IChatProgressResponseContent): content is IChatProgressHistoryResponseContent {
|
||||
return !nonHistoryKinds.has(content.kind);
|
||||
}
|
||||
|
||||
@@ -152,6 +152,12 @@ export interface IChatTaskDto {
|
||||
kind: 'progressTask';
|
||||
}
|
||||
|
||||
export interface IChatTaskSerialized {
|
||||
content: IMarkdownString;
|
||||
progress: (IChatWarningMessage | IChatContentReference)[];
|
||||
kind: 'progressTaskSerialized';
|
||||
}
|
||||
|
||||
export interface IChatTaskResult {
|
||||
content: IMarkdownString | void;
|
||||
kind: 'progressTaskResult';
|
||||
@@ -295,7 +301,8 @@ export type IChatProgress =
|
||||
| IChatToolInvocationSerialized
|
||||
| IChatExtensionsContent
|
||||
| IChatUndoStop
|
||||
| IChatPrepareToolInvocationPart;
|
||||
| IChatPrepareToolInvocationPart
|
||||
| IChatTaskSerialized;
|
||||
|
||||
export interface IChatFollowup {
|
||||
kind: 'reply';
|
||||
|
||||
Reference in New Issue
Block a user