From 177ddd8a6d3712530b44db0b4fba2e8053b97e4d Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 31 Jan 2025 13:38:13 -0800 Subject: [PATCH] Fix showing wrong welcome view content when offline (#239365) 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 d614ffcf1be8b..2d4a9c8ce4b61 100644 --- a/src/vs/workbench/contrib/chat/browser/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatWidget.ts @@ -630,7 +630,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);