From 21d2297f8cbd713cac21ecb5d56f2c7f3069e572 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 17 Nov 2023 10:54:53 -0600 Subject: [PATCH] Make filtered responses less readable and not copyable (#198539) --- .../contrib/chat/browser/actions/chatCopyActions.ts | 5 ++++- src/vs/workbench/contrib/chat/browser/chatWidget.ts | 10 +++++++--- src/vs/workbench/contrib/chat/browser/media/chat.css | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts index 972b483c675d3..816379d86468d 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts @@ -9,6 +9,7 @@ import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/act import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { CHAT_CATEGORY } from 'vs/workbench/contrib/chat/browser/actions/chatActions'; import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat'; +import { CONTEXT_RESPONSE_FILTERED } from 'vs/workbench/contrib/chat/common/chatContextKeys'; import { IChatRequestViewModel, IChatResponseViewModel, isRequestVM, isResponseVM } from 'vs/workbench/contrib/chat/common/chatViewModel'; export function registerChatCopyActions() { @@ -24,6 +25,7 @@ export function registerChatCopyActions() { category: CHAT_CATEGORY, menu: { id: MenuId.ChatContext, + when: CONTEXT_RESPONSE_FILTERED.toNegated(), group: 'copy', } }); @@ -36,7 +38,7 @@ export function registerChatCopyActions() { if (widget) { const viewModel = widget.viewModel; const sessionAsText = viewModel?.getItems() - .filter((item): item is (IChatRequestViewModel | IChatResponseViewModel) => isRequestVM(item) || isResponseVM(item)) + .filter((item): item is (IChatRequestViewModel | IChatResponseViewModel) => isRequestVM(item) || (isResponseVM(item) && !item.errorDetails?.responseIsFiltered)) .map(stringifyItem) .join('\n\n'); if (sessionAsText) { @@ -58,6 +60,7 @@ export function registerChatCopyActions() { category: CHAT_CATEGORY, menu: { id: MenuId.ChatContext, + when: CONTEXT_RESPONSE_FILTERED.toNegated(), group: 'copy', } }); diff --git a/src/vs/workbench/contrib/chat/browser/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/chatWidget.ts index 89e4e1bd9407d..0bf13a5db1a2a 100644 --- a/src/vs/workbench/contrib/chat/browser/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatWidget.ts @@ -27,7 +27,7 @@ import { ChatInputPart } from 'vs/workbench/contrib/chat/browser/chatInputPart'; import { ChatAccessibilityProvider, ChatListDelegate, ChatListItemRenderer, IChatListItemRendererOptions, IChatRendererDelegate } from 'vs/workbench/contrib/chat/browser/chatListRenderer'; import { ChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatOptions'; import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane'; -import { CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_SESSION } from 'vs/workbench/contrib/chat/common/chatContextKeys'; +import { CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE_FILTERED } from 'vs/workbench/contrib/chat/common/chatContextKeys'; import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService'; import { ChatModelInitState, IChatModel } from 'vs/workbench/contrib/chat/common/chatModel'; import { IChatReplyFollowup, IChatService } from 'vs/workbench/contrib/chat/common/chatService'; @@ -354,12 +354,16 @@ export class ChatWidget extends Disposable implements IChatWidget { e.browserEvent.preventDefault(); e.browserEvent.stopPropagation(); + const selected = e.element; + const scopedContextKeyService = this.contextKeyService.createOverlay([ + [CONTEXT_RESPONSE_FILTERED.key, isResponseVM(selected) && !!selected.errorDetails?.responseIsFiltered] + ]); this.contextMenuService.showContextMenu({ menuId: MenuId.ChatContext, menuActionOptions: { shouldForwardArgs: true }, - contextKeyService: this.contextKeyService, + contextKeyService: scopedContextKeyService, getAnchor: () => e.anchor, - getActionsContext: () => e.element, + getActionsContext: () => selected, }); } diff --git a/src/vs/workbench/contrib/chat/browser/media/chat.css b/src/vs/workbench/contrib/chat/browser/media/chat.css index 7ba3e573bd9e5..307a49652c26f 100644 --- a/src/vs/workbench/contrib/chat/browser/media/chat.css +++ b/src/vs/workbench/contrib/chat/browser/media/chat.css @@ -460,8 +460,10 @@ } .interactive-item-container.filtered-response .value > .rendered-markdown { - -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.05)); - mask-image: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.05)); + pointer-events: none; + filter: blur(1.8px); + -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.02)); + mask-image: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.02)); } /* #region Quick Chat */