Skip to content

fix how _selectVendorDefaultLanguageModel is set#287804

Merged
jrieken merged 1 commit intomainfrom
joh/plain-iguana
Jan 14, 2026
Merged

fix how _selectVendorDefaultLanguageModel is set#287804
jrieken merged 1 commit intomainfrom
joh/plain-iguana

Conversation

@jrieken
Copy link
Copy Markdown
Member

@jrieken jrieken commented Jan 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 15:51
@jrieken jrieken enabled auto-merge (squash) January 14, 2026 15:51
@jrieken jrieken self-assigned this Jan 14, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 14, 2026
Copy link
Copy Markdown
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

This PR moves the setting of the _selectVendorDefaultLanguageModel static field from widget initialization to the run() method and adds proper cleanup. The change addresses when the listener is attached to track language model changes and ensures the listener is disposed when the session completes.

Changes:

  • Moved onDidChangeCurrentLanguageModel listener from widget initialization to run() method
  • Added DisposableStore for proper cleanup of the listener
  • Wrapped existing wait logic in try-finally block to ensure cleanup
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts:439

  • This line has the same issue as Comment 1. For notebook contexts, it should check against the widget's actual location (which could be ChatAgentLocation.Notebook), not session.chatModel.initialLocation (which is always ChatAgentLocation.EditorInline).
		if (!persistModelChoice && InlineChatController._selectVendorDefaultLanguageModel && model && !model.metadata.isDefaultForLocation[session.chatModel.initialLocation]) {

Comment on lines +450 to +452
store.add(this._zone.value.widget.chatWidget.input.onDidChangeCurrentLanguageModel(newModel => {
InlineChatController._selectVendorDefaultLanguageModel = Boolean(newModel.metadata.isDefaultForLocation[session.chatModel.initialLocation]);
}));
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Using session.chatModel.initialLocation is incorrect for notebook contexts. The session is always created with ChatAgentLocation.EditorInline (see InlineChatSessionServiceImpl.createSession), but the widget's location can be ChatAgentLocation.Notebook for notebook editors. The old code correctly used location.location which could be either EditorInline or Notebook. This should either store the widget's location for use here, or access it differently to handle the notebook case correctly.

Copilot uses AI. Check for mistakes.

const session = this._inlineChatSessionService.createSession(this._editor);

const store = new DisposableStore();
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The store will leak if an exception is thrown anywhere between lines 433-504 (before the try block starts). Move the store creation and the try block to encompass all code that could throw after line 432, or wrap all potentially throwing code in the try block.

Copilot uses AI. Check for mistakes.
@bpasero
Copy link
Copy Markdown
Member

bpasero commented Jan 14, 2026

@jrieken just fyi looks like Copilot has some thoughts

@jrieken jrieken merged commit 472a1bb into main Jan 14, 2026
27 of 28 checks passed
@jrieken jrieken deleted the joh/plain-iguana branch January 14, 2026 16:13
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Feb 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants