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

Trigger change event in model when response model completes #242014

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

DonJayamanne
Copy link
Contributor

@DonJayamanne DonJayamanne commented Feb 26, 2025

@DonJayamanne DonJayamanne self-assigned this Feb 26, 2025
@@ -1585,6 +1591,7 @@ export class ChatModel extends Disposable implements IChatModel {
}

request.response.complete();
this._onDidChange.fire({ kind: 'completedRequest', request });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We access chatModelrequestInProgress in chatEditingEditorContextKeys.ts.
However the onDidChange event doesn't trigger when the response is complete.
I found that this was the case in some cases for regular text editors as well.

More like a race condition.
In some cases the response complete variable is set before the session state is change.

Here onDidChange is never triggered, hence this is effectively the same as
const isRequestInProgress = chatModel?.requestInProgress === true
Usage

			const isRequestInProgress = chatModel
				? observableFromEvent(this, chatModel.onDidChange, () => chatModel.requestInProgress)
				: constObservable(false);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I came to the same conclusion and would have done the same change.

@DonJayamanne DonJayamanne requested a review from jrieken February 26, 2025 04:55
@DonJayamanne DonJayamanne marked this pull request as ready for review February 26, 2025 04:55
@vs-code-engineering vs-code-engineering bot added this to the February 2025 milestone Feb 26, 2025
@DonJayamanne DonJayamanne enabled auto-merge (squash) February 26, 2025 05:25
@kodizia

This comment was marked as spam.

@@ -1585,6 +1591,7 @@ export class ChatModel extends Disposable implements IChatModel {
}

request.response.complete();
this._onDidChange.fire({ kind: 'completedRequest', request });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I came to the same conclusion and would have done the same change.

@DonJayamanne DonJayamanne merged commit 1142862 into main Feb 26, 2025
8 checks passed
@DonJayamanne DonJayamanne deleted the don/wasteful-hookworm branch February 26, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants