mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-16 19:44:36 +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
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue