Fix sidebar indexing status timing-related bugs (#1368)
* readd overwritten commit * Remove duplicated code * Fix status load in and failed state update * Late sidebar open bugs fixed * Change ideMessenger post parameters * debug pause * Don't use global, fix table creation bug * Creating new branch for config-related issues here * cleanup
This commit is contained in:
parent
759ba1281f
commit
b70552a7db
9 changed files with 52 additions and 14 deletions
11
core/core.ts
11
core/core.ts
|
|
@ -25,6 +25,7 @@ import type { IMessenger, Message } from "./util/messenger";
|
|||
import { editConfigJson, getConfigJsonPath } from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { streamDiffLines } from "./util/verticalEdit";
|
||||
import { IndexingProgressUpdate } from ".";
|
||||
|
||||
export class Core {
|
||||
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
|
||||
|
|
@ -32,6 +33,7 @@ export class Core {
|
|||
codebaseIndexerPromise: Promise<CodebaseIndexer>;
|
||||
completionProvider: CompletionProvider;
|
||||
continueServerClientPromise: Promise<ContinueServerClient>;
|
||||
indexingState: IndexingProgressUpdate
|
||||
|
||||
private abortedMessageIds: Set<string> = new Set();
|
||||
|
||||
|
|
@ -59,6 +61,7 @@ export class Core {
|
|||
private readonly ide: IDE,
|
||||
private readonly onWrite: (text: string) => Promise<void> = async () => {},
|
||||
) {
|
||||
this.indexingState = { status:"loading", desc: 'loading', progress: 0 }
|
||||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
this.configHandler = new ConfigHandler(
|
||||
this.ide,
|
||||
|
|
@ -519,6 +522,13 @@ export class Core {
|
|||
new GlobalContext().update("indexingPaused", msg.data);
|
||||
indexingPauseToken.paused = msg.data;
|
||||
});
|
||||
on("index/indexingProgressBarInitialized", async (msg) => {
|
||||
// Triggered when progress bar is initialized.
|
||||
// If a non-default state has been stored, update the indexing display to that state
|
||||
if (this.indexingState.status != 'loading') {
|
||||
this.messenger.request("indexProgress", this.indexingState);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private indexingCancellationController: AbortController | undefined;
|
||||
|
|
@ -533,6 +543,7 @@ export class Core {
|
|||
this.indexingCancellationController.signal,
|
||||
)) {
|
||||
this.messenger.request("indexProgress", update);
|
||||
this.indexingState = update
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -37,7 +37,7 @@ export interface Chunk extends ChunkWithoutID {
|
|||
export interface IndexingProgressUpdate {
|
||||
progress: number;
|
||||
desc: string;
|
||||
status: "starting" | "indexing" | "done" | "failed" | "paused" | "disabled";
|
||||
status: "loading" | "indexing" | "done" | "failed" | "paused" | "disabled";
|
||||
}
|
||||
|
||||
export type PromptTemplate =
|
||||
|
|
|
|||
|
|
@ -148,8 +148,8 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
|
||||
// Compute
|
||||
let table: Table<number[]> | undefined = undefined;
|
||||
let needToCreateTable = true;
|
||||
const existingTables = await db.tableNames();
|
||||
let needToCreateTable = !existingTables.includes(tableName);
|
||||
|
||||
const addComputedLanceDbRows = async (
|
||||
pathAndCacheKey: PathAndCacheKey,
|
||||
|
|
|
|||
|
|
@ -56,16 +56,16 @@ export class CodebaseIndexer {
|
|||
yield {
|
||||
progress: 0,
|
||||
desc: "Nothing to index",
|
||||
status: "disabled",
|
||||
status: "disabled",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const config = await this.configHandler.loadConfig();
|
||||
if (config.disableIndexing) {
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: "Indexing is disabled in the config.json",
|
||||
desc: "Indexing is disabled in config.json",
|
||||
status: "disabled",
|
||||
};
|
||||
return;
|
||||
|
|
@ -73,7 +73,7 @@ export class CodebaseIndexer {
|
|||
yield {
|
||||
progress: 0,
|
||||
desc: "Starting indexing",
|
||||
status: "starting",
|
||||
status: "loading",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ export class CodebaseIndexer {
|
|||
yield {
|
||||
progress: 0,
|
||||
desc: "Starting indexing...",
|
||||
status: "starting",
|
||||
status: "loading",
|
||||
};
|
||||
|
||||
for (const directory of workspaceDirs) {
|
||||
|
|
@ -161,9 +161,15 @@ export class CodebaseIndexer {
|
|||
status: "indexing",
|
||||
};
|
||||
} catch (e) {
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: `${e}`,
|
||||
status: "failed"
|
||||
}
|
||||
console.warn(
|
||||
`Error updating the ${codebaseIndex.artifactId} index: ${e}`,
|
||||
);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
];
|
||||
"index/setPaused": [boolean, void];
|
||||
"index/forceReIndex": [undefined | string, void];
|
||||
"index/indexingProgressBarInitialized": [undefined, void];
|
||||
completeOnboarding: [
|
||||
{
|
||||
mode:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"stats/getTokensPerModel",
|
||||
"index/setPaused",
|
||||
"index/forceReIndex",
|
||||
"index/indexingProgressBarInitialized",
|
||||
"completeOnboarding",
|
||||
"addAutocompleteModel",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import fs from "node:fs";
|
||||
import { getGlobalContextFilePath } from "./paths";
|
||||
import { IndexingProgressUpdate } from "..";
|
||||
|
||||
export type GlobalContextType = {
|
||||
indexingPaused: boolean;
|
||||
|
|
|
|||
|
|
@ -223,10 +223,10 @@ const Layout = () => {
|
|||
}
|
||||
}, [location]);
|
||||
|
||||
const [indexingState, setIndexingState] = useState<IndexingProgressUpdate>({
|
||||
desc: "Indexing disabled",
|
||||
const [indexingState, setIndexingState] = useState<IndexingProgressUpdate>({
|
||||
desc: "Loading indexing config",
|
||||
progress: 0.0,
|
||||
status: "disabled",
|
||||
status: "loading",
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -51,10 +51,28 @@ const P = styled.p`
|
|||
`;
|
||||
|
||||
interface ProgressBarProps {
|
||||
indexingState: IndexingProgressUpdate;
|
||||
indexingState?: IndexingProgressUpdate;
|
||||
}
|
||||
|
||||
const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
||||
const IndexingProgressBar = ({ indexingState: indexingStateProp }: ProgressBarProps) => {
|
||||
// If sidebar is opened before extension initiates, define a default indexingState
|
||||
const defaultIndexingState: IndexingProgressUpdate = {
|
||||
status: 'loading',
|
||||
progress: 0,
|
||||
desc: ''
|
||||
};
|
||||
const indexingState = indexingStateProp || defaultIndexingState;
|
||||
|
||||
// If sidebar is opened after extension initializes, retrieve saved states.
|
||||
let initialized = false
|
||||
useEffect(() => {
|
||||
if (!initialized) {
|
||||
// Triggers retrieval for possible non-default states set prior to IndexingProgressBar initialization
|
||||
ideMessenger.post("index/indexingProgressBarInitialized", undefined)
|
||||
initialized = true
|
||||
}
|
||||
}, []);
|
||||
|
||||
const fillPercentage = Math.min(
|
||||
100,
|
||||
Math.max(0, indexingState.progress * 100),
|
||||
|
|
@ -87,7 +105,7 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
}}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
{indexingState.status === "starting" ? ( // ice-blue 'indexing starting up' dot
|
||||
{indexingState.status === "loading" ? ( // ice-blue 'indexing loading' dot
|
||||
<>
|
||||
<CircleDiv
|
||||
data-tooltip-id="indexingNotLoaded_dot"
|
||||
|
|
@ -96,7 +114,7 @@ const IndexingProgressBar = ({ indexingState }: ProgressBarProps) => {
|
|||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id="indexingNotLoaded_dot" place="top">
|
||||
Codebase indexing is starting up.
|
||||
Continue is initializing
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue