Skip to content

Commit 5f88101

Browse files
dmitrivMSCopilotTylerLeonhardt
authored
Add setting to turn off "Ask GitHub Copilot" option in command palette (microsoft#270458)
* Added setting to turn off "Ask GitHub Copilot" option in command palette * Update src/vs/workbench/browser/quickaccess.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * PR feedback * Update src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.ts Co-authored-by: Tyler James Leonhardt <2644648+TylerLeonhardt@users.noreply.github.com> * Update src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.ts Co-authored-by: Tyler James Leonhardt <2644648+TylerLeonhardt@users.noreply.github.com> * Remove experimental from showAskChat setting * PR feedback --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tyler James Leonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
1 parent 4dbe013 commit 5f88101

3 files changed

Lines changed: 35 additions & 16 deletions

File tree

src/vs/workbench/browser/quickaccess.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface IWorkbenchQuickAccessConfiguration {
2929
readonly commandPalette: {
3030
readonly history: number;
3131
readonly preserveInput: boolean;
32+
readonly showAskInChat: boolean;
3233
readonly experimental: {
3334
readonly suggestCommands: boolean;
3435
readonly enableNaturalLanguageSearch: boolean;
@@ -53,6 +54,7 @@ export function getQuickNavigateHandler(id: string, next?: boolean): ICommandHan
5354
quickInputService.navigate(!!next, quickNavigate);
5455
};
5556
}
57+
5658
export class PickerEditorState extends Disposable {
5759
private _editorViewState: {
5860
editor: EditorInput;

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
490490
localize('askChatLocation.quickChat', "Ask chat questions in Quick Chat.")
491491
]
492492
},
493+
'workbench.commandPalette.showAskInChat': {
494+
'type': 'boolean',
495+
tags: ['experimental'],
496+
'description': localize('showAskInChat', "Controls whether the command palette shows 'Ask in Chat' option at the bottom."),
497+
'default': true
498+
},
493499
'workbench.commandPalette.experimental.enableNaturalLanguageSearch': {
494500
'type': 'boolean',
495501
tags: ['experimental'],

src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
9898

9999
return {
100100
preserveInput: commandPaletteConfig.preserveInput,
101+
showAskInChat: commandPaletteConfig.showAskInChat,
101102
experimental: commandPaletteConfig.experimental
102103
};
103104
}
@@ -158,29 +159,39 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
158159
return [];
159160
}
160161

161-
let additionalPicks;
162-
162+
let additionalPicks: (ICommandQuickPick | IQuickPickSeparator)[] = [];
163163
try {
164164
// Wait a bit to see if the user is still typing
165165
await timeout(CommandsQuickAccessProvider.AI_RELATED_INFORMATION_DEBOUNCE, token);
166166
additionalPicks = await this.getRelatedInformationPicks(allPicks, picksSoFar, filter, token);
167167
} catch (e) {
168-
return [];
168+
// Ignore and continue to add "Ask in Chat" option
169169
}
170170

171-
if (picksSoFar.length || additionalPicks.length) {
172-
additionalPicks.push({
173-
type: 'separator'
174-
});
175-
}
176-
177-
const defaultAgent = this.chatAgentService.getDefaultAgent(ChatAgentLocation.Chat);
178-
if (defaultAgent) {
179-
additionalPicks.push({
180-
label: localize('askXInChat', "Ask {0}: {1}", defaultAgent.fullName, filter),
181-
commandId: this.configuration.experimental.askChatLocation === 'quickChat' ? ASK_QUICK_QUESTION_ACTION_ID : CHAT_OPEN_ACTION_ID,
182-
args: [filter]
183-
});
171+
// If enabled in settings, add "Ask in Chat" option after a separator (if needed).
172+
if (this.configuration.showAskInChat) {
173+
const defaultAgent = this.chatAgentService.getDefaultAgent(ChatAgentLocation.Chat);
174+
if (defaultAgent) {
175+
if (picksSoFar.length || additionalPicks.length) {
176+
additionalPicks.push({
177+
type: 'separator'
178+
});
179+
}
180+
181+
additionalPicks.push({
182+
label: localize('commandsQuickAccess.askInChat', "Ask in Chat: {0}", filter),
183+
commandId: this.configuration.experimental.askChatLocation === 'quickChat' ? ASK_QUICK_QUESTION_ACTION_ID : CHAT_OPEN_ACTION_ID,
184+
args: [filter],
185+
buttons: [{
186+
iconClass: ThemeIcon.asClassName(Codicon.gear),
187+
tooltip: localize('commandsQuickAccess.configureAskInChatSetting', "Configure visibility"),
188+
}],
189+
trigger: () => {
190+
void this.preferencesService.openSettings({ jsonEditor: false, query: 'workbench.commandPalette.showAskInChat' });
191+
return TriggerAction.CLOSE_PICKER;
192+
},
193+
});
194+
}
184195
}
185196

186197
return additionalPicks;

0 commit comments

Comments
 (0)