Skip to content

Commit

Permalink
Merge pull request #192346 from microsoft/roblou/obvious-seahorse
Browse files Browse the repository at this point in the history
Add setting to disable chat history variables
  • Loading branch information
roblourens authored Sep 6, 2023
2 parents cec6e5b + 448a760 commit 8b617bd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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}`;
Expand Down

0 comments on commit 8b617bd

Please sign in to comment.