Не подтверждена Коммит 50a2adc6 создал по автору Rob Lourens's avatar Rob Lourens Зафиксировано автором GitHub
Просмотр файлов

Cleanup chat context keys (#232515)

* Start renaming context keys

* vote

* detected agent

* More

* More

* chatEditApplied

* More

* More

* More

* Cleanup

* Cleanup
владелец f9922989
......@@ -13,7 +13,7 @@ import { IContextKeyService } from '../../../../platform/contextkey/common/conte
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { AccessibilityHelpAction } from './accessibleViewActions.js';
import { CONTEXT_CHAT_ENABLED } from '../../chat/common/chatContextKeys.js';
import { ChatContextKeys } from '../../chat/common/chatContextKeys.js';
import { CommentAccessibilityHelpNLS } from '../../comments/browser/commentsAccessibility.js';
import { CommentContextKeys } from '../../comments/common/commentContextKeys.js';
import { NEW_UNTITLED_FILE_COMMAND_ID } from '../../files/browser/fileConstants.js';
......@@ -115,7 +115,7 @@ export function getCommentCommandInfo(keybindingService: IKeybindingService, con
}
export function getChatCommandInfo(keybindingService: IKeybindingService, contextKeyService: IContextKeyService): string | undefined {
if (CONTEXT_CHAT_ENABLED.getValue(contextKeyService)) {
if (ChatContextKeys.enabled.getValue(contextKeyService)) {
return [AccessibilityHelpNLS.quickChat, AccessibilityHelpNLS.startInlineChat].join('\n');
}
return;
......
......@@ -3,26 +3,26 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from '../../../../../nls.js';
import { ICodeEditor } from '../../../../../editor/browser/editorBrowser.js';
import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions.js';
import { IChatWidgetService } from '../chat.js';
import { AccessibleViewProviderId, AccessibleViewType, AccessibleContentProvider } from '../../../../../platform/accessibility/browser/accessibleView.js';
import { AccessibilityVerbositySettingId } from '../../../accessibility/browser/accessibilityConfiguration.js';
import { AccessibleDiffViewerNext } from '../../../../../editor/browser/widget/diffEditor/commands.js';
import { INLINE_CHAT_ID } from '../../../inlineChat/common/inlineChat.js';
import { ICodeEditorService } from '../../../../../editor/browser/services/codeEditorService.js';
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js';
import { CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST, CONTEXT_CHAT_LOCATION, CONTEXT_IN_QUICK_CHAT } from '../../common/chatContextKeys.js';
import { AccessibleDiffViewerNext } from '../../../../../editor/browser/widget/diffEditor/commands.js';
import { localize } from '../../../../../nls.js';
import { AccessibleContentProvider, AccessibleViewProviderId, AccessibleViewType } from '../../../../../platform/accessibility/browser/accessibleView.js';
import { IAccessibleViewImplentation } from '../../../../../platform/accessibility/browser/accessibleViewRegistry.js';
import { ChatAgentLocation } from '../../common/chatAgents.js';
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js';
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
import { AccessibilityVerbositySettingId } from '../../../accessibility/browser/accessibilityConfiguration.js';
import { INLINE_CHAT_ID } from '../../../inlineChat/common/inlineChat.js';
import { ChatAgentLocation } from '../../common/chatAgents.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IChatWidgetService } from '../chat.js';
export class PanelChatAccessibilityHelp implements IAccessibleViewImplentation {
readonly priority = 107;
readonly name = 'panelChat';
readonly type = AccessibleViewType.Help;
readonly when = ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel), CONTEXT_IN_QUICK_CHAT.negate(), ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST));
readonly when = ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel), ChatContextKeys.inQuickChat.negate(), ContextKeyExpr.or(ChatContextKeys.inChatSession, ChatContextKeys.isResponse, ChatContextKeys.isRequest));
getProvider(accessor: ServicesAccessor) {
const codeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor() || accessor.get(ICodeEditorService).getFocusedCodeEditor();
return getChatAccessibilityHelpProvider(accessor, codeEditor ?? undefined, 'panelChat');
......@@ -33,7 +33,7 @@ export class QuickChatAccessibilityHelp implements IAccessibleViewImplentation {
readonly priority = 107;
readonly name = 'quickChat';
readonly type = AccessibleViewType.Help;
readonly when = ContextKeyExpr.and(CONTEXT_IN_QUICK_CHAT, ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST));
readonly when = ContextKeyExpr.and(ChatContextKeys.inQuickChat, ContextKeyExpr.or(ChatContextKeys.inChatSession, ChatContextKeys.isResponse, ChatContextKeys.isRequest));
getProvider(accessor: ServicesAccessor) {
const codeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor() || accessor.get(ICodeEditorService).getFocusedCodeEditor();
return getChatAccessibilityHelpProvider(accessor, codeEditor ?? undefined, 'quickChat');
......
......@@ -33,7 +33,7 @@ import { ACTIVE_GROUP, IEditorService } from '../../../../services/editor/common
import { IViewsService } from '../../../../services/views/common/viewsService.js';
import { IExtensionsWorkbenchService } from '../../../extensions/common/extensions.js';
import { ChatAgentLocation, IChatAgentService } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_INPUT_CURSOR_AT_TOP, CONTEXT_CHAT_INSTALL_ENTITLED, CONTEXT_CHAT_LOCATION, CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_QUICK_CHAT } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { extractAgentAndCommand } from '../../common/chatParserTypes.js';
import { IChatDetail, IChatService } from '../../common/chatService.js';
import { IChatRequestViewModel, IChatResponseViewModel, isRequestVM } from '../../common/chatViewModel.js';
......@@ -96,7 +96,7 @@ class OpenChatGlobalAction extends Action2 {
title: OpenChatGlobalAction.TITLE,
icon: defaultChat.icon,
f1: true,
precondition: CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED,
precondition: ChatContextKeys.panelParticipantRegistered,
category: CHAT_CATEGORY,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
......@@ -160,7 +160,7 @@ class ChatHistoryAction extends Action2 {
category: CHAT_CATEGORY,
icon: Codicon.history,
f1: true,
precondition: CONTEXT_CHAT_ENABLED
precondition: ChatContextKeys.enabled
});
}
......@@ -265,7 +265,7 @@ class OpenChatEditorAction extends Action2 {
title: localize2('interactiveSession.open', "Open Editor"),
f1: true,
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_ENABLED
precondition: ChatContextKeys.enabled
});
}
......@@ -286,7 +286,7 @@ class ChatAddAction extends Action2 {
category: CHAT_CATEGORY,
menu: {
id: MenuId.ChatInput,
when: CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel),
when: ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel),
group: 'navigation',
order: 1
}
......@@ -331,7 +331,7 @@ export function registerChatActions() {
super({
id: 'workbench.action.chat.clearInputHistory',
title: localize2('interactiveSession.clearHistory.label', "Clear Input History"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
category: CHAT_CATEGORY,
f1: true,
});
......@@ -347,7 +347,7 @@ export function registerChatActions() {
super({
id: 'workbench.action.chat.clearHistory',
title: localize2('chat.clear.label', "Clear All Workspace Chats"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
category: CHAT_CATEGORY,
f1: true,
});
......@@ -381,23 +381,23 @@ export function registerChatActions() {
super({
id: 'chat.action.focus',
title: localize2('actions.interactiveSession.focus', 'Focus Chat List'),
precondition: ContextKeyExpr.and(CONTEXT_IN_CHAT_INPUT),
precondition: ContextKeyExpr.and(ChatContextKeys.inChatInput),
category: CHAT_CATEGORY,
keybinding: [
// On mac, require that the cursor is at the top of the input, to avoid stealing cmd+up to move the cursor to the top
{
when: ContextKeyExpr.and(CONTEXT_CHAT_INPUT_CURSOR_AT_TOP, CONTEXT_IN_QUICK_CHAT.negate()),
when: ContextKeyExpr.and(ChatContextKeys.inputCursorAtTop, ChatContextKeys.inQuickChat.negate()),
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
weight: KeybindingWeight.EditorContrib,
},
// On win/linux, ctrl+up can always focus the chat list
{
when: ContextKeyExpr.and(ContextKeyExpr.or(IsWindowsContext, IsLinuxContext), CONTEXT_IN_QUICK_CHAT.negate()),
when: ContextKeyExpr.and(ContextKeyExpr.or(IsWindowsContext, IsLinuxContext), ChatContextKeys.inQuickChat.negate()),
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
weight: KeybindingWeight.EditorContrib,
},
{
when: ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_QUICK_CHAT),
when: ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inQuickChat),
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
weight: KeybindingWeight.WorkbenchContrib,
}
......@@ -424,10 +424,10 @@ export function registerChatActions() {
{
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate(), CONTEXT_IN_QUICK_CHAT.negate()),
when: ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate(), ChatContextKeys.inQuickChat.negate()),
},
{
when: ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate(), CONTEXT_IN_QUICK_CHAT),
when: ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate(), ChatContextKeys.inQuickChat),
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
weight: KeybindingWeight.WorkbenchContrib,
}
......@@ -462,7 +462,7 @@ MenuRegistry.appendMenuItem(MenuId.CommandCenter, {
icon: defaultChat.icon,
when: ContextKeyExpr.and(
ContextKeyExpr.has('config.chat.commandCenter.enabled'),
ContextKeyExpr.or(CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_INSTALL_ENTITLED)
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.installEntitled)
),
order: 10001,
});
......@@ -475,7 +475,7 @@ registerAction2(class ToggleChatControl extends ToggleTitleBarConfigAction {
localize('toggle.chatControlsDescription', "Toggle visibility of the Chat Controls in title bar"), 3, false,
ContextKeyExpr.and(
ContextKeyExpr.has('config.window.commandCenter'),
ContextKeyExpr.or(CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_INSTALL_ENTITLED)
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.installEntitled)
)
);
}
......@@ -606,7 +606,7 @@ class InstallChatWithoutPromptAction extends BaseInstallChatAction {
id: MenuId.ChatCommandCenter,
group: 'a_atfirst',
order: 1,
when: CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED.negate()
when: ChatContextKeys.panelParticipantRegistered.negate()
}
});
}
......@@ -630,12 +630,12 @@ class LearnMoreChatAction extends Action2 {
id: MenuId.ChatCommandCenter,
group: 'a_atfirst',
order: 2,
when: CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED.negate()
when: ChatContextKeys.panelParticipantRegistered.negate()
}, {
id: MenuId.ChatCommandCenter,
group: 'z_atlast',
order: 1,
when: CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED
when: ChatContextKeys.panelParticipantRegistered
}]
});
}
......
......@@ -16,7 +16,7 @@ import { ActiveEditorContext } from '../../../../common/contextkeys.js';
import { IViewsService } from '../../../../services/views/common/viewsService.js';
import { isChatViewTitleActionContext } from '../../common/chatActions.js';
import { ChatAgentLocation } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_EDITING_CAN_REDO, CONTEXT_CHAT_EDITING_CAN_UNDO, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_LOCATION, CONTEXT_IN_CHAT_SESSION } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, IChatEditingService, WorkingSetEntryState } from '../../common/chatEditingService.js';
import { CHAT_VIEW_ID, EDITS_VIEW_ID, IChatWidgetService } from '../chat.js';
import { ChatEditorInput } from '../chatEditorInput.js';
......@@ -36,7 +36,7 @@ export function registerNewChatActions() {
title: localize2('chat.newChat.label', "New Chat"),
icon: Codicon.plus,
f1: false,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
menu: [{
id: MenuId.EditorTitle,
group: 'navigation',
......@@ -58,7 +58,7 @@ export function registerNewChatActions() {
title: localize2('chat.newChat.label', "New Chat"),
category: CHAT_CATEGORY,
icon: Codicon.plus,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession)),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession)),
f1: true,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
......@@ -66,7 +66,7 @@ export function registerNewChatActions() {
mac: {
primary: KeyMod.WinCtrl | KeyCode.KeyL
},
when: CONTEXT_IN_CHAT_SESSION
when: ChatContextKeys.inChatSession
},
menu: [{
id: MenuId.ChatContext,
......@@ -108,7 +108,7 @@ export function registerNewChatActions() {
title: localize2('chat.newEdits.label', "New Edit Session"),
category: CHAT_CATEGORY,
icon: Codicon.plus,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered),
f1: true,
menu: [{
id: MenuId.ChatContext,
......@@ -206,11 +206,11 @@ export function registerNewChatActions() {
id: 'workbench.action.chat.done',
title: localize2('chat.done.label', "Done"),
category: CHAT_CATEGORY,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered),
f1: false,
menu: [{
id: MenuId.ChatEditingWidgetToolbar,
when: ContextKeyExpr.and(hasUndecidedChatEditingResourceContextKey.negate(), hasAppliedChatEditsContextKey, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)),
when: ContextKeyExpr.and(hasUndecidedChatEditingResourceContextKey.negate(), hasAppliedChatEditsContextKey, ChatContextKeys.editingParticipantRegistered, ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)),
group: 'navigation',
order: 0
}]
......@@ -252,7 +252,7 @@ export function registerNewChatActions() {
title: localize2('chat.undoEdit.label', "Undo Last Edit"),
category: CHAT_CATEGORY,
icon: Codicon.discard,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_EDITING_CAN_UNDO, CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
precondition: ContextKeyExpr.and(ChatContextKeys.chatEditingCanUndo, ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered),
f1: true,
menu: [{
id: MenuId.ViewTitle,
......@@ -284,7 +284,7 @@ export function registerNewChatActions() {
title: localize2('chat.redoEdit.label', "Redo Last Edit"),
category: CHAT_CATEGORY,
icon: Codicon.redo,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_EDITING_CAN_REDO, CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
precondition: ContextKeyExpr.and(ChatContextKeys.chatEditingCanRedo, ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered),
f1: true,
menu: [{
id: MenuId.ViewTitle,
......@@ -316,16 +316,16 @@ export function registerNewChatActions() {
title: localize2('chat.openEdits.label', "Open {0}", 'Copilot Edits'),
category: CHAT_CATEGORY,
icon: Codicon.goToEditingSession,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered),
f1: true,
menu: [{
id: MenuId.ViewTitle,
when: ContextKeyExpr.and(ContextKeyExpr.equals('view', CHAT_VIEW_ID), CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
when: ContextKeyExpr.and(ContextKeyExpr.equals('view', CHAT_VIEW_ID), ChatContextKeys.editingParticipantRegistered),
group: 'navigation',
order: 1
}, {
id: MenuId.ChatCommandCenter,
when: CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED,
when: ChatContextKeys.editingParticipantRegistered,
group: 'a_chatEdit',
order: 1
}],
......@@ -335,7 +335,7 @@ export function registerNewChatActions() {
linux: {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.KeyI
},
when: ContextKeyExpr.and(ContextKeyExpr.notEquals('view', EDITS_VIEW_ID), CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED)
when: ContextKeyExpr.and(ContextKeyExpr.notEquals('view', EDITS_VIEW_ID), ChatContextKeys.editingParticipantRegistered)
}
});
}
......
......@@ -21,7 +21,7 @@ import { IUntitledTextResourceEditorInput } from '../../../../common/editor.js';
import { IEditorService } from '../../../../services/editor/common/editorService.js';
import { accessibleViewInCodeBlock } from '../../../accessibility/browser/accessibilityConfiguration.js';
import { ITerminalEditorService, ITerminalGroupService, ITerminalService } from '../../../terminal/browser/terminal.js';
import { CONTEXT_CHAT_EDIT_APPLIED, CONTEXT_CHAT_ENABLED, CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IChatEditingService } from '../../common/chatEditingService.js';
import { ChatCopyKind, IChatService } from '../../common/chatService.js';
import { IChatResponseViewModel, isResponseVM } from '../../common/chatViewModel.js';
......@@ -186,7 +186,7 @@ export function registerChatCodeBlockActions() {
super({
id: 'workbench.action.chat.applyInEditor',
title: localize2('interactive.applyInEditor.label', "Apply in Editor"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
icon: Codicon.gitPullRequestGoToChanges,
......@@ -195,13 +195,13 @@ export function registerChatCodeBlockActions() {
id: MenuId.ChatCodeBlock,
group: 'navigation',
when: ContextKeyExpr.and(
CONTEXT_IN_CHAT_SESSION,
ChatContextKeys.inChatSession,
...shellLangIds.map(e => ContextKeyExpr.notEquals(EditorContextKeys.languageId.key, e))
),
order: 10
},
keybinding: {
when: ContextKeyExpr.or(ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate()), accessibleViewInCodeBlock),
when: ContextKeyExpr.or(ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate()), accessibleViewInCodeBlock),
primary: KeyMod.CtrlCmd | KeyCode.Enter,
mac: { primary: KeyMod.WinCtrl | KeyCode.Enter },
weight: KeybindingWeight.ExternalExtension + 1
......@@ -222,7 +222,7 @@ export function registerChatCodeBlockActions() {
super({
id: 'workbench.action.chat.applyAll',
title: localize2('chat.applyAll.label', "Apply All Edits"),
precondition: CONTEXT_CHAT_ENABLED, // improve this condition
precondition: ChatContextKeys.enabled, // improve this condition
f1: true,
category: CHAT_CATEGORY,
icon: Codicon.edit
......@@ -254,18 +254,18 @@ export function registerChatCodeBlockActions() {
super({
id: 'workbench.action.chat.insertCodeBlock',
title: localize2('interactive.insertCodeBlock.label', "Insert At Cursor"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
icon: Codicon.insert,
menu: {
id: MenuId.ChatCodeBlock,
group: 'navigation',
when: CONTEXT_IN_CHAT_SESSION,
when: ChatContextKeys.inChatSession,
order: 20
},
keybinding: {
when: ContextKeyExpr.or(ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate()), accessibleViewInCodeBlock),
when: ContextKeyExpr.or(ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate()), accessibleViewInCodeBlock),
primary: KeyMod.CtrlCmd | KeyCode.Enter,
mac: { primary: KeyMod.WinCtrl | KeyCode.Enter },
weight: KeybindingWeight.ExternalExtension + 1
......@@ -284,7 +284,7 @@ export function registerChatCodeBlockActions() {
super({
id: 'workbench.action.chat.insertIntoNewFile',
title: localize2('interactive.insertIntoNewFile.label', "Insert into New File"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
icon: Codicon.newFile,
......@@ -331,7 +331,7 @@ export function registerChatCodeBlockActions() {
super({
id: 'workbench.action.chat.runInTerminal',
title: localize2('interactive.runInTerminal.label', "Insert into Terminal"),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
icon: Codicon.terminal,
......@@ -339,7 +339,7 @@ export function registerChatCodeBlockActions() {
id: MenuId.ChatCodeBlock,
group: 'navigation',
when: ContextKeyExpr.and(
CONTEXT_IN_CHAT_SESSION,
ChatContextKeys.inChatSession,
ContextKeyExpr.or(...shellLangIds.map(e => ContextKeyExpr.equals(EditorContextKeys.languageId.key, e)))
),
},
......@@ -348,7 +348,7 @@ export function registerChatCodeBlockActions() {
group: 'navigation',
isHiddenByDefault: true,
when: ContextKeyExpr.and(
CONTEXT_IN_CHAT_SESSION,
ChatContextKeys.inChatSession,
...shellLangIds.map(e => ContextKeyExpr.notEquals(EditorContextKeys.languageId.key, e))
)
}],
......@@ -358,7 +358,7 @@ export function registerChatCodeBlockActions() {
primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Enter
},
weight: KeybindingWeight.EditorContrib,
when: ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, accessibleViewInCodeBlock),
when: ContextKeyExpr.or(ChatContextKeys.inChatSession, accessibleViewInCodeBlock),
}]
});
}
......@@ -448,9 +448,9 @@ export function registerChatCodeBlockActions() {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown, },
weight: KeybindingWeight.WorkbenchContrib,
when: CONTEXT_IN_CHAT_SESSION,
when: ChatContextKeys.inChatSession,
},
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
});
......@@ -470,9 +470,9 @@ export function registerChatCodeBlockActions() {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp, },
weight: KeybindingWeight.WorkbenchContrib,
when: CONTEXT_IN_CHAT_SESSION,
when: ChatContextKeys.inChatSession,
},
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
});
......@@ -537,7 +537,7 @@ export function registerChatCodeCompareBlockActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.check,
precondition: ContextKeyExpr.and(EditorContextKeys.hasChanges, CONTEXT_CHAT_EDIT_APPLIED.negate()),
precondition: ContextKeyExpr.and(EditorContextKeys.hasChanges, ChatContextKeys.editApplied.negate()),
menu: {
id: MenuId.ChatCompareBlock,
group: 'navigation',
......@@ -569,7 +569,7 @@ export function registerChatCodeCompareBlockActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.trash,
precondition: ContextKeyExpr.and(EditorContextKeys.hasChanges, CONTEXT_CHAT_EDIT_APPLIED.negate()),
precondition: ContextKeyExpr.and(EditorContextKeys.hasChanges, ChatContextKeys.editApplied.negate()),
menu: {
id: MenuId.ChatCompareBlock,
group: 'navigation',
......
......@@ -39,7 +39,7 @@ import { SearchView } from '../../../search/browser/searchView.js';
import { ISymbolQuickPickItem, SymbolsQuickAccessProvider } from '../../../search/browser/symbolsQuickAccess.js';
import { SearchContext } from '../../../search/common/constants.js';
import { ChatAgentLocation, IChatAgentService } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_LOCATION, CONTEXT_IN_CHAT_INPUT } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IChatEditingService } from '../../common/chatEditingService.js';
import { IChatRequestVariableEntry } from '../../common/chatModel.js';
import { ChatRequestAgentPart } from '../../common/chatParserTypes.js';
......@@ -169,7 +169,7 @@ class AttachFileAction extends Action2 {
title: localize2('workbench.action.chat.attachFile.label', "Add File to Chat"),
category: CHAT_CATEGORY,
f1: false,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor')),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor')),
menu: {
id: MenuId.ChatCommandCenter,
group: 'a_chat',
......@@ -200,7 +200,7 @@ class AttachSelectionAction extends Action2 {
title: localize2('workbench.action.chat.attachSelection.label', "Add Selection to Chat"),
category: CHAT_CATEGORY,
f1: false,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor')),
precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ActiveEditorContext.isEqualTo('workbench.editors.files.textFileEditor')),
menu: {
id: MenuId.ChatCommandCenter,
group: 'a_chat',
......@@ -231,10 +231,10 @@ export class AttachContextAction extends Action2 {
// used to enable/disable the keybinding and defined menu containment
protected static _cdt = ContextKeyExpr.or(
ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel)),
ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Editor)),
ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Notebook)),
ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Terminal)),
ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel)),
ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Editor)),
ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Notebook)),
ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Terminal)),
);
constructor(desc: Readonly<IAction2Options> = {
......@@ -242,21 +242,21 @@ export class AttachContextAction extends Action2 {
title: localize2('workbench.action.chat.attachContext.label', "Attach Context"),
icon: Codicon.attach,
category: CHAT_CATEGORY,
precondition: ContextKeyExpr.or(AttachContextAction._cdt, ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession))),
precondition: ContextKeyExpr.or(AttachContextAction._cdt, ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession))),
keybinding: {
when: CONTEXT_IN_CHAT_INPUT,
when: ChatContextKeys.inChatInput,
primary: KeyMod.CtrlCmd | KeyCode.Slash,
weight: KeybindingWeight.EditorContrib
},
menu: [
{
when: ContextKeyExpr.or(ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)), ContextKeyExpr.and(ContextKeyExpr.or(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel), CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)), AttachContextAction._cdt)),
when: ContextKeyExpr.or(ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)), ContextKeyExpr.and(ContextKeyExpr.or(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel), ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)), AttachContextAction._cdt)),
id: MenuId.ChatInput,
group: 'navigation',
order: 2
},
{
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel).negate(), AttachContextAction._cdt),
when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel).negate(), AttachContextAction._cdt),
id: MenuId.ChatExecute,
group: 'navigation',
order: 1
......@@ -660,7 +660,7 @@ registerAction2(class AttachFilesAction extends AttachContextAction {
title: localize2('workbench.action.chat.editing.attachFiles.label', "Add Files to Working Set"),
f1: false,
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)
precondition: ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)
});
}
......
......@@ -9,7 +9,7 @@ import { Action2, MenuId, registerAction2 } from '../../../../../platform/action
import { IClipboardService } from '../../../../../platform/clipboard/common/clipboardService.js';
import { CHAT_CATEGORY, stringifyItem } from './chatActions.js';
import { IChatWidgetService } from '../chat.js';
import { CONTEXT_RESPONSE_FILTERED } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IChatRequestViewModel, IChatResponseViewModel, isRequestVM, isResponseVM } from '../../common/chatViewModel.js';
export function registerChatCopyActions() {
......@@ -22,7 +22,7 @@ export function registerChatCopyActions() {
category: CHAT_CATEGORY,
menu: {
id: MenuId.ChatContext,
when: CONTEXT_RESPONSE_FILTERED.toNegated(),
when: ChatContextKeys.responseIsFiltered.toNegated(),
group: 'copy',
}
});
......@@ -54,7 +54,7 @@ export function registerChatCopyActions() {
category: CHAT_CATEGORY,
menu: {
id: MenuId.ChatContext,
when: CONTEXT_RESPONSE_FILTERED.toNegated(),
when: ChatContextKeys.responseIsFiltered.toNegated(),
group: 'copy',
}
});
......
......@@ -14,7 +14,7 @@ import { IDialogService } from '../../../../../platform/dialogs/common/dialogs.j
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
import { IViewsService } from '../../../../services/views/common/viewsService.js';
import { ChatAgentLocation, IChatAgentService } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_INPUT_HAS_AGENT, CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_LOCATION, CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_INPUT, CONTEXT_LANGUAGE_MODELS_ARE_USER_SELECTABLE } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { applyingChatEditsContextKey, IChatEditingService } from '../../common/chatEditingService.js';
import { chatAgentLeader, extractAgentAndCommand } from '../../common/chatParserTypes.js';
import { IChatService } from '../../common/chatService.js';
......@@ -42,9 +42,9 @@ export class SubmitAction extends Action2 {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.send,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), ContextKeyExpr.or(CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession), ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey.toNegated()))),
precondition: ContextKeyExpr.and(ChatContextKeys.inputHasText, ChatContextKeys.requestInProgress.negate(), ContextKeyExpr.or(ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession), ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey.toNegated()))),
keybinding: {
when: CONTEXT_IN_CHAT_INPUT,
when: ChatContextKeys.inChatInput,
primary: KeyCode.Enter,
weight: KeybindingWeight.EditorContrib
},
......@@ -57,7 +57,7 @@ export class SubmitAction extends Action2 {
{
id: MenuId.ChatExecute,
order: 4,
when: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), ContextKeyExpr.or(CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession), ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey.toNegated()))),
when: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), ContextKeyExpr.or(ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession), ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey.toNegated()))),
group: 'navigation',
},
]
......@@ -83,11 +83,11 @@ class SubmitWithoutDispatchingAction extends Action2 {
f1: false,
category: CHAT_CATEGORY,
precondition: ContextKeyExpr.and(
CONTEXT_CHAT_INPUT_HAS_TEXT,
CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(),
ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel))),
ChatContextKeys.inputHasText,
ChatContextKeys.requestInProgress.negate(),
ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel))),
keybinding: {
when: CONTEXT_IN_CHAT_INPUT,
when: ChatContextKeys.inChatInput,
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.Enter,
weight: KeybindingWeight.EditorContrib
},
......@@ -119,11 +119,11 @@ MenuRegistry.appendMenuItem(MenuId.ChatExecute, {
order: 3,
group: 'navigation',
when: ContextKeyExpr.and(
CONTEXT_LANGUAGE_MODELS_ARE_USER_SELECTABLE,
ChatContextKeys.languageModelsAreUserSelectable,
ContextKeyExpr.or(
ContextKeyExpr.equals(CONTEXT_CHAT_LOCATION.key, ChatAgentLocation.Panel),
ContextKeyExpr.equals(CONTEXT_CHAT_LOCATION.key, ChatAgentLocation.EditingSession),
ContextKeyExpr.equals(CONTEXT_CHAT_LOCATION.key, ChatAgentLocation.Editor)
ContextKeyExpr.equals(ChatContextKeys.location.key, ChatAgentLocation.Panel),
ContextKeyExpr.equals(ChatContextKeys.location.key, ChatAgentLocation.EditingSession),
ContextKeyExpr.equals(ChatContextKeys.location.key, ChatAgentLocation.Editor)
)
),
});
......@@ -135,14 +135,14 @@ export class ChatSubmitSecondaryAgentAction extends Action2 {
super({
id: ChatSubmitSecondaryAgentAction.ID,
title: localize2({ key: 'actions.chat.submitSecondaryAgent', comment: ['Send input from the chat input box to the secondary agent'] }, "Submit to Secondary Agent"),
precondition: ContextKeyExpr.and(CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_INPUT_HAS_AGENT.negate(), CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate()),
precondition: ContextKeyExpr.and(ChatContextKeys.inputHasText, ChatContextKeys.inputHasAgent.negate(), ChatContextKeys.requestInProgress.negate()),
menu: {
id: MenuId.ChatExecuteSecondary,
group: 'group_1',
order: 3
},
keybinding: {
when: CONTEXT_IN_CHAT_INPUT,
when: ChatContextKeys.inChatInput,
primary: KeyMod.CtrlCmd | KeyCode.Enter,
weight: KeybindingWeight.EditorContrib
},
......@@ -177,19 +177,19 @@ class SendToChatEditingAction extends Action2 {
super({
id: 'workbench.action.chat.sendToChatEditing',
title: localize2('chat.sendToChatEditing.label', "Send to Copilot Edits"),
precondition: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), CONTEXT_CHAT_INPUT_HAS_AGENT.negate(), CONTEXT_CHAT_INPUT_HAS_TEXT),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), ChatContextKeys.inputHasAgent.negate(), ChatContextKeys.inputHasText),
category: CHAT_CATEGORY,
f1: false,
menu: {
id: MenuId.ChatExecuteSecondary,
group: 'group_1',
order: 4,
when: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession))
when: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered, ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession))
},
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter,
when: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession))
when: ContextKeyExpr.and(ChatContextKeys.enabled, ChatContextKeys.editingParticipantRegistered, ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession))
}
});
}
......@@ -252,7 +252,7 @@ class SendToNewChatAction extends Action2 {
super({
id: 'workbench.action.chat.sendToNewChat',
title: localize2('chat.newChat.label', "Send to New Chat"),
precondition: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), CONTEXT_CHAT_INPUT_HAS_TEXT),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), ChatContextKeys.inputHasText),
category: CHAT_CATEGORY,
f1: false,
menu: {
......@@ -262,7 +262,7 @@ class SendToNewChatAction extends Action2 {
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter,
when: CONTEXT_IN_CHAT_INPUT,
when: ChatContextKeys.inChatInput,
}
});
}
......@@ -292,7 +292,7 @@ export class CancelAction extends Action2 {
icon: Codicon.stopCircle,
menu: {
id: MenuId.ChatExecute,
when: ContextKeyExpr.or(CONTEXT_CHAT_REQUEST_IN_PROGRESS, ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey)),
when: ContextKeyExpr.or(ChatContextKeys.requestInProgress, ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), applyingChatEditsContextKey)),
order: 4,
group: 'navigation',
},
......
......@@ -10,7 +10,7 @@ import { Action2, registerAction2 } from '../../../../../platform/actions/common
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
import { CHAT_CATEGORY } from './chatActions.js';
import { IChatWidgetService } from '../chat.js';
import { CONTEXT_IN_CHAT_SESSION, CONTEXT_CHAT_ENABLED } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IChatResponseViewModel, isResponseVM } from '../../common/chatViewModel.js';
export function registerChatFileTreeActions() {
......@@ -22,9 +22,9 @@ export function registerChatFileTreeActions() {
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.F9,
weight: KeybindingWeight.WorkbenchContrib,
when: CONTEXT_IN_CHAT_SESSION,
when: ChatContextKeys.inChatSession,
},
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
});
......@@ -43,9 +43,9 @@ export function registerChatFileTreeActions() {
keybinding: {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F9,
weight: KeybindingWeight.WorkbenchContrib,
when: CONTEXT_IN_CHAT_SESSION,
when: ChatContextKeys.inChatSession,
},
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
category: CHAT_CATEGORY,
});
......
......@@ -14,7 +14,7 @@ import { CHAT_CATEGORY } from './chatActions.js';
import { IChatWidgetService } from '../chat.js';
import { IChatEditorOptions } from '../chatEditor.js';
import { ChatEditorInput } from '../chatEditorInput.js';
import { CONTEXT_CHAT_ENABLED } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { isExportableSessionData } from '../../common/chatModel.js';
import { IChatService } from '../../common/chatService.js';
import { IEditorService } from '../../../../services/editor/common/editorService.js';
......@@ -29,7 +29,7 @@ export function registerChatExportActions() {
id: 'workbench.action.chat.export',
category: CHAT_CATEGORY,
title: localize2('chat.export.label', "Export Chat..."),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
});
}
......@@ -70,7 +70,7 @@ export function registerChatExportActions() {
id: 'workbench.action.chat.import',
title: localize2('chat.import.label', "Import Chat..."),
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
});
}
......
......@@ -13,7 +13,7 @@ import { CHAT_VIEW_ID, IChatWidgetService } from '../chat.js';
import { ChatEditor, IChatEditorOptions } from '../chatEditor.js';
import { ChatEditorInput } from '../chatEditorInput.js';
import { ChatViewPane } from '../chatViewPane.js';
import { CONTEXT_CHAT_ENABLED } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { IEditorGroupsService } from '../../../../services/editor/common/editorGroupsService.js';
import { ACTIVE_GROUP, AUX_WINDOW_GROUP, IEditorService } from '../../../../services/editor/common/editorService.js';
import { IViewsService } from '../../../../services/views/common/viewsService.js';
......@@ -31,7 +31,7 @@ export function registerMoveActions() {
id: `workbench.action.chat.openInEditor`,
title: localize2('chat.openInEditor.label', "Open Chat in Editor"),
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
menu: {
id: MenuId.ViewTitle,
......@@ -53,7 +53,7 @@ export function registerMoveActions() {
id: `workbench.action.chat.openInNewWindow`,
title: localize2('chat.openInNewWindow.label', "Open Chat in New Window"),
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
menu: {
id: MenuId.ViewTitle,
......@@ -75,7 +75,7 @@ export function registerMoveActions() {
id: `workbench.action.chat.openInSidebar`,
title: localize2('interactiveSession.openInSidebar.label', "Open Chat in Side Bar"),
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
f1: true,
menu: [{
id: MenuId.EditorTitle,
......
......@@ -13,7 +13,7 @@ import { ServicesAccessor } from '../../../../../platform/instantiation/common/i
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
import { CHAT_CATEGORY } from './chatActions.js';
import { IQuickChatOpenOptions, IQuickChatService } from '../chat.js';
import { CONTEXT_CHAT_ENABLED } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { InlineChatController } from '../../../inlineChat/browser/inlineChatController.js';
export const ASK_QUICK_QUESTION_ACTION_ID = 'workbench.action.quickchat.toggle';
......@@ -103,7 +103,7 @@ class QuickChatGlobalAction extends Action2 {
super({
id: ASK_QUICK_QUESTION_ACTION_ID,
title: localize2('quickChat', 'Quick Chat'),
precondition: CONTEXT_CHAT_ENABLED,
precondition: ChatContextKeys.enabled,
icon: Codicon.commentDiscussion,
f1: false,
category: CHAT_CATEGORY,
......
......@@ -27,7 +27,7 @@ import { INotebookEditor } from '../../../notebook/browser/notebookBrowser.js';
import { CellEditType, CellKind, NOTEBOOK_EDITOR_ID } from '../../../notebook/common/notebookCommon.js';
import { NOTEBOOK_IS_ACTIVE_EDITOR } from '../../../notebook/common/notebookContextKeys.js';
import { ChatAgentLocation, IChatAgentService } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_LOCATION, CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION, CONTEXT_ITEM_ID, CONTEXT_LAST_ITEM_ID, CONTEXT_REQUEST, CONTEXT_RESPONSE, CONTEXT_RESPONSE_ERROR, CONTEXT_RESPONSE_FILTERED, CONTEXT_RESPONSE_VOTE } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { applyingChatEditsFailedContextKey, IChatEditingService, WorkingSetEntryState } from '../../common/chatEditingService.js';
import { IParsedChatRequest } from '../../common/chatParserTypes.js';
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, IChatProgress, IChatService } from '../../common/chatService.js';
......@@ -47,17 +47,17 @@ export function registerChatTitleActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.thumbsup,
toggled: CONTEXT_RESPONSE_VOTE.isEqualTo('up'),
toggled: ChatContextKeys.responseVote.isEqualTo('up'),
menu: [{
id: MenuId.ChatMessageFooter,
group: 'navigation',
order: 1,
when: ContextKeyExpr.and(CONTEXT_RESPONSE, CONTEXT_RESPONSE_ERROR.negate())
when: ContextKeyExpr.and(ChatContextKeys.isResponse, ChatContextKeys.responseHasError.negate())
}, {
id: MENU_INLINE_CHAT_WIDGET_SECONDARY,
group: 'navigation',
order: 1,
when: ContextKeyExpr.and(CONTEXT_RESPONSE, CONTEXT_RESPONSE_ERROR.negate())
when: ContextKeyExpr.and(ChatContextKeys.isResponse, ChatContextKeys.responseHasError.negate())
}]
});
}
......@@ -94,17 +94,17 @@ export function registerChatTitleActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.thumbsdown,
toggled: CONTEXT_RESPONSE_VOTE.isEqualTo('down'),
toggled: ChatContextKeys.responseVote.isEqualTo('down'),
menu: [{
id: MenuId.ChatMessageFooter,
group: 'navigation',
order: 2,
when: ContextKeyExpr.and(CONTEXT_RESPONSE)
when: ContextKeyExpr.and(ChatContextKeys.isResponse)
}, {
id: MENU_INLINE_CHAT_WIDGET_SECONDARY,
group: 'navigation',
order: 2,
when: ContextKeyExpr.and(CONTEXT_RESPONSE, CONTEXT_RESPONSE_ERROR.negate())
when: ContextKeyExpr.and(ChatContextKeys.isResponse, ChatContextKeys.responseHasError.negate())
}]
});
}
......@@ -151,12 +151,12 @@ export function registerChatTitleActions() {
id: MenuId.ChatMessageFooter,
group: 'navigation',
order: 3,
when: ContextKeyExpr.and(CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE)
when: ContextKeyExpr.and(ChatContextKeys.responseSupportsIssueReporting, ChatContextKeys.isResponse)
}, {
id: MENU_INLINE_CHAT_WIDGET_SECONDARY,
group: 'navigation',
order: 3,
when: ContextKeyExpr.and(CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE)
when: ContextKeyExpr.and(ChatContextKeys.responseSupportsIssueReporting, ChatContextKeys.isResponse)
}]
});
}
......@@ -194,8 +194,8 @@ export function registerChatTitleActions() {
id: MenuId.ChatMessageFooter,
group: 'navigation',
when: ContextKeyExpr.and(
CONTEXT_RESPONSE,
ContextKeyExpr.in(CONTEXT_ITEM_ID.key, CONTEXT_LAST_ITEM_ID.key))
ChatContextKeys.isResponse,
ContextKeyExpr.in(ChatContextKeys.itemId.key, ChatContextKeys.lastItemId.key))
},
{
id: MenuId.ChatEditingWidgetToolbar,
......@@ -277,7 +277,7 @@ export function registerChatTitleActions() {
id: MenuId.ChatMessageFooter,
group: 'navigation',
isHiddenByDefault: true,
when: ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, CONTEXT_RESPONSE, CONTEXT_RESPONSE_FILTERED.negate())
when: ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, ChatContextKeys.isResponse, ChatContextKeys.responseIsFiltered.negate())
}
});
}
......@@ -346,20 +346,20 @@ export function registerChatTitleActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.x,
precondition: CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession),
precondition: ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession),
keybinding: {
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace,
},
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession), CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate()),
when: ContextKeyExpr.and(ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate()),
weight: KeybindingWeight.WorkbenchContrib,
},
menu: {
id: MenuId.ChatMessageTitle,
group: 'navigation',
order: 2,
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession), CONTEXT_REQUEST)
when: ContextKeyExpr.and(ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession), ChatContextKeys.isRequest)
}
});
}
......@@ -400,7 +400,7 @@ export function registerChatTitleActions() {
f1: false,
category: CHAT_CATEGORY,
icon: Codicon.goToEditingSession,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession)),
precondition: ContextKeyExpr.and(ChatContextKeys.editingParticipantRegistered, ChatContextKeys.location.notEqualsTo(ChatAgentLocation.EditingSession)),
menu: {
id: MenuId.ChatMessageFooter,
group: 'navigation',
......
......@@ -21,7 +21,7 @@ import { IListService } from '../../../../../platform/list/browser/listService.j
import { GroupsOrder, IEditorGroupsService } from '../../../../services/editor/common/editorGroupsService.js';
import { IEditorService } from '../../../../services/editor/common/editorService.js';
import { ChatAgentLocation } from '../../common/chatAgents.js';
import { CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_LOCATION, CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION, CONTEXT_ITEM_ID, CONTEXT_LAST_ITEM_ID, CONTEXT_REQUEST } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { applyingChatEditsFailedContextKey, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingResourceContextKey, chatEditingWidgetFileStateContextKey, decidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, IChatEditingService, IChatEditingSession, WorkingSetEntryState } from '../../common/chatEditingService.js';
import { IChatService } from '../../common/chatService.js';
import { isRequestVM, isResponseVM } from '../../common/chatViewModel.js';
......@@ -180,10 +180,10 @@ export class ChatEditingAcceptAllAction extends Action2 {
title: localize('accept', 'Accept'),
icon: Codicon.check,
tooltip: localize('acceptAllEdits', 'Accept All Edits'),
precondition: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey),
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.Enter,
when: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey, CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), CONTEXT_IN_CHAT_INPUT),
when: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey, ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatInput),
weight: KeybindingWeight.WorkbenchContrib,
},
menu: [
......@@ -197,7 +197,7 @@ export class ChatEditingAcceptAllAction extends Action2 {
id: MenuId.ChatEditingWidgetToolbar,
group: 'navigation',
order: 0,
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(hasUndecidedChatEditingResourceContextKey, ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)))))
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(hasUndecidedChatEditingResourceContextKey, ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)))))
}
]
});
......@@ -222,7 +222,7 @@ export class ChatEditingDiscardAllAction extends Action2 {
title: localize('discard', 'Discard'),
icon: Codicon.discard,
tooltip: localize('discardAllEdits', 'Discard All Edits'),
precondition: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey),
menu: [
{
when: ContextKeyExpr.equals('resourceScheme', CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME),
......@@ -234,11 +234,11 @@ export class ChatEditingDiscardAllAction extends Action2 {
id: MenuId.ChatEditingWidgetToolbar,
group: 'navigation',
order: 1,
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), hasUndecidedChatEditingResourceContextKey)))
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), hasUndecidedChatEditingResourceContextKey)))
}
],
keybinding: {
when: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey, CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), CONTEXT_IN_CHAT_INPUT, CONTEXT_CHAT_INPUT_HAS_TEXT.negate()),
when: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey, ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatInput, ChatContextKeys.inputHasText.negate()),
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyCode.Backspace,
},
......@@ -273,7 +273,7 @@ export class ChatEditingShowChangesAction extends Action2 {
id: MenuId.ChatEditingWidgetToolbar,
group: 'navigation',
order: 4,
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession))))
when: ContextKeyExpr.and(applyingChatEditsFailedContextKey.negate(), ContextKeyExpr.or(hasAppliedChatEditsContextKey.negate(), ContextKeyExpr.and(hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession))))
}
],
});
......@@ -297,7 +297,7 @@ registerAction2(class AddFilesToWorkingSetAction extends Action2 {
title: localize2('workbench.action.chat.addSelectedFilesToWorkingSet.label', "Add Selected Files to Working Set"),
icon: Codicon.attach,
category: CHAT_CATEGORY,
precondition: CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession),
precondition: ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession),
f1: true
});
}
......@@ -347,7 +347,7 @@ registerAction2(class RemoveAction extends Action2 {
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace,
},
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT.negate()),
when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatSession, ChatContextKeys.inChatInput.negate()),
weight: KeybindingWeight.WorkbenchContrib,
},
menu: [
......@@ -355,7 +355,7 @@ registerAction2(class RemoveAction extends Action2 {
id: MenuId.ChatMessageTitle,
group: 'navigation',
order: 2,
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), CONTEXT_REQUEST)
when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.isRequest)
}
]
});
......@@ -453,7 +453,7 @@ registerAction2(class OpenWorkingSetHistoryAction extends Action2 {
id: MenuId.ChatEditingCodeBlockContext,
group: 'navigation',
order: 0,
when: ContextKeyExpr.notIn(CONTEXT_ITEM_ID.key, CONTEXT_LAST_ITEM_ID.key),
when: ContextKeyExpr.notIn(ChatContextKeys.itemId.key, ChatContextKeys.lastItemId.key),
},]
});
}
......
......@@ -33,7 +33,7 @@ import { MultiDiffEditor } from '../../../multiDiffEditor/browser/multiDiffEdito
import { MultiDiffEditorInput } from '../../../multiDiffEditor/browser/multiDiffEditorInput.js';
import { IMultiDiffSourceResolver, IMultiDiffSourceResolverService, IResolvedMultiDiffSource, MultiDiffEditorItem } from '../../../multiDiffEditor/browser/multiDiffSourceResolverService.js';
import { ICodeMapperResponse, ICodeMapperService } from '../../common/chatCodeMapperService.js';
import { CONTEXT_CHAT_EDITING_CAN_REDO, CONTEXT_CHAT_EDITING_CAN_UNDO } from '../../common/chatContextKeys.js';
import { ChatContextKeys } from '../../common/chatContextKeys.js';
import { applyingChatEditsContextKey, applyingChatEditsFailedContextKey, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingMaxFileAssignmentName, chatEditingResourceContextKey, ChatEditingSessionState, decidedChatEditingResourceContextKey, defaultChatEditingMaxFileLimit, hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, IChatEditingService, IChatEditingSession, IChatEditingSessionStream, inChatEditingSessionContextKey, WorkingSetEntryState } from '../../common/chatEditingService.js';
import { IChatResponseModel, IChatTextEditGroup } from '../../common/chatModel.js';
import { IChatService } from '../../common/chatService.js';
......@@ -129,10 +129,10 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
this._register(bindContextKey(applyingChatEditsContextKey, contextKeyService, (reader) => {
return this._currentAutoApplyOperationObs.read(reader) !== null;
}));
this._register(bindContextKey(CONTEXT_CHAT_EDITING_CAN_UNDO, contextKeyService, (r) => {
this._register(bindContextKey(ChatContextKeys.chatEditingCanUndo, contextKeyService, (r) => {
return this._currentSessionObs.read(r)?.canUndo.read(r) || false;
}));
this._register(bindContextKey(CONTEXT_CHAT_EDITING_CAN_REDO, contextKeyService, (r) => {
this._register(bindContextKey(ChatContextKeys.chatEditingCanRedo, contextKeyService, (r) => {
return this._currentSessionObs.read(r)?.canRedo.read(r) || false;
}));
this._register(this._chatService.onDidDisposeSession((e) => {
......
......@@ -25,7 +25,7 @@ import { IEditorService } from '../../../services/editor/common/editorService.js
import { IFilesConfigurationService } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
import { ITextFileService } from '../../../services/textfile/common/textfiles.js';
import { ChatAgentLocation, IChatAgentService } from '../common/chatAgents.js';
import { CONTEXT_CHAT_LOCATION, CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_INPUT } from '../common/chatContextKeys.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { applyingChatEditsFailedContextKey, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, IChatEditingService, IChatEditingSession, WorkingSetEntryState } from '../common/chatEditingService.js';
export class ChatEditorSaving extends Disposable implements IWorkbenchContribution {
......@@ -199,7 +199,7 @@ export class ChatEditingSaveAllAction extends Action2 {
id: ChatEditingSaveAllAction.ID,
title: ChatEditingSaveAllAction.LABEL,
tooltip: ChatEditingSaveAllAction.LABEL,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey),
icon: Codicon.saveAll,
menu: [
{
......@@ -218,13 +218,13 @@ export class ChatEditingSaveAllAction extends Action2 {
applyingChatEditsFailedContextKey.negate(),
ContextKeyExpr.or(hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey.negate()),
ContextKeyExpr.notEquals('config.files.autoSave', 'off'), ContextKeyExpr.equals(`config.${ChatEditorSaving._config}`, false),
CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession)
ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)
)
}
],
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.KeyS,
when: ContextKeyExpr.and(CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(), hasUndecidedChatEditingResourceContextKey, CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession), CONTEXT_IN_CHAT_INPUT),
when: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey, ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatInput),
weight: KeybindingWeight.WorkbenchContrib,
},
});
......
......@@ -69,7 +69,7 @@ import { AccessibilityVerbositySettingId } from '../../accessibility/browser/acc
import { AccessibilityCommandId } from '../../accessibility/common/accessibilityCommands.js';
import { getSimpleCodeEditorWidgetOptions, getSimpleEditorOptions, setupSimpleEditorSelectionStyling } from '../../codeEditor/browser/simpleEditorOptions.js';
import { ChatAgentLocation, IChatAgentService } from '../common/chatAgents.js';
import { CONTEXT_CHAT_HAS_FILE_ATTACHMENTS, CONTEXT_CHAT_INPUT_CURSOR_AT_TOP, CONTEXT_CHAT_INPUT_HAS_FOCUS, CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_IN_CHAT_INPUT } from '../common/chatContextKeys.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { ChatEditingSessionState, IChatEditingService, IChatEditingSession, WorkingSetEntryState } from '../common/chatEditingService.js';
import { IChatRequestVariableEntry } from '../common/chatModel.js';
import { ChatRequestDynamicVariablePart } from '../common/chatParserTypes.js';
......@@ -272,9 +272,9 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
};
this.inputEditorMaxHeight = this.options.renderStyle === 'compact' ? INPUT_EDITOR_MAX_HEIGHT / 3 : INPUT_EDITOR_MAX_HEIGHT;
this.inputEditorHasText = CONTEXT_CHAT_INPUT_HAS_TEXT.bindTo(contextKeyService);
this.chatCursorAtTop = CONTEXT_CHAT_INPUT_CURSOR_AT_TOP.bindTo(contextKeyService);
this.inputEditorHasFocus = CONTEXT_CHAT_INPUT_HAS_FOCUS.bindTo(contextKeyService);
this.inputEditorHasText = ChatContextKeys.inputHasText.bindTo(contextKeyService);
this.chatCursorAtTop = ChatContextKeys.inputCursorAtTop.bindTo(contextKeyService);
this.inputEditorHasFocus = ChatContextKeys.inputHasFocus.bindTo(contextKeyService);
this.history = this.loadHistory();
this._register(this.historyService.onDidClearHistory(() => this.history = new HistoryNavigator2([{ text: '' }], 50, historyKeyFn)));
......@@ -287,7 +287,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
this._chatEditsListPool = this._register(this.instantiationService.createInstance(CollapsibleListPool, this._onDidChangeVisibility.event, MenuId.ChatEditingWidgetModifiedFilesToolbar));
this._hasFileAttachmentContextKey = CONTEXT_CHAT_HAS_FILE_ATTACHMENTS.bindTo(contextKeyService);
this._hasFileAttachmentContextKey = ChatContextKeys.hasFileAttachments.bindTo(contextKeyService);
}
private setCurrentLanguageModelToDefault() {
......@@ -548,7 +548,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
this.renderChatEditingSessionState(null, widget);
const inputScopedContextKeyService = this._register(this.contextKeyService.createScoped(inputContainer));
CONTEXT_IN_CHAT_INPUT.bindTo(inputScopedContextKeyService).set(true);
ChatContextKeys.inChatInput.bindTo(inputScopedContextKeyService).set(true);
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, inputScopedContextKeyService])));
const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(inputScopedContextKeyService, this));
......
......@@ -43,7 +43,7 @@ import { IThemeService } from '../../../../platform/theme/common/themeService.js
import { IWorkbenchIssueService } from '../../issue/common/issue.js';
import { annotateSpecialMarkdownContent } from '../common/annotations.js';
import { ChatAgentLocation, IChatAgentMetadata } from '../common/chatAgents.js';
import { CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_ITEM_ID, CONTEXT_REQUEST, CONTEXT_RESPONSE, CONTEXT_RESPONSE_DETECTED_AGENT_COMMAND, CONTEXT_RESPONSE_ERROR, CONTEXT_RESPONSE_FILTERED, CONTEXT_RESPONSE_VOTE } from '../common/chatContextKeys.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { IChatRequestVariableEntry, IChatTextEditGroup } from '../common/chatModel.js';
import { chatSubcommandLeader } from '../common/chatParserTypes.js';
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, IChatConfirmation, IChatContentReference, IChatFollowup, IChatMarkdownContent, IChatTask, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData } from '../common/chatService.js';
......@@ -361,15 +361,15 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
'welcome';
this.traceLayout('renderElement', `${kind}, index=${index}`);
CONTEXT_RESPONSE.bindTo(templateData.contextKeyService).set(isResponseVM(element));
CONTEXT_ITEM_ID.bindTo(templateData.contextKeyService).set(element.id);
CONTEXT_REQUEST.bindTo(templateData.contextKeyService).set(isRequestVM(element));
CONTEXT_RESPONSE_DETECTED_AGENT_COMMAND.bindTo(templateData.contextKeyService).set(isResponseVM(element) && element.agentOrSlashCommandDetected);
ChatContextKeys.isResponse.bindTo(templateData.contextKeyService).set(isResponseVM(element));
ChatContextKeys.itemId.bindTo(templateData.contextKeyService).set(element.id);
ChatContextKeys.isRequest.bindTo(templateData.contextKeyService).set(isRequestVM(element));
ChatContextKeys.responseDetectedAgentCommand.bindTo(templateData.contextKeyService).set(isResponseVM(element) && element.agentOrSlashCommandDetected);
if (isResponseVM(element)) {
CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING.bindTo(templateData.contextKeyService).set(!!element.agent?.metadata.supportIssueReporting);
CONTEXT_RESPONSE_VOTE.bindTo(templateData.contextKeyService).set(element.vote === ChatAgentVoteDirection.Up ? 'up' : element.vote === ChatAgentVoteDirection.Down ? 'down' : '');
ChatContextKeys.responseSupportsIssueReporting.bindTo(templateData.contextKeyService).set(!!element.agent?.metadata.supportIssueReporting);
ChatContextKeys.responseVote.bindTo(templateData.contextKeyService).set(element.vote === ChatAgentVoteDirection.Up ? 'up' : element.vote === ChatAgentVoteDirection.Down ? 'down' : '');
} else {
CONTEXT_RESPONSE_VOTE.bindTo(templateData.contextKeyService).set('');
ChatContextKeys.responseVote.bindTo(templateData.contextKeyService).set('');
}
if (templateData.titleToolbar) {
......@@ -377,9 +377,9 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
}
templateData.footerToolbar.context = element;
CONTEXT_RESPONSE_ERROR.bindTo(templateData.contextKeyService).set(isResponseVM(element) && !!element.errorDetails);
ChatContextKeys.responseHasError.bindTo(templateData.contextKeyService).set(isResponseVM(element) && !!element.errorDetails);
const isFiltered = !!(isResponseVM(element) && element.errorDetails?.responseIsFiltered);
CONTEXT_RESPONSE_FILTERED.bindTo(templateData.contextKeyService).set(isFiltered);
ChatContextKeys.responseIsFiltered.bindTo(templateData.contextKeyService).set(isFiltered);
templateData.rowContainer.classList.toggle('editing-session', this.chatWidgetService.getWidgetBySessionId(element.sessionId)?.location === ChatAgentLocation.EditingSession);
templateData.rowContainer.classList.toggle('interactive-request', isRequestVM(element));
......
......@@ -26,7 +26,7 @@ import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase
import { IViewContainersRegistry, IViewDescriptor, IViewDescriptorService, IViewsRegistry, ViewContainer, ViewContainerLocation, Extensions as ViewExtensions } from '../../../common/views.js';
import { IPaneCompositePartService } from '../../../services/panecomposite/browser/panecomposite.js';
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { CONTEXT_CHAT_EXTENSION_INVALID, CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_SHOULD_SHOW_MOVED_VIEW_WELCOME } from '../common/chatContextKeys.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { CHAT_VIEW_ID, showChatView } from './chat.js';
import { CHAT_SIDEBAR_OLD_VIEW_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
......@@ -44,7 +44,7 @@ export class MoveChatViewContribution extends Disposable implements IWorkbenchCo
private static readonly hideMovedChatWelcomeViewStorageKey = 'workbench.chat.hideMovedChatWelcomeView';
private readonly showWelcomeViewCtx = CONTEXT_CHAT_SHOULD_SHOW_MOVED_VIEW_WELCOME.bindTo(this.contextKeyService);
private readonly showWelcomeViewCtx = ChatContextKeys.shouldShowMovedViewWelcome.bindTo(this.contextKeyService);
constructor(
@IContextKeyService private readonly contextKeyService: IContextKeyService,
......@@ -131,7 +131,7 @@ export class MoveChatViewContribution extends Disposable implements IWorkbenchCo
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: CHAT_SIDEBAR_OLD_VIEW_PANEL_ID,
weight: KeybindingWeight.WorkbenchContrib,
when: CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED,
when: ChatContextKeys.panelParticipantRegistered,
primary: 0,
handler: accessor => showChatView(accessor.get(IViewsService))
});
......@@ -206,7 +206,7 @@ export class MoveChatViewContribution extends Disposable implements IWorkbenchCo
order: 1,
canToggleVisibility: false,
canMoveView: false,
when: ContextKeyExpr.and(CONTEXT_CHAT_SHOULD_SHOW_MOVED_VIEW_WELCOME, ContextKeyExpr.or(CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_EXTENSION_INVALID)),
when: ContextKeyExpr.and(ChatContextKeys.shouldShowMovedViewWelcome, ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.extensionInvalid)),
ctorDescriptor: new SyncDescriptor(MovedChatViewPane, [{ id: viewId }]),
};
......@@ -244,7 +244,7 @@ export class MoveChatViewContribution extends Disposable implements IWorkbenchCo
return viewsRegistry.registerViewWelcomeContent(viewId, {
content: [welcomeViewMainMessage, okButton, restoreButton, welcomeViewFooterMessage].join('\n\n'),
renderSecondaryButtons: true,
when: ContextKeyExpr.and(CONTEXT_CHAT_SHOULD_SHOW_MOVED_VIEW_WELCOME, ContextKeyExpr.or(CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_EXTENSION_INVALID))
when: ContextKeyExpr.and(ChatContextKeys.shouldShowMovedViewWelcome, ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.extensionInvalid))
});
}
......
......@@ -25,7 +25,7 @@ import * as extensionsRegistry from '../../../services/extensions/common/extensi
import { showExtensionsWithIdsCommandId } from '../../extensions/browser/extensionsActions.js';
import { IExtension, IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
import { ChatAgentLocation, IChatAgentData, IChatAgentService } from '../common/chatAgents.js';
import { CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_EXTENSION_INVALID, CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED } from '../common/chatContextKeys.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { IRawChatParticipantContribution } from '../common/chatParticipantContribTypes.js';
import { CHAT_VIEW_ID } from './chat.js';
import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID, ChatViewPane } from './chatViewPane.js';
......@@ -317,7 +317,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
order: 100
},
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.Panel }]),
when: ContextKeyExpr.or(CONTEXT_CHAT_PANEL_PARTICIPANT_REGISTERED, CONTEXT_CHAT_EXTENSION_INVALID)
when: ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.extensionInvalid)
}];
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, this._viewContainer);
......@@ -350,7 +350,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
canToggleVisibility: false,
canMoveView: true,
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.EditingSession }]),
when: CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED
when: ChatContextKeys.editingParticipantRegistered
}];
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, viewContainer);
......@@ -379,7 +379,7 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC
// It may be better to have some generic UI for this, for any extension that is incompatible,
// but this is only enabled for Copilot Chat now and it needs to be obvious.
const isInvalid = CONTEXT_CHAT_EXTENSION_INVALID.bindTo(contextKeyService);
const isInvalid = ChatContextKeys.extensionInvalid.bindTo(contextKeyService);
this._register(Event.runAndSubscribe(
extensionsWorkbenchService.onDidChangeExtensionsNotification,
() => {
......@@ -408,7 +408,7 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC
const viewsRegistry = Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry);
this._register(viewsRegistry.registerViewWelcomeContent(CHAT_VIEW_ID, {
content: [mainMessage, commandButton, versionMessage].join('\n\n'),
when: CONTEXT_CHAT_EXTENSION_INVALID,
when: ChatContextKeys.extensionInvalid,
}));
}
}
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать