Skip to content

Commit 431aebe

Browse files
authored
Fix for agent session progress (#281397)
1 parent a649ee8 commit 431aebe

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,22 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
188188
}
189189

190190
private renderDescription(session: ITreeNode<IAgentSession, FuzzyScore>, template: IAgentSessionItemTemplate): void {
191-
192-
// Support description as string
193-
if (typeof session.element.description === 'string') {
194-
template.description.textContent = session.element.description;
195-
}
196-
197-
// or as markdown
198-
else if (session.element.description) {
199-
template.elementDisposable.add(this.markdownRendererService.render(session.element.description, {
200-
sanitizerConfig: {
201-
replaceWithPlaintext: true,
202-
allowedTags: {
203-
override: allowedChatMarkdownHtmlTags,
191+
const description = session.element.description;
192+
if (description) {
193+
// Support description as string
194+
if (typeof description === 'string') {
195+
template.description.textContent = description;
196+
} else {
197+
template.elementDisposable.add(this.markdownRendererService.render(description, {
198+
sanitizerConfig: {
199+
replaceWithPlaintext: true,
200+
allowedTags: {
201+
override: allowedChatMarkdownHtmlTags,
202+
},
203+
allowedLinkSchemes: { augment: [this.productService.urlProtocol] }
204204
},
205-
allowedLinkSchemes: { augment: [this.productService.urlProtocol] }
206-
},
207-
}, template.description));
205+
}, template.description));
206+
}
208207
}
209208

210209
// Fallback to state label

src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -953,33 +953,35 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
953953

954954
for (let i = responseParts.length - 1; i >= 0; i--) {
955955
const part = responseParts[i];
956-
if (!description && part.kind === 'confirmation' && typeof part.message === 'string') {
957-
description = part.message;
956+
if (description) {
957+
break;
958958
}
959-
if (!description && part.kind === 'toolInvocation') {
959+
960+
if (part.kind === 'confirmation' && typeof part.message === 'string') {
961+
description = part.message;
962+
} else if (part.kind === 'toolInvocation') {
960963
const toolInvocation = part as IChatToolInvocation;
961964
const state = toolInvocation.state.get();
962965

963966
if (state.type !== IChatToolInvocation.StateKind.Completed) {
964-
const pastTenseMessage = toolInvocation.pastTenseMessage;
965-
const invocationMessage = toolInvocation.invocationMessage;
966-
description = pastTenseMessage || invocationMessage;
967+
description = toolInvocation.pastTenseMessage || toolInvocation.invocationMessage;
967968

968969
if (state.type === IChatToolInvocation.StateKind.WaitingForConfirmation) {
969-
const message = toolInvocation.confirmationMessages?.title && (typeof toolInvocation.confirmationMessages.title === 'string'
970-
? toolInvocation.confirmationMessages.title
971-
: toolInvocation.confirmationMessages.title.value);
972-
description = message ?? localize('chat.sessions.description.waitingForConfirmation', "Waiting for confirmation: {0}", typeof description === 'string' ? description : description.value);
970+
const confirmationTitle = toolInvocation.confirmationMessages?.title;
971+
const titleMessage = confirmationTitle && (typeof confirmationTitle === 'string'
972+
? confirmationTitle
973+
: confirmationTitle.value);
974+
const descriptionValue = typeof description === 'string' ? description : description.value;
975+
description = titleMessage ?? localize('chat.sessions.description.waitingForConfirmation', "Waiting for confirmation: {0}", descriptionValue);
973976
}
974977
}
975-
}
976-
if (!description && part.kind === 'toolInvocationSerialized') {
978+
} else if (part.kind === 'toolInvocationSerialized') {
977979
description = part.invocationMessage;
978-
}
979-
if (!description && part.kind === 'progressMessage') {
980+
} else if (part.kind === 'progressMessage') {
980981
description = part.content;
981982
}
982983
}
984+
983985
return renderAsPlaintext(description, { useLinkFormatter: true });
984986
}
985987

0 commit comments

Comments
 (0)