merge dev

This commit is contained in:
Patrick Erichsen 2024-08-13 11:29:07 -07:00
commit b6fedb54b3
21 changed files with 369 additions and 109 deletions

View file

@ -638,8 +638,13 @@ export class Core {
const rows = await DevDataSqliteDb.getTokensPerModel();
return rows;
});
on("index/forceReIndex", async (msg) => {
const dirs = msg.data ? [msg.data] : await this.ide.getWorkspaceDirs();
on("index/forceReIndex", async ({ data }) => {
if (data?.shouldClearIndexes) {
const codebaseIndexer = await this.codebaseIndexerPromise;
await codebaseIndexer.clearIndexes();
}
const dirs = data?.dir ? [data.dir] : await this.ide.getWorkspaceDirs();
await this.refreshCodebaseIndex(dirs);
});
on("index/setPaused", (msg) => {

1
core/index.d.ts vendored
View file

@ -37,6 +37,7 @@ export interface Chunk extends ChunkWithoutID {
export interface IndexingProgressUpdate {
progress: number;
desc: string;
shouldClearIndexes?: boolean;
status: "loading" | "indexing" | "done" | "failed" | "paused" | "disabled";
}

View file

@ -201,7 +201,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
for (const snippet of snippets) {
const { lastID } = await db.run(
"INSERT INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)",
"REPLACE INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)",
[
addTag.path,
addTag.cacheKey,
@ -212,7 +212,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
],
);
await db.run(
"INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)",
"REPLACE INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)",
[lastID, tagString],
);
}

View file

@ -1,6 +1,7 @@
import { ConfigHandler } from "../config/ConfigHandler.js";
import { IContinueServerClient } from "../continueServer/interface.js";
import { IDE, IndexTag, IndexingProgressUpdate } from "../index.js";
import { getIndexSqlitePath, getLanceDbPath } from "../util/paths.js";
import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js";
import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js";
import { FullTextSearchCodebaseIndex } from "./FullTextSearch.js";
@ -12,6 +13,7 @@ import {
RefreshIndexResults,
} from "./types.js";
import { walkDirAsync } from "./walkDir.js";
import * as fs from "fs/promises";
export class PauseToken {
constructor(private _paused: boolean) {}
@ -33,6 +35,17 @@ export class CodebaseIndexer {
*/
filesPerBatch = 1000;
// Note that we exclude certain Sqlite errors that we do not want to clear the indexes on,
// e.g. a `SQLITE_BUSY` error.
errorsRegexesToClearIndexesOn = [
/Invalid argument error: Values length (d+) is less than the length ((d+)) multiplied by the value size (d+)/,
/SQLITE_CONSTRAINT/,
/SQLITE_ERROR/,
/SQLITE_CORRUPT/,
/SQLITE_IOERR/,
/SQLITE_FULL/,
];
constructor(
private readonly configHandler: ConfigHandler,
protected readonly ide: IDE,
@ -40,6 +53,23 @@ export class CodebaseIndexer {
private readonly continueServerClient: IContinueServerClient,
) {}
async clearIndexes() {
const sqliteFilepath = getIndexSqlitePath();
const lanceDbFolder = getLanceDbPath();
try {
await fs.unlink(sqliteFilepath);
} catch (error) {
console.error(`Error deleting ${sqliteFilepath} folder: ${error}`);
}
try {
await fs.rm(lanceDbFolder, { recursive: true, force: true });
} catch (error) {
console.error(`Error deleting ${lanceDbFolder}: ${error}`);
}
}
protected async getIndexesToBuild(): Promise<CodebaseIndex[]> {
const config = await this.configHandler.loadConfig();
const pathSep = await this.ide.pathSep();
@ -210,7 +240,6 @@ export class CodebaseIndexer {
yield this.handleErrorAndGetProgressUpdate(err);
return;
}
completedDirs += 1;
}
yield {
progress: 100,
@ -234,20 +263,25 @@ export class CodebaseIndexer {
}
private errorToProgressUpdate(err: Error): IndexingProgressUpdate {
const errorRegex =
/Invalid argument error: Values length (\d+) is less than the length \((\d+)\) multiplied by the value size \(\d+\)/;
const match = err.message.match(errorRegex);
let errMsg: string;
if (match) {
const [_, valuesLength, expectedLength] = match;
errMsg = `Generated embedding had length ${valuesLength} but was expected to be ${expectedLength}. This may be solved by deleting ~/.continue/index and refreshing the window to re-index.`;
} else {
errMsg = `${err}`;
let errMsg: string = `${err}`;
let shouldClearIndexes = false;
// Check if any of the error regexes match
for (const regexStr of this.errorsRegexesToClearIndexesOn) {
const regex = new RegExp(regexStr);
const match = err.message.match(regex);
if (match !== null) {
shouldClearIndexes = true;
break;
}
}
return {
progress: 0,
desc: errMsg,
status: "failed",
shouldClearIndexes,
};
}

View file

@ -2,7 +2,6 @@ import { RunResult } from "sqlite3";
import { IContinueServerClient } from "../../continueServer/interface.js";
import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js";
import { getBasename } from "../../util/index.js";
import { getLanguageForFile } from "../../util/treeSitter.js";
import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js";
import {
IndexResultType,
@ -12,6 +11,7 @@ import {
type CodebaseIndex,
} from "../types.js";
import { chunkDocument, shouldChunk } from "./chunk.js";
import * as path from "path";
export class ChunkCodebaseIndex implements CodebaseIndex {
relativeExpectedTime: number = 1;
@ -61,8 +61,11 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
let accumulatedProgress = 0;
if (results.compute.length > 0) {
const filepath = results.compute[0].path;
const folderName = path.basename(path.dirname(filepath));
yield {
desc: `Chunking ${results.compute.length} ${this.formatListPlurality("file", results.compute.length)}`,
desc: `Chunking files in ${folderName}`,
status: "indexing",
progress: accumulatedProgress,
};
@ -171,11 +174,17 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
}
private async computeChunks(paths: PathAndCacheKey[]): Promise<Chunk[]> {
const chunkLists = await Promise.all(paths.map(p => this.packToChunks(p)));
const chunkLists = await Promise.all(
paths.map((p) => this.packToChunks(p)),
);
return chunkLists.flat();
}
private async insertChunks(db: DatabaseConnection, tagString: string, chunks: Chunk[]) {
private async insertChunks(
db: DatabaseConnection,
tagString: string,
chunks: Chunk[],
) {
await new Promise<void>((resolve, reject) => {
db.db.serialize(() => {
db.db.exec("BEGIN", (err: Error | null) => {
@ -183,23 +192,45 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
reject(new Error("error creating transaction", { cause: err }));
}
});
const chunksSQL = "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)";
chunks.map(c => {
db.db.run(chunksSQL, [c.digest, c.filepath, c.index, c.startLine, c.endLine, c.content], (result: RunResult, err: Error) => {
if (err) {
reject(new Error("error inserting into chunks table", { cause: err }));
}
});
const chunkTagsSQL = "INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)";
db.db.run(chunkTagsSQL, [ tagString ], (result: RunResult, err: Error) => {
if (err) {
reject(new Error("error inserting into chunk_tags table", { cause: err }));
}
});
const chunksSQL =
"INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)";
chunks.map((c) => {
db.db.run(
chunksSQL,
[c.digest, c.filepath, c.index, c.startLine, c.endLine, c.content],
(result: RunResult, err: Error) => {
if (err) {
reject(
new Error("error inserting into chunks table", {
cause: err,
}),
);
}
},
);
const chunkTagsSQL =
"INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)";
db.db.run(
chunkTagsSQL,
[tagString],
(result: RunResult, err: Error) => {
if (err) {
reject(
new Error("error inserting into chunk_tags table", {
cause: err,
}),
);
}
},
);
});
db.db.exec("COMMIT", (err: Error | null) => {
if (err) {
reject(new Error("error while committing insert chunks transaction", { cause: err }));
reject(
new Error("error while committing insert chunks transaction", {
cause: err,
}),
);
} else {
resolve();
}

View file

@ -20,6 +20,10 @@ class Mistral extends OpenAI {
) {
this.apiBase = options.apiBase ?? "https://codestral.mistral.ai/v1/";
}
if (!this.apiBase?.endsWith("/")) {
this.apiBase += "/";
}
}
private static modelConversion: { [key: string]: string } = {

View file

@ -130,7 +130,10 @@ export type ToCoreFromIdeOrWebviewProtocol = {
{ model: string; promptTokens: number; generatedTokens: number }[],
];
"index/setPaused": [boolean, void];
"index/forceReIndex": [undefined | string, void];
"index/forceReIndex": [
undefined | { dir?: string; shouldClearIndexes?: boolean },
void,
];
"index/indexingProgressBarInitialized": [undefined, void];
completeOnboarding: [
{

View file

@ -5,8 +5,6 @@ keywords: [experimental, automate, configuration]
toc_max_heading_level: 5
---
## Quick Actions (experimental, VS Code only)
Quick Actions streamline your development workflow by providing a tool to quickly select an entire class or function to perform a quick edit on. Configure custom actions to execute complex operations with a single click.
![Quick actions example](/img/quick-actions-demo.gif)

View file

@ -20,7 +20,7 @@ You can configure Azure OpenAI service through the UI, or you can configure it m
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
"engine": "<YOUR_ENGINE>",
"apiVersion": "<YOUR_API_VERSION>",
"apiType": "azure",
"apiType": "openai",
"apiKey": "<MY_API_KEY>"
}]
```

View file

@ -1,13 +1,54 @@
---
title: Overview
description: Get started with Continue and tailor it to your needs
keywords: [setup, customization, models, configuration, LLMs]
---
# Overview
Continue gives you choice over what [Large Language Models (LLMs)](https://www.youtube.com/watch?v=zjkBMFhNj_g) you use. You can use it with commercial models like Claude 3 Opus via the Anthropic API, open-source models like Llama 3 running on your laptop with Ollama, and everything in between.
Continue is a flexible AI coding assistant that allows you to choose and customize your Large Language Models (LLMs). This guide will help you get started and make Continue work best for you.
When you first install Continue, you can try it out for free using a proxy server that securely makes calls with our API keys. Once you're ready to use your own API keys or different models / providers, you can add them to the `config.json`.
## Quick Start
You will need to decide which models and providers you use for [chat](select-model.md#chat), [autocomplete](select-model.md#autocomplete), and [embeddings](select-model.md#embeddings).
1. When you first install Continue, you can use it immediately with our free proxy server.
2. As you get familiar with Continue, you can set up your own API keys and customize your experience.
Learn more:
## Choosing Your Models
- [Configuration](configuration.md)
- [Model Providers](model-providers.md)
- [Select models](select-model.md)
Continue works with a variety of LLMs:
- Commercial models (e.g., Claude 3 Opus via Anthropic API)
- Open-source models (e.g., Llama 3 running locally with Ollama)
- And many options in between
You'll need to select models for three main functions:
- [Chat](select-model.md#chat)
- [Autocomplete](select-model.md#autocomplete)
- [Embeddings](select-model.md#embeddings)
## Customization Options
Continue offers deep customization through `config.json` and `config.ts` files. These are located in:
- MacOS: `~/.continue/`
- Windows: `%userprofile%\.continue`
You can customize:
1. [Basic Configuration](configuration.md)
2. [Model Providers](model-providers.md)
3. [Model Selection](select-model.md)
4. [Context Providers](../customization/context-providers.md)
5. [Slash Commands](../customization/slash-commands.md)
6. [Advanced Options](../reference/config.mdx)
## Sharing Your Configuration
To share your Continue setup with a team:
1. Create a `.continuerc.json` file in your project's root directory.
2. Use the same JSON Schema as `config.json`.
3. This file will automatically apply on top of the local `config.json`.
Get started with Continue today and shape it to fit your coding workflow perfectly!

View file

@ -49,7 +49,7 @@ On JetBrains, the "pre-release" happens through their Early Access Program (EAP)
1. Open JetBrains settings (cmd/ctrl+,) and go to "Plugins"
2. Click the gear icon at the top
3. Select "Manage Plugin Repositories..."
4. Add "https://plugins.jetbrains.com/plugins/eap/list" to the list
4. Add "[https://plugins.jetbrains.com/plugins/eap/list>](https://plugins.jetbrains.com/plugins/eap/list>)" to the list
5. You'll now always be able to download the latest EAP version from the marketplace
## Download an Older Version
@ -108,6 +108,12 @@ By default the Continue window is on the left side of VS Code, but it can be dra
If you have entered a valid API key and model, but are still getting a 404 error from OpenAI, this may be because you need to add credits to your billing account. You can do so from the [billing console](https://platform.openai.com/settings/organization/billing/overview). If you just want to check that this is in fact the cause of the error, you can try adding $1 to your account and checking whether the error persists.
### Indexing issues
If you are having persistent errors with indexing, our recommendation is to rebuild your index from scratch. Note that for large codebases this may take some time.
This can be accomplished using the following command: `Continue: Rebuild codebase index`.
## Still having trouble?
Create a GitHub issue [here](https://github.com/continuedev/continue/issues/new?assignees=&labels=bug&projects=&template=bug-report-%F0%9F%90%9B.md&title=), leaving the details of your problem, and we'll be able to more quickly help you out.

91
docs/package-lock.json generated
View file

@ -19,7 +19,8 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.2.1"
"@docusaurus/module-type-aliases": "^3.2.1",
"nodemon": "^3.1.4"
},
"engines": {
"node": ">=20.11.0"
@ -7534,6 +7535,12 @@
"node": ">= 4"
}
},
"node_modules/ignore-by-default": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
"integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
"dev": true
},
"node_modules/image-size": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/image-size/-/image-size-1.1.1.tgz",
@ -10569,6 +10576,55 @@
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
"integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw=="
},
"node_modules/nodemon": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz",
"integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==",
"dev": true,
"dependencies": {
"chokidar": "^3.5.2",
"debug": "^4",
"ignore-by-default": "^1.0.1",
"minimatch": "^3.1.2",
"pstree.remy": "^1.1.8",
"semver": "^7.5.3",
"simple-update-notifier": "^2.0.0",
"supports-color": "^5.5.0",
"touch": "^3.1.0",
"undefsafe": "^2.0.5"
},
"bin": {
"nodemon": "bin/nodemon.js"
},
"engines": {
"node": ">=10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nodemon"
}
},
"node_modules/nodemon/node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"engines": {
"node": ">=4"
}
},
"node_modules/nodemon/node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@ -11739,6 +11795,12 @@
"node": ">= 0.10"
}
},
"node_modules/pstree.remy": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
"dev": true
},
"node_modules/punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
@ -13057,6 +13119,18 @@
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
},
"node_modules/simple-update-notifier": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
"integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
"dev": true,
"dependencies": {
"semver": "^7.5.3"
},
"engines": {
"node": ">=10"
}
},
"node_modules/sirv": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
@ -13628,6 +13702,15 @@
"node": ">=6"
}
},
"node_modules/touch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
"integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
"dev": true,
"bin": {
"nodetouch": "bin/nodetouch.js"
}
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
@ -13714,6 +13797,12 @@
"node": ">=14.17"
}
},
"node_modules/undefsafe": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
"dev": true
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",

View file

@ -5,7 +5,7 @@
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"start": "nodemon --watch sidebars.js --exec 'docusaurus start'",
"build": "docusaurus build",
"build:netlify": "docusaurus build --out-dir build/docs",
"swizzle": "docusaurus swizzle",
@ -27,7 +27,8 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.2.1"
"@docusaurus/module-type-aliases": "^3.2.1",
"nodemon": "^3.1.4"
},
"browserslist": {
"production": [
@ -45,4 +46,4 @@
"engines": {
"node": ">=20.11.0"
}
}
}

View file

@ -31,25 +31,24 @@ const sidebars = {
},
{
type: "category",
label: "🎨 Customization",
collapsible: true,
collapsed: true,
items: [
"customization/overview",
"customization/context-providers",
"customization/slash-commands",
],
},
{
type: "category",
label: "🪄 Features",
label: "⭐ Features",
collapsible: true,
collapsed: true,
items: [
"features/codebase-embeddings",
"features/tab-autocomplete",
"features/prompt-files",
"features/quick-actions",
"customization/context-providers",
"customization/slash-commands",
{
type: "doc",
id: "features/prompt-files",
label: "Prompt Files (experimental)",
},
{
type: "doc",
id: "features/quick-actions",
label: "Quick Actions (experimental)",
},
],
},
{

View file

@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension
pluginName = continue-intellij-extension
pluginRepositoryUrl = https://github.com/continuedev/continue
# SemVer format -> https://semver.org
pluginVersion = 0.0.59
pluginVersion = 0.0.60
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223

View file

@ -174,7 +174,7 @@
{
"command": "continue.debugTerminal",
"category": "Continue",
"title": "Continue: Debug Terminal",
"title": "Debug Terminal",
"group": "Continue"
},
{
@ -199,7 +199,7 @@
{
"command": "continue.selectFilesAsContext",
"category": "Continue",
"title": "Continue: Select Files as Context",
"title": "Select Files as Context",
"group": "Continue"
},
{
@ -252,6 +252,12 @@
"title": "Codebase Force Re-Index",
"group": "Continue"
},
{
"command": "continue.rebuildCodebaseIndex",
"category": "Continue",
"title": "Rebuild codebase index",
"group": "Continue"
},
{
"command": "continue.docsIndex",
"category": "Continue",
@ -276,11 +282,6 @@
"mac": "cmd+shift+l",
"key": "ctrl+shift+l"
},
{
"command": "continue.toggleAuxiliaryBar",
"mac": "alt+cmd+l",
"key": "alt+ctrl+l"
},
{
"command": "continue.acceptDiff",
"mac": "shift+cmd+enter",

View file

@ -284,12 +284,12 @@ const commandsMap: (
streamInlineEdit("docstring", prompt, false, range);
},
"continue.toggleAuxiliaryBar": () => {
vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar");
},
"continue.codebaseForceReIndex": async () => {
core.invoke("index/forceReIndex", undefined);
},
"continue.rebuildCodebaseIndex": async () => {
core.invoke("index/forceReIndex", { shouldClearIndexes: true });
},
"continue.docsIndex": async () => {
core.invoke("context/indexDocs", { reIndex: false });
},

View file

@ -293,7 +293,7 @@ export class VsCodeExtension {
currentBranch !== this.PREVIOUS_BRANCH_FOR_WORKSPACE_DIR[dir]
) {
// Trigger refresh of index only in this directory
this.core.invoke("index/forceReIndex", dir);
this.core.invoke("index/forceReIndex", { dir });
}
}

View file

@ -36,7 +36,7 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
return (
<div className="p-4">
<h3>{props.title ?? "Confirmation"}</h3>
<p>{props.text}</p>
<p style={{ whiteSpace: "pre-wrap" }}>{props.text}</p>
<GridDiv>
{!!props.hideCancelButton || (

View file

@ -2,13 +2,19 @@ import { IndexingProgressUpdate } from "core";
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
import { useContext, useEffect, useState } from "react";
import ReactDOM from "react-dom";
import { useSelector } from "react-redux";
import { useSelector, useDispatch } from "react-redux";
import styled from "styled-components";
import { StyledTooltip, lightGray, vscForeground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { RootState } from "../../redux/store";
import { getFontSize, isJetBrains } from "../../util";
import StatusDot from "./StatusDot";
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
import {
setDialogMessage,
setShowDialog,
} from "../../redux/slices/uiStateSlice";
import { usePostHog } from "posthog-js/react";
const STATUS_COLORS = {
DISABLED: lightGray, // light gray
@ -69,16 +75,36 @@ interface ProgressBarProps {
const IndexingProgressBar = ({
indexingState: indexingStateProp,
}: ProgressBarProps) => {
const dispatch = useDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const posthog = usePostHog();
const [paused, setPaused] = useState<boolean | undefined>(undefined);
const [hovered, setHovered] = useState(false);
const embeddingsProvider = useSelector(
(state: RootState) => state.state.config.embeddingsProvider,
);
// If sidebar is opened before extension initiates, define a default indexingState
const defaultIndexingState: IndexingProgressUpdate = {
status: "loading",
progress: 0,
desc: "",
};
const indexingState = indexingStateProp || defaultIndexingState;
const fillPercentage = Math.min(
100,
Math.max(0, indexingState.progress * 100),
);
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
// 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
@ -87,58 +113,79 @@ const IndexingProgressBar = ({
}
}, []);
const fillPercentage = Math.min(
100,
Math.max(0, indexingState.progress * 100),
);
const ideMessenger = useContext(IdeMessengerContext);
const embeddingsProvider = useSelector(
(state: RootState) => state.state.config.embeddingsProvider,
);
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
const [paused, setPaused] = useState<boolean | undefined>(undefined);
const [hovered, setHovered] = useState(false);
useEffect(() => {
if (paused === undefined) return;
ideMessenger.post("index/setPaused", paused);
}, [paused]);
function onClick() {
switch (indexingState.status) {
case "failed":
if (indexingState.shouldClearIndexes) {
dispatch(setShowDialog(true));
dispatch(
setDialogMessage(
<ConfirmationDialog
title="Rebuild codebase index"
confirmText="Rebuild"
text={
"Your index appears corrupted. We recommend clearing and rebuilding it, " +
"which may take time for large codebases.\n\n" +
"Alternatively, you can close this and use the 'Continue: Force Codebase Re-Indexing' " +
"command to attempt a faster rebuild without clearing data, though it may be " +
"less reliable for persistent issues."
}
onConfirm={() => {
posthog.capture("rebuild_index_clicked");
ideMessenger.post("index/forceReIndex", {
shouldClearIndexes: true,
});
}}
/>,
),
);
} else {
ideMessenger.post("index/forceReIndex", undefined);
}
break;
case "indexing":
case "paused":
if (indexingState.progress < 1 && indexingState.progress >= 0) {
setPaused((prev) => !prev);
} else {
ideMessenger.post("index/forceReIndex", undefined);
}
break;
default:
ideMessenger.post("index/forceReIndex", undefined);
break;
}
}
function getIndexingErrMsg(msg: string): string {
if (
isJetBrains() &&
embeddingsProvider === TransformersJsEmbeddingsProvider.model
) {
return "The 'transformers.js' embeddingsProvider is currently unsupported in JetBrains. To enable codebase indexing, you can use any of the other providers described in the docs: https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers";
return (
"The 'transformers.js' embeddingsProvider is currently unsupported in JetBrains. " +
"To enable codebase indexing, you can use any of the other providers described " +
"in the docs: https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers"
);
}
return msg;
}
return (
<div
onClick={() => {
if (
indexingState.status !== "failed" &&
indexingState.progress < 1 &&
indexingState.progress >= 0
) {
setPaused((prev) => !prev);
} else {
ideMessenger.post("index/forceReIndex", undefined);
}
}}
className="cursor-pointer"
>
<div onClick={onClick} className="cursor-pointer">
{indexingState.status === "failed" ? (
<FlexDiv data-tooltip-id="indexingFailed_dot">
<StatusDot color={STATUS_COLORS.FAILED}></StatusDot>
<div>
<StatusHeading>Indexing error - click to retry</StatusHeading>
{/* <StatusInfo>{getIndexingErrMsg(indexingState.desc)}</StatusInfo> */}
</div>
{tooltipPortalDiv &&
ReactDOM.createPortal(

View file

@ -26,5 +26,5 @@ export const selectContextProviderDescriptions = createSelector(
export const selectUseActiveFile = createSelector(
[(store: RootState) => store.state.config.experimental?.defaultContext],
(defaultContext) => defaultContext?.includes("activeFile"),
(defaultContext) => defaultContext?.includes("activeFile" as any),
);