Skip to content

Avoid unnecesary updates to model in new background agent sessions#299121

Merged
DonJayamanne merged 1 commit intomainfrom
don/controlled-squirrel
Mar 4, 2026
Merged

Avoid unnecesary updates to model in new background agent sessions#299121
DonJayamanne merged 1 commit intomainfrom
don/controlled-squirrel

Conversation

@DonJayamanne
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 4, 2026 05:42
@DonJayamanne DonJayamanne self-assigned this Mar 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 currentSessionResource is 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 (currentSessionResource becomes undefined), but the handler still calls checkModelInSessionPool() unconditionally. If the currently selected model is session-targeted, checkModelInSessionPool() can call setCurrentLanguageModelToDefault(), which persists the selection and syncs state to _inputModel—and _inputModel is not cleared when ChatWidget#setModel(undefined) is called. Consider also skipping checkModelInSessionPool() (and any other model-syncing work) when e.currentSessionResource is undefined, or explicitly clearing _inputModel when 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();

@DonJayamanne DonJayamanne marked this pull request as ready for review March 4, 2026 05:47
@vs-code-engineering vs-code-engineering bot added this to the 1.111.0 milestone Mar 4, 2026
@DonJayamanne DonJayamanne merged commit 6e1d1b1 into main Mar 4, 2026
24 checks passed
@DonJayamanne DonJayamanne deleted the don/controlled-squirrel branch March 4, 2026 07:31
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