mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-12 22:31:24 +00:00
feat: add proper streaming implementation
This commit is contained in:
parent
2ce05a50af
commit
cb0146034c
19 changed files with 593 additions and 251 deletions
|
|
@ -20,4 +20,8 @@ public class CodeGPTKeys {
|
|||
Key.create("codegpt.addedDocumentation");
|
||||
public static final Key<PersonaDetails> ADDED_PERSONA =
|
||||
Key.create("codegpt.addedPersona");
|
||||
public static final Key<String> REMAINING_EDITOR_COMPLETION =
|
||||
Key.create("codegpt.editorCompletionLines");
|
||||
public static final Key<Boolean> IS_FETCHING_COMPLETION =
|
||||
Key.create("codegpt.isFetchingCompletion");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ee.carlrobert.codegpt;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.AnimatedIcon;
|
||||
import javax.swing.Icon;
|
||||
|
||||
public final class Icons {
|
||||
|
|
@ -27,4 +28,5 @@ public final class Icons {
|
|||
public static final Icon Upload = IconLoader.getIcon("/icons/upload.svg", Icons.class);
|
||||
public static final Icon GreenCheckmark =
|
||||
IconLoader.getIcon("/icons/greenCheckmark.svg", Icons.class);
|
||||
public static final Icon StatusBarCompletionInProgress = new AnimatedIcon.Default();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package ee.carlrobert.codegpt.statusbar;
|
||||
|
||||
import static ee.carlrobert.codegpt.CodeGPTKeys.IS_FETCHING_COMPLETION;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
|
|
@ -8,24 +10,43 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
|
|||
import com.intellij.openapi.ui.popup.JBPopupFactory.ActionSelectionAid;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.impl.status.EditorBasedStatusBarPopup;
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.Icons;
|
||||
import ee.carlrobert.codegpt.codecompletions.CodeCompletionProgressNotifier;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CodeGPTStatusBarWidget extends EditorBasedStatusBarPopup {
|
||||
|
||||
private static final String ID = "ee.carlrobert.codegpt.statusbar.widget";
|
||||
|
||||
public CodeGPTStatusBarWidget(Project project) {
|
||||
super(project, false);
|
||||
|
||||
project.getMessageBus()
|
||||
.connect(this)
|
||||
.subscribe(
|
||||
CodeCompletionProgressNotifier.Companion.getCODE_COMPLETION_PROGRESS_TOPIC(),
|
||||
(CodeCompletionProgressNotifier) loading -> {
|
||||
CodeGPTStatusBarWidget widget = findWidget(project);
|
||||
if (widget != null && widget.myStatusBar != null) {
|
||||
widget.update(() -> widget.myStatusBar.updateWidget(ID));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull WidgetState getWidgetState(@Nullable VirtualFile file) {
|
||||
var state = new WidgetState(CodeGPTBundle.get("statusBar.widget.tooltip"), "", true);
|
||||
state.setIcon(Icons.DefaultSmall);
|
||||
var fetchingCompletion = IS_FETCHING_COMPLETION.get(getEditor());
|
||||
var loading = fetchingCompletion != null && fetchingCompletion;
|
||||
|
||||
state.setIcon(loading ? Icons.StatusBarCompletionInProgress : Icons.DefaultSmall);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +68,18 @@ public class CodeGPTStatusBarWidget extends EditorBasedStatusBarPopup {
|
|||
|
||||
@Override
|
||||
public @NonNls @NotNull String ID() {
|
||||
return "ee.carlrobert.codegpt.statusbar.widget";
|
||||
return ID;
|
||||
}
|
||||
|
||||
private static @Nullable CodeGPTStatusBarWidget findWidget(@NotNull Project project) {
|
||||
StatusBar bar = WindowManager.getInstance().getStatusBar(project);
|
||||
if (bar != null) {
|
||||
StatusBarWidget widget = bar.getWidget(ID);
|
||||
if (widget instanceof CodeGPTStatusBarWidget) {
|
||||
return (CodeGPTStatusBarWidget) widget;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat;
|
||||
|
||||
public enum ChatToolWindowType {
|
||||
CODEGPT_CHAT("CodeGPT Chat"),
|
||||
CODEGPT_CHAT_WITHOUT_PERSONA("CodeGPT Chat without Persona"),
|
||||
CODEGPT_CHAT_WITH_PERSONA("CodeGPT Chat with Persona");
|
||||
|
||||
private final String name;
|
||||
|
||||
ChatToolWindowType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue