From 205b792fc40cd512d537b86556b581962637a83a Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 31 Jan 2025 11:28:02 -0800 Subject: [PATCH] Fix showing wrong welcome view content when offline Only apply agent content override hack in chatwidget welcome content, not contributed welcome views Fix microsoft/vscode-copilot#12726 --- src/vs/workbench/contrib/chat/browser/chatWidget.ts | 5 ++++- .../chat/browser/viewsWelcome/chatViewWelcomeController.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/chatWidget.ts index 8858806e069b7..a3e4acb19aca4 100644 --- a/src/vs/workbench/contrib/chat/browser/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatWidget.ts @@ -587,7 +587,10 @@ export class ChatWidget extends Disposable implements IChatWidget { const welcomePart = this._register(this.instantiationService.createInstance( ChatViewWelcomePart, { ...welcomeContent, tips, }, - { location: this.location } + { + location: this.location, + isWidgetWelcomeViewContent: true + } )); dom.append(this.welcomeMessageContainer, welcomePart.element); } diff --git a/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.ts b/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.ts index 9fe96562bba28..eb8eadcfa0d35 100644 --- a/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.ts +++ b/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.ts @@ -116,6 +116,7 @@ export interface IChatViewWelcomeContent { export interface IChatViewWelcomeRenderOptions { firstLinkToButton?: boolean; location: ChatAgentLocation; + isWidgetWelcomeViewContent?: boolean; } export class ChatViewWelcomePart extends Disposable { @@ -146,7 +147,7 @@ export class ChatViewWelcomePart extends Disposable { title.textContent = content.title; // Preview indicator - if (options?.location === ChatAgentLocation.EditingSession && typeof content.message !== 'function' && chatAgentService.toolsAgentModeEnabled) { + if (options?.location === ChatAgentLocation.EditingSession && typeof content.message !== 'function' && chatAgentService.toolsAgentModeEnabled && options.isWidgetWelcomeViewContent) { // Override welcome message for the agent. Sort of a hack, should it come from the participant? This case is different because the welcome content typically doesn't change per ChatWidget const agentMessage = localize({ key: 'agentMessage', comment: ['{Locked="["}', '{Locked="]({0})"}'] }, "Ask Copilot to edit your files in [agent mode]({0}). Copilot will automatically use multiple requests to pick files to edit, run terminal commands, and iterate on errors.\n\nCopilot is powered by AI, so mistakes are possible. Review output carefully before use.", 'https://aka.ms/vscode-copilot-agent'); content.message = new MarkdownString(agentMessage);