diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b73cdb3ad..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-12 # should migrate this to the newer x64 version of macos-14 + - os: macos-13 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-12 # 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 a65e79c7f..bd5f4b7ac 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.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-13 platform: darwin arch: x64 npm_config_arch: x64 - - os: macos-12 # same here, especially + - os: macos-13 platform: darwin arch: arm64 npm_config_arch: arm64 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/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 55cde067a..180c339e6 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -10,6 +10,7 @@ import { showWhateverWeHaveAtXMs, skipPrefixes, stopAtLines, + stopAtLinesExact, stopAtRepeatingLines, stopAtSimilarLine, streamWithNewLines, @@ -42,6 +43,12 @@ export class StreamTransformPipeline { let lineGenerator = streamLines(charGenerator); lineGenerator = stopAtLines(lineGenerator, fullStop); + const lineBelowCursor = this.getLineBelowCursor(helper); + if (lineBelowCursor.trim() !== "") { + lineGenerator = stopAtLinesExact(lineGenerator, fullStop, [ + lineBelowCursor, + ]); + } lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop); lineGenerator = avoidEmptyComments( lineGenerator, diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.ts b/core/autocomplete/filtering/streamTransforms/lineStream.ts index aaeec1291..851dea88a 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.ts @@ -2,7 +2,6 @@ import { distance } from "fastest-levenshtein"; import { DiffLine } from "../../.."; import { LineStream } from "../../../diff/util"; -import { BRACKETS, BRACKETS_REVERSE } from "../BracketMatchingService"; export type LineFilter = (args: { lines: LineStream; @@ -270,6 +269,20 @@ export async function* stopAtLines( } } +export async function* stopAtLinesExact( + stream: LineStream, + fullStop: () => void, + linesToStopAt: string[], +): LineStream { + for await (const line of stream) { + if (linesToStopAt.some((stopAt) => line === stopAt)) { + fullStop(); + break; + } + yield line; + } +} + /** * Filters a LineStream, skipping specified prefixes on the first line. * @param {LineStream} lines - The input stream of lines. diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index 277c8cdc8..f83de1607 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -810,8 +810,7 @@ func main() {}`, }`, expectedCompletion: `string State string - ZipCode string -}`, + ZipCode string`, }, { @@ -1118,8 +1117,7 @@ impl Calculator { self.result /= number; } else { println!("Cannot divide by zero."); - } -}`, + }`, }, { description: "Should autocomplete Rust struct definition", @@ -1600,8 +1598,7 @@ interface User { age: number; }`, expectedCompletion: `mail: string; - age: number; -}`, + age: number;`, }, { description: "Should autocomplete TypeScript interface declarations", @@ -1853,8 +1850,7 @@ let john = { FirstName = "John"; LastName = "Doe"; Age = 30 }`, Address: string }`, expectedCompletion: ` - Address: string -}`, + Address: string`, }, { 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/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/core.ts b/core/core.ts index e943e7a7d..f201849a6 100644 --- a/core/core.ts +++ b/core/core.ts @@ -859,10 +859,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/index.d.ts b/core/index.d.ts index 39a920499..b6a29e1d0 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -806,6 +806,7 @@ type ModelProvider = | "nvidia" | "vllm" | "mock" + | "test" | "cerebras" | "askSage" | "vertexai" 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]; 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/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) { 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.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, }); 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/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" { 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/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/TestUtils.ts b/extensions/vscode/e2e/TestUtils.ts new file mode 100644 index 000000000..05e4bc5d1 --- /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 = 5000, + 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/actions/GUI.actions.ts b/extensions/vscode/e2e/actions/GUI.actions.ts new file mode 100644 index 000000000..7a6e76c04 --- /dev/null +++ b/extensions/vscode/e2e/actions/GUI.actions.ts @@ -0,0 +1,59 @@ +import { + WebDriver, + WebElement, + WebView, + Workbench, +} from "vscode-extension-tester"; +import { GUISelectors } from "../selectors/GUI.selectors"; +import { TestUtils } from "../TestUtils"; + +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 TestUtils.waitForElement(() => { + return 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..b4c88aacb --- /dev/null +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -0,0 +1,40 @@ +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 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-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/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts new file mode 100644 index 000000000..6a5e820f8 --- /dev/null +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -0,0 +1,59 @@ +import { + EditorView, + WebView, + WebDriver, + 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; + let driver: WebDriver; + + before(async function () { + this.timeout(10000000); + + await VSBrowser.instance.openResources(path.join("e2e/test-continue")); + + 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.", + ); + }).timeout(20_000); + + it("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 TestUtils.waitForElement(() => + GUISelectors.getThreadMessageByText(view, "I'm fine"), + ); + }).timeout(20_000); +}); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 42b504a66..b63ed82f9 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.240", + "version": "0.9.242", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -625,9 +625,11 @@ "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: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: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 && 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 && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test" }, "devDependencies": { "@biomejs/biome": "1.6.4", 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/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() { >
{isInEditMode && ( { loadLastSession().catch((e) => console.error(`Failed to load last session: ${e}`), diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 2ddcfccc6..c8b3f1048 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"; @@ -73,7 +74,7 @@ function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { const initialState: SessionState = { history: [], isStreaming: false, - title: "New Session", + title: NEW_SESSION_TITLE, id: uuidv4(), selectedProfileId: "local", curCheckpointIndex: 0, diff --git a/gui/src/redux/thunks/cancelStream.ts b/gui/src/redux/thunks/cancelStream.ts new file mode 100644 index 000000000..dc23c04a6 --- /dev/null +++ b/gui/src/redux/thunks/cancelStream.ts @@ -0,0 +1,15 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +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 + // dispatch(clearLastEmptyResponse()); + }, +);