feat: include recently + open files in codebase search (#1833)

* feat: include recently + open files in codebase search

* cleanup

* Update BaseRetrievalPipeline.ts

* add params object to chunkDocument

* Update package-lock.json
This commit is contained in:
Patrick Erichsen 2024-07-26 10:40:52 -07:00 • committed by GitHub
parent 7cb15acfe2
commit 3e0fae35a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 13767 additions and 2019 deletions

14
.vscode/settings.json vendored
View file

@ -7,10 +7,14 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"args": ["-l"]
}
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"args": ["-l"]
}
},
"search.exclude": {
"./binary": true,
"**/core/vendor/**": true
}
}

View file

@ -1,11 +1,11 @@
import { IDE } from "..";
import { RangeInFileWithContents } from "../commands/util";
import { PrecalculatedLruCache } from "../util/LruCache";
import { IDE } from "../index.js";
import { RangeInFileWithContents } from "../commands/util.js";
import { PrecalculatedLruCache } from "../util/LruCache.js";
import {
TSQueryType,
getParserForFile,
getQueryForFile,
} from "../util/treeSitter";
} from "../util/treeSitter.js";
interface FileInfo {
imports: { [key: string]: RangeInFileWithContents[] };

View file

@ -361,13 +361,21 @@ async function intermediateToFinalConfig(
new CodebaseContextProvider({}),
];
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
({ description: { title } }) => title,
);
// Context providers
const contextProviders: IContextProvider[] = DEFAULT_CONTEXT_PROVIDERS;
for (const provider of config.contextProviders || []) {
if (isContextProviderWithParams(provider)) {
const cls = contextProviderClassFromName(provider.name) as any;
if (!cls) {
console.warn(`Unknown context provider ${provider.name}`);
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(provider.name)) {
console.warn(`Unknown context provider ${provider.name}`);
}
continue;
}
const instance: IContextProvider = new cls(provider.params);

View file

@ -4,9 +4,12 @@ import {
EmbeddingsProvider,
IDE,
Reranker,
} from "../../..";
import { LanceDbIndex } from "../../../indexing/LanceDbIndex";
import { retrieveFts } from "../fullTextSearch";
} from "../../../index.js";
import { chunkDocument } from "../../../indexing/chunk/chunk.js";
import { LanceDbIndex } from "../../../indexing/LanceDbIndex.js";
import { MAX_CHUNK_SIZE } from "../../../llm/constants.js";
import { retrieveFts } from "../fullTextSearch.js";
import { recentlyEditedFilesCache } from "../recentlyEditedFilesCache.js";
export interface RetrievalPipelineOptions {
ide: IDE;
@ -32,6 +35,43 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
);
}
protected async retrieveAndChunkRecentlyEditedFiles(
n: number,
): Promise<Chunk[]> {
const recentlyEditedFilesSlice = Array.from(
recentlyEditedFilesCache.keys(),
).slice(0, n);
// If the number of recently edited files is less than the retrieval limit,
// include additional open files. This is useful in the case where a user
// has many tabs open and reloads their IDE. They now have 0 recently edited files,
// but many open tabs that represent what they were working on prior to reload.
if (recentlyEditedFilesSlice.length < n) {
const openFiles = await this.options.ide.getOpenFiles();
recentlyEditedFilesSlice.push(
...openFiles.slice(0, n - recentlyEditedFilesSlice.length),
);
}
const chunks: Chunk[] = [];
for (const filepath of recentlyEditedFilesSlice) {
const contents = await this.options.ide.readFile(filepath);
const fileChunks = chunkDocument({
filepath,
contents,
maxChunkSize: MAX_CHUNK_SIZE,
digest: filepath,
});
for await (const chunk of fileChunks) {
chunks.push(chunk);
}
}
return chunks;
}
protected async retrieveFts(input: string, n: number): Promise<Chunk[]> {
return retrieveFts(
input,

View file

@ -1,26 +1,38 @@
import { Chunk } from "../../..";
import { deduplicateChunks } from "../util";
import BaseRetrievalPipeline from "./BaseRetrievalPipeline";
import { Chunk } from "../../../index.js";
import { deduplicateChunks } from "../util.js";
import BaseRetrievalPipeline from "./BaseRetrievalPipeline.js";
export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
async run(): Promise<Chunk[]> {
const { input } = this.options;
const { input, nFinal } = this.options;
// We give 1/4 weight to recently edited files, 1/4 to full text search,
// and the remaining 1/2 to embeddings
const recentlyEditedNFinal = nFinal * 0.25;
const ftsNFinal = nFinal * 0.25;
const embeddingsNFinal = nFinal - recentlyEditedNFinal - ftsNFinal;
// Get all retrieval results
const retrievalResults: Chunk[] = [];
// Full-text search
const ftsResults = await this.retrieveFts(input, this.options.nFinal / 2);
retrievalResults.push(...ftsResults);
const ftsChunks = await this.retrieveFts(input, ftsNFinal);
// Embeddings
const embeddingResults = await this.retrieveEmbeddings(
const embeddingsChunks = await this.retrieveEmbeddings(
input,
this.options.nFinal / 2,
embeddingsNFinal,
);
retrievalResults.push(...embeddingResults);
const finalResults: Chunk[] = deduplicateChunks(retrievalResults);
return finalResults;
const recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(recentlyEditedNFinal);
retrievalResults.push(
...recentlyEditedFilesChunks,
...ftsChunks,
...embeddingsChunks,
);
const deduplicatedRetrievalResults: Chunk[] =
deduplicateChunks(retrievalResults);
return deduplicatedRetrievalResults;
}
}

View file

@ -1,27 +1,30 @@
import { Chunk } from "../../..";
import { RETRIEVAL_PARAMS } from "../../../util/parameters";
import { deduplicateChunks } from "../util";
import BaseRetrievalPipeline from "./BaseRetrievalPipeline";
import { Chunk } from "../../../index.js";
import { RETRIEVAL_PARAMS } from "../../../util/parameters.js";
import { recentlyEditedFilesCache } from "../recentlyEditedFilesCache.js";
import { deduplicateChunks } from "../util.js";
import BaseRetrievalPipeline from "./BaseRetrievalPipeline.js";
export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
private async _retrieveInitial(): Promise<Chunk[]> {
const { input, nRetrieve } = this.options;
// Get all retrieval results
const retrievalResults: Chunk[] = [];
// Full-text search
const ftsResults = await this.retrieveFts(input, nRetrieve / 2);
retrievalResults.push(...ftsResults);
const ftsChunks = await this.retrieveFts(input, nRetrieve);
const embeddingsChunks = await this.retrieveEmbeddings(input, nRetrieve);
const recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(nRetrieve);
// Embeddings
const embeddingResults = await this.retrieveEmbeddings(input, nRetrieve);
retrievalResults.push(
...embeddingResults.slice(0, nRetrieve - ftsResults.length),
...recentlyEditedFilesChunks,
...ftsChunks,
...embeddingsChunks,
);
const results: Chunk[] = deduplicateChunks(retrievalResults);
return results;
const deduplicatedRetrievalResults: Chunk[] =
deduplicateChunks(retrievalResults);
return deduplicatedRetrievalResults;
}
private async _rerank(input: string, chunks: Chunk[]): Promise<Chunk[]> {
@ -74,12 +77,8 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
}
async run(): Promise<Chunk[]> {
// Retrieve initial results
let results = await this._retrieveInitial();
// Rerank
const { input } = this.options;
results = await this._rerank(input, results);
const intialResults = await this._retrieveInitial();
const rankedResults = await this._rerank(this.options.input, intialResults);
// // // Expand top reranked results
// const expanded = await this._expandRankedResults(results);
@ -93,7 +92,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
// TODO: stitch together results
return results;
return rankedResults;
}
}

View file

@ -0,0 +1,15 @@
import QuickLRU from "quick-lru";
import { ToWebviewOrCoreFromIdeProtocol } from "../../protocol/ide.js";
// The cache key and value are both a filepath string
export type RecentlyEditedFilesCacheKeyAndValue =
ToWebviewOrCoreFromIdeProtocol["didChangeActiveTextEditor"][0]["filepath"];
const MAX_NUM_RECENTLY_EDITED_FILES = 100;
export const recentlyEditedFilesCache = new QuickLRU<
RecentlyEditedFilesCacheKeyAndValue,
RecentlyEditedFilesCacheKeyAndValue
>({
maxSize: MAX_NUM_RECENTLY_EDITED_FILES,
});

View file

@ -3,11 +3,12 @@ import {
ContextItem,
ContextProviderExtras,
} from "../../index.js";
import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider.js";
import { getRelativePath } from "../../util/index.js";
import { RetrievalPipelineOptions } from "./pipelines/BaseRetrievalPipeline.js";
import NoRerankerRetrievalPipeline from "./pipelines/NoRerankerRetrievalPipeline.js";
import RerankerRetrievalPipeline from "./pipelines/RerankerRetrievalPipeline.js";
import { recentlyEditedFilesCache } from "./recentlyEditedFilesCache.js";
export async function retrieveContextItemsFromEmbeddings(
extras: ContextProviderExtras,
@ -19,27 +20,20 @@ export async function retrieveContextItemsFromEmbeddings(
}
// transformers.js not supported in JetBrains IDEs right now
if (
extras.embeddingsProvider.id === "all-MiniLM-L6-v2" &&
(await extras.ide.getIdeInfo()).ideType === "jetbrains"
) {
const isJetBrainsAndTransformersJs =
extras.embeddingsProvider.id === TransformersJsEmbeddingsProvider.model &&
(await extras.ide.getIdeInfo()).ideType === "jetbrains";
if (isJetBrainsAndTransformersJs) {
throw new Error(
"The transformers.js context provider is not currently supported in JetBrains. " +
"The 'transformers.js' context provider is not currently supported in JetBrains. " +
"For now, you can use Ollama to set up local embeddings, or use our 'free-trial' " +
"embeddings provider. See here to learn more: " +
"https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers",
);
}
// Fill half of the context length, up to a max of 100 snippets
const contextLength = extras.llm.contextLength;
const tokensPerSnippet = 512;
const nFinal =
options?.nFinal ?? Math.min(50, contextLength / tokensPerSnippet / 2);
const useReranking = extras.reranker !== undefined;
const nRetrieve =
useReranking === false ? nFinal : options?.nRetrieve || 2 * nFinal;
// Get tags to retrieve for
const workspaceDirs = await extras.ide.getWorkspaceDirs();
@ -47,6 +41,14 @@ export async function retrieveContextItemsFromEmbeddings(
throw new Error("No workspace directories found");
}
// Fill half of the context length, up to a max of 100 snippets
const contextLength = extras.llm.contextLength;
const tokensPerSnippet = 512;
const nFinal =
options?.nFinal ?? Math.min(50, contextLength / tokensPerSnippet / 2);
const useReranking = !!extras.reranker;
const nRetrieve = useReranking ? options?.nRetrieve || 2 * nFinal : nFinal;
const branches = (await Promise.race([
Promise.all(workspaceDirs.map((dir) => extras.ide.getBranch(dir))),
new Promise((resolve) => {
@ -55,6 +57,7 @@ export async function retrieveContextItemsFromEmbeddings(
}, 500);
}),
])) as string[];
const tags: BranchAndDir[] = workspaceDirs.map((directory, i) => ({
directory,
branch: branches[i],
@ -63,6 +66,7 @@ export async function retrieveContextItemsFromEmbeddings(
const pipelineType = useReranking
? RerankerRetrievalPipeline
: NoRerankerRetrievalPipeline;
const pipelineOptions: RetrievalPipelineOptions = {
nFinal,
nRetrieve,
@ -73,6 +77,7 @@ export async function retrieveContextItemsFromEmbeddings(
ide: extras.ide,
input: extras.fullInput,
};
const pipeline = new pipelineType(pipelineOptions);
const results = await pipeline.run();

View file

@ -17,8 +17,7 @@ import {
import { createNewPromptFile } from "./config/promptFile.js";
import { addModel, addOpenAIKey, deleteModel } from "./config/util.js";
import { ContinueServerClient } from "./continueServer/stubs/client.js";
import { getAuthUrlForTokenPage } from "./control-plane/auth";
import { ControlPlaneClient } from "./control-plane/client";
import { ControlPlaneClient } from "./control-plane/client.js";
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer.js";
import { DocsService } from "./indexing/docs/DocsService.js";
import Ollama from "./llm/llms/Ollama.js";
@ -32,6 +31,8 @@ import type { IMessenger, Message } from "./util/messenger";
import { editConfigJson } from "./util/paths.js";
import { Telemetry } from "./util/posthog.js";
import { streamDiffLines } from "./util/verticalEdit.js";
import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFilesCache.js";
import { getAuthUrlForTokenPage } from "./control-plane/auth/index.js";
export class Core {
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
@ -663,6 +664,10 @@ export class Core {
const url = await getAuthUrlForTokenPage();
return { url };
});
on("didChangeActiveTextEditor", ({ data: { filepath } }) => {
recentlyEditedFilesCache.set(filepath, filepath);
});
}
private indexingCancellationController: AbortController | undefined;
@ -694,10 +699,16 @@ export class Core {
);
if (isJetBrainsAndPreIndexedDocsProvider) {
this.ide.errorPopup(
`${DocsService.preIndexedDocsEmbeddingsProvider.id} cannot be used as an embeddings provider with JetBrains. Please select a different embeddings provider.`,
);
try {
this.ide.errorPopup(
"The 'transformers.js' embeddings provider currently cannot be used to index " +
"documentation in JetBrains. To enable documentation indexing, you can use " +
"any of the other providers described in the docs: " +
"https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers",
);
} catch (error) {
console.error("Failed to show error popup:", error);
}
this.globalContext.update(
"curEmbeddingsProviderId",
curEmbeddingsProviderId,

View file

@ -96,12 +96,12 @@ export class LanceDbIndex implements CodebaseIndex {
let hasEmptyChunks = false;
for await (const chunk of chunkDocument(
items[i].path,
content,
this.embeddingsProvider.maxChunkSize,
items[i].cacheKey,
)) {
for await (const chunk of chunkDocument({
filepath: items[i].path,
contents: content,
maxChunkSize: this.embeddingsProvider.maxChunkSize,
digest: items[i].cacheKey,
})) {
if (chunk.content.length == 0) {
hasEmptyChunks = true;
break;

View file

@ -18,7 +18,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
constructor(
private readonly readFile: (filepath: string) => Promise<string>,
private readonly continueServerClient: IContinueServerClient,
private readonly maxChunkSize: number
private readonly maxChunkSize: number,
) {
this.readFile = readFile;
}
@ -105,12 +105,12 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
const item = results.compute[i];
// Insert chunks
for await (const chunk of chunkDocument(
item.path,
contents[i],
this.maxChunkSize,
item.cacheKey,
)) {
for await (const chunk of chunkDocument({
filepath: item.path,
contents: contents[i],
maxChunkSize: this.maxChunkSize,
digest: item.cacheKey,
})) {
handleChunk(chunk);
}
@ -132,12 +132,12 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
const item = results.addTag[i];
// Insert chunks
for await (const chunk of chunkDocument(
item.path,
addContents[i],
this.maxChunkSize,
item.cacheKey,
)) {
for await (const chunk of chunkDocument({
filepath: item.path,
contents: contents[i],
maxChunkSize: this.maxChunkSize,
digest: item.cacheKey,
})) {
handleChunk(chunk);
}

View file

@ -4,6 +4,13 @@ import { supportedLanguages } from "../../util/treeSitter.js";
import { basicChunker } from "./basic.js";
import { codeChunker } from "./code.js";
export type ChunkDocumentParam = {
filepath: string;
contents: string;
maxChunkSize: number;
digest: string;
};
async function* chunkDocumentWithoutId(
filepath: string,
contents: string,
@ -30,12 +37,12 @@ async function* chunkDocumentWithoutId(
yield* basicChunker(contents, maxChunkSize);
}
export async function* chunkDocument(
filepath: string,
contents: string,
maxChunkSize: number,
digest: string,
): AsyncGenerator<Chunk> {
export async function* chunkDocument({
filepath,
contents,
maxChunkSize,
digest,
}: ChunkDocumentParam): AsyncGenerator<Chunk> {
let index = 0;
for await (const chunkWithoutId of chunkDocumentWithoutId(
filepath,

View file

@ -38,9 +38,12 @@ class EmbeddingsPipeline {
export class TransformersJsEmbeddingsProvider extends BaseEmbeddingsProvider {
static maxGroupSize: number = 4;
static model: string = "all-MiniLM-L6-v2";
constructor() {
super({ model: "all-MiniLM-L6-v2" }, () => Promise.resolve(null));
super({ model: TransformersJsEmbeddingsProvider.model }, () =>
Promise.resolve(null),
);
}
async embed(chunks: string[]) {

25
core/package-lock.json generated
View file

@ -47,6 +47,7 @@
"openai": "^4.20.1",
"pg": "^8.11.3",
"posthog-node": "^3.6.3",
"quick-lru": "^7.0.0",
"replicate": "^0.26.0",
"request": "^2.88.2",
"socket.io-client": "^4.7.3",
@ -56,7 +57,7 @@
"tree-sitter-wasms": "^0.1.11",
"uuid": "^9.0.1",
"vectordb": "^0.4.20",
"web-tree-sitter": "^0.22.0",
"web-tree-sitter": "^0.21.0",
"win-ca": "^3.5.1",
"yaml": "^2.4.2",
"zod": "^3.23.8"
@ -10293,11 +10294,6 @@
"web-tree-sitter": "^0.21.0"
}
},
"node_modules/llm-code-highlighter/node_modules/web-tree-sitter": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.21.0.tgz",
"integrity": "sha512-iJ+QJ6ikN9D9cG7Kh6q3KtAstYFUQbYZ8OjuPEJYWfj2kLrmp5I3C2n6WjE1Y3jvj7nJbkcrJytJGWUEhCxn+g=="
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -11927,6 +11923,17 @@
"resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz",
"integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag=="
},
"node_modules/quick-lru": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-7.0.0.tgz",
"integrity": "sha512-MX8gB7cVYTrYcFfAnfLlhRd0+Toyl8yX8uBx1MrX7K0jegiz9TumwOK27ldXrgDlHRdVi+MqU9Ssw6dr4BNreg==",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
@ -13631,9 +13638,9 @@
}
},
"node_modules/web-tree-sitter": {
"version": "0.22.6",
"resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.22.6.tgz",
"integrity": "sha512-hS87TH71Zd6mGAmYCvlgxeGDjqd9GTeqXNqTT+u0Gs51uIozNIaaq/kUAbV/Zf56jb2ZOyG8BxZs2GG9wbLi6Q=="
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.21.0.tgz",
"integrity": "sha512-iJ+QJ6ikN9D9cG7Kh6q3KtAstYFUQbYZ8OjuPEJYWfj2kLrmp5I3C2n6WjE1Y3jvj7nJbkcrJytJGWUEhCxn+g=="
},
"node_modules/webidl-conversions": {
"version": "7.0.0",

View file

@ -68,6 +68,7 @@
"openai": "^4.20.1",
"pg": "^8.11.3",
"posthog-node": "^3.6.3",
"quick-lru": "^7.0.0",
"replicate": "^0.26.0",
"request": "^2.88.2",
"socket.io-client": "^4.7.3",
@ -77,7 +78,7 @@
"tree-sitter-wasms": "^0.1.11",
"uuid": "^9.0.1",
"vectordb": "^0.4.20",
"web-tree-sitter": "^0.22.0",
"web-tree-sitter": "^0.21.0",
"win-ca": "^3.5.1",
"yaml": "^2.4.2",
"zod": "^3.23.8"

View file

@ -133,6 +133,7 @@
"openai": "^4.20.1",
"pg": "^8.11.3",
"posthog-node": "^3.6.3",
"quick-lru": "^7.0.0",
"replicate": "^0.26.0",
"request": "^2.88.2",
"socket.io-client": "^4.7.3",

View file

@ -320,6 +320,10 @@ export class VsCodeExtension {
documentContentProvider,
),
);
this.ide.onDidChangeActiveTextEditor((filepath) => {
this.core.invoke("didChangeActiveTextEditor", { filepath });
});
}
static continueVirtualDocumentScheme = "continue";

View file

@ -18,7 +18,9 @@ export const currentSuggestion: Map<string, number> = new Map(); // Map from edi
// When tab is reopened, rerender the decorations:
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (!editor) return;
if (!editor) {
return;
}
rerenderDecorations(editor.document.uri.toString());
});
vscode.workspace.onDidOpenTextDocument((doc) => {
@ -57,7 +59,9 @@ export function rerenderDecorations(editorUri: string) {
const editor = vscode.window.visibleTextEditors.find(
(editor) => editor.document.uri.toString() === editorUri,
);
if (!suggestions || !editor) return;
if (!suggestions || !editor) {
return;
}
const rangesWithoutEmptyLastLine = (ranges: vscode.Range[]) => {
const newRanges: vscode.Range[] = [];
@ -116,7 +120,9 @@ export function rerenderDecorations(editorUri: string) {
editor.setDecorations(newSelDecorationType, newSels);
// Reveal the range in the editor
if (idx === undefined) return;
if (idx === undefined) {
return;
}
editor.revealRange(
suggestions[idx].newRange,
vscode.TextEditorRevealType.Default,
@ -129,35 +135,47 @@ export function rerenderDecorations(editorUri: string) {
export function suggestionDownCommand() {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
if (!editor) {
return;
}
const editorUri = editor.document.uri.toString();
const suggestions = editorToSuggestions.get(editorUri);
const idx = currentSuggestion.get(editorUri);
if (!suggestions || idx === undefined) return;
if (!suggestions || idx === undefined) {
return;
}
const suggestion = suggestions[idx];
if (!suggestion.newSelected) {
suggestion.newSelected = true;
} else if (idx + 1 < suggestions.length) {
currentSuggestion.set(editorUri, idx + 1);
} else return;
} else {
return;
}
rerenderDecorations(editorUri);
}
export function suggestionUpCommand() {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
if (!editor) {
return;
}
const editorUri = editor.document.uri.toString();
const suggestions = editorToSuggestions.get(editorUri);
const idx = currentSuggestion.get(editorUri);
if (!suggestions || idx === undefined) return;
if (!suggestions || idx === undefined) {
return;
}
const suggestion = suggestions[idx];
if (suggestion.newSelected) {
suggestion.newSelected = false;
} else if (idx > 0) {
currentSuggestion.set(editorUri, idx - 1);
} else return;
} else {
return;
}
rerenderDecorations(editorUri);
}
@ -167,11 +185,15 @@ function selectSuggestion(
key: SuggestionRanges | null = null,
) {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
if (!editor) {
return;
}
const editorUri = editor.document.uri.toString();
const suggestions = editorToSuggestions.get(editorUri);
if (!suggestions) return;
if (!suggestions) {
return;
}
let idx: number | undefined;
if (key) {
@ -190,7 +212,9 @@ function selectSuggestion(
// Otherwise, use the current suggestion
idx = currentSuggestion.get(editorUri);
}
if (idx === undefined) return;
if (idx === undefined) {
return;
}
const [suggestion] = suggestions.splice(idx, 1);
@ -245,10 +269,14 @@ export function acceptSuggestionCommand(key: SuggestionRanges | null = null) {
function handleAllSuggestions(accept: boolean) {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
if (!editor) {
return;
}
const editorUri = editor.document.uri.toString();
const suggestions = editorToSuggestions.get(editorUri);
if (!suggestions) return;
if (!suggestions) {
return;
}
while (suggestions.length > 0) {
selectSuggestion(accept ? "new" : "old", suggestions[0]);
@ -284,7 +312,9 @@ export async function showSuggestion(
}
const editor = await openEditorAndRevealRange(editorFilename, range);
if (!editor) return Promise.resolve(false);
if (!editor) {
return Promise.resolve(false);
}
return new Promise((resolve, reject) => {
editor!

15395
gui/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
import { RootState } from "../../redux/store";
import { getFontSize, isJetBrains } from "../../util";
import StatusDot from "./StatusDot";
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
const STATUS_COLORS = {
DISABLED: lightGray, // light gray
@ -108,7 +109,10 @@ const IndexingProgressBar = ({
}, [paused]);
function getIndexingErrMsg(msg: string): string {
if (isJetBrains() && embeddingsProvider === "all-MiniLM-L6-v2") {
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 msg;