Merge branch 'preview' into nate/mistral-prefilling
This commit is contained in:
commit
dfc6347cf3
14 changed files with 94 additions and 16 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;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ rimrafSync(path.join(__dirname, "..", "out"));
|
|||
fs.mkdirSync(path.join(__dirname, "..", "out", "node_modules"), {
|
||||
recursive: true,
|
||||
});
|
||||
const guiDist = path.join(__dirname, "..", "..", "..", "gui", "dist");
|
||||
if (!fs.existsSync(guiDist)) {
|
||||
fs.mkdirSync(guiDist, { recursive: true });
|
||||
}
|
||||
|
||||
// Get the target to package for
|
||||
let target = undefined;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@ import type {
|
|||
} from "core";
|
||||
import { defaultIgnoreFile } from "core/indexing/ignore";
|
||||
import { IdeSettings } from "core/protocol/ideWebview";
|
||||
import { getContinueGlobalPath } from "core/util/paths";
|
||||
import {
|
||||
editConfigJson,
|
||||
getConfigJsonPath,
|
||||
getContinueGlobalPath,
|
||||
} from "core/util/paths";
|
||||
import * as vscode from "vscode";
|
||||
import { DiffManager } from "./diff/horizontal";
|
||||
import { Repository } from "./otherExtensions/git";
|
||||
|
|
@ -48,6 +52,28 @@ class VsCodeIde implements IDE {
|
|||
if (session) {
|
||||
this.authToken = session.accessToken;
|
||||
return session.accessToken;
|
||||
} else if (!this.askedForAuth) {
|
||||
// User cancelled the login prompt
|
||||
// Explain that they can avoid the prompt by removing free trial models from config.json
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
"We'll only ask you to log in if using the free trial. To avoid this prompt, make sure to remove free trial models from your config.json",
|
||||
"Remove for me",
|
||||
"Open config.json",
|
||||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Remove for me") {
|
||||
editConfigJson((configJson) => {
|
||||
configJson.models = configJson.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
configJson.tabAutocompleteModel = undefined;
|
||||
return configJson;
|
||||
});
|
||||
} else if (selection === "Open config.json") {
|
||||
this.openFile(getConfigJsonPath());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to get GitHub authentication session:", error);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
|
|||
import { Button, Input, SecondaryButton, vscForeground } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
interface GitHubSignInButtonProps {
|
||||
onComplete: (token: string) => void;
|
||||
|
|
@ -52,6 +53,7 @@ function GitHubSignInButton(props: GitHubSignInButtonProps) {
|
|||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
setLocalStorage("signedInToGh", true);
|
||||
props.onComplete(jbGhAuthToken);
|
||||
}}
|
||||
>
|
||||
|
|
@ -66,6 +68,7 @@ function GitHubSignInButton(props: GitHubSignInButtonProps) {
|
|||
"getGitHubAuthToken",
|
||||
undefined,
|
||||
);
|
||||
setLocalStorage("signedInToGh", true);
|
||||
props.onComplete(token);
|
||||
}}
|
||||
className="grid grid-flow-col items-center gap-2"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { useContext } from "react";
|
|||
import { useNavigate } from "react-router-dom";
|
||||
import QuickModelSetup from "../../components/modelSelection/quickSetup/QuickModelSetup";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { getLocalStorage } from "../../util/localStorage";
|
||||
|
||||
function ApiKeyOnboarding() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
|
@ -23,7 +24,12 @@ function ApiKeyOnboarding() {
|
|||
<QuickModelSetup
|
||||
onDone={() => {
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
navigate("/apiKeyAutocompleteOnboarding");
|
||||
|
||||
if (getLocalStorage("signedInToGh") === true) {
|
||||
navigate("/");
|
||||
} else {
|
||||
navigate("/apiKeyAutocompleteOnboarding");
|
||||
}
|
||||
}}
|
||||
></QuickModelSetup>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ type LocalStorageTypes = {
|
|||
inputHistory: JSONContent[];
|
||||
extensionVersion: string;
|
||||
indexingState: IndexingProgressUpdate;
|
||||
signedInToGh: boolean;
|
||||
};
|
||||
|
||||
export function getLocalStorage<T extends keyof LocalStorageTypes>(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue