3030import com .intellij .openapi .ui .popup .ListPopup ;
3131import ee .carlrobert .codegpt .Icons ;
3232import ee .carlrobert .codegpt .completions .llama .LlamaModel ;
33+ import ee .carlrobert .codegpt .settings .models .ModelDetailsState ;
3334import ee .carlrobert .codegpt .settings .models .ModelRegistry ;
3435import ee .carlrobert .codegpt .settings .models .ModelSelection ;
3536import ee .carlrobert .codegpt .settings .models .ModelSettings ;
5152import java .awt .Color ;
5253import java .util .Arrays ;
5354import java .util .List ;
54- import java .util .Objects ;
5555import java .util .function .Consumer ;
5656import javax .swing .Icon ;
5757import javax .swing .JComponent ;
@@ -72,7 +72,8 @@ public ModelComboBoxAction(
7272 Project project ,
7373 Consumer <ServiceType > onModelChange ,
7474 ServiceType selectedService ) {
75- this (project , onModelChange , selectedService , Arrays .asList (ServiceType .values ()), true , FeatureType .CHAT );
75+ this (project , onModelChange , selectedService , Arrays .asList (ServiceType .values ()), true ,
76+ FeatureType .CHAT );
7677 }
7778
7879 public ModelComboBoxAction (
@@ -81,7 +82,8 @@ public ModelComboBoxAction(
8182 ServiceType selectedProvider ,
8283 List <ServiceType > availableProviders ,
8384 boolean showConfigureModels ) {
84- this (project , onModelChange , selectedProvider , availableProviders , showConfigureModels , FeatureType .CHAT );
85+ this (project , onModelChange , selectedProvider , availableProviders , showConfigureModels ,
86+ FeatureType .CHAT );
8587 }
8688
8789 public ModelComboBoxAction (
@@ -349,10 +351,19 @@ private void updateTemplatePresentation(ServiceType selectedService) {
349351 }
350352
351353 private String getGooglePresentationText () {
352- var model = ApplicationManager .getApplication ().getService (GoogleSettings .class )
354+ var chatModel = ApplicationManager .getApplication ()
355+ .getService (ModelSettings .class )
353356 .getState ()
354- .getModel ();
355- return ModelRegistry .getInstance ().getModelDisplayName (GOOGLE , model );
357+ .getModelSelection (featureType );
358+ return ModelRegistry .getInstance ().getModelDisplayName (GOOGLE , getGoogleModelCode (chatModel ));
359+ }
360+
361+ private String getGoogleModelCode (@ Nullable ModelDetailsState chatModel ) {
362+ if (chatModel == null || chatModel .getModel () == null || chatModel .getModel ().isBlank ()) {
363+ return ModelRegistry .GEMINI_PRO_2_5 ;
364+ }
365+
366+ return chatModel .getModel ();
356367 }
357368
358369 private String getLlamaCppPresentationText () {
@@ -473,8 +484,22 @@ private AnAction createGoogleModelAction(GoogleModel model, Presentation comboBo
473484 modelName ,
474485 Icons .Google ,
475486 comboBoxPresentation ,
476- () -> ApplicationManager .getApplication ().getService (ModelSettings .class )
477- .setModel (featureType , model .getCode (), GOOGLE ));
487+ () -> {
488+ // Persist selection in the unified ModelSettings used across features
489+ ApplicationManager .getApplication ()
490+ .getService (ModelSettings .class )
491+ .setModel (featureType , model .getCode (), GOOGLE );
492+
493+ // Also mirror the selection into GoogleSettings for any legacy UI reads
494+ try {
495+ ApplicationManager .getApplication ()
496+ .getService (GoogleSettings .class )
497+ .getState ()
498+ .setModel (model .getCode ());
499+ } catch (Exception ignored ) {
500+ // Best-effort sync; lack of GoogleSettings should not block selection
501+ }
502+ });
478503 }
479504
480505 private AnAction createAnthropicModelAction (
0 commit comments