Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have ChatView be default "Ask Chat" location #192608

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/workbench/browser/quickaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IWorkbenchQuickAccessConfiguration {
readonly experimental: {
readonly suggestCommands: boolean;
readonly enableNaturalLanguageSearch: boolean;
readonly askChatLocation: 'quickChat' | 'chatView';
};
};
readonly quickOpen: {
Expand Down
11 changes: 11 additions & 0 deletions src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
'description': localize('suggestCommands', "Controls whether the command palette should have a list of commonly used commands."),
'default': false
},
'workbench.commandPalette.experimental.askChatLocation': {
'type': 'string',
tags: ['experimental'],
'description': localize('askChatLocation', "Controls where the command palette should ask chat questions."),
'default': 'chatView',
enum: ['chatView', 'quickChat'],
enumDescriptions: [
localize('askChatLocation.chatView', "Ask chat questions in the Chat view."),
localize('askChatLocation.quickChat', "Ask chat questions in Quick Chat.")
]
},
'workbench.commandPalette.experimental.enableNaturalLanguageSearch': {
'type': 'boolean',
tags: ['experimental'],
Expand Down
39 changes: 39 additions & 0 deletions src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,47 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions';

export const CHAT_CATEGORY = { value: localize('chat.category', "Chat"), original: 'Chat' };
export const CHAT_OPEN_ACTION_ID = 'workbench.action.chat.open';

class QuickChatGlobalAction extends Action2 {
constructor() {
super({
id: CHAT_OPEN_ACTION_ID,
title: { value: localize('quickChat', "Quick Chat"), original: 'Quick Chat' },
precondition: CONTEXT_PROVIDER_EXISTS,
icon: Codicon.commentDiscussion,
f1: false,
category: CHAT_CATEGORY,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyI,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the keybinding from the extension if you haven't done that already

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac: {
primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KeyI
}
}
});
}

override async run(accessor: ServicesAccessor, query?: string): Promise<void> {
const chatService = accessor.get(IChatService);
const chatWidgetService = accessor.get(IChatWidgetService);
const providers = chatService.getProviderInfos();
if (!providers.length) {
return;
}
const chatWidget = await chatWidgetService.revealViewForProvider(providers[0].id);
if (!chatWidget) {
return;
}
if (query) {
chatWidget.acceptInput(query);
}
chatWidget.focusInput();
}
}

export function registerChatActions() {
registerAction2(QuickChatGlobalAction);
registerEditorAction(class ChatAcceptInput extends EditorAction {
constructor() {
super({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { ASK_QUICK_QUESTION_ACTION_ID } from 'vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
import { CommandInformationResult, IAiRelatedInformationService, RelatedInformationType } from 'vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation';
import { CHAT_OPEN_ACTION_ID } from 'vs/workbench/contrib/chat/browser/actions/chatActions';

export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {

Expand Down Expand Up @@ -181,7 +182,7 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
if (info) {
additionalPicks.push({
label: localize('askXInChat', "Ask {0}: {1}", info.displayName, filter),
commandId: ASK_QUICK_QUESTION_ACTION_ID,
commandId: this.configuration.experimental.askChatLocation === 'quickChat' ? ASK_QUICK_QUESTION_ACTION_ID : CHAT_OPEN_ACTION_ID,
args: [filter]
});
}
Expand Down