From 9b4e21695e2b905d293544dcb583fae2ef8ec7c0 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 22 Apr 2025 13:54:07 +0200 Subject: [PATCH] make sure chat edits part use the canonical uris (#247120) fyi @roblourens re https://github.com/microsoft/vscode-copilot/issues/16050 --- .../api/browser/mainThreadChatAgents2.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts index 953499f889f..4560cc6026f 100644 --- a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts +++ b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts @@ -21,6 +21,7 @@ import { ILanguageFeaturesService } from '../../../editor/common/services/langua import { ExtensionIdentifier } from '../../../platform/extensions/common/extensions.js'; import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js'; import { ILogService } from '../../../platform/log/common/log.js'; +import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js'; import { IChatWidgetService } from '../../contrib/chat/browser/chat.js'; import { ChatInputPart } from '../../contrib/chat/browser/chatInputPart.js'; import { AddDynamicVariableAction, IAddDynamicVariableContext } from '../../contrib/chat/browser/contrib/chatDynamicVariables.js'; @@ -102,6 +103,7 @@ export class MainThreadChatAgents2 extends Disposable implements MainThreadChatA @IInstantiationService private readonly _instantiationService: IInstantiationService, @ILogService private readonly _logService: ILogService, @IExtensionService private readonly _extensionService: IExtensionService, + @IUriIdentityService private readonly _uriIdentityService: IUriIdentityService, ) { super(); this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostChatAgents2); @@ -227,7 +229,19 @@ export class MainThreadChatAgents2 extends Disposable implements MainThreadChatA } async $handleProgressChunk(requestId: string, progress: IChatProgressDto, responsePartHandle?: number): Promise { - const revivedProgress = progress.kind === 'notebookEdit' ? ChatNotebookEdit.fromChatEdit(revive(progress)) : revive(progress) as IChatProgress; + + const revivedProgress = progress.kind === 'notebookEdit' + ? ChatNotebookEdit.fromChatEdit(revive(progress)) + : revive(progress) as IChatProgress; + + if (revivedProgress.kind === 'notebookEdit' + || revivedProgress.kind === 'textEdit' + || revivedProgress.kind === 'codeblockUri' + ) { + // make sure to use the canonical uri + revivedProgress.uri = this._uriIdentityService.asCanonicalUri(revivedProgress.uri); + } + if (revivedProgress.kind === 'progressTask') { const handle = ++this._responsePartHandlePool; const responsePartId = `${requestId}_${handle}`;