Avoid unnecesary updates to model in new background agent sessions#299121
Merged
DonJayamanne merged 1 commit intomainfrom Mar 4, 2026
Merged
Avoid unnecesary updates to model in new background agent sessions#299121DonJayamanne merged 1 commit intomainfrom
DonJayamanne merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts chat input model-selection reinitialization to reduce state churn when a chat session becomes a background session (i.e., the widget’s view model is cleared).
Changes:
- Guarded session-type tracking/model reinitialization so it only runs when
currentSessionResourceis present.
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts:1944
- With this guard,
initSelectedModel()won’t run when the widget transitions to a background session (currentSessionResourcebecomes undefined), but the handler still callscheckModelInSessionPool()unconditionally. If the currently selected model is session-targeted,checkModelInSessionPool()can callsetCurrentLanguageModelToDefault(), which persists the selection and syncs state to_inputModel—and_inputModelis not cleared whenChatWidget#setModel(undefined)is called. Consider also skippingcheckModelInSessionPool()(and any other model-syncing work) whene.currentSessionResourceis undefined, or explicitly clearing_inputModelwhen the view model is cleared to avoid mutating the background session’s input state.
if (e.currentSessionResource && newSessionType !== this._currentSessionType) {
this._currentSessionType = newSessionType;
this.initSelectedModel();
}
// Validate that the current model belongs to the new session's pool
this.checkModelInSessionPool();
bpasero
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.