CON-1067 communicate progress to frontend
This commit is contained in:
parent
9f37792c8f
commit
79c12ff4b2
3 changed files with 23 additions and 7 deletions
|
|
@ -120,11 +120,22 @@ export class VsCodeExtension {
|
|||
context.globalState.update("continue.indexingFailed", msg.data)
|
||||
});
|
||||
this.webviewProtocol.on("index/indexingProgressBarInitialized", (msg) => {
|
||||
// Triggered when progress bar is initialized.
|
||||
// Purpose: To relay global state values to the progress bar
|
||||
|
||||
// Update indexingFailed
|
||||
if (context.globalState.get("continue.indexingFailed")){
|
||||
this.webviewProtocol?.request("setIndexingFailed", {failed: true});
|
||||
} else {
|
||||
this.webviewProtocol?.request("setIndexingFailed", {failed: false});
|
||||
}
|
||||
|
||||
// Update indexingProgress
|
||||
if (context.globalState.get("continue.indexingProgress")){
|
||||
let progress = context.globalState.get<number>("continue.indexingProgress") as number
|
||||
let desc = context.globalState.get<string>("continue.indexingDesc") as string
|
||||
this.webviewProtocol?.request("indexProgress", {progress, desc})
|
||||
}
|
||||
});
|
||||
|
||||
this.diffManager.webviewProtocol = this.webviewProtocol;
|
||||
|
|
@ -280,8 +291,11 @@ export class VsCodeExtension {
|
|||
private indexingCancellationController: AbortController | undefined;
|
||||
|
||||
private async refreshCodebaseIndex(dirs: string[], context: vscode.ExtensionContext) {
|
||||
//reset all state variables
|
||||
this.webviewProtocol?.request("setIndexingFailed", {failed:false});
|
||||
context.globalState.update("continue.indexingFailed", false)
|
||||
context.globalState.update("continue.indexingProgress", 0)
|
||||
context.globalState.update("continue.indexingDesc", "")
|
||||
|
||||
if (this.indexingCancellationController) {
|
||||
this.indexingCancellationController.abort();
|
||||
|
|
@ -295,12 +309,14 @@ export class VsCodeExtension {
|
|||
if (update.indexingFailed) {
|
||||
err = update.desc
|
||||
|
||||
// Signal to front-end
|
||||
// Signal failure to front-end
|
||||
this.webviewProtocol?.request("setIndexingFailed", {failed: true});
|
||||
context.globalState.update("continue.indexingFailed", true)
|
||||
|
||||
break
|
||||
} else {
|
||||
// Save progress
|
||||
context.globalState.update("continue.indexingProgress", update.progress)
|
||||
context.globalState.update("continue.indexingDesc", update.desc)
|
||||
this.webviewProtocol.request("indexProgress", update);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import TextDialog from "./dialogs";
|
|||
import IndexingProgressBar from "./loaders/IndexingProgressBar";
|
||||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import ModelSelect from "./modelSelection/ModelSelect";
|
||||
import * as vscode from "../../../extensions/vscode";
|
||||
|
||||
|
||||
// #region Styled Components
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
|
|
|||
|
|
@ -79,7 +79,9 @@ const IndexingProgressBar = ({
|
|||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
if (completed < total) {
|
||||
console.log("progress bar clicked")
|
||||
console.log(completed, " | ", total)
|
||||
if (completed < total && completed >= 0) {
|
||||
setExpanded((prev) => !prev);
|
||||
} else {
|
||||
postToIde("index/forceReIndex", undefined);
|
||||
|
|
@ -88,7 +90,7 @@ const IndexingProgressBar = ({
|
|||
className="cursor-pointer"
|
||||
>
|
||||
{
|
||||
completed < 0 ? ( //
|
||||
(completed < 0 && !indexingFailed) ? ( // ice-blue 'indexing starting up' dot
|
||||
<>
|
||||
<CircleDiv data-tooltip-id="indexingNotLoaded_dot" color="#72aec2"></CircleDiv>
|
||||
{tooltipPortalDiv &&
|
||||
|
|
@ -110,7 +112,7 @@ const IndexingProgressBar = ({
|
|||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
) : completed >= total ? ( //indexing complete green dot
|
||||
) : completed >= total ? ( //indexing complete green dot
|
||||
<>
|
||||
<CircleDiv data-tooltip-id="progress_dot" color="#090"></CircleDiv>
|
||||
{tooltipPortalDiv &&
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue