mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 15:35:20 +01:00
* Chat-related commands should not be available on web (without backend) (fix #241873) * Remove notebook.cellOutput.addToChat from command palette * Only show "Toggle agent mode" when chat enabled * Show notebook.cellOutput.addToChat only when chat enabled --------- Co-authored-by: Rob Lourens <roblourens@gmail.com>
This commit is contained in:
@@ -74,7 +74,8 @@
|
||||
{
|
||||
"command": "notebook.cellOutput.addToChat",
|
||||
"title": "%addCellOutputToChat.title%",
|
||||
"category": "Notebook"
|
||||
"category": "Notebook",
|
||||
"enablement": "chatIsEnabled"
|
||||
},
|
||||
{
|
||||
"command": "notebook.cellOutput.openInTextEditor",
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -122,7 +122,10 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
|
||||
}
|
||||
|
||||
private async create(): Promise<void> {
|
||||
if (this.configurationService.getValue<boolean>(ChatStatusBarEntry.SETTING) === true) {
|
||||
const hidden = this.contextKeyService.getContextKeyValue<boolean>(ChatContextKeys.Setup.hidden.key) === true;
|
||||
const disabled = this.configurationService.getValue<boolean>(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<boolean>(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 {
|
||||
|
||||
+14
-12
@@ -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)
|
||||
});
|
||||
|
||||
+9
-7
@@ -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)
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user