diff --git a/extensions/ipynb/package.json b/extensions/ipynb/package.json index f7ee3c344e7..f43a494f66b 100644 --- a/extensions/ipynb/package.json +++ b/extensions/ipynb/package.json @@ -74,7 +74,8 @@ { "command": "notebook.cellOutput.addToChat", "title": "%addCellOutputToChat.title%", - "category": "Notebook" + "category": "Notebook", + "enablement": "chatIsEnabled" }, { "command": "notebook.cellOutput.openInTextEditor", diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts index 9ea0054f433..8821860a8f3 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts @@ -116,6 +116,7 @@ export function registerChatActions() { icon: Codicon.copilot, f1: true, category: CHAT_CATEGORY, + precondition: ChatContextKeys.Setup.hidden.toNegated(), keybinding: { weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyI, @@ -546,6 +547,7 @@ export function registerChatActions() { title: localize2('showCopilotUsageExtensions', "Show Extensions using Copilot"), f1: true, category: EXTENSIONS_CATEGORY, + precondition: ChatContextKeys.enabled }); } diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.ts b/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.ts index 985dc1b9aa9..a5c08661755 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.ts @@ -13,6 +13,7 @@ import { IViewsService } from '../../../../../services/views/common/viewsService import { ServicesAccessor } from '../../../../../../editor/browser/editorExtensions.js'; import { ISelectPromptOptions, askToSelectPrompt } from './dialogs/askToSelectPrompt.js'; import { IQuickInputService } from '../../../../../../platform/quickinput/common/quickInput.js'; +import { ChatContextKeys } from '../../../common/chatContextKeys.js'; /** * Action ID for the `Attach Prompt` action. @@ -35,6 +36,7 @@ export class AttachPromptAction extends Action2 { id: ATTACH_PROMPT_ACTION_ID, title: localize2('workbench.action.chat.attach.prompt.label', "Use Prompt"), f1: false, + precondition: ChatContextKeys.enabled, category: CHAT_CATEGORY, }); } diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts index 7390f91b882..0ea53e725db 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts @@ -345,6 +345,7 @@ export function registerNewChatActions() { category: CHAT_CATEGORY, icon: Codicon.goToEditingSession, f1: true, + precondition: ChatContextKeys.Setup.hidden.toNegated(), menu: [{ id: MenuId.ViewTitle, when: ContextKeyExpr.and(ContextKeyExpr.equals('view', ChatViewId), ChatContextKeys.editingParticipantRegistered, diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.ts index 4d9afa63ee4..aa3b3db690b 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.ts @@ -8,6 +8,7 @@ import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions import { localize2 } from '../../../../../nls.js'; import { Categories } from '../../../../../platform/action/common/actionCommonCategories.js'; import { Action2, registerAction2 } from '../../../../../platform/actions/common/actions.js'; +import { ChatContextKeys } from '../../common/chatContextKeys.js'; import { IChatWidgetService } from '../chat.js'; export function registerChatDeveloperActions() { @@ -24,7 +25,8 @@ class LogChatInputHistoryAction extends Action2 { title: localize2('workbench.action.chat.logInputHistory.label', "Log Chat Input History"), icon: Codicon.attach, category: Categories.Developer, - f1: true + f1: true, + precondition: ChatContextKeys.enabled }); } diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts index cacf54dcc9f..b5074baf299 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts @@ -107,6 +107,7 @@ export class ToggleAgentModeAction extends EditingSessionAction { f1: true, category: CHAT_CATEGORY, precondition: ContextKeyExpr.and( + ChatContextKeys.enabled, ChatContextKeys.Editing.hasToolsAgent, ChatContextKeys.requestInProgress.negate()), toggled: { diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts index 7d59054a9d1..f5f9343bed8 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.ts @@ -134,6 +134,7 @@ class AskQuickChatAction extends Action2 { id: `workbench.action.openQuickChat`, category: CHAT_CATEGORY, title: localize2('interactiveSession.open', "Open Quick Chat"), + precondition: ChatContextKeys.enabled, f1: true }); } diff --git a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.ts b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.ts index bd4d875cfd8..29299765e87 100644 --- a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.ts +++ b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.ts @@ -21,6 +21,7 @@ import { MultiDiffEditorInput } from '../../../multiDiffEditor/browser/multiDiff import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; import { ActiveEditorContext } from '../../../../common/contextkeys.js'; import { EditorResourceAccessor, SideBySideEditor, TEXT_DIFF_EDITOR_ID } from '../../../../common/editor.js'; +import { ChatContextKeys } from '../../common/chatContextKeys.js'; abstract class ChatEditingEditorAction extends Action2 { @@ -71,7 +72,7 @@ abstract class NavigateAction extends ChatEditingEditorAction { ? localize2('next', 'Go to Next Chat Edit') : localize2('prev', 'Go to Previous Chat Edit'), icon: next ? Codicon.arrowDown : Codicon.arrowUp, - precondition: ctxHasRequestInProgress.negate(), + precondition: ContextKeyExpr.and(ChatContextKeys.enabled, ctxHasRequestInProgress.negate()), keybinding: { primary: next ? KeyMod.Alt | KeyCode.F5 diff --git a/src/vs/workbench/contrib/chat/browser/chatSetup.ts b/src/vs/workbench/contrib/chat/browser/chatSetup.ts index 67221131bb5..9e8aac0a218 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts @@ -168,7 +168,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr title: ChatSetupHideAction.TITLE, f1: true, category: CHAT_CATEGORY, - precondition: ChatContextKeys.Setup.installed.negate(), + precondition: ContextKeyExpr.and(ChatContextKeys.Setup.installed.negate(), ChatContextKeys.Setup.hidden.negate()), menu: { id: MenuId.ChatTitleBarMenu, group: 'z_hide', diff --git a/src/vs/workbench/contrib/chat/browser/chatStatus.ts b/src/vs/workbench/contrib/chat/browser/chatStatus.ts index 23655a2a115..48b31011420 100644 --- a/src/vs/workbench/contrib/chat/browser/chatStatus.ts +++ b/src/vs/workbench/contrib/chat/browser/chatStatus.ts @@ -122,7 +122,10 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu } private async create(): Promise { - if (this.configurationService.getValue(ChatStatusBarEntry.SETTING) === true) { + const hidden = this.contextKeyService.getContextKeyValue(ChatContextKeys.Setup.hidden.key) === true; + const disabled = this.configurationService.getValue(ChatStatusBarEntry.SETTING) === false; + + if (!hidden && !disabled) { this.entry ||= this.statusbarService.addEntry(this.getEntryProps(), ChatStatusBarEntry.ID, StatusbarAlignment.RIGHT, { location: { id: 'status.editor.mode', priority: 100.1 }, alignment: StatusbarAlignment.RIGHT }); this.statusbarService.updateEntryVisibility(`${this.productService.defaultChatAgent?.extensionId}.status`, false); // TODO@bpasero: remove this eventually } else { @@ -219,7 +222,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu function isNewUser(contextKeyService: IContextKeyService, chatEntitlementService: IChatEntitlementService): boolean { return contextKeyService.getContextKeyValue(ChatContextKeys.Setup.installed.key) === false || // copilot not installed - chatEntitlementService.entitlement === ChatEntitlement.Available; // not yet signed up to copilot + chatEntitlementService.entitlement === ChatEntitlement.Available; // not yet signed up to copilot } class ChatStatusDashboard extends Disposable { diff --git a/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.ts b/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.ts index e3f61c986d4..6f73d7ee036 100644 --- a/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.ts +++ b/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.ts @@ -14,11 +14,13 @@ import { IOpenerService } from '../../../../../../../platform/opener/common/open import { PromptsConfig } from '../../../../../../../platform/prompts/common/config.js'; import { ICommandService } from '../../../../../../../platform/commands/common/commands.js'; import { IPromptPath, IPromptsService } from '../../../../common/promptSyntax/service/types.js'; -import { appendToCommandPalette } from '../../../../../files/browser/fileActions.contribution.js'; import { IQuickInputService } from '../../../../../../../platform/quickinput/common/quickInput.js'; import { ServicesAccessor } from '../../../../../../../platform/instantiation/common/instantiation.js'; import { IWorkspaceContextService } from '../../../../../../../platform/workspace/common/workspace.js'; import { KeybindingsRegistry, KeybindingWeight } from '../../../../../../../platform/keybinding/common/keybindingsRegistry.js'; +import { MenuId, MenuRegistry } from '../../../../../../../platform/actions/common/actions.js'; +import { ContextKeyExpr } from '../../../../../../../platform/contextkey/common/contextkey.js'; +import { ChatContextKeys } from '../../../../common/chatContextKeys.js'; /** * Base command ID prefix. @@ -109,7 +111,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: LOCAL_COMMAND_ID, weight: KeybindingWeight.WorkbenchContrib, handler: commandFactory('local'), - when: PromptsConfig.enabledCtx, + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled), }); /** @@ -119,29 +121,29 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: USER_COMMAND_ID, weight: KeybindingWeight.WorkbenchContrib, handler: commandFactory('user'), - when: PromptsConfig.enabledCtx, + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled), }); /** * Register the "Create Prompt" command in the command palette. */ -appendToCommandPalette( - { +MenuRegistry.appendMenuItem(MenuId.CommandPalette, { + command: { id: LOCAL_COMMAND_ID, title: LOCAL_COMMAND_TITLE, - category: CHAT_CATEGORY, + category: CHAT_CATEGORY }, - PromptsConfig.enabledCtx, -); + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled) +}); /** * Register the "Create User Prompt" command in the command palette. */ -appendToCommandPalette( - { +MenuRegistry.appendMenuItem(MenuId.CommandPalette, { + command: { id: USER_COMMAND_ID, title: USER_COMMAND_TITLE, category: CHAT_CATEGORY, }, - PromptsConfig.enabledCtx, -); + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled) +}); diff --git a/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.ts b/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.ts index efad5945824..87aa3636fe4 100644 --- a/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.ts +++ b/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.ts @@ -13,11 +13,13 @@ import { IViewsService } from '../../../../../services/views/common/viewsService import { isPromptFile } from '../../../../../../platform/prompts/common/constants.js'; import { IEditorService } from '../../../../../services/editor/common/editorService.js'; import { ICommandService } from '../../../../../../platform/commands/common/commands.js'; -import { appendToCommandPalette } from '../../../../files/browser/fileActions.contribution.js'; import { ServicesAccessor } from '../../../../../../platform/instantiation/common/instantiation.js'; import { IActiveCodeEditor, isCodeEditor, isDiffEditor } from '../../../../../../editor/browser/editorBrowser.js'; import { KeybindingsRegistry, KeybindingWeight } from '../../../../../../platform/keybinding/common/keybindingsRegistry.js'; import { IChatAttachPromptActionOptions, ATTACH_PROMPT_ACTION_ID } from '../../actions/chatAttachPromptAction/chatAttachPromptAction.js'; +import { MenuId, MenuRegistry } from '../../../../../../platform/actions/common/actions.js'; +import { ContextKeyExpr } from '../../../../../../platform/contextkey/common/contextkey.js'; +import { ChatContextKeys } from '../../../common/chatContextKeys.js'; /** * Command ID of the "Use Prompt" command. @@ -133,17 +135,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: KeybindingWeight.WorkbenchContrib, primary: COMMAND_KEY_BINDING, handler: command, - when: PromptsConfig.enabledCtx, + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled), }); /** * Register the "Use Prompt" command in the `command palette`. */ -appendToCommandPalette( - { +MenuRegistry.appendMenuItem(MenuId.CommandPalette, { + command: { id: COMMAND_ID, title: localize('commands.prompts.use.title', "Use Prompt"), - category: CHAT_CATEGORY, + category: CHAT_CATEGORY }, - PromptsConfig.enabledCtx, -); + when: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled) +}); diff --git a/src/vs/workbench/contrib/chat/common/chatEntitlementService.ts b/src/vs/workbench/contrib/chat/common/chatEntitlementService.ts index cdfdedd1065..a462cafcd5b 100644 --- a/src/vs/workbench/contrib/chat/common/chatEntitlementService.ts +++ b/src/vs/workbench/contrib/chat/common/chatEntitlementService.ts @@ -115,6 +115,7 @@ export class ChatEntitlementService extends Disposable implements IChatEntitleme !productService.defaultChatAgent || // needs product config (isWeb && !environmentService.remoteAuthority) // only enabled locally or a remote backend ) { + ChatContextKeys.Setup.hidden.bindTo(this.contextKeyService).set(true); // hide copilot UI return; } diff --git a/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.ts b/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.ts index fd5ac883a4c..91607d1621d 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.ts @@ -24,6 +24,7 @@ import { ChatInputPart } from '../../../../chat/browser/chatInputPart.js'; import { ChatDynamicVariableModel } from '../../../../chat/browser/contrib/chatDynamicVariables.js'; import { computeCompletionRanges } from '../../../../chat/browser/contrib/chatInputCompletions.js'; import { ChatAgentLocation, IChatAgentService } from '../../../../chat/common/chatAgents.js'; +import { ChatContextKeys } from '../../../../chat/common/chatContextKeys.js'; import { IChatRequestPasteVariableEntry } from '../../../../chat/common/chatModel.js'; import { chatVariableLeader } from '../../../../chat/common/chatParserTypes.js'; import { NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT, NOTEBOOK_CELL_OUTPUT_MIMETYPE } from '../../../common/notebookContextKeys.js'; @@ -249,6 +250,7 @@ registerAction2(class CopyCellOutputAction extends Action2 { }, category: NOTEBOOK_ACTIONS_CATEGORY, icon: icons.copyIcon, + precondition: ChatContextKeys.enabled }); }