diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index d81a4ec19..7a35e8f24 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -193,8 +193,15 @@ export default class DocsService { this.docsIndexingQueue.delete(startUrl); } - isAborted(startUrl: string) { - return this.statuses.get(startUrl)?.status === "aborted"; + shouldCancel(startUrl: string) { + const isAborted = this.statuses.get(startUrl)?.status === "aborted"; + if (isAborted) { + return true; + } + if (this.config.disableIndexing) { + this.abort(startUrl); + return true; + } } // NOTE Pausing not supported for docs yet @@ -421,7 +428,7 @@ export default class DocsService { estimatedProgress += 1 / 2 ** (processedPages + 1); // NOTE - during "indexing" phase, check if aborted before each status update - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -459,7 +466,7 @@ export default class DocsService { for (let i = 0; i < articles.length; i++) { const article = articles[i]; - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -496,7 +503,7 @@ export default class DocsService { `No embeddings were created for site: ${siteIndexingConfig.startUrl}\n Num chunks: ${chunks.length}`, ); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -514,7 +521,7 @@ export default class DocsService { // Add docs to databases console.log(`Adding ${embeddings.length} embeddings to db`); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -532,7 +539,7 @@ export default class DocsService { const favicon = await fetchFavicon(new URL(siteIndexingConfig.startUrl)); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -551,7 +558,7 @@ export default class DocsService { this.docsIndexingQueue.delete(startUrl); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ diff --git a/gui/src/components/indexing/DocsIndexingStatus.tsx b/gui/src/components/indexing/DocsIndexingStatus.tsx index 31604874f..7f11d9dfa 100644 --- a/gui/src/components/indexing/DocsIndexingStatus.tsx +++ b/gui/src/components/indexing/DocsIndexingStatus.tsx @@ -28,6 +28,7 @@ const STATUS_TO_ICON: Record = { }; function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) { + const config = useAppSelector((store) => store.config.config); const ideMessenger = useContext(IdeMessengerContext); const dispatch = useAppDispatch(); @@ -146,28 +147,30 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
{}, - pending: () => {}, - }[status?.status] + config.disableIndexing + ? undefined + : { + complete: reIndex, + indexing: abort, + failed: reIndex, + aborted: reIndex, + paused: () => {}, + pending: () => {}, + }[status?.status] } > - { - { - complete: "Click to re-index", - indexing: "Cancel indexing", - failed: "Click to retry", - aborted: "Click to index", - paused: "", - pending: "", - }[status?.status] - } + {config.disableIndexing + ? "Indexing disabled" + : { + complete: "Click to re-index", + indexing: "Cancel indexing", + failed: "Click to retry", + aborted: "Click to index", + paused: "", + pending: "", + }[status?.status]} diff --git a/gui/src/components/indexing/DocsIndexingStatuses.tsx b/gui/src/components/indexing/DocsIndexingStatuses.tsx index 9a9ffb4df..9c52ab0af 100644 --- a/gui/src/components/indexing/DocsIndexingStatuses.tsx +++ b/gui/src/components/indexing/DocsIndexingStatuses.tsx @@ -41,12 +41,13 @@ function DocsIndexingStatuses() { ) : null}
- {configDocs.length - ? "Manage your documentation sources" - : "No docs yet"} - -
- {!hasDocsProvider && ( + {hasDocsProvider ? ( + configDocs.length ? ( + "Manage your documentation sources" + ) : ( + "No docs yet" + ) + ) : (
@@ -69,6 +70,8 @@ function DocsIndexingStatuses() {
)} + +
{configDocs.length === 0 && (