Skip to content

Commit 6711af1

Browse files
dileepyavanCopilot
andauthored
fix for 264315 (#269632)
* fix for 264315 * Update src/vs/workbench/contrib/chat/common/chatService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Updating silent property for onload scenario * implementing code comments --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a50d3d2 commit 6711af1

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ChatConfirmationContentPart extends Disposable implements IChatCont
4040
{ label: localize('accept', "Accept"), data: confirmation.data },
4141
{ label: localize('dismiss', "Dismiss"), data: confirmation.data, isSecondary: true },
4242
];
43-
const confirmationWidget = this._register(this.instantiationService.createInstance(SimpleChatConfirmationWidget, context.container, { title: confirmation.title, buttons, message: confirmation.message }));
43+
const confirmationWidget = this._register(this.instantiationService.createInstance(SimpleChatConfirmationWidget, context.container, { title: confirmation.title, buttons, message: confirmation.message, silent: confirmation.isLive === false }));
4444
confirmationWidget.setShowButtons(!confirmation.isUsed);
4545

4646
this._register(confirmationWidget.onDidChangeHeight(() => this._onDidChangeHeight.fire()));

src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationWidget.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface IChatConfirmationWidgetOptions<T> {
4343
subtitle?: string | IMarkdownString;
4444
buttons: IChatConfirmationButton<T>[];
4545
toolbarData?: { arg: any; partType: string; partSource?: string };
46+
silent?: boolean;
4647
}
4748

4849
export class ChatQueryTitlePart extends Disposable {
@@ -129,6 +130,7 @@ abstract class BaseSimpleChatConfirmationWidget<T> extends Disposable {
129130
protected readonly markdownRenderer: MarkdownRenderer;
130131
private readonly title: string | IMarkdownString;
131132

133+
private readonly silent: boolean;
132134
private readonly notification = this._register(new MutableDisposable<DisposableStore>());
133135

134136
constructor(
@@ -142,8 +144,9 @@ abstract class BaseSimpleChatConfirmationWidget<T> extends Disposable {
142144
) {
143145
super();
144146

145-
const { title, subtitle, message, buttons } = options;
147+
const { title, subtitle, message, buttons, silent } = options;
146148
this.title = title;
149+
this.silent = !!silent;
147150

148151

149152
const elements = dom.h('.chat-confirmation-widget-container@container', [
@@ -235,7 +238,7 @@ abstract class BaseSimpleChatConfirmationWidget<T> extends Disposable {
235238
protected renderMessage(element: HTMLElement, listContainer: HTMLElement): void {
236239
this.messageElement.append(element);
237240

238-
if (this.showingButtons && this._configurationService.getValue<boolean>('chat.notifyWindowOnConfirmation')) {
241+
if (this.showingButtons && this._configurationService.getValue<boolean>('chat.notifyWindowOnConfirmation') && !this.silent) {
239242
const targetWindow = dom.getWindow(listContainer);
240243
if (!targetWindow.document.hasFocus()) {
241244
this.notifyConfirmationNeeded(targetWindow);

src/vs/workbench/contrib/chat/common/chatModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,8 @@ export class ChatModel extends Disposable implements IChatModel {
18521852
id: item.id,
18531853
metadata: item.metadata
18541854
};
1855+
} else if (item.kind === 'confirmation') {
1856+
return { ...item, isLive: false };
18551857
} else {
18561858
// eslint-disable-next-line local/code-no-any-casts
18571859
return item as any; // TODO

src/vs/workbench/contrib/chat/common/chatService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ export interface IChatConfirmation {
260260
title: string;
261261
message: string | IMarkdownString;
262262
data: any;
263+
/** Indicates whether this came from a current chat session (true/undefined) or a restored historic session (false) */
264+
isLive?: boolean;
263265
buttons?: string[];
264266
isUsed?: boolean;
265267
kind: 'confirmation';

0 commit comments

Comments
 (0)