Skip to content

Commit

Permalink
Fade out interactive session responses that were filtered out (#178073)
Browse files Browse the repository at this point in the history
* Fade out interactive session responses that were filtered out

* Fix import
  • Loading branch information
roblourens authored Mar 22, 2023
1 parent 6742eff commit 324d1a2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ import { SaveReason } from 'vs/workbench/common/editor';
import { IRevealOptions, ITreeItem, IViewBadge } from 'vs/workbench/common/views';
import { CallHierarchyItem } from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
import { DebugConfigurationProviderTriggerKind, IAdapterDescriptor, IConfig, IDebugSessionReplMode } from 'vs/workbench/contrib/debug/common/debug';
import { IInteractiveResponseErrorDetails } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionModel';
import { IInteractiveProgress, IInteractiveSessionDynamicRequest, IInteractiveSessionFollowup, IInteractiveSessionReplyFollowup, IInteractiveSessionUserActionEvent, IInteractiveSlashCommand } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import { IInteractiveProgress, IInteractiveResponseErrorDetails, IInteractiveSessionDynamicRequest, IInteractiveSessionFollowup, IInteractiveSessionReplyFollowup, IInteractiveSessionUserActionEvent, IInteractiveSlashCommand } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import * as notebookCommon from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellExecutionUpdateType } from 'vs/workbench/contrib/notebook/common/notebookExecutionService';
import { ICellExecutionComplete, ICellExecutionStateUpdate } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class InteractiveListItemRenderer extends Disposable implements ITreeRend
templateData.rowContainer.classList.toggle('interactive-request', isRequestVM(element));
templateData.rowContainer.classList.toggle('interactive-response', isResponseVM(element));
templateData.rowContainer.classList.toggle('interactive-welcome', isWelcomeVM(element));
templateData.rowContainer.classList.toggle('filtered-response', !!(isResponseVM(element) && element.errorDetails?.responseIsFiltered));
templateData.username.textContent = element.username;

if (element.avatarIconUri) {
Expand Down Expand Up @@ -230,15 +231,16 @@ export class InteractiveListItemRenderer extends Disposable implements ITreeRend
runProgressiveRender(true);
timer.cancelAndSet(runProgressiveRender, 50);
} else if (isResponseVM(element)) {
this.basicRenderElement(element.response.value, element, index, templateData, element.isCanceled);
this.basicRenderElement(element.response.value, element, index, templateData);
} else if (isRequestVM(element)) {
this.basicRenderElement(element.messageText, element, index, templateData);
} else {
this.renderWelcomeMessage(element, templateData);
}
}

private basicRenderElement(markdownValue: string, element: InteractiveTreeItem, index: number, templateData: IInteractiveListItemTemplate, fillInIncompleteTokens = false) {
private basicRenderElement(markdownValue: string, element: InteractiveTreeItem, index: number, templateData: IInteractiveListItemTemplate) {
const fillInIncompleteTokens = isResponseVM(element) && (!element.isComplete || element.isCanceled || element.errorDetails?.responseIsFiltered);
const result = this.renderMarkdown(new MarkdownString(markdownValue), element, templateData.elementDisposables, templateData, fillInIncompleteTokens);
dom.clearNode(templateData.value);
templateData.value.appendChild(result.element);
Expand Down Expand Up @@ -299,7 +301,7 @@ export class InteractiveListItemRenderer extends Disposable implements ITreeRend
if (element.isCanceled) {
this.traceLayout('runProgressiveRender', `canceled, index=${index}`);
element.renderData = undefined;
this.basicRenderElement(element.response.value, element, index, templateData, true);
this.basicRenderElement(element.response.value, element, index, templateData);
isFullyRendered = true;
} else {
// TODO- this method has the side effect of updating element.renderData
Expand All @@ -315,7 +317,7 @@ export class InteractiveListItemRenderer extends Disposable implements ITreeRend
this.traceLayout('runProgressiveRender', `Rendered all available words, but model is not complete.`);
}
disposables.clear();
this.basicRenderElement(element.response.value, element, index, templateData, !element.isComplete);
this.basicRenderElement(element.response.value, element, index, templateData);
} else if (toRender) {
// Doing the progressive render
const plusCursor = toRender.match(/```.*$/) ? toRender + `\n${InteractiveListItemRenderer.cursorCharacter}` : toRender + ` ${InteractiveListItemRenderer.cursorCharacter}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,8 @@
/* Very aggressive list styles try to apply focus colors to every codicon in a list row. */
color: var(--vscode-foreground) !important;
}

.interactive-session .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));
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IMarkdownString, MarkdownString } from 'vs/base/common/htmlContent';
import { Disposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ILogService } from 'vs/platform/log/common/log';
import { IInteractiveProgress, IInteractiveResponse, IInteractiveSession, IInteractiveSessionFollowup, IInteractiveSessionReplyFollowup, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import { IInteractiveProgress, IInteractiveResponse, IInteractiveResponseErrorDetails, IInteractiveSession, IInteractiveSessionFollowup, IInteractiveSessionReplyFollowup, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';

export interface IInteractiveRequestModel {
readonly id: string;
Expand All @@ -18,11 +18,6 @@ export interface IInteractiveRequestModel {
readonly response: IInteractiveResponseModel | undefined;
}

export interface IInteractiveResponseErrorDetails {
message: string;
responseIsIncomplete?: boolean;
}

export interface IInteractiveResponseModel {
readonly onDidChange: Event<void>;
readonly id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { CompletionItemKind, ProviderResult } from 'vs/editor/common/languages';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IInteractiveResponseErrorDetails, InteractiveSessionModel } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionModel';
import { InteractiveSessionModel } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionModel';

export interface IInteractiveSession {
id: number;
Expand All @@ -26,6 +26,12 @@ export interface IInteractiveRequest {
message: string | IInteractiveSessionReplyFollowup;
}

export interface IInteractiveResponseErrorDetails {
message: string;
responseIsIncomplete?: boolean;
responseIsFiltered?: boolean;
}

export interface IInteractiveResponse {
session: IInteractiveSession;
errorDetails?: IInteractiveResponseErrorDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { IInteractiveRequestModel, IInteractiveResponseErrorDetails, IInteractiveResponseModel, IInteractiveSessionModel, IInteractiveSessionWelcomeMessageModel, IInteractiveWelcomeMessageContent } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionModel';
import { IInteractiveSessionReplyFollowup, IInteractiveSessionResponseCommandFollowup, IInteractiveSessionService, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import { IInteractiveRequestModel, IInteractiveResponseModel, IInteractiveSessionModel, IInteractiveSessionWelcomeMessageModel, IInteractiveWelcomeMessageContent } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionModel';
import { IInteractiveResponseErrorDetails, IInteractiveSessionReplyFollowup, IInteractiveSessionResponseCommandFollowup, IInteractiveSessionService, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import { countWords } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionWordCounter';

export function isRequestVM(item: unknown): item is IInteractiveRequestViewModel {
Expand Down
1 change: 1 addition & 0 deletions src/vscode-dts/vscode.proposed.interactive.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ declare module 'vscode' {
export interface InteractiveResponseErrorDetails {
message: string;
responseIsIncomplete?: boolean;
responseIsFiltered?: boolean;
}

export interface InteractiveResponseForProgress {
Expand Down

0 comments on commit 324d1a2

Please sign in to comment.