Skip to content

Commit e6de1b0

Browse files
Miscellaneous NL Command Palette improvements (microsoft#185382)
* Always show "Ask Copilot" * Open Quick Question UX instead of Chat view * If we have _any_ similar commands, show the "similar commands" separators even if there are no regular picks * Have Semantic Similarity setting be on by default * Remove QQ setting since it's not really useful
1 parent 2f867fa commit e6de1b0

File tree

6 files changed

+39
-80
lines changed

6 files changed

+39
-80
lines changed

src/vs/platform/quickinput/browser/commandsQuickAccess.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2626
export interface ICommandQuickPick extends IPickerQuickAccessItem {
2727
readonly commandId: string;
2828
readonly commandAlias?: string;
29+
readonly args?: any[];
2930
}
3031

3132
export interface ICommandsQuickAccessOptions extends IPickerQuickAccessProviderOptions<ICommandQuickPick> {
@@ -211,7 +212,9 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
211212

212213
// Run
213214
try {
214-
await this.commandService.executeCommand(commandPick.commandId);
215+
commandPick.args?.length
216+
? await this.commandService.executeCommand(commandPick.commandId, ...commandPick.args)
217+
: await this.commandService.executeCommand(commandPick.commandId);
215218
} catch (error) {
216219
if (!isCancellationError(error)) {
217220
this.dialogService.error(localize('canNotRun', "Command '{0}' resulted in an error", commandPick.label), toErrorMessage(error));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
358358
'type': 'boolean',
359359
tags: ['experimental'],
360360
'description': localize('useSemanticSimilarity', "Controls whether the command palette should include similar commands. You must have an extension installed that provides Semantic Similarity."),
361-
'default': false
361+
'default': true
362362
},
363363
'workbench.quickOpen.closeOnFocusLost': {
364364
'type': 'boolean',

src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import { IChatReplyFollowup, IChatService } from 'vs/workbench/contrib/chat/comm
2424
import { ChatViewModel } from 'vs/workbench/contrib/chat/common/chatViewModel';
2525
import { CHAT_CATEGORY } from 'vs/workbench/contrib/chat/browser/actions/chatActions';
2626
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
27-
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
2827
import { CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
2928

29+
export const ASK_QUICK_QUESTION_ACTION_ID = 'chat.action.askQuickQuestion';
30+
3031
export function registerChatQuickQuestionActions() {
3132
registerAction2(AskQuickQuestionAction);
3233
}
@@ -41,15 +42,14 @@ class AskQuickQuestionAction extends Action2 {
4142

4243
constructor() {
4344
super({
44-
id: 'chat.action.askQuickQuestion',
45+
id: ASK_QUICK_QUESTION_ACTION_ID,
4546
title: { value: localize('askQuickQuestion', "Ask Quick Question"), original: 'Ask Quick Question' },
4647
precondition: CONTEXT_PROVIDER_EXISTS,
47-
f1: true,
48+
f1: false,
4849
category: CHAT_CATEGORY,
4950
keybinding: {
5051
weight: KeybindingWeight.WorkbenchContrib,
51-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyI,
52-
when: ContextKeyExpr.equals('config.chat.experimental.quickQuestion.enable', true),
52+
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyI
5353
}
5454
});
5555
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ configurationRegistry.registerConfiguration({
7070
type: 'number',
7171
description: nls.localize('interactiveSession.editor.lineHeight', "Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."),
7272
default: 0
73-
},
74-
'chat.experimental.quickQuestion.enable': {
75-
type: 'boolean',
76-
description: nls.localize('interactiveSession.experimental.quickQuestion.enable', "Controls whether the quick question feature is enabled."),
77-
default: false,
78-
tags: ['experimental']
7973
}
8074
}
8175
});

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

Lines changed: 28 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ import { isFirefox } from 'vs/base/browser/browser';
3535
import { IProductService } from 'vs/platform/product/common/productService';
3636
import { ISemanticSimilarityService } from 'vs/workbench/services/semanticSimilarity/common/semanticSimilarityService';
3737
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
38-
import { ILogService } from 'vs/platform/log/common/log';
39-
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
38+
import { ASK_QUICK_QUESTION_ACTION_ID } from 'vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
4039

4140
export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {
4241

@@ -80,19 +79,10 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
8079
) {
8180
super({
8281
showAlias: !Language.isDefaultVariant(),
83-
noResultsPick: (filter) => {
84-
const info = this.chatService.getProviderInfos()[0];
85-
return info
86-
? {
87-
label: localize('askXInChat', "Ask {0}: {1}", info.displayName, filter),
88-
commandId: AskInInteractiveAction.ID,
89-
accept: () => commandService.executeCommand(AskInInteractiveAction.ID, filter)
90-
}
91-
: {
92-
label: localize('noCommandResults', "No matching commands"),
93-
commandId: ''
94-
};
95-
},
82+
noResultsPick: () => ({
83+
label: localize('noCommandResults', "No matching commands"),
84+
commandId: ''
85+
}),
9686
}, instantiationService, keybindingService, commandService, telemetryService, dialogService);
9787

9888
this._register(configurationService.onDidChangeConfiguration((e) => this.updateOptions(e)));
@@ -175,12 +165,7 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
175165

176166
const sortedIndices = scores.map((_, i) => i).sort((a, b) => scores[b] - scores[a]);
177167
const setOfPicksSoFar = new Set(picksSoFar.map(p => p.commandId));
178-
const additionalPicks: Array<ICommandQuickPick | IQuickPickSeparator> = picksSoFar.length > 0
179-
? [{
180-
type: 'separator',
181-
label: localize('semanticSimilarity', "similar commands")
182-
}]
183-
: [];
168+
const additionalPicks = new Array<ICommandQuickPick | IQuickPickSeparator>();
184169

185170
let numOfSmartPicks = 0;
186171
for (const i of sortedIndices) {
@@ -196,6 +181,28 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
196181
}
197182
}
198183

184+
if (numOfSmartPicks) {
185+
additionalPicks.unshift({
186+
type: 'separator',
187+
label: localize('semanticSimilarity', "similar commands")
188+
});
189+
}
190+
191+
if (picksSoFar.length || additionalPicks.length) {
192+
additionalPicks.push({
193+
type: 'separator'
194+
});
195+
}
196+
197+
const info = this.chatService.getProviderInfos()[0];
198+
if (info) {
199+
additionalPicks.push({
200+
label: localize('askXInChat', "Ask {0}: {1}", info.displayName, filter),
201+
commandId: ASK_QUICK_QUESTION_ACTION_ID,
202+
args: [filter]
203+
});
204+
}
205+
199206
return additionalPicks;
200207
}
201208

@@ -299,48 +306,4 @@ export class ClearCommandHistoryAction extends Action2 {
299306
}
300307
}
301308

302-
// TODO: Should this live here? It seems fairly generic and could live in the interactive code.
303-
export class AskInInteractiveAction extends Action2 {
304-
305-
static readonly ID = 'workbench.action.askCommandInChat';
306-
307-
constructor() {
308-
super({
309-
id: AskInInteractiveAction.ID,
310-
title: { value: localize('askInChat', "Ask In Chat"), original: 'Ask In Chat' },
311-
f1: false
312-
});
313-
}
314-
315-
async run(accessor: ServicesAccessor, filter?: string): Promise<void> {
316-
const chatService = accessor.get(IChatService);
317-
const chatWidgetService = accessor.get(IChatWidgetService);
318-
const logService = accessor.get(ILogService);
319-
320-
if (!filter) {
321-
throw new Error('No filter provided.');
322-
}
323-
324-
let providerId: string;
325-
const providerInfos = chatService.getProviderInfos();
326-
switch (providerInfos.length) {
327-
case 0:
328-
throw new Error('No chat provider found.');
329-
case 1:
330-
providerId = providerInfos[0].id;
331-
break;
332-
default:
333-
logService.warn('Multiple chat providers found. Using the first one.');
334-
providerId = providerInfos[0].id;
335-
break;
336-
}
337-
338-
const widget = await chatWidgetService.revealViewForProvider(providerId);
339-
if (widget?.viewModel) {
340-
// TODO: Maybe this could provide metadata saying it came from the command palette?
341-
chatService.sendRequestToProvider(widget.viewModel.sessionId, { message: filter });
342-
}
343-
}
344-
}
345-
346309
//#endregion

src/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IQuickAccessRegistry, Extensions } from 'vs/platform/quickinput/common/
88
import { Registry } from 'vs/platform/registry/common/platform';
99
import { HelpQuickAccessProvider } from 'vs/platform/quickinput/browser/helpQuickAccess';
1010
import { ViewQuickAccessProvider, OpenViewPickerAction, QuickAccessViewPickerAction } from 'vs/workbench/contrib/quickaccess/browser/viewQuickAccess';
11-
import { CommandsQuickAccessProvider, ShowAllCommandsAction, ClearCommandHistoryAction, AskInInteractiveAction } from 'vs/workbench/contrib/quickaccess/browser/commandsQuickAccess';
11+
import { CommandsQuickAccessProvider, ShowAllCommandsAction, ClearCommandHistoryAction } from 'vs/workbench/contrib/quickaccess/browser/commandsQuickAccess';
1212
import { MenuRegistry, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
1313
import { KeyMod } from 'vs/base/common/keyCodes';
1414
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@@ -112,7 +112,6 @@ registerAction2(ClearCommandHistoryAction);
112112
registerAction2(ShowAllCommandsAction);
113113
registerAction2(OpenViewPickerAction);
114114
registerAction2(QuickAccessViewPickerAction);
115-
registerAction2(AskInInteractiveAction);
116115

117116
const inViewsPickerContextKey = 'inViewsPicker';
118117
const inViewsPickerContext = ContextKeyExpr.and(inQuickPickContext, ContextKeyExpr.has(inViewsPickerContextKey));

0 commit comments

Comments
 (0)