revert to old indexing progress folder structure
This commit is contained in:
parent
dfe11d357a
commit
23bde03054
10 changed files with 38 additions and 155 deletions
|
|
@ -1,20 +1,26 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../../util";
|
||||
import { useWebviewListener } from "../../../../hooks/useWebviewListener";
|
||||
import IndexingProgressBar from "../IndexingProgressBar";
|
||||
import IndexingProgressIndicator from "../IndexingProgressIndicator";
|
||||
import IndexingProgressSubtext from "../IndexingProgressSubtext";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { useWebviewListener } from "../../../hooks/useWebviewListener";
|
||||
import IndexingProgressBar from "./IndexingProgressBar";
|
||||
import IndexingProgressIndicator from "./IndexingProgressIndicator";
|
||||
import IndexingProgressTitleText from "./IndexingProgressTitleText";
|
||||
import IndexingProgressSubtext from "./IndexingProgressSubtext";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog";
|
||||
import ConfirmationDialog from "../../../components/dialogs/ConfirmationDialog";
|
||||
import {
|
||||
setShowDialog,
|
||||
setDialogMessage,
|
||||
} from "../../../../redux/slices/uiStateSlice";
|
||||
} from "../../../redux/slices/uiStateSlice";
|
||||
import IndexingProgressErrorText from "./IndexingProgressErrorText";
|
||||
import IndexingProgressTitleText from "../IndexingProgressTitleText";
|
||||
|
||||
export function getProgressPercentage(
|
||||
progress: IndexingProgressUpdate["progress"],
|
||||
) {
|
||||
return Math.min(100, Math.max(0, progress * 100));
|
||||
}
|
||||
|
||||
function IndexingProgress() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
|
@ -27,13 +33,19 @@ function IndexingProgress() {
|
|||
status: "loading",
|
||||
});
|
||||
|
||||
// If sidebar is opened after extension initializes, retrieve saved states.
|
||||
let initialized = false;
|
||||
|
||||
useWebviewListener("indexProgress", async (data) => {
|
||||
setUpdate(data);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
// Triggers retrieval for possible non-default states set prior to IndexingProgressBar initialization
|
||||
ideMessenger.post("index/indexingProgressBarInitialized", undefined);
|
||||
if (!initialized) {
|
||||
// Triggers retrieval for possible non-default states set prior to IndexingProgressBar initialization
|
||||
ideMessenger.post("index/indexingProgressBarInitialized", undefined);
|
||||
initialized = true;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import { getProgressPercentage } from ".";
|
||||
import { getProgressPercentage } from "./IndexingProgress";
|
||||
|
||||
export interface IndexingProgressBarProps {
|
||||
update: IndexingProgressUpdate;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../../../../redux/store";
|
||||
import { isJetBrains } from "../../../../util";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { XCircleIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
export interface IndexingProgressErrorTextProps {
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import { getProgressPercentage } from "./IndexingProgress";
|
||||
import {
|
||||
ArrowPathIcon,
|
||||
PauseCircleIcon,
|
||||
CheckCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { getProgressPercentage } from ".";
|
||||
|
||||
export interface IndexingProgressIndicatorProps {
|
||||
update: IndexingProgressUpdate;
|
||||
|
|
@ -1,11 +1,19 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import { AnimatedEllipsis } from "../../../components";
|
||||
import { STATUS_TO_TEXT } from ".";
|
||||
|
||||
export interface IndexingProgressTitleTextProps {
|
||||
update: IndexingProgressUpdate;
|
||||
}
|
||||
|
||||
const STATUS_TO_TEXT: Record<IndexingProgressUpdate["status"], string> = {
|
||||
done: "Indexing complete",
|
||||
loading: "Initializing",
|
||||
indexing: "Indexing in-progress",
|
||||
paused: "Indexing paused",
|
||||
failed: "Indexing failed",
|
||||
disabled: "Indexing disabled",
|
||||
};
|
||||
|
||||
function IndexingProgressTitleText({ update }: IndexingProgressTitleTextProps) {
|
||||
const showEllipsis = update.status === "loading";
|
||||
|
||||
1
gui/src/pages/More/IndexingProgress/index.ts
Normal file
1
gui/src/pages/More/IndexingProgress/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default } from "./IndexingProgress";
|
||||
|
|
@ -14,7 +14,7 @@ import { useDispatch } from "react-redux";
|
|||
import { setOnboardingCard } from "../../redux/slices/uiStateSlice";
|
||||
import useHistory from "../../hooks/useHistory";
|
||||
import MoreHelpRow from "./MoreHelpRow";
|
||||
import IndexingProgress from "./progress/codebase";
|
||||
import IndexingProgress from "./IndexingProgress";
|
||||
|
||||
function MorePage() {
|
||||
useNavigationListener();
|
||||
|
|
|
|||
|
|
@ -1,121 +0,0 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../../util";
|
||||
import { useWebviewListener } from "../../../../hooks/useWebviewListener";
|
||||
import IndexingProgressBar from "../IndexingProgressBar";
|
||||
import IndexingProgressIndicator from "../IndexingProgressIndicator";
|
||||
import IndexingProgressSubtext from "../IndexingProgressSubtext";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog";
|
||||
import {
|
||||
setShowDialog,
|
||||
setDialogMessage,
|
||||
} from "../../../../redux/slices/uiStateSlice";
|
||||
import IndexingProgressTitleText from "../IndexingProgressTitleText";
|
||||
import IndexingProgressErrorText from "../codebase/IndexingProgressErrorText";
|
||||
|
||||
function DocsIndexingProgressItem() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const posthog = usePostHog();
|
||||
const dispatch = useDispatch();
|
||||
const [paused, setPaused] = useState<boolean | undefined>(undefined);
|
||||
const [update, setUpdate] = useState<IndexingProgressUpdate>({
|
||||
desc: "Loading indexing config",
|
||||
progress: 0.0,
|
||||
status: "loading",
|
||||
});
|
||||
|
||||
useWebviewListener("indexProgress", async (data) => {
|
||||
setUpdate(data);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
// Triggers retrieval for possible non-default states set prior to IndexingProgressBar initialization
|
||||
ideMessenger.post("index/indexingProgressBarInitialized", undefined);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (paused === undefined) return;
|
||||
ideMessenger.post("index/setPaused", paused);
|
||||
}, [paused]);
|
||||
|
||||
function onClickRetry() {
|
||||
// For now, we don't show in JetBrains since the re-index command
|
||||
// is not yet implemented
|
||||
if (update.shouldClearIndexes && !isJetBrains()) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
title="Rebuild codebase index"
|
||||
confirmText="Rebuild"
|
||||
text={
|
||||
"Your index appears corrupted. We recommend clearing and rebuilding it, " +
|
||||
"which may take time for large codebases.\n\n" +
|
||||
"For a faster rebuild without clearing data, press 'Shift + Command + P' to open " +
|
||||
"the Command Palette, and type out 'Continue: Force Codebase Re-Indexing'"
|
||||
}
|
||||
onConfirm={() => {
|
||||
posthog.capture("rebuild_index_clicked");
|
||||
ideMessenger.post("index/forceReIndex", {
|
||||
shouldClearIndexes: true,
|
||||
});
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ideMessenger.post("index/forceReIndex", undefined);
|
||||
}
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
switch (update.status) {
|
||||
case "failed":
|
||||
onClickRetry();
|
||||
break;
|
||||
case "indexing":
|
||||
case "loading":
|
||||
case "paused":
|
||||
if (update.progress < 1 && update.progress >= 0) {
|
||||
setPaused((prev) => !prev);
|
||||
} else {
|
||||
ideMessenger.post("index/forceReIndex", undefined);
|
||||
}
|
||||
break;
|
||||
case "disabled":
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
break;
|
||||
case "done":
|
||||
ideMessenger.post("index/forceReIndex", undefined);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-6 flex flex-col">
|
||||
<div className="mb-0 flex justify-between text-sm">
|
||||
<IndexingProgressTitleText update={update} />
|
||||
{update.status !== "loading" && (
|
||||
<IndexingProgressIndicator update={update} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<IndexingProgressBar update={update} />
|
||||
|
||||
<IndexingProgressSubtext update={update} onClick={onClick} />
|
||||
|
||||
{update.status === "failed" && (
|
||||
<div className="mt-4">
|
||||
<IndexingProgressErrorText update={update} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AllDocsIndexingProgress() {}
|
||||
export default AllDocsIndexingProgress;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import { IndexingProgressUpdate } from "core";
|
||||
|
||||
export function getProgressPercentage(
|
||||
progress: IndexingProgressUpdate["progress"],
|
||||
) {
|
||||
return Math.min(100, Math.max(0, progress * 100));
|
||||
}
|
||||
|
||||
export const STATUS_TO_TEXT: Record<IndexingProgressUpdate["status"], string> =
|
||||
{
|
||||
done: "Indexing complete",
|
||||
loading: "Initializing",
|
||||
indexing: "Indexing in-progress",
|
||||
paused: "Indexing paused",
|
||||
failed: "Indexing failed",
|
||||
disabled: "Indexing disabled",
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue