Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure requests and responses are rerendered when the session is initialized #181371

Merged
merged 2 commits into from May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -188,7 +188,7 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
this.tree.setChildren(null, treeItems, {
diffIdentityProvider: {
getId: (element) => {
return element.id +
return ((isResponseVM(element) || isRequestVM(element)) ? element.dataId : element.id) +
// Ensure re-rendering an element once slash commands are loaded, so the colorization can be applied.
`${(isRequestVM(element) || isWelcomeVM(element)) && !!this.lastSlashCommands ? '_scLoaded' : ''}` +
// If a response is in the process of progressive rendering, we need to ensure that it will
Expand Down
Expand Up @@ -16,6 +16,7 @@ export interface IInteractiveRequestModel {
readonly id: string;
readonly username: string;
readonly avatarIconUri?: URI;
readonly session: IInteractiveSessionModel;
readonly message: string | IInteractiveSessionReplyFollowup;
readonly response: IInteractiveResponseModel | undefined;
}
Expand All @@ -27,6 +28,7 @@ export interface IInteractiveResponseModel {
readonly providerResponseId: string | undefined;
readonly username: string;
readonly avatarIconUri?: URI;
readonly session: IInteractiveSessionModel;
readonly response: IMarkdownString;
readonly isComplete: boolean;
readonly isCanceled: boolean;
Expand Down Expand Up @@ -55,15 +57,15 @@ export class InteractiveRequestModel implements IInteractiveRequestModel {
}

public get username(): string {
return this._session.requesterUsername;
return this.session.requesterUsername;
}

public get avatarIconUri(): URI | undefined {
return this._session.requesterAvatarIconUri;
return this.session.requesterAvatarIconUri;
}

constructor(
private readonly _session: InteractiveSessionModel,
public readonly session: InteractiveSessionModel,
public readonly message: string | IInteractiveSessionReplyFollowup) {
this._id = 'request_' + InteractiveRequestModel.nextId++;
}
Expand Down Expand Up @@ -109,20 +111,20 @@ export class InteractiveResponseModel extends Disposable implements IInteractive
}

public get providerId(): string {
return this._session.providerId;
return this.session.providerId;
}

public get username(): string {
return this._session.responderUsername;
return this.session.responderUsername;
}

public get avatarIconUri(): URI | undefined {
return this._session.responderAvatarIconUri;
return this.session.responderAvatarIconUri;
}

constructor(
private _response: IMarkdownString,
private readonly _session: InteractiveSessionModel,
public readonly session: InteractiveSessionModel,
private _isComplete: boolean = false,
private _isCanceled = false,
private _vote?: InteractiveSessionVoteDirection,
Expand Down Expand Up @@ -171,6 +173,7 @@ export interface IInteractiveSessionModel {
readonly onDidChange: Event<IInteractiveSessionChangeEvent>;
readonly sessionId: string;
readonly providerId: string;
readonly isInitialized: boolean;
// readonly title: string;
readonly welcomeMessage: IInteractiveSessionWelcomeMessageModel | undefined;
readonly requestInProgress: boolean;
Expand Down Expand Up @@ -286,6 +289,10 @@ export class InteractiveSessionModel extends Disposable implements IInteractiveS
return this._session?.responderAvatarIconUri ?? this._initialResponderAvatarIconUri;
}

get isInitialized(): boolean {
return this._isInitializedDeferred.isSettled;
}

constructor(
public readonly providerId: string,
private readonly initialData: ISerializableInteractiveSessionData | undefined,
Expand Down
Expand Up @@ -38,6 +38,8 @@ export interface IInteractiveSessionViewModel {

export interface IInteractiveRequestViewModel {
readonly id: string;
/** This ID updates every time the underlying data changes */
readonly dataId: string;
readonly username: string;
readonly avatarIconUri?: URI;
readonly message: string | IInteractiveSessionReplyFollowup;
Expand All @@ -61,6 +63,8 @@ export interface IInteractiveSessionLiveUpdateData {
export interface IInteractiveResponseViewModel {
readonly onDidChange: Event<void>;
readonly id: string;
/** This ID updates every time the underlying data changes */
readonly dataId: string;
readonly providerId: string;
readonly providerResponseId: string | undefined;
readonly username: string;
Expand Down Expand Up @@ -155,6 +159,10 @@ export class InteractiveRequestViewModel implements IInteractiveRequestViewModel
return this._model.id;
}

get dataId() {
return this.id + (this._model.session.isInitialized ? '' : '_initializing');
}

get username() {
return this._model.username;
}
Expand Down Expand Up @@ -183,7 +191,11 @@ export class InteractiveResponseViewModel extends Disposable implements IInterac
readonly onDidChange = this._onDidChange.event;

get id() {
return this._model.id + `_${this._modelChangeCount}`;
return this._model.id;
}

get dataId() {
return this._model.id + `_${this._modelChangeCount}` + (this._model.session.isInitialized ? '' : '_initializing');
}

get providerId() {
Expand Down