From 30e42bce8692028a02b04ecce28845cecc6d8f74 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 8 Jan 2025 12:26:11 -0600 Subject: [PATCH 1/2] fix #10338 --- .../contrib/chat/browser/chatEditing/chatEditingActions.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts index 8a2ac519e78dd..3780470477490 100644 --- a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts +++ b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts @@ -98,6 +98,11 @@ registerAction2(class RemoveFileFromWorkingSet extends WorkingSetAction { order: 5, group: 'navigation' }], + keybinding: { + primary: KeyCode.Delete, + when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatInput.negate()), + weight: KeybindingWeight.WorkbenchContrib, + } }); } From 8114df05cacac2ce32e224b4ae259625a790ba97 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Thu, 9 Jan 2025 15:25:58 -0600 Subject: [PATCH 2/2] add ctx key for working set, use it for the when clause --- .../contrib/chat/browser/chatEditing/chatEditingActions.ts | 2 +- src/vs/workbench/contrib/chat/browser/chatInputPart.ts | 6 ++++++ src/vs/workbench/contrib/chat/common/chatContextKeys.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts index 3780470477490..9e4102b583845 100644 --- a/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts +++ b/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts @@ -100,7 +100,7 @@ registerAction2(class RemoveFileFromWorkingSet extends WorkingSetAction { }], keybinding: { primary: KeyCode.Delete, - when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatInput.negate()), + when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatEditWorkingSet), weight: KeybindingWeight.WorkbenchContrib, } }); diff --git a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts index cc9ebf1b7baff..3dad10ec25c74 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts @@ -149,6 +149,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge readonly onDidAcceptFollowup = this._onDidAcceptFollowup.event; private readonly _attachmentModel: ChatAttachmentModel; + private _inChatEditWorkingSetCtx: IContextKey | undefined; + public get attachmentModel(): ChatAttachmentModel { return this._attachmentModel; } @@ -643,6 +645,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge ChatContextKeys.inChatInput.bindTo(inputScopedContextKeyService).set(true); const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, inputScopedContextKeyService]))); + this._inChatEditWorkingSetCtx = ChatContextKeys.inChatEditWorkingSet.bindTo(this.contextKeyService); + const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(inputScopedContextKeyService, this)); this.historyNavigationBackwardsEnablement = historyNavigationBackwardsEnablement; this.historyNavigationForewardsEnablement = historyNavigationForwardsEnablement; @@ -1268,6 +1272,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge // Working set const workingSetContainer = innerContainer.querySelector('.chat-editing-session-list') as HTMLElement ?? dom.append(innerContainer, $('.chat-editing-session-list')); + this._register(addDisposableListener(workingSetContainer, 'focusin', () => this._inChatEditWorkingSetCtx?.set(true))); + this._register(addDisposableListener(workingSetContainer, 'focusout', () => this._inChatEditWorkingSetCtx?.set(false))); if (!this._chatEditList) { this._chatEditList = this._chatEditsListPool.get(); const list = this._chatEditList.object; diff --git a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts index 68c50c90600a0..e9fa7f0ac91af 100644 --- a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts +++ b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts @@ -28,6 +28,7 @@ export namespace ChatContextKeys { export const inputHasFocus = new RawContextKey('chatInputHasFocus', false, { type: 'boolean', description: localize('interactiveInputHasFocus', "True when the chat input has focus.") }); export const inChatInput = new RawContextKey('inChatInput', false, { type: 'boolean', description: localize('inInteractiveInput', "True when focus is in the chat input, false otherwise.") }); export const inChatSession = new RawContextKey('inChat', false, { type: 'boolean', description: localize('inChat', "True when focus is in the chat widget, false otherwise.") }); + export const inChatEditWorkingSet = new RawContextKey('inChatEditWorkingSet', false, { type: 'boolean', description: localize('inChatEditWorkingSet', "True when focus is in the chat edit working set, false otherwise.") }); export const supported = ContextKeyExpr.or(IsWebContext.toNegated(), RemoteNameContext.notEqualsTo('')); // supported on desktop and in web only with a remote connection export const enabled = new RawContextKey('chatIsEnabled', false, { type: 'boolean', description: localize('chatIsEnabled', "True when chat is enabled because a default chat participant is activated with an implementation.") });