docs - use config.docs instead of inferring from statuses
This commit is contained in:
parent
f4e9da5828
commit
263c839153
16 changed files with 179 additions and 168 deletions
|
|
@ -731,9 +731,6 @@ export class Core {
|
|||
this.docsService.setPaused(msg.data.id, msg.data.paused);
|
||||
}
|
||||
});
|
||||
on("indexing/initStatuses", async (msg) => {
|
||||
return this.docsService.initStatuses();
|
||||
});
|
||||
on("docs/getSuggestedDocs", async (msg) => {
|
||||
if (hasRequestedDocs) {
|
||||
return;
|
||||
|
|
@ -742,6 +739,9 @@ export class Core {
|
|||
const suggestedDocs = await getAllSuggestedDocs(this.ide);
|
||||
this.messenger.send("docs/suggestions", suggestedDocs);
|
||||
});
|
||||
on("docs/initStatuses", async (msg) => {
|
||||
void this.docsService.initStatuses();
|
||||
});
|
||||
//
|
||||
|
||||
on("didChangeSelectedProfile", (msg) => {
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -68,8 +68,6 @@ export interface IndexingStatus {
|
|||
url?: string;
|
||||
}
|
||||
|
||||
export type IndexingStatusMap = Map<string, IndexingStatus>;
|
||||
|
||||
export type PromptTemplateFunction = (
|
||||
history: ChatMessage[],
|
||||
otherData: Record<string, string>,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import {
|
|||
ContinueConfig,
|
||||
EmbeddingsProvider,
|
||||
IDE,
|
||||
IndexingStatusMap,
|
||||
IndexingStatus,
|
||||
SiteIndexingConfig,
|
||||
IdeInfo,
|
||||
|
|
@ -86,7 +85,6 @@ export type AddParams = {
|
|||
export default class DocsService {
|
||||
static lanceTableName = "docs";
|
||||
static sqlitebTableName = "docs";
|
||||
static indexingType = "docs";
|
||||
|
||||
static preIndexedDocsEmbeddingsProvider =
|
||||
new TransformersJsEmbeddingsProvider();
|
||||
|
|
@ -136,38 +134,55 @@ export default class DocsService {
|
|||
configHandler.onConfigUpdate(this.handleConfigUpdate.bind(this));
|
||||
}
|
||||
|
||||
readonly statuses: IndexingStatusMap = new Map();
|
||||
|
||||
// Function for GUI to retrieve initial pending statuses
|
||||
// And kickoff indexing where needed
|
||||
async initStatuses() {
|
||||
this.config?.docs?.forEach(async (doc) => {
|
||||
const currentStatus = this.statuses.get(doc.startUrl);
|
||||
if (currentStatus) {
|
||||
this.handleStatusUpdate(currentStatus);
|
||||
} else {
|
||||
this.handleStatusUpdate({
|
||||
type: "docs",
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId: this.config.embeddingsProvider.id,
|
||||
isReindexing: false,
|
||||
progress: 0,
|
||||
description: "Pending",
|
||||
status: "pending",
|
||||
title: doc.title,
|
||||
debugInfo: `max depth: ${doc.maxDepth}`,
|
||||
icon: doc.faviconUrl,
|
||||
url: doc.startUrl,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
readonly statuses: Map<string, IndexingStatus> = new Map();
|
||||
|
||||
handleStatusUpdate(update: IndexingStatus) {
|
||||
this.statuses.set(update.id, update);
|
||||
this.messenger?.send("indexing/statusUpdate", update);
|
||||
}
|
||||
|
||||
// A way for gui to retrieve initial statuses
|
||||
async initStatuses(): Promise<void> {
|
||||
if (!this.config?.docs) {
|
||||
return;
|
||||
}
|
||||
const metadata = await this.listMetadata();
|
||||
|
||||
this.config.docs?.forEach((doc) => {
|
||||
if (!doc.startUrl) {
|
||||
console.error("Invalid config docs entry", doc);
|
||||
return;
|
||||
}
|
||||
|
||||
const sharedStatus = {
|
||||
type: "docs" as IndexingStatus["type"],
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId: this.config.embeddingsProvider.id,
|
||||
isReindexing: false,
|
||||
title: doc.title,
|
||||
debugInfo: `max depth: ${doc.maxDepth}`,
|
||||
icon: doc.faviconUrl,
|
||||
url: doc.startUrl,
|
||||
};
|
||||
const indexedStatus: IndexingStatus = metadata.find(
|
||||
(meta) => meta.startUrl === doc.startUrl,
|
||||
)
|
||||
? {
|
||||
...sharedStatus,
|
||||
progress: 0,
|
||||
description: "Pending",
|
||||
status: "pending",
|
||||
}
|
||||
: {
|
||||
...sharedStatus,
|
||||
progress: 1,
|
||||
description: "Complete",
|
||||
status: "complete",
|
||||
};
|
||||
this.handleStatusUpdate(indexedStatus);
|
||||
});
|
||||
}
|
||||
|
||||
abort(startUrl: string) {
|
||||
const status = this.statuses.get(startUrl);
|
||||
if (status) {
|
||||
|
|
@ -362,6 +377,7 @@ export default class DocsService {
|
|||
|
||||
const indexExists = await this.hasMetadata(startUrl);
|
||||
|
||||
// Build status update - most of it is fixed values
|
||||
const fixedStatus: Pick<
|
||||
IndexingStatus,
|
||||
| "type"
|
||||
|
|
@ -383,6 +399,8 @@ export default class DocsService {
|
|||
url: siteIndexingConfig.startUrl,
|
||||
};
|
||||
|
||||
// Clear current indexes if reIndexing
|
||||
//
|
||||
if (indexExists) {
|
||||
if (reIndex) {
|
||||
await this.deleteIndexes(startUrl);
|
||||
|
|
@ -398,6 +416,12 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
|
||||
// If not preindexed
|
||||
const isPreIndexedDoc = !!preIndexedDocs[siteIndexingConfig.startUrl];
|
||||
if (!isPreIndexedDoc) {
|
||||
this.addToConfig(siteIndexingConfig);
|
||||
}
|
||||
|
||||
try {
|
||||
this.handleStatusUpdate({
|
||||
...fixedStatus,
|
||||
|
|
@ -435,7 +459,7 @@ export default class DocsService {
|
|||
articles.push(article);
|
||||
|
||||
processedPages++;
|
||||
await new Promise((resolve) => setTimeout(resolve, 50)); // Locks down GUI if no sleeping
|
||||
await new Promise((resolve) => setTimeout(resolve, 100)); // Locks down GUI if no sleeping
|
||||
}
|
||||
|
||||
void Telemetry.capture("docs_pages_crawled", {
|
||||
|
|
@ -788,19 +812,13 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
|
||||
// Sends "Pending" or current status for each
|
||||
await this.initStatuses();
|
||||
|
||||
for (const doc of changedDocs) {
|
||||
console.log(`Updating indexed doc: ${doc.startUrl}`);
|
||||
await this.indexAndAdd(doc, true);
|
||||
}
|
||||
await Promise.allSettled([
|
||||
...changedDocs.map((doc) => this.indexAndAdd(doc, true)),
|
||||
...newDocs.map((doc) => this.indexAndAdd(doc)),
|
||||
]);
|
||||
|
||||
for (const doc of newDocs) {
|
||||
console.log(`Indexing new doc: ${doc.startUrl}`);
|
||||
void Telemetry.capture("add_docs_config", { url: doc.startUrl });
|
||||
|
||||
await this.indexAndAdd(doc);
|
||||
}
|
||||
|
||||
for (const doc of deletedDocs) {
|
||||
|
|
@ -941,7 +959,7 @@ export default class DocsService {
|
|||
);
|
||||
}
|
||||
|
||||
private addToConfig({ siteIndexingConfig }: AddParams) {
|
||||
private addToConfig(siteIndexingConfig: SiteIndexingConfig) {
|
||||
// Handles the case where a user has manually added the doc to config.json
|
||||
// so it already exists in the file
|
||||
const doesDocExist = this.config.docs?.some(
|
||||
|
|
@ -959,13 +977,6 @@ export default class DocsService {
|
|||
private async add(params: AddParams) {
|
||||
await this.addToLance(params);
|
||||
await this.addMetadataToSqlite(params);
|
||||
|
||||
const isPreIndexedDoc =
|
||||
!!preIndexedDocs[params.siteIndexingConfig.startUrl];
|
||||
|
||||
if (!isPreIndexedDoc) {
|
||||
this.addToConfig(params);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete methods
|
||||
|
|
@ -1030,10 +1041,7 @@ export default class DocsService {
|
|||
console.log(
|
||||
`Reindexing non-preindexed docs with new embeddings provider: ${embeddingsProvider.id}`,
|
||||
);
|
||||
await this.initStatuses();
|
||||
for (const doc of docs) {
|
||||
await this.indexAndAdd(doc, true);
|
||||
}
|
||||
await Promise.allSettled(docs.map((doc) => this.indexAndAdd(doc)));
|
||||
|
||||
// Important that this only is invoked after we have successfully
|
||||
// cleared and reindex the docs so that the table cannot end up in an
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import type {
|
|||
DiffLine,
|
||||
FileSymbolMap,
|
||||
IdeSettings,
|
||||
IndexingStatus,
|
||||
LLMFullCompletionOptions,
|
||||
MessageContent,
|
||||
ModelDescription,
|
||||
|
|
@ -165,8 +166,8 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"indexing/reindex": [{ type: string; id: string }, void];
|
||||
"indexing/abort": [{ type: string; id: string }, void];
|
||||
"indexing/setPaused": [{ type: string; id: string; paused: boolean }, void];
|
||||
"indexing/initStatuses": [undefined, void];
|
||||
"docs/getSuggestedDocs": [undefined, void];
|
||||
"docs/initStatuses": [undefined, void];
|
||||
|
||||
addAutocompleteModel: [{ model: ModelDescription }, void];
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"index/forceReIndexFiles",
|
||||
"index/indexingProgressBarInitialized",
|
||||
// Docs, etc.
|
||||
"indexing/initStatuses",
|
||||
"indexing/reindex",
|
||||
"indexing/abort",
|
||||
"indexing/setPaused",
|
||||
"docs/getSuggestedDocs",
|
||||
"docs/initStatuses",
|
||||
//
|
||||
"completeOnboarding",
|
||||
"addAutocompleteModel",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import useSubmenuContextProviders from "./hooks/useSubmenuContextProviders";
|
|||
import { useVscTheme } from "./hooks/useVscTheme";
|
||||
import { AddNewModel, ConfigureProvider } from "./pages/AddNewModel";
|
||||
import ConfigErrorPage from "./pages/config-error";
|
||||
import Edit from "./pages/Edit";
|
||||
import Edit from "./pages/edit";
|
||||
import ErrorPage from "./pages/error";
|
||||
import Chat from "./pages/gui";
|
||||
import History from "./pages/history";
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ function AccountDialog() {
|
|||
);
|
||||
}
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const changeProfileId = (id: string) => {
|
||||
ideMessenger.post("didChangeSelectedProfile", { id });
|
||||
dispatch(setSelectedProfileId(id));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {
|
|||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import IndexingStatusViewer from "../indexing/IndexingStatus";
|
||||
import IndexingStatusViewer from "../indexing/DocsIndexingStatus";
|
||||
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import FileIcon from "../FileIcon";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { IndexingStatus } from "core";
|
||||
import { useMemo } from "react";
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
export interface DocsIndexingPeekProps {
|
||||
status: IndexingStatus;
|
||||
|
|
@ -58,6 +59,9 @@ interface DocsIndexingPeeksProps {
|
|||
}
|
||||
|
||||
function DocsIndexingPeekList({ statuses }: DocsIndexingPeeksProps) {
|
||||
const config = useSelector((store: RootState) => store.state.config);
|
||||
const configDocs = config.docs ?? [];
|
||||
// const docs
|
||||
return (
|
||||
<div className="border-vsc-input-border mt-2 flex flex-col border-0 border-t border-solid pt-2">
|
||||
<p className="mx-0 my-1.5 p-0 px-1 font-semibold text-stone-500">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { IndexingStatus } from "core";
|
||||
import { IndexingStatus, SiteIndexingConfig } from "core";
|
||||
import { PropsWithChildren, useContext, useMemo } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import {
|
||||
|
|
@ -12,9 +12,10 @@ import {
|
|||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { updateIndexingStatus } from "../../redux/slices/stateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
interface IndexingStatusViewerProps {
|
||||
status: IndexingStatus;
|
||||
docConfig: SiteIndexingConfig;
|
||||
}
|
||||
|
||||
const STATUS_TO_ICON: Record<IndexingStatus["status"], any> = {
|
||||
|
|
@ -27,33 +28,43 @@ const STATUS_TO_ICON: Record<IndexingStatus["status"], any> = {
|
|||
failed: XMarkIcon, // Since we show an erorr message below
|
||||
};
|
||||
|
||||
function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
||||
function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const posthog = usePostHog();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
// const status = undefined;
|
||||
const status = useSelector(
|
||||
(store: RootState) => store.state.indexing.statuses[docConfig.startUrl],
|
||||
);
|
||||
|
||||
const reIndex = () =>
|
||||
ideMessenger.post("indexing/reindex", {
|
||||
type: status.type,
|
||||
id: status.id,
|
||||
type: "docs",
|
||||
id: docConfig.startUrl,
|
||||
});
|
||||
|
||||
const abort = () => {
|
||||
ideMessenger.post("indexing/abort", {
|
||||
type: status.type,
|
||||
id: status.id,
|
||||
type: "docs",
|
||||
id: docConfig.startUrl,
|
||||
});
|
||||
// Optimistic abort status
|
||||
dispatch(
|
||||
updateIndexingStatus({ ...status, status: "aborted", progress: 0 }),
|
||||
);
|
||||
if (status) {
|
||||
dispatch(
|
||||
updateIndexingStatus({ ...status, status: "aborted", progress: 0 }),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const progressPercentage = useMemo(() => {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
return Math.min(100, Math.max(0, status.progress * 100));
|
||||
}, [status.progress]);
|
||||
}, [status?.progress]);
|
||||
|
||||
const Icon = STATUS_TO_ICON[status.status];
|
||||
const Icon = STATUS_TO_ICON[status?.status];
|
||||
|
||||
return (
|
||||
<div className="mt-2 flex w-full flex-col">
|
||||
|
|
@ -62,24 +73,26 @@ function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
|||
className={`flex flex-row items-center justify-between gap-2 text-sm`}
|
||||
>
|
||||
<div
|
||||
className={`flex flex-row items-center gap-2 ${status.url ? "cursor-pointer hover:underline" : ""}`}
|
||||
className={`flex flex-row items-center gap-2 ${status?.url ? "cursor-pointer hover:underline" : ""}`}
|
||||
onClick={() => {
|
||||
if (status.url) {
|
||||
if (status?.url) {
|
||||
ideMessenger.post("openUrl", status.url);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{status.icon ? (
|
||||
<img src={status.icon} alt="doc icon" className="h-4 w-4" />
|
||||
{docConfig.faviconUrl ? (
|
||||
<img
|
||||
src={docConfig.faviconUrl}
|
||||
alt="doc icon"
|
||||
className="h-4 w-4"
|
||||
/>
|
||||
) : null}
|
||||
<p className="lines lines-1 m-0 p-0 text-left">
|
||||
{status.title ?? status.id}
|
||||
{docConfig.title ?? docConfig.startUrl}
|
||||
</p>
|
||||
{!!status.url && (
|
||||
<ArrowTopRightOnSquareIcon className="mb-0.5 h-3 w-3 text-stone-500" />
|
||||
)}
|
||||
<ArrowTopRightOnSquareIcon className="mb-0.5 h-3 w-3 text-stone-500" />
|
||||
</div>
|
||||
{status.status === "pending" ? (
|
||||
{status?.status === "pending" ? (
|
||||
<div className="text-xs text-stone-500">Pending...</div>
|
||||
) : (
|
||||
<div className="flex flex-row items-center gap-1 text-stone-500">
|
||||
|
|
@ -87,7 +100,7 @@ function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
|||
{Icon ? (
|
||||
<Icon
|
||||
className={`inline-block h-4 w-4 text-stone-500 ${
|
||||
status.status === "indexing" ? "animate-spin-slow" : ""
|
||||
status?.status === "indexing" ? "animate-spin-slow" : ""
|
||||
}`}
|
||||
></Icon>
|
||||
) : null}
|
||||
|
|
@ -98,7 +111,7 @@ function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
|||
<div className="my-2 h-1.5 w-full rounded-md border border-solid border-gray-400">
|
||||
<div
|
||||
className={`h-full rounded-lg transition-all duration-200 ease-in-out ${
|
||||
status.status === "failed" ? "bg-red-600" : "bg-stone-500"
|
||||
status?.status === "failed" ? "bg-red-600" : "bg-stone-500"
|
||||
}`}
|
||||
style={{
|
||||
width: `${progressPercentage}%`,
|
||||
|
|
@ -118,7 +131,7 @@ function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
|||
paused: () => {},
|
||||
deleted: () => {},
|
||||
pending: () => {},
|
||||
}[status.status]
|
||||
}[status?.status]
|
||||
}
|
||||
>
|
||||
{
|
||||
|
|
@ -130,18 +143,16 @@ function IndexingStatusViewer({ status }: IndexingStatusViewerProps) {
|
|||
paused: "",
|
||||
deleted: "",
|
||||
pending: "",
|
||||
}[status.status]
|
||||
}[status?.status]
|
||||
}
|
||||
</span>
|
||||
|
||||
{/* {status.status === "indexing" && ( */}
|
||||
<span className="lines lines-1 text-right text-xs text-stone-500">
|
||||
{status.description}
|
||||
{status?.description}
|
||||
</span>
|
||||
{/* )} */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default IndexingStatusViewer;
|
||||
export default DocsIndexingStatus;
|
||||
57
gui/src/components/indexing/DocsIndexingStatuses.tsx
Normal file
57
gui/src/components/indexing/DocsIndexingStatuses.tsx
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { useMemo } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
import IndexingStatusViewer from "./DocsIndexingStatus";
|
||||
import { SecondaryButton } from "..";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import AddDocsDialog from "../dialogs/AddDocsDialog";
|
||||
import DocsIndexingStatus from "./DocsIndexingStatus";
|
||||
|
||||
function DocsIndexingStatuses() {
|
||||
const dispatch = useDispatch();
|
||||
const config = useSelector((store: RootState) => store.state.config);
|
||||
const configDocs = config.docs ?? [];
|
||||
|
||||
// const indexingStatuses = useSelector(
|
||||
// (store: RootState) => store.state.indexing.statuses,
|
||||
// );
|
||||
// const docsStatuses = useMemo(() => {
|
||||
// const docs = Object.values(indexingStatuses).filter(
|
||||
// (status) => status.type === "docs" && status.status !== "deleted",
|
||||
// );
|
||||
// return docs;
|
||||
// }, [indexingStatuses]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h3 className="mb-1 mt-0 text-xl">@docs indexes</h3>
|
||||
{configDocs.length ? (
|
||||
<SecondaryButton
|
||||
className="border-vsc-foreground text-vsc-foreground enabled:hover:bg-vsc-background m-2 rounded border bg-inherit px-3 py-2 enabled:hover:cursor-pointer enabled:hover:opacity-90 disabled:text-gray-500"
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddDocsDialog />));
|
||||
}}
|
||||
>
|
||||
Add
|
||||
</SecondaryButton>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="text-xs text-stone-500">
|
||||
Manage your documentation sources
|
||||
</span>
|
||||
<div className="flex max-h-[170px] flex-col gap-1 overflow-x-hidden overflow-y-scroll pr-2">
|
||||
{configDocs.map((doc) => {
|
||||
return <DocsIndexingStatus key={doc.startUrl} docConfig={doc} />;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DocsIndexingStatuses;
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
import { useMemo } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
import IndexingStatusViewer from "./IndexingStatus";
|
||||
import { Button, SecondaryButton } from "..";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import AddDocsDialog from "../dialogs/AddDocsDialog";
|
||||
import { PlusCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
function IndexingStatuses() {
|
||||
const indexingStatuses = useSelector(
|
||||
(store: RootState) => store.state.indexing.statuses,
|
||||
);
|
||||
const docsStatuses = useMemo(() => {
|
||||
const docs = Object.values(indexingStatuses).filter(
|
||||
(status) => status.type === "docs" && status.status !== "deleted",
|
||||
);
|
||||
return docs;
|
||||
}, [indexingStatuses]);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h3 className="mb-1 mt-0 text-xl">@docs indexes</h3>
|
||||
{docsStatuses.length ? (
|
||||
<div
|
||||
className="border-vsc-foreground text-vsc-foreground enabled:hover:bg-vsc-background m-2 rounded border border-solid bg-inherit px-3 py-2 enabled:hover:cursor-pointer enabled:hover:opacity-90 disabled:text-gray-500"
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddDocsDialog />));
|
||||
}}
|
||||
>
|
||||
Add
|
||||
</div>
|
||||
) : // <div>
|
||||
// <PlusCircleIcon
|
||||
// data-tooltip-id={"more-add-docs-button"}
|
||||
// className="text-vsc-foreground-muted h-5 w-5 cursor-pointer focus:ring-0"
|
||||
// onClick={() => {
|
||||
// dispatch(setShowDialog(true));
|
||||
// dispatch(setDialogMessage(<AddDocsDialog />));
|
||||
// }}
|
||||
// />
|
||||
// <ToolTip id={"more-add-docs-button"} place="top">
|
||||
// Add Docs
|
||||
// </ToolTip>
|
||||
// </div>
|
||||
null}
|
||||
</div>
|
||||
<span className="text-xs text-stone-500">
|
||||
Manage your documentation sources
|
||||
</span>
|
||||
<div className="flex max-h-[170px] flex-col gap-1 overflow-x-hidden overflow-y-scroll pr-2">
|
||||
{docsStatuses.length ? (
|
||||
docsStatuses.map((status) => {
|
||||
return <IndexingStatusViewer key={status.id} status={status} />;
|
||||
})
|
||||
) : (
|
||||
<SecondaryButton>Add Docs</SecondaryButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default IndexingStatuses;
|
||||
|
|
@ -54,9 +54,12 @@ function useSetup(dispatch: Dispatch) {
|
|||
loadConfig();
|
||||
const interval = setInterval(() => {
|
||||
if (initialConfigLoad.current) {
|
||||
// Docs init on config load
|
||||
ideMessenger.post("docs/getSuggestedDocs", undefined);
|
||||
ideMessenger.post("docs/initStatuses", undefined);
|
||||
|
||||
// This triggers sending pending status to the GUI for relevant docs indexes
|
||||
clearInterval(interval);
|
||||
ideMessenger.post("indexing/initStatuses", undefined);
|
||||
return;
|
||||
}
|
||||
loadConfig();
|
||||
|
|
@ -85,8 +88,6 @@ function useSetup(dispatch: Dispatch) {
|
|||
|
||||
// ON LOAD
|
||||
useEffect(() => {
|
||||
ideMessenger.post("docs/getSuggestedDocs", undefined);
|
||||
|
||||
// Override persisted state
|
||||
dispatch(setInactive());
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import { setOnboardingCard } from "../../redux/slices/uiStateSlice";
|
|||
import useHistory from "../../hooks/useHistory";
|
||||
import MoreHelpRow from "./MoreHelpRow";
|
||||
import IndexingProgress from "./IndexingProgress";
|
||||
import IndexingStatuses from "../../components/indexing/IndexingStatuses";
|
||||
import DocsIndexingStatuses from "../../components/indexing/DocsIndexingStatuses";
|
||||
|
||||
function MorePage() {
|
||||
useNavigationListener();
|
||||
|
|
@ -52,7 +52,7 @@ function MorePage() {
|
|||
<IndexingProgress />
|
||||
</div>
|
||||
<div className="flex flex-col py-5">
|
||||
<IndexingStatuses />
|
||||
<DocsIndexingStatuses />
|
||||
</div>
|
||||
|
||||
<div className="py-5">
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ type State = {
|
|||
nextCodeBlockToApplyIndex: number;
|
||||
indexing: {
|
||||
hiddenChatPeekTypes: Record<IndexingStatus["type"], boolean>;
|
||||
statuses: Record<string, IndexingStatus>;
|
||||
statuses: Record<string, IndexingStatus>; // status id -> status
|
||||
};
|
||||
streamAborter: AbortController;
|
||||
docsSuggestions: PackageDocsResult[];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue