Skip to content

Commit

Permalink
Merge pull request #3122 from continuedev/dallin/indexing-fixes
Browse files Browse the repository at this point in the history
Minor indexing fixes
  • Loading branch information
sestinj authored Dec 3, 2024
2 parents fabf54b + f7f64ff commit 238898d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
6 changes: 4 additions & 2 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,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",
});
Expand Down Expand Up @@ -842,6 +842,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";
Expand Down
11 changes: 9 additions & 2 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
16 changes: 7 additions & 9 deletions core/indexing/CodebaseIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ export class CodebaseIndexer {
}
}

async *refreshFiles(
files: string[],
): AsyncGenerator<IndexingProgressUpdate> {
async *refreshFiles(files: string[]): AsyncGenerator<IndexingProgressUpdate> {
let progress = 0;
if (files.length === 0) {
yield {
Expand Down Expand Up @@ -192,9 +190,9 @@ export class CodebaseIndexer {

if (dirs.length === 0) {
yield {
progress,
progress: 1,
desc: "Nothing to index",
status: "disabled",
status: "done",
};
return;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const STATUS_TO_ICON: Record<IndexingProgressUpdate["status"], any> = {
paused: PauseCircleIcon,
done: CheckCircleIcon,
failed: null, // Since we show an erorr message below
cancelled: null,
};

function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const STATUS_TO_TEXT: Record<IndexingProgressUpdate["status"], string> = {
paused: "Indexing paused",
failed: "Indexing failed",
disabled: "Indexing disabled",
cancelled: "Indexing cancelled",
};

function IndexingProgressTitleText({ update }: IndexingProgressTitleTextProps) {
Expand Down
2 changes: 0 additions & 2 deletions gui/src/util/localStorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { JSONContent } from "@tiptap/react";
import { IndexingProgressUpdate } from "core";
import { OnboardingStatus } from "../components/OnboardingCard";

type LocalStorageTypes = {
Expand All @@ -12,7 +11,6 @@ type LocalStorageTypes = {
lastSessionId: string | undefined;
[key: `inputHistory_${string}`]: JSONContent[];
extensionVersion: string;
indexingState: IndexingProgressUpdate;
showTutorialCard: boolean;
shownProfilesIntroduction: boolean;
disableIndexing: boolean;
Expand Down

0 comments on commit 238898d

Please sign in to comment.