Codebase refactoring (#226)

* Refactor codebase
This commit is contained in:
Carl-Robert 2023-10-05 02:43:06 +03:00 committed by GitHub
parent 4c8b8d4e4f
commit 7dfe62b96d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 244 additions and 247 deletions

View file

@ -7,14 +7,14 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.startup.StartupActivity;
import ee.carlrobert.codegpt.actions.editor.EditorActionsUtil;
import ee.carlrobert.codegpt.credentials.UserCredentialsManager;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.credentials.YouCredentialsManager;
import ee.carlrobert.codegpt.settings.state.SettingsState;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.AuthenticationError;
import ee.carlrobert.codegpt.user.auth.AuthenticationHandler;
import ee.carlrobert.codegpt.user.auth.AuthenticationService;
import ee.carlrobert.codegpt.user.auth.SessionVerificationJob;
import ee.carlrobert.codegpt.user.auth.response.AuthenticationResponse;
import ee.carlrobert.codegpt.completions.you.auth.YouAuthenticationError;
import ee.carlrobert.codegpt.completions.you.auth.AuthenticationHandler;
import ee.carlrobert.codegpt.completions.you.auth.YouAuthenticationService;
import ee.carlrobert.codegpt.completions.you.auth.SessionVerificationJob;
import ee.carlrobert.codegpt.completions.you.auth.response.YouAuthenticationResponse;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;
import org.quartz.JobBuilder;
@ -33,9 +33,9 @@ public class PluginStartupActivity implements StartupActivity {
public void runActivity(@NotNull Project project) {
EditorActionsUtil.refreshActions();
var authenticationResponse = UserManager.getInstance().getAuthenticationResponse();
var authenticationResponse = YouUserManager.getInstance().getAuthenticationResponse();
if (authenticationResponse == null) {
handleAuthentication();
handleYouServiceAuthentication();
} else {
startSessionVerificationJob();
}
@ -77,18 +77,18 @@ public class PluginStartupActivity implements StartupActivity {
}
}
private void handleAuthentication() {
private void handleYouServiceAuthentication() {
var settings = SettingsState.getInstance();
if (!settings.isPreviouslySignedIn()) {
return;
}
var password = UserCredentialsManager.getInstance().getAccountPassword();
var password = YouCredentialsManager.getInstance().getAccountPassword();
if (!settings.getEmail().isEmpty() && password != null && !password.isEmpty()) {
AuthenticationService.getInstance()
YouAuthenticationService.getInstance()
.signInAsync(settings.getEmail(), password, new AuthenticationHandler() {
@Override
public void handleAuthenticated(AuthenticationResponse authenticationResponse) {
public void handleAuthenticated(YouAuthenticationResponse authenticationResponse) {
OverlayUtils.showNotification("Authentication successful.", NotificationType.INFORMATION);
startSessionVerificationJob();
}
@ -99,8 +99,8 @@ public class PluginStartupActivity implements StartupActivity {
}
@Override
public void handleError(AuthenticationError authenticationError) {
OverlayUtils.showNotification(authenticationError.getErrorMessage(), NotificationType.ERROR);
public void handleError(YouAuthenticationError youAuthenticationError) {
OverlayUtils.showNotification(youAuthenticationError.getErrorMessage(), NotificationType.ERROR);
}
});
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.toolwindow.chat.editor.actions;
package ee.carlrobert.codegpt.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@ -24,7 +24,7 @@ public abstract class TrackableAction extends AnAction {
this.actionType = actionType;
}
abstract void handleAction(@NotNull AnActionEvent e);
public abstract void handleAction(@NotNull AnActionEvent e);
@Override
public void actionPerformed(@NotNull AnActionEvent e) {

View file

@ -12,7 +12,7 @@ import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UI;
import ee.carlrobert.codegpt.conversations.message.Message;
import ee.carlrobert.codegpt.toolwindow.chat.standard.StandardChatToolWindowContentManager;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import ee.carlrobert.codegpt.util.SwingUtils;
import javax.swing.JComponent;
import javax.swing.JTextArea;

View file

@ -13,7 +13,7 @@ import com.intellij.openapi.project.Project;
import ee.carlrobert.codegpt.conversations.message.Message;
import ee.carlrobert.codegpt.settings.configuration.ConfigurationState;
import ee.carlrobert.codegpt.toolwindow.chat.standard.StandardChatToolWindowContentManager;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.text.CaseUtils;

View file

@ -6,9 +6,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.Messages;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.editor.EditorActionsUtil;
import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import ee.carlrobert.codegpt.conversations.ConversationService;
import ee.carlrobert.codegpt.conversations.ConversationsState;
import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;
@ -35,8 +34,6 @@ public class DeleteConversationAction extends AnAction {
TelemetryAction.IDE_ACTION.createActionMessage()
.property("action", ActionType.DELETE_CONVERSATION.name())
.send();
ConversationService.getInstance().deleteSelectedConversation();
onDelete.run();
}
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.user;
package ee.carlrobert.codegpt.completions.you;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -14,13 +14,13 @@ import okhttp3.Request;
import okhttp3.RequestBody;
@Service
public final class ApiClient {
public final class YouApiClient {
private static final String API_BASE_URL = "https://web.stytch.com/sdk";
private static final String publicToken = "public-token-live-507a52ad-7e69-496b-aee0-1c9863c7c819";
public static ApiClient getInstance() {
return ApplicationManager.getApplication().getService(ApiClient.class);
public static YouApiClient getInstance() {
return ApplicationManager.getApplication().getService(YouApiClient.class);
}
public void authenticate(String email, String password, Callback callback) {

View file

@ -1,9 +1,9 @@
package ee.carlrobert.codegpt.completions;
package ee.carlrobert.codegpt.completions.you;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SerpResult {
public class YouSerpResult {
private final String url;
private final String name;
@ -11,7 +11,7 @@ public class SerpResult {
private final String snippetSource;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public SerpResult(
public YouSerpResult(
@JsonProperty("url") String url,
@JsonProperty("name") String name,
@JsonProperty("snippet") String snippet,

View file

@ -0,0 +1,43 @@
package ee.carlrobert.codegpt.completions.you;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import ee.carlrobert.codegpt.completions.you.auth.SignedOutNotifier;
import ee.carlrobert.codegpt.completions.you.auth.response.YouAuthenticationResponse;
@Service
public final class YouUserManager {
private YouAuthenticationResponse authenticationResponse;
private YouUserManager() {
}
public static YouUserManager getInstance() {
return ApplicationManager.getApplication().getService(YouUserManager.class);
}
public YouAuthenticationResponse getAuthenticationResponse() {
return authenticationResponse;
}
public void setAuthenticationResponse(YouAuthenticationResponse authenticationResponse) {
this.authenticationResponse = authenticationResponse;
}
public void clearSession() {
authenticationResponse = null;
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(SignedOutNotifier.SIGNED_OUT_TOPIC)
.signedOut();
}
public boolean isSubscribed() {
return true; // TODO
}
public boolean isAuthenticated() {
return authenticationResponse != null;
}
}

View file

@ -0,0 +1,12 @@
package ee.carlrobert.codegpt.completions.you.auth;
import ee.carlrobert.codegpt.completions.you.auth.response.YouAuthenticationResponse;
public interface AuthenticationHandler {
void handleAuthenticated(YouAuthenticationResponse authenticationResponse);
void handleGenericError();
void handleError(YouAuthenticationError authenticationError);
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.user.auth;
package ee.carlrobert.codegpt.completions.you.auth;
import com.intellij.util.messages.Topic;

View file

@ -1,7 +1,6 @@
package ee.carlrobert.codegpt.user.auth;
package ee.carlrobert.codegpt.completions.you.auth;
import com.intellij.openapi.diagnostic.Logger;
import ee.carlrobert.codegpt.user.UserManager;
import java.time.LocalDateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@ -13,5 +12,6 @@ public class SessionVerificationJob implements Job {
@Override
public void execute(JobExecutionContext context) {
LOG.info("Refreshing token: " + LocalDateTime.now());
// TODO: Not implemented
}
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.user.auth;
package ee.carlrobert.codegpt.completions.you.auth;
import com.intellij.util.messages.Topic;

View file

@ -1,15 +1,15 @@
package ee.carlrobert.codegpt.user.auth;
package ee.carlrobert.codegpt.completions.you.auth;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationError {
public class YouAuthenticationError {
private final String errorType;
private final String errorMessage;
public AuthenticationError(@JsonProperty("error_type") String errorType, @JsonProperty("error_message") String errorMessage) {
public YouAuthenticationError(@JsonProperty("error_type") String errorType, @JsonProperty("error_message") String errorMessage) {
this.errorType = errorType;
this.errorMessage = errorMessage;
}

View file

@ -1,13 +1,13 @@
package ee.carlrobert.codegpt.user.auth;
package ee.carlrobert.codegpt.completions.you.auth;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import ee.carlrobert.codegpt.user.ApiClient;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.response.AuthenticationResponse;
import ee.carlrobert.codegpt.completions.you.YouApiClient;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.completions.you.auth.response.YouAuthenticationResponse;
import ee.carlrobert.codegpt.util.OverlayUtils;
import java.io.IOException;
import okhttp3.Call;
@ -16,32 +16,28 @@ import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
@Service
public final class AuthenticationService {
public final class YouAuthenticationService {
private static final Logger LOG = Logger.getInstance(AuthenticationService.class);
private static final ApiClient client = ApiClient.getInstance();
private static final Logger LOG = Logger.getInstance(YouAuthenticationService.class);
private static final YouApiClient client = YouApiClient.getInstance();
private AuthenticationService() {
private YouAuthenticationService() {
}
public static AuthenticationService getInstance() {
return ApplicationManager.getApplication().getService(AuthenticationService.class);
public static YouAuthenticationService getInstance() {
return ApplicationManager.getApplication().getService(YouAuthenticationService.class);
}
public void signInAsync(String email, String password, AuthenticationHandler authenticationHandler) {
client.authenticate(email, password, new AuthenticationCallback(authenticationHandler, email, password));
client.authenticate(email, password, new AuthenticationCallback(authenticationHandler));
}
static class AuthenticationCallback implements Callback {
private final AuthenticationHandler authenticationHandler;
private final String email;
private final String password;
public AuthenticationCallback(AuthenticationHandler authenticationHandler, String email, String password) {
public AuthenticationCallback(AuthenticationHandler authenticationHandler) {
this.authenticationHandler = authenticationHandler;
this.email = email;
this.password = password;
}
@Override
@ -60,8 +56,8 @@ public final class AuthenticationService {
if (response.code() == 200) {
try {
var authenticationResponse = new ObjectMapper().readValue(body.string(), AuthenticationResponse.class);
UserManager.getInstance().setAuthenticationResponse(authenticationResponse);
var authenticationResponse = new ObjectMapper().readValue(body.string(), YouAuthenticationResponse.class);
YouUserManager.getInstance().setAuthenticationResponse(authenticationResponse);
authenticationHandler.handleAuthenticated(authenticationResponse);
ApplicationManager.getApplication().getMessageBus()
@ -74,7 +70,7 @@ public final class AuthenticationService {
}
try {
authenticationHandler.handleError(new ObjectMapper().readValue(body.string(), AuthenticationError.class));
authenticationHandler.handleError(new ObjectMapper().readValue(body.string(), YouAuthenticationError.class));
} catch (Throwable ex) {
authenticationHandler.handleGenericError();
throw new RuntimeException(ex);

View file

@ -0,0 +1,18 @@
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class YouAuthenticationResponse {
private final YouAuthenticationResponseData data;
public YouAuthenticationResponse(@JsonProperty("data") YouAuthenticationResponseData data) {
this.data = data;
}
public YouAuthenticationResponseData getData() {
return data;
}
}

View file

@ -1,28 +1,28 @@
package ee.carlrobert.codegpt.user.auth.response;
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationResponseData {
public class YouAuthenticationResponseData {
private final Session session;
private final YouSession session;
private final String sessionJwt;
private final String sessionToken;
private final User user;
private final YouUser user;
public AuthenticationResponseData(
@JsonProperty("session") Session session,
public YouAuthenticationResponseData(
@JsonProperty("session") YouSession session,
@JsonProperty("session_jwt") String sessionJwt,
@JsonProperty("session_token") String sessionToken,
@JsonProperty("user") User user) {
@JsonProperty("user") YouUser user) {
this.session = session;
this.sessionJwt = sessionJwt;
this.sessionToken = sessionToken;
this.user = user;
}
public Session getSession() {
public YouSession getSession() {
return session;
}
@ -34,7 +34,7 @@ public class AuthenticationResponseData {
return sessionToken;
}
public User getUser() {
public YouUser getUser() {
return user;
}
}

View file

@ -1,16 +1,16 @@
package ee.carlrobert.codegpt.user.auth.response;
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Email {
public class YouEmail {
private final String email;
private final String emailId;
private final boolean verified;
public Email(
public YouEmail(
@JsonProperty("email") String email,
@JsonProperty("email_id") String emailId,
@JsonProperty("verified") boolean verified) {

View file

@ -1,16 +1,16 @@
package ee.carlrobert.codegpt.user.auth.response;
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Name {
public class YouName {
private final String firstName;
private final String middleName;
private final String lastName;
public Name(
public YouName(
@JsonProperty("first_name") String firstName,
@JsonProperty("middle_name") String middleName,
@JsonProperty("last_name") String lastName) {

View file

@ -1,10 +1,10 @@
package ee.carlrobert.codegpt.user.auth.response;
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Session {
public class YouSession {
private final String expiresAt;
private final String lastAccessedAt;
@ -12,7 +12,7 @@ public class Session {
private final String startedAt;
private final String userId;
public Session(
public YouSession(
@JsonProperty("expires_at") String expiresAt,
@JsonProperty("last_accessed_at") String lastAccessedAt,
@JsonProperty("session_id") String sessionId,

View file

@ -1,30 +1,30 @@
package ee.carlrobert.codegpt.user.auth.response;
package ee.carlrobert.codegpt.completions.you.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class User {
public class YouUser {
private final List<Email> emails;
private final Name name;
private final List<YouEmail> emails;
private final YouName name;
private final String userId;
public User(
@JsonProperty("emails") List<Email> emails,
@JsonProperty("name") Name name,
public YouUser(
@JsonProperty("emails") List<YouEmail> emails,
@JsonProperty("name") YouName name,
@JsonProperty("user_id") String userId) {
this.emails = emails;
this.name = name;
this.userId = userId;
}
public List<Email> getEmails() {
public List<YouEmail> getEmails() {
return emails;
}
public Name getName() {
public YouName getName() {
return name;
}

View file

@ -2,7 +2,7 @@ package ee.carlrobert.codegpt.conversations.message;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import ee.carlrobert.codegpt.completions.SerpResult;
import ee.carlrobert.codegpt.completions.you.YouSerpResult;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@ -13,7 +13,7 @@ public class Message {
private final String prompt;
private String response;
private String userMessage;
private List<SerpResult> serpResults;
private List<YouSerpResult> serpResults;
public Message(String prompt, String response) {
this(prompt);
@ -50,11 +50,11 @@ public class Message {
this.userMessage = userMessage;
}
public List<SerpResult> getSerpResults() {
public List<YouSerpResult> getSerpResults() {
return serpResults;
}
public void setSerpResults(List<SerpResult> serpResults) {
public void setSerpResults(List<YouSerpResult> serpResults) {
this.serpResults = serpResults;
}

View file

@ -6,18 +6,18 @@ import com.intellij.openapi.components.Service;
import org.jetbrains.annotations.Nullable;
@Service
public final class UserCredentialsManager {
public final class YouCredentialsManager {
private static final CredentialAttributes accountPasswordCredentialAttributes = CredentialsUtil.createCredentialAttributes("ACCOUNT_PASSWORD");
private String accountPassword;
private UserCredentialsManager() {
private YouCredentialsManager() {
accountPassword = CredentialsUtil.getPassword(accountPasswordCredentialAttributes);
}
public static UserCredentialsManager getInstance() {
return ApplicationManager.getApplication().getService(UserCredentialsManager.class);
public static YouCredentialsManager getInstance() {
return ApplicationManager.getApplication().getService(YouCredentialsManager.class);
}
public @Nullable String getAccountPassword() {

View file

@ -1,12 +1,10 @@
package ee.carlrobert.codegpt.actions;
package ee.carlrobert.codegpt.indexes;
import static com.intellij.openapi.ui.DialogWrapper.OK_EXIT_CODE;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import ee.carlrobert.codegpt.indexes.CodebaseIndexingTask;
import ee.carlrobert.codegpt.indexes.FolderStructureTreePanel;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;

View file

@ -14,7 +14,7 @@ import com.intellij.openapi.util.io.FileUtil;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.CodeGPTPlugin;
import ee.carlrobert.codegpt.completions.CompletionClientProvider;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import ee.carlrobert.codegpt.util.OverlayUtils;
import ee.carlrobert.embedding.CheckedFile;
import ee.carlrobert.embedding.EmbeddingsService;

View file

@ -20,7 +20,7 @@ import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.AsyncProcessIcon;
import com.intellij.util.ui.JBUI;
import ee.carlrobert.embedding.CheckedFile;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;

View file

@ -17,8 +17,8 @@ import ee.carlrobert.codegpt.credentials.OpenAICredentialsManager;
import ee.carlrobert.codegpt.settings.state.AzureSettingsState;
import ee.carlrobert.codegpt.settings.state.OpenAISettingsState;
import ee.carlrobert.codegpt.settings.state.SettingsState;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.completions.you.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.util.SwingUtils;
import ee.carlrobert.llm.client.openai.completion.chat.OpenAIChatCompletionModel;
import ee.carlrobert.llm.completion.CompletionModel;
@ -120,7 +120,7 @@ public class ServiceSelectionForm {
azureCompletionModelComboBox.getEditor().getEditorComponent().setMaximumSize(azureBaseHostField.getPreferredSize());
displayWebSearchResultsCheckBox = new JBCheckBox("Display web search results", settings.isDisplayWebSearchResults());
displayWebSearchResultsCheckBox.setEnabled(UserManager.getInstance().isAuthenticated());
displayWebSearchResultsCheckBox.setEnabled(YouUserManager.getInstance().isAuthenticated());
openAIServiceSectionPanel = createOpenAIServiceSectionPanel();
azureServiceSectionPanel = createAzureServiceSectionPanel();
@ -233,7 +233,7 @@ public class ServiceSelectionForm {
private JPanel createYouServiceSectionPanel() {
return FormBuilder.createFormBuilder()
.addComponent(new UserDetailsSettingsPanel(Disposer.newDisposable()))
.addComponent(new YouServiceSelectionPanel(Disposer.newDisposable()))
.addComponent(new TitledSeparator("Chat Preferences"))
.addComponent(withEmptyLeftBorder(displayWebSearchResultsCheckBox))
.getPanel();

View file

@ -15,12 +15,12 @@ public class SettingsComponent {
private final JPanel mainPanel;
private final JBTextField displayNameField;
private final ServiceSelectionForm serviceSelectionForm;
private final UserDetailsSettingsPanel userDetailsSettingsPanel;
private final YouServiceSelectionPanel youServiceSelectionPanel;
public SettingsComponent(Disposable parentDisposable, SettingsState settings) {
serviceSelectionForm = new ServiceSelectionForm(settings);
displayNameField = new JBTextField(settings.getDisplayName(), 20);
userDetailsSettingsPanel = new UserDetailsSettingsPanel(parentDisposable);
youServiceSelectionPanel = new YouServiceSelectionPanel(parentDisposable);
mainPanel = FormBuilder.createFormBuilder()
.addComponent(UI.PanelFactory.panel(displayNameField)
.withLabel(CodeGPTBundle.get("settingsConfigurable.section.integration.displayNameFieldLabel"))
@ -42,15 +42,15 @@ public class SettingsComponent {
}
public String getEmail() {
return userDetailsSettingsPanel.getEmail();
return youServiceSelectionPanel.getEmail();
}
public void setEmail(String email) {
userDetailsSettingsPanel.setEmail(email);
youServiceSelectionPanel.setEmail(email);
}
public String getPassword() {
return userDetailsSettingsPanel.getPassword();
return youServiceSelectionPanel.getPassword();
}
public ServiceSelectionForm getServiceSelectionForm() {

View file

@ -14,14 +14,14 @@ import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.JBFont;
import com.intellij.util.ui.JBUI;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.credentials.UserCredentialsManager;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.completions.you.auth.AuthenticationHandler;
import ee.carlrobert.codegpt.completions.you.auth.YouAuthenticationError;
import ee.carlrobert.codegpt.completions.you.auth.YouAuthenticationService;
import ee.carlrobert.codegpt.completions.you.auth.response.YouAuthenticationResponse;
import ee.carlrobert.codegpt.completions.you.auth.response.YouUser;
import ee.carlrobert.codegpt.credentials.YouCredentialsManager;
import ee.carlrobert.codegpt.settings.state.SettingsState;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.AuthenticationError;
import ee.carlrobert.codegpt.user.auth.AuthenticationHandler;
import ee.carlrobert.codegpt.user.auth.AuthenticationService;
import ee.carlrobert.codegpt.user.auth.response.AuthenticationResponse;
import ee.carlrobert.codegpt.user.auth.response.User;
import ee.carlrobert.codegpt.util.SwingUtils;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
@ -34,7 +34,7 @@ import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import org.jetbrains.annotations.Nullable;
public class UserDetailsSettingsPanel extends JPanel {
public class YouServiceSelectionPanel extends JPanel {
private final JBTextField emailField;
private final JBPasswordField passwordField;
@ -42,14 +42,14 @@ public class UserDetailsSettingsPanel extends JPanel {
private final JTextPane signUpTextPane;
private final AsyncProcessIcon loadingSpinner;
public UserDetailsSettingsPanel(Disposable parentDisposable) {
public YouServiceSelectionPanel(Disposable parentDisposable) {
super(new BorderLayout());
var settings = SettingsState.getInstance();
emailField = new JBTextField(settings.getEmail(), 25);
passwordField = new JBPasswordField();
passwordField.setColumns(25);
if (!settings.getEmail().isEmpty()) {
passwordField.setText(UserCredentialsManager.getInstance().getAccountPassword());
passwordField.setText(YouCredentialsManager.getInstance().getAccountPassword());
}
signInButton = new JButton(CodeGPTBundle.get("settingsConfigurable.section.userAuthentication.signIn.label"));
signUpTextPane = createSignUpTextPane();
@ -66,15 +66,16 @@ public class UserDetailsSettingsPanel extends JPanel {
if (emailValidator.getValidationInfo() == null && passwordValidator.getValidationInfo() == null) {
loadingSpinner.resume();
loadingSpinner.setVisible(true);
AuthenticationService.getInstance()
YouAuthenticationService.getInstance()
.signInAsync(emailField.getText(), new String(passwordField.getPassword()), new UserAuthenticationHandler());
}
});
if (UserManager.getInstance().getAuthenticationResponse() == null) {
if (YouUserManager.getInstance().getAuthenticationResponse() == null) {
add(createUserAuthenticationPanel(emailField, passwordField, null));
} else {
add(createUserInformationPanel(UserManager.getInstance().getAuthenticationResponse().getData().getUser()));
add(createUserInformationPanel(
YouUserManager.getInstance().getAuthenticationResponse().getData().getUser()));
}
}
@ -147,7 +148,7 @@ public class UserDetailsSettingsPanel extends JPanel {
return panel;
}
private JPanel createUserAuthenticationPanel(JBTextField emailAddressField, JBPasswordField passwordField, @Nullable AuthenticationError error) {
private JPanel createUserAuthenticationPanel(JBTextField emailAddressField, JBPasswordField passwordField, @Nullable YouAuthenticationError error) {
var contentPanelBuilder = FormBuilder.createFormBuilder()
.addLabeledComponent("Email address:", emailAddressField)
.addLabeledComponent("Password:", passwordField)
@ -171,8 +172,8 @@ public class UserDetailsSettingsPanel extends JPanel {
.getPanel();
}
private JPanel createUserInformationPanel(User user) {
var userManager = UserManager.getInstance();
private JPanel createUserInformationPanel(YouUser user) {
var userManager = YouUserManager.getInstance();
var contentPanelBuilder = FormBuilder.createFormBuilder()
.addLabeledComponent("Email address:", new JBLabel(user.getEmails().get(0).getEmail()).withFont(JBFont.label().asBold()));
@ -196,12 +197,12 @@ public class UserDetailsSettingsPanel extends JPanel {
class UserAuthenticationHandler implements AuthenticationHandler {
@Override
public void handleAuthenticated(AuthenticationResponse authenticationResponse) {
public void handleAuthenticated(YouAuthenticationResponse authenticationResponse) {
SwingUtilities.invokeLater(() -> {
var email = emailField.getText();
var password = passwordField.getPassword();
SettingsState.getInstance().setEmail(email);
UserCredentialsManager.getInstance().setAccountPassword(new String(password));
YouCredentialsManager.getInstance().setAccountPassword(new String(password));
refreshView(createUserInformationPanel(authenticationResponse.getData().getUser()));
});
}
@ -209,11 +210,11 @@ public class UserDetailsSettingsPanel extends JPanel {
@Override
public void handleGenericError() {
SwingUtilities.invokeLater(() -> refreshView(
createUserAuthenticationPanel(emailField, passwordField, new AuthenticationError("unknown", "Something went wrong."))));
createUserAuthenticationPanel(emailField, passwordField, new YouAuthenticationError("unknown", "Something went wrong."))));
}
@Override
public void handleError(AuthenticationError error) {
public void handleError(YouAuthenticationError error) {
SwingUtilities.invokeLater(() -> refreshView(createUserAuthenticationPanel(emailField, passwordField, error)));
}
}

View file

@ -13,7 +13,7 @@ import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.ui.JBUI;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.completions.CompletionRequestHandler;
import ee.carlrobert.codegpt.completions.SerpResult;
import ee.carlrobert.codegpt.completions.you.YouSerpResult;
import ee.carlrobert.codegpt.conversations.Conversation;
import ee.carlrobert.codegpt.conversations.ConversationService;
import ee.carlrobert.codegpt.conversations.message.Message;
@ -26,11 +26,12 @@ import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import ee.carlrobert.codegpt.toolwindow.ModelIconLabel;
import ee.carlrobert.codegpt.toolwindow.chat.components.ChatMessageResponseBody;
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
import ee.carlrobert.codegpt.toolwindow.chat.components.SmartScroller;
import ee.carlrobert.codegpt.toolwindow.chat.components.UserMessagePanel;
import ee.carlrobert.codegpt.toolwindow.chat.components.UserPromptTextArea;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.util.EditorUtils;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import ee.carlrobert.codegpt.util.OverlayUtils;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
@ -54,7 +55,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
private final JPanel rootPanel;
private final ScrollablePanel scrollablePanel;
private final Map<UUID, JPanel> visibleMessagePanels = new HashMap<>();
private final Map<UUID, List<SerpResult>> serpResultsMapping = new HashMap<>();
private final Map<UUID, List<YouSerpResult>> serpResultsMapping = new HashMap<>();
protected final Project project;
protected final UserPromptTextArea userPromptTextArea;
@ -132,7 +133,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
private boolean isCredentialSet() {
if (SettingsState.getInstance().isUseYouService()) {
return UserManager.getInstance().isAuthenticated();
return YouUserManager.getInstance().isAuthenticated();
}
if (SettingsState.getInstance().isUseAzureService()) {
return AzureCredentialsManager.getInstance().isCredentialSet();
@ -177,7 +178,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
if (containsResults) {
message.setSerpResults(serpResults.stream()
.map(result -> new SerpResult(
.map(result -> new YouSerpResult(
result.getUrl(),
result.getName(),
result.getSnippet(),
@ -213,7 +214,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
});
requestHandler.addSerpResultsListener(
serpResults -> serpResultsMapping.put(message.getId(), serpResults.stream()
.map(result -> new SerpResult(
.map(result -> new YouSerpResult(
result.getUrl(),
result.getName(),
result.getSnippet(),

View file

@ -20,14 +20,14 @@ import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.data.MutableDataSet;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.completions.SerpResult;
import ee.carlrobert.codegpt.completions.you.YouSerpResult;
import ee.carlrobert.codegpt.settings.SettingsConfigurable;
import ee.carlrobert.codegpt.settings.state.SettingsState;
import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import ee.carlrobert.codegpt.toolwindow.chat.editor.ChatToolWindowTabPanelEditor;
import ee.carlrobert.codegpt.toolwindow.chat.ResponseNodeRenderer;
import ee.carlrobert.codegpt.toolwindow.chat.StreamParser;
import ee.carlrobert.codegpt.toolwindow.chat.StreamResponseType;
import ee.carlrobert.codegpt.toolwindow.chat.editor.ResponseEditor;
import ee.carlrobert.codegpt.util.MarkdownUtils;
import ee.carlrobert.codegpt.util.SwingUtils;
import java.awt.BorderLayout;
@ -46,7 +46,7 @@ public class ChatMessageResponseBody extends JPanel {
private final Disposable parentDisposable;
private final StreamParser streamParser;
private JPanel currentlyProcessedElement;
private ChatToolWindowTabPanelEditor currentlyProcessedEditor;
private ResponseEditor currentlyProcessedEditor;
private JTextPane currentlyProcessedTextPane;
private boolean responseReceived;
@ -159,7 +159,7 @@ public class ChatMessageResponseBody extends JPanel {
displayError("Something went wrong.");
}
public void displaySerpResults(List<SerpResult> serpResults) {
public void displaySerpResults(List<YouSerpResult> serpResults) {
var titles = serpResults.stream()
.map(result -> format("<li style=\"margin-bottom: 4px;\"><a href=\"%s\">%s</a></li>",
result.getUrl(), result.getName()))
@ -235,14 +235,14 @@ public class ChatMessageResponseBody extends JPanel {
private void prepareProcessingCodeResponse(String code, String language) {
hideCarets();
currentlyProcessedTextPane = null;
currentlyProcessedEditor = new ChatToolWindowTabPanelEditor(
currentlyProcessedEditor = new ResponseEditor(
project,
code,
language,
parentDisposable);
currentlyProcessedElement = new ResponseWrapper();
currentlyProcessedElement.add(currentlyProcessedEditor.getComponent());
currentlyProcessedElement.add(currentlyProcessedEditor);
add(currentlyProcessedElement);
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.toolwindow;
package ee.carlrobert.codegpt.toolwindow.chat.components;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.ActionToolbar;

View file

@ -10,7 +10,6 @@ import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.JBFont;
import com.intellij.util.ui.JBUI;
import ee.carlrobert.codegpt.Icons;
import ee.carlrobert.codegpt.toolwindow.IconActionButton;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.Box;

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.toolwindow.chat;
package ee.carlrobert.codegpt.toolwindow.chat.components;
import java.awt.Component;
import java.awt.event.AdjustmentEvent;

View file

@ -14,9 +14,9 @@ import ee.carlrobert.codegpt.indexes.CodebaseIndexingTask;
import ee.carlrobert.codegpt.indexes.FolderStructureTreePanel;
import ee.carlrobert.codegpt.settings.SettingsConfigurable;
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.user.auth.SignedOutNotifier;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.completions.you.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.completions.you.auth.SignedOutNotifier;
import ee.carlrobert.codegpt.util.OverlayUtils;
import ee.carlrobert.codegpt.util.SwingUtils;
import ee.carlrobert.vector.VectorStore;
@ -51,7 +51,7 @@ class ContextualChatToolWindowLandingPanel extends ResponsePanel {
private JTextPane createContent() {
var description = createTextPane();
var userManager = UserManager.getInstance();
var userManager = YouUserManager.getInstance();
if (userManager.getAuthenticationResponse() == null) {
description.setText("<html>" +

View file

@ -7,7 +7,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.util.Disposer;
import ee.carlrobert.codegpt.actions.CodebaseIndexingAction;
import ee.carlrobert.codegpt.indexes.CodebaseIndexingAction;
import ee.carlrobert.codegpt.actions.toolwindow.ClearChatWindowAction;
import org.jetbrains.annotations.NotNull;

View file

@ -2,13 +2,13 @@ package ee.carlrobert.codegpt.toolwindow.chat.contextual;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import ee.carlrobert.codegpt.completions.you.YouUserManager;
import ee.carlrobert.codegpt.conversations.Conversation;
import ee.carlrobert.codegpt.conversations.message.Message;
import ee.carlrobert.codegpt.indexes.CodebaseIndexingCompletedNotifier;
import ee.carlrobert.codegpt.toolwindow.chat.BaseChatToolWindowTabPanel;
import ee.carlrobert.codegpt.user.UserManager;
import ee.carlrobert.codegpt.user.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.user.auth.SignedOutNotifier;
import ee.carlrobert.codegpt.completions.you.auth.AuthenticationNotifier;
import ee.carlrobert.codegpt.completions.you.auth.SignedOutNotifier;
import javax.swing.JComponent;
import org.jetbrains.annotations.NotNull;
@ -17,16 +17,18 @@ public class ContextualChatToolWindowTabPanel extends BaseChatToolWindowTabPanel
public ContextualChatToolWindowTabPanel(@NotNull Project project) {
super(project, true);
displayLandingView();
userPromptTextArea.setTextAreaEnabled(UserManager.getInstance().isSubscribed());
userPromptTextArea.setTextAreaEnabled(YouUserManager.getInstance().isSubscribed());
project.getMessageBus()
.connect()
.subscribe(CodebaseIndexingCompletedNotifier.INDEXING_COMPLETED_TOPIC,
(CodebaseIndexingCompletedNotifier) () -> userPromptTextArea.setTextAreaEnabled(UserManager.getInstance().isSubscribed()));
(CodebaseIndexingCompletedNotifier) () -> userPromptTextArea.setTextAreaEnabled(
YouUserManager.getInstance().isSubscribed()));
var messageBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
messageBusConnection.subscribe(AuthenticationNotifier.AUTHENTICATION_TOPIC,
(AuthenticationNotifier) () -> userPromptTextArea.setTextAreaEnabled(UserManager.getInstance().isSubscribed()));
(AuthenticationNotifier) () -> userPromptTextArea.setTextAreaEnabled(
YouUserManager.getInstance().isSubscribed()));
messageBusConnection.subscribe(SignedOutNotifier.SIGNED_OUT_TOPIC, (SignedOutNotifier) () -> userPromptTextArea.setTextAreaEnabled(false));
}

View file

@ -1,6 +1,6 @@
package ee.carlrobert.codegpt.toolwindow.chat.editor;
import static ee.carlrobert.codegpt.util.FileUtils.findFileNameExtensionMapping;
import static ee.carlrobert.codegpt.util.file.FileUtils.findFileNameExtensionMapping;
import static java.lang.String.format;
import com.intellij.openapi.Disposable;
@ -23,7 +23,7 @@ import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.JBUI;
import ee.carlrobert.codegpt.actions.toolwindow.ReplaceCodeInMainEditorAction;
import ee.carlrobert.codegpt.toolwindow.IconActionButton;
import ee.carlrobert.codegpt.toolwindow.chat.components.IconActionButton;
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.CopyAction;
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.DiffAction;
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.EditAction;
@ -35,20 +35,21 @@ import java.awt.FlowLayout;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.swing.Box;
import javax.swing.JComponent;
import javax.swing.JPanel;
public class ChatToolWindowTabPanelEditor implements Disposable {
public class ResponseEditor extends JPanel implements Disposable {
private final Editor editor;
private final String fileName;
private final String fileExtension;
public ChatToolWindowTabPanelEditor(
public ResponseEditor(
Project project,
String code,
String language,
Disposable disposableParent) {
super(new BorderLayout());
var fileNameExtensionMapping = findFileNameExtensionMapping(language);
this.fileName = fileNameExtensionMapping.getKey();
this.fileExtension = fileNameExtensionMapping.getValue();
@ -91,6 +92,9 @@ public class ChatToolWindowTabPanelEditor implements Disposable {
settings.setVirtualSpace(false);
settings.setUseSoftWraps(false);
add(createHeaderComponent(), BorderLayout.NORTH);
add(editor.getComponent(), BorderLayout.SOUTH);
Disposer.register(disposableParent, this);
}
@ -99,13 +103,6 @@ public class ChatToolWindowTabPanelEditor implements Disposable {
EditorFactory.getInstance().releaseEditor(editor);
}
public JComponent getComponent() {
var wrapper = new JPanel(new BorderLayout());
wrapper.add(createHeaderComponent(), BorderLayout.NORTH);
wrapper.add(editor.getComponent(), BorderLayout.SOUTH);
return wrapper;
}
public Editor getEditor() {
return editor;
}

View file

@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.TrackableAction;
import ee.carlrobert.codegpt.util.OverlayUtils;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;

View file

@ -16,8 +16,9 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.util.Pair;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.TrackableAction;
import ee.carlrobert.codegpt.util.EditorUtils;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;

View file

@ -6,6 +6,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.EditorEx;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.TrackableAction;
import java.awt.event.MouseEvent;
import org.jetbrains.annotations.NotNull;

View file

@ -8,7 +8,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.TextBrowseFolderListener;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
@ -18,8 +17,8 @@ import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.FormBuilder;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.util.ApplicationUtils;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.actions.TrackableAction;
import ee.carlrobert.codegpt.util.file.FileUtils;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;

View file

@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.TrackableAction;
import ee.carlrobert.codegpt.util.EditorUtils;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;

View file

@ -12,7 +12,7 @@ import ee.carlrobert.codegpt.toolwindow.chat.components.ChatMessageResponseBody;
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
import ee.carlrobert.codegpt.toolwindow.chat.components.UserMessagePanel;
import ee.carlrobert.codegpt.util.EditorUtils;
import ee.carlrobert.codegpt.util.FileUtils;
import ee.carlrobert.codegpt.util.file.FileUtils;
import ee.carlrobert.codegpt.util.OverlayUtils;
import javax.swing.JComponent;
import org.jetbrains.annotations.NotNull;

View file

@ -11,8 +11,8 @@ import ee.carlrobert.codegpt.actions.toolwindow.DeleteConversationAction;
import ee.carlrobert.codegpt.conversations.Conversation;
import ee.carlrobert.codegpt.conversations.ConversationsState;
import ee.carlrobert.codegpt.settings.state.SettingsState;
import ee.carlrobert.codegpt.toolwindow.IconActionButton;
import ee.carlrobert.codegpt.toolwindow.ModelIconLabel;
import ee.carlrobert.codegpt.toolwindow.chat.components.IconActionButton;
import ee.carlrobert.codegpt.toolwindow.chat.standard.StandardChatToolWindowContentManager;
import java.awt.BorderLayout;
import java.awt.Cursor;

View file

@ -70,7 +70,10 @@ public class ConversationsToolWindow extends JPanel {
} else {
sortedConversations.forEach(conversation -> {
scrollablePanel.add(Box.createVerticalStrut(8));
scrollablePanel.add(new ConversationPanel(project, conversation, this::refresh));
scrollablePanel.add(new ConversationPanel(project, conversation, () -> {
ConversationService.getInstance().deleteConversation(conversation);
refresh();
}));
});
}

View file

@ -1,43 +0,0 @@
package ee.carlrobert.codegpt.user;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import ee.carlrobert.codegpt.user.auth.SignedOutNotifier;
import ee.carlrobert.codegpt.user.auth.response.AuthenticationResponse;
@Service
public final class UserManager {
private AuthenticationResponse authenticationResponse;
private UserManager() {
}
public static UserManager getInstance() {
return ApplicationManager.getApplication().getService(UserManager.class);
}
public AuthenticationResponse getAuthenticationResponse() {
return authenticationResponse;
}
public void setAuthenticationResponse(AuthenticationResponse authenticationResponse) {
this.authenticationResponse = authenticationResponse;
}
public void clearSession() {
authenticationResponse = null;
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(SignedOutNotifier.SIGNED_OUT_TOPIC)
.signedOut();
}
public boolean isSubscribed() {
return true; // TODO
}
public boolean isAuthenticated() {
return authenticationResponse != null;
}
}

View file

@ -1,12 +0,0 @@
package ee.carlrobert.codegpt.user.auth;
import ee.carlrobert.codegpt.user.auth.response.AuthenticationResponse;
public interface AuthenticationHandler {
void handleAuthenticated(AuthenticationResponse authenticationResponse);
void handleGenericError();
void handleError(AuthenticationError authenticationError);
}

View file

@ -1,18 +0,0 @@
package ee.carlrobert.codegpt.user.auth.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationResponse {
private final AuthenticationResponseData data;
public AuthenticationResponse(@JsonProperty("data") AuthenticationResponseData data) {
this.data = data;
}
public AuthenticationResponseData getData() {
return data;
}
}

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.util;
package ee.carlrobert.codegpt.util.file;
public class FileExtensionLanguageDetails {

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.util;
package ee.carlrobert.codegpt.util.file;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;

View file

@ -1,4 +1,4 @@
package ee.carlrobert.codegpt.util;
package ee.carlrobert.codegpt.util.file;
import java.util.List;