diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index b5e8896a9..3108307e5 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -16,8 +16,9 @@ jobs: repo-token: ${{ secrets.CI_GITHUB_TOKEN }} assignees: sestinj,Patrick-Erichsen numOfAssignee: 1 - - name: Add default labels + - name: "Add default labels" uses: actions-ecosystem/action-add-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - labels: "needs-triage" + labels: | + "needs-triage" diff --git a/.prettierrc b/.prettierrc index 46664808a..7b5484dd7 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,8 @@ "tabWidth": 2, "useTabs": false, "trailingComma": "all", + "semi": true, + "singleQuote": false, + "bracketSpacing": true, "plugins": ["prettier-plugin-tailwindcss"] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index fb4e1241d..8331b5380 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -41,7 +41,7 @@ "background": { "activeOnStart": true, "beginsPattern": ">", - "endsPattern": "node scripts/esbuild.js --sourcemap --watch" + "endsPattern": "VS Code Extension esbuild complete" } } ] diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index ae0eb42b8..f2c95083f 100644 --- a/core/context/providers/DiffContextProvider.ts +++ b/core/context/providers/DiffContextProvider.ts @@ -17,7 +17,7 @@ class DiffContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { - const diff = await extras.ide.getDiff(false); + const diff = await extras.ide.getDiff(this.options.includeUnstaged ?? true); return [ { description: "The current git diff", diff --git a/core/context/rerankers/tei.ts b/core/context/rerankers/tei.ts index 61f38b98b..2d3f9ab12 100644 --- a/core/context/rerankers/tei.ts +++ b/core/context/rerankers/tei.ts @@ -15,6 +15,7 @@ export class HuggingFaceTEIReranker implements Reranker { apiBase?: string; truncate?: boolean; truncation_direction?: string; + apiKey?: string; }, ) {} @@ -24,9 +25,17 @@ export class HuggingFaceTEIReranker implements Reranker { apiBase += "/"; } + const headers: Record = { + "Content-Type": "application/json", + }; + + if (this.params.apiKey) { + headers["Authorization"] = `Bearer ${this.params.apiKey}`; + } + const resp = await fetch(new URL("rerank", apiBase), { method: "POST", - headers: { "Content-Type": "application/json" }, + headers, body: JSON.stringify({ query: query, return_text: false, diff --git a/core/index.d.ts b/core/index.d.ts index 133270873..5b0b892f6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -48,9 +48,9 @@ export interface IndexingProgressUpdate { export type PromptTemplate = | string | (( - history: ChatMessage[], - otherData: Record, - ) => string | ChatMessage[]); + history: ChatMessage[], + otherData: Record, + ) => string | ChatMessage[]); export interface ILLM extends LLMOptions { get providerName(): ModelProvider; @@ -646,7 +646,8 @@ type ModelProvider = | "cerebras" | "askSage" | "vertexai" - | "nebius"; + | "nebius" + | "xAI"; export type ModelName = | "AUTODETECT" @@ -696,6 +697,8 @@ export type ModelName = | "llama3.2-3b" | "llama3.2-11b" | "llama3.2-90b" + // xAI + | "grok-beta" // Other Open-source | "phi2" | "phind-codellama-34b" @@ -1054,9 +1057,9 @@ export interface Config { embeddingsProvider?: EmbeddingsProviderDescription | EmbeddingsProvider; /** The model that Continue will use for tab autocompletions. */ tabAutocompleteModel?: - | CustomLLM - | ModelDescription - | (CustomLLM | ModelDescription)[]; + | CustomLLM + | ModelDescription + | (CustomLLM | ModelDescription)[]; /** Options for tab autocomplete */ tabAutocompleteOptions?: Partial; /** UI styles customization */ diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index d6c3b684c..0224dc3a0 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -404,12 +404,15 @@ export default class DocsService { async getFavicon(startUrl: string) { const db = await this.getOrCreateSqliteDb(); - const { favicon } = await db.get( + const result = await db.get( `SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`, startUrl, ); - return favicon; + if (!result) { + return; + } + return result.favicon; } private async init(configHandler: ConfigHandler) { diff --git a/core/indexing/docs/preIndexedDocs.ts b/core/indexing/docs/preIndexedDocs.ts index 83b439d42..48b777b21 100644 --- a/core/indexing/docs/preIndexedDocs.ts +++ b/core/indexing/docs/preIndexedDocs.ts @@ -299,30 +299,32 @@ const preIndexedDocs: Record< rootUrl: "https://docs.godotengine.org/en/latest/", faviconUrl: "https://godotengine.org/favicon.ico", }, - "https://docs.amplify.aws/react/": { + "https://docs.amplify.aws/react/start/": { title: "AWS Amplify (Gen 2)", startUrl: "https://docs.amplify.aws/react/start/", rootUrl: "https://docs.amplify.aws/react/", - faviconUrl: "https://docs.amplify.aws/favicon.ico" + faviconUrl: "https://docs.amplify.aws/favicon.ico", }, "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/": { title: "AWS SDK for JavaScript v3", startUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/", rootUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/", - faviconUrl: "https://docs.aws.amazon.com/favicon.ico" + faviconUrl: "https://docs.aws.amazon.com/favicon.ico", }, "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html": { title: "AWS CDK v2", - startUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html", + startUrl: + "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html", rootUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/", - faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png" + faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png", }, "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html": { title: "AWS CLI commands", - startUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html", + startUrl: + "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html", rootUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/", - faviconUrl: "https://docs.aws.amazon.com/favicon.ico" - } + faviconUrl: "https://docs.aws.amazon.com/favicon.ico", + }, }; export default preIndexedDocs; diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index c6b1874c3..64e0634a5 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -146,7 +146,8 @@ function autodetectTemplateType(model: string): TemplateType | undefined { lower.includes("command") || lower.includes("chat-bison") || lower.includes("pplx") || - lower.includes("gemini") + lower.includes("gemini") || + lower.includes("grok") ) { return undefined; } diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 4a6b1d539..64882b09b 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -45,6 +45,7 @@ import WatsonX from "./WatsonX"; import ContinueProxy from "./stubs/ContinueProxy"; import VertexAI from "./VertexAI"; import Asksage from "./Asksage"; +import xAI from "./xAI"; const LLMs = [ Anthropic, @@ -84,7 +85,8 @@ const LLMs = [ Cerebras, Asksage, Nebius, - VertexAI + VertexAI, + xAI ]; export async function llmFromDescription( diff --git a/core/llm/llms/xAI.ts b/core/llm/llms/xAI.ts new file mode 100644 index 000000000..aa33ee70d --- /dev/null +++ b/core/llm/llms/xAI.ts @@ -0,0 +1,20 @@ +import { LLMOptions, ModelProvider } from "../../index.js"; + +import OpenAI from "./OpenAI.js"; + +class xAI extends OpenAI { + static providerName: ModelProvider = "xAI"; + static defaultOptions: Partial = { + apiBase: "https://api.x.ai/v1/", + }; + + private static MODEL_IDS: { [name: string]: string } = { + "grok-beta": "grok-beta", // Future names might not line up + }; + + protected _convertModelName(model: string) { + return xAI.MODEL_IDS[model] || this.model; + } +} + +export default xAI; diff --git a/docs/docs/customize/model-providers/top-level/xAI.md b/docs/docs/customize/model-providers/top-level/xAI.md new file mode 100644 index 000000000..fbdfa83ad --- /dev/null +++ b/docs/docs/customize/model-providers/top-level/xAI.md @@ -0,0 +1,53 @@ +--- +title: xAI +slug: ../xai +--- + +:::info + +You can get an API key from the [xAI console](https://console.x.ai/) + +::: + +## Chat model + +We recommend configuring **grok-beta** as your chat model. + +```json title="config.json" +{ + "models": [ + { + "title": "Grok Beta", + "provider": "xAI", + "model": "grok-beta", + "apiKey": "[API_KEY]" + } + ] +} +``` + +## Autocomplete model + +xAI currently does not offer any autocomplete models. + +[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers. + +## Embeddings model + +xAI currently does not offer any embeddings models. + +[Click here](../../model-types/embeddings.md) to see a list of embeddings model providers. + +## Reranking model + +xAI currently does not offer any reranking models. + +[Click here](../../model-types/reranking.md) to see a list of reranking model providers. + +## Legacy Completions + +To force usage of `chat/completions` instead of `completions` endpoint you can set + +```json +"useLegacyCompletionsEndpoint": false +``` diff --git a/docs/docs/customize/model-types/reranking.md b/docs/docs/customize/model-types/reranking.md index 4aceade4a..a87918cb2 100644 --- a/docs/docs/customize/model-types/reranking.md +++ b/docs/docs/customize/model-types/reranking.md @@ -72,6 +72,7 @@ The `"modelTitle"` field must match one of the models in your "models" array in "name": "huggingface-tei", "params": { "apiBase": "http://localhost:8080", + "apiKey": "", "truncate": true, "truncation_direction": "Right" } diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 19e8f386e..391273943 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -421,7 +421,7 @@ Several experimental config parameters are available, as described below: - `fix`: Prompt for fixing code. - `optimize`: Prompt for optimizing code. - `fixGrammar`: Prompt for fixing grammar or spelling. -- `useChromiumForDocsCrawling`: Use chromium to crawl docs instead of default lighter-weight tool that can't render sites. Downloads and installs Chromium to `~/.continue/.utils`. +- `useChromiumForDocsCrawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`.. Example diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ConfigJsonSchemaProviderFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ConfigJsonSchemaProviderFactory.kt index c303b26fb..2056d216e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ConfigJsonSchemaProviderFactory.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ConfigJsonSchemaProviderFactory.kt @@ -22,7 +22,7 @@ class ConfigJsonSchemaProviderFactory : JsonSchemaProviderFactory { class ConfigJsonSchemaFileProvider : JsonSchemaFileProvider { override fun isAvailable(file: VirtualFile): Boolean { - return path.endsWith("/.continue/config.json") + return file.path.endsWith("/.continue/config.json") } override fun getName(): String { 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 f73ba509c..5db34ff29 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 @@ -2,10 +2,12 @@ package com.github.continuedev.continueintellijextension.services import com.github.continuedev.continueintellijextension.constants.getConfigJsPath import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath +import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.* import com.intellij.openapi.options.Configurable import com.intellij.openapi.project.DumbAware +import com.intellij.openapi.util.SystemInfo import com.intellij.util.concurrency.AppExecutorUtil import com.intellij.util.messages.Topic import kotlinx.serialization.Serializable @@ -28,6 +30,7 @@ class ContinueSettingsComponent : DumbAware { val userToken: JTextField = JTextField() val enableTabAutocomplete: JCheckBox = JCheckBox("Enable Tab Autocomplete") val enableContinueTeamsBeta: JCheckBox = JCheckBox("Enable Continue for Teams Beta") + val enableOSR: JCheckBox = JCheckBox("Enable Off-Screen Rendering") val displayEditorTooltip: JCheckBox = JCheckBox("Display Editor Tooltip") init { @@ -56,6 +59,8 @@ class ContinueSettingsComponent : DumbAware { constraints.gridy++ panel.add(enableContinueTeamsBeta, constraints) constraints.gridy++ + panel.add(enableOSR, constraints) + constraints.gridy++ panel.add(displayEditorTooltip, constraints) constraints.gridy++ @@ -87,6 +92,7 @@ open class ContinueExtensionSettings : PersistentStateComponent= minBuildNumber +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index 03d4f4715..7891a02dc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -5,6 +5,7 @@ import com.github.continuedev.continueintellijextension.constants.MessageTypes import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath import com.github.continuedev.continueintellijextension.`continue`.* import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory +import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.google.gson.Gson import com.google.gson.JsonObject @@ -78,7 +79,8 @@ class ContinueBrowser(val project: Project, url: String) { val browser: JBCefBrowser init { - this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(shouldRenderOffScreen()).build() + val enableOSR = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR + this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(enableOSR).build() browser.jbCefClient.setProperty( @@ -274,34 +276,4 @@ class ContinueBrowser(val project: Project, url: String) { return """window.postMessage($jsonData, "*");""" } - /** - * This function checks if the pluginSinceBuild is greater than or equal to 233, which corresponds - * to IntelliJ platform version 2023.3 and later. - * - * Setting `setOffScreenRendering` to `false` causes a number of issues such as a white screen flash when loading - * the GUI and the inability to set `cursor: pointer`. However, setting `setOffScreenRendering` to `true` on - * platform versions prior to 2023.3.4 causes larger issues such as an inability to type input for certain langauges, - * e.g. Korean. - * - * References: - * 1. https://youtrack.jetbrains.com/issue/IDEA-347828/JCEF-white-flash-when-tool-window-show#focus=Comments-27-9334070.0-0 - * This issue mentions that white screen flash problems were resolved in platformVersion 2023.3.4. - * 2. https://www.jetbrains.com/idea/download/other.html - * This documentation shows mappings from platformVersion to branchNumber. - * - * We use the branchNumber (e.g., 233) instead of the full version number (e.g., 2023.3.4) because - * 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 - return currentBuildNumber >= minBuildNumber - } } diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c0a734b02..f18bdbb6a 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -88,7 +88,10 @@ "type": "string" } }, - "required": ["cert", "key"] + "required": [ + "cert", + "key" + ] }, "RequestOptions": { "title": "RequestOptions", @@ -198,7 +201,8 @@ "cerebras", "askSage", "nebius", - "vertexai" + "vertexai", + "xAI" ], "markdownEnumDescriptions": [ "### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", @@ -233,7 +237,8 @@ "### NVIDIA NIMs\nNVIDIA offers a single API to access almost any language model. To find out more, visit the [LLM APIs Documentation](https://docs.api.nvidia.com/nim/reference/llm-apis).\nFor information specific to getting a key, please check out the [docs here](https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html#option-1-from-api-catalog)", "### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server.", "### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/).", - "### Ask Sage\nAsk Sage is an agnostic hosted service that provides language models. To get started with Ask Sage:\n1. Obtain an API key from your account. For more information, visit [Ask Sage](https://docs.asksage.ai/).\n2. Paste the API key below.\n3. Select a model preset.\n> [Reference](https://docs.asksage.ai/)" + "### Ask Sage\nAsk Sage is an agnostic hosted service that provides language models. To get started with Ask Sage:\n1. Obtain an API key from your account. For more information, visit [Ask Sage](https://docs.asksage.ai/).\n2. Paste the API key below.\n3. Select a model preset.\n> [Reference](https://docs.asksage.ai/)", + "### xAI offers a world class developer tool set to build scalable applications powered by Grok. To get started, obtain an API key from [the x Console](https://console.x.ai/), and see the [docs](https://docs.x.ai/docs/)" ], "type": "string" }, @@ -401,7 +406,10 @@ "title": "Api Type", "markdownDescription": "OpenAI API type, either `openai` or `azure`", "x-intellij-html-description": "OpenAI API type, either openai or azure", - "enum": ["openai", "azure"] + "enum": [ + "openai", + "azure" + ] }, "apiVersion": { "title": "Api Version", @@ -424,7 +432,11 @@ } } }, - "required": ["title", "provider", "model"], + "required": [ + "title", + "provider", + "model" + ], "allOf": [ { "if": { @@ -434,7 +446,9 @@ } }, "not": { - "required": ["provider"] + "required": [ + "provider" + ] } }, "then": { @@ -459,50 +473,72 @@ "together", "cloudflare", "sambanova", - "nebius" + "nebius", + "xAI" ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { - "required": ["apiKey"] + "required": [ + "apiKey" + ] } }, { "if": { "properties": { "provider": { - "enum": ["bedrockimport"] + "enum": [ + "bedrockimport" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { - "required": ["modelArn"] + "required": [ + "modelArn" + ] } }, { "if": { "properties": { "provider": { - "enum": ["huggingface-tgi", "huggingface-inference-api"] + "enum": [ + "huggingface-tgi", + "huggingface-inference-api" + ] } } }, "then": { - "required": ["apiBase"] + "required": [ + "apiBase" + ] }, - "required": ["provider"] + "required": [ + "provider" + ] }, { "if": { "properties": { "provider": { - "enum": ["openai"] + "enum": [ + "openai" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -522,10 +558,14 @@ "if": { "properties": { "provider": { - "enum": ["cloudflare"] + "enum": [ + "cloudflare" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -583,10 +623,14 @@ "if": { "properties": { "provider": { - "enum": ["openai"] + "enum": [ + "openai" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -618,10 +662,45 @@ "if": { "properties": { "provider": { - "enum": ["replicate"] + "enum": [ + "xAI" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "grok-beta", + "AUTODETECT" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "replicate" + ] + } + }, + "required": [ + "provider" + ] }, "then": { "properties": { @@ -655,10 +734,14 @@ "if": { "properties": { "provider": { - "enum": ["free-trial"] + "enum": [ + "free-trial" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -682,7 +765,9 @@ "if": { "properties": { "provider": { - "enum": ["openai"] + "enum": [ + "openai" + ] }, "apiType": { "not": { @@ -690,7 +775,9 @@ } } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -752,10 +839,14 @@ "if": { "properties": { "provider": { - "enum": ["anthropic"] + "enum": [ + "anthropic" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -796,15 +887,22 @@ "if": { "properties": { "provider": { - "enum": ["cohere"] + "enum": [ + "cohere" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { "model": { - "enum": ["command-r", "command-r-plus"] + "enum": [ + "command-r", + "command-r-plus" + ] } } } @@ -813,10 +911,14 @@ "if": { "properties": { "provider": { - "enum": ["bedrock"] + "enum": [ + "bedrock" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -841,10 +943,14 @@ "if": { "properties": { "provider": { - "enum": ["sagemaker"] + "enum": [ + "sagemaker" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -858,10 +964,14 @@ "if": { "properties": { "provider": { - "enum": ["gemini"] + "enum": [ + "gemini" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -891,10 +1001,14 @@ "if": { "properties": { "provider": { - "enum": ["together"] + "enum": [ + "together" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -932,10 +1046,14 @@ "if": { "properties": { "provider": { - "enum": ["deepinfra"] + "enum": [ + "deepinfra" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -959,7 +1077,9 @@ ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1008,10 +1128,14 @@ "if": { "properties": { "provider": { - "enum": ["ollama"] + "enum": [ + "ollama" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1063,10 +1187,14 @@ "if": { "properties": { "provider": { - "enum": ["mistral"] + "enum": [ + "mistral" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1088,23 +1216,34 @@ "if": { "properties": { "provider": { - "enum": ["vertexai"] + "enum": [ + "vertexai" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { - "required": ["projectId", "region"] + "required": [ + "projectId", + "region" + ] } }, { "if": { "properties": { "provider": { - "enum": ["deepseek"] + "enum": [ + "deepseek" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1121,7 +1260,10 @@ } }, "model": { - "enum": ["deepseek-chat", "deepseek-coder"] + "enum": [ + "deepseek-chat", + "deepseek-coder" + ] } } } @@ -1130,10 +1272,14 @@ "if": { "properties": { "provider": { - "enum": ["groq"] + "enum": [ + "groq" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1158,15 +1304,21 @@ "if": { "properties": { "provider": { - "enum": ["fireworks"] + "enum": [ + "fireworks" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { "model": { - "enum": ["starcoder-7b"] + "enum": [ + "starcoder-7b" + ] } } } @@ -1178,20 +1330,29 @@ "const": "azure" } }, - "required": ["apiType"] + "required": [ + "apiType" + ] }, "then": { - "required": ["deployment", "apiBase"] + "required": [ + "deployment", + "apiBase" + ] } }, { "if": { "properties": { "provider": { - "enum": ["openai"] + "enum": [ + "openai" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1208,7 +1369,9 @@ "const": "llamafile" } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1222,15 +1385,22 @@ "if": { "properties": { "provider": { - "enum": ["cerebras"] + "enum": [ + "cerebras" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { "model": { - "enum": ["llama3.1-8b", "llama3.1-70b"] + "enum": [ + "llama3.1-8b", + "llama3.1-70b" + ] } } } @@ -1239,10 +1409,14 @@ "if": { "properties": { "provider": { - "enum": ["text-gen-webui"] + "enum": [ + "text-gen-webui" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1256,10 +1430,14 @@ "if": { "properties": { "provider": { - "enum": ["flowise"] + "enum": [ + "flowise" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1286,7 +1464,10 @@ "type": "string" } }, - "required": ["key", "value"] + "required": [ + "key", + "value" + ] } }, "additionalFlowiseConfiguration": { @@ -1305,7 +1486,10 @@ "description": "Configuration Property value" } }, - "required": ["key", "value"] + "required": [ + "key", + "value" + ] } }, "model": { @@ -1380,10 +1564,14 @@ "if": { "properties": { "provider": { - "enum": ["watsonx"] + "enum": [ + "watsonx" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1419,24 +1607,36 @@ ] } }, - "required": ["apiBase", "apiKey", "apiVersion"] + "required": [ + "apiBase", + "apiKey", + "apiVersion" + ] } }, { "if": { "properties": { "provider": { - "enum": ["sambanova"] + "enum": [ + "sambanova" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { "model": { "anyOf": [ { - "enum": ["llama3.1-8b", "llama3.1-70b", "llama3.1-405b"] + "enum": [ + "llama3.1-8b", + "llama3.1-70b", + "llama3.1-405b" + ] }, { "type": "string" @@ -1451,10 +1651,14 @@ "if": { "properties": { "provider": { - "enum": ["ask-sage"] + "enum": [ + "ask-sage" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -1509,7 +1713,9 @@ "type": "string" } }, - "required": ["default"] + "required": [ + "default" + ] }, "SlashCommand": { "title": "SlashCommand", @@ -1566,7 +1772,9 @@ "if": { "properties": { "name": { - "enum": ["issue"] + "enum": [ + "issue" + ] } } }, @@ -1579,17 +1787,23 @@ "description": "Enter the URL of the GitHub repository for which you want to generate the issue." } }, - "required": ["repositoryUrl"] + "required": [ + "repositoryUrl" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["edit"] + "enum": [ + "edit" + ] } } }, @@ -1615,7 +1829,9 @@ "if": { "properties": { "name": { - "enum": ["share"] + "enum": [ + "share" + ] } } }, @@ -1637,7 +1853,9 @@ "if": { "properties": { "name": { - "enum": ["commit"] + "enum": [ + "commit" + ] } } }, @@ -1656,7 +1874,10 @@ } } ], - "required": ["name", "description"] + "required": [ + "name", + "description" + ] }, "CustomCommand": { "title": "CustomCommand", @@ -1675,7 +1896,11 @@ "type": "string" } }, - "required": ["name", "prompt", "description"] + "required": [ + "name", + "prompt", + "description" + ] }, "ContextProviderWithParams": { "title": "ContextProviderWithParams", @@ -1755,7 +1980,9 @@ "if": { "properties": { "name": { - "enum": ["discord"] + "enum": [ + "discord" + ] } } }, @@ -1788,11 +2015,15 @@ "description": "The name of the channel" } }, - "required": ["id"] + "required": [ + "id" + ] } } }, - "required": ["discordKey"] + "required": [ + "discordKey" + ] } } }, @@ -1801,14 +2032,18 @@ { "properties": { "params": { - "required": ["guildId"] + "required": [ + "guildId" + ] } } }, { "properties": { "params": { - "required": ["channels"] + "required": [ + "channels" + ] } } } @@ -1821,7 +2056,9 @@ "if": { "properties": { "name": { - "enum": ["google"] + "enum": [ + "google" + ] } } }, @@ -1834,17 +2071,23 @@ "description": "Your API key for https://serper.dev in order to get Google search results" } }, - "required": ["serperApiKey"] + "required": [ + "serperApiKey" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["web"] + "enum": [ + "web" + ] } } }, @@ -1861,14 +2104,18 @@ } } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["open"] + "enum": [ + "open" + ] } } }, @@ -1890,7 +2137,9 @@ "if": { "properties": { "name": { - "enum": ["issue"] + "enum": [ + "issue" + ] } } }, @@ -1919,24 +2168,37 @@ "type": { "type": "string", "description": "The type of issues to search for", - "enum": ["open", "closed", "all"] + "enum": [ + "open", + "closed", + "all" + ] } }, - "required": ["owner", "repo"] + "required": [ + "owner", + "repo" + ] } } }, - "required": ["repos"] + "required": [ + "repos" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["database"] + "enum": [ + "database" + ] } } }, @@ -1957,7 +2219,11 @@ "connection_type": { "type": "string", "description": "The type of database (e.g., 'postgres', 'mysql')", - "enum": ["postgres", "mysql", "sqlite"] + "enum": [ + "postgres", + "mysql", + "sqlite" + ] }, "connection": { "type": "object", @@ -1990,21 +2256,31 @@ "required": [] } }, - "required": ["name", "connection_type", "connection"] + "required": [ + "name", + "connection_type", + "connection" + ] } } }, - "required": ["connections"] + "required": [ + "connections" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["gitlab-mr"] + "enum": [ + "gitlab-mr" + ] } } }, @@ -2025,17 +2301,23 @@ "description": "If you have code selected, filters out comments that aren't related to the selection." } }, - "required": ["token"] + "required": [ + "token" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["jira"] + "enum": [ + "jira" + ] } } }, @@ -2082,17 +2364,24 @@ ] } }, - "required": ["domain", "token"] + "required": [ + "domain", + "token" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["http"] + "enum": [ + "http" + ] } } }, @@ -2110,17 +2399,24 @@ "type": "object" } }, - "required": ["url"] + "required": [ + "url" + ] } }, - "required": ["params"] + "required": [ + "params" + ] } }, { "if": { "properties": { "name": { - "enum": ["codebase", "folder"] + "enum": [ + "codebase", + "folder" + ] } } }, @@ -2155,7 +2451,9 @@ "if": { "properties": { "name": { - "enum": ["postgres"] + "enum": [ + "postgres" + ] } } }, @@ -2207,14 +2505,22 @@ } } }, - "required": ["host", "port", "user", "password", "database"] + "required": [ + "host", + "port", + "user", + "password", + "database" + ] } }, { "if": { "properties": { "name": { - "enum": ["greptile"] + "enum": [ + "greptile" + ] } } }, @@ -2237,11 +2543,16 @@ } } }, - "required": ["GreptileToken", "GithubToken"] + "required": [ + "GreptileToken", + "GithubToken" + ] } } ], - "required": ["name"] + "required": [ + "name" + ] }, "SerializedContinueConfig": { "title": "config.json", @@ -2275,7 +2586,10 @@ "description": "The URL path to a favicon for the site - by default, it will be `/favicon.ico` path from the Start URL" } }, - "required": ["title", "startUrl"] + "required": [ + "title", + "startUrl" + ] } }, "allowAnonymousTelemetry": { @@ -2451,29 +2765,44 @@ "type": "string" } }, - "required": ["provider"], + "required": [ + "provider" + ], "allOf": [ { "if": { "properties": { "provider": { - "enum": ["cohere", "voyage", "nvidia", "gemini"] + "enum": [ + "cohere", + "voyage", + "nvidia", + "gemini" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { - "required": ["apiKey"] + "required": [ + "apiKey" + ] } }, { "if": { "properties": { "provider": { - "enum": ["sagemaker"] + "enum": [ + "sagemaker" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -2481,17 +2810,23 @@ "description": "SageMaker endpoint name" } }, - "required": ["model"] + "required": [ + "model" + ] } }, { "if": { "properties": { "provider": { - "enum": ["vertexai"] + "enum": [ + "vertexai" + ] } }, - "required": ["provider"] + "required": [ + "provider" + ] }, "then": { "properties": { @@ -2506,7 +2841,11 @@ "default": "text-embedding-004" } }, - "required": ["projectId", "model", "region"] + "required": [ + "projectId", + "model", + "region" + ] } } ] @@ -2529,16 +2868,22 @@ "type": "object" } }, - "required": ["name"], + "required": [ + "name" + ], "allOf": [ { "if": { "properties": { "name": { - "enum": ["cohere"] + "enum": [ + "cohere" + ] } }, - "required": ["name"] + "required": [ + "name" + ] }, "then": { "properties": { @@ -2560,7 +2905,9 @@ "type": "string" } }, - "required": ["apiKey"] + "required": [ + "apiKey" + ] } } } @@ -2569,10 +2916,14 @@ "if": { "properties": { "name": { - "enum": ["llm"] + "enum": [ + "llm" + ] } }, - "required": ["name"] + "required": [ + "name" + ] }, "then": { "properties": { @@ -2583,7 +2934,9 @@ "type": "string" } }, - "required": ["modelTitle"] + "required": [ + "modelTitle" + ] } } } @@ -2592,10 +2945,14 @@ "if": { "properties": { "name": { - "enum": ["voyage"] + "enum": [ + "voyage" + ] } }, - "required": ["name"] + "required": [ + "name" + ] }, "then": { "properties": { @@ -2614,7 +2971,9 @@ ] } }, - "required": ["apiKey"] + "required": [ + "apiKey" + ] } } } @@ -2623,10 +2982,14 @@ "if": { "properties": { "name": { - "enum": ["huggingface-tei"] + "enum": [ + "huggingface-tei" + ] } }, - "required": ["name"] + "required": [ + "name" + ] }, "then": { "properties": { @@ -2637,18 +3000,26 @@ "type": "string", "default": "http://localhost:8080" }, + "apiKey": { + "type": "string" + }, "truncate": { "type": "boolean", "description": "Whether to truncate long sequences to the maximum allowed context length.", "default": false }, "truncation_direction": { - "enum": ["Right", "Left"], + "enum": [ + "Right", + "Left" + ], "description": "Whether to truncate sequences from the left or right.", "default": "Right" } }, - "required": ["apiBase"] + "required": [ + "apiBase" + ] } }, "if": { @@ -2659,7 +3030,9 @@ } }, "then": { - "required": ["truncation_direction"] + "required": [ + "truncation_direction" + ] } } } @@ -2730,7 +3103,11 @@ "description": "An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables." }, "multilineCompletions": { - "enum": ["always", "never", "auto"], + "enum": [ + "always", + "never", + "auto" + ], "description": "If set to true, Continue will only complete a single line at a time." }, "useCache": { @@ -2759,7 +3136,10 @@ "type": "object", "properties": { "codeBlockToolbarPosition": { - "enum": ["top", "bottom"], + "enum": [ + "top", + "bottom" + ], "default": "top", "description": "Whether to show the copy and apply code buttons at the top or bottom of code blocks in the sidebar." }, @@ -2785,7 +3165,10 @@ "properties": { "provider": { "type": "string", - "enum": ["posthog", "logstash"], + "enum": [ + "posthog", + "logstash" + ], "description": "The 3rd party analytics provider to use.", "default": "posthog", "markdownEnumDescriptions": [ @@ -2801,30 +3184,40 @@ "description": "The client key to use for analytics" } }, - "required": ["provider"], + "required": [ + "provider" + ], "allOf": [ { "if": { "properties": { "provider": { - "enum": ["posthog"] + "enum": [ + "posthog" + ] } } }, "then": { - "required": ["clientKey"] + "required": [ + "clientKey" + ] } }, { "if": { "properties": { "provider": { - "enum": ["logstash"] + "enum": [ + "logstash" + ] } } }, "then": { - "required": ["url"] + "required": [ + "url" + ] } } ] @@ -2896,7 +3289,10 @@ "default": false } }, - "required": ["prompt", "title"] + "required": [ + "prompt", + "title" + ] }, "description": "Quick actions are a way to add custom commands to the Code Lens of function and class declarations." }, @@ -2924,10 +3320,15 @@ "default": "If there are any grammar or spelling mistakes in this writing, fix them. Do not make other large changes to the writing." } } + }, + "useChromiumForDocsCrawling": { + "type": "boolean", + "description": "Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`.", + "default": false } } } } } } -} +} \ No newline at end of file diff --git a/extensions/vscode/scripts/esbuild.js b/extensions/vscode/scripts/esbuild.js index f3d2c09db..7e367bfaa 100644 --- a/extensions/vscode/scripts/esbuild.js +++ b/extensions/vscode/scripts/esbuild.js @@ -30,4 +30,5 @@ const esbuildConfig = { } else { await esbuild.build(esbuildConfig); } -})(); + console.log("VS Code Extension esbuild complete"); // Used in task endpattern to signal completion +})(); \ No newline at end of file diff --git a/gui/package-lock.json b/gui/package-lock.json index ef9f8cda9..b0be81c6c 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -37,7 +37,7 @@ "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hook-form": "^7.47.0", - "react-intersection-observer": "^9.10.3", + "react-intersection-observer": "^9.13.1", "react-markdown": "^9.0.1", "react-redux": "^8.0.5", "react-remark": "^2.1.0", diff --git a/gui/package.json b/gui/package.json index dae097902..ef77ac910 100644 --- a/gui/package.json +++ b/gui/package.json @@ -45,7 +45,7 @@ "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hook-form": "^7.47.0", - "react-intersection-observer": "^9.10.3", + "react-intersection-observer": "^9.13.1", "react-markdown": "^9.0.1", "react-redux": "^8.0.5", "react-remark": "^2.1.0", diff --git a/gui/public/logos/xAI.png b/gui/public/logos/xAI.png new file mode 100644 index 000000000..95bdec71a Binary files /dev/null and b/gui/public/logos/xAI.png differ diff --git a/gui/src/components/gui/StepContainer.tsx b/gui/src/components/gui/StepContainer.tsx index 94652bc7d..c90d6c9c7 100644 --- a/gui/src/components/gui/StepContainer.tsx +++ b/gui/src/components/gui/StepContainer.tsx @@ -1,5 +1,4 @@ import { - ArrowPathIcon, BarsArrowDownIcon, HandThumbDownIcon, HandThumbUpIcon, @@ -14,7 +13,7 @@ import { vscBackground, vscInputBackground } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; import useUIConfig from "../../hooks/useUIConfig"; import { RootState } from "../../redux/store"; -import { getFontSize } from "../../util"; +import { getFontSize, getMetaKeyLabel } from "../../util"; import ButtonWithTooltip from "../ButtonWithTooltip"; import { CopyButton } from "../markdown/CopyButton"; import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; @@ -50,7 +49,7 @@ function StepContainer(props: StepContainerProps) { const isUserInput = props.item.message.role === "user"; const uiConfig = useUIConfig(); - const shouldRenderActions = !props.isLast || (props.isLast && !active); + const shouldRenderActions = !active || !props.isLast; useEffect(() => { if (!active) { @@ -84,7 +83,11 @@ function StepContainer(props: StepContainerProps) { }; return ( -
+
- - {shouldRenderActions && ( -
- {truncatedEarly && ( - - - - )} - - {props.index !== 1 && ( - - - - )} - - - +
+ {truncatedEarly && ( sendFeedback(true)} + text="Continue generation" + onClick={props.onContinueGeneration} > - + + )} + {props.index !== 1 && ( sendFeedback(false)} + onClick={props.onDelete} > - + -
- )} + )} + + + + sendFeedback(true)} + > + + + + sendFeedback(false)} + > + + +
); } diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index 4924acee8..4a9ea0dfd 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -109,7 +109,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) { }, [isGatheringContextStore]); return ( -
+
` props.border ? props.border : `0.5px solid ${vscInputBorder}`}; outline: none; font-size: ${getFontSize()}px; + &:focus { outline: none; @@ -561,86 +564,36 @@ function TipTapEditor(props: TipTapEditorProps) { /** * This handles various issues with meta key actions - * - In JetBrains, when using "off screen rendering", there is a bug where using the meta key to + * - In JetBrains, when using OSR in JCEF, there is a bug where using the meta key to * highlight code using arrow keys is not working * - In VS Code, while working with .ipynb files there is a problem where copy/paste/cut will affect * the actual notebook cells, even when performing them in our GUI + * + * Currently keydown events for a number of keys are not registering if the + * meta/shift key is pressed, for example "x", "c", "v", "z", etc. + * Until this is resolved we can't turn on OSR for non-Mac users due to issues + * with those key actions. */ const handleKeyDown = async (e: KeyboardEvent) => { if (!editor || !editorFocusedRef.current) return; setActiveKey(e.key); - if (isMetaEquivalentKeyPressed(e)) { - const { key, code } = e; - const isWebEnv = isWebEnvironment(); - const text = editor.state.doc.textBetween( - editor.state.selection.from, - editor.state.selection.to, - ); - - if (isJetBrains()) { - if (code === "KeyJ") { - e.stopPropagation(); - e.preventDefault(); - setIgnoreHighlightedCode(true); - setTimeout(() => { - setIgnoreHighlightedCode(false); - }, 100); - } - - if (isMetaEquivalentKeyPressed(e)) { - e.stopPropagation(); - e.preventDefault(); - handleMetaKeyPressJetBrains(e, text, editor.commands.setContent); - } - } else { - if (code === "KeyL") { - e.stopPropagation(); - e.preventDefault(); - setIgnoreHighlightedCode(true); - setTimeout(() => { - setIgnoreHighlightedCode(false); - }, 100); - return; - } - - switch (key) { - case "x": - e.stopPropagation(); - e.preventDefault(); - if (isWebEnv) { - await navigator.clipboard.writeText(text); - editor.commands.deleteSelection(); - } else { - document.execCommand("cut"); - } - break; - case "c": - e.stopPropagation(); - e.preventDefault(); - if (isWebEnv) { - await navigator.clipboard.writeText(text); - } else { - document.execCommand("copy"); - } - break; - case "v": - e.stopPropagation(); - e.preventDefault(); - if (isWebEnv) { - const clipboardText = await navigator.clipboard.readText(); - editor.commands.insertContent(clipboardText); - } else { - document.execCommand("paste"); - } - break; - } - } - } else if (e.key === "Escape") { + // Allow users to use the escape key to jump back to the editor + if (e.key === "Escape") { e.stopPropagation(); e.preventDefault(); ideMessenger.post("focusEditor", undefined); + return; + } + + // Handle meta key issues + if (isMetaEquivalentKeyPressed(e)) { + if (isJetBrains()) { + handleJetBrainsMetaKeyPress(e, editor); + } + + await handleMetaKeyPress(e, editor); } }; @@ -671,9 +624,6 @@ function TipTapEditor(props: TipTapEditorProps) { [props.onEnter, editor, props.isMainInput], ); - // This is a mechanism for overriding the IDE keyboard shortcut when inside of the webview - const [ignoreHighlightedCode, setIgnoreHighlightedCode] = useState(false); - // Re-focus main input after done generating useEffect(() => { if (editor && !active && props.isMainInput && document.hasFocus()) { @@ -748,71 +698,68 @@ function TipTapEditor(props: TipTapEditorProps) { if (!props.isMainInput || !editor) { return; } - if (!ignoreHighlightedCode) { - const rif: RangeInFile & { contents: string } = - data.rangeInFileWithContents; - const basename = getBasename(rif.filepath); - const relativePath = getRelativePath( - rif.filepath, - await ideMessenger.ide.getWorkspaceDirs(), - ); - const rangeStr = `(${rif.range.start.line + 1}-${ - rif.range.end.line + 1 - })`; - const item: ContextItemWithId = { - content: rif.contents, - name: `${basename} ${rangeStr}`, - // Description is passed on to the LLM to give more context on file path - description: `${relativePath} ${rangeStr}`, - id: { - providerTitle: "code", - itemId: v4(), - }, - uri: { - type: "file", - value: rif.filepath, - }, - }; - let index = 0; - for (const el of editor.getJSON().content) { - if (el.type === "codeBlock") { - index += 2; - } else { - break; - } + const rif: RangeInFile & { contents: string } = + data.rangeInFileWithContents; + const basename = getBasename(rif.filepath); + const relativePath = getRelativePath( + rif.filepath, + await ideMessenger.ide.getWorkspaceDirs(), + ); + const rangeStr = `(${rif.range.start.line + 1}-${ + rif.range.end.line + 1 + })`; + const item: ContextItemWithId = { + content: rif.contents, + name: `${basename} ${rangeStr}`, + // Description is passed on to the LLM to give more context on file path + description: `${relativePath} ${rangeStr}`, + id: { + providerTitle: "code", + itemId: v4(), + }, + uri: { + type: "file", + value: rif.filepath, + }, + }; + + let index = 0; + for (const el of editor.getJSON().content) { + if (el.type === "codeBlock") { + index += 2; + } else { + break; } - editor - .chain() - .insertContentAt(index, { - type: "codeBlock", - attrs: { - item, - }, - }) - .run(); - - if (data.prompt) { - editor.commands.focus("end"); - editor.commands.insertContent(data.prompt); - } - - if (data.shouldRun) { - onEnterRef.current({ useCodebase: false, noContext: true }); - } - - setTimeout(() => { - editor.commands.blur(); - editor.commands.focus("end"); - }, 20); } - setIgnoreHighlightedCode(false); + editor + .chain() + .insertContentAt(index, { + type: "codeBlock", + attrs: { + item, + }, + }) + .run(); + + if (data.prompt) { + editor.commands.focus("end"); + editor.commands.insertContent(data.prompt); + } + + if (data.shouldRun) { + onEnterRef.current({ useCodebase: false, noContext: true }); + } + + setTimeout(() => { + editor.commands.blur(); + editor.commands.focus("end"); + }, 20); }, [ editor, props.isMainInput, historyLength, - ignoreHighlightedCode, props.isMainInput, onEnterRef.current, ], diff --git a/gui/src/components/mainInput/handleMetaKeyPress.ts b/gui/src/components/mainInput/handleMetaKeyPress.ts new file mode 100644 index 000000000..fd122350f --- /dev/null +++ b/gui/src/components/mainInput/handleMetaKeyPress.ts @@ -0,0 +1,107 @@ +import { KeyboardEvent } from "react"; +import { isWebEnvironment } from "../../util"; +import { Editor } from "@tiptap/react"; + +const isWebEnv = isWebEnvironment(); + +export const handleJetBrainsMetaKeyPress = ( + e: KeyboardEvent, + editor: Editor, +) => { + const selection = window.getSelection(); + + const handlers: Record void> = { + Backspace: () => handleJetBrainsMetaBackspace(editor), + ArrowLeft: () => + selection.modify( + e.shiftKey ? "extend" : "move", + "backward", + "lineboundary", + ), + ArrowRight: () => + selection.modify( + e.shiftKey ? "extend" : "move", + "forward", + "lineboundary", + ), + ArrowDown: () => + selection.modify( + e.shiftKey ? "extend" : "move", + "forward", + "documentboundary", + ), + ArrowUp: () => { + selection.modify( + e.shiftKey ? "extend" : "move", + "backward", + "documentboundary", + ); + }, + }; + + if (e.key in handlers) { + e.stopPropagation(); + e.preventDefault(); + handlers[e.key](); + } +}; + +export const handleMetaKeyPress = async (e: KeyboardEvent, editor: Editor) => { + const text = editor.state.doc.textBetween( + editor.state.selection.from, + editor.state.selection.to, + ); + + const handlers: Record Promise> = { + x: () => handleCutOperation(text, editor), + c: () => handleCopyOperation(text), + v: () => handlePasteOperation(editor), + }; + + if (e.key in handlers) { + e.stopPropagation(); + e.preventDefault(); + await handlers[e.key](); + } +}; + +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); + } + } + + // Add an empty string so the user can keep typing + editor.commands.createParagraphNear(); +}; + +export const handleCutOperation = async (text: string, editor: Editor) => { + if (isWebEnv) { + await navigator.clipboard.writeText(text); + editor.commands.deleteSelection(); + } else { + document.execCommand("cut"); + } +}; + +export const handleCopyOperation = async (text: string) => { + if (isWebEnv) { + await navigator.clipboard.writeText(text); + } else { + document.execCommand("copy"); + } +}; + +export const handlePasteOperation = async (editor: Editor) => { + if (isWebEnv) { + const clipboardText = await navigator.clipboard.readText(); + editor.commands.insertContent(clipboardText); + } else { + document.execCommand("paste"); + } +}; diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index b951d8673..87bdfc546 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -1059,6 +1059,19 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["nebius"], isOpenSource: true, }, + grokBeta: { + title: "Grok Beta", + description: "Generative artificial intelligence chatbot developed by xAI.", + refUrl: "", + params: { + title: "Grok Beta", + model: "grok-beta", + contextLength: 128_000, + }, + icon: "xAI.png", + providerOptions: ["xAI"], + isOpenSource: false, + }, AUTODETECT: { title: "Autodetect", description: diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 62f6905d1..dd1c3fbdb 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -352,6 +352,27 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n packages: [models.gemini15Pro, models.geminiPro, models.gemini15Flash], apiKeyUrl: "https://aistudio.google.com/app/apikey", }, + xAI: { + title: "xAI", + provider: "xAI", + icon: "xAI.png", + description: "xAI is a company working on building artificial intelligence to accelerate human scientific discovery", + longDescription: "To get started with xAI, obtain an API key from their [console](https://console.x.ai/).", + tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], + collectInputFor: [ + { + inputType: "text", + key: "apiKey", + label: "API Key", + placeholder: "Enter your xAI API key", + required: true, + }, + ], + packages: [ + models.grokBeta, + ], + apiKeyUrl: "https://console.x.ai/", + }, lmstudio: { title: "LM Studio", provider: "lmstudio", diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index a24c959af..6ca0cc167 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -66,7 +66,6 @@ const TopGuiDiv = styled.div<{ showScrollbar?: boolean; }>` overflow-y: auto; - height: 100%; scrollbar-width: ${(props) => (props.showScrollbar ? "thin" : "none")}; &::-webkit-scrollbar { @@ -75,6 +74,7 @@ const TopGuiDiv = styled.div<{ `; const StopButton = styled.div` + background-color: ${vscBackground}; width: fit-content; margin-right: auto; margin-left: auto; @@ -97,6 +97,7 @@ const StopButton = styled.div` `; const StepsDiv = styled.div` + margin-top: 8px; position: relative; background-color: transparent; @@ -147,16 +148,17 @@ export function Chat() { const { saveSession, getLastSessionId, loadLastSession } = useHistory(dispatch); - useEffect(() => { - if (!active || !topGuiDivRef.current) return; - - const scrollAreaElement = topGuiDivRef.current; - - scrollAreaElement.scrollTop = - scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight; + const scrollToBottom = useCallback(() => { + if (!topGuiDivRef.current) return; + const elem = topGuiDivRef.current; + elem.scrollTop = elem.scrollHeight - elem.clientHeight; setIsAtBottom(true); - }, [active]); + }, [topGuiDivRef, setIsAtBottom]); + + useEffect(() => { + if (active) scrollToBottom(); + }, [active, scrollToBottom]); useEffect(() => { // Cmd + Backspace to delete current step @@ -311,6 +313,7 @@ export function Chat() { return ( <> 0 ? "h-full" : ""}`} ref={topGuiDivRef} onScroll={handleScroll} showScrollbar={state.config.ui?.showChatScrollbar || false} @@ -415,22 +418,56 @@ export function Chat() { ))} +
+ + -