From b80272842e5135b1716a499947cdd71973f4e197 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 25 Sep 2024 10:59:30 +0200 Subject: [PATCH] chat command center polish (#229674) * mark `chat.commandCenter.enabled` as EXP setting, change default * render keybindings * order in buckets of panel, inline, and quick chat --- .vscode/settings.json | 2 +- .../browser/dropdownWithPrimaryActionViewItem.ts | 2 +- .../contrib/chat/browser/actions/chatActions.ts | 4 ++-- .../chat/browser/actions/chatContextActions.ts | 4 ++-- .../browser/actions/chatQuickInputActions.ts | 2 +- .../contrib/chat/browser/chat.contribution.ts | 3 ++- .../inlineChat/browser/inlineChatActions.ts | 16 +++++++++++----- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d2abaca7005d5..1f0f99b5df72a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -170,5 +170,5 @@ }, "css.format.spaceAroundSelectorSeparator": true, "typescript.enablePromptUseWorkspaceTsdk": true, - "inlineChat.experimental.onlyZoneWidget": true + "chat.commandCenter.enabled": true } diff --git a/src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts b/src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts index 37ab032480cfe..e8f00698cf808 100644 --- a/src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts +++ b/src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts @@ -61,7 +61,7 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem { menuAsChild: _options?.menuAsChild ?? true, classNames: className ? ['codicon', 'codicon-chevron-down', className] : ['codicon', 'codicon-chevron-down'], actionRunner: this._options?.actionRunner, - keybindingProvider: this._options?.getKeyBinding, + keybindingProvider: this._options?.getKeyBinding ?? (action => _keybindingService.lookupKeybinding(action.id)), hoverDelegate: _options?.hoverDelegate }); } diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts index 306d189602c8e..dc4e3178674ac 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts @@ -88,8 +88,8 @@ class OpenChatGlobalAction extends Action2 { }, menu: { id: MenuId.ChatCommandCenter, - group: 'open', - order: 1 + group: 'a_chat', + order: 10 } }); } diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts index 53efaea7ec791..c34772c6031cd 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts @@ -116,7 +116,7 @@ class AttachFileAction extends Action2 { precondition: ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor'), menu: { id: MenuId.ChatCommandCenter, - group: 'attach', + group: 'a_chat', order: 1, } }); @@ -146,7 +146,7 @@ class AttachSelectionAction extends Action2 { precondition: ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor'), menu: { id: MenuId.ChatCommandCenter, - group: 'attach', + group: 'a_chat', order: 2, } }); diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts index 96617956b60f6..05652beb1962b 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts @@ -116,7 +116,7 @@ class QuickChatGlobalAction extends Action2 { }, menu: { id: MenuId.ChatCommandCenter, - group: 'open', + group: 'c_quickChat', order: 5 }, metadata: { diff --git a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts index 23dc3df331c32..bec60f8fd124a 100644 --- a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts +++ b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts @@ -103,8 +103,9 @@ configurationRegistry.registerConfiguration({ }, 'chat.commandCenter.enabled': { type: 'boolean', + tags: ['experimental'], markdownDescription: nls.localize('chat.commandCenter.enabled', "Controls whether the command center shows a menu for chat actions (requires {0}).", '`#window.commandCenter#`'), - default: true + default: false }, 'chat.experimental.implicitContext': { type: 'boolean', diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.ts index 7fdc59e70ee5d..f6a04eeb1fa88 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.ts @@ -13,7 +13,7 @@ import { EditorContextKeys } from '../../../../editor/common/editorContextKeys.j import { InlineChatController, InlineChatRunOptions } from './inlineChatController.js'; import { ACTION_ACCEPT_CHANGES, CTX_INLINE_CHAT_HAS_AGENT, CTX_INLINE_CHAT_HAS_STASHED_SESSION, CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, CTX_INLINE_CHAT_USER_DID_EDIT, CTX_INLINE_CHAT_DOCUMENT_CHANGED, CTX_INLINE_CHAT_EDIT_MODE, EditMode, MENU_INLINE_CHAT_WIDGET_STATUS, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_RESPONSE_TYPE, InlineChatResponseType, ACTION_REGENERATE_RESPONSE, ACTION_VIEW_IN_CHAT, ACTION_TOGGLE_DIFF, CTX_INLINE_CHAT_CHANGE_HAS_DIFF, CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF, MENU_INLINE_CHAT_ZONE, ACTION_DISCARD_CHANGES } from '../common/inlineChat.js'; import { localize, localize2 } from '../../../../nls.js'; -import { Action2, IAction2Options } from '../../../../platform/actions/common/actions.js'; +import { Action2, IAction2Options, MenuId } from '../../../../platform/actions/common/actions.js'; import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js'; import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js'; import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js'; @@ -27,6 +27,7 @@ import { ILogService } from '../../../../platform/log/common/log.js'; import { IChatService } from '../../chat/common/chatService.js'; import { CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_IN_CHAT_INPUT } from '../../chat/common/chatContextKeys.js'; import { HunkInformation } from './inlineChatSession.js'; +import { ActiveEditorContext } from '../../../common/contextkeys.js'; CommandsRegistry.registerCommandAlias('interactiveEditor.start', 'inlineChat.start'); CommandsRegistry.registerCommandAlias('interactive.acceptChanges', ACTION_ACCEPT_CHANGES); @@ -49,17 +50,22 @@ export class StartSessionAction extends EditorAction2 { constructor() { super({ id: 'inlineChat.start', - title: localize2('run', 'Editor Chat'), + title: localize2('run', 'Editor Inline Chat'), category: AbstractInlineChatAction.category, f1: true, - precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_AGENT, EditorContextKeys.writable), + precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_AGENT, ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor')), keybinding: { - when: EditorContextKeys.focus, + when: ContextKeyExpr.and(EditorContextKeys.focus, EditorContextKeys.writable), weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.CtrlCmd | KeyCode.KeyI, secondary: [KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyI)], }, - icon: START_INLINE_CHAT + icon: START_INLINE_CHAT, + menu: { + id: MenuId.ChatCommandCenter, + group: 'b_inlineChat', + order: 10, + } }); }