Skip to content

Commit

Permalink
Merge pull request #113 from devoxx/issue-112
Browse files Browse the repository at this point in the history
Issue 112
  • Loading branch information
stephanj authored Jun 25, 2024
2 parents 49d4347 + 53e9330 commit 8b445f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public DevoxxGenieToolWindowContent(@NotNull ToolWindow toolWindow) {
*/
private void setLastSelectedProvider() {
String lastSelectedProvider = DevoxxGenieStateService.getInstance().getLastSelectedProvider();
if (lastSelectedProvider != null && !lastSelectedProvider.isEmpty()) {
if (lastSelectedProvider != null && !lastSelectedProvider.isEmpty()) {
llmProvidersComboBox.setSelectedItem(lastSelectedProvider);
updateModelNamesComboBox(ModelProvider.valueOf(lastSelectedProvider));
} else {
// If no last selected provider, select the first item in the combobox
Object selectedItem = llmProvidersComboBox.getSelectedItem();
if (selectedItem != null) {
updateModelNamesComboBox(ModelProvider.valueOf((String) selectedItem));
Expand All @@ -90,6 +91,8 @@ private void setupUI() {
contentPanel.setLayout(new BorderLayout());
contentPanel.add(createTopPanel(), BorderLayout.NORTH);
contentPanel.add(createSplitter(), BorderLayout.CENTER);

setLastSelectedProvider();
}

/**
Expand Down Expand Up @@ -125,8 +128,22 @@ private void setupUI() {
* Refresh the UI elements because the settings have changed.
*/
public void settingsChanged() {
String currentProvider = (String) llmProvidersComboBox.getSelectedItem();
String currentModel = (String) modelNameComboBox.getSelectedItem();

llmProvidersComboBox.removeAllItems();
addLLMProvidersToComboBox();

if (currentProvider != null && !currentProvider.isEmpty()) {
llmProvidersComboBox.setSelectedItem(currentProvider);
updateModelNamesComboBox(ModelProvider.valueOf(currentProvider));
if (currentModel != null && !currentModel.isEmpty()) {
modelNameComboBox.setSelectedItem(currentModel);
}
} else {
setLastSelectedProvider();
}

actionButtonsPanel.configureSearchButtonsVisibility();
}

Expand Down Expand Up @@ -242,7 +259,6 @@ private void handleModelProviderSelectionChange(@NotNull ActionEvent e) {
if (!e.getActionCommand().equals(Constant.COMBO_BOX_CHANGED) || !isInitializationComplete) return;

JComboBox<?> comboBox = (JComboBox<?>) e.getSource();

String selectedLLMProvider = (String) comboBox.getSelectedItem();
if (selectedLLMProvider == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
Expand All @@ -14,7 +13,6 @@

@Getter
@Setter
@Service
@State(
name = "com.devoxx.genie.ui.SettingsState",
storages = @Storage("DevoxxGenieSettingsPlugin.xml")
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<h2>v0.1.19</h2>
<UL>
<LI>Feat #98: Allow a streaming response to be stopped</LI>
<LI>Feat #112: Keep selected LLM provider after settings page</LI>
</UL>
<h2>v0.1.18</h2>
<UL>
Expand Down Expand Up @@ -222,6 +223,7 @@
icon="/icons/pluginIcon.svg"
factoryClass="com.devoxx.genie.ui.DevoxxGenieToolWindowFactory"/>

<applicationService serviceImplementation="com.devoxx.genie.ui.settings.DevoxxGenieStateService"/>
<applicationService serviceImplementation="com.devoxx.genie.service.PromptExecutionService"/>
<applicationService serviceImplementation="com.devoxx.genie.service.ChatMemoryService"/>
<applicationService serviceImplementation="com.devoxx.genie.service.MessageCreationService"/>
Expand Down

0 comments on commit 8b445f0

Please sign in to comment.