mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-18 09:53:23 +01:00
fix: rerender progress task when it settles
This commit is contained in:
@@ -74,14 +74,11 @@ class ChatAgentResponseStream {
|
||||
this._firstProgress = this._stopWatch.elapsed();
|
||||
}
|
||||
|
||||
this._proxy.$handleProgressChunk(this._request.requestId, progress)
|
||||
.then((handle) => {
|
||||
if (typeof handle === 'number' && task) {
|
||||
task().then((res) => {
|
||||
this._proxy.$handleProgressChunk(this._request.requestId, typeConvert.ChatTaskResult.from(res), handle);
|
||||
});
|
||||
}
|
||||
});
|
||||
Promise.all([this._proxy.$handleProgressChunk(this._request.requestId, progress,), task ? task() : undefined]).then(([handle, res]) => {
|
||||
if (typeof handle === 'number' && task) {
|
||||
this._proxy.$handleProgressChunk(this._request.requestId, typeConvert.ChatTaskResult.from(res), handle);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this._apiObject = {
|
||||
|
||||
@@ -72,7 +72,7 @@ import { IChatProgressRenderableResponseContent, IChatTextEditGroup } from 'vs/w
|
||||
import { chatAgentLeader, chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes';
|
||||
import { IChatCommandButton, IChatConfirmation, IChatContentReference, IChatFollowup, IChatProgressMessage, IChatResponseProgressFileTreeData, IChatSendRequestOptions, IChatService, IChatTask, IChatWarningMessage, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChatVariablesService } from 'vs/workbench/contrib/chat/common/chatVariables';
|
||||
import { IChatProgressMessageRenderData, IChatRenderData, IChatResponseMarkdownRenderData, IChatResponseViewModel, IChatWelcomeMessageViewModel, isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
|
||||
import { IChatProgressMessageRenderData, IChatRenderData, IChatResponseMarkdownRenderData, IChatResponseViewModel, IChatTaskRenderData, IChatWelcomeMessageViewModel, isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
|
||||
import { IWordCountResult, getNWords } from 'vs/workbench/contrib/chat/common/chatWordCounter';
|
||||
import { createFileIconThemableTreeContainerScope } from 'vs/workbench/contrib/files/browser/views/explorerView';
|
||||
import { IFilesConfiguration } from 'vs/workbench/contrib/files/common/files';
|
||||
@@ -615,9 +615,13 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
|
||||
} else if (part.kind === 'command' ||
|
||||
part.kind === 'textEditGroup' ||
|
||||
part.kind === 'confirmation' ||
|
||||
part.kind === 'warning' ||
|
||||
part.kind === 'progressTask') {
|
||||
part.kind === 'warning') {
|
||||
partsToRender[index] = part;
|
||||
} else if (part.kind === 'progressTask') {
|
||||
partsToRender[index] = {
|
||||
task: part,
|
||||
isSettled: part.isSettled?.() ?? true
|
||||
};
|
||||
} else {
|
||||
const wordCountResult = this.getDataForProgressiveRender(element, contentToMarkdown(part.content), { renderedWordCount: 0, lastRenderTime: 0 });
|
||||
if (wordCountResult !== undefined) {
|
||||
@@ -662,6 +666,13 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
|
||||
isLast: index === renderableResponse.length - 1,
|
||||
} satisfies IChatProgressMessageRenderData;
|
||||
}
|
||||
|
||||
else if (part.kind === 'progressTask' && isProgressTaskRenderData(renderedPart) && renderedPart.isSettled !== part.isSettled?.()) {
|
||||
const isSettled = part.isSettled?.() ?? true;
|
||||
if (renderedPart.isSettled !== isSettled) {
|
||||
partsToRender[index] = { task: part, isSettled };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
isFullyRendered = partsToRender.length === 0 && !somePartIsNotFullyRendered;
|
||||
@@ -691,8 +702,8 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
} else if (isProgressTask(partToRender)) {
|
||||
result = this.renderProgressMessage(partToRender, partToRender.isSettled ? !partToRender.isSettled() : false);
|
||||
} else if (isProgressTaskRenderData(partToRender)) {
|
||||
result = this.renderProgressMessage(partToRender.task, !partToRender.isSettled);
|
||||
} else if (isCommandButtonRenderData(partToRender)) {
|
||||
result = this.renderCommandButton(element, partToRender);
|
||||
} else if (isTextEditRenderData(partToRender)) {
|
||||
@@ -1643,8 +1654,8 @@ function isProgressMessage(item: any): item is IChatProgressMessage {
|
||||
return item && 'kind' in item && item.kind === 'progressMessage';
|
||||
}
|
||||
|
||||
function isProgressTask(item: any): item is IChatTask {
|
||||
return item && 'kind' in item && item.kind === 'progressTask';
|
||||
function isProgressTaskRenderData(item: any): item is IChatTaskRenderData {
|
||||
return item && 'isSettled' in item;
|
||||
}
|
||||
|
||||
function isWarningRenderData(item: any): item is IChatWarningMessage {
|
||||
|
||||
@@ -214,15 +214,13 @@ export class Response implements IResponse {
|
||||
const responsePosition = this._responseParts.push(progress) - 1;
|
||||
this._updateRepr(quiet);
|
||||
|
||||
if (progress.task) {
|
||||
progress.task?.().then((content) => {
|
||||
// Replace the resolving part's content with the resolved response
|
||||
if (typeof content === 'string') {
|
||||
this._responseParts[responsePosition] = { ...progress, content: new MarkdownString(content) };
|
||||
}
|
||||
this._updateRepr(false);
|
||||
});
|
||||
}
|
||||
progress.task?.().then((content) => {
|
||||
// Replace the resolving part's content with the resolved response
|
||||
if (typeof content === 'string') {
|
||||
this._responseParts[responsePosition] = { ...progress, content: new MarkdownString(content) };
|
||||
}
|
||||
this._updateRepr(false);
|
||||
});
|
||||
} else {
|
||||
this._responseParts.push(progress);
|
||||
this._updateRepr(quiet);
|
||||
|
||||
@@ -95,7 +95,12 @@ export interface IChatProgressMessageRenderData {
|
||||
isLast: boolean;
|
||||
}
|
||||
|
||||
export type IChatRenderData = IChatResponseProgressFileTreeData | IChatResponseMarkdownRenderData | IChatProgressMessageRenderData | IChatCommandButton | IChatTextEditGroup | IChatConfirmation | IChatTask | IChatWarningMessage;
|
||||
export interface IChatTaskRenderData {
|
||||
task: IChatTask;
|
||||
isSettled: boolean;
|
||||
}
|
||||
|
||||
export type IChatRenderData = IChatResponseProgressFileTreeData | IChatResponseMarkdownRenderData | IChatProgressMessageRenderData | IChatCommandButton | IChatTextEditGroup | IChatConfirmation | IChatTaskRenderData | IChatWarningMessage;
|
||||
export interface IChatResponseRenderData {
|
||||
renderedParts: IChatRenderData[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user