mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-27 00:26:23 +00:00
feat: add project-based chat history filtering
This commit is contained in:
parent
ff03d9c1fb
commit
a530ca6e9f
16 changed files with 316 additions and 44 deletions
|
|
@ -16,6 +16,7 @@ public class Conversation {
|
|||
private LocalDateTime createdOn;
|
||||
private LocalDateTime updatedOn;
|
||||
private boolean discardTokenLimit;
|
||||
private String projectPath;
|
||||
|
||||
public Conversation() {
|
||||
this.messages = new ArrayList<>();
|
||||
|
|
@ -82,4 +83,12 @@ public class Conversation {
|
|||
.filter(message -> !message.getId().equals(messageId))
|
||||
.toList());
|
||||
}
|
||||
|
||||
public String getProjectPath() {
|
||||
return projectPath;
|
||||
}
|
||||
|
||||
public void setProjectPath(String projectPath) {
|
||||
this.projectPath = projectPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package ee.carlrobert.codegpt.conversations;
|
|||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.Service;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import ee.carlrobert.codegpt.completions.ChatCompletionParameters;
|
||||
import ee.carlrobert.codegpt.conversations.message.Message;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -74,8 +75,13 @@ public final class ConversationService {
|
|||
conversationState.setCurrentConversation(conversation);
|
||||
}
|
||||
|
||||
public Conversation startConversation() {
|
||||
public Conversation startConversation(Project project) {
|
||||
return startConversation(project != null ? project.getBasePath() : null);
|
||||
}
|
||||
|
||||
private Conversation startConversation(String projectPath) {
|
||||
var conversation = createConversation();
|
||||
conversation.setProjectPath(projectPath);
|
||||
conversationState.setCurrentConversation(conversation);
|
||||
addConversation(conversation);
|
||||
return conversation;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public final class ChatToolWindowContentManager {
|
|||
.map(item -> {
|
||||
var panel = new ChatToolWindowTabPanel(
|
||||
project,
|
||||
ConversationService.getInstance().startConversation());
|
||||
ConversationService.getInstance().startConversation(project));
|
||||
item.addNewTab(panel);
|
||||
return panel;
|
||||
})
|
||||
|
|
@ -117,7 +117,7 @@ public final class ChatToolWindowContentManager {
|
|||
tabbedPane.clearAll();
|
||||
tabbedPane.addNewTab(new ChatToolWindowTabPanel(
|
||||
project,
|
||||
ConversationService.getInstance().startConversation()));
|
||||
ConversationService.getInstance().startConversation(project)));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,11 +45,13 @@ public class ChatToolWindowPanel extends SimpleToolWindowPanel {
|
|||
private final ToolWindowFooterNotification imageFileAttachmentNotification;
|
||||
private final ActionLink upgradePlanLink;
|
||||
private final ChatToolWindowTabbedPane tabbedPane;
|
||||
private final Project project;
|
||||
|
||||
public ChatToolWindowPanel(
|
||||
@NotNull Project project,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
super(true);
|
||||
this.project = project;
|
||||
imageFileAttachmentNotification = new ToolWindowFooterNotification(() ->
|
||||
project.putUserData(CodeGPTKeys.IMAGE_ATTACHMENT_FILE_PATH, ""));
|
||||
upgradePlanLink = new ActionLink("Upgrade your plan", event -> {
|
||||
|
|
@ -72,7 +74,7 @@ public class ChatToolWindowPanel extends SimpleToolWindowPanel {
|
|||
private Conversation getConversation() {
|
||||
var conversation = ConversationsState.getCurrentConversation();
|
||||
if (conversation == null) {
|
||||
return ConversationService.getInstance().startConversation();
|
||||
return ConversationService.getInstance().startConversation(project);
|
||||
}
|
||||
return conversation;
|
||||
}
|
||||
|
|
@ -118,7 +120,7 @@ public class ChatToolWindowPanel extends SimpleToolWindowPanel {
|
|||
Runnable onAddNewTab = () -> {
|
||||
tabbedPane.addNewTab(new ChatToolWindowTabPanel(
|
||||
project,
|
||||
ConversationService.getInstance().startConversation()));
|
||||
ConversationService.getInstance().startConversation(project)));
|
||||
repaint();
|
||||
revalidate();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public class ChatToolWindowTabbedPane extends JBTabbedPane {
|
|||
removeTabAt(getSelectedIndex());
|
||||
addNewTab(new ChatToolWindowTabPanel(
|
||||
project,
|
||||
ConversationService.getInstance().startConversation()));
|
||||
ConversationService.getInstance().startConversation(project)));
|
||||
repaint();
|
||||
revalidate();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue