🐛 fix indexing status display
This commit is contained in:
parent
3b45028f54
commit
be741acf9f
5 changed files with 81 additions and 36 deletions
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -37,7 +37,7 @@ export interface Chunk extends ChunkWithoutID {
|
|||
export interface IndexingProgressUpdate {
|
||||
progress: number;
|
||||
desc: string;
|
||||
status: "starting" | "indexing" | "done" | "failed" | "paused";
|
||||
status: "starting" | "indexing" | "done" | "failed" | "paused" | "disabled";
|
||||
}
|
||||
|
||||
export type PromptTemplate =
|
||||
|
|
|
|||
|
|
@ -53,12 +53,28 @@ export class CodebaseIndexer {
|
|||
abortSignal: AbortSignal,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
if (workspaceDirs.length === 0) {
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: "Nothing to index",
|
||||
status: "disabled",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await this.configHandler.loadConfig();
|
||||
if (config.disableIndexing) {
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: "Indexing is disabled in the config.json",
|
||||
status: "disabled",
|
||||
};
|
||||
return;
|
||||
} else {
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: "Starting indexing",
|
||||
status: "starting",
|
||||
};
|
||||
}
|
||||
|
||||
const indexesToBuild = await this.getIndexesToBuild();
|
||||
|
|
@ -107,12 +123,20 @@ export class CodebaseIndexer {
|
|||
yield {
|
||||
progress: 1,
|
||||
desc: "Indexing cancelled",
|
||||
status: "failed",
|
||||
status: "disabled",
|
||||
};
|
||||
return;
|
||||
}
|
||||
while (this.pauseToken.paused) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
|
||||
if (this.pauseToken.paused) {
|
||||
yield {
|
||||
progress: completedDirs / workspaceDirs.length,
|
||||
desc: "Paused",
|
||||
status: "paused",
|
||||
};
|
||||
while (this.pauseToken.paused) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
}
|
||||
|
||||
yield {
|
||||
|
|
|
|||
|
|
@ -279,21 +279,17 @@ export class VsCodeExtension {
|
|||
dirs: string[],
|
||||
context: vscode.ExtensionContext,
|
||||
) {
|
||||
//reset all state variables
|
||||
console.log("Codebase indexing starting up");
|
||||
this.webviewProtocol?.request("indexProgress", {
|
||||
progress: 0,
|
||||
desc: "",
|
||||
status: "failed",
|
||||
});
|
||||
context.globalState.update("continue.indexingFailed", false);
|
||||
context.globalState.update("continue.indexingProgress", 0);
|
||||
context.globalState.update("continue.indexingDesc", "");
|
||||
|
||||
// Cancel previous indexing job if it exists
|
||||
if (this.indexingCancellationController) {
|
||||
this.indexingCancellationController.abort();
|
||||
}
|
||||
this.indexingCancellationController = new AbortController();
|
||||
|
||||
//reset all state variables
|
||||
context.globalState.update("continue.indexingFailed", false);
|
||||
context.globalState.update("continue.indexingProgress", 0);
|
||||
context.globalState.update("continue.indexingDesc", "");
|
||||
|
||||
let err = undefined;
|
||||
for await (const update of this.indexer.refresh(
|
||||
dirs,
|
||||
|
|
|
|||
|
|
@ -186,9 +186,9 @@ const Layout = () => {
|
|||
}, [location]);
|
||||
|
||||
const [indexingState, setIndexingState] = useState<IndexingProgressUpdate>({
|
||||
desc: "Starting indexing",
|
||||
desc: "Indexing disabled",
|
||||
progress: 0.0,
|
||||
status: "starting",
|
||||
status: "disabled",
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -62,12 +62,13 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
const [expanded, setExpanded] = useState(true);
|
||||
const [paused, setPaused] = useState<boolean | undefined>(undefined);
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
postToIde("index/setPaused", !expanded);
|
||||
}, [expanded]);
|
||||
if (paused === undefined) return;
|
||||
postToIde("index/setPaused", paused);
|
||||
}, [paused]);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -77,7 +78,7 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
indexingState.progress < 1 &&
|
||||
indexingState.progress >= 0
|
||||
) {
|
||||
setExpanded((prev) => !prev);
|
||||
setPaused((prev) => !prev);
|
||||
} else {
|
||||
postToIde("index/forceReIndex", undefined);
|
||||
}
|
||||
|
|
@ -125,12 +126,49 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
) : expanded ? ( //progress bar
|
||||
) : indexingState.status === "disabled" ? ( //gray disabled dot
|
||||
<>
|
||||
<CircleDiv
|
||||
data-tooltip-id="progress_dot"
|
||||
color={lightGray}
|
||||
></CircleDiv>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id="progress_dot" place="top">
|
||||
{indexingState.desc}
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
) : indexingState.status === "paused" ||
|
||||
(paused && indexingState.status === "indexing") ? (
|
||||
//yellow 'paused' dot
|
||||
<>
|
||||
<CircleDiv
|
||||
data-tooltip-id="progress_dot"
|
||||
color="#bb0"
|
||||
onClick={(e) => {
|
||||
postToIde("index/setPaused", false);
|
||||
}}
|
||||
></CircleDiv>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id="progress_dot" place="top">
|
||||
Click to unpause indexing (
|
||||
{Math.trunc(indexingState.progress * 100)}%)
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
) : indexingState.status === "indexing" ? ( //progress bar
|
||||
<>
|
||||
<GridDiv
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
onClick={(e) => {
|
||||
postToIde("index/setPaused", true);
|
||||
}}
|
||||
>
|
||||
<ProgressBarWrapper>
|
||||
<ProgressBarFill completed={fillPercentage} />
|
||||
|
|
@ -149,20 +187,7 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
//yellow 'paused' dot
|
||||
<>
|
||||
<CircleDiv data-tooltip-id="progress_dot" color="#bb0"></CircleDiv>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id="progress_dot" place="top">
|
||||
Click to unpause indexing (
|
||||
{Math.trunc(indexingState.progress * 100)}%)
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue