Make inline chat fallback to the default model of selected vendor (#287244)

This makes sure inline chat uses the model the vendor/extension recommends. Also makes sure folks aren't stuck on an old model selection. This can be disabled (via setting) and a custom selection will be honoured for the duration of a vscode session (lifetime of a window)

https://github.com/microsoft/vscode-internalbacklog/issues/6544
This commit is contained in:
Johannes Rieken
2026-01-13 10:45:59 +01:00
committed by GitHub
parent 3cb484f591
commit 9d62a24f48
2 changed files with 30 additions and 2 deletions

View File

@@ -104,6 +104,8 @@ export class InlineChatController implements IEditorContribution {
return editor.getContribution<InlineChatController>(InlineChatController.ID) ?? undefined;
}
private static _selectVendorDefaultLanguageModel: boolean = true;
private readonly _store = new DisposableStore();
private readonly _isActiveController = observableValue(this, false);
private readonly _zone: Lazy<InlineChatZoneWidget>;
@@ -125,7 +127,7 @@ export class InlineChatController implements IEditorContribution {
@IInlineChatSessionService private readonly _inlineChatSessionService: IInlineChatSessionService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ISharedWebContentExtractorService private readonly _webContentExtractorService: ISharedWebContentExtractorService,
@IFileService private readonly _fileService: IFileService,
@IChatAttachmentResolveService private readonly _chatAttachmentResolveService: IChatAttachmentResolveService,
@@ -135,7 +137,7 @@ export class InlineChatController implements IEditorContribution {
) {
const ctxInlineChatVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
const notebookAgentConfig = observableConfigValue(InlineChatConfigKeys.notebookAgent, false, configurationService);
const notebookAgentConfig = observableConfigValue(InlineChatConfigKeys.notebookAgent, false, this._configurationService);
this._zone = new Lazy<InlineChatZoneWidget>(() => {
@@ -202,6 +204,10 @@ export class InlineChatController implements IEditorContribution {
this._store.add(result);
this._store.add(result.widget.chatWidget.input.onDidChangeCurrentLanguageModel(newModel => {
InlineChatController._selectVendorDefaultLanguageModel = Boolean(newModel.metadata.isDefault);
}));
result.domNode.classList.add('inline-chat-2');
return result;
@@ -429,6 +435,22 @@ export class InlineChatController implements IEditorContribution {
const session = this._inlineChatSessionService.createSession(this._editor);
// fallback to the default model of the selected vendor unless an explicit selection was made for the session
// or unless the user has chosen to persist their model choice
const persistModelChoice = this._configurationService.getValue<boolean>(InlineChatConfigKeys.PersistModelChoice);
const model = this._zone.value.widget.chatWidget.input.selectedLanguageModel;
if (!persistModelChoice && InlineChatController._selectVendorDefaultLanguageModel && model && !model.metadata.isDefault) {
const ids = await this._languageModelService.selectLanguageModels({ vendor: model.metadata.vendor }, false);
for (const identifier of ids) {
const candidate = this._languageModelService.lookupLanguageModel(identifier);
if (candidate?.isDefault) {
this._zone.value.widget.chatWidget.input.setCurrentLanguageModel({ metadata: candidate, identifier });
break;
}
}
}
// ADD diagnostics
const entries: IChatRequestVariableEntry[] = [];
for (const [range, marker] of this._markerDecorationsService.getLiveMarkers(uri)) {