Skip to content

Commit

Permalink
fix: model value change for empty conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
carlrobertoh committed Dec 17, 2024
1 parent 1c2a549 commit 54fa78e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private Optional<Conversation> tryGetNextOrPreviousConversation(boolean isPrevio
return Optional.empty();
}

private static String getModelForSelectedService(ServiceType serviceType) {
public String getModelForSelectedService(ServiceType serviceType) {
var application = ApplicationManager.getApplication();
return switch (serviceType) {
case CODEGPT -> application.getService(CodeGPTServiceSettings.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public ChatToolWindowTabPanel(@NotNull Project project, @NotNull Conversation co
this);
userInputPanel = new UserInputPanel(
project,
conversation,
totalTokensPanel,
this::handleSubmit,
this::handleCancel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.intellij.util.ui.UIUtil
import ee.carlrobert.codegpt.CodeGPTBundle
import ee.carlrobert.codegpt.Icons
import ee.carlrobert.codegpt.actions.AttachImageAction
import ee.carlrobert.codegpt.conversations.Conversation
import ee.carlrobert.codegpt.conversations.ConversationService
import ee.carlrobert.codegpt.conversations.ConversationsState
import ee.carlrobert.codegpt.settings.GeneralSettings
import ee.carlrobert.codegpt.settings.service.ServiceType
import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTServiceSettings
Expand All @@ -41,6 +41,7 @@ import javax.swing.JPanel

class UserInputPanel(
private val project: Project,
private val conversation: Conversation,
private val totalTokensPanel: TotalTokensPanel,
private val onSubmit: (String, List<AppliedActionInlay>?) -> Unit,
private val onStop: () -> Unit
Expand Down Expand Up @@ -158,9 +159,12 @@ class UserInputPanel(
{
imageActionSupported.set(isImageActionSupported())
// TODO: Implement a proper session management
if (service<ConversationsState>().state?.currentConversation?.messages?.isNotEmpty() == true) {
service<ConversationService>().startConversation()
val conversationService = service<ConversationService>()
if (conversation.messages.isNotEmpty()) {
conversationService.startConversation()
project.service<ChatToolWindowContentManager>().createNewTabPanel()
} else {
conversation.model = conversationService.getModelForSelectedService(it)
}
},
service<GeneralSettings>().state.selectedService
Expand Down

0 comments on commit 54fa78e

Please sign in to comment.