From 0341c60bdf6dc8d94320217f450046f51ef8895b Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Tue, 3 Dec 2024 14:06:40 +0100 Subject: [PATCH 01/43] Brings support for Bedrock's reranking models --- core/context/rerankers/bedrock.ts | 99 +++++++++++++++++++ core/context/rerankers/index.ts | 4 +- core/index.d.ts | 1 + .../model-providers/top-level/bedrock.md | 14 ++- extensions/vscode/config_schema.json | 27 +++++ 5 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 core/context/rerankers/bedrock.ts diff --git a/core/context/rerankers/bedrock.ts b/core/context/rerankers/bedrock.ts new file mode 100644 index 000000000..071910bd9 --- /dev/null +++ b/core/context/rerankers/bedrock.ts @@ -0,0 +1,99 @@ +import { + BedrockRuntimeClient, + InvokeModelCommand, +} from "@aws-sdk/client-bedrock-runtime"; +import { fromIni } from "@aws-sdk/credential-providers"; +import { Chunk, Reranker, RerankerName } from "../../index.js"; + +export class BedrockReranker implements Reranker { + name: RerankerName = "bedrock"; + + static defaultOptions = { + region: "us-east-1", + model: "amazon.rerank-v1:0", + profile: "bedrock", + }; + + private supportedModels = ["amazon.rerank-v1:0", "cohere.rerank-v3-5:0"]; + + constructor( + private readonly params: { + region?: string; + model?: string; + profile?: string; + } = {}, + ) { + if (params.model && !this.supportedModels.includes(params.model)) { + throw new Error( + `Unsupported model: ${params.model}. Supported models are: ${this.supportedModels.join(", ")}`, + ); + } + } + + async rerank(query: string, chunks: Chunk[]): Promise { + if (!query || !chunks.length) { + throw new Error("Query and chunks must not be empty"); + } + + try { + const credentials = await this._getCredentials(); + const client = new BedrockRuntimeClient({ + region: this.params.region ?? BedrockReranker.defaultOptions.region, + credentials, + }); + + const model = this.params.model ?? BedrockReranker.defaultOptions.model; + + // Base payload for both models + const payload: any = { + query: query, + documents: chunks.map((chunk) => chunk.content), + top_n: chunks.length, + }; + + // Add api_version for Cohere model + if (model.startsWith("cohere.rerank")) { + payload.api_version = 2; + } + + const input = { + body: JSON.stringify(payload), + modelId: model, + accept: "*/*", + contentType: "application/json", + }; + + const command = new InvokeModelCommand(input); + const response = await client.send(command); + + if (!response.body) { + throw new Error("Empty response received from Bedrock"); + } + + const responseBody = JSON.parse(new TextDecoder().decode(response.body)); + + // Sort results by index to maintain original order + return responseBody.results + .sort((a: any, b: any) => a.index - b.index) + .map((result: any) => result.relevance_score); + } catch (error) { + console.error("Error in BedrockReranker.rerank:", error); + throw error; + } + } + + private async _getCredentials() { + try { + const credentials = await fromIni({ + profile: this.params.profile ?? BedrockReranker.defaultOptions.profile, + ignoreCache: true, + })(); + return credentials; + } catch (e) { + console.warn( + `AWS profile with name ${this.params.profile ?? BedrockReranker.defaultOptions.profile} not found in ~/.aws/credentials, using default profile`, + ); + return await fromIni()(); + } + } +} diff --git a/core/context/rerankers/index.ts b/core/context/rerankers/index.ts index 9b1db230d..ba6af849c 100644 --- a/core/context/rerankers/index.ts +++ b/core/context/rerankers/index.ts @@ -1,5 +1,6 @@ import { RerankerName } from "../../index.js"; +import { BedrockReranker } from "./bedrock.js"; import { CohereReranker } from "./cohere.js"; import { ContinueProxyReranker } from "./ContinueProxyReranker.js"; import { FreeTrialReranker } from "./freeTrial.js"; @@ -9,9 +10,10 @@ import { VoyageReranker } from "./voyage.js"; export const AllRerankers: { [key in RerankerName]: any } = { cohere: CohereReranker, + bedrock: BedrockReranker, llm: LLMReranker, voyage: VoyageReranker, "free-trial": FreeTrialReranker, "huggingface-tei": HuggingFaceTEIReranker, "continue-proxy": ContinueProxyReranker, -}; +}; \ No newline at end of file diff --git a/core/index.d.ts b/core/index.d.ts index 34212cfac..b66e00499 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1034,6 +1034,7 @@ export interface EmbeddingsProvider { export type RerankerName = | "cohere" + | "bedrock" | "voyage" | "llm" | "free-trial" diff --git a/docs/docs/customize/model-providers/top-level/bedrock.md b/docs/docs/customize/model-providers/top-level/bedrock.md index 8d46c5ad9..e76f88a77 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.md +++ b/docs/docs/customize/model-providers/top-level/bedrock.md @@ -46,9 +46,19 @@ We recommend configuring [`amazon.titan-embed-text-v2:0`](https://docs.aws.amazo ## Reranking model -Bedrock currently does not offer any reranking models. +We recommend configuring `cohere.rerank-v3-5:0` as your reranking model, you may also use `amazon.titan-embed-text-v2:0`. -[Click here](../../model-types/reranking.md) to see a list of reranking model providers. +```json title="~/.continue/config.json" +{ + "reranker": { + "name": "bedrock", + "params": { + "model": "cohere.rerank-v3-5:0", + "region": "us-west-2" + } + } +} +``` ## Authentication diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 86a9d54a2..36fe771da 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2642,6 +2642,7 @@ "properties": { "name": { "enum": [ + "bedrock", "cohere", "voyage", "llm", @@ -2743,6 +2744,32 @@ } } }, + { + "if": { + "properties": { + "name": { + "enum": ["bedrock"] + } + }, + "required": ["name"] + }, + "then": { + "properties": { + "params": { + "type": "object", + "properties": { + "model": { + "enum": [ + "cohere.rerank-v3-5:0", + "amazon.rerank-v1:0" + ] + } + }, + "required": ["model"] + } + } + } + }, { "if": { "properties": { From 9c3cd49f08a8304435587f68a158c55a3258414f Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Tue, 3 Dec 2024 14:10:25 +0100 Subject: [PATCH 02/43] Wrong model specified in the documentation --- docs/docs/customize/model-providers/top-level/bedrock.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/top-level/bedrock.md b/docs/docs/customize/model-providers/top-level/bedrock.md index e76f88a77..fb88d5ae0 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.md +++ b/docs/docs/customize/model-providers/top-level/bedrock.md @@ -46,7 +46,7 @@ We recommend configuring [`amazon.titan-embed-text-v2:0`](https://docs.aws.amazo ## Reranking model -We recommend configuring `cohere.rerank-v3-5:0` as your reranking model, you may also use `amazon.titan-embed-text-v2:0`. +We recommend configuring `cohere.rerank-v3-5:0` as your reranking model, you may also use `amazon.rerank-v1:0`. ```json title="~/.continue/config.json" { From d431a4645131212ef19f96136708e58ef3966614 Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Wed, 4 Dec 2024 09:40:13 +0100 Subject: [PATCH 03/43] Wrong sorting key used in the reranker --- core/context/rerankers/bedrock.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/context/rerankers/bedrock.ts b/core/context/rerankers/bedrock.ts index 071910bd9..262ef3482 100644 --- a/core/context/rerankers/bedrock.ts +++ b/core/context/rerankers/bedrock.ts @@ -72,10 +72,13 @@ export class BedrockReranker implements Reranker { const responseBody = JSON.parse(new TextDecoder().decode(response.body)); - // Sort results by index to maintain original order - return responseBody.results - .sort((a: any, b: any) => a.index - b.index) - .map((result: any) => result.relevance_score); + // Sort results by relevance_score in descending order + const sortedResults = responseBody.results.sort( + (a: any, b: any) => b.relevance_score - a.relevance_score, + ); + + // Return the sorted relevance scores + return sortedResults.map((result: any) => result.relevance_score); } catch (error) { console.error("Error in BedrockReranker.rerank:", error); throw error; From abbf2fb74c6a0cd509cf4b19358d8dc5bbf9251e Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Wed, 4 Dec 2024 09:49:15 +0100 Subject: [PATCH 04/43] Cancels the last commit --- core/context/rerankers/bedrock.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/context/rerankers/bedrock.ts b/core/context/rerankers/bedrock.ts index 262ef3482..071910bd9 100644 --- a/core/context/rerankers/bedrock.ts +++ b/core/context/rerankers/bedrock.ts @@ -72,13 +72,10 @@ export class BedrockReranker implements Reranker { const responseBody = JSON.parse(new TextDecoder().decode(response.body)); - // Sort results by relevance_score in descending order - const sortedResults = responseBody.results.sort( - (a: any, b: any) => b.relevance_score - a.relevance_score, - ); - - // Return the sorted relevance scores - return sortedResults.map((result: any) => result.relevance_score); + // Sort results by index to maintain original order + return responseBody.results + .sort((a: any, b: any) => a.index - b.index) + .map((result: any) => result.relevance_score); } catch (error) { console.error("Error in BedrockReranker.rerank:", error); throw error; From 2f3121c4b9bcd26dd4ff8d43bce64008594d263a Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Thu, 5 Dec 2024 16:42:14 +0100 Subject: [PATCH 05/43] Fixes #400, a bug that sents chunks too large for the embedding model --- core/indexing/docs/article.ts | 88 +++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index 1bc74c62e..99992b415 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -25,56 +25,74 @@ function breakdownArticleComponent( max_chunk_size: number, ): Chunk[] { const chunks: Chunk[] = []; - - const lines = article.body.split("\n"); + const words = article.body.split(/\s+/); + let currentChunk = ""; let startLine = 0; - let endLine = 0; - let content = ""; let index = 0; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - if (content.length + line.length <= max_chunk_size) { - content += `${line}\n`; - endLine = i; - } else { - chunks.push({ - content: content.trim(), - startLine: startLine, - endLine: endLine, - otherMetadata: { - title: cleanHeader(article.title), - }, - index: index, - filepath: new URL( - `${subpath}#${cleanFragment(article.title)}`, - url, - ).toString(), - digest: subpath, - }); - content = `${line}\n`; - startLine = i; - endLine = i; - index += 1; - } - } - - // Push the last chunk - if (content) { + const createChunk = ( + content: string, + currentStartLine: number, + endLine: number, + ) => { chunks.push({ content: content.trim(), - startLine: startLine, + startLine: currentStartLine, endLine: endLine, otherMetadata: { title: cleanHeader(article.title), }, - index: index, + index: index++, filepath: new URL( `${subpath}#${cleanFragment(article.title)}`, url, ).toString(), digest: subpath, }); + }; + + for (let i = 0; i < words.length; i++) { + const word = words[i]; + + // If a single word is longer than max_chunk_size, split it + if (word.length > max_chunk_size) { + // First, push the current chunk if it has content + if (currentChunk.trim().length > 0) { + createChunk(currentChunk.trim(), startLine, i - 1); + currentChunk = ""; + } + + // Split the long word into smaller pieces + let remainingWord = word; + while (remainingWord.length > 0) { + const chunk = remainingWord.slice(0, max_chunk_size); + createChunk(chunk, i, i); + remainingWord = remainingWord.slice(max_chunk_size); + } + + startLine = i + 1; + continue; + } + + // Check if adding this word would exceed max_chunk_size + if (currentChunk.length + word.length + 1 > max_chunk_size) { + // Push current chunk if it has content + if (currentChunk.trim().length > 0) { + createChunk(currentChunk.trim(), startLine, i - 1); + } + + // Start new chunk with current word + currentChunk = word; + startLine = i; + } else { + // Add word to current chunk + currentChunk = currentChunk.length > 0 ? `${currentChunk} ${word}` : word; + } + } + + // Push the last chunk if it has content + if (currentChunk.trim().length > 0) { + createChunk(currentChunk.trim(), startLine, words.length - 1); } // Don't use small chunks. Probably they're a mistake. Definitely they'll confuse the embeddings model. From f1c7e5ad6b744a419b831afe6bd79ba1f591e9ab Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Thu, 5 Dec 2024 16:56:30 +0100 Subject: [PATCH 06/43] Preserves line breaks on doc chunking --- core/indexing/docs/article.ts | 76 +++++++++++++++++------------------ 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index 99992b415..2ae0e7995 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -25,20 +25,21 @@ function breakdownArticleComponent( max_chunk_size: number, ): Chunk[] { const chunks: Chunk[] = []; - const words = article.body.split(/\s+/); - let currentChunk = ""; + const lines = article.body.split("\n"); let startLine = 0; + let endLine = 0; + let content = ""; let index = 0; const createChunk = ( - content: string, - currentStartLine: number, - endLine: number, + chunkContent: string, + chunkStartLine: number, + chunkEndLine: number, ) => { chunks.push({ - content: content.trim(), - startLine: currentStartLine, - endLine: endLine, + content: chunkContent.trim(), + startLine: chunkStartLine, + endLine: chunkEndLine, otherMetadata: { title: cleanHeader(article.title), }, @@ -51,51 +52,48 @@ function breakdownArticleComponent( }); }; - for (let i = 0; i < words.length; i++) { - const word = words[i]; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; - // If a single word is longer than max_chunk_size, split it - if (word.length > max_chunk_size) { - // First, push the current chunk if it has content - if (currentChunk.trim().length > 0) { - createChunk(currentChunk.trim(), startLine, i - 1); - currentChunk = ""; + // Handle oversized lines by splitting them + if (line.length > max_chunk_size) { + // First push any accumulated content + if (content.trim().length > 0) { + createChunk(content, startLine, endLine); + content = ""; } - // Split the long word into smaller pieces - let remainingWord = word; - while (remainingWord.length > 0) { - const chunk = remainingWord.slice(0, max_chunk_size); - createChunk(chunk, i, i); - remainingWord = remainingWord.slice(max_chunk_size); + // Split the long line into chunks + let remainingLine = line; + let subLineStart = i; + while (remainingLine.length > 0) { + const chunk = remainingLine.slice(0, max_chunk_size); + createChunk(chunk, subLineStart, i); + remainingLine = remainingLine.slice(max_chunk_size); } - startLine = i + 1; continue; } - // Check if adding this word would exceed max_chunk_size - if (currentChunk.length + word.length + 1 > max_chunk_size) { - // Push current chunk if it has content - if (currentChunk.trim().length > 0) { - createChunk(currentChunk.trim(), startLine, i - 1); - } - - // Start new chunk with current word - currentChunk = word; - startLine = i; + // Normal line handling + if (content.length + line.length + 1 <= max_chunk_size) { + content += `${line}\n`; + endLine = i; } else { - // Add word to current chunk - currentChunk = currentChunk.length > 0 ? `${currentChunk} ${word}` : word; + if (content.trim().length > 0) { + createChunk(content, startLine, endLine); + } + content = `${line}\n`; + startLine = i; + endLine = i; } } - // Push the last chunk if it has content - if (currentChunk.trim().length > 0) { - createChunk(currentChunk.trim(), startLine, words.length - 1); + // Push the last chunk + if (content.trim().length > 0) { + createChunk(content, startLine, endLine); } - // Don't use small chunks. Probably they're a mistake. Definitely they'll confuse the embeddings model. return chunks.filter((c) => c.content.trim().length > 20); } From 5e46f83f06d9611be541805c377b3231578afe45 Mon Sep 17 00:00:00 2001 From: Annoying Technology Date: Thu, 5 Dec 2024 16:58:10 +0100 Subject: [PATCH 07/43] Adds the support for bedrock reranking in the reference documentation --- docs/docs/reference.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 0a5c02aad..df3f08e75 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -206,10 +206,11 @@ Configuration for the reranker model used in response ranking. **Properties:** -- `name` (**required**): Reranker name, e.g., `cohere`, `voyage`, `llm`, `free-trial`, `huggingface-tei` +- `name` (**required**): Reranker name, e.g., `cohere`, `voyage`, `llm`, `free-trial`, `huggingface-tei`, `bedrock` - `params`: - `model`: Model name - `apiKey`: Api key + - `region`: Region (for Bedrock only) Example From 2b611df53ba716c2b550ab3b275c571eed9d2c65 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 5 Dec 2024 13:06:40 -0800 Subject: [PATCH 08/43] fix: disable completions in the commit box --- extensions/vscode/src/autocomplete/completionProvider.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index 5d6faef3f..f9d397388 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -101,6 +101,10 @@ export class ContinueCompletionProvider return null; } + if (document.uri.scheme === "vscode-scm") { + return null; + } + // If the text at the range isn't a prefix of the intellisense text, // no completion will be displayed, regardless of what we return if ( From 16571200fd6bc4469ee6bbd8018979a61a04ab89 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Dec 2024 15:17:07 -0800 Subject: [PATCH 09/43] Update context-providers.md --- docs/docs/customize/context-providers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/context-providers.md b/docs/docs/customize/context-providers.md index 2c7708cac..024786e14 100644 --- a/docs/docs/customize/context-providers.md +++ b/docs/docs/customize/context-providers.md @@ -444,7 +444,7 @@ Available connection types: ### `@Debugger` -Reference the contents of the local variables in the debugger. +Reference the contents of the local variables in the debugger. Currently only available in VS Code. ```json title="config.json" { From 7e466e73acf84b2aa1fd51341fbdb6c995d398dc Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Dec 2024 16:02:17 -0800 Subject: [PATCH 10/43] bugfix: use correct config.json when applying --- .../continue/IdeProtocolClient.kt | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 6dccf7f08..d0f0da761 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -51,6 +51,7 @@ import java.net.NetworkInterface import java.nio.charset.Charset import java.nio.file.Paths import java.util.* +import kotlin.coroutines.resume fun uuid(): String { @@ -106,7 +107,9 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) : for (event in events) { if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith( ".continue\\config.json" - ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json") + ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith( + ".continuerc.json" + ) ) { return object : AsyncFileListener.ChangeApplier { override fun afterVfsChange() { @@ -662,18 +665,41 @@ class IdeProtocolClient( var llm = getModelByRole(config, "applyCodeBlock") if (llm == null) { - val models = (config as? Map<*, *>)?.get("models") as? List> - llm = models?.find { model -> model["title"] == curSelectedModelTitle } as Map + llm = try { + suspendCancellableCoroutine { continuation -> + continuePluginService.coreMessenger?.request( + "config/getSerializedProfileInfo", + null, + null + ) { response -> + val models = + ((response as Map)["config"] as Map)["models"] as List> + val foundModel = models.find { it["title"] == curSelectedModelTitle } - if (llm == null) { - showToast("error", "Model '$curSelectedModelTitle' not found in config.") + if (foundModel == null) { + launch { + showToast( + "error", + "Model '$curSelectedModelTitle' not found in config." + ) + } + continuation.resume(null) + } else { + continuation.resume(foundModel) + } + } + } + } catch (e: Exception) { + launch { showToast("error", "Failed to fetch model configuration") } respond(null) return@launch } } + val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: "" + val prompt = "The following code was suggested as an edit:\n```\n${text}\n```\nPlease apply it to the previous code." From fd513edf96dbeb680d40cd12d5f30d09735df486 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 5 Dec 2024 18:15:07 -0800 Subject: [PATCH 11/43] fix lag --- extensions/vscode/package-lock.json | 6 +- gui/package-lock.json | 2 +- gui/src/context/IdeMessenger.ts | 30 ++-- gui/src/redux/slices/sessionSlice.ts | 134 +++++++++--------- gui/src/redux/thunks/streamNormalInput.ts | 11 +- .../thunks/streamResponseAfterToolCall.ts | 4 +- gui/src/redux/thunks/streamSlashCommand.ts | 17 ++- 7 files changed, 109 insertions(+), 95 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 9de97f4ac..923f4c9b5 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.243", + "version": "0.9.244", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.243", + "version": "0.9.244", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -115,7 +115,7 @@ "comment-json": "^4.2.3", "dbinfoz": "^0.14.0", "diff": "^7.0.0", - "dotenv": "^16.4.7", + "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", diff --git a/gui/package-lock.json b/gui/package-lock.json index af3d5cafa..91410e6df 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -121,7 +121,7 @@ "comment-json": "^4.2.3", "dbinfoz": "^0.14.0", "diff": "^7.0.0", - "dotenv": "^16.4.7", + "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index bddd3fbbe..fbbfc21b1 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -37,14 +37,14 @@ export interface IIdeMessenger { messageType: T, data: FromWebviewProtocol[T][0], cancelToken?: AbortSignal, - ): FromWebviewProtocol[T][1]; + ): AsyncGenerator; llmStreamChat( modelTitle: string, cancelToken: AbortSignal | undefined, messages: ChatMessage[], options?: LLMFullCompletionOptions, - ): AsyncGenerator; + ): AsyncGenerator; ide: IDE; } @@ -147,11 +147,20 @@ export class IdeMessenger implements IIdeMessenger { }); } + /** + * Because of weird type stuff, we're actually yielding an array of the things + * that are streamed. For example, if the return type here says + * AsyncGenerator, then it's actually AsyncGenerator. + * This needs to be handled by the caller. + * + * Using unknown for now to make this more explicit + */ async *streamRequest( messageType: T, data: FromWebviewProtocol[T][0], cancelToken?: AbortSignal, - ): FromWebviewProtocol[T][1] { + ): AsyncGenerator { + // ): FromWebviewProtocol[T][1] { const messageId = uuidv4(); this.post(messageType, data, messageId); @@ -181,17 +190,16 @@ export class IdeMessenger implements IIdeMessenger { while (!done) { if (buffer.length > index) { - const chunk = buffer[index]; - index++; - yield chunk; + const chunks = buffer.slice(index); + index = buffer.length; + yield chunks; } await new Promise((resolve) => setTimeout(resolve, 50)); } - while (buffer.length > index) { - const chunk = buffer[index]; - index++; - yield chunk; + if (buffer.length > index) { + const chunks = buffer.slice(index); + yield chunks; } return returnVal; @@ -202,7 +210,7 @@ export class IdeMessenger implements IIdeMessenger { cancelToken: AbortSignal | undefined, messages: ChatMessage[], options: LLMFullCompletionOptions = {}, - ): AsyncGenerator { + ): AsyncGenerator { const gen = this.streamRequest( "llm/streamChat", { diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 46e9e21f5..1b6f4d7f4 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -10,21 +10,21 @@ import { ApplyState, ChatHistoryItem, ChatMessage, + CodeToEdit, + ContextItem, ContextItemWithId, FileSymbolMap, - Session, - PromptLog, - CodeToEdit, - ToolCall, - ContextItem, MessageModes, + PromptLog, + Session, + ToolCall, } from "core"; import { incrementalParseJson } from "core/util/incrementalParseJson"; import { renderChatMessage } from "core/util/messageContent"; import { v4 as uuidv4 } from "uuid"; +import { RootState } from "../store"; import { streamResponseThunk } from "../thunks/streamResponse"; import { findCurrentToolCall } from "../util"; -import { RootState } from "../store"; // We need this to handle reorderings (e.g. a mid-array deletion) of the messages array. // The proper fix is adding a UUID to all chat messages, but this is the temp workaround. @@ -284,72 +284,74 @@ export const sessionSlice = createSlice({ state.streamAborter.abort(); state.streamAborter = new AbortController(); }, - streamUpdate: (state, action: PayloadAction) => { + streamUpdate: (state, action: PayloadAction) => { if (state.history.length) { - const lastMessage = state.history[state.history.length - 1]; + for (const message of action.payload) { + const lastMessage = state.history[state.history.length - 1]; - if ( - action.payload.role && - (lastMessage.message.role !== action.payload.role || - // This is when a tool call comes after assistant text - (lastMessage.message.content !== "" && - action.payload.role === "assistant" && - action.payload.toolCalls?.length)) - ) { - const baseHistoryItem = getBaseHistoryItem(); - - // Create a new message - const historyItem: ChatHistoryItemWithMessageId = { - ...baseHistoryItem, - message: { ...baseHistoryItem.message, ...action.payload }, - }; - - if (action.payload.role === "assistant" && action.payload.toolCalls) { - const [_, parsedArgs] = incrementalParseJson( - action.payload.toolCalls[0].function.arguments, - ); - historyItem.toolCallState = { - status: "generating", - toolCall: action.payload.toolCalls[0] as ToolCall, - toolCallId: action.payload.toolCalls[0].id, - parsedArgs, - }; - } - - state.history.push(historyItem); - } else { - // Add to the existing message - const msg = state.history[state.history.length - 1].message; - if (action.payload.content) { - msg.content += renderChatMessage(action.payload); - } else if ( - action.payload.role === "assistant" && - action.payload.toolCalls && - msg.role === "assistant" + if ( + message.role && + (lastMessage.message.role !== message.role || + // This is when a tool call comes after assistant text + (lastMessage.message.content !== "" && + message.role === "assistant" && + message.toolCalls?.length)) ) { - if (!msg.toolCalls) { - msg.toolCalls = []; + const baseHistoryItem = getBaseHistoryItem(); + + // Create a new message + const historyItem: ChatHistoryItemWithMessageId = { + ...baseHistoryItem, + message: { ...baseHistoryItem.message, ...message }, + }; + + if (message.role === "assistant" && message.toolCalls) { + const [_, parsedArgs] = incrementalParseJson( + message.toolCalls[0].function.arguments, + ); + historyItem.toolCallState = { + status: "generating", + toolCall: message.toolCalls[0] as ToolCall, + toolCallId: message.toolCalls[0].id, + parsedArgs, + }; } - action.payload.toolCalls.forEach((toolCall, i) => { - if (msg.toolCalls.length <= i) { - msg.toolCalls.push(toolCall); - } else { - msg.toolCalls[i].function.arguments += - toolCall.function.arguments; - const [_, parsedArgs] = incrementalParseJson( - msg.toolCalls[i].function.arguments, - ); - - state.history[ - state.history.length - 1 - ].toolCallState.parsedArgs = parsedArgs; - state.history[ - state.history.length - 1 - ].toolCallState.toolCall.function.arguments += - toolCall.function.arguments; + state.history.push(historyItem); + } else { + // Add to the existing message + const msg = state.history[state.history.length - 1].message; + if (message.content) { + msg.content += renderChatMessage(message); + } else if ( + message.role === "assistant" && + message.toolCalls && + msg.role === "assistant" + ) { + if (!msg.toolCalls) { + msg.toolCalls = []; } - }); + message.toolCalls.forEach((toolCall, i) => { + if (msg.toolCalls.length <= i) { + msg.toolCalls.push(toolCall); + } else { + msg.toolCalls[i].function.arguments += + toolCall.function.arguments; + + const [_, parsedArgs] = incrementalParseJson( + msg.toolCalls[i].function.arguments, + ); + + state.history[ + state.history.length - 1 + ].toolCallState.parsedArgs = parsedArgs; + state.history[ + state.history.length - 1 + ].toolCallState.toolCall.function.arguments += + toolCall.function.arguments; + } + }); + } } } } diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 3c3c49222..5a22a36b5 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -1,6 +1,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ChatMessage, PromptLog } from "core"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; +import { selectDefaultModel } from "../slices/configSlice"; import { abortStream, addPromptCompletionPair, @@ -10,7 +11,6 @@ import { } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; import { callTool } from "./callTool"; -import { selectDefaultModel } from "../slices/configSlice"; export const streamNormalInput = createAsyncThunk< void, @@ -56,14 +56,9 @@ export const streamNormalInput = createAsyncThunk< break; } - const update = next.value as ChatMessage; - dispatch(streamUpdate(update)); + const updates = next.value as ChatMessage[]; + dispatch(streamUpdate(updates)); next = await gen.next(); - - // There has been lag when streaming tool calls. This is a temporary solution - if (update.role === "assistant" && update.toolCalls) { - await new Promise((resolve) => setTimeout(resolve, 10)); - } } // Attach prompt log diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 0fe588f56..52b15c13f 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -2,6 +2,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ChatMessage, ContextItem } from "core"; import { constructMessages } from "core/llm/constructMessages"; import { renderContextItems } from "core/util/messageContent"; +import { selectDefaultModel } from "../slices/configSlice"; import { addContextItemsAtIndex, setActive, @@ -11,7 +12,6 @@ import { ThunkApiType } from "../store"; import { handleErrors } from "./handleErrors"; import { resetStateForNewMessage } from "./resetStateForNewMessage"; import { streamNormalInput } from "./streamNormalInput"; -import { selectDefaultModel } from "../slices/configSlice"; export const streamResponseAfterToolCall = createAsyncThunk< void, @@ -39,7 +39,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< toolCallId, }; - dispatch(streamUpdate(newMessage)); + dispatch(streamUpdate([newMessage])); dispatch( addContextItemsAtIndex({ index: initialHistory.length, diff --git a/gui/src/redux/thunks/streamSlashCommand.ts b/gui/src/redux/thunks/streamSlashCommand.ts index 314b5cc53..79336bb3d 100644 --- a/gui/src/redux/thunks/streamSlashCommand.ts +++ b/gui/src/redux/thunks/streamSlashCommand.ts @@ -5,9 +5,9 @@ import { RangeInFile, SlashCommandDescription, } from "core"; -import { ThunkApiType } from "../store"; -import { abortStream, streamUpdate } from "../slices/sessionSlice"; import { selectDefaultModel } from "../slices/configSlice"; +import { abortStream, streamUpdate } from "../slices/sessionSlice"; +import { ThunkApiType } from "../store"; export const streamSlashCommand = createAsyncThunk< void, @@ -62,8 +62,17 @@ export const streamSlashCommand = createAsyncThunk< dispatch(abortStream()); break; } - if (typeof update === "string") { - dispatch(streamUpdate(update)); + for (const item of update) { + if (typeof item === "string") { + dispatch( + streamUpdate([ + { + role: "assistant", + content: item, + }, + ]), + ); + } } } clearInterval(checkActiveInterval); From ac1906b108317a5105ad3bdc7aa27caac15b9a32 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 5 Dec 2024 18:29:42 -0800 Subject: [PATCH 12/43] items-center on last session button --- extensions/vscode/package-lock.json | 6 +-- gui/package-lock.json | 2 +- gui/src/pages/gui/Chat.tsx | 65 +++++++++++++++-------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 9de97f4ac..923f4c9b5 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.243", + "version": "0.9.244", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.243", + "version": "0.9.244", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -115,7 +115,7 @@ "comment-json": "^4.2.3", "dbinfoz": "^0.14.0", "diff": "^7.0.0", - "dotenv": "^16.4.7", + "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", diff --git a/gui/package-lock.json b/gui/package-lock.json index af3d5cafa..91410e6df 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -121,7 +121,7 @@ "comment-json": "^4.2.3", "dbinfoz": "^0.14.0", "diff": "^7.0.0", - "dotenv": "^16.4.7", + "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 309f536db..db0367969 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -7,6 +7,7 @@ import { import { Editor, JSONContent } from "@tiptap/react"; import { InputModifiers, RangeInFileWithContents, ToolCallState } from "core"; import { streamResponse } from "core/llm/stream"; +import { stripImages } from "core/util/messageContent"; import { usePostHog } from "posthog-js/react"; import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { ErrorBoundary } from "react-error-boundary"; @@ -19,22 +20,30 @@ import { vscBackground, } from "../../components"; import { ChatScrollAnchor } from "../../components/ChatScrollAnchor"; +import CodeToEditCard from "../../components/CodeToEditCard"; +import FeedbackDialog from "../../components/dialogs/FeedbackDialog"; import { useFindWidget } from "../../components/find/FindWidget"; import TimelineItem from "../../components/gui/TimelineItem"; import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks"; import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; import { NewSessionButton } from "../../components/mainInput/NewSessionButton"; +import resolveEditorContent from "../../components/mainInput/resolveInput"; import { TutorialCard } from "../../components/mainInput/TutorialCard"; import { OnboardingCard, useOnboardingCard, } from "../../components/OnboardingCard"; +import PageHeader from "../../components/PageHeader"; import StepContainer from "../../components/StepContainer"; +import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import useHistory from "../../hooks/useHistory"; import { useTutorialCard } from "../../hooks/useTutorialCard"; import { useWebviewListener } from "../../hooks/useWebviewListener"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall"; +import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { submitEdit } from "../../redux/slices/editModeState"; import { clearLastEmptyResponse, newSession, @@ -42,6 +51,13 @@ import { selectIsSingleRangeEditOrInsertion, setInactive, } from "../../redux/slices/sessionSlice"; +import { + setDialogEntryOn, + setDialogMessage, + setShowDialog, +} from "../../redux/slices/uiSlice"; +import { RootState } from "../../redux/store"; +import { exitEditMode } from "../../redux/thunks/exitEditMode"; import { streamResponseThunk } from "../../redux/thunks/streamResponse"; import { getFontSize, @@ -49,29 +65,12 @@ import { isMetaEquivalentKeyPressed, } from "../../util"; import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial"; +import getMultifileEditPrompt from "../../util/getMultifileEditPrompt"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; import ConfigErrorIndicator from "./ConfigError"; import { ToolCallDiv } from "./ToolCallDiv"; import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv"; import ToolOutput from "./ToolCallDiv/ToolOutput"; -import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; -import { - setDialogMessage, - setDialogEntryOn, - setShowDialog, -} from "../../redux/slices/uiSlice"; -import { RootState } from "../../redux/store"; -import FeedbackDialog from "../../components/dialogs/FeedbackDialog"; -import getMultifileEditPrompt from "../../util/getMultifileEditPrompt"; -import { submitEdit } from "../../redux/slices/editModeState"; -import { stripImages } from "core/util/messageContent"; -import resolveEditorContent from "../../components/mainInput/resolveInput"; -import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons"; -import CodeToEditCard from "../../components/CodeToEditCard"; -import { exitEditMode } from "../../redux/thunks/exitEditMode"; -import PageHeader from "../../components/PageHeader"; -import Spinner from "../../components/gui/Spinner"; const StopButton = styled.div` background-color: ${vscBackground}; @@ -496,19 +495,23 @@ export function Chat() { }} >
- {history.length === 0 && getLastSessionId() && !isInEditMode && ( - - loadLastSession().catch((e) => - console.error(`Failed to load last session: ${e}`), - ) - } - className="xs:inline flex hidden items-center gap-2" - > - - Last Session - - )} +
+ {history.length === 0 && getLastSessionId() && !isInEditMode && ( +
+ + loadLastSession().catch((e) => + console.error(`Failed to load last session: ${e}`), + ) + } + className="flex items-center gap-2" + > + + Last Session + +
+ )} +
From 03d7a673ed80f0f8ad12071c2ba64f3348a4f65f Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Dec 2024 18:30:15 -0800 Subject: [PATCH 13/43] bugfix: delete single word on linux/windows --- .../mainInput/handleMetaKeyIssues.ts | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/gui/src/components/mainInput/handleMetaKeyIssues.ts b/gui/src/components/mainInput/handleMetaKeyIssues.ts index 77cbbb4dc..867203a14 100644 --- a/gui/src/components/mainInput/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/handleMetaKeyIssues.ts @@ -1,8 +1,9 @@ import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; -import { isWebEnvironment } from "../../util"; +import { getPlatform, isWebEnvironment } from "../../util"; const isWebEnv = isWebEnvironment(); +const platform = getPlatform(); /** * This handles various keypress issues when OSR is enabled @@ -56,15 +57,48 @@ export const handleVSCMetaKeyIssues = async ( } }; +const deleteSingleWord = (editor: Editor) => { + const textContent = + editor.state.doc.resolve(editor.state.selection.from).parent.textContent ?? + ""; + + const cursorPosition = editor.state.selection.from; + const nodeStartPosition = editor.state.doc.resolve(cursorPosition).start(); + + const textBeforeCursor = textContent.slice( + 0, + cursorPosition - nodeStartPosition, + ); + + // Match the last word including any trailing whitespace + const lastWordMatch = textBeforeCursor.match(/\S+\s*$/); + + if (lastWordMatch) { + const lastWordWithSpace = lastWordMatch[0]; + editor.commands.deleteRange({ + from: editor.state.selection.from - lastWordWithSpace.length, + to: editor.state.selection.from, + }); + } +}; + export const handleJetBrainsMetaBackspace = (editor: Editor) => { const { doc } = editor.state; for (let i = doc.content.childCount - 1; i >= 0; i--) { const node = doc.content.child(i); - if (node.type.name !== "codeBlock") { - editor.commands.deleteNode(node.type.name); + if (node.type.name === "codeBlock") { + continue; } + + // For Linux/Windows, only delete the word to the left of the cursor + if (platform !== "mac") { + deleteSingleWord(editor); + break; + } + + editor.commands.deleteNode(node.type.name); } // Add an empty string so the user can keep typing From db77b5020d9b93cb4a7504e213d81940dbee9eaa Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Dec 2024 19:36:36 -0800 Subject: [PATCH 14/43] fix: enable OSR for mac after validations --- .../services/ContinueExtensionSettingsService.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinueExtensionSettingsService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinueExtensionSettingsService.kt index 5db34ff29..2cf51b5de 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinueExtensionSettingsService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinueExtensionSettingsService.kt @@ -271,12 +271,6 @@ class ContinueExtensionConfigurable : Configurable { * it's a simple integer without dot notation, making it easier to compare. */ private fun shouldRenderOffScreen(): Boolean { - // With the 0.0.77 release, non-Mac users have been reporting issues with paste functionality - // in the browser. Disabling OSR for all non-Mac users for now. - if (!SystemInfo.isMac) { - return false - } - val minBuildNumber = 233 val applicationInfo = ApplicationInfo.getInstance() val currentBuildNumber = applicationInfo.build.baselineVersion From aa73e87c13f3efd914c6e30ed4630d3debc9b867 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 5 Dec 2024 19:53:57 -0800 Subject: [PATCH 15/43] bump package.json version --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index acc5b947b..42b504a66 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.244", + "version": "0.9.240", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 4d2eb1569b9792a2b72cf13fb477da7732e87741 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Dec 2024 20:04:30 -0800 Subject: [PATCH 16/43] Update gradle.properties --- extensions/intellij/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index be8b0febb..b469e1e23 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginName=continue-intellij-extension pluginRepositoryUrl=https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion=0.0.82 +pluginVersion=0.0.83 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension From b47110a60539c1469374dc4ce65256f2662c2a96 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 5 Dec 2024 20:15:50 -0800 Subject: [PATCH 17/43] increase login timeout --- extensions/vscode/src/stubs/WorkOsAuthProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index 28f3f6032..486b0df12 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -408,7 +408,7 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { return await Promise.race([ codeExchangePromise.promise, new Promise((_, reject) => - setTimeout(() => reject("Cancelled"), 60000), + setTimeout(() => reject("Cancelled"), 15 * 60 * 1_000), ), promiseFromEvent( token.onCancellationRequested, From 100be30b413cca4c82fef05940865ac659d422d1 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 08:37:31 -0800 Subject: [PATCH 18/43] test macos-14 --- .github/workflows/main.yaml | 4 +- .github/workflows/preview.yaml | 167 +++++++++++++++++---------------- 2 files changed, 87 insertions(+), 84 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b73cdb3ad..f54d7bbe4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -49,11 +49,11 @@ jobs: platform: alpine arch: x64 npm_config_arch: x64 - - os: macos-12 # should migrate this to the newer x64 version of macos-14 + - os: macos-14 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-12 # same here, especially + - os: macos-14 # same here, especially platform: darwin arch: arm64 npm_config_arch: arm64 diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index a65e79c7f..7f50f37bf 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -1,8 +1,11 @@ name: Publish Preview Extension on: - release: - types: [prereleased] + push: + branches: + - nate/mac-14-ci + # release: + # types: [prereleased] jobs: check_release_name: @@ -49,11 +52,11 @@ jobs: platform: alpine arch: x64 npm_config_arch: x64 - - os: macos-12 # should migrate this to the newer x64 version of macos-14 + - os: macos-14 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-12 # same here, especially + - os: macos-14 platform: darwin arch: arm64 npm_config_arch: arm64 @@ -161,93 +164,93 @@ jobs: name: ${{ env.target }}-vsix path: "extensions/vscode/*.vsix" - release: - permissions: - contents: write - runs-on: ubuntu-latest - needs: - - build - steps: - - name: Checkout - uses: actions/checkout@v4 + # release: + # permissions: + # contents: write + # runs-on: ubuntu-latest + # needs: + # - build + # steps: + # - name: Checkout + # uses: actions/checkout@v4 - - name: Set up Git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + # - name: Set up Git + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" - # Download the .vsix artifacts - - uses: actions/download-artifact@v4 - with: - pattern: "*-vsix" - path: vsix-artifacts - merge-multiple: true + # # Download the .vsix artifacts + # - uses: actions/download-artifact@v4 + # with: + # pattern: "*-vsix" + # path: vsix-artifacts + # merge-multiple: true - - name: Release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ github.ref_name }} - files: | - vsix-artifacts/*.vsix - token: ${{ secrets.CI_GITHUB_TOKEN }} - repository: continuedev/continue - prerelease: true + # - name: Release + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: ${{ github.ref_name }} + # files: | + # vsix-artifacts/*.vsix + # token: ${{ secrets.CI_GITHUB_TOKEN }} + # repository: continuedev/continue + # prerelease: true - publish: - runs-on: ubuntu-latest - needs: - - build - permissions: - contents: write - steps: - # 0. Setup git - - name: Checkout - uses: actions/checkout@v4 + # publish: + # runs-on: ubuntu-latest + # needs: + # - build + # permissions: + # contents: write + # steps: + # # 0. Setup git + # - name: Checkout + # uses: actions/checkout@v4 - - name: Set up Git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + # - name: Set up Git + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" - - name: Pull latest changes - run: git pull origin main + # - name: Pull latest changes + # run: git pull origin main - # 1. Download the artifacts - - uses: actions/download-artifact@v4 - with: - pattern: "*-vsix" - path: vsix-artifacts - merge-multiple: true + # # 1. Download the artifacts + # - uses: actions/download-artifact@v4 + # with: + # pattern: "*-vsix" + # path: vsix-artifacts + # merge-multiple: true - # 2. Publish the extension to VS Code Marketplace - - name: Publish to VS Code Marketplace - run: | - cd extensions/vscode - npx vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix - env: - VSCE_PAT: ${{ secrets.VSCE_TOKEN }} + # # 2. Publish the extension to VS Code Marketplace + # - name: Publish to VS Code Marketplace + # run: | + # cd extensions/vscode + # npx vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix + # env: + # VSCE_PAT: ${{ secrets.VSCE_TOKEN }} - # 3. Publish the extension to Open VSX Registry - - name: Publish (Open VSX Registry) - continue-on-error: true - run: | - cd extensions/vscode - npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix + # # 3. Publish the extension to Open VSX Registry + # - name: Publish (Open VSX Registry) + # continue-on-error: true + # run: | + # cd extensions/vscode + # npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch + # 4. Update the package.json version and push changes + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "💚 Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "💚 Update package.json version [skip ci]" - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} From 8d5030c1038ddbcf31b0bc0bef1224b2a89fbfce Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 09:10:40 -0800 Subject: [PATCH 19/43] don't check release name --- .github/workflows/preview.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 7f50f37bf..18e6161c4 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -8,23 +8,23 @@ on: # types: [prereleased] jobs: - check_release_name: - runs-on: ubuntu-latest - outputs: - should_run: ${{ steps.check.outputs.should_run }} - steps: - - id: check - working-directory: . - run: | - if [[ "${{ github.event.release.tag_name }}" == v0.9.*-vscode ]]; then - echo "should_run=true" >> $GITHUB_OUTPUT - else - echo "should_run=false" >> $GITHUB_OUTPUT - fi + # check_release_name: + # runs-on: ubuntu-latest + # outputs: + # should_run: ${{ steps.check.outputs.should_run }} + # steps: + # - id: check + # working-directory: . + # run: | + # if [[ "${{ github.event.release.tag_name }}" == v0.9.*-vscode ]]; then + # echo "should_run=true" >> $GITHUB_OUTPUT + # else + # echo "should_run=false" >> $GITHUB_OUTPUT + # fi build: - needs: check_release_name - if: needs.check_release_name.outputs.should_run == 'true' + # needs: check_release_name + # if: needs.check_release_name.outputs.should_run == 'true' strategy: matrix: include: From a5db0d46ae656dd04bf2150e74c0cc7885d81084 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 6 Dec 2024 11:01:59 -0800 Subject: [PATCH 20/43] Update Chat.tsx --- gui/src/pages/gui/Chat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index db0367969..8545813bc 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -341,7 +341,7 @@ export function Chat() { <> {isInEditMode && ( { loadLastSession().catch((e) => console.error(`Failed to load last session: ${e}`), From 9e41fa1e678d165ae5554ffdb292ec7c0ba759eb Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 13:44:29 -0800 Subject: [PATCH 21/43] use 13 --- .github/workflows/main.yaml | 4 ++-- .github/workflows/preview.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f54d7bbe4..ae0359027 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -49,11 +49,11 @@ jobs: platform: alpine arch: x64 npm_config_arch: x64 - - os: macos-14 + - os: macos-13 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-14 # same here, especially + - os: macos-13 platform: darwin arch: arm64 npm_config_arch: arm64 diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 18e6161c4..9a3604f09 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -52,11 +52,11 @@ jobs: platform: alpine arch: x64 npm_config_arch: x64 - - os: macos-14 + - os: macos-13 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-14 + - os: macos-13 platform: darwin arch: arm64 npm_config_arch: arm64 From 608a157ef5742df182339749a67652adcdf50e58 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 5 Dec 2024 16:41:22 -0800 Subject: [PATCH 22/43] test: add utils --- core/autocomplete/filtering/test/util.ts | 4 +- core/index.d.ts | 1 + core/llm/llms/Mock.ts | 4 +- core/llm/llms/Test.ts | 39 +++++++++ core/llm/llms/index.ts | 6 +- extensions/vscode/e2e/GUI.test.ts | 86 ------------------- extensions/vscode/e2e/actions/GUI.actions.ts | 58 +++++++++++++ .../vscode/e2e/selectors/GUI.selectors.ts | 44 ++++++++++ .../vscode/e2e/selectors/SelectorUtils.ts | 16 ++++ extensions/vscode/e2e/test-files/config.json | 4 + extensions/vscode/e2e/tests/GUI.test.ts | 61 +++++++++++++ extensions/vscode/package.json | 9 +- gui/src/components/mainInput/InputToolbar.tsx | 1 + .../components/modelSelection/ModelSelect.tsx | 1 + 14 files changed, 239 insertions(+), 95 deletions(-) create mode 100644 core/llm/llms/Test.ts delete mode 100644 extensions/vscode/e2e/GUI.test.ts create mode 100644 extensions/vscode/e2e/actions/GUI.actions.ts create mode 100644 extensions/vscode/e2e/selectors/GUI.selectors.ts create mode 100644 extensions/vscode/e2e/selectors/SelectorUtils.ts create mode 100644 extensions/vscode/e2e/test-files/config.json create mode 100644 extensions/vscode/e2e/tests/GUI.test.ts diff --git a/core/autocomplete/filtering/test/util.ts b/core/autocomplete/filtering/test/util.ts index a052aace2..db8d99131 100644 --- a/core/autocomplete/filtering/test/util.ts +++ b/core/autocomplete/filtering/test/util.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; -import Mock from "../../../llm/llms/Mock"; +import MockLLM from "../../../llm/llms/Mock"; import { testConfigHandler, testIde } from "../../../test/fixtures"; import { CompletionProvider } from "../../CompletionProvider"; import { AutocompleteInput } from "../../util/types"; @@ -30,7 +30,7 @@ export async function testAutocompleteFiltering( const { prefix, suffix } = parseFimExample(test.input); // Setup necessary objects - const llm = new Mock({ + const llm = new MockLLM({ model: "mock", }); llm.completion = test.llmOutput; diff --git a/core/index.d.ts b/core/index.d.ts index 06fbd7275..4e050bb58 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -807,6 +807,7 @@ type ModelProvider = | "nvidia" | "vllm" | "mock" + | "test" | "cerebras" | "askSage" | "vertexai" diff --git a/core/llm/llms/Mock.ts b/core/llm/llms/Mock.ts index 5f3880e3c..6f564cce7 100644 --- a/core/llm/llms/Mock.ts +++ b/core/llm/llms/Mock.ts @@ -1,7 +1,7 @@ import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js"; import { BaseLLM } from "../index.js"; -class Mock extends BaseLLM { +class MockLLM extends BaseLLM { public completion: string = "Test Completion"; static providerName: ModelProvider = "mock"; @@ -27,4 +27,4 @@ class Mock extends BaseLLM { } } -export default Mock; +export default MockLLM; diff --git a/core/llm/llms/Test.ts b/core/llm/llms/Test.ts new file mode 100644 index 000000000..b35984f3e --- /dev/null +++ b/core/llm/llms/Test.ts @@ -0,0 +1,39 @@ +import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js"; +import { BaseLLM } from "../index.js"; + +const RESPONSES: Record = { + "How are you?": "I'm fine", +}; + +const HARDCODED_CHAT_RESPONSE = "THIS IS A HARDCODED RESPONSE"; + +class TestLLM extends BaseLLM { + static providerName: ModelProvider = "test"; + + private findResponse(prompt: string) { + return Object.entries(RESPONSES).find(([key]) => prompt.includes(key))?.[1]; + } + + protected async *_streamComplete( + prompt: string, + signal: AbortSignal, + options: CompletionOptions, + ): AsyncGenerator { + yield this.findResponse(prompt) || `PROMPT: ${prompt}`; + } + + protected async *_streamChat( + messages: ChatMessage[], + signal: AbortSignal, + options: CompletionOptions, + ): AsyncGenerator { + for (const char of HARDCODED_CHAT_RESPONSE) { + yield { + role: "assistant", + content: char, + }; + } + } +} + +export default TestLLM; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 632607ed1..9604cb9f6 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -31,7 +31,7 @@ import LlamaCpp from "./LlamaCpp"; import Llamafile from "./Llamafile"; import LMStudio from "./LMStudio"; import Mistral from "./Mistral"; -import Mock from "./Mock"; +import MockLLM from "./Mock"; import Moonshot from "./Moonshot"; import Msty from "./Msty"; import Nebius from "./Nebius"; @@ -50,6 +50,7 @@ import Vllm from "./Vllm"; import WatsonX from "./WatsonX"; import xAI from "./xAI"; import SiliconFlow from "./SiliconFlow"; +import TestLLM from "./Test"; const LLMs = [ Anthropic, @@ -87,7 +88,8 @@ const LLMs = [ Nvidia, Vllm, SambaNova, - Mock, + MockLLM, + TestLLM, Cerebras, Asksage, Nebius, diff --git a/extensions/vscode/e2e/GUI.test.ts b/extensions/vscode/e2e/GUI.test.ts deleted file mode 100644 index 0055df1ba..000000000 --- a/extensions/vscode/e2e/GUI.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { - Workbench, - EditorView, - WebView, - By, - WebElement, - WebDriver, - Key, -} from "vscode-extension-tester"; -import { expect } from "chai"; - -const switchToReactIframe = async (driver: WebDriver) => { - const iframes = await driver.findElements(By.css("iframe")); - let continueIFrame: WebElement | undefined = undefined; - for (let i = 0; i < iframes.length; i++) { - const iframe = iframes[i]; - const src = await iframe.getAttribute("src"); - if (src.includes("extensionId=Continue.continue")) { - continueIFrame = iframe; - break; - } - } - - if (!continueIFrame) { - throw new Error("Could not find continue iframe"); - } - - await driver.switchTo().frame(continueIFrame); - - await new Promise((res) => { - setTimeout(res, 500); - }); - - const reactIFrame = await driver.findElement(By.css("iframe")); - - if (!reactIFrame) { - throw new Error("Could not find React iframe"); - } - - await driver.switchTo().frame(reactIFrame); -}; - -describe("GUI Test", () => { - let view: WebView; - let driver: WebDriver; - - before(async function () { - this.timeout(10000); - - await new Workbench().executeCommand("continue.focusContinueInput"); - - view = new WebView(); - driver = view.getDriver(); - - await switchToReactIframe(driver); - }); - - after(async () => { - await view.switchBack(); - await new EditorView().closeAllEditors(); - }); - - it("should display correct panel description", async () => { - const description = await view.findWebElement( - By.xpath("//*[contains(text(), 'Quickly')]"), - ); - - expect(await description.getText()).has.string( - "Quickly get up and running using our API keys.", - ); - }); - - it("should allow typing text in the editor", async () => { - const tiptap = await view.findWebElement(By.className("tiptap")); - - await tiptap.sendKeys("Hello world!"); - - expect(await tiptap.getText()).has.string("Hello world!"); - - // Just to show that we can - await tiptap.sendKeys(Key.ENTER); - await new Promise((res) => { - setTimeout(res, 5000); - }); - }).timeout(6000); -}); diff --git a/extensions/vscode/e2e/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts new file mode 100644 index 000000000..1e59f1d15 --- /dev/null +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -0,0 +1,58 @@ +import { + WebDriver, + WebElement, + WebView, + Workbench, +} from "vscode-extension-tester"; +import { GUISelectors } from "../selectors/GUI.selectors"; + +export class GUIActions { + public static switchToReactIframe = async (driver: WebDriver) => { + const iframes = await GUISelectors.getAllIframes(driver); + let continueIFrame: WebElement | undefined = undefined; + for (let i = 0; i < iframes.length; i++) { + const iframe = iframes[i]; + const src = await iframe.getAttribute("src"); + if (src.includes("extensionId=Continue.continue")) { + continueIFrame = iframe; + break; + } + } + + if (!continueIFrame) { + throw new Error("Could not find continue iframe"); + } + + await driver.switchTo().frame(continueIFrame); + + await new Promise((res) => { + setTimeout(res, 500); + }); + + const reactIFrame = await GUISelectors.getReactIframe(driver); + + if (!reactIFrame) { + throw new Error("Could not find React iframe"); + } + + await driver.switchTo().frame(reactIFrame); + }; + + public static openGui = async () => { + return new Workbench().executeCommand("continue.focusContinueInput"); + }; + + public static selectModelFromDropdown = async ( + view: WebView, + option: string, + ) => { + const dropdownButton = await GUISelectors.getModelDropdownButton(view); + await dropdownButton.click(); + + const dropdownOption = await GUISelectors.getModelDropdownOption( + view, + option, + ); + await dropdownOption.click(); + }; +} diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts new file mode 100644 index 000000000..1208d1a04 --- /dev/null +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -0,0 +1,44 @@ +import { By, WebDriver, WebView } from "vscode-extension-tester"; +import { SelectorUtils } from "./SelectorUtils"; + +export class GUISelectors { + public static getDescription(view: WebView) { + return view.findWebElement(By.xpath("//*[contains(text(), 'Quickly')]")); + } + + public static getTipTapEditor(view: WebView) { + return view.findWebElement(By.className("tiptap")); + } + + public static getAllIframes(driver: WebDriver) { + return driver.findElements(By.css("iframe")); + } + + public static getReactIframe(driver: WebDriver) { + return driver.findElement(By.css("iframe")); + } + + public static getSubmitInputButton(view: WebView) { + return SelectorUtils.getElementByDataTestId(view, "submit-input-button"); + } + + public static getModelDropdownButton(view: WebView) { + return SelectorUtils.getElementByDataTestId(view, "model-select-button"); + } + + public static getListbox(view: WebView) { + const listbox = view.findWebElement(By.css('[role="listbox"]')); + } + + public static getModelDropdownOption(view: WebView, option: string) { + return view.findWebElement( + By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`), + ); + } + + public static getThreadMessageByText(view: WebView, text: string) { + return view.findWebElement( + By.xpath(`//*[@class="thread-message"]//*[contains(text(), "${text}")]`), + ); + } +} diff --git a/extensions/vscode/e2e/selectors/SelectorUtils.ts b/extensions/vscode/e2e/selectors/SelectorUtils.ts new file mode 100644 index 000000000..243e1bf44 --- /dev/null +++ b/extensions/vscode/e2e/selectors/SelectorUtils.ts @@ -0,0 +1,16 @@ +import { By, WebElement, WebView } from "vscode-extension-tester"; + +export class SelectorUtils { + /** + * Finds a web element by its data-testid attribute within a WebView. + * @param view - The WebView to search within. + * @param testId - The data-testid value to search for. + * @returns A promise that resolves to the WebElement found. + */ + public static getElementByDataTestId( + view: WebView, + testId: string, + ): Promise { + return view.findWebElement(By.css(`[data-testid='${testId}']`)); + } +} diff --git a/extensions/vscode/e2e/test-files/config.json b/extensions/vscode/e2e/test-files/config.json new file mode 100644 index 000000000..524cd8403 --- /dev/null +++ b/extensions/vscode/e2e/test-files/config.json @@ -0,0 +1,4 @@ +{ + "name": "Untitled.txt", + "content": "Hello, world!" +} diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts new file mode 100644 index 000000000..87837c69c --- /dev/null +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -0,0 +1,61 @@ +import { + EditorView, + WebView, + WebDriver, + Key, + VSBrowser, +} from "vscode-extension-tester"; +import { expect } from "chai"; +import { GUIActions } from "../actions/GUI.actions"; +import { GUISelectors } from "../selectors/GUI.selectors"; +import * as path from "path"; + +describe("GUI Test", () => { + let view: WebView; + let driver: WebDriver; + + before(async function () { + this.timeout(10000000); + + await VSBrowser.instance.openResources(path.join("e2e/test-files")); + + await GUIActions.openGui(); + + view = new WebView(); + driver = view.getDriver(); + + await GUIActions.switchToReactIframe(driver); + // await new Promise((res) => { + // setTimeout(res, 10000000); + // }); + }); + + after(async () => { + await view.switchBack(); + await new EditorView().closeAllEditors(); + }); + + it("should display correct panel description", async () => { + const description = await GUISelectors.getDescription(view); + + expect(await description.getText()).has.string( + "Quickly get up and running using our API keys.", + ); + }); + + it.only("should allow typing text in the editor", async () => { + await GUIActions.selectModelFromDropdown(view, "Mock"); + await GUIActions.selectModelFromDropdown(view, "TEST LLM"); + + const tiptap = await GUISelectors.getTipTapEditor(view); + + await tiptap.sendKeys("How are you?"); + (await GUISelectors.getSubmitInputButton(view)).click(); + + await new Promise((res) => { + setTimeout(res, 600000000); + }); + + await GUISelectors.getThreadMessageByText(view, "I'm fine"); + }).timeout(600000000); +}); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index acc5b947b..9d353798f 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.244", + "version": "0.9.251", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -613,6 +613,7 @@ "quick-test": "npm run build-test && node ./out/runTestOnVSCodeHost.js", "prepackage": "node scripts/prepackage.js", "package": "node scripts/package.js", + "e2e:package": "CONTINUE_GLOBAL_DIR=e2e/test-files node scripts/package.js", "package-all": "node scripts/package-all.js", "package:pre-release": "node scripts/package.js --pre-release", "build:rust": "cargo-cp-artifact -ac sync sync.node -- cargo build --manifest-path ../../sync/Cargo.toml --message-format=json-render-diagnostics", @@ -625,8 +626,10 @@ "e2e:sign-vscode": "codesign --entitlements entitlements.plist --deep --force -s - './e2e/storage/Visual Studio Code.app'", "e2e:copy-vsix": "chmod +x ./e2e/get-latest-vsix.sh && bash ./e2e/get-latest-vsix.sh", "e2e:install-vsix": "extest install-vsix -f ./e2e/vsix/continue.vsix --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage", - "e2e:test": "extest run-tests './e2e/_output/*.test.js' --code_settings settings.json --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage", - "e2e:all": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test", + "e2e:test": "extest run-tests './e2e/_output/tests/*.test.js' --code_settings settings.json --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage", + "e2e:clean": "rm -rf ./e2e/_output", + "e2e:all": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test && npm run e2e:clean", + "e2e:quick": "CONTINUE_GLOBAL_DIR=e2e/test-files npm run e2e:compile && npm run e2e:test && npm run e2e:clean", "e2e:ci": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test" }, "devDependencies": { diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 9348e5262..f83c27d1e 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -208,6 +208,7 @@ function InputToolbar(props: InputToolbarProps) { )} { if (props.onEnter) { props.onEnter({ diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index a4d7fe364..c5edb5d7b 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -316,6 +316,7 @@ function ModelSelect() { >
Date: Fri, 6 Dec 2024 15:39:42 -0800 Subject: [PATCH 23/43] fix ImportDefinitionsService bug --- .../context/ImportDefinitionsService.ts | 13 +++++++++++-- core/util/LruCache.ts | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/autocomplete/context/ImportDefinitionsService.ts b/core/autocomplete/context/ImportDefinitionsService.ts index 128dbf78e..309310738 100644 --- a/core/autocomplete/context/ImportDefinitionsService.ts +++ b/core/autocomplete/context/ImportDefinitionsService.ts @@ -29,14 +29,23 @@ export class ImportDefinitionsService { return this.cache.get(filepath); } - private async _getFileInfo(filepath: string): Promise { + private async _getFileInfo(filepath: string): Promise { const parser = await getParserForFile(filepath); if (!parser) { return { imports: {}, }; } - const ast = parser.parse(await this.ide.readFile(filepath), undefined, { + + let fileContents: string | undefined = undefined; + try { + fileContents = await this.ide.readFile(filepath); + } catch (err) { + // File removed + return null; + } + + const ast = parser.parse(fileContents, undefined, { includedRanges: [ { startIndex: 0, diff --git a/core/util/LruCache.ts b/core/util/LruCache.ts index f6d923fed..86925a6bc 100644 --- a/core/util/LruCache.ts +++ b/core/util/LruCache.ts @@ -1,7 +1,7 @@ export class PrecalculatedLruCache { private items: [string, V][] = []; constructor( - private readonly calculateValue: (key: string) => Promise, + private readonly calculateValue: (key: string) => Promise, private readonly N: number, ) {} @@ -11,7 +11,11 @@ export class PrecalculatedLruCache { if (index < 0) { // Calculate info for new file - const value: V = await this.calculateValue(key); + const value: V | null = await this.calculateValue(key); + + if (value === null) { + return; + } this.items.push([key, value]); if (this.items.length > this.N) { From b95956155f8c40beebd89894fdf1d2184295569c Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 15:45:57 -0800 Subject: [PATCH 24/43] preview.yaml back to normal --- .github/workflows/preview.yaml | 193 ++++++++++++++++----------------- 1 file changed, 95 insertions(+), 98 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 9a3604f09..f433e8fe0 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -1,30 +1,27 @@ name: Publish Preview Extension on: - push: - branches: - - nate/mac-14-ci - # release: - # types: [prereleased] + release: + types: [prereleased] jobs: - # check_release_name: - # runs-on: ubuntu-latest - # outputs: - # should_run: ${{ steps.check.outputs.should_run }} - # steps: - # - id: check - # working-directory: . - # run: | - # if [[ "${{ github.event.release.tag_name }}" == v0.9.*-vscode ]]; then - # echo "should_run=true" >> $GITHUB_OUTPUT - # else - # echo "should_run=false" >> $GITHUB_OUTPUT - # fi + check_release_name: + runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.check.outputs.should_run }} + steps: + - id: check + working-directory: . + run: | + if [[ "${{ github.event.release.tag_name }}" == v0.9.*-vscode ]]; then + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "should_run=false" >> $GITHUB_OUTPUT + fi build: - # needs: check_release_name - # if: needs.check_release_name.outputs.should_run == 'true' + needs: check_release_name + if: needs.check_release_name.outputs.should_run == 'true' strategy: matrix: include: @@ -164,93 +161,93 @@ jobs: name: ${{ env.target }}-vsix path: "extensions/vscode/*.vsix" - # release: - # permissions: - # contents: write - # runs-on: ubuntu-latest - # needs: - # - build - # steps: - # - name: Checkout - # uses: actions/checkout@v4 + release: + permissions: + contents: write + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Checkout + uses: actions/checkout@v4 - # - name: Set up Git - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" + - name: Set up Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" - # # Download the .vsix artifacts - # - uses: actions/download-artifact@v4 - # with: - # pattern: "*-vsix" - # path: vsix-artifacts - # merge-multiple: true + # Download the .vsix artifacts + - uses: actions/download-artifact@v4 + with: + pattern: "*-vsix" + path: vsix-artifacts + merge-multiple: true - # - name: Release - # uses: softprops/action-gh-release@v2 - # with: - # tag_name: ${{ github.ref_name }} - # files: | - # vsix-artifacts/*.vsix - # token: ${{ secrets.CI_GITHUB_TOKEN }} - # repository: continuedev/continue - # prerelease: true + - name: Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + files: | + vsix-artifacts/*.vsix + token: ${{ secrets.CI_GITHUB_TOKEN }} + repository: continuedev/continue + prerelease: true - # publish: - # runs-on: ubuntu-latest - # needs: - # - build - # permissions: - # contents: write - # steps: - # # 0. Setup git - # - name: Checkout - # uses: actions/checkout@v4 + publish: + runs-on: ubuntu-latest + needs: + - build + permissions: + contents: write + steps: + # 0. Setup git + - name: Checkout + uses: actions/checkout@v4 - # - name: Set up Git - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" + - name: Set up Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" - # - name: Pull latest changes - # run: git pull origin main + - name: Pull latest changes + run: git pull origin main - # # 1. Download the artifacts - # - uses: actions/download-artifact@v4 - # with: - # pattern: "*-vsix" - # path: vsix-artifacts - # merge-multiple: true + # 1. Download the artifacts + - uses: actions/download-artifact@v4 + with: + pattern: "*-vsix" + path: vsix-artifacts + merge-multiple: true - # # 2. Publish the extension to VS Code Marketplace - # - name: Publish to VS Code Marketplace - # run: | - # cd extensions/vscode - # npx vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix - # env: - # VSCE_PAT: ${{ secrets.VSCE_TOKEN }} + # 2. Publish the extension to VS Code Marketplace + - name: Publish to VS Code Marketplace + run: | + cd extensions/vscode + npx vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix + env: + VSCE_PAT: ${{ secrets.VSCE_TOKEN }} - # # 3. Publish the extension to Open VSX Registry - # - name: Publish (Open VSX Registry) - # continue-on-error: true - # run: | - # cd extensions/vscode - # npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix + # 3. Publish the extension to Open VSX Registry + - name: Publish (Open VSX Registry) + continue-on-error: true + run: | + cd extensions/vscode + npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch + 4. Update the package.json version and push changes + - name: Update version in package.json + run: | + cd extensions/vscode + npm version patch - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "💚 Update package.json version [skip ci]" + - name: Commit changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -am "💚 Update package.json version [skip ci]" - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} From 39a0cab5e413ac060a492d1ab24bd9367688d3b8 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 15:47:12 -0800 Subject: [PATCH 25/43] comment --- .github/workflows/preview.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index f433e8fe0..2f3e0875d 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -234,20 +234,20 @@ jobs: cd extensions/vscode npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - 4. Update the package.json version and push changes - - name: Update version in package.json - run: | - cd extensions/vscode - npm version patch + # 4. Update the package.json version and push changes + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -am "💚 Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "💚 Update package.json version [skip ci]" - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} From a255583d2264b40a22546fd45871ceabaaf2c5d3 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 15:47:33 -0800 Subject: [PATCH 26/43] tab --- .github/workflows/preview.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 2f3e0875d..da46e9d49 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -234,20 +234,20 @@ jobs: cd extensions/vscode npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch + # 4. Update the package.json version and push changes + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "💚 Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "💚 Update package.json version [skip ci]" - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} From 9857ea8df6d6833524cc279d72f2de61ae218c7e Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 15:47:57 -0800 Subject: [PATCH 27/43] tab --- .github/workflows/preview.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index da46e9d49..2f3e0875d 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -234,20 +234,20 @@ jobs: cd extensions/vscode npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch + # 4. Update the package.json version and push changes + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "💚 Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "💚 Update package.json version [skip ci]" - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} From 321e079d527407e29fa78c595e30c0369639e2e6 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 15:48:16 -0800 Subject: [PATCH 28/43] more tabs --- .github/workflows/preview.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 2f3e0875d..bd5f4b7ac 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -234,20 +234,20 @@ jobs: cd extensions/vscode npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch + # 4. Update the package.json version and push changes + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "💚 Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "💚 Update package.json version [skip ci]" - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} From ba41678a398385300f11b2194c091a62b2ee4e94 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 16:47:20 -0800 Subject: [PATCH 29/43] test: set up test config.json and test project directory --- extensions/vscode/.gitignore | 3 +- extensions/vscode/.vscodeignore | 1 + .../vscode/e2e/test-continue/config.json | 44 +++++++++++++++++++ extensions/vscode/e2e/test-files/config.json | 4 -- extensions/vscode/e2e/tests/GUI.test.ts | 6 +-- extensions/vscode/package.json | 7 ++- 6 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 extensions/vscode/e2e/test-continue/config.json delete mode 100644 extensions/vscode/e2e/test-files/config.json diff --git a/extensions/vscode/.gitignore b/extensions/vscode/.gitignore index 23c012927..f922ad032 100644 --- a/extensions/vscode/.gitignore +++ b/extensions/vscode/.gitignore @@ -18,8 +18,9 @@ gui/** continue_rc_schema.json - e2e/_output e2e/.test-extensions e2e/storage e2e/vsix +e2e/test-continue/* +!e2e/test-continue/config.json \ No newline at end of file diff --git a/extensions/vscode/.vscodeignore b/extensions/vscode/.vscodeignore index 9d59dbe5c..387be8ba5 100644 --- a/extensions/vscode/.vscodeignore +++ b/extensions/vscode/.vscodeignore @@ -21,6 +21,7 @@ esbuild.js esbuild.test.mjs importMetaUrl.js scripts +e2e server/exe/** !out/node_modules/** diff --git a/extensions/vscode/e2e/test-continue/config.json b/extensions/vscode/e2e/test-continue/config.json new file mode 100644 index 000000000..6ffeb7465 --- /dev/null +++ b/extensions/vscode/e2e/test-continue/config.json @@ -0,0 +1,44 @@ +{ + "ui": { + "displayRawMarkdown": false + }, + "models": [ + { + "title": "TEST LLM", + "provider": "test", + "model": "this field is not used" + }, + { + "title": "Mock", + "provider": "mock", + "model": "this field is not used" + } + ], + "analytics": { + "provider": "continue-proxy" + }, + "tabAutocompleteModel": { + "title": "Qwen", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "" + }, + "tabAutocompleteOptions": { + "useCache": false + }, + "contextProviders": [ + { + "name": "docs" + }, + { + "name": "diff" + }, + { + "name": "url" + }, + { + "name": "folder" + } + ], + "docs": [] +} diff --git a/extensions/vscode/e2e/test-files/config.json b/extensions/vscode/e2e/test-files/config.json deleted file mode 100644 index 524cd8403..000000000 --- a/extensions/vscode/e2e/test-files/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Untitled.txt", - "content": "Hello, world!" -} diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 87837c69c..abab249b9 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -17,7 +17,7 @@ describe("GUI Test", () => { before(async function () { this.timeout(10000000); - await VSBrowser.instance.openResources(path.join("e2e/test-files")); + await VSBrowser.instance.openResources(path.join("e2e/test-continue")); await GUIActions.openGui(); @@ -43,7 +43,7 @@ describe("GUI Test", () => { ); }); - it.only("should allow typing text in the editor", async () => { + it("should allow typing text in the editor", async () => { await GUIActions.selectModelFromDropdown(view, "Mock"); await GUIActions.selectModelFromDropdown(view, "TEST LLM"); @@ -53,7 +53,7 @@ describe("GUI Test", () => { (await GUISelectors.getSubmitInputButton(view)).click(); await new Promise((res) => { - setTimeout(res, 600000000); + setTimeout(res, 1000); }); await GUISelectors.getThreadMessageByText(view, "I'm fine"); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9d353798f..b9b2fb022 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.251", + "version": "0.9.257", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -613,7 +613,6 @@ "quick-test": "npm run build-test && node ./out/runTestOnVSCodeHost.js", "prepackage": "node scripts/prepackage.js", "package": "node scripts/package.js", - "e2e:package": "CONTINUE_GLOBAL_DIR=e2e/test-files node scripts/package.js", "package-all": "node scripts/package-all.js", "package:pre-release": "node scripts/package.js --pre-release", "build:rust": "cargo-cp-artifact -ac sync sync.node -- cargo build --manifest-path ../../sync/Cargo.toml --message-format=json-render-diagnostics", @@ -628,8 +627,8 @@ "e2e:install-vsix": "extest install-vsix -f ./e2e/vsix/continue.vsix --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage", "e2e:test": "extest run-tests './e2e/_output/tests/*.test.js' --code_settings settings.json --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage", "e2e:clean": "rm -rf ./e2e/_output", - "e2e:all": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test && npm run e2e:clean", - "e2e:quick": "CONTINUE_GLOBAL_DIR=e2e/test-files npm run e2e:compile && npm run e2e:test && npm run e2e:clean", + "e2e:all": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean", + "e2e:quick": "npm run e2e:compile && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean", "e2e:ci": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test" }, "devDependencies": { From af5d5fadb0fa9e8ae9364eb77844b9a027280ac3 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:22:24 -0800 Subject: [PATCH 30/43] test: add waitForElement util --- extensions/vscode/e2e/TestUtils.ts | 27 +++++++++++++++++++++++++ extensions/vscode/e2e/tests/GUI.test.ts | 11 +++++----- 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 extensions/vscode/e2e/TestUtils.ts diff --git a/extensions/vscode/e2e/TestUtils.ts b/extensions/vscode/e2e/TestUtils.ts new file mode 100644 index 000000000..dc1fd556e --- /dev/null +++ b/extensions/vscode/e2e/TestUtils.ts @@ -0,0 +1,27 @@ +import { WebElement } from "vscode-extension-tester"; + +export class TestUtils { + public static async waitForElement( + locatorFn: () => Promise, + timeout: number = 1500, + interval: number = 500, + ): Promise { + const startTime = Date.now(); + + while (Date.now() - startTime < timeout) { + try { + const element = await locatorFn(); + if (element) { + return element; + } + } catch (e) { + if (Date.now() - startTime >= timeout) { + throw new Error(`Element not found after ${timeout}ms timeout`); + } + } + await new Promise((resolve) => setTimeout(resolve, interval)); + } + + throw new Error(`Element not found after ${timeout}ms timeout`); + } +} diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index abab249b9..d14eaad2a 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -2,13 +2,13 @@ import { EditorView, WebView, WebDriver, - Key, VSBrowser, } from "vscode-extension-tester"; import { expect } from "chai"; import { GUIActions } from "../actions/GUI.actions"; import { GUISelectors } from "../selectors/GUI.selectors"; import * as path from "path"; +import { TestUtils } from "../TestUtils"; describe("GUI Test", () => { let view: WebView; @@ -52,10 +52,9 @@ describe("GUI Test", () => { await tiptap.sendKeys("How are you?"); (await GUISelectors.getSubmitInputButton(view)).click(); - await new Promise((res) => { - setTimeout(res, 1000); - }); - - await GUISelectors.getThreadMessageByText(view, "I'm fine"); + await TestUtils.waitForElement( + () => GUISelectors.getThreadMessageByText(view, "I'm fine"), + 5000, + ); }).timeout(600000000); }); From ec121409f8bd813fc3360227adddcc869d10a29f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:25:10 -0800 Subject: [PATCH 31/43] test: clean up code --- extensions/vscode/e2e/TestUtils.ts | 2 +- extensions/vscode/e2e/actions/GUI.actions.ts | 1 + extensions/vscode/e2e/selectors/GUI.selectors.ts | 4 ---- extensions/vscode/e2e/tests/GUI.test.ts | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/extensions/vscode/e2e/TestUtils.ts b/extensions/vscode/e2e/TestUtils.ts index dc1fd556e..47651d926 100644 --- a/extensions/vscode/e2e/TestUtils.ts +++ b/extensions/vscode/e2e/TestUtils.ts @@ -3,7 +3,7 @@ import { WebElement } from "vscode-extension-tester"; export class TestUtils { public static async waitForElement( locatorFn: () => Promise, - timeout: number = 1500, + timeout: number = 5000, interval: number = 500, ): Promise { const startTime = Date.now(); diff --git a/extensions/vscode/e2e/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts index 1e59f1d15..86fcb293b 100644 --- a/extensions/vscode/e2e/actions/GUI.actions.ts +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -5,6 +5,7 @@ import { Workbench, } from "vscode-extension-tester"; import { GUISelectors } from "../selectors/GUI.selectors"; +import { TestUtils } from "../TestUtils"; export class GUIActions { public static switchToReactIframe = async (driver: WebDriver) => { diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts index 1208d1a04..b4c88aacb 100644 --- a/extensions/vscode/e2e/selectors/GUI.selectors.ts +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -26,10 +26,6 @@ export class GUISelectors { return SelectorUtils.getElementByDataTestId(view, "model-select-button"); } - public static getListbox(view: WebView) { - const listbox = view.findWebElement(By.css('[role="listbox"]')); - } - public static getModelDropdownOption(view: WebView, option: string) { return view.findWebElement( By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`), diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index d14eaad2a..b01feb35e 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -54,7 +54,6 @@ describe("GUI Test", () => { await TestUtils.waitForElement( () => GUISelectors.getThreadMessageByText(view, "I'm fine"), - 5000, ); }).timeout(600000000); }); From b9f161f6d8b4e7400dff25912881f41f472a9137 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:43:13 -0800 Subject: [PATCH 32/43] fix: timeout --- extensions/vscode/e2e/actions/GUI.actions.ts | 4 ++++ extensions/vscode/e2e/tests/GUI.test.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/e2e/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts index 86fcb293b..9ad60e275 100644 --- a/extensions/vscode/e2e/actions/GUI.actions.ts +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -50,6 +50,10 @@ export class GUIActions { const dropdownButton = await GUISelectors.getModelDropdownButton(view); await dropdownButton.click(); + await new Promise((res) => { + setTimeout(res, 1000); + }); + const dropdownOption = await GUISelectors.getModelDropdownOption( view, option, diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index b01feb35e..66791cf74 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -52,8 +52,8 @@ describe("GUI Test", () => { await tiptap.sendKeys("How are you?"); (await GUISelectors.getSubmitInputButton(view)).click(); - await TestUtils.waitForElement( - () => GUISelectors.getThreadMessageByText(view, "I'm fine"), + await TestUtils.waitForElement(() => + GUISelectors.getThreadMessageByText(view, "I'm fine"), ); }).timeout(600000000); }); From 120e46fcbc31d0f743c3dd98e08c70fa21f5cdd5 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:50:18 -0800 Subject: [PATCH 33/43] test: timeout --- extensions/vscode/e2e/actions/GUI.actions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/vscode/e2e/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts index 9ad60e275..3c8f59100 100644 --- a/extensions/vscode/e2e/actions/GUI.actions.ts +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -5,7 +5,6 @@ import { Workbench, } from "vscode-extension-tester"; import { GUISelectors } from "../selectors/GUI.selectors"; -import { TestUtils } from "../TestUtils"; export class GUIActions { public static switchToReactIframe = async (driver: WebDriver) => { @@ -51,7 +50,7 @@ export class GUIActions { await dropdownButton.click(); await new Promise((res) => { - setTimeout(res, 1000); + setTimeout(res, 2000); }); const dropdownOption = await GUISelectors.getModelDropdownOption( From 8d06b9f381414ecc7c6c030d4730e89d80b41466 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:51:52 -0800 Subject: [PATCH 34/43] test: wait for element --- extensions/vscode/e2e/TestUtils.ts | 2 +- extensions/vscode/e2e/actions/GUI.actions.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/extensions/vscode/e2e/TestUtils.ts b/extensions/vscode/e2e/TestUtils.ts index 47651d926..05e4bc5d1 100644 --- a/extensions/vscode/e2e/TestUtils.ts +++ b/extensions/vscode/e2e/TestUtils.ts @@ -5,7 +5,7 @@ export class TestUtils { locatorFn: () => Promise, timeout: number = 5000, interval: number = 500, - ): Promise { + ): Promise { const startTime = Date.now(); while (Date.now() - startTime < timeout) { diff --git a/extensions/vscode/e2e/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts index 3c8f59100..7a6e76c04 100644 --- a/extensions/vscode/e2e/actions/GUI.actions.ts +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -5,6 +5,7 @@ import { Workbench, } from "vscode-extension-tester"; import { GUISelectors } from "../selectors/GUI.selectors"; +import { TestUtils } from "../TestUtils"; export class GUIActions { public static switchToReactIframe = async (driver: WebDriver) => { @@ -49,14 +50,10 @@ export class GUIActions { const dropdownButton = await GUISelectors.getModelDropdownButton(view); await dropdownButton.click(); - await new Promise((res) => { - setTimeout(res, 2000); + const dropdownOption = await TestUtils.waitForElement(() => { + return GUISelectors.getModelDropdownOption(view, option); }); - const dropdownOption = await GUISelectors.getModelDropdownOption( - view, - option, - ); await dropdownOption.click(); }; } From fe06296bba7f86e270b93e234670f18d7cced594 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:57:42 -0800 Subject: [PATCH 35/43] test: timeouts --- extensions/vscode/e2e/tests/GUI.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 66791cf74..6a5e820f8 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -41,7 +41,7 @@ describe("GUI Test", () => { expect(await description.getText()).has.string( "Quickly get up and running using our API keys.", ); - }); + }).timeout(20_000); it("should allow typing text in the editor", async () => { await GUIActions.selectModelFromDropdown(view, "Mock"); @@ -55,5 +55,5 @@ describe("GUI Test", () => { await TestUtils.waitForElement(() => GUISelectors.getThreadMessageByText(view, "I'm fine"), ); - }).timeout(600000000); + }).timeout(20_000); }); From 92a688c7a8c1fe1ace3426fe2be521b9f5d55afb Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 17:58:34 -0800 Subject: [PATCH 36/43] cancelStream --- gui/src/pages/gui/Chat.tsx | 3 ++- gui/src/redux/thunks/cancelStream.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gui/src/redux/thunks/cancelStream.ts diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 8545813bc..851a6f13b 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -57,6 +57,7 @@ import { setShowDialog, } from "../../redux/slices/uiSlice"; import { RootState } from "../../redux/store"; +import { cancelStream } from "../../redux/thunks/cancelStream"; import { exitEditMode } from "../../redux/thunks/exitEditMode"; import { streamResponseThunk } from "../../redux/thunks/streamResponse"; import { @@ -203,7 +204,7 @@ export function Chat() { isMetaEquivalentKeyPressed(e) && !e.shiftKey ) { - // dispatch(cancelGeneration()); TODO!!! + dispatch(cancelStream()); } }; window.addEventListener("keydown", listener); diff --git a/gui/src/redux/thunks/cancelStream.ts b/gui/src/redux/thunks/cancelStream.ts new file mode 100644 index 000000000..0f1a6aeca --- /dev/null +++ b/gui/src/redux/thunks/cancelStream.ts @@ -0,0 +1,14 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { setInactive } from "../slices/sessionSlice"; +import { ThunkApiType } from "../store"; + +export const cancelStream = createAsyncThunk( + "chat/cancelStream", + async (messages, { dispatch, extra, getState }) => { + dispatch(setInactive()); + + // If the assistant message is empty, then remove it and the user message, placing the user input in the main text box + // TODO: Waiting until next release + // dispatch(clearLastEmptyResponse()); + }, +); From 781f27728b468140b947dfd45767911ea64b6eec Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 17:59:44 -0800 Subject: [PATCH 37/43] test: ci --- extensions/vscode/e2e/tests/GUI.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 6a5e820f8..e4db4df3b 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -44,7 +44,7 @@ describe("GUI Test", () => { }).timeout(20_000); it("should allow typing text in the editor", async () => { - await GUIActions.selectModelFromDropdown(view, "Mock"); + // await GUIActions.selectModelFromDropdown(view, "Mock"); await GUIActions.selectModelFromDropdown(view, "TEST LLM"); const tiptap = await GUISelectors.getTipTapEditor(view); From 1520d0815a4737228b729906cdb9d72851fbf63a Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 18:04:02 -0800 Subject: [PATCH 38/43] abortStream() --- gui/src/redux/thunks/cancelStream.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/src/redux/thunks/cancelStream.ts b/gui/src/redux/thunks/cancelStream.ts index 0f1a6aeca..dc23c04a6 100644 --- a/gui/src/redux/thunks/cancelStream.ts +++ b/gui/src/redux/thunks/cancelStream.ts @@ -1,11 +1,12 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; -import { setInactive } from "../slices/sessionSlice"; +import { abortStream, setInactive } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; export const cancelStream = createAsyncThunk( "chat/cancelStream", async (messages, { dispatch, extra, getState }) => { dispatch(setInactive()); + dispatch(abortStream()); // If the assistant message is empty, then remove it and the user message, placing the user input in the main text box // TODO: Waiting until next release From 90603a6ccd7a713596bb8354a1d3c211f96a5c37 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 18:04:33 -0800 Subject: [PATCH 39/43] test: log listbox --- extensions/vscode/e2e/selectors/GUI.selectors.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts index b4c88aacb..c1dbdbf78 100644 --- a/extensions/vscode/e2e/selectors/GUI.selectors.ts +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -26,7 +26,10 @@ export class GUISelectors { return SelectorUtils.getElementByDataTestId(view, "model-select-button"); } - public static getModelDropdownOption(view: WebView, option: string) { + public static async getModelDropdownOption(view: WebView, option: string) { + const listbox = await view.findWebElement(By.xpath('//*[@role="listbox"]')); + + console.log("LISTBOX", await listbox.getText()); return view.findWebElement( By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`), ); From 27d20eb08b25b142a54641048670b036e201ea1d Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 6 Dec 2024 18:07:34 -0800 Subject: [PATCH 40/43] fix: ci tests --- extensions/vscode/e2e/selectors/GUI.selectors.ts | 5 +---- extensions/vscode/e2e/tests/GUI.test.ts | 2 +- extensions/vscode/package.json | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts index c1dbdbf78..b4c88aacb 100644 --- a/extensions/vscode/e2e/selectors/GUI.selectors.ts +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -26,10 +26,7 @@ export class GUISelectors { return SelectorUtils.getElementByDataTestId(view, "model-select-button"); } - public static async getModelDropdownOption(view: WebView, option: string) { - const listbox = await view.findWebElement(By.xpath('//*[@role="listbox"]')); - - console.log("LISTBOX", await listbox.getText()); + public static getModelDropdownOption(view: WebView, option: string) { return view.findWebElement( By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`), ); diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index e4db4df3b..6a5e820f8 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -44,7 +44,7 @@ describe("GUI Test", () => { }).timeout(20_000); it("should allow typing text in the editor", async () => { - // await GUIActions.selectModelFromDropdown(view, "Mock"); + await GUIActions.selectModelFromDropdown(view, "Mock"); await GUIActions.selectModelFromDropdown(view, "TEST LLM"); const tiptap = await GUISelectors.getTipTapEditor(view); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index f5beee189..9cf7db2b1 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -629,7 +629,7 @@ "e2e:clean": "rm -rf ./e2e/_output", "e2e:all": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean", "e2e:quick": "npm run e2e:compile && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean", - "e2e:ci": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:test" + "e2e:ci": "npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test" }, "devDependencies": { "@biomejs/biome": "1.6.4", From 2d09fdcb295d88295bb375078d14965f1fb6d156 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 18:57:30 -0800 Subject: [PATCH 41/43] clean up logs --- core/context/retrieval/repoMapRequest.ts | 1 - core/util/constants.ts | 1 + core/util/history.ts | 4 ++-- core/util/treeSitter.ts | 8 +++++++- extensions/vscode/package-lock.json | 4 ++-- gui/src/components/FileIcon.tsx | 10 ++++++++-- gui/src/components/mainInput/ContextItemsPeek.tsx | 6 +++--- gui/src/hooks/useHistory.tsx | 5 +++-- gui/src/redux/slices/sessionSlice.ts | 3 ++- 9 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 core/util/constants.ts diff --git a/core/context/retrieval/repoMapRequest.ts b/core/context/retrieval/repoMapRequest.ts index 57f2b339e..5c82ace95 100644 --- a/core/context/retrieval/repoMapRequest.ts +++ b/core/context/retrieval/repoMapRequest.ts @@ -66,7 +66,6 @@ This is the question that you should select relevant files for: "${input}"`; new AbortController().signal, ); const content = renderChatMessage(response); - console.debug("Repo map retrieval response: ", content); if (!content.includes("\n")) { return []; diff --git a/core/util/constants.ts b/core/util/constants.ts new file mode 100644 index 000000000..188fc0005 --- /dev/null +++ b/core/util/constants.ts @@ -0,0 +1 @@ +export const NEW_SESSION_TITLE = "New Session"; diff --git a/core/util/history.ts b/core/util/history.ts index 053c23455..622c2c9ce 100644 --- a/core/util/history.ts +++ b/core/util/history.ts @@ -3,8 +3,8 @@ import * as fs from "fs"; import { Session, SessionMetadata } from "../index.js"; import { ListHistoryOptions } from "../protocol/core.js"; +import { NEW_SESSION_TITLE } from "./constants.js"; import { getSessionFilePath, getSessionsListPath } from "./paths.js"; - function safeParseArray( value: string, errorMessage: string = "Error parsing array", @@ -80,7 +80,7 @@ class HistoryManager { console.log(`Error loading session: ${e}`); return { history: [], - title: "Failed to load session", + title: NEW_SESSION_TITLE, workspaceDirectory: "", sessionId: sessionId, }; diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index 8029c0609..daa12827d 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -231,7 +231,13 @@ export async function getSymbolsForFile( return; } - const tree = parser.parse(contents); + let tree: Parser.Tree; + try { + tree = parser.parse(contents); + } catch (e) { + console.log(`Error parsing file: ${filepath}`); + return; + } // console.log(`file: ${filepath}`); // Function to recursively find all named nodes (classes and functions) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 923f4c9b5..ea5966c13 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.244", + "version": "0.9.240", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.244", + "version": "0.9.240", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/gui/src/components/FileIcon.tsx b/gui/src/components/FileIcon.tsx index 8117ce734..96321348c 100644 --- a/gui/src/components/FileIcon.tsx +++ b/gui/src/components/FileIcon.tsx @@ -31,9 +31,15 @@ export default function FileIcon({ filename, height, width }: FileIconProps) { const sanitizedSVG = DOMPurify.sanitize(svg); return ( -
); } diff --git a/gui/src/components/mainInput/ContextItemsPeek.tsx b/gui/src/components/mainInput/ContextItemsPeek.tsx index 2f97af73b..1e3997930 100644 --- a/gui/src/components/mainInput/ContextItemsPeek.tsx +++ b/gui/src/components/mainInput/ContextItemsPeek.tsx @@ -9,11 +9,11 @@ import { getBasename } from "core/util"; import { useContext, useMemo, useState } from "react"; import { AnimatedEllipsis, lightGray, vscBackground } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { selectIsGatheringContext } from "../../redux/slices/sessionSlice"; import FileIcon from "../FileIcon"; import SafeImg from "../SafeImg"; import { getIconFromDropdownItem } from "./MentionList"; -import { useAppSelector } from "../../redux/hooks"; -import { selectIsGatheringContext } from "../../redux/slices/sessionSlice"; interface ContextItemsPeekProps { contextItems?: ContextItemWithId[]; @@ -172,7 +172,7 @@ function ContextItemsPeek({ {isGatheringContext ? ( <> - Gathering context... + Gathering context ) : ( diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index 4fcb20035..63252d8f1 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -1,5 +1,6 @@ import { Dispatch } from "@reduxjs/toolkit"; import { Session, SessionMetadata } from "core"; +import { NEW_SESSION_TITLE } from "core/util/constants"; import { renderChatMessage } from "core/util/messageContent"; import { useCallback, useContext } from "react"; import { IdeMessengerContext } from "../context/IdeMessenger"; @@ -65,7 +66,7 @@ function useHistory(dispatch: Dispatch) { } let currentTitle = title; - if (config?.ui?.getChatTitles && currentTitle === "New Session") { + if (config?.ui?.getChatTitles && currentTitle === NEW_SESSION_TITLE) { try { // Check if we have first assistant response let assistantResponse = history @@ -82,7 +83,7 @@ function useHistory(dispatch: Dispatch) { // Fallback if we get an error above or if the user has not set getChatTitles let newTitle = - currentTitle === "New Session" + currentTitle === NEW_SESSION_TITLE ? truncateText( renderChatMessage(history[0].message) .split("\n") diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 1b6f4d7f4..871b1e7eb 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -19,6 +19,7 @@ import { Session, ToolCall, } from "core"; +import { NEW_SESSION_TITLE } from "core/util/constants"; import { incrementalParseJson } from "core/util/incrementalParseJson"; import { renderChatMessage } from "core/util/messageContent"; import { v4 as uuidv4 } from "uuid"; @@ -86,7 +87,7 @@ function getBaseHistoryItem(): ChatHistoryItemWithMessageId { const initialState: SessionState = { history: [], isStreaming: false, - title: "New Session", + title: NEW_SESSION_TITLE, id: uuidv4(), selectedProfileId: "local", curCheckpointIndex: 0, From 16cb2e34f2db56688e165f556c056ab9e45380f1 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 19:04:50 -0800 Subject: [PATCH 42/43] clean more logs --- core/core.ts | 5 +---- core/indexing/docs/DocsService.ts | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/core/core.ts b/core/core.ts index 4dce3ca64..ddfacf5b9 100644 --- a/core/core.ts +++ b/core/core.ts @@ -860,10 +860,7 @@ export class Core { this.indexingCancellationController && !this.indexingCancellationController.signal.aborted ) { - return console.debug( - "Codebase indexing already in progress, skipping indexing of files\n" + - files.join("\n"), - ); + return; } this.indexingCancellationController = new AbortController(); for await (const update of (await this.codebaseIndexerPromise).refreshFiles( diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 6e841f6be..b52577a5f 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -7,9 +7,9 @@ import { ContinueConfig, EmbeddingsProvider, IDE, + IdeInfo, IndexingStatus, SiteIndexingConfig, - IdeInfo, } from "../.."; import { ConfigHandler } from "../../config/ConfigHandler"; import { addContextProvider } from "../../config/util"; @@ -69,7 +69,6 @@ export type AddParams = { favicon?: string; }; - /* General process: - On config update: @@ -476,8 +475,6 @@ export default class DocsService { const embeddings: number[][] = []; // Create embeddings of retrieved articles - console.debug(`Creating embeddings for ${articles.length} articles`); - for (let i = 0; i < articles.length; i++) { const article = articles[i]; From 12018ec24d70afff4c7915c62000f9c917f0fabb Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 6 Dec 2024 19:15:53 -0800 Subject: [PATCH 43/43] fix tests --- core/util/history.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/util/history.test.ts b/core/util/history.test.ts index 048087564..dbcf69619 100644 --- a/core/util/history.test.ts +++ b/core/util/history.test.ts @@ -1,6 +1,7 @@ import { v4 as uuidv4 } from "uuid"; import { Session } from ".."; +import { NEW_SESSION_TITLE } from "./constants"; import historyManager from "./history"; import { getSessionFilePath } from "./paths"; @@ -31,7 +32,7 @@ describe("No sessions have been created", () => { const session = historyManager.load(testSessionId); expect(session).toEqual({ history: [], - title: "Failed to load session", + title: NEW_SESSION_TITLE, workspaceDirectory: "", sessionId: testSessionId, });