Skip to content

Commit

Permalink
Make filtered responses less readable and not copyable (#198539)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens authored Nov 17, 2023
1 parent 9d596ed commit 21d2297
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -24,6 +25,7 @@ export function registerChatCopyActions() {
category: CHAT_CATEGORY,
menu: {
id: MenuId.ChatContext,
when: CONTEXT_RESPONSE_FILTERED.toNegated(),
group: 'copy',
}
});
Expand All @@ -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) {
Expand All @@ -58,6 +60,7 @@ export function registerChatCopyActions() {
category: CHAT_CATEGORY,
menu: {
id: MenuId.ChatContext,
when: CONTEXT_RESPONSE_FILTERED.toNegated(),
group: 'copy',
}
});
Expand Down
10 changes: 7 additions & 3 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
}

Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/chat/browser/media/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 21d2297

Please sign in to comment.