Add tabs for multiple concurrent conversations (#54)

This commit is contained in:
Carl-Robert Linnupuu 2023-03-22 23:42:32 +00:00
parent 638fb557a7
commit 3d104c8b5a
11 changed files with 158 additions and 94 deletions

View file

@ -3,9 +3,8 @@ package ee.carlrobert.codegpt.action;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import ee.carlrobert.codegpt.conversations.ConversationsState;
import ee.carlrobert.codegpt.toolwindow.ContentManagerService;
import ee.carlrobert.codegpt.toolwindow.ToolWindowService;
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowPanel;
import org.jetbrains.annotations.NotNull;
public class AskAction extends AnAction {
@ -23,10 +22,15 @@ public class AskAction extends AnAction {
public void actionPerformed(@NotNull AnActionEvent event) {
var project = event.getProject();
if (project != null) {
ConversationsState.getInstance().startConversation();
project.getService(ContentManagerService.class).displayChatTab(project);
var chatToolWindow = project.getService(ToolWindowService.class).getChatToolWindow();
chatToolWindow.displayLandingView();
var contentManagerService = project.getService(ContentManagerService.class);
contentManagerService.displayChatTab(project);
contentManagerService.tryFindChatTabbedPane(project)
.ifPresent(tabbedPane -> {
var panel = new ChatToolWindowPanel(project);
panel.displayLandingView();
tabbedPane.addTab("Chat " + (tabbedPane.getTabCount() + 1), panel);
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
});
}
}
}