From f7f64ff341ded4cc64959d05b84fb3c8a1d7120b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 27 Nov 2024 23:42:15 -0700 Subject: [PATCH] pause fix, cancelled status --- core/core.ts | 6 ++++-- core/index.d.ts | 11 +++++++++-- core/indexing/CodebaseIndexer.ts | 16 +++++++--------- .../IndexingProgressIndicator.tsx | 1 + .../IndexingProgress/IndexingProgressSubtext.tsx | 1 + .../IndexingProgressTitleText.tsx | 1 + gui/src/util/localStorage.ts | 2 -- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/core/core.ts b/core/core.ts index a1d74f2818..0742a35487 100644 --- a/core/core.ts +++ b/core/core.ts @@ -154,10 +154,10 @@ export class Core { // Index on initialization void this.ide.getWorkspaceDirs().then(async (dirs) => { // Respect pauseCodebaseIndexOnStart user settings - this.indexingPauseToken.paused = true; if (ideSettings.pauseCodebaseIndexOnStart) { + this.indexingPauseToken.paused = true; void this.messenger.request("indexProgress", { - progress: 1, + progress: 0, desc: "Initial Indexing Skipped", status: "paused", }); @@ -803,6 +803,8 @@ export class Core { this.indexingCancellationController.signal, )) { let updateToSend = { ...update }; + // TODO reconsider this status overwrite? + // original goal was to not concern users with edge noncritical errors if (update.status === "failed") { updateToSend.status = "done"; updateToSend.desc = "Indexing complete"; diff --git a/core/index.d.ts b/core/index.d.ts index efb7a18e94..b711b9319a 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -42,11 +42,18 @@ export interface IndexingProgressUpdate { progress: number; desc: string; shouldClearIndexes?: boolean; - status: "loading" | "indexing" | "done" | "failed" | "paused" | "disabled"; + status: + | "loading" + | "indexing" + | "done" + | "failed" + | "paused" + | "disabled" + | "cancelled"; debugInfo?: string; } -// This is more or less a V2 of IndexingProgressUpdate +// This is more or less a V2 of IndexingProgressUpdate for docs etc. export interface IndexingStatus { id: string; type: "docs"; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 5c70f8badd..af204a723e 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -145,9 +145,7 @@ export class CodebaseIndexer { } } - async *refreshFiles( - files: string[], - ): AsyncGenerator { + async *refreshFiles(files: string[]): AsyncGenerator { let progress = 0; if (files.length === 0) { yield { @@ -192,9 +190,9 @@ export class CodebaseIndexer { if (dirs.length === 0) { yield { - progress, + progress: 1, desc: "Nothing to index", - status: "disabled", + status: "done", }; return; } @@ -238,9 +236,9 @@ export class CodebaseIndexer { directoryFiles.push(p); if (abortSignal.aborted) { yield { - progress: 1, + progress: 0, desc: "Indexing cancelled", - status: "disabled", + status: "cancelled", }; return; } @@ -263,9 +261,9 @@ export class CodebaseIndexer { // Handle pausing in this loop because it's the only one really taking time if (abortSignal.aborted) { yield { - progress: 1, + progress: 0, desc: "Indexing cancelled", - status: "disabled", + status: "cancelled", }; return; } diff --git a/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx b/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx index 944fdc9175..83abeed110 100644 --- a/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx +++ b/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx @@ -17,6 +17,7 @@ const STATUS_TO_ICON: Record = { paused: PauseCircleIcon, done: CheckCircleIcon, failed: null, // Since we show an erorr message below + cancelled: null, }; function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) { diff --git a/gui/src/pages/More/IndexingProgress/IndexingProgressSubtext.tsx b/gui/src/pages/More/IndexingProgress/IndexingProgressSubtext.tsx index 6c07babb05..a731480099 100644 --- a/gui/src/pages/More/IndexingProgress/IndexingProgressSubtext.tsx +++ b/gui/src/pages/More/IndexingProgress/IndexingProgressSubtext.tsx @@ -15,6 +15,7 @@ const STATUS_TO_SUBTITLE_TEXT: Record< paused: "Click to resume", failed: "Click to retry", disabled: "Click to open config.json and enable indexing (requires reload)", + cancelled: "Click to restart", }; function IndexingProgressSubtext({ diff --git a/gui/src/pages/More/IndexingProgress/IndexingProgressTitleText.tsx b/gui/src/pages/More/IndexingProgress/IndexingProgressTitleText.tsx index 61d4bbba64..e15ba57137 100644 --- a/gui/src/pages/More/IndexingProgress/IndexingProgressTitleText.tsx +++ b/gui/src/pages/More/IndexingProgress/IndexingProgressTitleText.tsx @@ -12,6 +12,7 @@ const STATUS_TO_TEXT: Record = { paused: "Indexing paused", failed: "Indexing failed", disabled: "Indexing disabled", + cancelled: "Indexing cancelled", }; function IndexingProgressTitleText({ update }: IndexingProgressTitleTextProps) { diff --git a/gui/src/util/localStorage.ts b/gui/src/util/localStorage.ts index a49f046605..1f3fa7a61b 100644 --- a/gui/src/util/localStorage.ts +++ b/gui/src/util/localStorage.ts @@ -1,5 +1,4 @@ import { JSONContent } from "@tiptap/react"; -import { IndexingProgressUpdate } from "core"; import { OnboardingStatus } from "../components/OnboardingCard"; type LocalStorageTypes = { @@ -12,7 +11,6 @@ type LocalStorageTypes = { lastSessionId: string | undefined; [key: `inputHistory_${string}`]: JSONContent[]; extensionVersion: string; - indexingState: IndexingProgressUpdate; showTutorialCard: boolean; shownProfilesIntroduction: boolean; disableIndexing: boolean;