From 448a760c0b26758012fe958977038182fb0ef606 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 30 Aug 2023 11:07:27 -0700 Subject: [PATCH] Add setting to disable chat history variables --- .../contrib/chat/browser/contrib/chatInputEditorContrib.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts index d4ff01aec83f2..e110d6ad3ccdc 100644 --- a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts +++ b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts @@ -15,6 +15,7 @@ import { CompletionContext, CompletionItem, CompletionItemKind, CompletionList } import { ITextModel } from 'vs/editor/common/model'; import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; import { localize } from 'vs/nls'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Registry } from 'vs/platform/registry/common/platform'; import { inputPlaceholderForeground } from 'vs/platform/theme/common/colorRegistry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -357,6 +358,7 @@ class VariableCompletions extends Disposable { @ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService, @IChatWidgetService private readonly chatWidgetService: IChatWidgetService, @IChatVariablesService private readonly chatVariablesService: IChatVariablesService, + @IConfigurationService private readonly configurationService: IConfigurationService, ) { super(); @@ -389,13 +391,14 @@ class VariableCompletions extends Disposable { .filter(isResponseVM); // TODO@roblourens work out a real API for this- maybe it can be part of the two-step flow that @file will probably use - const historyItems = history.map((h, i): CompletionItem => ({ + const historyVariablesEnabled = this.configurationService.getValue('chat.experimental.historyVariables'); + const historyItems = historyVariablesEnabled ? history.map((h, i): CompletionItem => ({ label: `@response:${i + 1}`, detail: h.response.asString(), insertText: `@response:${String(i + 1).padStart(String(history.length).length, '0')} `, kind: CompletionItemKind.Text, range: { insert, replace }, - })); + })) : []; const variableItems = Array.from(this.chatVariablesService.getVariables()).map(v => { const withAt = `@${v.name}`;