From c50d73a13f9b0f6ac3a97bc0ae2bae61f71f3e6c Mon Sep 17 00:00:00 2001 From: George Date: Tue, 6 Aug 2024 22:57:24 +0100 Subject: [PATCH 001/255] Add includeUnstaged option to commit slash command --- core/commands/slash/commit.ts | 4 +-- core/config/promptFile.ts | 2 +- core/config/types.ts | 2 +- core/context/providers/DiffContextProvider.ts | 2 +- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/util/filesystem.ts | 2 +- core/util/messageIde.ts | 4 +-- core/util/reverseMessageIde.ts | 4 +-- docs/docs/customization/slash-commands.md | 5 ++-- docs/static/schemas/config.json | 21 ++++++++++++++++ .../src/main/resources/config_schema.json | 21 ++++++++++++++++ extensions/vscode/config_schema.json | 21 ++++++++++++++++ extensions/vscode/continue_rc_schema.json | 25 ++++++++++++++++++- .../vscode/src/extension/VsCodeMessenger.ts | 2 +- extensions/vscode/src/ideProtocol.ts | 4 +-- .../src/test/test-suites/ideUtils.test.ts | 2 +- extensions/vscode/src/util/ideUtils.ts | 18 ++++++------- 18 files changed, 113 insertions(+), 30 deletions(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 899222998..90be8c3a9 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -4,8 +4,8 @@ import { stripImages } from "../../llm/images.js"; const CommitMessageCommand: SlashCommand = { name: "commit", description: "Generate a commit message for current changes", - run: async function* ({ ide, llm, input }) { - const diff = await ide.getDiff(); + run: async function* ({ ide, llm, params }) { + const diff = await ide.getDiff(!params?.includeUnstaged); if (!diff || diff.trim() === "") { yield "No changes detected. Make sure you are in a git repository with current changes."; diff --git a/core/config/promptFile.ts b/core/config/promptFile.ts index 92d558aaf..fbe097f71 100644 --- a/core/config/promptFile.ts +++ b/core/config/promptFile.ts @@ -146,7 +146,7 @@ async function renderPrompt(prompt: string, context: any, userInput: string) { const helpers = getContextProviderHelpers(context); // A few context providers that don't need to be in config.json to work in .prompt files - const diff = await context.ide.getDiff(); + const diff = await context.ide.getDiff(false); const currentFilePath = await context.ide.getCurrentFile(); const currentFile = currentFilePath ? await context.ide.readFile(currentFilePath) diff --git a/core/config/types.ts b/core/config/types.ts index d950c15f7..bbffc3ae6 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -375,7 +375,7 @@ declare global { export interface IDE { getIdeInfo(): Promise; - getDiff(): Promise; + getDiff(stagedOnly: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index 696b71a21..ae0eb42b8 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(); + const diff = await extras.ide.getDiff(false); return [ { description: "The current git diff", diff --git a/core/index.d.ts b/core/index.d.ts index 8c08c5923..7cd6865a2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -442,7 +442,7 @@ export interface IdeSettings { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(): Promise; + getDiff(stagedOnly: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index bb5f59810..f05436908 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -47,7 +47,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { getPinnedFiles: [undefined, string[]]; showLines: [{ filepath: string; startLine: number; endLine: number }, void]; readRangeInFile: [{ filepath: string; range: Range }, string]; - getDiff: [undefined, string]; + getDiff: [{ stagedOnly: boolean }, string]; getWorkspaceConfigs: [undefined, ContinueRcJson[]]; getTerminalContents: [undefined, string]; getDebugLocals: [{ threadIndex: number }, string]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 978fa0829..a7251e80a 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -108,7 +108,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - getDiff(): Promise { + getDiff(stagedOnly: boolean): Promise { return Promise.resolve(""); } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 396df29c7..455a885ac 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -108,8 +108,8 @@ export class MessageIde implements IDE { return this.request("getWorkspaceConfigs", undefined); } - async getDiff() { - return await this.request("getDiff", undefined); + async getDiff(stagedOnly: boolean) { + return await this.request("getDiff", { stagedOnly }); } async getTerminalContents() { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index 1e5a2d1ca..ac8e18c10 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -104,8 +104,8 @@ export class ReverseMessageIde { return this.ide.getIdeSettings(); }); - this.on("getDiff", () => { - return this.ide.getDiff(); + this.on("getDiff", (data) => { + return this.ide.getDiff(data.stagedOnly); }); this.on("getTerminalContents", () => { diff --git a/docs/docs/customization/slash-commands.md b/docs/docs/customization/slash-commands.md index 661f7e5e6..39594bf27 100644 --- a/docs/docs/customization/slash-commands.md +++ b/docs/docs/customization/slash-commands.md @@ -68,7 +68,8 @@ Shows the LLM your current git diff and asks it to generate a commit message. ```json { "name": "commit", - "description": "Generate a commit message for the current changes" + "description": "Generate a commit message for the current changes", + "params": { "includeUnstaged": false } } ``` @@ -151,7 +152,7 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + const diff = await sdk.ide.getDiff(true); for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, { diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index e9d6e375e..99fcfb171 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index e9d6e375e..99fcfb171 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index e9d6e375e..99fcfb171 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 180908ddb..047c3eb71 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1526,6 +1526,29 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "commit" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": [ @@ -2726,4 +2749,4 @@ } } } -} \ No newline at end of file +} diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index a51bd8233..fe2d824c2 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -218,7 +218,7 @@ export class VsCodeMessenger { return ide.getIdeSettings(); }); this.onWebviewOrCore("getDiff", async (msg) => { - return ide.getDiff(); + return ide.getDiff(msg.data.stagedOnly); }); this.onWebviewOrCore("getTerminalContents", async (msg) => { return ide.getTerminalContents(); diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/ideProtocol.ts index df3a909f1..207020329 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/ideProtocol.ts @@ -282,8 +282,8 @@ class VsCodeIde implements IDE { return Promise.resolve(vscode.env.machineId); } - async getDiff(): Promise { - return await this.ideUtils.getDiff(); + async getDiff(stagedOnly: boolean): Promise { + return await this.ideUtils.getDiff(stagedOnly); } async getTerminalContents(): Promise { diff --git a/extensions/vscode/src/test/test-suites/ideUtils.test.ts b/extensions/vscode/src/test/test-suites/ideUtils.test.ts index 761a8343c..adae3fab4 100644 --- a/extensions/vscode/src/test/test-suites/ideUtils.test.ts +++ b/extensions/vscode/src/test/test-suites/ideUtils.test.ts @@ -80,7 +80,7 @@ describe("IDE Utils", () => { }); test("noDiff", async () => { - const noDiff = await utils.getDiff(); + const noDiff = await utils.getDiff(false); assert(noDiff === ""); }); diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index 15f79ddfd..cf07388de 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -593,7 +593,7 @@ export class VsCodeIdeUtils { return repo?.state?.HEAD?.name || "NONE"; } - async getDiff(): Promise { + async getDiff(stagedOnly: boolean): Promise { let diffs: string[] = []; let repos = []; @@ -604,17 +604,13 @@ export class VsCodeIdeUtils { } repos.push(repo.state.HEAD?.name); - // Staged changes - // const a = await repo.diffIndexWithHEAD(); + const staged = await repo.diff(true); - // Un-staged changes - // const b = await repo.diffWithHEAD(); - const unstaged = await repo.diff(false); - // All changes - // const e = await repo.diffWith("HEAD"); - // Only staged - // const f = await repo.diffIndexWith("HEAD"); - diffs.push(`${staged}\n${unstaged}`); + diffs.push(`${staged}`); + if (!stagedOnly) { + const unstaged = await repo.diff(false); + diffs.push(`\n${unstaged}`); + } } const fullDiff = diffs.join("\n\n"); From 92f689071ab7ac2eda8032a054d1a484312bb26d Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Sep 2024 15:00:51 -0700 Subject: [PATCH 002/255] inline diff red --- core/diff/streamDiff.ts | 1 + .../editor/DiffStreamHandler.kt | 69 ++++++++++++++++--- .../editor/EditorComponentInlaysManager.kt | 12 ++-- .../editor/InlineEditAction.kt | 6 +- 4 files changed, 70 insertions(+), 18 deletions(-) diff --git a/core/diff/streamDiff.ts b/core/diff/streamDiff.ts index 42c8409b9..2761b5d97 100644 --- a/core/diff/streamDiff.ts +++ b/core/diff/streamDiff.ts @@ -8,6 +8,7 @@ import { LineStream, matchLine } from "./util.js"; * - old + same = oldLinesCopy.length * ^ (above two guarantee that all lines get represented) * - Lines are always output in order, at least among old and new separately + * - Old lines in a hunk are always output before the new lines */ export async function* streamDiff( oldLines: string[], diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index f30347150..46e37dc7c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.command.undo.UndoManager import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.colors.EditorFontType import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.openapi.editor.markup.HighlighterLayer import com.intellij.openapi.editor.markup.RangeHighlighter @@ -17,6 +18,7 @@ import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.project.Project import com.intellij.ui.JBColor import java.awt.event.KeyEvent +import javax.swing.BorderFactory import javax.swing.JTextArea import kotlin.math.min @@ -34,6 +36,7 @@ class DiffStreamHandler( private val onClose: () -> Unit, private val onFinish: () -> Unit ) { + // Text attributes keys private val greenKey = run { val attributes = TextAttributes().apply { backgroundColor = JBColor(0x3000FF00.toInt(), 0x3000FF00.toInt()) @@ -61,12 +64,18 @@ class DiffStreamHandler( key } + private val editorComponentInlaysManager = EditorComponentInlaysManager.from(editor, false) + + // State variables private var currentLine = startLine private var currentLineHighlighter: RangeHighlighter? = null private val unfinishedHighlighters: MutableList = mutableListOf() - private var changeCount: Int = 0 + private var changeCount: Int = 0 // Kept track of so we can count steps to undo when cancelling private var running: Boolean = false + private var deletionBufferStartLine: Int = -1 + private val deletionsBuffer: MutableList = mutableListOf() + fun setup() { // Highlight the range with unfinished color for (i in startLine..endLine) { @@ -77,11 +86,44 @@ class DiffStreamHandler( } } + private fun deleteLineAt(index: Int) { + val startOffset = editor.document.getLineStartOffset(index) + val endOffset = editor.document.getLineEndOffset(index) + 1 + editor.document.deleteString(startOffset, min(endOffset, editor.document.textLength)) + } + + private fun insertDeletionBuffer() { + // Insert red highlighted code between the real lines in the editor + if (deletionBufferStartLine != -1 && deletionsBuffer.isNotEmpty()) { + val component = JTextArea().apply { + text = deletionsBuffer.joinToString(" \n") + isEditable = false + background = JBColor(0x30FF0000.toInt(), 0x30FF0000.toInt()) + foreground = JBColor.GRAY + border = BorderFactory.createEmptyBorder(0, 0, 0, 0) + lineWrap = false + wrapStyleWord = false + columns = Int.MAX_VALUE // This ensures the component takes up the full width + margin = java.awt.Insets(0, -100, 0, 0) + + font = editor.colorsScheme.getFont(EditorFontType.PLAIN) + preferredSize = java.awt.Dimension(editor.contentComponent.width, preferredSize.height) + } + + editorComponentInlaysManager.insertAfter(deletionBufferStartLine - 1, component) + + // Clear the buffer + deletionsBuffer.clear() + deletionBufferStartLine = -1 + } + } + private fun handleDiffLine(type: DiffLineType, line: String) { println("DiffStreamHandler: handleDiffLine: $currentLine, $type, $line") try { when (type) { DiffLineType.SAME -> { + insertDeletionBuffer() currentLine++ } DiffLineType.NEW -> { @@ -95,14 +137,21 @@ class DiffStreamHandler( // Highlight the new line green editor.markupModel.addLineHighlighter(greenKey, currentLine, HighlighterLayer.LAST) + insertDeletionBuffer() + currentLine++ changeCount++ } DiffLineType.OLD -> { // Remove old line - val startOffset = editor.document.getLineStartOffset(currentLine) - val endOffset = editor.document.getLineEndOffset(currentLine) + 1 - editor.document.deleteString(startOffset, min(endOffset, editor.document.textLength)) + deleteLineAt(currentLine) + + // Add to deletions buffer + deletionsBuffer.add(line) + if (deletionBufferStartLine == -1) { + deletionBufferStartLine = currentLine + } + changeCount++ } } @@ -175,12 +224,7 @@ class DiffStreamHandler( running = true // Highlight the range with unfinished color - for (i in startLine..endLine) { - val highlighter = editor.markupModel.addLineHighlighter(unfinishedKey, min( - i, editor.document.lineCount - 1 - ), HighlighterLayer.FIRST) - unfinishedHighlighters.add(highlighter) - } + setup() // Request diff stream from core val continuePluginService = ServiceManager.getService( @@ -206,12 +250,15 @@ class DiffStreamHandler( onFinish() ApplicationManager.getApplication().invokeLater { - // Clean up highlighters + // Clean up progress highlighters if (currentLineHighlighter != null) { editor.markupModel.removeHighlighter(currentLineHighlighter!!) } unfinishedHighlighters.forEach { editor.markupModel.removeHighlighter(it) } + // Flush deletion buffer + insertDeletionBuffer() + // Add ", " to the text area textArea.document.insertString(textArea.caretPosition, ", ", null) textArea.requestFocus() diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt index c5b089d7a..f8277d383 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt @@ -26,7 +26,7 @@ import kotlin.math.min * Copied from com.intellij.util.ui.codereview.diff.EditorComponentInlaysManager * via https://github.com/cursive-ide/component-inlay-example/blob/master/src/main/kotlin/inlays/EditorComponentInlaysManager.kt */ -class EditorComponentInlaysManager(val editor: EditorImpl) : Disposable { +class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneInlay: Boolean) : Disposable { private val managedInlays = mutableMapOf() private val editorWidthWatcher = EditorTextWidthWatcher() @@ -44,8 +44,10 @@ class EditorComponentInlaysManager(val editor: EditorImpl) : Disposable { fun insertAfter(lineIndex: Int, component: JComponent): Disposable? { if (Disposer.isDisposed(this)) return null - // Dispose all other inlays - managedInlays.values.forEach(Disposer::dispose) + if (onlyOneInlay) { + // Dispose all other inlays + managedInlays.values.forEach(Disposer::dispose) + } val wrappedComponent = ComponentWrapper(component) val offset = editor.document.getLineEndOffset(lineIndex) @@ -144,11 +146,11 @@ class EditorComponentInlaysManager(val editor: EditorImpl) : Disposable { companion object { val INLAYS_KEY: Key = Key.create("EditorComponentInlaysManager") - fun from(editor: Editor): EditorComponentInlaysManager { + fun from(editor: Editor, onlyOneInlay: Boolean): EditorComponentInlaysManager { return synchronized(editor) { val manager = editor.getUserData(INLAYS_KEY) if (manager == null) { - val newManager = EditorComponentInlaysManager(editor as EditorImpl) + val newManager = EditorComponentInlaysManager(editor as EditorImpl, false) editor.putUserData(INLAYS_KEY, newManager) newManager } else manager diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index f94214c34..5b77f8165 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -103,7 +103,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { return } - val manager = EditorComponentInlaysManager.from(editor) + val manager = EditorComponentInlaysManager.from(editor, true) // Get list of model titles val continuePluginService = project.service() @@ -192,7 +192,9 @@ fun openInlineEdit(project: Project?, editor: Editor) { diffStreamService.reject(editor) // Re-highlight the selected text - selectionModel.setSelection(start, end) + val documentLength = editor.document.textLength + val safeEnd = minOf(end, documentLength) + selectionModel.setSelection(start, safeEnd) } else if (e.keyCode == KeyEvent.VK_ENTER) { if (e.modifiersEx == KeyEvent.SHIFT_DOWN_MASK) { textArea.document.insertString(textArea.caretPosition, "\n", null) From b48a77bd68a6929a901c7497c90398a0d38647e6 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Sep 2024 16:46:15 -0700 Subject: [PATCH 003/255] fix model selectedIndex err --- .../continueintellijextension/editor/InlineEditAction.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 5b77f8165..aea1b8c6b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -278,8 +278,10 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List horizontalAlignment = SwingConstants.RIGHT } selectedIndex = continueSettingsService.continueState.lastSelectedInlineEditModel?.let { - val index = modelTitles.indexOf(it) - if (index != -1) index else 0 + if (modelTitles.isEmpty()) -1 else { + val index = modelTitles.indexOf(it) + if (index != -1) index else 0 + } } ?: 0 addActionListener { From f37884dee81130bc20a8e2ab9498112b3f8efed1 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Sep 2024 17:14:54 -0700 Subject: [PATCH 004/255] remove deletion inlays --- .../editor/DiffStreamHandler.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index 46e37dc7c..7de4ec6ec 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.editor import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.google.gson.Gson +import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.command.undo.UndoManager @@ -75,6 +76,14 @@ class DiffStreamHandler( private var deletionBufferStartLine: Int = -1 private val deletionsBuffer: MutableList = mutableListOf() + private val deletionInlays: MutableList = mutableListOf() + + private fun removeDeletionInlays() { + deletionInlays.forEach { + it.dispose() + } + deletionInlays.clear() + } fun setup() { // Highlight the range with unfinished color @@ -110,7 +119,10 @@ class DiffStreamHandler( preferredSize = java.awt.Dimension(editor.contentComponent.width, preferredSize.height) } - editorComponentInlaysManager.insertAfter(deletionBufferStartLine - 1, component) + val disposable = editorComponentInlaysManager.insertAfter(deletionBufferStartLine - 1, component) + if (disposable != null) { + deletionInlays.add(disposable) + } // Clear the buffer deletionsBuffer.clear() @@ -177,6 +189,9 @@ class DiffStreamHandler( // Remove all highlighters editor.markupModel.removeAllHighlighters() + // Remove all of the deletion inlays + removeDeletionInlays() + // Undo changes just by using builtin undo WriteCommandAction.runWriteCommandAction(project) { val undoManager = UndoManager.getInstance(project) @@ -197,6 +212,7 @@ class DiffStreamHandler( fun accept() { // Accept the changes editor.markupModel.removeAllHighlighters() + removeDeletionInlays() onClose() running = false } @@ -204,6 +220,7 @@ class DiffStreamHandler( fun reject() { // Reject the changes resetState() + removeDeletionInlays() onClose() running = false } From d1267877f4e9ee668c044c165d1bf6998bfca212 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Sep 2024 17:27:04 -0700 Subject: [PATCH 005/255] insert inlays above --- .../continueintellijextension/editor/DiffStreamHandler.kt | 4 +--- .../editor/EditorComponentInlaysManager.kt | 4 ++-- .../continueintellijextension/editor/InlineEditAction.kt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index 7de4ec6ec..d34603482 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -1,7 +1,6 @@ package com.github.continuedev.continueintellijextension.editor import com.github.continuedev.continueintellijextension.services.ContinuePluginService -import com.google.gson.Gson import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.WriteCommandAction @@ -18,7 +17,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.project.Project import com.intellij.ui.JBColor -import java.awt.event.KeyEvent import javax.swing.BorderFactory import javax.swing.JTextArea import kotlin.math.min @@ -119,7 +117,7 @@ class DiffStreamHandler( preferredSize = java.awt.Dimension(editor.contentComponent.width, preferredSize.height) } - val disposable = editorComponentInlaysManager.insertAfter(deletionBufferStartLine - 1, component) + val disposable = editorComponentInlaysManager.insert(deletionBufferStartLine, component, true) if (disposable != null) { deletionInlays.add(disposable) } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt index f8277d383..6ed4df136 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt @@ -41,7 +41,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn } @RequiresEdt - fun insertAfter(lineIndex: Int, component: JComponent): Disposable? { + fun insert(lineIndex: Int, component: JComponent, showAbove: Boolean = false): Disposable? { if (Disposer.isDisposed(this)) return null if (onlyOneInlay) { @@ -57,7 +57,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn EditorEmbeddedComponentManager.Properties(EditorEmbeddedComponentManager.ResizePolicy.none(), null, true, - false, + showAbove, 0, offset))?.also { managedInlays[wrappedComponent] = it diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index aea1b8c6b..318afda59 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -179,7 +179,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { diffStreamService.reject(editor) inlayRef.get().dispose() }) - val inlay = manager.insertAfter(lineNumber, panel) + val inlay = manager.insert(startLineNum, panel, true) panel.revalidate() inlayRef.set(inlay) val viewport = (editor as? EditorImpl)?.scrollPane?.viewport From 1e699f15d4fa0c71e50062d296f2f6d04ffd6a42 Mon Sep 17 00:00:00 2001 From: Lester Hairston Date: Fri, 27 Sep 2024 16:40:53 -0500 Subject: [PATCH 006/255] adding discord provider --- core/context/providers/DiscordContext.ts | 147 +++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 core/context/providers/DiscordContext.ts diff --git a/core/context/providers/DiscordContext.ts b/core/context/providers/DiscordContext.ts new file mode 100644 index 000000000..6a3615e09 --- /dev/null +++ b/core/context/providers/DiscordContext.ts @@ -0,0 +1,147 @@ +import { AxiosError, AxiosInstance } from "axios"; +import { + ContextItem, + ContextProviderDescription, + ContextProviderExtras, +} from "../../index.js"; +import { BaseContextProvider } from "../index.js"; + +// Define helper interfaces for Discord responses +export interface DiscordChannel { + id: string; + name?: string; + icon?: string; + topic?: string; + guild_id?: string; // The ID of the guild (server) that the channel belongs to +} + +interface DiscordMessage { + id: string; + content: string; + author: { + id: string; + username: string; + }; + timestamp: string; +} + +class DiscordContextProvider extends BaseContextProvider { + // Description for the context provider + static description: ContextProviderDescription = { + title: "discord-messages", + displayTitle: "Discord Messages", + description: "Reference messages from a Discord channel", + type: "normal", + }; + + // Helper function to get the Axios instance with proper authorization + private async getApi(): Promise { + const { default: Axios } = await import("axios"); + const token = this.options.token; + if (!token) { + throw new Error("Discord Bot Token is required!"); + } + + return Axios.create({ + baseURL: "https://discord.com/api/v10", + headers: { + Authorization: `Bot ${token}`, + }, + }); + } + + // Reusable error handling method + private handleApiError(ex: unknown): string { + let content = "# Discord API Error\n\nFailed to retrieve data. "; + if (ex instanceof AxiosError) { + if (ex.response) { + const errorMessage = ex.response?.data + ? (ex.response.data.message ?? JSON.stringify(ex.response?.data)) + : `${ex.response.status}: ${ex.response.statusText}`; + content += `Discord API Error: ${errorMessage}`; + } else { + content += `Discord API Request Error ${ex.request}`; + } + } else { + content += `Unknown error: ${ex instanceof Error ? ex.message : JSON.stringify(ex)}`; + } + return content; + } + + // Fetch Discord channels + private async fetchChannels( + extras: ContextProviderExtras, + ): Promise> { + const api = await this.getApi(); + + try { + const response = await api.get>( + `/guilds/${this.options.guildId}/channels`, + ); + return response.data; + } catch (ex) { + throw new Error(this.handleApiError(ex)); + } + } + + // Fetch messages from a specific channel + private async fetchMessages( + channelId: string, + extras: ContextProviderExtras, + ): Promise> { + const api = await this.getApi(); + try { + const response = await api.get>( + `/channels/${channelId}/messages`, + { params: { limit: 10 } }, + ); + return response.data; + } catch (ex) { + throw new Error(this.handleApiError(ex)); + } + } + + // Main function to get context items (channels and messages) + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { + const result = [] as Array; + + try { + // Fetch channels + const channels = await this.fetchChannels(extras); + + // Fetch messages for each channel in parallel + const channelMessagePromises = channels.map(async (channel) => { + const messages = await this.fetchMessages(channel.id, extras); + const parts = [ + `# Discord Channel: ${channel.name}`, + ...messages.map( + (message) => + `- ${message.author.username}: ${message.content} (at ${message.timestamp})`, + ), + ]; + + return { + name: `Messages from ${channel.name}`, + content: parts.join("\n"), + description: `Latest messages from the channel ${channel.name}`, + }; + }); + + const channelMessageItems = await Promise.all(channelMessagePromises); + result.push(...channelMessageItems); + } catch (ex) { + result.push({ + name: "Discord Error", + content: this.handleApiError(ex), + description: "Error fetching data from Discord.", + }); + } + + return result; + } +} + +export default DiscordContextProvider; From d371133becfdd2029776968fd177c5225289053f Mon Sep 17 00:00:00 2001 From: George Date: Sun, 29 Sep 2024 15:25:35 +0100 Subject: [PATCH 007/255] Merge in docs changes --- .../tutorials/build-your-own-slash-command.md | 106 ------------------ 1 file changed, 106 deletions(-) diff --git a/docs/docs/customize/tutorials/build-your-own-slash-command.md b/docs/docs/customize/tutorials/build-your-own-slash-command.md index d33ec9d42..b3fc25c3a 100644 --- a/docs/docs/customize/tutorials/build-your-own-slash-command.md +++ b/docs/docs/customize/tutorials/build-your-own-slash-command.md @@ -2,112 +2,6 @@ title: Build your own slash command --- -# Slash Commands - -Slash commands are shortcuts that can be activated by typing '/' and selecting from the dropdown. For example, the built-in '/edit' slash command let you stream edits directly into your editor. - -![slash-commands](/img/slash-commands.png) - -## Built-in Slash Commands - -To use any of the built-in slash commands, open `~/.continue/config.json` and add it to the `slashCommands` list. - -### `/edit` - -Select code with ctrl/cmd + L (VS Code) or ctrl/cmd + J (JetBrains), and then type "/edit", followed by instructions for the edit. Continue will stream the changes into a side-by-side diff editor. - -```json -{ - "name": "edit", - "description": "Edit highlighted code" -} -``` - -### `/comment` - -Comment works just like /edit, except it will automatically prompt the LLM to comment the code. - -```json -{ - "name": "comment", - "description": "Write comments for the highlighted code" -} -``` - -### `/share` - -Type "/share" to generate a shareable markdown transcript of your current chat history. - -```json -{ - "name": "share", - "description": "Export the current chat session to markdown", - "params": { "outputDir": "~/.continue/session-transcripts" } -} -``` - -Use the `outputDir` parameter to specify where you want to the markdown file to be saved. - -### `/cmd` - -Generate a shell command from natural language and (only in VS Code) automatically paste it into the terminal. - -```json -{ - "name": "cmd", - "description": "Generate a shell command" -} -``` - -### `/commit` - -Shows the LLM your current git diff and asks it to generate a commit message. - -```json -{ - "name": "commit", - "description": "Generate a commit message for the current changes", - "params": { "includeUnstaged": false } -} -``` - -### `/http` - -Write a custom slash command at your own HTTP endpoint. Set 'url' in the params object for the endpoint you have setup. The endpoint should return a sequence of string updates, which will be streamed to the Continue sidebar. See our basic [FastAPI example](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) for reference. - -```json -{ - "name": "http", - "description": "Does something custom", - "params": { "url": "" } -} -``` - -### `/issue` - -Describe the issue you'd like to generate, and Continue will turn into a well-formatted title and body, then give you a link to the draft so you can submit. Make sure to set the URL of the repository you want to generate issues for. - -```json -{ - "name": "issue", - "description": "Generate a link to a drafted GitHub issue", - "params": { "repositoryUrl": "https://github.com/continuedev/continue" } -} -``` - -### `/so` - -The StackOverflow slash command will automatically pull results from StackOverflow to answer your question, quoting links along with its answer. - -```json -{ - "name": "so", - "description": "Reference StackOverflow to answer the question" -} -``` - -## Custom Slash Commands - There are two ways to add custom slash commands: 1. With natural language prompts - this is simpler and only requires writing a string or string template. From cf8b4bdc4391e5c027cf72756fee21843bd1e9d4 Mon Sep 17 00:00:00 2001 From: George Date: Sun, 29 Sep 2024 15:30:10 +0100 Subject: [PATCH 008/255] Refactor stagedOnly -> includeUnstaged --- core/commands/slash/commit.ts | 3 ++- core/config/types.ts | 2 +- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/util/filesystem.ts | 2 +- core/util/messageIde.ts | 4 ++-- core/util/reverseMessageIde.ts | 2 +- extensions/vscode/src/VsCodeIde.ts | 4 ++-- extensions/vscode/src/extension/VsCodeMessenger.ts | 2 +- extensions/vscode/src/util/ideUtils.ts | 4 ++-- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 90be8c3a9..648b76770 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -5,7 +5,8 @@ const CommitMessageCommand: SlashCommand = { name: "commit", description: "Generate a commit message for current changes", run: async function* ({ ide, llm, params }) { - const diff = await ide.getDiff(!params?.includeUnstaged); + const includeUnstaged = params ? params.includeUnstaged : false; + const diff = await ide.getDiff(includeUnstaged); if (!diff || diff.trim() === "") { yield "No changes detected. Make sure you are in a git repository with current changes."; diff --git a/core/config/types.ts b/core/config/types.ts index 0f9035097..8c03e171d 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -434,7 +434,7 @@ declare global { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(stagedOnly: boolean): Promise; + getDiff(includeUnstaged: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/index.d.ts b/core/index.d.ts index 50b66f933..1995045fe 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -464,7 +464,7 @@ export interface IdeSettings { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(stagedOnly: boolean): Promise; + getDiff(includeUnstaged: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 542356006..a62b3fdce 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -52,7 +52,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { getPinnedFiles: [undefined, string[]]; showLines: [{ filepath: string; startLine: number; endLine: number }, void]; readRangeInFile: [{ filepath: string; range: Range }, string]; - getDiff: [{ stagedOnly: boolean }, string]; + getDiff: [{ includeUnstaged: boolean }, string]; getWorkspaceConfigs: [undefined, ContinueRcJson[]]; getTerminalContents: [undefined, string]; getDebugLocals: [{ threadIndex: number }, string]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index b5ca3be1e..e907d6642 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -124,7 +124,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - getDiff(stagedOnly: boolean): Promise { + getDiff(includeUnstaged: boolean): Promise { return Promise.resolve(""); } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index fcd7f199a..5eaaf8752 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -108,8 +108,8 @@ export class MessageIde implements IDE { return this.request("getWorkspaceConfigs", undefined); } - async getDiff(stagedOnly: boolean) { - return await this.request("getDiff", { stagedOnly }); + async getDiff(includeUnstaged: boolean) { + return await this.request("getDiff", { includeUnstaged }); } async getTerminalContents() { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index e8bdd8797..1b0686d99 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -101,7 +101,7 @@ export class ReverseMessageIde { }); this.on("getDiff", (data) => { - return this.ide.getDiff(data.stagedOnly); + return this.ide.getDiff(data.includeUnstaged); }); this.on("getTerminalContents", () => { diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index e8ca30c90..5e5ed1ccd 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -304,8 +304,8 @@ class VsCodeIde implements IDE { return Promise.resolve(vscode.env.machineId); } - async getDiff(stagedOnly: boolean): Promise { - return await this.ideUtils.getDiff(stagedOnly); + async getDiff(includeUnstaged: boolean): Promise { + return await this.ideUtils.getDiff(includeUnstaged); } async getTerminalContents(): Promise { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index afdf16b23..8f57a421f 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -283,7 +283,7 @@ export class VsCodeMessenger { return ide.getIdeSettings(); }); this.onWebviewOrCore("getDiff", async (msg) => { - return ide.getDiff(msg.data.stagedOnly); + return ide.getDiff(msg.data.includeUnstaged); }); this.onWebviewOrCore("getTerminalContents", async (msg) => { return ide.getTerminalContents(); diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index 717ce481c..839806111 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -619,7 +619,7 @@ export class VsCodeIdeUtils { return repo?.state?.HEAD?.name || "NONE"; } - async getDiff(stagedOnly: boolean): Promise { + async getDiff(includeUnstaged: boolean): Promise { let diffs: string[] = []; let repos = []; @@ -633,7 +633,7 @@ export class VsCodeIdeUtils { const staged = await repo.diff(true); diffs.push(`${staged}`); - if (!stagedOnly) { + if (includeUnstaged) { const unstaged = await repo.diff(false); diffs.push(`\n${unstaged}`); } From 22b37e1f5606553b3f738921015d715cfd2dbf89 Mon Sep 17 00:00:00 2001 From: Steve Rhoades Date: Sun, 29 Sep 2024 11:38:33 -0700 Subject: [PATCH 009/255] fixes issue #2313 - detect wsl paths and convert them to windows paths using the wslpath command fix oops --- extensions/vscode/package-lock.json | 147 +++++++++++++++++- extensions/vscode/package.json | 2 + extensions/vscode/src/VsCodeIde.ts | 37 ++++- .../src/test/test-suites/vsCodeIde.test.ts | 78 ++++++++++ 4 files changed, 255 insertions(+), 9 deletions(-) create mode 100644 extensions/vscode/src/test/test-suites/vsCodeIde.test.ts diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 0eb4461d9..02d7e5408 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.212", + "version": "0.9.213", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.212", + "version": "0.9.213", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -68,6 +68,7 @@ "@types/node": "16.x", "@types/react-dom": "^18.2.4", "@types/request": "^2.48.8", + "@types/sinon": "^17.0.3", "@types/vscode": "1.70", "@types/ws": "^8.5.4", "@typescript-eslint/eslint-plugin": "^5.45.0", @@ -81,6 +82,7 @@ "mocha": "^10.4.0", "ovsx": "^0.8.3", "rimraf": "^5.0.5", + "sinon": "^19.0.2", "typescript": "^5.3.3", "vite": "^4.3.9", "vsce": "^2.15.0" @@ -1732,6 +1734,50 @@ "url": "https://github.com/sindresorhus/is?sponsor=1" } }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.2.tgz", + "integrity": "sha512-4Bb+oqXZTSTZ1q27Izly9lv8B9dlV61CROxPiVtywwzv5SnytJqhvYe6FclHYuXml4cd1VHPo1zd5PmTeJozvA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.1" + } + }, + "node_modules/@sinonjs/samsam": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.2.tgz", + "integrity": "sha512-v46t/fwnhejRSFTGqbpn9u+LQ9xJDse10gNnPgAcxgdoCDMXj/G2asWAC/8Qs+BAZDicX+MNZouXT1A7c83kVw==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.1", + "lodash.get": "^4.4.2", + "type-detect": "^4.1.0" + } + }, + "node_modules/@sinonjs/samsam/node_modules/type-detect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@sinonjs/text-encoding": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.3.tgz", + "integrity": "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==", + "dev": true + }, "node_modules/@socket.io/component-emitter": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", @@ -2073,6 +2119,21 @@ "@types/send": "*" } }, + "node_modules/@types/sinon": { + "version": "17.0.3", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.3.tgz", + "integrity": "sha512-j3uovdn8ewky9kRBG19bOwaZbexJu/XjtkHyjvUgt4xfPFz18dcORIMqnYh66Fx3Powhcr85NT5+er3+oViapw==", + "dev": true, + "dependencies": { + "@types/sinonjs__fake-timers": "*" + } + }, + "node_modules/@types/sinonjs__fake-timers": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz", + "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==", + "dev": true + }, "node_modules/@types/tough-cookie": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", @@ -4485,9 +4546,9 @@ } }, "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "engines": { "node": ">=6" } @@ -6562,6 +6623,12 @@ "setimmediate": "^1.0.5" } }, + "node_modules/just-extend": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz", + "integrity": "sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==", + "dev": true + }, "node_modules/jwa": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", @@ -6695,6 +6762,12 @@ "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", "peer": true }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + }, "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", @@ -7983,6 +8056,28 @@ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", "dev": true }, + "node_modules/nise": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/nise/-/nise-6.1.1.tgz", + "integrity": "sha512-aMSAzLVY7LyeM60gvBS423nBmIPP+Wy7St7hsb+8/fc1HmeoHJfLO8CKse4u3BtOZvQLJghYPI2i/1WZrEj5/g==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.1", + "@sinonjs/fake-timers": "^13.0.1", + "@sinonjs/text-encoding": "^0.7.3", + "just-extend": "^6.2.0", + "path-to-regexp": "^8.1.0" + } + }, + "node_modules/nise/node_modules/path-to-regexp": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", + "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, "node_modules/node-abi": { "version": "3.62.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.62.0.tgz", @@ -8686,9 +8781,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -9984,6 +10079,33 @@ "simple-concat": "^1.0.0" } }, + "node_modules/sinon": { + "version": "19.0.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-19.0.2.tgz", + "integrity": "sha512-euuToqM+PjO4UgXeLETsfQiuoyPXlqFezr6YZDFwHR3t4qaX0fZUe1MfPMznTL5f8BWrVS89KduLdMUsxFCO6g==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.1", + "@sinonjs/fake-timers": "^13.0.2", + "@sinonjs/samsam": "^8.0.1", + "diff": "^7.0.0", + "nise": "^6.1.1", + "supports-color": "^7.2.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/sinon" + } + }, + "node_modules/sinon/node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -11112,6 +11234,15 @@ "node": ">= 0.8.0" } }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 653922315..20bf183a0 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -524,6 +524,7 @@ "@types/node": "16.x", "@types/react-dom": "^18.2.4", "@types/request": "^2.48.8", + "@types/sinon": "^17.0.3", "@types/vscode": "1.70", "@types/ws": "^8.5.4", "@typescript-eslint/eslint-plugin": "^5.45.0", @@ -537,6 +538,7 @@ "mocha": "^10.4.0", "ovsx": "^0.8.3", "rimraf": "^5.0.5", + "sinon": "^19.0.2", "typescript": "^5.3.3", "vite": "^4.3.9", "vsce": "^2.15.0" diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 0df445b01..3c1fb7df5 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -431,7 +431,42 @@ class VsCodeIde implements IDE { } async getOpenFiles(): Promise { - return await this.ideUtils.getOpenFiles(); + const openFiles = await this.ideUtils.getOpenFiles(); + return this.convertWslPathsIfNeeded(openFiles); + } + + private async convertWslPathsIfNeeded(paths: string[]): Promise { + if (!this.isWsl()) { + return paths; + } + + const convertedPaths = await Promise.all(paths.map(async (path) => { + if (path.startsWith('/mnt/')) { + try { + const [stdout, stderr] = await this.subprocess(`wslpath -w "${path}"`); + if (stderr) { + console.error(`Error converting WSL path: ${stderr}`); + return path; + } + return stdout.trim(); + } catch (error) { + console.error(`Error executing wslpath command: ${error}`); + return path; + } + } + return path; + })); + + return convertedPaths; + } + + /** + * Tests the remote name of the vscode.env.remoteName to see if it starts with 'wsl' + * + * @returns boolean + */ + private isWsl(): boolean { + return !!vscode.env.remoteName?.toLowerCase().startsWith('wsl'); } async getCurrentFile(): Promise { diff --git a/extensions/vscode/src/test/test-suites/vsCodeIde.test.ts b/extensions/vscode/src/test/test-suites/vsCodeIde.test.ts new file mode 100644 index 000000000..368afbf36 --- /dev/null +++ b/extensions/vscode/src/test/test-suites/vsCodeIde.test.ts @@ -0,0 +1,78 @@ +import { describe, test, beforeEach, afterEach } from "mocha"; +import assert from "node:assert"; +import sinon from "sinon"; +import { VsCodeIde } from '../../VsCodeIde'; + +// Mock the vscode module +const mockVscode = { + Uri: { + file: (path: string) => ({ fsPath: path }) + }, + workspace: { + fs: { + readDirectory: sinon.stub().resolves([]) + } + } +}; + +// Replace the real vscode module with our mock +import * as vscode from 'vscode'; +(global as any).vscode = mockVscode; + +describe('VsCodeIde', () => { + let ide: VsCodeIde; + let mockIdeUtils: any; + + beforeEach(() => { + mockIdeUtils = { + getOpenFiles: sinon.stub().resolves([]) + }; + + ide = new VsCodeIde(null as any, Promise.resolve(null as any)); + (ide as any).ideUtils = mockIdeUtils; + (ide as any).subprocess = sinon.stub().resolves(['', '']); + }); + + afterEach(() => { + sinon.restore(); + }); + + describe('getOpenFiles', () => { + test('should return open files without conversion when not in WSL', async () => { + sinon.stub(ide as any, 'isWsl').returns(false); + const mockFiles = ['/path/to/file1', '/path/to/file2']; + mockIdeUtils.getOpenFiles.resolves(mockFiles); + + const result = await ide.getOpenFiles(); + + assert.deepStrictEqual(result, mockFiles); + }); + + test('should convert WSL paths when in WSL environment', async () => { + sinon.stub(ide as any, 'isWsl').returns(true); + + const mockFiles = ['/mnt/c/path/to/file1', '/path/to/file2']; + mockIdeUtils.getOpenFiles.resolves(mockFiles); + + (ide as any).subprocess.withArgs('wslpath -w "/mnt/c/path/to/file1"').resolves(['C:\\path\\to\\file1', '']); + + const result = await ide.getOpenFiles(); + + assert.deepStrictEqual(result, ['C:\\path\\to\\file1', '/path/to/file2']); + }); + + test('should handle errors in WSL path conversion', async () => { + sinon.stub(ide as any, 'isWsl').returns(true); + + const mockFiles = ['/mnt/c/path/to/file1', '/path/to/file2']; + mockIdeUtils.getOpenFiles.resolves(mockFiles); + + (ide as any).subprocess.throws(new Error('Command failed')); + + + const result = await ide.getOpenFiles(); + + assert.deepStrictEqual(result, mockFiles); + }); + }); +}); From 5ae106537d64d9bf795a8da7120f6a5fa6814d54 Mon Sep 17 00:00:00 2001 From: Steve Rhoades Date: Sun, 29 Sep 2024 13:25:53 -0700 Subject: [PATCH 010/255] fix inadvertent package-lock version change --- extensions/vscode/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 02d7e5408..c7e0e63f0 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.213", + "version": "0.9.212", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.213", + "version": "0.9.212", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", From 6da94c48646ca13d9a8a23cfeef3f8731c01b075 Mon Sep 17 00:00:00 2001 From: Lester Hairston Date: Sun, 29 Sep 2024 20:33:48 -0500 Subject: [PATCH 011/255] updated the provider for multichannel support --- core/context/providers/DiscordContext.ts | 147 --------------- .../providers/DiscordContextProvider.ts | 168 ++++++++++++++++++ core/context/providers/index.ts | 2 + .../src/main/resources/config_schema.json | 73 ++++++++ extensions/vscode/config_schema.json | 66 +++++++ extensions/vscode/continue_rc_schema.json | 83 +++++++++ 6 files changed, 392 insertions(+), 147 deletions(-) delete mode 100644 core/context/providers/DiscordContext.ts create mode 100644 core/context/providers/DiscordContextProvider.ts diff --git a/core/context/providers/DiscordContext.ts b/core/context/providers/DiscordContext.ts deleted file mode 100644 index 6a3615e09..000000000 --- a/core/context/providers/DiscordContext.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { AxiosError, AxiosInstance } from "axios"; -import { - ContextItem, - ContextProviderDescription, - ContextProviderExtras, -} from "../../index.js"; -import { BaseContextProvider } from "../index.js"; - -// Define helper interfaces for Discord responses -export interface DiscordChannel { - id: string; - name?: string; - icon?: string; - topic?: string; - guild_id?: string; // The ID of the guild (server) that the channel belongs to -} - -interface DiscordMessage { - id: string; - content: string; - author: { - id: string; - username: string; - }; - timestamp: string; -} - -class DiscordContextProvider extends BaseContextProvider { - // Description for the context provider - static description: ContextProviderDescription = { - title: "discord-messages", - displayTitle: "Discord Messages", - description: "Reference messages from a Discord channel", - type: "normal", - }; - - // Helper function to get the Axios instance with proper authorization - private async getApi(): Promise { - const { default: Axios } = await import("axios"); - const token = this.options.token; - if (!token) { - throw new Error("Discord Bot Token is required!"); - } - - return Axios.create({ - baseURL: "https://discord.com/api/v10", - headers: { - Authorization: `Bot ${token}`, - }, - }); - } - - // Reusable error handling method - private handleApiError(ex: unknown): string { - let content = "# Discord API Error\n\nFailed to retrieve data. "; - if (ex instanceof AxiosError) { - if (ex.response) { - const errorMessage = ex.response?.data - ? (ex.response.data.message ?? JSON.stringify(ex.response?.data)) - : `${ex.response.status}: ${ex.response.statusText}`; - content += `Discord API Error: ${errorMessage}`; - } else { - content += `Discord API Request Error ${ex.request}`; - } - } else { - content += `Unknown error: ${ex instanceof Error ? ex.message : JSON.stringify(ex)}`; - } - return content; - } - - // Fetch Discord channels - private async fetchChannels( - extras: ContextProviderExtras, - ): Promise> { - const api = await this.getApi(); - - try { - const response = await api.get>( - `/guilds/${this.options.guildId}/channels`, - ); - return response.data; - } catch (ex) { - throw new Error(this.handleApiError(ex)); - } - } - - // Fetch messages from a specific channel - private async fetchMessages( - channelId: string, - extras: ContextProviderExtras, - ): Promise> { - const api = await this.getApi(); - try { - const response = await api.get>( - `/channels/${channelId}/messages`, - { params: { limit: 10 } }, - ); - return response.data; - } catch (ex) { - throw new Error(this.handleApiError(ex)); - } - } - - // Main function to get context items (channels and messages) - async getContextItems( - query: string, - extras: ContextProviderExtras, - ): Promise { - const result = [] as Array; - - try { - // Fetch channels - const channels = await this.fetchChannels(extras); - - // Fetch messages for each channel in parallel - const channelMessagePromises = channels.map(async (channel) => { - const messages = await this.fetchMessages(channel.id, extras); - const parts = [ - `# Discord Channel: ${channel.name}`, - ...messages.map( - (message) => - `- ${message.author.username}: ${message.content} (at ${message.timestamp})`, - ), - ]; - - return { - name: `Messages from ${channel.name}`, - content: parts.join("\n"), - description: `Latest messages from the channel ${channel.name}`, - }; - }); - - const channelMessageItems = await Promise.all(channelMessagePromises); - result.push(...channelMessageItems); - } catch (ex) { - result.push({ - name: "Discord Error", - content: this.handleApiError(ex), - description: "Error fetching data from Discord.", - }); - } - - return result; - } -} - -export default DiscordContextProvider; diff --git a/core/context/providers/DiscordContextProvider.ts b/core/context/providers/DiscordContextProvider.ts new file mode 100644 index 000000000..f1282070a --- /dev/null +++ b/core/context/providers/DiscordContextProvider.ts @@ -0,0 +1,168 @@ +import { + ContextItem, + ContextProviderDescription, + ContextProviderExtras, + ContextSubmenuItem, + LoadSubmenuItemsArgs, +} from "../../index.js"; +import { BaseContextProvider } from "../index.js"; +import axios, { AxiosInstance } from "axios"; + +// Define helper interfaces for Discord responses +export interface DiscordChannel { + id: string; + name?: string; // Optional field + icon?: string; + topic?: string; + type?: number; + guild_id?: string; // The ID of the guild (server) that the channel belongs to +} + +interface DiscordMessage { + id: string; + content: string; + author: { + id: string; + username: string; + }; + timestamp: string; +} + +class DiscordContextProvider extends BaseContextProvider { + // Description for the context provider + static description: ContextProviderDescription = { + title: "discord", + displayTitle: "Discord", + description: "Reference Discord messages from a channel", + type: "submenu", + }; + + private baseUrl = "https://discord.com/api/v10"; + + // Helper function to get the Axios instance with proper authorization + private getApi(): AxiosInstance { + const token = this.options.discordKey; + if (!token) { + throw new Error("Discord Bot Token is required!"); + } + + return axios.create({ + baseURL: this.baseUrl, + headers: { + Authorization: `Bot ${token}`, + "Content-Type": "application/json", + }, + }); + } + + // Fetch Discord messages from a specific channel using Axios + async fetchMessages(channelId: string): Promise> { + const api = this.getApi(); + + try { + const response = await api.get>( + `/channels/${channelId}/messages`, + ); + return response.data; + } catch (error) { + console.error("Error fetching messages:", error); + throw new Error(`Failed to fetch messages: ${error}`); + } + } + + // Fetch Discord channels using Axios + async fetchChannels(): Promise> { + // If channels (with id and optional name) are already provided, skip the API call + if (this.options.channels && this.options.channels.length > 0) { + // Return the channel details using the provided channel objects + return this.options.channels.map( + (channel: { id: string; name?: string }) => ({ + id: channel.id, + name: channel.name ?? `Channel ${channel.id}`, // Fall back to "Channel {id}" if name is not provided + }), + ); + } + + // If no channels are provided, fetch them from the API using guildId + const api = this.getApi(); + + try { + const response = await api.get>( + `/guilds/${this.options.guildId}/channels`, + ); + + // Filter for text channels (type 0 represents text channels) + const filteredChannels = response.data.filter( + (channel) => channel.type === 0, + ); + + return filteredChannels; + } catch (error) { + console.error("Error fetching channels:", error); + throw new Error(`Failed to fetch channels: ${error}`); + } + } + + // Main function to get context items (messages) + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { + // Ensure channels are fetched if only guildId is provided + const channels = await this.fetchChannels(); + + // Determine the channel ID from the selected channel (either from query or the first in the options) + let channelId: string; + const selectedChannel = channels.find( + (channel) => channel.id === query || channel.name === query, + ); + + channelId = selectedChannel ? selectedChannel.id : channels[0].id; // Use the first channel if no match is found + + // Prepare parts for rendering the message content + const parts = ["# Discord Channel Messages", `Channel ID: ${channelId}`]; + const messages = await this.fetchMessages(channelId); + + // Check if there are messages + if (messages.length > 0) { + parts.push("## Messages"); + + messages.forEach((message) => { + // Log each message and the username to confirm access + parts.push( + `### ${message.author?.username ?? "Unknown User"} on ${ + message.timestamp + }\n\n${message.content}`, + ); + }); + } else { + parts.push("No messages found."); + } + + const content = parts.join("\n\n"); + + return [ + { + name: `Messages from Channel ${channelId}`, + content, + description: "Latest messages from the channel", + }, + ]; + } + + // Submenu to load the list of channels + async loadSubmenuItems( + args: LoadSubmenuItemsArgs, + ): Promise { + const channels = await this.fetchChannels(); + + // Map over the channels and return them as submenu items + return channels.map((channel) => ({ + id: channel.id, + title: channel.name || `Channel ${channel.id}`, // Fallback to ID if name is missing + description: channel.topic ?? "", + })); + } +} + +export default DiscordContextProvider; diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index 9c2ab4303..110ed066b 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -22,6 +22,7 @@ import SearchContextProvider from "./SearchContextProvider"; import TerminalContextProvider from "./TerminalContextProvider"; import URLContextProvider from "./URLContextProvider"; import RepoMapContextProvider from "./RepoMapContextProvider"; +import DiscordContextProvider from "./DiscordContextProvider"; /** * Note: We are currently omitting the following providers due to bugs: @@ -53,6 +54,7 @@ export const Providers: (typeof BaseContextProvider)[] = [ URLContextProvider, ContinueProxyContextProvider, RepoMapContextProvider, + DiscordContextProvider, ]; export function contextProviderClassFromName( diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 5a20c6daf..333edeb25 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1570,6 +1570,72 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": ["discord"] + } + } + }, + "then": { + "allOf": [ + { + "properties": { + "params": { + "properties": { + "discordKey": { + "type": "string", + "description": "Your Discord bot token to access the Discord API. Required to fetch messages from servers." + }, + "guildId": { + "type": "string", + "description": "The ID of the guild (server) from which to fetch channels and messages." + }, + "channels": { + "type": "array", + "description": "A list of channel objects to search for messages", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the channel" + }, + "name": { + "type": "string", + "description": "The name of the channel" + } + }, + "required": ["id"] + } + } + }, + "required": ["discordKey"] + } + } + }, + { + "oneOf": [ + { + "properties": { + "params": { + "required": ["guildId"] + } + } + }, + { + "properties": { + "params": { + "required": ["channels"] + } + } + } + ] + } + ] + } + }, { "if": { "properties": { @@ -2115,6 +2181,13 @@ "minimum": 128, "exclusiveMaximum": 2147483647 }, + "maxBatchSize": { + "title": "Maximum Batch Size", + "description": "The maximum number of chunks that can be sent to the embeddings provider in a single request", + "type": "integer", + "minimum": 1, + "exclusiveMaximum": 2147483647 + }, "region": { "title": "Region", "description": "The region where the model is hosted", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 176bbd295..333edeb25 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1570,6 +1570,72 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": ["discord"] + } + } + }, + "then": { + "allOf": [ + { + "properties": { + "params": { + "properties": { + "discordKey": { + "type": "string", + "description": "Your Discord bot token to access the Discord API. Required to fetch messages from servers." + }, + "guildId": { + "type": "string", + "description": "The ID of the guild (server) from which to fetch channels and messages." + }, + "channels": { + "type": "array", + "description": "A list of channel objects to search for messages", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the channel" + }, + "name": { + "type": "string", + "description": "The name of the channel" + } + }, + "required": ["id"] + } + } + }, + "required": ["discordKey"] + } + } + }, + { + "oneOf": [ + { + "properties": { + "params": { + "required": ["guildId"] + } + } + }, + { + "properties": { + "params": { + "required": ["channels"] + } + } + } + ] + } + ] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 7a7e54764..f7bff8284 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1741,6 +1741,82 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": [ + "discord" + ] + } + } + }, + "then": { + "allOf": [ + { + "properties": { + "params": { + "properties": { + "discordKey": { + "type": "string", + "description": "Your Discord bot token to access the Discord API. Required to fetch messages from servers." + }, + "guildId": { + "type": "string", + "description": "The ID of the guild (server) from which to fetch channels and messages." + }, + "channels": { + "type": "array", + "description": "A list of channel objects to search for messages", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the channel" + }, + "name": { + "type": "string", + "description": "The name of the channel" + } + }, + "required": [ + "id" + ] + } + } + }, + "required": [ + "discordKey" + ] + } + } + }, + { + "oneOf": [ + { + "properties": { + "params": { + "required": [ + "guildId" + ] + } + } + }, + { + "properties": { + "params": { + "required": [ + "channels" + ] + } + } + } + ] + } + ] + } + }, { "if": { "properties": { @@ -2356,6 +2432,13 @@ "minimum": 128, "exclusiveMaximum": 2147483647 }, + "maxBatchSize": { + "title": "Maximum Batch Size", + "description": "The maximum number of chunks that can be sent to the embeddings provider in a single request", + "type": "integer", + "minimum": 1, + "exclusiveMaximum": 2147483647 + }, "region": { "title": "Region", "description": "The region where the model is hosted", From 986f2d2204d95ada9cc04d936d5c08df6d989b8b Mon Sep 17 00:00:00 2001 From: Lester Hairston Date: Sun, 29 Sep 2024 22:27:33 -0500 Subject: [PATCH 012/255] docs update --- docs/docs/customize/context-providers.md | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/docs/customize/context-providers.md b/docs/docs/customize/context-providers.md index daed6d63b..d5212e562 100644 --- a/docs/docs/customize/context-providers.md +++ b/docs/docs/customize/context-providers.md @@ -315,6 +315,36 @@ assignee = currentUser() AND resolution = Unresolved order by updated DESC You can override this query by setting the `issueQuery` parameter. +### `@Discord` + +Reference the messages in a Discord channel. + +```json title="config.json" +{ + "contextProviders": [ + { + "name": "discord", + "params": { + "discordKey": "bot token", + "guildId": "1234567890", + "channels": [ + { + "id": "123456", + "name": "example-channel" + }, + { + "id": "678901", + "name": "example-channel-2" + } + ] + } + } + ] +} +``` + +Make sure to include your own [Bot Token](https://discord.com/developers/applications), and join it to your related server . If you want more granular control over which channels are searched, you can specify a list of channel IDs to search in. If you don't want to specify any channels, just include the guild id(Server ID) and all channels will be included. The provider only reads text channels. + ### `@Postgres` Reference the schema of a table, and some sample rows From 15b457f9b1fc0aff72c178fe5cd49002b746b823 Mon Sep 17 00:00:00 2001 From: Kevin Abestilla Date: Tue, 1 Oct 2024 00:43:00 +0200 Subject: [PATCH 013/255] Update introduction.md --- docs/docs/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md index 9f5bbe9be..b3f6d87d6 100644 --- a/docs/docs/introduction.md +++ b/docs/docs/introduction.md @@ -20,6 +20,6 @@ keywords: **Continue is the leading open-source AI code assistant inside of [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension)** - [Chat](chat/how-to-use-it.md) to understand and iterate on code in the sidebar -- [Autocomplete](autocomplete/how-to-use-it.md) to recieve inline code suggestions as you type +- [Autocomplete](autocomplete/how-to-use-it.md) to receive inline code suggestions as you type - [Edit](edit/how-to-use-it.md) to modify code without leaving your current file - [Actions](actions/how-to-use-it.md) to establish shortcuts for common use cases From 47bf44eaf8840643fd40e1b9e3a2e5f5bdc66fc5 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 30 Sep 2024 17:59:33 -0700 Subject: [PATCH 014/255] ? --- core/llm/llms/Ollama.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 3b16d0456..96e01edf1 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -31,7 +31,7 @@ class Ollama extends BaseLLM { body: JSON.stringify({ name: this._getModel() }), }) .then(async (response) => { - if (response.status !== 200) { + if (response?.status !== 200) { // console.warn( // "Error calling Ollama /api/show endpoint: ", // await response.text(), From cc414ebfd4209f040511ec288e41f153ed932fb3 Mon Sep 17 00:00:00 2001 From: Santiago Basulto Date: Tue, 1 Oct 2024 06:51:08 -0300 Subject: [PATCH 015/255] Fixed docs: OpenAI's example embeddings model --- .../customize/model-providers/top-level/openai.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/openai.md b/docs/docs/customize/model-providers/top-level/openai.md index 600ec08cd..d594f4f39 100644 --- a/docs/docs/customize/model-providers/top-level/openai.md +++ b/docs/docs/customize/model-providers/top-level/openai.md @@ -38,13 +38,11 @@ We recommend configuring **text-embedding-3-large** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "openai", - "model": "text-embedding-3-large", - "apiKey": "[API_KEY]" - } - ] + "embeddingsProvider": { + "provider": "openai", + "model": "text-embedding-3-large", + "apiKey": "[API_KEY]" + } } ``` From 75e2d2f39df30424b3831615ee3720a2844a60a5 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 10:48:45 -0700 Subject: [PATCH 016/255] feat: improve dropshadow on jb inline edit --- .gitignore | 2 + .../editor/InlineEditAction.kt | 147 ++++++++---------- .../src/main/resources/config_schema.json | 36 ++++- extensions/vscode/continue_rc_schema.json | 41 ++++- extensions/vscode/package-lock.json | 4 +- 5 files changed, 142 insertions(+), 88 deletions(-) diff --git a/.gitignore b/.gitignore index ba5199b56..113c07c43 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,5 @@ Icon? .aider* notes.md + +manual-testing-sandbox/Continue/.idea/vcs.xml \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index f94214c34..c2dab4527 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -24,38 +24,38 @@ import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import org.jdesktop.swingx.JXPanel import org.jdesktop.swingx.JXTextArea -import org.jdesktop.swingx.border.DropShadowBorder import java.awt.* import java.awt.event.* -import java.awt.geom.RoundRectangle2D +import java.awt.geom.Path2D import javax.swing.* import javax.swing.border.EmptyBorder import javax.swing.event.DocumentEvent import javax.swing.event.DocumentListener import javax.swing.plaf.basic.BasicComboBoxUI import kotlin.math.max +import java.awt.geom.RoundRectangle2D +import java.awt.geom.AffineTransform - -const val SHADOW_SIZE = 7 const val MAIN_FONT_SIZE = 13 fun makeTextArea(): JTextArea { - val textArea = CustomTextArea( 2, 40).apply { + val textArea = CustomTextArea(1, 40).apply { lineWrap = true wrapStyleWord = true isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(8) + margin = JBUI.insets(6, 4, 4, 4) // Reduced from 8 to 4 font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) + // Set a preferred size with a taller height + preferredSize = Dimension(400, 75) // Added this line } textArea.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) - return textArea } fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { - val topPanel = ShadowPanel(MigLayout("wrap 1, insets 4 $leftInset 2 2, gap 0!")).apply { + val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset + 4} 8 2, gap 0!")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground // background = defaultBackground @@ -63,7 +63,7 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 0, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { + val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -71,16 +71,9 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) preferredSize = textArea.preferredSize - isOpaque = false setup() - - val shadow = DropShadowBorder() - shadow.shadowColor = JBColor(0xb0b0b0, 0x505050) - shadow.isShowRightShadow = true - shadow.isShowBottomShadow = true - shadow.shadowSize = SHADOW_SIZE - border = shadow } + customPanelRef.set(panel) textArea.addComponentListener(object : ComponentAdapter() { @@ -252,6 +245,19 @@ class InlineEditAction : AnAction(), DumbAware { } class CustomPanel(layout: MigLayout, project: Project, modelTitles: List, comboBoxRef: Ref>, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel(layout) { + private val shadowSize = 5 + private val cornerRadius = 8 + private val shadowColor = Color(0, 0, 0, 40) // Lighter shadow + private val borderColor = Color(128, 128, 128, 128) + private val borderThickness = 1 + private val triangleSize = 6 + private val rightMargin = 3.0 + + init { + isOpaque = false + } + + private val subPanelA: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground @@ -289,9 +295,8 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List comboBoxRef.set(dropdown) - val rightButton = CustomButton("Submit") { onEnter() }.apply { -// background = GetTheme().getHighlight() - background = JBColor(0xe04573e8.toInt(), 0xe04573e8.toInt()) + val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { + background = JBColor(0x999998.toInt(), 0x999998.toInt()) foreground = JBColor(0xffffffff.toInt(), 0xffffffff.toInt()) } @@ -302,7 +307,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List add(rightButton, "align right") } - border = EmptyBorder(4, 8, 4, 8) + border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 add(leftButton, "align left") add(rightPanel, "align right") @@ -311,52 +316,17 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) } - private val subPanelB: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { - // Get the global color scheme and default background color - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground - - val leftButton = CustomButton("Esc to cancel") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) - background = defaultBackground - } - - val dropdown = JComboBox(modelTitles.toTypedArray()).apply { - isEditable = true - background = defaultBackground - foreground = Color(128, 128, 128, 200) - font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) - border = EmptyBorder(2, 4, 2, 4) - isOpaque = false - isEditable = false - cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) - renderer = DefaultListCellRenderer().apply { - horizontalAlignment = SwingConstants.RIGHT - } - - isVisible = false - -// setUI(TransparentArrowButtonUI()) - } - - val progressBar = JProgressBar() - progressBar.isIndeterminate = true - - val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { - isOpaque = false - border = EmptyBorder(0, 0, 0, 0) - add(dropdown, "align right") - add(progressBar, "align right") - } - - - - border = EmptyBorder(4, 8, 4, 8) - add(leftButton, "align left") - add(rightPanel, "align right") + private val subPanelB: JPanel = JPanel(BorderLayout()).apply { isOpaque = false - cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) + val progressBar = JProgressBar().apply { + isIndeterminate = true + } + + add(progressBar, BorderLayout.CENTER) + + // Add right and bottom insets + border = BorderFactory.createEmptyBorder(0, 0, 20, 16) } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -387,6 +357,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List } fun setup() { +// add(subPanelB, "grow, gap 0!") remove(subPanelB) remove(subPanelC) add(subPanelA, "grow, gap 0!") @@ -408,30 +379,41 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List } override fun paintComponent(g: Graphics) { + super.paintComponent(g) + val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - // Draw the rounded border - val borderColor = Color(128, 128, 128, 128) - val borderThickness = 1 - val borderRadius = 8 + val w = width - shadowSize + val h = height - shadowSize + // Create the shape for the tooltip/triangle + val shape = Path2D.Double() + shape.moveTo(borderThickness / 2.0, cornerRadius.toDouble()) + shape.quadTo(borderThickness / 2.0, borderThickness / 2.0, cornerRadius.toDouble(), borderThickness / 2.0) + shape.lineTo(w - cornerRadius.toDouble() - rightMargin, borderThickness / 2.0) + shape.quadTo(w - borderThickness / 2.0 - rightMargin, borderThickness / 2.0, w - borderThickness / 2.0 - rightMargin, cornerRadius.toDouble()) + shape.lineTo(w - borderThickness / 2.0 - rightMargin, h - cornerRadius - triangleSize.toDouble()) + shape.quadTo(w - borderThickness / 2.0 - rightMargin, h - triangleSize.toDouble(), w - cornerRadius.toDouble() - rightMargin, h - triangleSize.toDouble()) + shape.lineTo(triangleSize.toDouble(), h - triangleSize.toDouble()) + shape.lineTo(borderThickness / 2.0, h.toDouble()) + shape.lineTo(borderThickness / 2.0, cornerRadius.toDouble()) + + // Draw shadow + g2.color = shadowColor + g2.fill(shape.createTransformedShape(AffineTransform.getTranslateInstance(shadowSize.toDouble(), shadowSize.toDouble()))) + + // Draw main shape + g2.color = background + g2.fill(shape) + + // Draw border g2.color = borderColor g2.stroke = BasicStroke(borderThickness.toFloat()) - g2.drawRoundRect( - borderThickness / 2, - borderThickness / 2, - width - borderThickness - SHADOW_SIZE + 1, - height - borderThickness - SHADOW_SIZE + 1, - borderRadius, - borderRadius - ) - - super.paintComponent(g) + g2.draw(shape) } } - class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { private var isHovered = false @@ -488,7 +470,7 @@ class CustomTextArea(rows: Int, columns: Int) : JXTextArea("") { if (text.isEmpty()) { g.color = Color(128, 128, 128, 255) g.font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) - g.drawString("Enter instructions to edit highlighted code", 8, 20) + g.drawString("Enter instructions...", 3, 20) } super.paintComponent(g) @@ -543,4 +525,5 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { val defaultBackground = globalScheme.defaultBackground comboBox.background = defaultBackground } -} \ No newline at end of file +} + diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 1f8e85f73..3f340f6ce 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1552,7 +1552,8 @@ "url", "database", "os", - "repo-map" + "repo-map", + "greptile" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -1576,7 +1577,8 @@ "Reference the contents of a page at a URL", "Reference table schemas", "Operating system and CPU Information", - "Map of files in the repository with important code highlights" + "Map of files in the repository with important code highlights", + "Query your greptile index of the current repo" ], "type": "string" }, @@ -1954,6 +1956,36 @@ }, "required": ["host", "port", "user", "password", "database"] } + }, + { + "if": { + "properties": { + "name": { + "enum": ["greptile"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "GithubToken": { + "title": "GithubToken", + "description": "Your github access token", + "default": "", + "type": "string" + }, + "GreptileToken": { + "title": "GreptileToken", + "description": "Your greptile access token", + "default": "", + "type": "string" + } + } + } + }, + "required": ["GreptileToken", "GithubToken"] + } } ], "required": ["name"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index a5ce1dbc4..26877d8a3 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1723,7 +1723,8 @@ "url", "database", "os", - "repo-map" + "repo-map", + "greptile" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -1747,7 +1748,8 @@ "Reference the contents of a page at a URL", "Reference table schemas", "Operating system and CPU Information", - "Map of files in the repository with important code highlights" + "Map of files in the repository with important code highlights", + "Query your greptile index of the current repo" ], "type": "string" }, @@ -2190,6 +2192,41 @@ "database" ] } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "greptile" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "GithubToken": { + "title": "GithubToken", + "description": "Your github access token", + "default": "", + "type": "string" + }, + "GreptileToken": { + "title": "GreptileToken", + "description": "Your greptile access token", + "default": "", + "type": "string" + } + } + } + }, + "required": [ + "GreptileToken", + "GithubToken" + ] + } } ], "required": [ diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 05833b84e..5bfd16377 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.213", + "version": "0.9.214", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.213", + "version": "0.9.214", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", From 9699eb7c99bdad54602e634892949dee5d20c961 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 1 Oct 2024 23:04:58 +0200 Subject: [PATCH 017/255] add chat shortcut to quick picks --- extensions/vscode/src/commands.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 17140eaf8..0edf63227 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -641,6 +641,12 @@ const commandsMap: ( : StatusBarStatus.Disabled; } quickPick.items = [ + { + label: "$(comment) Open chat (Cmd+L)", + }, + { + label: "$(screen-full) Open full screen chat (Cmd+K Cmd+M)", + }, { label: quickPickStatusText(targetStatus), }, @@ -685,6 +691,13 @@ const commandsMap: ( configHandler.reloadConfig(); } else if (selectedOption === "$(feedback) Give feedback") { vscode.commands.executeCommand("continue.giveAutocompleteFeedback"); + } else if (selectedOption === "$(comment) Open chat (Cmd+L)") { + vscode.commands.executeCommand("continue.focusContinueInput"); + } else if ( + selectedOption === + "$(screen-full) Open full screen chat (Cmd+K Cmd+M)" + ) { + vscode.commands.executeCommand("continue.toggleFullScreen"); } quickPick.dispose(); }); From 0570e93741bdd760c9b121db2e583fce675bbf02 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 14:35:05 -0700 Subject: [PATCH 018/255] update shadow --- docs/static/schemas/config.json | 36 ++++++++- .../editor/InlineEditAction.kt | 78 +++++++++++-------- 2 files changed, 80 insertions(+), 34 deletions(-) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 1f8e85f73..3f340f6ce 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1552,7 +1552,8 @@ "url", "database", "os", - "repo-map" + "repo-map", + "greptile" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -1576,7 +1577,8 @@ "Reference the contents of a page at a URL", "Reference table schemas", "Operating system and CPU Information", - "Map of files in the repository with important code highlights" + "Map of files in the repository with important code highlights", + "Query your greptile index of the current repo" ], "type": "string" }, @@ -1954,6 +1956,36 @@ }, "required": ["host", "port", "user", "password", "database"] } + }, + { + "if": { + "properties": { + "name": { + "enum": ["greptile"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "GithubToken": { + "title": "GithubToken", + "description": "Your github access token", + "default": "", + "type": "string" + }, + "GreptileToken": { + "title": "GreptileToken", + "description": "Your greptile access token", + "default": "", + "type": "string" + } + } + } + }, + "required": ["GreptileToken", "GithubToken"] + } } ], "required": ["name"] diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index c2dab4527..7de540cdc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -244,7 +244,16 @@ class InlineEditAction : AnAction(), DumbAware { } } -class CustomPanel(layout: MigLayout, project: Project, modelTitles: List, comboBoxRef: Ref>, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel(layout) { +class CustomPanel( + layout: MigLayout, + project: Project, + modelTitles: List, + comboBoxRef: Ref>, + private val onEnter: () -> Unit, + private val onCancel: () -> Unit, + private val onAccept: () -> Unit, + private val onReject: () -> Unit +) : JPanel(layout) { private val shadowSize = 5 private val cornerRadius = 8 private val shadowColor = Color(0, 0, 0, 40) // Lighter shadow @@ -252,24 +261,28 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List private val borderThickness = 1 private val triangleSize = 6 private val rightMargin = 3.0 + private val closeButton: JComponent = createCloseButton() init { isOpaque = false + add(closeButton, "pos 100% 0 -3 3, w 20!, h 20!") } + private fun createCloseButton(): JComponent { + return CustomButton("X") { onCancel() }.apply { + foreground = Color(128, 128, 128, 200) + background = Color(0, 0, 0, 0) + font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 12) + border = EmptyBorder(2, 6, 2, 6) + } + } private val subPanelA: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground - - val leftButton = CustomButton("Esc to cancel") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) - background = defaultBackground - } - val continueSettingsService = service() - val dropdown = JComboBox(modelTitles.toTypedArray()).apply { + setUI(TransparentArrowButtonUI()) isEditable = true background = defaultBackground foreground = Color(128, 128, 128, 200) @@ -279,7 +292,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List isEditable = false cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) renderer = DefaultListCellRenderer().apply { - horizontalAlignment = SwingConstants.RIGHT + horizontalAlignment = SwingConstants.LEFT } selectedIndex = continueSettingsService.continueState.lastSelectedInlineEditModel?.let { val index = modelTitles.indexOf(it) @@ -289,8 +302,6 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List addActionListener { continueSettingsService.continueState.lastSelectedInlineEditModel = selectedItem as String } - -// setUI(TransparentArrowButtonUI()) } comboBoxRef.set(dropdown) @@ -309,8 +320,8 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 - add(leftButton, "align left") - add(rightPanel, "align right") + add(dropdown, "align left") + add(rightPanel, "align right, split 2") isOpaque = false cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) @@ -496,34 +507,37 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - val size = 6 + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE) + + val size = 4 // Smaller size val x = (width - size) / 2 - val y = (height - size / 2) / 2 - val triangle = Polygon( - intArrayOf(x, x + size, x + size / 2), - intArrayOf(y, y, (y + size / 1.16).toInt()), - 3 - ) - g2.color = Color.GRAY - g2.fill(triangle) + val y = (height - size) / 2 + + val path = Path2D.Double() + path.moveTo(x.toDouble(), y.toDouble()) + path.lineTo((x + size).toDouble(), y.toDouble()) + path.lineTo((x + size / 2.0), (y + size).toDouble()) + path.closePath() + + g2.color = Color(128, 128, 128, 200) // Light gray, semi-transparent + g2.fill(path) + } + + override fun getPreferredSize(): Dimension { + return Dimension(12, 12) // Smaller button size } }.apply { - border = EmptyBorder(0, 0, 0, 0) -// background = Color(0, 0, 0, 0) isOpaque = false - } - - override fun getInsets(): Insets { - return JBUI.insets(0, 0, 0, 0) + isFocusable = false + isBorderPainted = false + isContentAreaFilled = false } override fun installUI(c: JComponent?) { super.installUI(c) - comboBox.border = EmptyBorder(0, 0, 0, 0) + comboBox.border = EmptyBorder(2, 0, 2, 0) comboBox.isOpaque = false - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground - comboBox.background = defaultBackground + comboBox.background = Color(0, 0, 0, 0) // Fully transparent background } } From dfd37912df051d291e7883ad7aef8fa4b8850a74 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 17:04:53 -0700 Subject: [PATCH 019/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 130 ++++++++++++------ 1 file changed, 91 insertions(+), 39 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 7de540cdc..0020d260f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -45,7 +45,7 @@ fun makeTextArea(): JTextArea { isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(6, 4, 4, 4) // Reduced from 8 to 4 + margin = JBUI.insets(6, 4, 0, 4) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) // Set a preferred size with a taller height preferredSize = Dimension(400, 75) // Added this line @@ -55,7 +55,7 @@ fun makeTextArea(): JTextArea { } fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { - val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset + 4} 8 2, gap 0!")).apply { + val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset} 2 2, gap 0!")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground // background = defaultBackground @@ -63,7 +63,7 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { + val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject, textArea).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -197,6 +197,15 @@ fun openInlineEdit(project: Project?, editor: Editor) { } }) + // Listen for key typed events after diff streaming is finished + textArea.addKeyListener(object : KeyAdapter() { + override fun keyTyped(e: KeyEvent) { + if (customPanelRef.get().isFinished) { + customPanelRef.get().setup() + } + } + }) + // Listen for changes to textarea line count textArea.document.addDocumentListener(object : DocumentListener { private var lastNumLines: Int = 0 @@ -252,7 +261,8 @@ class CustomPanel( private val onEnter: () -> Unit, private val onCancel: () -> Unit, private val onAccept: () -> Unit, - private val onReject: () -> Unit + private val onReject: () -> Unit, + private val textArea: JTextArea ) : JPanel(layout) { private val shadowSize = 5 private val cornerRadius = 8 @@ -262,18 +272,31 @@ class CustomPanel( private val triangleSize = 6 private val rightMargin = 3.0 private val closeButton: JComponent = createCloseButton() + private val originalTextColor: Color = textArea.foreground + private val greyTextColor: Color = Color(128, 128, 128, 200) + public var isFinished = false init { isOpaque = false - add(closeButton, "pos 100% 0 -3 3, w 20!, h 20!") + add(closeButton, "pos 100%-25 0 -3 3, w 20!, h 20!") } private fun createCloseButton(): JComponent { return CustomButton("X") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) + foreground = Color(128, 128, 128, 128) background = Color(0, 0, 0, 0) - font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 12) + font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 10) border = EmptyBorder(2, 6, 2, 6) + toolTipText = "`esc` to cancel" + + addMouseListener(object : MouseAdapter() { + override fun mouseEntered(e: MouseEvent) { + foreground = Color(128, 128, 128, 255) + } + override fun mouseExited(e: MouseEvent) { + foreground = Color(128, 128, 128, 128) + } + }) } } @@ -307,8 +330,9 @@ class CustomPanel( comboBoxRef.set(dropdown) val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { - background = JBColor(0x999998.toInt(), 0x999998.toInt()) - foreground = JBColor(0xffffffff.toInt(), 0xffffffff.toInt()) + background = JBColor(0x33999998.toInt(), 0x33999998.toInt()) + foreground = Color.WHITE + border = EmptyBorder(2, 6, 2, 6) } val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -318,7 +342,7 @@ class CustomPanel( add(rightButton, "align right") } - border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 + border = EmptyBorder(0, 0, 20, 16) add(dropdown, "align left") add(rightPanel, "align right, split 2") @@ -341,17 +365,20 @@ class CustomPanel( } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { - val leftLabel = JLabel("Enter follow-up instructions").apply { + val leftLabel = JLabel("Type to re-prompt").apply { foreground = Color(128, 128, 128, 200) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) + border = EmptyBorder(0, 4, 0, 0) } - val leftButton = CustomButton("${getAltKeyLabel()}⇧N") { onReject() }.apply { - background = Color(255, 0, 0, 64) + val leftButton = CustomButton("Reject (${getAltKeyLabel()}⇧N)") { onReject() }.apply { + background = Color(239, 68, 68) // text-red-500 + foreground = Color.WHITE } - val rightButton = CustomButton("${getAltKeyLabel()}⇧Y") { onAccept() }.apply { - background = Color(0, 255, 0, 64) + val rightButton = CustomButton("Accept (${getAltKeyLabel()}⇧Y)") { onAccept() }.apply { + background = Color(34, 197, 94) // text-green-500 + foreground = Color.WHITE } val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -363,15 +390,19 @@ class CustomPanel( add(leftLabel, "align left") add(rightPanel, "align right") - border = EmptyBorder(4, 8, 4, 8) + // Add right and bottom insets + border = BorderFactory.createEmptyBorder(0, 0, 20, 16) isOpaque = false } fun setup() { -// add(subPanelB, "grow, gap 0!") remove(subPanelB) remove(subPanelC) add(subPanelA, "grow, gap 0!") + isFinished = false + revalidate() + repaint() + textArea.foreground = originalTextColor } fun enter() { @@ -387,6 +418,8 @@ class CustomPanel( add(subPanelC, "grow, gap 0!") revalidate() repaint() + isFinished = true + textArea.foreground = greyTextColor } override fun paintComponent(g: Graphics) { @@ -507,37 +540,56 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE) - - val size = 4 // Smaller size + val size = 6 val x = (width - size) / 2 - val y = (height - size) / 2 - - val path = Path2D.Double() - path.moveTo(x.toDouble(), y.toDouble()) - path.lineTo((x + size).toDouble(), y.toDouble()) - path.lineTo((x + size / 2.0), (y + size).toDouble()) - path.closePath() - - g2.color = Color(128, 128, 128, 200) // Light gray, semi-transparent - g2.fill(path) - } - - override fun getPreferredSize(): Dimension { - return Dimension(12, 12) // Smaller button size + val y = (height - size / 2) / 2 + val triangle = Polygon( + intArrayOf(x, x + size, x + size / 2), + intArrayOf(y, y, (y + size / 1.16).toInt()), + 3 + ) + g2.color = Color.GRAY + g2.fill(triangle) } }.apply { + border = EmptyBorder(0, 0, 0, 0) isOpaque = false - isFocusable = false - isBorderPainted = false - isContentAreaFilled = false + } + + override fun getInsets(): Insets { + return JBUI.insets(0, 6, 0, 0) } override fun installUI(c: JComponent?) { super.installUI(c) - comboBox.border = EmptyBorder(2, 0, 2, 0) comboBox.isOpaque = false - comboBox.background = Color(0, 0, 0, 0) // Fully transparent background + val globalScheme = EditorColorsManager.getInstance().globalScheme + val defaultBackground = globalScheme.defaultBackground + comboBox.background = defaultBackground } + + override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + + // Do nothing to prevent painting the background +} + +override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + val renderer = comboBox.renderer + val item = comboBox.selectedItem + + if (item != null) { + val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) + c.font = comboBox.font + c.foreground = comboBox.foreground + c.background = comboBox.background + + if (c is JComponent) { + c.isOpaque = false + } + + val currentValuePane = currentValuePane + currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) + } +} } From 25b8b84a80c4838902c271ff31da823b156d674b Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 17:16:32 -0700 Subject: [PATCH 020/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 146 ++++++++++++------ 1 file changed, 96 insertions(+), 50 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 0020d260f..55ad62630 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -45,25 +45,43 @@ fun makeTextArea(): JTextArea { isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(6, 4, 0, 4) + margin = JBUI.insets(6, 4, 6, 4) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) - // Set a preferred size with a taller height - preferredSize = Dimension(400, 75) // Added this line + preferredSize = Dimension(400, 75) } textArea.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) return textArea } -fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { +fun makePanel( + project: Project, + customPanelRef: Ref, + textArea: JTextArea, + inlayRef: Ref, + comboBoxRef: Ref>, + leftInset: Int, + modelTitles: List, + onEnter: () -> Unit, + onCancel: () -> Unit, + onAccept: () -> Unit, + onReject: () -> Unit +): JPanel { val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset} 2 2, gap 0!")).apply { - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground -// background = defaultBackground - background = JBColor(0x20888888.toInt(), 0x20888888.toInt()) + background = JBColor(0x20888888.toInt(), 0x20888888.toInt()) isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject, textArea).apply { + val panel = CustomPanel( + MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), + project, + modelTitles, + comboBoxRef, + onEnter, + onCancel, + onAccept, + onReject, + textArea + ).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -92,9 +110,9 @@ fun openInlineEdit(project: Project?, editor: Editor) { if (project == null) return // Don't open in terminal - if (EditorUtils().isTerminal(editor)) { - return - } + if (EditorUtils().isTerminal(editor)) { + return + } val manager = EditorComponentInlaysManager.from(editor) @@ -135,7 +153,8 @@ fun openInlineEdit(project: Project?, editor: Editor) { val lineEnd = editor.document.getLineEndOffset(indentationLineNum) val text = editor.document.getText(TextRange(lineStart, lineEnd)) val indentation = text.takeWhile { it == ' ' }.length - val charWidth = editor.contentComponent.getFontMetrics(editor.colorsScheme.getFont(EditorFontType.PLAIN)).charWidth(' ') + val charWidth = + editor.contentComponent.getFontMetrics(editor.colorsScheme.getFont(EditorFontType.PLAIN)).charWidth(' ') val leftInset = indentation * charWidth * 2 / 3 val inlayRef = Ref() @@ -162,16 +181,17 @@ fun openInlineEdit(project: Project?, editor: Editor) { diffStreamHandler.run(textArea.text, prefix, highlighted, suffix, comboBoxRef.get().selectedItem as String) } - val panel = makePanel(project, customPanelRef, textArea, inlayRef, comboBoxRef, leftInset, modelTitles, {onEnter()}, { - diffStreamService.reject(editor) - selectionModel.setSelection(start, end) - }, { - diffStreamService.accept(editor) - inlayRef.get().dispose() - }, { - diffStreamService.reject(editor) - inlayRef.get().dispose() - }) + val panel = + makePanel(project, customPanelRef, textArea, inlayRef, comboBoxRef, leftInset, modelTitles, { onEnter() }, { + diffStreamService.reject(editor) + selectionModel.setSelection(start, end) + }, { + diffStreamService.accept(editor) + inlayRef.get().dispose() + }, { + diffStreamService.reject(editor) + inlayRef.get().dispose() + }) val inlay = manager.insertAfter(lineNumber, panel) panel.revalidate() inlayRef.set(inlay) @@ -216,6 +236,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { viewport?.dispatchEvent(ComponentEvent(viewport, ComponentEvent.COMPONENT_RESIZED)) } } + override fun insertUpdate(e: DocumentEvent?) { updateSize() } @@ -293,6 +314,7 @@ class CustomPanel( override fun mouseEntered(e: MouseEvent) { foreground = Color(128, 128, 128, 255) } + override fun mouseExited(e: MouseEvent) { foreground = Color(128, 128, 128, 128) } @@ -329,7 +351,7 @@ class CustomPanel( comboBoxRef.set(dropdown) - val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { + val rightButton = CustomButton("⏎ Enter") { onEnter() }.apply { background = JBColor(0x33999998.toInt(), 0x33999998.toInt()) foreground = Color.WHITE border = EmptyBorder(2, 6, 2, 6) @@ -359,14 +381,12 @@ class CustomPanel( } add(progressBar, BorderLayout.CENTER) - - // Add right and bottom insets border = BorderFactory.createEmptyBorder(0, 0, 20, 16) } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val leftLabel = JLabel("Type to re-prompt").apply { - foreground = Color(128, 128, 128, 200) + foreground = Color(156, 163, 175) // text-gray-400 font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) border = EmptyBorder(0, 4, 0, 0) } @@ -390,7 +410,6 @@ class CustomPanel( add(leftLabel, "align left") add(rightPanel, "align right") - // Add right and bottom insets border = BorderFactory.createEmptyBorder(0, 0, 20, 16) isOpaque = false } @@ -436,16 +455,33 @@ class CustomPanel( shape.moveTo(borderThickness / 2.0, cornerRadius.toDouble()) shape.quadTo(borderThickness / 2.0, borderThickness / 2.0, cornerRadius.toDouble(), borderThickness / 2.0) shape.lineTo(w - cornerRadius.toDouble() - rightMargin, borderThickness / 2.0) - shape.quadTo(w - borderThickness / 2.0 - rightMargin, borderThickness / 2.0, w - borderThickness / 2.0 - rightMargin, cornerRadius.toDouble()) + shape.quadTo( + w - borderThickness / 2.0 - rightMargin, + borderThickness / 2.0, + w - borderThickness / 2.0 - rightMargin, + cornerRadius.toDouble() + ) shape.lineTo(w - borderThickness / 2.0 - rightMargin, h - cornerRadius - triangleSize.toDouble()) - shape.quadTo(w - borderThickness / 2.0 - rightMargin, h - triangleSize.toDouble(), w - cornerRadius.toDouble() - rightMargin, h - triangleSize.toDouble()) + shape.quadTo( + w - borderThickness / 2.0 - rightMargin, + h - triangleSize.toDouble(), + w - cornerRadius.toDouble() - rightMargin, + h - triangleSize.toDouble() + ) shape.lineTo(triangleSize.toDouble(), h - triangleSize.toDouble()) shape.lineTo(borderThickness / 2.0, h.toDouble()) shape.lineTo(borderThickness / 2.0, cornerRadius.toDouble()) // Draw shadow g2.color = shadowColor - g2.fill(shape.createTransformedShape(AffineTransform.getTranslateInstance(shadowSize.toDouble(), shadowSize.toDouble()))) + g2.fill( + shape.createTransformedShape( + AffineTransform.getTranslateInstance( + shadowSize.toDouble(), + shadowSize.toDouble() + ) + ) + ) // Draw main shape g2.color = background @@ -484,13 +520,21 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) border = EmptyBorder(2, 4, 2, 4) } + override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) val cornerRadius = 8 val rect = Rectangle(0, 0, width, height) - val roundRect = RoundRectangle2D.Float(rect.x.toFloat(), rect.y.toFloat(), rect.width.toFloat(), rect.height.toFloat(), cornerRadius.toFloat(), cornerRadius.toFloat()) + val roundRect = RoundRectangle2D.Float( + rect.x.toFloat(), + rect.y.toFloat(), + rect.width.toFloat(), + rect.height.toFloat(), + cornerRadius.toFloat(), + cornerRadius.toFloat() + ) if (isHovered) { g2.color = background.brighter() } else { @@ -498,8 +542,10 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { } g2.fill(roundRect) g2.color = foreground - g2.drawString(text, (width / 2 - g.fontMetrics.stringWidth(text) / 2).toFloat(), - (height / 2 + g.fontMetrics.ascent / 2).toFloat()) + g2.drawString( + text, (width / 2 - g.fontMetrics.stringWidth(text) / 2).toFloat(), + (height / 2 + g.fontMetrics.ascent / 2).toFloat() + ) } } @@ -570,26 +616,26 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - // Do nothing to prevent painting the background -} + // Do nothing to prevent painting the background + } -override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - val renderer = comboBox.renderer - val item = comboBox.selectedItem + override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + val renderer = comboBox.renderer + val item = comboBox.selectedItem - if (item != null) { - val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) - c.font = comboBox.font - c.foreground = comboBox.foreground - c.background = comboBox.background + if (item != null) { + val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) + c.font = comboBox.font + c.foreground = Color(156, 163, 175) // text-gray-400 + c.background = comboBox.background - if (c is JComponent) { - c.isOpaque = false + if (c is JComponent) { + c.isOpaque = false + } + + val currentValuePane = currentValuePane + currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) } - - val currentValuePane = currentValuePane - currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) } } -} From 29d82536cfae2deff3c7d82227f653e7d5ff6187 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Oct 2024 21:22:48 -0700 Subject: [PATCH 021/255] use max_completion_tokens property --- packages/openai-adapters/package-lock.json | 19 +++++++++++++------ packages/openai-adapters/package.json | 2 +- packages/openai-adapters/src/apis/OpenAI.ts | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 27df8c41a..af8cd0800 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -13,7 +13,7 @@ "@continuedev/config-types": "^1.0.5", "@continuedev/fetch": "^1.0.3", "node-fetch": "^3.3.2", - "openai": "^4.52.5" + "openai": "^4.67.0" }, "devDependencies": { "@types/follow-redirects": "^1.14.4", @@ -3581,9 +3581,9 @@ } }, "node_modules/openai": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.52.5.tgz", - "integrity": "sha512-qqH8GsyPE3z06took/2uWOGqRcrZNlRoPAsihpg4jsl0+2Dfelnw6HDDMep0EI2Cfzw75nn3vHRZehep/IZzxg==", + "version": "4.67.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.67.0.tgz", + "integrity": "sha512-jdsPSEdZbUNVtvEFE/eeL4FjKavyVMJJEdGMZk9vExglqUrblEcFxi3LK2WhskhrYKAU1MgJAI+dK9pDcA5z5w==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -3591,11 +3591,18 @@ "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" + "node-fetch": "^2.6.7" }, "bin": { "openai": "bin/cli" + }, + "peerDependencies": { + "zod": "^3.23.8" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } } }, "node_modules/openai/node_modules/node-fetch": { diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index 48084a364..a0fa4f266 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -16,7 +16,7 @@ "@continuedev/config-types": "^1.0.5", "@continuedev/fetch": "^1.0.3", "node-fetch": "^3.3.2", - "openai": "^4.52.5" + "openai": "^4.67.0" }, "devDependencies": { "@types/follow-redirects": "^1.14.4", diff --git a/packages/openai-adapters/src/apis/OpenAI.ts b/packages/openai-adapters/src/apis/OpenAI.ts index c9e3b1d98..c05cc749c 100644 --- a/packages/openai-adapters/src/apis/OpenAI.ts +++ b/packages/openai-adapters/src/apis/OpenAI.ts @@ -72,6 +72,7 @@ export class OpenAIApi implements BaseLlmApi { prompt: body.prompt, suffix: body.suffix, max_tokens: body.max_tokens, + max_completion_tokens: (body as any).max_completion_tokens, temperature: body.temperature, top_p: body.top_p, frequency_penalty: body.frequency_penalty, From ffa542360868ac2d8726412a59a71f2e5a7458eb Mon Sep 17 00:00:00 2001 From: Lukas Kreussel <65088241+LLukas22@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:59:00 +0200 Subject: [PATCH 022/255] Add `showToast` --- .../continue/IdeProtocolClient.kt | 22 +++++++++++++++++++ .../toolWindow/MessageTypes.kt | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) 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 3b11fbe78..aae6d044d 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 @@ -14,6 +14,9 @@ import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore +import com.intellij.notification.NotificationDisplayType +import com.intellij.notification.NotificationGroup +import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager @@ -191,6 +194,7 @@ class IdeProtocolClient ( private val project: Project ): DumbAware { val diffManager = DiffManager(project) + private val CONTINUE_NOTIFICATION_GROUP = NotificationGroup("Continue", NotificationDisplayType.BALLOON, true) private val ripgrep: String init { @@ -599,6 +603,13 @@ class IdeProtocolClient ( respond(null) // Running commands not yet supported in JetBrains } + "showToast" -> { + val data = data as ArrayList + val toast_type = data[0] + val message = data[1] + showToast(toast_type, message) + respond(null) + } "errorPopup" -> { val data = data as Map val message = data["message"] as String @@ -976,6 +987,17 @@ class IdeProtocolClient ( return virtualFile?.path } + private fun showToast(type: String, content:String) { + val notificationType = when (type.uppercase()) { + "ERROR" -> NotificationType.ERROR + "WARNING" -> NotificationType.WARNING + else -> NotificationType.INFORMATION + } + + CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) + .notify(project); + } + suspend fun showMessage(msg: String) { withContext(Dispatchers.Main) { val statusBar = WindowManager.getInstance().getStatusBar(project) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt index ccd76b570..2e87f0734 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt @@ -50,7 +50,8 @@ class MessageTypes { "pathSep", "getControlPlaneSessionInfo", "logoutOfControlPlane", - "getTerminalContents" + "getTerminalContents", + "showToast" ) val PASS_THROUGH_TO_WEBVIEW = listOf( From 95db505b0e1ec4e6c0090dc9662545f8473d93dc Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 2 Oct 2024 08:14:33 -0700 Subject: [PATCH 023/255] add pag and swp to list of ignored files --- core/indexing/ignore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/indexing/ignore.ts b/core/indexing/ignore.ts index fd111e56b..93ad7b43d 100644 --- a/core/indexing/ignore.ts +++ b/core/indexing/ignore.ts @@ -68,6 +68,8 @@ export const DEFAULT_IGNORE_FILETYPES = [ "*.uasset", "*.pdb", "*.bin", + "*.pag", + "*.swp", // "*.prompt", // can be incredibly confusing for the LLM to have another set of instructions injected into the prompt ]; From ae428dbc98e1bdbcc733dd46335af7e7af1ede2d Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Oct 2024 20:11:37 +0200 Subject: [PATCH 024/255] correct embeddingsProvider schema --- .../customize/model-providers/top-level/azure.md | 4 ++-- .../customize/model-providers/top-level/gemini.md | 12 +++++------- .../customize/model-providers/top-level/mistral.md | 14 ++++++-------- .../customize/model-providers/top-level/openai.md | 12 +++++------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/azure.md b/docs/docs/customize/model-providers/top-level/azure.md index 295b7cdc8..f6e54137f 100644 --- a/docs/docs/customize/model-providers/top-level/azure.md +++ b/docs/docs/customize/model-providers/top-level/azure.md @@ -42,7 +42,7 @@ We recommend configuring **Codestral** as your autocomplete model. We recommend configuring **text-embedding-3-large** as your embeddings model. ```json title="config.json" -"embeddingsProvider": [{ +"embeddingsProvider": { "provider": "azure", "model": "text-embedding-3-large", "apiBase": "", @@ -50,7 +50,7 @@ We recommend configuring **text-embedding-3-large** as your embeddings model. "apiVersion": "", "apiType": "azure", "apiKey": "" -}] +} ``` ## Reranking model diff --git a/docs/docs/customize/model-providers/top-level/gemini.md b/docs/docs/customize/model-providers/top-level/gemini.md index e8b55c2e8..eff3e91ac 100644 --- a/docs/docs/customize/model-providers/top-level/gemini.md +++ b/docs/docs/customize/model-providers/top-level/gemini.md @@ -38,13 +38,11 @@ We recommend configuring **text-embedding-004** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "gemini", - "model": "models/text-embedding-004", - "apiKey": "[API_KEY]" - } - ] + "embeddingsProvider": { + "provider": "gemini", + "model": "models/text-embedding-004", + "apiKey": "[API_KEY]" + } } ``` diff --git a/docs/docs/customize/model-providers/top-level/mistral.md b/docs/docs/customize/model-providers/top-level/mistral.md index 7da0fd6e2..ba9427c9f 100644 --- a/docs/docs/customize/model-providers/top-level/mistral.md +++ b/docs/docs/customize/model-providers/top-level/mistral.md @@ -46,14 +46,12 @@ We recommend configuring **Mistral Embed** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "mistral", - "model": "mistral-embed", - "apiKey": "[API_KEY]", - "apiBase": "https://api.mistral.ai/v1" - } - ] + "embeddingsProvider": { + "provider": "mistral", + "model": "mistral-embed", + "apiKey": "[API_KEY]", + "apiBase": "https://api.mistral.ai/v1" + } } ``` diff --git a/docs/docs/customize/model-providers/top-level/openai.md b/docs/docs/customize/model-providers/top-level/openai.md index 600ec08cd..d594f4f39 100644 --- a/docs/docs/customize/model-providers/top-level/openai.md +++ b/docs/docs/customize/model-providers/top-level/openai.md @@ -38,13 +38,11 @@ We recommend configuring **text-embedding-3-large** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "openai", - "model": "text-embedding-3-large", - "apiKey": "[API_KEY]" - } - ] + "embeddingsProvider": { + "provider": "openai", + "model": "text-embedding-3-large", + "apiKey": "[API_KEY]" + } } ``` From c8482ce9a8b70d11da29dd1d46b7dcb481a1613f Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 2 Oct 2024 12:19:28 -0700 Subject: [PATCH 025/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 55ad62630..843fd69c0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -35,6 +35,7 @@ import javax.swing.plaf.basic.BasicComboBoxUI import kotlin.math.max import java.awt.geom.RoundRectangle2D import java.awt.geom.AffineTransform +import javax.swing.event.ListDataListener const val MAIN_FONT_SIZE = 13 @@ -582,24 +583,9 @@ class ShadowPanel(layout: LayoutManager) : JXPanel(layout) { } class TransparentArrowButtonUI : BasicComboBoxUI() { - override fun createArrowButton() = object : JButton() { - override fun paintComponent(g: Graphics) { - val g2 = g as Graphics2D - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - val size = 6 - val x = (width - size) / 2 - val y = (height - size / 2) / 2 - val triangle = Polygon( - intArrayOf(x, x + size, x + size / 2), - intArrayOf(y, y, (y + size / 1.16).toInt()), - 3 - ) - g2.color = Color.GRAY - g2.fill(triangle) - } - }.apply { - border = EmptyBorder(0, 0, 0, 0) - isOpaque = false + override fun createArrowButton() = JButton().apply { + isVisible = false + preferredSize = Dimension(0, 0) } override fun getInsets(): Insets { @@ -612,13 +598,37 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground comboBox.background = defaultBackground + + // Modify the ComboBoxModel to include the down symbol + val originalModel = comboBox.model + comboBox.model = object : ComboBoxModel { + override fun getSize(): Int = originalModel.size + override fun getElementAt(index: Int): Any? = originalModel.getElementAt(index) + override fun setSelectedItem(anItem: Any?) { + originalModel.selectedItem = anItem + } + + override fun getSelectedItem(): Any? { + val item = originalModel.selectedItem + return if (item is String) "$item ▾" else item + } + + override fun addListDataListener(l: ListDataListener?) { + originalModel.addListDataListener(l) + } + + override fun removeListDataListener(l: ListDataListener?) { + originalModel.removeListDataListener(l) + } + } } + override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - // Do nothing to prevent painting the background } + override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { val renderer = comboBox.renderer val item = comboBox.selectedItem From 29b0b5a3d0087e4491f901557e08315fe1d326b3 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 2 Oct 2024 08:14:33 -0700 Subject: [PATCH 026/255] add pag and swp to list of ignored files --- core/indexing/ignore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/indexing/ignore.ts b/core/indexing/ignore.ts index fd111e56b..93ad7b43d 100644 --- a/core/indexing/ignore.ts +++ b/core/indexing/ignore.ts @@ -68,6 +68,8 @@ export const DEFAULT_IGNORE_FILETYPES = [ "*.uasset", "*.pdb", "*.bin", + "*.pag", + "*.swp", // "*.prompt", // can be incredibly confusing for the LLM to have another set of instructions injected into the prompt ]; From f698d686eddba5ff0a38056b2b3cc04494203134 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Oct 2024 20:11:37 +0200 Subject: [PATCH 027/255] correct embeddingsProvider schema --- .../customize/model-providers/top-level/azure.md | 4 ++-- .../customize/model-providers/top-level/gemini.md | 12 +++++------- .../customize/model-providers/top-level/mistral.md | 14 ++++++-------- .../customize/model-providers/top-level/openai.md | 12 +++++------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/azure.md b/docs/docs/customize/model-providers/top-level/azure.md index 295b7cdc8..f6e54137f 100644 --- a/docs/docs/customize/model-providers/top-level/azure.md +++ b/docs/docs/customize/model-providers/top-level/azure.md @@ -42,7 +42,7 @@ We recommend configuring **Codestral** as your autocomplete model. We recommend configuring **text-embedding-3-large** as your embeddings model. ```json title="config.json" -"embeddingsProvider": [{ +"embeddingsProvider": { "provider": "azure", "model": "text-embedding-3-large", "apiBase": "", @@ -50,7 +50,7 @@ We recommend configuring **text-embedding-3-large** as your embeddings model. "apiVersion": "", "apiType": "azure", "apiKey": "" -}] +} ``` ## Reranking model diff --git a/docs/docs/customize/model-providers/top-level/gemini.md b/docs/docs/customize/model-providers/top-level/gemini.md index e8b55c2e8..eff3e91ac 100644 --- a/docs/docs/customize/model-providers/top-level/gemini.md +++ b/docs/docs/customize/model-providers/top-level/gemini.md @@ -38,13 +38,11 @@ We recommend configuring **text-embedding-004** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "gemini", - "model": "models/text-embedding-004", - "apiKey": "[API_KEY]" - } - ] + "embeddingsProvider": { + "provider": "gemini", + "model": "models/text-embedding-004", + "apiKey": "[API_KEY]" + } } ``` diff --git a/docs/docs/customize/model-providers/top-level/mistral.md b/docs/docs/customize/model-providers/top-level/mistral.md index 7da0fd6e2..ba9427c9f 100644 --- a/docs/docs/customize/model-providers/top-level/mistral.md +++ b/docs/docs/customize/model-providers/top-level/mistral.md @@ -46,14 +46,12 @@ We recommend configuring **Mistral Embed** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "mistral", - "model": "mistral-embed", - "apiKey": "[API_KEY]", - "apiBase": "https://api.mistral.ai/v1" - } - ] + "embeddingsProvider": { + "provider": "mistral", + "model": "mistral-embed", + "apiKey": "[API_KEY]", + "apiBase": "https://api.mistral.ai/v1" + } } ``` diff --git a/docs/docs/customize/model-providers/top-level/openai.md b/docs/docs/customize/model-providers/top-level/openai.md index 600ec08cd..d594f4f39 100644 --- a/docs/docs/customize/model-providers/top-level/openai.md +++ b/docs/docs/customize/model-providers/top-level/openai.md @@ -38,13 +38,11 @@ We recommend configuring **text-embedding-3-large** as your embeddings model. ```json title="config.json" { - "embeddingsProvider": [ - { - "provider": "openai", - "model": "text-embedding-3-large", - "apiKey": "[API_KEY]" - } - ] + "embeddingsProvider": { + "provider": "openai", + "model": "text-embedding-3-large", + "apiKey": "[API_KEY]" + } } ``` From 35b94e710260782d0311ee22a2849203b8965e38 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 10:48:45 -0700 Subject: [PATCH 028/255] feat: improve dropshadow on jb inline edit --- .gitignore | 2 + .../editor/InlineEditAction.kt | 147 ++++++++---------- 2 files changed, 67 insertions(+), 82 deletions(-) diff --git a/.gitignore b/.gitignore index ba5199b56..113c07c43 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,5 @@ Icon? .aider* notes.md + +manual-testing-sandbox/Continue/.idea/vcs.xml \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index f94214c34..c2dab4527 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -24,38 +24,38 @@ import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import org.jdesktop.swingx.JXPanel import org.jdesktop.swingx.JXTextArea -import org.jdesktop.swingx.border.DropShadowBorder import java.awt.* import java.awt.event.* -import java.awt.geom.RoundRectangle2D +import java.awt.geom.Path2D import javax.swing.* import javax.swing.border.EmptyBorder import javax.swing.event.DocumentEvent import javax.swing.event.DocumentListener import javax.swing.plaf.basic.BasicComboBoxUI import kotlin.math.max +import java.awt.geom.RoundRectangle2D +import java.awt.geom.AffineTransform - -const val SHADOW_SIZE = 7 const val MAIN_FONT_SIZE = 13 fun makeTextArea(): JTextArea { - val textArea = CustomTextArea( 2, 40).apply { + val textArea = CustomTextArea(1, 40).apply { lineWrap = true wrapStyleWord = true isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(8) + margin = JBUI.insets(6, 4, 4, 4) // Reduced from 8 to 4 font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) + // Set a preferred size with a taller height + preferredSize = Dimension(400, 75) // Added this line } textArea.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) - return textArea } fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { - val topPanel = ShadowPanel(MigLayout("wrap 1, insets 4 $leftInset 2 2, gap 0!")).apply { + val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset + 4} 8 2, gap 0!")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground // background = defaultBackground @@ -63,7 +63,7 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 0, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { + val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -71,16 +71,9 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) preferredSize = textArea.preferredSize - isOpaque = false setup() - - val shadow = DropShadowBorder() - shadow.shadowColor = JBColor(0xb0b0b0, 0x505050) - shadow.isShowRightShadow = true - shadow.isShowBottomShadow = true - shadow.shadowSize = SHADOW_SIZE - border = shadow } + customPanelRef.set(panel) textArea.addComponentListener(object : ComponentAdapter() { @@ -252,6 +245,19 @@ class InlineEditAction : AnAction(), DumbAware { } class CustomPanel(layout: MigLayout, project: Project, modelTitles: List, comboBoxRef: Ref>, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel(layout) { + private val shadowSize = 5 + private val cornerRadius = 8 + private val shadowColor = Color(0, 0, 0, 40) // Lighter shadow + private val borderColor = Color(128, 128, 128, 128) + private val borderThickness = 1 + private val triangleSize = 6 + private val rightMargin = 3.0 + + init { + isOpaque = false + } + + private val subPanelA: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground @@ -289,9 +295,8 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List comboBoxRef.set(dropdown) - val rightButton = CustomButton("Submit") { onEnter() }.apply { -// background = GetTheme().getHighlight() - background = JBColor(0xe04573e8.toInt(), 0xe04573e8.toInt()) + val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { + background = JBColor(0x999998.toInt(), 0x999998.toInt()) foreground = JBColor(0xffffffff.toInt(), 0xffffffff.toInt()) } @@ -302,7 +307,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List add(rightButton, "align right") } - border = EmptyBorder(4, 8, 4, 8) + border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 add(leftButton, "align left") add(rightPanel, "align right") @@ -311,52 +316,17 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) } - private val subPanelB: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { - // Get the global color scheme and default background color - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground - - val leftButton = CustomButton("Esc to cancel") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) - background = defaultBackground - } - - val dropdown = JComboBox(modelTitles.toTypedArray()).apply { - isEditable = true - background = defaultBackground - foreground = Color(128, 128, 128, 200) - font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) - border = EmptyBorder(2, 4, 2, 4) - isOpaque = false - isEditable = false - cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) - renderer = DefaultListCellRenderer().apply { - horizontalAlignment = SwingConstants.RIGHT - } - - isVisible = false - -// setUI(TransparentArrowButtonUI()) - } - - val progressBar = JProgressBar() - progressBar.isIndeterminate = true - - val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { - isOpaque = false - border = EmptyBorder(0, 0, 0, 0) - add(dropdown, "align right") - add(progressBar, "align right") - } - - - - border = EmptyBorder(4, 8, 4, 8) - add(leftButton, "align left") - add(rightPanel, "align right") + private val subPanelB: JPanel = JPanel(BorderLayout()).apply { isOpaque = false - cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) + val progressBar = JProgressBar().apply { + isIndeterminate = true + } + + add(progressBar, BorderLayout.CENTER) + + // Add right and bottom insets + border = BorderFactory.createEmptyBorder(0, 0, 20, 16) } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -387,6 +357,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List } fun setup() { +// add(subPanelB, "grow, gap 0!") remove(subPanelB) remove(subPanelC) add(subPanelA, "grow, gap 0!") @@ -408,30 +379,41 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List } override fun paintComponent(g: Graphics) { + super.paintComponent(g) + val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - // Draw the rounded border - val borderColor = Color(128, 128, 128, 128) - val borderThickness = 1 - val borderRadius = 8 + val w = width - shadowSize + val h = height - shadowSize + // Create the shape for the tooltip/triangle + val shape = Path2D.Double() + shape.moveTo(borderThickness / 2.0, cornerRadius.toDouble()) + shape.quadTo(borderThickness / 2.0, borderThickness / 2.0, cornerRadius.toDouble(), borderThickness / 2.0) + shape.lineTo(w - cornerRadius.toDouble() - rightMargin, borderThickness / 2.0) + shape.quadTo(w - borderThickness / 2.0 - rightMargin, borderThickness / 2.0, w - borderThickness / 2.0 - rightMargin, cornerRadius.toDouble()) + shape.lineTo(w - borderThickness / 2.0 - rightMargin, h - cornerRadius - triangleSize.toDouble()) + shape.quadTo(w - borderThickness / 2.0 - rightMargin, h - triangleSize.toDouble(), w - cornerRadius.toDouble() - rightMargin, h - triangleSize.toDouble()) + shape.lineTo(triangleSize.toDouble(), h - triangleSize.toDouble()) + shape.lineTo(borderThickness / 2.0, h.toDouble()) + shape.lineTo(borderThickness / 2.0, cornerRadius.toDouble()) + + // Draw shadow + g2.color = shadowColor + g2.fill(shape.createTransformedShape(AffineTransform.getTranslateInstance(shadowSize.toDouble(), shadowSize.toDouble()))) + + // Draw main shape + g2.color = background + g2.fill(shape) + + // Draw border g2.color = borderColor g2.stroke = BasicStroke(borderThickness.toFloat()) - g2.drawRoundRect( - borderThickness / 2, - borderThickness / 2, - width - borderThickness - SHADOW_SIZE + 1, - height - borderThickness - SHADOW_SIZE + 1, - borderRadius, - borderRadius - ) - - super.paintComponent(g) + g2.draw(shape) } } - class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { private var isHovered = false @@ -488,7 +470,7 @@ class CustomTextArea(rows: Int, columns: Int) : JXTextArea("") { if (text.isEmpty()) { g.color = Color(128, 128, 128, 255) g.font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) - g.drawString("Enter instructions to edit highlighted code", 8, 20) + g.drawString("Enter instructions...", 3, 20) } super.paintComponent(g) @@ -543,4 +525,5 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { val defaultBackground = globalScheme.defaultBackground comboBox.background = defaultBackground } -} \ No newline at end of file +} + From c78079d72a658e103971fa505c82abfe5c7b9743 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 14:35:05 -0700 Subject: [PATCH 029/255] update shadow --- .../editor/InlineEditAction.kt | 78 +++++++++++-------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index c2dab4527..7de540cdc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -244,7 +244,16 @@ class InlineEditAction : AnAction(), DumbAware { } } -class CustomPanel(layout: MigLayout, project: Project, modelTitles: List, comboBoxRef: Ref>, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel(layout) { +class CustomPanel( + layout: MigLayout, + project: Project, + modelTitles: List, + comboBoxRef: Ref>, + private val onEnter: () -> Unit, + private val onCancel: () -> Unit, + private val onAccept: () -> Unit, + private val onReject: () -> Unit +) : JPanel(layout) { private val shadowSize = 5 private val cornerRadius = 8 private val shadowColor = Color(0, 0, 0, 40) // Lighter shadow @@ -252,24 +261,28 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List private val borderThickness = 1 private val triangleSize = 6 private val rightMargin = 3.0 + private val closeButton: JComponent = createCloseButton() init { isOpaque = false + add(closeButton, "pos 100% 0 -3 3, w 20!, h 20!") } + private fun createCloseButton(): JComponent { + return CustomButton("X") { onCancel() }.apply { + foreground = Color(128, 128, 128, 200) + background = Color(0, 0, 0, 0) + font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 12) + border = EmptyBorder(2, 6, 2, 6) + } + } private val subPanelA: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground - - val leftButton = CustomButton("Esc to cancel") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) - background = defaultBackground - } - val continueSettingsService = service() - val dropdown = JComboBox(modelTitles.toTypedArray()).apply { + setUI(TransparentArrowButtonUI()) isEditable = true background = defaultBackground foreground = Color(128, 128, 128, 200) @@ -279,7 +292,7 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List isEditable = false cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) renderer = DefaultListCellRenderer().apply { - horizontalAlignment = SwingConstants.RIGHT + horizontalAlignment = SwingConstants.LEFT } selectedIndex = continueSettingsService.continueState.lastSelectedInlineEditModel?.let { val index = modelTitles.indexOf(it) @@ -289,8 +302,6 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List addActionListener { continueSettingsService.continueState.lastSelectedInlineEditModel = selectedItem as String } - -// setUI(TransparentArrowButtonUI()) } comboBoxRef.set(dropdown) @@ -309,8 +320,8 @@ class CustomPanel(layout: MigLayout, project: Project, modelTitles: List border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 - add(leftButton, "align left") - add(rightPanel, "align right") + add(dropdown, "align left") + add(rightPanel, "align right, split 2") isOpaque = false cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR) @@ -496,34 +507,37 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - val size = 6 + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE) + + val size = 4 // Smaller size val x = (width - size) / 2 - val y = (height - size / 2) / 2 - val triangle = Polygon( - intArrayOf(x, x + size, x + size / 2), - intArrayOf(y, y, (y + size / 1.16).toInt()), - 3 - ) - g2.color = Color.GRAY - g2.fill(triangle) + val y = (height - size) / 2 + + val path = Path2D.Double() + path.moveTo(x.toDouble(), y.toDouble()) + path.lineTo((x + size).toDouble(), y.toDouble()) + path.lineTo((x + size / 2.0), (y + size).toDouble()) + path.closePath() + + g2.color = Color(128, 128, 128, 200) // Light gray, semi-transparent + g2.fill(path) + } + + override fun getPreferredSize(): Dimension { + return Dimension(12, 12) // Smaller button size } }.apply { - border = EmptyBorder(0, 0, 0, 0) -// background = Color(0, 0, 0, 0) isOpaque = false - } - - override fun getInsets(): Insets { - return JBUI.insets(0, 0, 0, 0) + isFocusable = false + isBorderPainted = false + isContentAreaFilled = false } override fun installUI(c: JComponent?) { super.installUI(c) - comboBox.border = EmptyBorder(0, 0, 0, 0) + comboBox.border = EmptyBorder(2, 0, 2, 0) comboBox.isOpaque = false - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground - comboBox.background = defaultBackground + comboBox.background = Color(0, 0, 0, 0) // Fully transparent background } } From f87de6641351558a9fd281c9957a37a4a11c8429 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 17:04:53 -0700 Subject: [PATCH 030/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 130 ++++++++++++------ 1 file changed, 91 insertions(+), 39 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 7de540cdc..0020d260f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -45,7 +45,7 @@ fun makeTextArea(): JTextArea { isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(6, 4, 4, 4) // Reduced from 8 to 4 + margin = JBUI.insets(6, 4, 0, 4) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) // Set a preferred size with a taller height preferredSize = Dimension(400, 75) // Added this line @@ -55,7 +55,7 @@ fun makeTextArea(): JTextArea { } fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { - val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset + 4} 8 2, gap 0!")).apply { + val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset} 2 2, gap 0!")).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground // background = defaultBackground @@ -63,7 +63,7 @@ fun makePanel(project: Project, customPanelRef: Ref, textArea: JTex isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject).apply { + val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject, textArea).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -197,6 +197,15 @@ fun openInlineEdit(project: Project?, editor: Editor) { } }) + // Listen for key typed events after diff streaming is finished + textArea.addKeyListener(object : KeyAdapter() { + override fun keyTyped(e: KeyEvent) { + if (customPanelRef.get().isFinished) { + customPanelRef.get().setup() + } + } + }) + // Listen for changes to textarea line count textArea.document.addDocumentListener(object : DocumentListener { private var lastNumLines: Int = 0 @@ -252,7 +261,8 @@ class CustomPanel( private val onEnter: () -> Unit, private val onCancel: () -> Unit, private val onAccept: () -> Unit, - private val onReject: () -> Unit + private val onReject: () -> Unit, + private val textArea: JTextArea ) : JPanel(layout) { private val shadowSize = 5 private val cornerRadius = 8 @@ -262,18 +272,31 @@ class CustomPanel( private val triangleSize = 6 private val rightMargin = 3.0 private val closeButton: JComponent = createCloseButton() + private val originalTextColor: Color = textArea.foreground + private val greyTextColor: Color = Color(128, 128, 128, 200) + public var isFinished = false init { isOpaque = false - add(closeButton, "pos 100% 0 -3 3, w 20!, h 20!") + add(closeButton, "pos 100%-25 0 -3 3, w 20!, h 20!") } private fun createCloseButton(): JComponent { return CustomButton("X") { onCancel() }.apply { - foreground = Color(128, 128, 128, 200) + foreground = Color(128, 128, 128, 128) background = Color(0, 0, 0, 0) - font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 12) + font = UIUtil.getFontWithFallback("Arial", Font.BOLD, 10) border = EmptyBorder(2, 6, 2, 6) + toolTipText = "`esc` to cancel" + + addMouseListener(object : MouseAdapter() { + override fun mouseEntered(e: MouseEvent) { + foreground = Color(128, 128, 128, 255) + } + override fun mouseExited(e: MouseEvent) { + foreground = Color(128, 128, 128, 128) + } + }) } } @@ -307,8 +330,9 @@ class CustomPanel( comboBoxRef.set(dropdown) val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { - background = JBColor(0x999998.toInt(), 0x999998.toInt()) - foreground = JBColor(0xffffffff.toInt(), 0xffffffff.toInt()) + background = JBColor(0x33999998.toInt(), 0x33999998.toInt()) + foreground = Color.WHITE + border = EmptyBorder(2, 6, 2, 6) } val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -318,7 +342,7 @@ class CustomPanel( add(rightButton, "align right") } - border = EmptyBorder(0, 0, 18, 12) // Increased bottom padding from 4 to 8 + border = EmptyBorder(0, 0, 20, 16) add(dropdown, "align left") add(rightPanel, "align right, split 2") @@ -341,17 +365,20 @@ class CustomPanel( } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { - val leftLabel = JLabel("Enter follow-up instructions").apply { + val leftLabel = JLabel("Type to re-prompt").apply { foreground = Color(128, 128, 128, 200) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) + border = EmptyBorder(0, 4, 0, 0) } - val leftButton = CustomButton("${getAltKeyLabel()}⇧N") { onReject() }.apply { - background = Color(255, 0, 0, 64) + val leftButton = CustomButton("Reject (${getAltKeyLabel()}⇧N)") { onReject() }.apply { + background = Color(239, 68, 68) // text-red-500 + foreground = Color.WHITE } - val rightButton = CustomButton("${getAltKeyLabel()}⇧Y") { onAccept() }.apply { - background = Color(0, 255, 0, 64) + val rightButton = CustomButton("Accept (${getAltKeyLabel()}⇧Y)") { onAccept() }.apply { + background = Color(34, 197, 94) // text-green-500 + foreground = Color.WHITE } val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { @@ -363,15 +390,19 @@ class CustomPanel( add(leftLabel, "align left") add(rightPanel, "align right") - border = EmptyBorder(4, 8, 4, 8) + // Add right and bottom insets + border = BorderFactory.createEmptyBorder(0, 0, 20, 16) isOpaque = false } fun setup() { -// add(subPanelB, "grow, gap 0!") remove(subPanelB) remove(subPanelC) add(subPanelA, "grow, gap 0!") + isFinished = false + revalidate() + repaint() + textArea.foreground = originalTextColor } fun enter() { @@ -387,6 +418,8 @@ class CustomPanel( add(subPanelC, "grow, gap 0!") revalidate() repaint() + isFinished = true + textArea.foreground = greyTextColor } override fun paintComponent(g: Graphics) { @@ -507,37 +540,56 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE) - - val size = 4 // Smaller size + val size = 6 val x = (width - size) / 2 - val y = (height - size) / 2 - - val path = Path2D.Double() - path.moveTo(x.toDouble(), y.toDouble()) - path.lineTo((x + size).toDouble(), y.toDouble()) - path.lineTo((x + size / 2.0), (y + size).toDouble()) - path.closePath() - - g2.color = Color(128, 128, 128, 200) // Light gray, semi-transparent - g2.fill(path) - } - - override fun getPreferredSize(): Dimension { - return Dimension(12, 12) // Smaller button size + val y = (height - size / 2) / 2 + val triangle = Polygon( + intArrayOf(x, x + size, x + size / 2), + intArrayOf(y, y, (y + size / 1.16).toInt()), + 3 + ) + g2.color = Color.GRAY + g2.fill(triangle) } }.apply { + border = EmptyBorder(0, 0, 0, 0) isOpaque = false - isFocusable = false - isBorderPainted = false - isContentAreaFilled = false + } + + override fun getInsets(): Insets { + return JBUI.insets(0, 6, 0, 0) } override fun installUI(c: JComponent?) { super.installUI(c) - comboBox.border = EmptyBorder(2, 0, 2, 0) comboBox.isOpaque = false - comboBox.background = Color(0, 0, 0, 0) // Fully transparent background + val globalScheme = EditorColorsManager.getInstance().globalScheme + val defaultBackground = globalScheme.defaultBackground + comboBox.background = defaultBackground } + + override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + + // Do nothing to prevent painting the background +} + +override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + val renderer = comboBox.renderer + val item = comboBox.selectedItem + + if (item != null) { + val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) + c.font = comboBox.font + c.foreground = comboBox.foreground + c.background = comboBox.background + + if (c is JComponent) { + c.isOpaque = false + } + + val currentValuePane = currentValuePane + currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) + } +} } From 753b0b03431a89c5d784641f8210d2a352bbdb63 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 1 Oct 2024 17:16:32 -0700 Subject: [PATCH 031/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 146 ++++++++++++------ 1 file changed, 96 insertions(+), 50 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 0020d260f..55ad62630 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -45,25 +45,43 @@ fun makeTextArea(): JTextArea { isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(6, 4, 0, 4) + margin = JBUI.insets(6, 4, 6, 4) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) - // Set a preferred size with a taller height - preferredSize = Dimension(400, 75) // Added this line + preferredSize = Dimension(400, 75) } textArea.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, true) return textArea } -fun makePanel(project: Project, customPanelRef: Ref, textArea: JTextArea, inlayRef: Ref, comboBoxRef: Ref>, leftInset: Int, modelTitles: List, onEnter: () -> Unit, onCancel: () -> Unit, onAccept: () -> Unit, onReject: () -> Unit): JPanel { +fun makePanel( + project: Project, + customPanelRef: Ref, + textArea: JTextArea, + inlayRef: Ref, + comboBoxRef: Ref>, + leftInset: Int, + modelTitles: List, + onEnter: () -> Unit, + onCancel: () -> Unit, + onAccept: () -> Unit, + onReject: () -> Unit +): JPanel { val topPanel = ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset} 2 2, gap 0!")).apply { - val globalScheme = EditorColorsManager.getInstance().globalScheme - val defaultBackground = globalScheme.defaultBackground -// background = defaultBackground - background = JBColor(0x20888888.toInt(), 0x20888888.toInt()) + background = JBColor(0x20888888.toInt(), 0x20888888.toInt()) isOpaque = false } - val panel = CustomPanel(MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), project, modelTitles, comboBoxRef, onEnter, onCancel, onAccept, onReject, textArea).apply { + val panel = CustomPanel( + MigLayout("wrap 1, insets 4 10 0 2, gap 0!, fillx"), + project, + modelTitles, + comboBoxRef, + onEnter, + onCancel, + onAccept, + onReject, + textArea + ).apply { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground background = defaultBackground @@ -92,9 +110,9 @@ fun openInlineEdit(project: Project?, editor: Editor) { if (project == null) return // Don't open in terminal - if (EditorUtils().isTerminal(editor)) { - return - } + if (EditorUtils().isTerminal(editor)) { + return + } val manager = EditorComponentInlaysManager.from(editor) @@ -135,7 +153,8 @@ fun openInlineEdit(project: Project?, editor: Editor) { val lineEnd = editor.document.getLineEndOffset(indentationLineNum) val text = editor.document.getText(TextRange(lineStart, lineEnd)) val indentation = text.takeWhile { it == ' ' }.length - val charWidth = editor.contentComponent.getFontMetrics(editor.colorsScheme.getFont(EditorFontType.PLAIN)).charWidth(' ') + val charWidth = + editor.contentComponent.getFontMetrics(editor.colorsScheme.getFont(EditorFontType.PLAIN)).charWidth(' ') val leftInset = indentation * charWidth * 2 / 3 val inlayRef = Ref() @@ -162,16 +181,17 @@ fun openInlineEdit(project: Project?, editor: Editor) { diffStreamHandler.run(textArea.text, prefix, highlighted, suffix, comboBoxRef.get().selectedItem as String) } - val panel = makePanel(project, customPanelRef, textArea, inlayRef, comboBoxRef, leftInset, modelTitles, {onEnter()}, { - diffStreamService.reject(editor) - selectionModel.setSelection(start, end) - }, { - diffStreamService.accept(editor) - inlayRef.get().dispose() - }, { - diffStreamService.reject(editor) - inlayRef.get().dispose() - }) + val panel = + makePanel(project, customPanelRef, textArea, inlayRef, comboBoxRef, leftInset, modelTitles, { onEnter() }, { + diffStreamService.reject(editor) + selectionModel.setSelection(start, end) + }, { + diffStreamService.accept(editor) + inlayRef.get().dispose() + }, { + diffStreamService.reject(editor) + inlayRef.get().dispose() + }) val inlay = manager.insertAfter(lineNumber, panel) panel.revalidate() inlayRef.set(inlay) @@ -216,6 +236,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { viewport?.dispatchEvent(ComponentEvent(viewport, ComponentEvent.COMPONENT_RESIZED)) } } + override fun insertUpdate(e: DocumentEvent?) { updateSize() } @@ -293,6 +314,7 @@ class CustomPanel( override fun mouseEntered(e: MouseEvent) { foreground = Color(128, 128, 128, 255) } + override fun mouseExited(e: MouseEvent) { foreground = Color(128, 128, 128, 128) } @@ -329,7 +351,7 @@ class CustomPanel( comboBoxRef.set(dropdown) - val rightButton = CustomButton("↵ Enter") { onEnter() }.apply { + val rightButton = CustomButton("⏎ Enter") { onEnter() }.apply { background = JBColor(0x33999998.toInt(), 0x33999998.toInt()) foreground = Color.WHITE border = EmptyBorder(2, 6, 2, 6) @@ -359,14 +381,12 @@ class CustomPanel( } add(progressBar, BorderLayout.CENTER) - - // Add right and bottom insets border = BorderFactory.createEmptyBorder(0, 0, 20, 16) } private val subPanelC: JPanel = JPanel(MigLayout("insets 0, fillx")).apply { val leftLabel = JLabel("Type to re-prompt").apply { - foreground = Color(128, 128, 128, 200) + foreground = Color(156, 163, 175) // text-gray-400 font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) border = EmptyBorder(0, 4, 0, 0) } @@ -390,7 +410,6 @@ class CustomPanel( add(leftLabel, "align left") add(rightPanel, "align right") - // Add right and bottom insets border = BorderFactory.createEmptyBorder(0, 0, 20, 16) isOpaque = false } @@ -436,16 +455,33 @@ class CustomPanel( shape.moveTo(borderThickness / 2.0, cornerRadius.toDouble()) shape.quadTo(borderThickness / 2.0, borderThickness / 2.0, cornerRadius.toDouble(), borderThickness / 2.0) shape.lineTo(w - cornerRadius.toDouble() - rightMargin, borderThickness / 2.0) - shape.quadTo(w - borderThickness / 2.0 - rightMargin, borderThickness / 2.0, w - borderThickness / 2.0 - rightMargin, cornerRadius.toDouble()) + shape.quadTo( + w - borderThickness / 2.0 - rightMargin, + borderThickness / 2.0, + w - borderThickness / 2.0 - rightMargin, + cornerRadius.toDouble() + ) shape.lineTo(w - borderThickness / 2.0 - rightMargin, h - cornerRadius - triangleSize.toDouble()) - shape.quadTo(w - borderThickness / 2.0 - rightMargin, h - triangleSize.toDouble(), w - cornerRadius.toDouble() - rightMargin, h - triangleSize.toDouble()) + shape.quadTo( + w - borderThickness / 2.0 - rightMargin, + h - triangleSize.toDouble(), + w - cornerRadius.toDouble() - rightMargin, + h - triangleSize.toDouble() + ) shape.lineTo(triangleSize.toDouble(), h - triangleSize.toDouble()) shape.lineTo(borderThickness / 2.0, h.toDouble()) shape.lineTo(borderThickness / 2.0, cornerRadius.toDouble()) // Draw shadow g2.color = shadowColor - g2.fill(shape.createTransformedShape(AffineTransform.getTranslateInstance(shadowSize.toDouble(), shadowSize.toDouble()))) + g2.fill( + shape.createTransformedShape( + AffineTransform.getTranslateInstance( + shadowSize.toDouble(), + shadowSize.toDouble() + ) + ) + ) // Draw main shape g2.color = background @@ -484,13 +520,21 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11) border = EmptyBorder(2, 4, 2, 4) } + override fun paintComponent(g: Graphics) { val g2 = g as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) val cornerRadius = 8 val rect = Rectangle(0, 0, width, height) - val roundRect = RoundRectangle2D.Float(rect.x.toFloat(), rect.y.toFloat(), rect.width.toFloat(), rect.height.toFloat(), cornerRadius.toFloat(), cornerRadius.toFloat()) + val roundRect = RoundRectangle2D.Float( + rect.x.toFloat(), + rect.y.toFloat(), + rect.width.toFloat(), + rect.height.toFloat(), + cornerRadius.toFloat(), + cornerRadius.toFloat() + ) if (isHovered) { g2.color = background.brighter() } else { @@ -498,8 +542,10 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) { } g2.fill(roundRect) g2.color = foreground - g2.drawString(text, (width / 2 - g.fontMetrics.stringWidth(text) / 2).toFloat(), - (height / 2 + g.fontMetrics.ascent / 2).toFloat()) + g2.drawString( + text, (width / 2 - g.fontMetrics.stringWidth(text) / 2).toFloat(), + (height / 2 + g.fontMetrics.ascent / 2).toFloat() + ) } } @@ -570,26 +616,26 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - // Do nothing to prevent painting the background -} + // Do nothing to prevent painting the background + } -override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - val renderer = comboBox.renderer - val item = comboBox.selectedItem + override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { + val renderer = comboBox.renderer + val item = comboBox.selectedItem - if (item != null) { - val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) - c.font = comboBox.font - c.foreground = comboBox.foreground - c.background = comboBox.background + if (item != null) { + val c = renderer.getListCellRendererComponent(listBox, item, -1, false, false) + c.font = comboBox.font + c.foreground = Color(156, 163, 175) // text-gray-400 + c.background = comboBox.background - if (c is JComponent) { - c.isOpaque = false + if (c is JComponent) { + c.isOpaque = false + } + + val currentValuePane = currentValuePane + currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) } - - val currentValuePane = currentValuePane - currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, true) } } -} From 1c8bc6ea5177470265974263081368adc056c934 Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 2 Oct 2024 12:19:28 -0700 Subject: [PATCH 032/255] Update InlineEditAction.kt --- .../editor/InlineEditAction.kt | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 55ad62630..843fd69c0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -35,6 +35,7 @@ import javax.swing.plaf.basic.BasicComboBoxUI import kotlin.math.max import java.awt.geom.RoundRectangle2D import java.awt.geom.AffineTransform +import javax.swing.event.ListDataListener const val MAIN_FONT_SIZE = 13 @@ -582,24 +583,9 @@ class ShadowPanel(layout: LayoutManager) : JXPanel(layout) { } class TransparentArrowButtonUI : BasicComboBoxUI() { - override fun createArrowButton() = object : JButton() { - override fun paintComponent(g: Graphics) { - val g2 = g as Graphics2D - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) - val size = 6 - val x = (width - size) / 2 - val y = (height - size / 2) / 2 - val triangle = Polygon( - intArrayOf(x, x + size, x + size / 2), - intArrayOf(y, y, (y + size / 1.16).toInt()), - 3 - ) - g2.color = Color.GRAY - g2.fill(triangle) - } - }.apply { - border = EmptyBorder(0, 0, 0, 0) - isOpaque = false + override fun createArrowButton() = JButton().apply { + isVisible = false + preferredSize = Dimension(0, 0) } override fun getInsets(): Insets { @@ -612,13 +598,37 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { val globalScheme = EditorColorsManager.getInstance().globalScheme val defaultBackground = globalScheme.defaultBackground comboBox.background = defaultBackground + + // Modify the ComboBoxModel to include the down symbol + val originalModel = comboBox.model + comboBox.model = object : ComboBoxModel { + override fun getSize(): Int = originalModel.size + override fun getElementAt(index: Int): Any? = originalModel.getElementAt(index) + override fun setSelectedItem(anItem: Any?) { + originalModel.selectedItem = anItem + } + + override fun getSelectedItem(): Any? { + val item = originalModel.selectedItem + return if (item is String) "$item ▾" else item + } + + override fun addListDataListener(l: ListDataListener?) { + originalModel.addListDataListener(l) + } + + override fun removeListDataListener(l: ListDataListener?) { + originalModel.removeListDataListener(l) + } + } } + override fun paintCurrentValueBackground(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { - // Do nothing to prevent painting the background } + override fun paintCurrentValue(g: Graphics, bounds: Rectangle, hasFocus: Boolean) { val renderer = comboBox.renderer val item = comboBox.selectedItem From ccfd649cd264beb0584beb9baf40b79667fa6ef1 Mon Sep 17 00:00:00 2001 From: Kevin Abestilla Date: Tue, 1 Oct 2024 00:43:00 +0200 Subject: [PATCH 033/255] Update introduction.md --- docs/docs/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md index 9f5bbe9be..b3f6d87d6 100644 --- a/docs/docs/introduction.md +++ b/docs/docs/introduction.md @@ -20,6 +20,6 @@ keywords: **Continue is the leading open-source AI code assistant inside of [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension)** - [Chat](chat/how-to-use-it.md) to understand and iterate on code in the sidebar -- [Autocomplete](autocomplete/how-to-use-it.md) to recieve inline code suggestions as you type +- [Autocomplete](autocomplete/how-to-use-it.md) to receive inline code suggestions as you type - [Edit](edit/how-to-use-it.md) to modify code without leaving your current file - [Actions](actions/how-to-use-it.md) to establish shortcuts for common use cases From 2a186a011503d7de40ebc6c1813d501b61addf8d Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 2 Oct 2024 13:18:13 -0700 Subject: [PATCH 034/255] remove `showMessage` in JB --- .vscode/settings.json | 8 +- .../continue/CoreMessenger.kt | 49 ++-- .../continue/IdeProtocolClient.kt | 220 ++++++++++-------- .../toolWindow/MessageTypes.kt | 1 - 4 files changed, 156 insertions(+), 122 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 41b357765..d07234a75 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,9 +17,9 @@ "**/binary": true, "binary/": false, "**/core/vendor/**": true, - "**/gui/dist": true + "**/gui/dist": true, + "**/extensions/vscode/gui/**": true, + "**/extensions/vscode/out/**": true }, - "eslint.workingDirectories": [ - "./core" - ] + "eslint.workingDirectories": ["./core"] } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index f47f6f138..9f8a943f5 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -15,7 +15,13 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.attribute.PosixFilePermission -class CoreMessenger(private val project: Project, esbuildPath: String, continueCorePath: String, ideProtocolClient: IdeProtocolClient, private val coroutineScope: CoroutineScope) { +class CoreMessenger( + private val project: Project, + esbuildPath: String, + continueCorePath: String, + ideProtocolClient: IdeProtocolClient, + private val coroutineScope: CoroutineScope +) { private var writer: Writer? = null private var reader: BufferedReader? = null private var process: Process? = null @@ -42,11 +48,13 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC fun request(messageType: String, data: Any?, messageId: String?, onResponse: (Any?) -> Unit) { val id = messageId ?: uuid() - val message = gson.toJson(mapOf( + val message = gson.toJson( + mapOf( "messageId" to id, "messageType" to messageType, "data" to data - )) + ) + ) responseListeners[id] = onResponse write(message) } @@ -60,11 +68,13 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC // IDE listeners if (MessageTypes.ideMessageTypes.contains(messageType)) { ideProtocolClient.handleMessage(json) { data -> - val message = gson.toJson(mapOf( + val message = gson.toJson( + mapOf( "messageId" to messageId, "messageType" to messageType, "data" to data - )) + ) + ) write(message) }; } @@ -76,11 +86,13 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC if (messageType == "getDefaultModelTitle") { val continueSettingsService = service() val defaultModelTitle = continueSettingsService.continueState.lastSelectedInlineEditModel; - val message = gson.toJson(mapOf( + val message = gson.toJson( + mapOf( "messageId" to messageId, "messageType" to messageType, "data" to defaultModelTitle - )) + ) + ) write(message) } val continuePluginService = project.service() @@ -94,7 +106,8 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC val done = (data as Map)["done"] if (done == true) { responseListeners.remove(messageId) - } else {} + } else { + } } else { responseListeners.remove(messageId) } @@ -106,10 +119,10 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC val osName = System.getProperty("os.name").toLowerCase() if (osName.contains("mac") || osName.contains("darwin")) { ProcessBuilder( - "xattr", - "-dr", - "com.apple.quarantine", - destination + "xattr", + "-dr", + "com.apple.quarantine", + destination ).start() setFilePermissions(destination, "rwxr-xr-x") } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("mac")) { @@ -177,7 +190,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC // Start the subprocess val processBuilder = ProcessBuilder(continueCorePath) - .directory(File(continueCorePath).parentFile) + .directory(File(continueCorePath).parentFile) process = processBuilder.start() val outputStream = process!!.outputStream @@ -200,14 +213,16 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC println("Core process exited with output: $err") CoroutineScope(Dispatchers.Main).launch { - ideProtocolClient.showMessage("Core process exited with output: $err") + ideProtocolClient.showToast("error", "Core process exited with output: $err") } // Log the cause of the failure val telemetryService = service() - telemetryService.capture("jetbrains_core_exit", mapOf( - "error" to err - )) + telemetryService.capture( + "jetbrains_core_exit", mapOf( + "error" to err + ) + ) // Clean up all resources writer?.close() 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 aae6d044d..aa1988504 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 @@ -157,8 +157,8 @@ private fun readConfigJson(): Map { val configJsonPath = getConfigJsonPath() val reader = FileReader(configJsonPath) val config: Map = gson.fromJson( - reader, - object : TypeToken>() {}.type + reader, + object : TypeToken>() {}.type ) reader.close() return config @@ -170,9 +170,13 @@ class AsyncFileSaveListener : AsyncFileListener { constructor(ideProtocolClient: IdeProtocolClient) { this.ideProtocolClient = ideProtocolClient } + override fun prepareChange(events: MutableList): AsyncFileListener.ChangeApplier? { 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")) { + 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") + ) { return object : AsyncFileListener.ChangeApplier { override fun afterVfsChange() { val config = readConfigJson() @@ -186,13 +190,13 @@ class AsyncFileSaveListener : AsyncFileListener { } -class IdeProtocolClient ( +class IdeProtocolClient( private val continuePluginService: ContinuePluginService, private val textSelectionStrategy: TextSelectionStrategy, private val coroutineScope: CoroutineScope, private val workspacePath: String?, private val project: Project -): DumbAware { +) : DumbAware { val diffManager = DiffManager(project) private val CONTINUE_NOTIFICATION_GROUP = NotificationGroup("Continue", NotificationDisplayType.BALLOON, true) private val ripgrep: String @@ -206,7 +210,8 @@ class IdeProtocolClient ( }) val myPluginId = "com.github.continuedev.continueintellijextension" - val pluginDescriptor = PluginManager.getPlugin(PluginId.getId(myPluginId)) ?: throw Exception("Plugin not found") + val pluginDescriptor = + PluginManager.getPlugin(PluginId.getId(myPluginId)) ?: throw Exception("Plugin not found") val pluginPath = pluginDescriptor.pluginPath val osName = System.getProperty("os.name").toLowerCase() @@ -217,7 +222,8 @@ class IdeProtocolClient ( else -> "linux" } - ripgrep = Paths.get(pluginPath.toString(), "ripgrep", "bin", "rg" + (if (os == "win32") ".exe" else "")).toString() + ripgrep = + Paths.get(pluginPath.toString(), "ripgrep", "bin", "rg" + (if (os == "win32") ".exe" else "")).toString() } private fun send(messageType: String, data: Any?, messageId: String? = null) { @@ -228,8 +234,8 @@ class IdeProtocolClient ( fun handleMessage(text: String, respond: (Any?) -> Unit) { coroutineScope.launch(Dispatchers.IO) { val parsedMessage: Map = Gson().fromJson( - text, - object : TypeToken>() {}.type + text, + object : TypeToken>() {}.type ) val messageType = parsedMessage["messageType"] as? String if (messageType == null) { @@ -243,16 +249,20 @@ class IdeProtocolClient ( "uniqueId" -> respond( mapOf("uniqueId" to uniqueId()) ) + "getIdeSettings" -> { val settings = - ServiceManager.getService(ContinueExtensionSettings::class.java) - respond(mapOf( - "remoteConfigServerUrl" to settings.continueState.remoteConfigServerUrl, - "remoteConfigSyncPeriod" to settings.continueState.remoteConfigSyncPeriod, - "userToken" to settings.continueState.userToken, - "enableControlServerBeta" to settings.continueState.enableContinueTeamsBeta - )) + ServiceManager.getService(ContinueExtensionSettings::class.java) + respond( + mapOf( + "remoteConfigServerUrl" to settings.continueState.remoteConfigServerUrl, + "remoteConfigSyncPeriod" to settings.continueState.remoteConfigSyncPeriod, + "userToken" to settings.continueState.userToken, + "enableControlServerBeta" to settings.continueState.enableContinueTeamsBeta + ) + ) } + "getControlPlaneSessionInfo" -> { val silent = (data as? Map)?.get("silent") as? Boolean ?: false @@ -265,12 +275,15 @@ class IdeProtocolClient ( respond(null) } } + "logoutOfControlPlane" -> { val authService = service() authService.signOut() - ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC).handleUpdatedSessionInfo(null) + ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC) + .handleUpdatedSessionInfo(null) respond(null) } + "getIdeInfo" -> { val applicationInfo = ApplicationInfo.getInstance() val ideName: String = applicationInfo.fullApplicationName @@ -287,13 +300,15 @@ class IdeProtocolClient ( val plugin = PluginManagerCore.getPlugin(PluginId.getId(pluginId)) val extensionVersion = plugin?.version ?: "Unknown" - respond(mapOf( - "ideType" to "jetbrains", - "name" to ideName, - "version" to ideVersion, - "remoteName" to remoteName, - "extensionVersion" to extensionVersion - )) + respond( + mapOf( + "ideType" to "jetbrains", + "name" to ideName, + "version" to ideVersion, + "remoteName" to remoteName, + "extensionVersion" to extensionVersion + ) + ) } "getUniqueId" -> { @@ -311,9 +326,9 @@ class IdeProtocolClient ( "showDiff" -> { val data = data as Map diffManager.showDiff( - data["filepath"] as String, - data["newContents"] as String, - (data["stepIndex"] as Double).toInt() + data["filepath"] as String, + data["newContents"] as String, + (data["stepIndex"] as Double).toInt() ) respond(null) } @@ -337,7 +352,8 @@ class IdeProtocolClient ( val endLine = end["line"] as Int val endCharacter = end["character"] as Int - val firstLine = fullContents.split("\n")[startLine].slice(startCharacter until fullContents.split("\n")[startLine].length) + val firstLine = + fullContents.split("\n")[startLine].slice(startCharacter until fullContents.split("\n")[startLine].length) val lastLine = fullContents.split("\n")[endLine].slice(0 until endCharacter) val between = fullContents.split("\n").slice(startLine + 1 until endLine).joinToString("\n") @@ -395,6 +411,7 @@ class IdeProtocolClient ( saveFile((data as Map)["filepath"] ?: throw Exception("No filepath provided")) respond(null) } + "showVirtualFile" -> { val data = data as Map showVirtualFile( @@ -405,15 +422,11 @@ class IdeProtocolClient ( } "connected" -> {} - "showMessage" -> { - showMessage(data as String) - respond(null) - } "setFileOpen" -> { val data = data as Map setFileOpen( - data["filepath"] as String, - data["open"] as Boolean + data["filepath"] as String, + data["open"] as Boolean ) respond(null) } @@ -424,14 +437,14 @@ class IdeProtocolClient ( val startLine = (data["startLine"] as Double).toInt() val endLine = (data["endLine"] as Double).toInt() highlightCode( - RangeInFile( - filepath, - Range( - Position(startLine, 0), - Position(endLine, 0) - ) - ), - data["color"] as String? + RangeInFile( + filepath, + Range( + Position(startLine, 0), + Position(endLine, 0) + ) + ), + data["color"] as String? ) respond(null) } @@ -442,7 +455,7 @@ class IdeProtocolClient ( val json = gson.toJson(data["rangeInFile"]) val type = object : TypeToken() {}.type val rangeInFile = - gson.fromJson(json, type) + gson.fromJson(json, type) highlightCode(rangeInFile, data["color"] as String) respond(null) } @@ -460,6 +473,7 @@ class IdeProtocolClient ( }.toMap() respond(pathToLastModified) } + "listDir" -> { val data = data as Map val dir = data["dir"] as String @@ -469,6 +483,7 @@ class IdeProtocolClient ( } ?: emptyList() respond(files) } + "getGitRootPath" -> { val data = data as Map val directory = data["dir"] as String @@ -482,12 +497,14 @@ class IdeProtocolClient ( respond(output) } + "getBranch" -> { // Get the current branch name val dir = (data as Map)["dir"] as String val branch = getBranch(dir) respond(branch) } + "getRepoName" -> { // Get the current repository name val dir = (data as Map)["dir"] as String @@ -526,6 +543,7 @@ class IdeProtocolClient ( respond(output.toString()); } + "getProblems" -> { // Get currently active editor var editor: Editor? = null @@ -574,53 +592,58 @@ class IdeProtocolClient ( // } // respond(problems) } + "getConfigJsUrl" -> { // Calculate a data URL for the config.js file val configJsPath = getConfigJsPath() val configJsContents = File(configJsPath).readText() - val configJsDataUrl = "data:text/javascript;base64,${Base64.getEncoder().encodeToString(configJsContents.toByteArray())}" + val configJsDataUrl = "data:text/javascript;base64,${ + Base64.getEncoder().encodeToString(configJsContents.toByteArray()) + }" respond(configJsDataUrl) } + "writeFile" -> { val msg = data as Map; val file = File(msg["path"]) file.writeText(msg["contents"] as String) respond(null); } + "fileExists" -> { val msg = data as Map; val file = File(msg["filepath"]) respond(file.exists()) } + "getContinueDir" -> { respond(getContinueGlobalPath()) } + "openFile" -> { setFileOpen((data as Map)["path"] as String) respond(null) } + "runCommand" -> { respond(null) // Running commands not yet supported in JetBrains } + "showToast" -> { val data = data as ArrayList - val toast_type = data[0] + val toast_type = data[0] val message = data[1] showToast(toast_type, message) respond(null) } - "errorPopup" -> { - val data = data as Map - val message = data["message"] as String - showMessage(message) - respond(null) - } "listFolders" -> { val workspacePath = workspacePath ?: return@launch val workspaceDir = File(workspacePath) - val folders = workspaceDir.listFiles { file -> file.isDirectory }?.map { file -> file.absolutePath } ?: emptyList() + val folders = + workspaceDir.listFiles { file -> file.isDirectory }?.map { file -> file.absolutePath } + ?: emptyList() respond(folders) } @@ -634,16 +657,19 @@ class IdeProtocolClient ( val openFiles = visibleFiles() respond(openFiles) } + "getCurrentFile" -> { val currentFile = currentFile() respond(currentFile) } + "getPinnedFiles" -> { ApplicationManager.getApplication().invokeLater { val pinnedFiles = pinnedFiles() respond(pinnedFiles) } } + "insertAtCursor" -> { val msg = data as Map; val text = msg["text"] as String @@ -660,8 +686,10 @@ class IdeProtocolClient ( } } } + "applyToFile" -> { } + "getGitHubAuthToken" -> { val continueSettingsService = service() val ghAuthToken = continueSettingsService.continueState.ghAuthToken; @@ -674,26 +702,30 @@ class IdeProtocolClient ( respond(ghAuthToken) } } + "setGitHubAuthToken" -> { val continueSettingsService = service() val data = data as Map continueSettingsService.continueState.ghAuthToken = data["token"] respond(null) } + "openUrl" -> { val url = data as String java.awt.Desktop.getDesktop().browse(java.net.URI(url)) respond(null) } + "pathSep" -> { respond(File.separator) } + else -> { println("Unknown messageType: $messageType") } } } catch (error: Exception) { - showMessage("Error handling message of type $messageType: $error") + showToast("error", "Error handling message of type $messageType: $error") } } } @@ -707,8 +739,8 @@ class IdeProtocolClient ( val configJsonPath = getConfigJsonPath() val reader = FileReader(configJsonPath) val config: MutableMap = gson.fromJson( - reader, - object : TypeToken>() {}.type + reader, + object : TypeToken>() {}.type ) reader.close() @@ -829,7 +861,8 @@ class IdeProtocolClient ( val result = ApplicationManager.getApplication().runReadAction { // Get the editor instance for the currently active editor window val editor = FileEditorManager.getInstance(project).selectedTextEditor ?: return@runReadAction null - val virtualFile = editor.let { FileDocumentManager.getInstance().getFile(it.document) } ?: return@runReadAction null + val virtualFile = + editor.let { FileDocumentManager.getInstance().getFile(it.document) } ?: return@runReadAction null // Get the selection range and content val selectionModel: SelectionModel = editor.selectionModel @@ -849,10 +882,12 @@ class IdeProtocolClient ( val startChar = startOffset - document.getLineStartOffset(startLine) val endChar = endOffset - document.getLineStartOffset(endLine) - return@runReadAction RangeInFileWithContents(virtualFile.path, Range( + return@runReadAction RangeInFileWithContents( + virtualFile.path, Range( Position(startLine, startChar), Position(endLine, endChar) - ), selectedText) + ), selectedText + ) } return result @@ -867,8 +902,8 @@ class IdeProtocolClient ( // )) continuePluginService.sendToWebview( -"highlightedCode", - mapOf( + "highlightedCode", + mapOf( "rangeInFileWithContents" to rif, "edit" to edit ) @@ -888,29 +923,30 @@ class IdeProtocolClient ( } private val DEFAULT_IGNORE_DIRS = listOf( - ".git", - ".vscode", - ".idea", - ".vs", - "venv", - ".venv", - "env", - ".env", - "node_modules", - "dist", - "build", - "target", - "out", - "bin", - ".pytest_cache", - ".vscode-test", - ".continue", - "__pycache__", - "site-packages", - ".gradle", - ".cache", - "gems", + ".git", + ".vscode", + ".idea", + ".vs", + "venv", + ".venv", + "env", + ".env", + "node_modules", + "dist", + "build", + "target", + "out", + "bin", + ".pytest_cache", + ".vscode-test", + ".continue", + "__pycache__", + "site-packages", + ".gradle", + ".cache", + "gems", ) + private fun shouldIgnoreDirectory(name: String): Boolean { val components = File(name).path.split(File.separator) return DEFAULT_IGNORE_DIRS.any { dir -> @@ -987,7 +1023,7 @@ class IdeProtocolClient ( return virtualFile?.path } - private fun showToast(type: String, content:String) { + fun showToast(type: String, content: String) { val notificationType = when (type.uppercase()) { "ERROR" -> NotificationType.ERROR "WARNING" -> NotificationType.WARNING @@ -995,25 +1031,9 @@ class IdeProtocolClient ( } CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) - .notify(project); + .notify(project); } -suspend fun showMessage(msg: String) { - withContext(Dispatchers.Main) { - val statusBar = WindowManager.getInstance().getStatusBar(project) - - JBPopupFactory.getInstance() - .createHtmlTextBalloonBuilder(msg, MessageType.INFO, null) - .setFadeoutTime(10000) - .setHideOnAction(false) - .createBalloon() - .show( - RelativePoint.getSouthEastOf(statusBar.component), - Balloon.Position.atRight - ) - } -} - fun highlightCode(rangeInFile: RangeInFile, color: String?) { val file = LocalFileSystem.getInstance().findFileByPath(rangeInFile.filepath) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt index 2e87f0734..7abc69a16 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/MessageTypes.kt @@ -38,7 +38,6 @@ class MessageTypes { "getTags", "getIdeInfo", "getIdeSettings", - "errorPopup", "getRepoName", "listDir", "getGitRootPath", From e92e052b16fb91173aa4dc85d4e80fa569b8e60a Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 2 Oct 2024 14:25:14 -0700 Subject: [PATCH 035/255] fix: show error is GH sign in failed in vscode --- extensions/vscode/src/VsCodeIde.ts | 1 + .../OnboardingCard/components/QuickStartSubmitButton.tsx | 8 +++++++- gui/src/pages/More/MoreHelpRow.tsx | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index ed7139636..e2fa97c9d 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -87,6 +87,7 @@ class VsCodeIde implements IDE { const session = await vscode.authentication.getSession("github", [], { silent: true, }); + if (session) { this.authToken = session.accessToken; return this.authToken; diff --git a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx index fb8b21c0a..7ffd07ba2 100644 --- a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx +++ b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx @@ -40,8 +40,14 @@ function QuickstartSubmitButton() { const result = await ideMessenger.request("getGitHubAuthToken", { force: true, }); - if (result.status === "success") { + + if (result.status === "success" && typeof result.content === "string") { onComplete(); + } else { + ideMessenger.post("showToast", [ + "error", + "Failed to sign up for Continue free trial through GitHub", + ]); } } diff --git a/gui/src/pages/More/MoreHelpRow.tsx b/gui/src/pages/More/MoreHelpRow.tsx index 70a2bbfc0..8a0412dab 100644 --- a/gui/src/pages/More/MoreHelpRow.tsx +++ b/gui/src/pages/More/MoreHelpRow.tsx @@ -12,7 +12,7 @@ function MoreHelpRow({ title, description, onClick, Icon }: MoreHelpRowProps) { className="flex items-center gap-2 justify-between cursor-pointer" onClick={onClick} > -
+

{title}

{description}
From 5cb3f35fc62e7da3f11edbf3c2071bc9ed836dfc Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Thu, 3 Oct 2024 15:57:07 +0900 Subject: [PATCH 036/255] =?UTF-8?q?=F0=9F=90=9B=20chore:=20update=20genera?= =?UTF-8?q?tion.d.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit paramater -> parameter --- .../@xenova/transformers/types/utils/generation.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/vendor/modules/@xenova/transformers/types/utils/generation.d.ts b/core/vendor/modules/@xenova/transformers/types/utils/generation.d.ts index 1688d6a6d..49ea01a51 100644 --- a/core/vendor/modules/@xenova/transformers/types/utils/generation.d.ts +++ b/core/vendor/modules/@xenova/transformers/types/utils/generation.d.ts @@ -320,7 +320,7 @@ export class NoBadWordsLogitsProcessor extends LogitsProcessor { * @property {number} [eta_cutoff=0.0] Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between 0 and 1, a token is only considered if it is greater than either `eta_cutoff` or `sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits)))`. The latter term is intuitively the expected next token probability, scaled by `sqrt(eta_cutoff)`. In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://arxiv.org/abs/2210.15191) for more details. * @property {number} [diversity_penalty=0.0] This value is subtracted from a beam's score if it generates a token same as any beam from other group at a particular time. Note that `diversity_penalty` is only effective if `group beam search` is enabled. * @property {number} [repetition_penalty=1.0] The parameter for repetition penalty. 1.0 means no penalty. See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details. - * @property {number} [encoder_repetition_penalty=1.0] The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty. + * @property {number} [encoder_repetition_penalty=1.0] The parameter for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty. * @property {number} [length_penalty=1.0] Exponential penalty to the length that is used with beam-based generation. It is applied as an exponent to the sequence length, which in turn is used to divide the score of the sequence. Since the score is the log likelihood of the sequence (i.e. negative), `length_penalty` > 0.0 promotes longer sequences, while `length_penalty` < 0.0 encourages shorter sequences. * @property {number} [no_repeat_ngram_size=0] If set to int > 0, all ngrams of that size can only occur once. * @property {number[][]} [bad_words_ids=null] List of token ids that are not allowed to be generated. In order to get the token ids of the words that should not appear in the generated text, use `(await tokenizer(bad_words, {add_prefix_space: true, add_special_tokens: false})).input_ids`. @@ -488,7 +488,7 @@ export type GenerationConfigType = { */ repetition_penalty?: number; /** - * The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty. + * The parameter for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty. */ encoder_repetition_penalty?: number; /** @@ -590,4 +590,4 @@ export type GenerationConfigType = { }; import { Tensor } from './tensor.js'; export {}; -//# sourceMappingURL=generation.d.ts.map \ No newline at end of file +//# sourceMappingURL=generation.d.ts.map From 28f2a5a874032e97e1aea8805e72e94db55a93f7 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Oct 2024 09:25:25 -0700 Subject: [PATCH 037/255] show profile switcher even when using free trial model --- gui/src/components/Footer.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gui/src/components/Footer.tsx b/gui/src/components/Footer.tsx index 8809848d4..671b000fb 100644 --- a/gui/src/components/Footer.tsx +++ b/gui/src/components/Footer.tsx @@ -2,16 +2,16 @@ import { Cog6ToothIcon, EllipsisHorizontalCircleIcon, } from "@heroicons/react/24/outline"; +import { useContext } from "react"; +import { useSelector } from "react-redux"; +import { useNavigate } from "react-router-dom"; +import { IdeMessengerContext } from "../context/IdeMessenger"; +import { defaultModelSelector } from "../redux/selectors/modelSelectors"; +import { RootState } from "../redux/store"; import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial"; +import ButtonWithTooltip from "./ButtonWithTooltip"; import FreeTrialProgressBar from "./loaders/FreeTrialProgressBar"; import ProfileSwitcher from "./ProfileSwitcher"; -import ButtonWithTooltip from "./ButtonWithTooltip"; -import { useSelector } from "react-redux"; -import { defaultModelSelector } from "../redux/selectors/modelSelectors"; -import { useNavigate } from "react-router-dom"; -import { useContext } from "react"; -import { IdeMessengerContext } from "../context/IdeMessenger"; -import { RootState } from "../redux/store"; function Footer() { const navigate = useNavigate(); @@ -43,13 +43,12 @@ function Footer() { return (
- {tooltipPortalDiv && - ReactDOM.createPortal( - - Configure a model above in order to continue - , - tooltipPortalDiv, - )} + + + Configure a model above in order to continue + ); } @@ -85,14 +79,9 @@ function FreeTrialProgressBar({ completed, total }: FreeTrialProgressBarProps) { /> - - {tooltipPortalDiv && - ReactDOM.createPortal( - - {`Click to use your own API key or local LLM (required after ${FREE_TRIAL_LIMIT_REQUESTS} inputs)`} - , - tooltipPortalDiv, - )} + + {`Click to use your own API key or local LLM (required after ${FREE_TRIAL_LIMIT_REQUESTS} inputs)`} + ); } diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 71920013a..da255e86d 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -25,6 +25,7 @@ import { isMetaEquivalentKeyPressed, } from "../../util"; import ModelSelect from "../modelSelection/ModelSelect"; +import { ToolTip } from "../gui/Tooltip"; const StyledDiv = styled.div<{ isHidden: boolean }>` padding: 4px 0; @@ -121,7 +122,14 @@ function InputToolbar(props: InputToolbarProps) { )} - + + + + Add context (files, docs, urls, etc.) + @@ -143,11 +151,12 @@ function InputToolbar(props: InputToolbarProps) { }) } > - - {getMetaKeyLabel()}⏎ Use @codebase + + @codebase - - @codebase + + Submit with the codebase as context ({getMetaKeyLabel()}⏎) + )} diff --git a/gui/src/pages/More/KeyboardShortcuts.tsx b/gui/src/pages/More/KeyboardShortcuts.tsx index 673593cf2..7b1697fb9 100644 --- a/gui/src/pages/More/KeyboardShortcuts.tsx +++ b/gui/src/pages/More/KeyboardShortcuts.tsx @@ -1,4 +1,3 @@ -import ReactDOM from "react-dom"; import styled from "styled-components"; import { defaultBorderRadius, @@ -42,20 +41,15 @@ const keyToName: { [key: string]: string } = { }; function KeyDiv({ text }: { text: string }) { - const tooltipPortalDiv = document.getElementById("tooltip-portal-div"); - return ( <> {text} - {tooltipPortalDiv && - ReactDOM.createPortal( - - {keyToName[text]} - , - tooltipPortalDiv, - )} + + + {keyToName[text]} + ); } From 2a46176c62ab7fe30d7d928de50c38f94b6b8e09 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Sun, 6 Oct 2024 16:54:35 +0200 Subject: [PATCH 077/255] Handle whitespace in / and @ commands --- gui/src/components/mainInput/TipTapEditor.tsx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 984da4e07..3ebc70726 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -16,7 +16,7 @@ import { modelSupportsImages } from "core/llm/autodetect"; import { getBasename, getRelativePath } from "core/util"; import { debounce } from "lodash"; import { usePostHog } from "posthog-js/react"; -import { useContext, useEffect, useRef, useState } from "react"; +import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import styled from "styled-components"; import { v4 } from "uuid"; @@ -817,6 +817,20 @@ function TipTapEditor(props: TipTapEditorProps) { const [activeKey, setActiveKey] = useState(null); + const insertCharacterWithWhitespace = useCallback( + (char: string) => { + const text = editor.getText(); + if (!text.endsWith(char)) { + if (text.length > 0 && !text.endsWith(" ")) { + editor.commands.insertContent(` ${char}`); + } else { + editor.commands.insertContent(char); + } + } + }, + [editor], + ); + return ( { @@ -877,16 +891,8 @@ function TipTapEditor(props: TipTapEditorProps) {
- { - // Save current session - saveSession(); - await loadSession(session.sessionId); - navigate("/"); - }} - > -
- {editing ? ( +
{ + // Save current session + saveSession(); + await loadSession(session.sessionId); + navigate("/"); + }} + > +
+ {editing ? ( +
handleKeyUp(e)} onBlur={() => setEditing(false)} /> - ) : ( - JSON.stringify(session.title).slice(1, -1) - )} -
+
+ ) : ( + + {JSON.stringify(session.title).slice(1, -1)} + + )} -
- {lastPartOfPath(session.workspaceDirectory || "")} +
+ {lastPartOfPath(session.workspaceDirectory || "")} {!hovered && ( - + {date.toLocaleString("en-US", { year: "2-digit", month: "2-digit", @@ -172,31 +158,29 @@ function TableRow({ )}
- +
{hovered && ( - { - setEditing(true); - }} - > - - - )} - - {hovered && ( - { - deleteSession(session.sessionId); - onDelete(session.sessionId); - }} - > - - +
+ { + e.stopPropagation(); + setEditing(true); + }} + > + + + { + deleteSession(session.sessionId); + onDelete(session.sessionId); + }} + > + + +
)}
@@ -208,10 +192,7 @@ function lastPartOfPath(path: string): string { return path.split(sep).pop() || path; } -function History() { - useNavigationListener(); - const navigate = useNavigate(); - +export function History() { const [sessions, setSessions] = useState([]); const [filteredAndSortedSessions, setFilteredAndSortedSessions] = useState< SessionInfo[] @@ -227,9 +208,6 @@ function History() { const searchInputRef = React.useRef(null); - const stickyHistoryHeaderRef = React.useRef(null); - const [headerHeight, setHeaderHeight] = useState(0); - const dispatch = useDispatch(); const { getHistory } = useHistory(dispatch); @@ -297,138 +275,90 @@ function History() { ); }, [sessions, searchTerm, minisearch]); - useEffect(() => { - setHeaderHeight(stickyHistoryHeaderRef.current?.clientHeight || 100); - }, [stickyHistoryHeaderRef.current]); - const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 24); const lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7); const lastMonth = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30); const earlier = new Date(0); return ( -
-
-
+ + setSearchTerm(e.target.value)} + /> + { + if (searchInputRef.current.value === "") { + searchInputRef.current.value = "*"; + setSearchTerm("*"); + } else { + searchInputRef.current.value = ""; + setSearchTerm(""); + } }} > - navigate("/")} - className="inline-block ml-4 cursor-pointer" - /> -

History

+ {searchTerm === "" ? "Show All" : "Clear"} +
+
+ + {filteredAndSortedSessions.length === 0 && ( +
+ No past sessions found. To start a new session, either click the "+" + button or use the keyboard shortcut: Option + Command + N
- {/* {workspacePaths && workspacePaths.length > 0 && ( - setFilteringByWorkspace((prev) => !prev)} - title={`Show only sessions from ${lastPartOfPath( - workspacePaths[workspacePaths.length - 1] - )}/`} - /> - )} */} -
+ )} -
- - setSearchTerm(e.target.value)} - /> - { - if (searchInputRef.current.value === "") { - searchInputRef.current.value = "*"; - setSearchTerm("*"); - } else { - searchInputRef.current.value = ""; - setSearchTerm(""); - } - }} - > - {searchTerm === "" ? "Show All" : "Clear"} - - - - {filteredAndSortedSessions.length === 0 && ( -
- No past sessions found. To start a new session, either click the "+" - button or use the keyboard shortcut: Option + Command + N -
- )} - - - - {filteredAndSortedSessions.map((session, index) => { - const prevDate = - index > 0 - ? parseDate(filteredAndSortedSessions[index - 1].dateCreated) - : earlier; - const date = parseDate(session.dateCreated); - return ( - - {index === 0 && date > yesterday && ( - - Today - - )} - {date < yesterday && - date > lastWeek && - prevDate > yesterday && ( - - This Week - - )} - {date < lastWeek && - date > lastMonth && - prevDate > lastWeek && ( - - This Month - - )} - {date < lastMonth && prevDate > lastMonth && ( - - Older - +
+ + {filteredAndSortedSessions.map((session, index) => { + const prevDate = + index > 0 + ? parseDate(filteredAndSortedSessions[index - 1].dateCreated) + : earlier; + const date = parseDate(session.dateCreated); + return ( + + {index === 0 && date > yesterday && ( + Today + )} + {date < yesterday && + date > lastWeek && + prevDate > yesterday && ( + This Week )} + {date < lastWeek && date > lastMonth && prevDate > lastWeek && ( + This Month + )} + {date < lastMonth && prevDate > lastMonth && ( + Older + )} - - deleteSessionInUI(session.sessionId)} - > - - - ); - })} - -
-
- - All session data is saved in ~/.continue/sessions - -
+ + deleteSessionInUI(session.sessionId)} + > + + + ); + })} + + +
+ + All session data is saved in ~/.continue/sessions +
); } - -export default History; diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui/Chat.tsx similarity index 92% rename from gui/src/pages/gui.tsx rename to gui/src/pages/gui/Chat.tsx index 156c0b3b2..243657462 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -24,43 +24,43 @@ import { lightGray, vscBackground, vscForeground, -} from "../components"; -import { ChatScrollAnchor } from "../components/ChatScrollAnchor"; -import StepContainer from "../components/gui/StepContainer"; -import TimelineItem from "../components/gui/TimelineItem"; -import ContinueInputBox from "../components/mainInput/ContinueInputBox"; -import { defaultInputModifiers } from "../components/mainInput/inputModifiers"; -import { TutorialCard } from "../components/mainInput/TutorialCard"; +} from "../../components"; +import { ChatScrollAnchor } from "../../components/ChatScrollAnchor"; +import StepContainer from "../../components/gui/StepContainer"; +import TimelineItem from "../../components/gui/TimelineItem"; +import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; +import { defaultInputModifiers } from "../../components/mainInput/inputModifiers"; +import { TutorialCard } from "../../components/mainInput/TutorialCard"; import { OnboardingCard, useOnboardingCard, -} from "../components/OnboardingCard"; -import { IdeMessengerContext } from "../context/IdeMessenger"; -import useChatHandler from "../hooks/useChatHandler"; -import useHistory from "../hooks/useHistory"; -import { useTutorialCard } from "../hooks/useTutorialCard"; -import { useWebviewListener } from "../hooks/useWebviewListener"; -import { defaultModelSelector } from "../redux/selectors/modelSelectors"; +} from "../../components/OnboardingCard"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import useChatHandler from "../../hooks/useChatHandler"; +import useHistory from "../../hooks/useHistory"; +import { useTutorialCard } from "../../hooks/useTutorialCard"; +import { useWebviewListener } from "../../hooks/useWebviewListener"; +import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; import { clearLastResponse, deleteMessage, newSession, setInactive, -} from "../redux/slices/stateSlice"; +} from "../../redux/slices/stateSlice"; import { setDialogEntryOn, setDialogMessage, setShowDialog, -} from "../redux/slices/uiStateSlice"; -import { RootState } from "../redux/store"; +} from "../../redux/slices/uiStateSlice"; +import { RootState } from "../../redux/store"; import { getFontSize, getMetaKeyLabel, isJetBrains, isMetaEquivalentKeyPressed, -} from "../util"; -import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial"; -import { getLocalStorage, setLocalStorage } from "../util/localStorage"; +} from "../../util"; +import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial"; +import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; const TopGuiDiv = styled.div<{ showScrollbar?: boolean; @@ -144,7 +144,7 @@ function fallbackRender({ error, resetErrorBoundary }: any) { ); } -function GUI() { +export function Chat() { const posthog = usePostHog(); const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); @@ -528,5 +528,3 @@ function GUI() { ); } - -export default GUI; diff --git a/gui/src/pages/gui/index.tsx b/gui/src/pages/gui/index.tsx new file mode 100644 index 000000000..53e184027 --- /dev/null +++ b/gui/src/pages/gui/index.tsx @@ -0,0 +1,22 @@ +import { Chat } from "./Chat"; +import { History } from "../../components/History"; +import styled from "styled-components"; +import { vscSidebarBorder } from "../../components"; + +export const Aside = styled.aside` + border-right: 1px solid ${vscSidebarBorder}; +`; + +export default function GUI() { + return ( +
+ + +
+ +
+
+ ); +} diff --git a/gui/src/pages/history/HistoryHeader.tsx b/gui/src/pages/history/HistoryHeader.tsx new file mode 100644 index 000000000..4a8d4688c --- /dev/null +++ b/gui/src/pages/history/HistoryHeader.tsx @@ -0,0 +1,37 @@ +import { useNavigate } from "react-router-dom"; +import { lightGray, vscBackground } from "../../components"; +import { useNavigationListener } from "../../hooks/useNavigationListener"; +import { ArrowLeftIcon } from "@heroicons/react/24/outline"; + +export const HistoryHeader = () => { + useNavigationListener(); + const navigate = useNavigate(); + + return ( +
+
+ navigate("/")} + className="inline-block ml-4 cursor-pointer" + /> +

History

+
+ {/* {workspacePaths && workspacePaths.length > 0 && ( + setFilteringByWorkspace((prev) => !prev)} + title={`Show only sessions from ${lastPartOfPath( + workspacePaths[workspacePaths.length - 1] + )}/`} + /> + )} */} +
+ ); +}; diff --git a/gui/src/pages/history/index.tsx b/gui/src/pages/history/index.tsx new file mode 100644 index 000000000..6d31c60bc --- /dev/null +++ b/gui/src/pages/history/index.tsx @@ -0,0 +1,12 @@ +import { History } from "../../components/History"; +import { getFontSize } from "../../util"; +import { HistoryHeader } from "./HistoryHeader"; + +export default function HistoryPage() { + return ( +
+ + +
+ ); +} diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index a20bdecf7..63e0c2810 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -10,12 +10,15 @@ module.exports = { theme: { // Note that these breakpoints are primarily optimized for the input toolbar screens: { - xxs: "170px", // Smallest width for Primary Sidebar in VS Code + "2xs": "170px", // Smallest width for Primary Sidebar in VS Code xs: "250px", // Avg default sidebar width in VS Code sm: "330px", md: "460px", lg: "590px", xl: "720px", + "2xl": "860px", + "3xl": "1000px", + "4xl": "1140px", }, extend: { animation: { From 3aee3ca08cf621d4b2b52b04d185110c79221a8a Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 08:32:06 -0700 Subject: [PATCH 095/255] cwd option in subprocess --- core/context/providers/GitLabMergeRequestContextProvider.ts | 6 ++---- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/util/filesystem.ts | 2 +- core/util/messageIde.ts | 4 ++-- core/util/reverseMessageIde.ts | 2 +- extensions/vscode/src/VsCodeIde.ts | 4 ++-- extensions/vscode/src/extension/VsCodeMessenger.ts | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/context/providers/GitLabMergeRequestContextProvider.ts b/core/context/providers/GitLabMergeRequestContextProvider.ts index 802d5f2ab..631de479c 100644 --- a/core/context/providers/GitLabMergeRequestContextProvider.ts +++ b/core/context/providers/GitLabMergeRequestContextProvider.ts @@ -64,9 +64,7 @@ const getSubprocess = async (extras: ContextProviderExtras) => { const workingDir = await extras.ide.getWorkspaceDirs().then(trimFirstElement); return (command: string) => - extras.ide - .subprocess(`cd ${workingDir}; ${command}`) - .then(trimFirstElement); + extras.ide.subprocess(command, workingDir).then(trimFirstElement); }; class GitLabMergeRequestContextProvider extends BaseContextProvider { @@ -269,7 +267,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { if (ex instanceof AxiosError) { if (ex.response) { const errorMessage = ex.response?.data - ? ex.response.data.message ?? JSON.stringify(ex.response?.data) + ? (ex.response.data.message ?? JSON.stringify(ex.response?.data)) : `${ex.response.status}: ${ex.response.statusText}`; content += `GitLab Error: ${errorMessage}`; } else { diff --git a/core/index.d.ts b/core/index.d.ts index c1c8ddc04..7c47ff5e5 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -500,7 +500,7 @@ export interface IDE { getCurrentFile(): Promise; getPinnedFiles(): Promise; getSearchResults(query: string): Promise; - subprocess(command: string): Promise<[string, string]>; + subprocess(command: string, cwd?: string): Promise<[string, string]>; getProblems(filepath?: string | undefined): Promise; getBranch(dir: string): Promise; getTags(artifactId: string): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 43cacb733..6e5907612 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { openFile: [{ path: string }, void]; runCommand: [{ command: string }, void]; getSearchResults: [{ query: string }, string]; - subprocess: [{ command: string }, [string, string]]; + subprocess: [{ command: string; cwd?: string }, [string, string]]; saveFile: [{ filepath: string }, void]; fileExists: [{ filepath: string }, boolean]; readFile: [{ filepath: string }, string]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index fe64a6fbc..6d8dbd1b3 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -237,7 +237,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - async subprocess(command: string): Promise<[string, string]> { + async subprocess(command: string, cwd?: string): Promise<[string, string]> { return ["", ""]; } } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 7f00a9cc1..98594ce1a 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -193,8 +193,8 @@ export class MessageIde implements IDE { return this.request("getProblems", { filepath }); } - subprocess(command: string): Promise<[string, string]> { - return this.request("subprocess", { command }); + subprocess(command: string, cwd?: string): Promise<[string, string]> { + return this.request("subprocess", { command, cwd }); } async getBranch(dir: string): Promise { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index 2a8a3e406..039c7f5cb 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -182,7 +182,7 @@ export class ReverseMessageIde { }); this.on("subprocess", (data) => { - return this.ide.subprocess(data.command); + return this.ide.subprocess(data.command, data.cwd); }); this.on("getBranch", (data) => { diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index e2fa97c9d..3ae31f922 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -512,9 +512,9 @@ class VsCodeIde implements IDE { }); } - async subprocess(command: string): Promise<[string, string]> { + async subprocess(command: string, cwd?: string): Promise<[string, string]> { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { + exec(command, { cwd }, (error, stdout, stderr) => { if (error) { console.warn(error); reject(stderr); diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index c0b62fdbc..e7445afb3 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -325,7 +325,7 @@ export class VsCodeMessenger { return ide.getSearchResults(msg.data.query); }); this.onWebviewOrCore("subprocess", async (msg) => { - return ide.subprocess(msg.data.command); + return ide.subprocess(msg.data.command, msg.data.cwd); }); this.onWebviewOrCore("getProblems", async (msg) => { return ide.getProblems(msg.data.filepath); From cacabc89a5d169e0db816c15288fbab4ba7d6321 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 8 Oct 2024 17:42:38 +0200 Subject: [PATCH 096/255] Refresh history on last session change --- gui/src/components/History.tsx | 4 +- gui/src/components/Layout.tsx | 66 ++++++++++++++------------ gui/src/context/LastSessionContext.tsx | 30 ++++++++++++ gui/src/hooks/useHistory.tsx | 14 ++++-- 4 files changed, 78 insertions(+), 36 deletions(-) create mode 100644 gui/src/context/LastSessionContext.tsx diff --git a/gui/src/components/History.tsx b/gui/src/components/History.tsx index 937064304..6112251fc 100644 --- a/gui/src/components/History.tsx +++ b/gui/src/components/History.tsx @@ -209,7 +209,7 @@ export function History() { const searchInputRef = React.useRef(null); const dispatch = useDispatch(); - const { getHistory } = useHistory(dispatch); + const { getHistory, lastSessionId } = useHistory(dispatch); const [minisearch, setMinisearch] = useState< MiniSearch<{ title: string; sessionId: string }> @@ -234,7 +234,7 @@ export function History() { ); }; fetchSessions(); - }, []); + }, [lastSessionId]); useEffect(() => { // When searchTerm is empty only show sessions from the current workspace diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 259de2e25..0714d32b4 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -13,6 +13,7 @@ import Footer from "./Footer"; import { updateApplyState, setShowDialog } from "../redux/slices/uiStateSlice"; import TextDialog from "./dialogs"; import { useOnboardingCard, isNewUserOnboarding } from "./OnboardingCard"; +import { LastSessionProvider } from "../context/LastSessionContext"; const LayoutTopDiv = styled(CustomScrollbarDiv)` height: 100%; @@ -174,39 +175,42 @@ const Layout = () => { }, [location]); return ( - -
- { - dispatch(setShowDialog(false)); + + +
{ - dispatch(setShowDialog(false)); - }} - message={dialogMessage} - /> + > + { + dispatch(setShowDialog(false)); + }} + onClose={() => { + dispatch(setShowDialog(false)); + }} + message={dialogMessage} + /> - - - - - -
- -
-
- + + + + + + +
+ +
+
+ + ); }; diff --git a/gui/src/context/LastSessionContext.tsx b/gui/src/context/LastSessionContext.tsx new file mode 100644 index 000000000..f931d9212 --- /dev/null +++ b/gui/src/context/LastSessionContext.tsx @@ -0,0 +1,30 @@ +import React, { createContext, useState, useEffect } from "react"; + +export const LastSessionContext = createContext<{ + lastSessionId: string | undefined; + setLastSessionId: (id: string | undefined) => void; +}>({ + lastSessionId: undefined, + setLastSessionId: () => {}, +}); + +export const LastSessionProvider: React.FC<{ + children: React.ReactNode; +}> = ({ children }) => { + const [lastSessionId, setLastSessionId] = useState(); + + useEffect(() => { + const storedId = localStorage.getItem("lastSessionId"); + if (storedId) { + setLastSessionId(storedId); + } + }, []); + + return ( + + {children} + + ); +}; + +export const useLastSessionContext = () => React.useContext(LastSessionContext); diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index 8e5fe22a2..2e00b3707 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -3,13 +3,14 @@ import { PersistedSessionInfo, SessionInfo } from "core"; import { llmCanGenerateInParallel } from "core/llm/autodetect"; import { stripImages } from "core/llm/images"; -import { useContext } from "react"; +import { useCallback, useContext, useEffect } from "react"; import { useSelector } from "react-redux"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; import { newSession } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; +import { useLastSessionContext } from "../context/LastSessionContext"; function truncateText(text: string, maxLength: number) { if (text.length > maxLength) { @@ -25,6 +26,12 @@ function useHistory(dispatch: Dispatch) { (store: RootState) => store.state.config.disableSessionTitles, ); const ideMessenger = useContext(IdeMessengerContext); + const { lastSessionId, setLastSessionId } = useLastSessionContext(); + + const updateLastSessionId = useCallback((sessionId: string) => { + setLastSessionId(sessionId); + setLocalStorage("lastSessionId", sessionId); + }, []); async function getHistory( offset?: number, @@ -85,7 +92,7 @@ function useHistory(dispatch: Dispatch) { sessionId: stateCopy.sessionId, workspaceDirectory: window.workspacePaths?.[0] || "", }; - setLocalStorage("lastSessionId", stateCopy.sessionId); + updateLastSessionId(stateCopy.sessionId); return await ideMessenger.request("history/save", sessionInfo); } @@ -106,7 +113,7 @@ function useHistory(dispatch: Dispatch) { } async function loadSession(id: string): Promise { - setLocalStorage("lastSessionId", state.sessionId); + updateLastSessionId(state.sessionId); const result = await ideMessenger.request("history/load", { id }); if (result.status === "error") { throw new Error(result.error); @@ -136,6 +143,7 @@ function useHistory(dispatch: Dispatch) { getLastSessionId, updateSession, getSession, + lastSessionId, }; } From cd693fb653a964e0892200ab8133dd7929498ed6 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 8 Oct 2024 17:46:04 +0200 Subject: [PATCH 097/255] Restore font sizes --- gui/src/components/History.tsx | 3 ++- gui/src/pages/history/HistoryHeader.tsx | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gui/src/components/History.tsx b/gui/src/components/History.tsx index 6112251fc..b930d304e 100644 --- a/gui/src/components/History.tsx +++ b/gui/src/components/History.tsx @@ -14,6 +14,7 @@ import { } from "."; import ButtonWithTooltip from "./ButtonWithTooltip"; import useHistory from "../hooks/useHistory"; +import { getFontSize } from "../util"; const SearchBarContainer = styled.div` display: flex; @@ -281,7 +282,7 @@ export function History() { const earlier = new Date(0); return ( -
+
{ useNavigationListener(); const navigate = useNavigate(); return ( -
+
Date: Tue, 8 Oct 2024 18:38:45 +0200 Subject: [PATCH 098/255] Remove unnecessary code --- gui/src/context/LastSessionContext.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gui/src/context/LastSessionContext.tsx b/gui/src/context/LastSessionContext.tsx index f931d9212..d3b555dc6 100644 --- a/gui/src/context/LastSessionContext.tsx +++ b/gui/src/context/LastSessionContext.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useState, useEffect } from "react"; +import React, { createContext, useState } from "react"; export const LastSessionContext = createContext<{ lastSessionId: string | undefined; @@ -13,13 +13,6 @@ export const LastSessionProvider: React.FC<{ }> = ({ children }) => { const [lastSessionId, setLastSessionId] = useState(); - useEffect(() => { - const storedId = localStorage.getItem("lastSessionId"); - if (storedId) { - setLastSessionId(storedId); - } - }, []); - return ( {children} From d2d2c1e058059648f5c7050bbbfee942e98e91f4 Mon Sep 17 00:00:00 2001 From: kbreese-x Date: Tue, 8 Oct 2024 11:37:58 -0700 Subject: [PATCH 099/255] config and build artifacts --- binary/package-lock.json | 1 + docs/static/schemas/config.json | 59 ++++++++++++++++++-- extensions/vscode/continue_rc_schema.json | 65 +++++++++++++++++++++-- extensions/vscode/package-lock.json | 4 +- extensions/vscode/package.json | 2 +- 5 files changed, 122 insertions(+), 9 deletions(-) diff --git a/binary/package-lock.json b/binary/package-lock.json index 5f1410c1a..010492e82 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -74,6 +74,7 @@ "jsdom": "^24.0.0", "launchdarkly-node-client-sdk": "^3.2.0", "llm-code-highlighter": "^0.0.14", + "lru-cache": "^10.2.2", "mac-ca": "^3.1.0", "node-fetch": "^3.3.2", "node-html-markdown": "^1.3.0", diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 3f340f6ce..4bb201b3e 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -246,7 +246,24 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "type": "string" + "anyOf":[ + { + "enum": [ + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + "eu-west-1", + "eu-central-1", + "ap-southeast-1", + "ap-northeast-1", + "ap-south-1" + ] + }, + { + "type": "string" + } + ] }, "profile": { "title": "Profile", @@ -2145,7 +2162,8 @@ "gemini", "voyage", "nvidia", - "bedrock" + "bedrock", + "sagemaker" ] }, "model": { @@ -2179,7 +2197,24 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "type": "string" + "anyOf":[ + { + "enum": [ + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + "eu-west-1", + "eu-central-1", + "ap-southeast-1", + "ap-northeast-1", + "ap-south-1" + ] + }, + { + "type": "string" + } + ] }, "profile": { "title": "Profile", @@ -2201,6 +2236,24 @@ "then": { "required": ["apiKey"] } + }, + { + "if": { + "properties": { + "provider": { + "enum": ["sagemaker"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "markdownDescription": "SageMaker endpoint name" + } + }, + "required": ["model"] + } } ] }, diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 26877d8a3..cc747a337 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -249,7 +249,24 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "type": "string" + "anyOf": [ + { + "enum": [ + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + "eu-west-1", + "eu-central-1", + "ap-southeast-1", + "ap-northeast-1", + "ap-south-1" + ] + }, + { + "type": "string" + } + ] }, "profile": { "title": "Profile", @@ -2391,7 +2408,8 @@ "gemini", "voyage", "nvidia", - "bedrock" + "bedrock", + "sagemaker" ] }, "model": { @@ -2425,7 +2443,24 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "type": "string" + "anyOf": [ + { + "enum": [ + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + "eu-west-1", + "eu-central-1", + "ap-southeast-1", + "ap-northeast-1", + "ap-south-1" + ] + }, + { + "type": "string" + } + ] }, "profile": { "title": "Profile", @@ -2458,6 +2493,30 @@ "apiKey" ] } + }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "sagemaker" + ] + } + }, + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "model": { + "markdownDescription": "SageMaker endpoint name" + } + }, + "required": [ + "model" + ] + } } ] }, diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5bfd16377..bf3982055 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.214", + "version": "0.9.215", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.214", + "version": "0.9.215", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 2269b08dc..197340faa 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.214", + "version": "0.9.215", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 487ea20a141ec4cab40469cd0a2233ccada1a3a7 Mon Sep 17 00:00:00 2001 From: Sahand Sojoodi Date: Tue, 8 Oct 2024 15:57:44 -0400 Subject: [PATCH 100/255] Adding Cerebras related info --- core/index.d.ts | 7 +++++- core/llm/llms/Cerebras.ts | 20 ++++++++++++++++ core/llm/llms/index.ts | 2 ++ .../model-providers/more/cerebras.md | 20 ++++++++++++++++ .../src/main/resources/config_schema.json | 23 +++++++++++++++++-- extensions/vscode/config_schema.json | 23 +++++++++++++++++-- 6 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 core/llm/llms/Cerebras.ts create mode 100644 docs/docs/customize/model-providers/more/cerebras.md diff --git a/core/index.d.ts b/core/index.d.ts index 7c47ff5e5..7c69beac3 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -644,7 +644,9 @@ type ModelProvider = | "sambanova" | "nvidia" | "vllm" - | "mock"; + | "mock" + | "cerebras"; + export type ModelName = | "AUTODETECT" @@ -683,6 +685,9 @@ export type ModelName = // Llama 3 | "llama3-8b" | "llama3-70b" + // Llama 3.1 + | "llama3.1-8b" + | "llama3.1-70b" // Other Open-source | "phi2" | "phind-codellama-34b" diff --git a/core/llm/llms/Cerebras.ts b/core/llm/llms/Cerebras.ts new file mode 100644 index 000000000..103994221 --- /dev/null +++ b/core/llm/llms/Cerebras.ts @@ -0,0 +1,20 @@ +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; + +class Cerebras extends OpenAI { + static providerName: ModelProvider = "cerebras"; + static defaultOptions: Partial = { + apiBase: "https://api.cerebras.ai/v1/", + }; + maxStopWords: number | undefined = 4; + + private static modelConversion: { [key: string]: string } = { + "llama3.1-8b": "llama3.1-8b", + "llama3.1-70b": "llama-3.1-70b", + }; + protected _convertModelName(model: string): string { + return Cerebras.modelConversion[model] ?? model; + } +} + +export default Cerebras; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index dedae7795..ea8968f5a 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -11,6 +11,7 @@ import Anthropic from "./Anthropic"; import Azure from "./Azure"; import Bedrock from "./Bedrock"; import BedrockImport from "./BedrockImport"; +import Cerebras from "./Cerebras"; import Cloudflare from "./Cloudflare"; import Cohere from "./Cohere"; import DeepInfra from "./DeepInfra"; @@ -77,6 +78,7 @@ const LLMs = [ Vllm, SambaNova, Mock, + Cerebras, ]; export async function llmFromDescription( diff --git a/docs/docs/customize/model-providers/more/cerebras.md b/docs/docs/customize/model-providers/more/cerebras.md new file mode 100644 index 000000000..57d549830 --- /dev/null +++ b/docs/docs/customize/model-providers/more/cerebras.md @@ -0,0 +1,20 @@ +# Cerebras Inference + +Cerebras Inference uses specialized silicon to provides fast inference for the Llama3.1 8B and Llama3.1 70B models. + +1. Create an account in the portal [here](https://cloud.cerebras.ai/). +2. Create and copy the API key for use in Continue. +3. Update your Continue config file: + +```json title="config.json" +{ + "models": [ + { + "title": "Cerebras Llama 3.1 70B", + "provider": "cerebras", + "model": "llama3.1-70b", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 77de3cf8a..87b026e38 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -194,7 +194,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "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)", @@ -224,7 +225,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### 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." + "### 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/)." ], "type": "string" }, @@ -1142,6 +1144,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["cerebras"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["llama3.1-8b", "llama3.1-70b"] + } + } + } + }, { "if": { "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 77de3cf8a..87b026e38 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -194,7 +194,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "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)", @@ -224,7 +225,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### 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." + "### 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/)." ], "type": "string" }, @@ -1142,6 +1144,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["cerebras"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["llama3.1-8b", "llama3.1-70b"] + } + } + } + }, { "if": { "properties": { From 97280cce7b9bd4e953620585c7f4b8b461d6c1f0 Mon Sep 17 00:00:00 2001 From: Sahand Sojoodi Date: Tue, 8 Oct 2024 18:26:31 -0400 Subject: [PATCH 101/255] Add Cerebras Inference to Llama3.1 tutorial --- docs/docs/customize/tutorials/llama3.1.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index bdcedccb0..1ad6a1dc9 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -111,3 +111,24 @@ SambaNova Cloud provides world record Llama3.1 70B/405B serving. ] } ``` + +## Cerebras Inference + +Cerebras Inference uses specialized silicon to provides fast inference for the Llama3.1 8B/70B. + +1. Create an account in the portal [here](https://cloud.cerebras.ai/). +2. Create and copy the API key for use in Continue. +3. Update your Continue config file: + +```json title="config.json" +{ + "models": [ + { + "title": "Cerebras Llama 3.1 70B", + "provider": "cerebras", + "model": "llama3.1-70b", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` From 5b1b36585a19338d6501074ef2824c47603d4cc7 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 15:36:23 -0700 Subject: [PATCH 102/255] allow additional properties in the body of httpcontextprovider --- core/context/providers/HttpContextProvider.ts | 25 +++++++++++++------ .../build-your-own-context-provider.md | 7 ++++-- docs/static/schemas/config.json | 5 ++++ .../src/main/resources/config_schema.json | 5 ++++ extensions/vscode/config_schema.json | 5 ++++ extensions/vscode/continue_rc_schema.json | 5 ++++ 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/core/context/providers/HttpContextProvider.ts b/core/context/providers/HttpContextProvider.ts index c9ff0b2ea..05a50e15d 100644 --- a/core/context/providers/HttpContextProvider.ts +++ b/core/context/providers/HttpContextProvider.ts @@ -37,20 +37,29 @@ class HttpContextProvider extends BaseContextProvider { body: JSON.stringify({ query: query || "", fullInput: extras.fullInput, + options: this.options.options, }), }); const json = await response.json(); - const createContextItem = (item: any) => ({ - description: item.description ?? "HTTP Context Item", - content: item.content ?? "", - name: item.name ?? this.options.title ?? "HTTP", - }); + try { + const createContextItem = (item: any) => ({ + description: item.description ?? "HTTP Context Item", + content: item.content ?? "", + name: item.name ?? this.options.title ?? "HTTP", + }); - return Array.isArray(json) - ? json.map(createContextItem) - : [createContextItem(json)]; + return Array.isArray(json) + ? json.map(createContextItem) + : [createContextItem(json)]; + } catch (e) { + console.warn( + `Failed to parse response from custom HTTP context provider.\nError:\n${e}\nResponse from server:\n`, + json, + ); + return []; + } } } diff --git a/docs/docs/customize/tutorials/build-your-own-context-provider.md b/docs/docs/customize/tutorials/build-your-own-context-provider.md index 3ff7a3246..f730d22a4 100644 --- a/docs/docs/customize/tutorials/build-your-own-context-provider.md +++ b/docs/docs/customize/tutorials/build-your-own-context-provider.md @@ -180,12 +180,15 @@ If you'd like to write a context provider in a language other than TypeScript, y "url": "https://myserver.com/context-provider", "title": "http", "description": "Custom HTTP Context Provider", - "displayTitle": "My Custom Context" + "displayTitle": "My Custom Context", + "options": {} } } ``` - +Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI. + +The `"options"` property can be used to send additional parameters to your endpoint, which will be included in the request body. ## Extension API for VSCode diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 77de3cf8a..827330b49 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1855,6 +1855,11 @@ "url": { "type": "string", "description": "The HTTP endpoint of your context provider server." + }, + "options": { + "title": "Custom Options", + "description": "Additional options to pass to your custom HTTP server.", + "type": "object" } }, "required": ["url"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 77de3cf8a..827330b49 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1855,6 +1855,11 @@ "url": { "type": "string", "description": "The HTTP endpoint of your context provider server." + }, + "options": { + "title": "Custom Options", + "description": "Additional options to pass to your custom HTTP server.", + "type": "object" } }, "required": ["url"] diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 77de3cf8a..827330b49 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1855,6 +1855,11 @@ "url": { "type": "string", "description": "The HTTP endpoint of your context provider server." + }, + "options": { + "title": "Custom Options", + "description": "Additional options to pass to your custom HTTP server.", + "type": "object" } }, "required": ["url"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 21f27ca4a..6099744e4 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -2076,6 +2076,11 @@ "url": { "type": "string", "description": "The HTTP endpoint of your context provider server." + }, + "options": { + "title": "Custom Options", + "description": "Additional options to pass to your custom HTTP server.", + "type": "object" } }, "required": [ From 26e536847ce571e0b3e16bdd33d72cc5c2ddefab Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 8 Oct 2024 15:54:59 -0700 Subject: [PATCH 103/255] update keybindings for accept/reject diff --- .../ContinuePluginStartupActivity.kt | 19 +--------- .../editor/DiffStreamHandler.kt | 3 +- .../editor/DiffStreamManager.java | 4 +++ .../editor/InlineEditAction.kt | 9 +++-- .../continueintellijextension/utils/Utils.kt | 4 +-- .../src/main/resources/META-INF/plugin.xml | 35 +++++++++++++------ .../vscode/src/diff/vertical/handler.ts | 12 +++---- .../vscode/src/diff/vertical/manager.ts | 1 - 8 files changed, 41 insertions(+), 46 deletions(-) create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamManager.java diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 4b0747ee7..f3a8f7d2e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -56,25 +56,8 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { private val coroutineScope = CoroutineScope(Dispatchers.IO) override fun runActivity(project: Project) { - removeShortcutFromAction(getPlatformSpecificKeyStroke("J")) removeShortcutFromAction(getPlatformSpecificKeyStroke("shift J")) - -// project.messageBus.connect().subscribe( -// ToolWindowManagerListener.TOPIC, -// object : ToolWindowManagerListener { -// override fun stateChanged(toolWindowManager: ToolWindowManager) { -// if (toolWindowManager.activeToolWindowId == TerminalToolWindowFactory.TOOL_WINDOW_ID -// || TerminalView.getInstance(project).isNotAvailable() -// ) { -// project.service().update( -// TerminalView.getInstance(project).widgets -// ) -// } -// } -// } -// ) - initializePlugin(project) } @@ -112,7 +95,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { project, ContinuePluginService::class.java ) - + val defaultStrategy = DefaultTextSelectionStrategy() coroutineScope.launch { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index aa43e88bf..f26a80f5f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -9,7 +9,6 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.EditorFontType import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.editor.markup.EffectType import com.intellij.openapi.editor.markup.HighlighterLayer import com.intellij.openapi.editor.markup.RangeHighlighter import com.intellij.openapi.editor.markup.TextAttributes @@ -54,7 +53,7 @@ class DiffStreamHandler( key.let { editor.colorsScheme.setAttributes(it, attributes) } key } - + private val unfinishedKey = run { val attributes = TextAttributes().apply { backgroundColor = JBColor(0x20888888.toInt(), 0x20888888.toInt()) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamManager.java b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamManager.java new file mode 100644 index 000000000..6a3bbaf77 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamManager.java @@ -0,0 +1,4 @@ +package com.github.continuedev.continueintellijextension.editor; + +public class DiffStreamManager { +} diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 6b05c6fb2..8645bf88a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -4,6 +4,7 @@ import com.github.continuedev.continueintellijextension.`continue`.GetTheme import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.github.continuedev.continueintellijextension.utils.getAltKeyLabel +import com.github.continuedev.continueintellijextension.utils.getMetaKeyLabel import com.intellij.openapi.Disposable import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction @@ -130,7 +131,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < maxWaitTime) { Thread.sleep(20) } - + // Get highlighted range val selectionModel = editor.selectionModel val startLineNumber = editor.document.getLineNumber(selectionModel.selectionStart) @@ -416,16 +417,14 @@ class CustomPanel( border = EmptyBorder(0, 4, 0, 0) } - val leftButton = CustomButton("Reject (${getAltKeyLabel()}⇧N)") { onReject() }.apply { + val leftButton = CustomButton("Reject All (${getMetaKeyLabel()}⇧⌫)") { onReject() }.apply { background = JBColor(0x30FF0000.toInt(), 0x30FF0000.toInt()) foreground = JBColor(0xF5F5F5.toInt(), 0xF5F5F5.toInt()) - } - val rightButton = CustomButton("Accept (${getAltKeyLabel()}⇧Y)") { onAccept() }.apply { + val rightButton = CustomButton("Accept All (${getMetaKeyLabel()}⇧⏎)") { onAccept() }.apply { background = JBColor(0x3000FF00.toInt(), 0x3000FF00.toInt()) foreground = JBColor(0xF5F5F5.toInt(), 0xF5F5F5.toInt()) - } val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt index a743e8b50..21cc17089 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt @@ -18,8 +18,8 @@ fun getOs(): Os { fun getMetaKeyLabel(): String { return when (getOs()) { Os.MAC -> "⌘" - Os.WINDOWS -> "Ctrl" - Os.LINUX -> "Ctrl" + Os.WINDOWS -> "^" + Os.LINUX -> "^" } } diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 2e8130e5e..3633201f8 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -48,7 +48,6 @@ + first-keystroke="shift ctrl ENTER"/> + first-keystroke="shift meta ENTER"/> + + + + + + + + + + + + - + @@ -93,7 +109,7 @@ @@ -102,7 +118,7 @@ @@ -110,7 +126,6 @@ diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 5aa5b070b..a1efbd1df 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -386,18 +386,14 @@ export class VerticalDiffHandler implements vscode.Disposable { } } - if (numRed > 0) { - const rangeToDelete = - this.redDecorationManager.deleteRangeStartingAt(startLine); - - if (accept) { - // Delete the actual lines - await this.deleteLinesAt(startLine, numRed); - } + if (numRed > 0 && accept) { + // Delete the actual lines + await this.deleteLinesAt(startLine, numRed); } // Shift everything below upward const offset = -(accept ? numRed : numGreen); + this.redDecorationManager.shiftDownAfterLine(startLine, offset); this.greenDecorationManager.shiftDownAfterLine(startLine, offset); diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index 2ecf6d596..985a6ba29 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -1,7 +1,6 @@ import { ConfigHandler } from "core/config/ConfigHandler"; import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens"; import { getMarkdownLanguageTagForFile } from "core/util"; - import { DiffLine } from "core"; import { streamDiffLines } from "core/edit/streamDiffLines"; import * as vscode from "vscode"; From e25f1c0299b694ed36e4d6cb1338d82a64ced6ad Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 16:51:27 -0700 Subject: [PATCH 104/255] fix settings update in jetbrains --- .../activities/ContinuePluginStartupActivity.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 4b0747ee7..004845314 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -112,7 +112,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { project, ContinuePluginService::class.java ) - + val defaultStrategy = DefaultTextSelectionStrategy() coroutineScope.launch { @@ -143,7 +143,12 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { continuePluginService.coreMessenger?.request("config/ideSettingsUpdate", settings, null) { _ -> } continuePluginService.sendToWebview( "didChangeIdeSettings", mapOf( - "settings" to settings + "settings" to mapOf( + "remoteConfigServerUrl" to settings.remoteConfigServerUrl, + "remoteConfigSyncPeriod" to settings.remoteConfigSyncPeriod, + "userToken" to settings.userToken, + "enableControlServerBeta" to settings.enableContinueTeamsBeta + ) ) ) } From c8ce3df4aa4af09a7babfd2251837024ecbe2acd Mon Sep 17 00:00:00 2001 From: Sahand Sojoodi Date: Tue, 8 Oct 2024 19:58:44 -0400 Subject: [PATCH 105/255] Fixes to support Cerebras Llama3.1 8b and 70b --- core/llm/llms/Cerebras.ts | 2 +- docs/static/schemas/config.json | 23 +++++++++++-- extensions/vscode/continue_rc_schema.json | 30 +++++++++++++++-- gui/public/logos/cerebras.png | Bin 0 -> 2947 bytes gui/src/pages/AddNewModel/configs/models.ts | 1 + .../pages/AddNewModel/configs/providers.ts | 31 ++++++++++++++++++ 6 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 gui/public/logos/cerebras.png diff --git a/core/llm/llms/Cerebras.ts b/core/llm/llms/Cerebras.ts index 103994221..4b0a1752c 100644 --- a/core/llm/llms/Cerebras.ts +++ b/core/llm/llms/Cerebras.ts @@ -10,7 +10,7 @@ class Cerebras extends OpenAI { private static modelConversion: { [key: string]: string } = { "llama3.1-8b": "llama3.1-8b", - "llama3.1-70b": "llama-3.1-70b", + "llama3.1-70b": "llama3.1-70b", }; protected _convertModelName(model: string): string { return Cerebras.modelConversion[model] ?? model; diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 77de3cf8a..87b026e38 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -194,7 +194,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "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)", @@ -224,7 +225,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### 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." + "### 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/)." ], "type": "string" }, @@ -1142,6 +1144,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["cerebras"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["llama3.1-8b", "llama3.1-70b"] + } + } + } + }, { "if": { "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 21f27ca4a..00ac4ff95 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -197,7 +197,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "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)", @@ -227,7 +228,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### 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." + "### 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/)." ], "type": "string" }, @@ -1265,6 +1267,30 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "cerebras" + ] + } + }, + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "model": { + "enum": [ + "llama3.1-8b", + "llama3.1-70b" + ] + } + } + } + }, { "if": { "properties": { diff --git a/gui/public/logos/cerebras.png b/gui/public/logos/cerebras.png new file mode 100644 index 0000000000000000000000000000000000000000..024dc5b7dccc6b6365962711c1e8dd9c3c6d0c19 GIT binary patch literal 2947 zcmY*bc|6qJ8Xr?(CQD3~n3}Ovgqv((EK#;Qdb_>%p7VLm^F7b+`+T4CoIlRzm*C`JB?y)R0{{R)8*6hH zu7~d$KQDKsL`JS~9S_CD3Js`aL#Mf$D>#fzki9)Xg^T$C`*=hFdv+<@3E+_e?E8rU zfRjAZzp)FC(k~7W0QeUHu=f|oi|coXHP^V=zx*C1&p(Px;BPjZx#u6eo95pjyvTK+ zP-{;L0I(mjYdnD4d6HZ;Pl6kUim|sd2qc9duxCgCI0P*ubT+7J`-f%Vs7~>ox3xZ z#Z#%F21sN?Lo zAQ9oay4V0x7}Z!-cDK;)@%K5YgrI*a5h=gg;x>rf{esj$ppd_{xv56GQ3FRZ0mrSp zt8b!V^pp92v0rtJkh{hI=P-YF`ZLOH)dXyW{C#aE;6r|6eB6uIvN1Pv!+>sh5JKHO z4qal`uPNB0-O&&^&acfcHF=Qx`$=0>ao09o%!UOk-_C48#8nfP-6QXBuGHcTPE1RN z^IJ0KjNyKILGd_;>y zhj{=-LYO!cj~2;&MQV6xbD>eiVIYSf*)Wwm+aE` zpOX&GAqK*-EiT@Xk|Q_86$`=GH*5+-+vRy~bdJH2LlNJ^W_w8uedMx$&5Uup$K|{_ zr`!+k5xR>;TmxcZW|`a8hrjFKu{E3984TIdVu zjetL~Zr#oRWm+vaE^2~!@|T>6zDNXA@hHly>G8MDy1L2hAkSF%-tXg<6t7QV7XN_InpZMg(*7TYhB_fSLcZZL!#TOv*J5X% z>S)|HPPu(-Nq#GJtsJV><)YV%3q3m+aH62?>>qH$go4RVJ)JO6jeH76-)d}VLkFxs zY6w2#su>->vEE*^UsisFQ88THTzGEh;E>GInwqpzUXZ*mcFy-4-_{FiM~%3ooCQZW zjxeuD9nW~!s~N-@HH(KkvK9EZTa=o=nXA90t-E#$2p0oMi{1UYNhiHxZC&9VAYjH6 zOK~N$zrSq<c-g#Q)vA5&W;i(!)RwJzB=5*yt z$#)WhF3Ng0g4V5Is3ydVdC{xaYj2{Qv(^lya=i@kb;g3(<%(Ux8N63%Jp)xa{1csg}(*=xMiUvR0 zSdY_|it@$-vJh~RkhD^e_8)UulHDR>bA%}T91HpJT0yC`lR!iD~Mtk(G zrMMp;yAdWA0&Y27P){zk&Ido#*k<4BiINn|T)l0@V37R~k&XoxUHt=934cn@&Q#%+ zJ*t9x{POfJF;0r(+QvE3R|%GYgAza|rEpL6j@9%MHRa@snN}|{2C~taB7OUNgITt*w_k+R5I&a|s z)dvo&hE9?AI1{jK{%B(=zhQVoY?8fT2b0Z)zuJ4+T{cvHzASCd?vkd%BlMk}d_ zZ$g}&j7Yd%m-F{kp!@d_sv<1wFp=4#}xck#_b~w--ff@E(yHJ5eFi z7ze1rQ^;g8EWlcA0(9J>MZe8x@ijwyPbTxm%V1?!j&uCjiIskg+KVAg+E`#z_K=gRxg^d#U$Hx|#rYV%O3AnI zM*o2)h#phRUAnHkZ#WAx{ z_L}UrGO*DX!5s+}-&_>A7m!^kgQ&S9fNGQqw%z#v^e0rB!H4-59!Sq0| z=fqLP2LYgMcez{W1BXSfZrSDXA<~$2(UKHJ%Ukz>w12-HnJ~5ROg4HS9vl@lF@JzK z_}z<=+94*Ew%m4IO0Hl#boOiZ7t1!JksRUb3b{q0EN*|WiiOmOhIhx%Q(?LO0aItL-CSF|V9-r{ zn$7!BCja3uWj0^aG5HXWojQAy&c-vcprwDIk=bnEk#jcd=jxX4-BK UkjQyfz56F>W8q+4i9Q|sA83a5p8x;= literal 0 HcmV?d00001 diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 5a70ad8d1..f3e0b9cfe 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -68,6 +68,7 @@ export const models: { [key: string]: ModelPackage } = { "llama.cpp", "replicate", "sambanova", + "cerebras", ], isOpenSource: true, }, diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 155905fbc..1bca2efff 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -595,4 +595,35 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo }), apiKeyUrl: "https://cloud.sambanova.ai/apis", }, + cerebras: { + title: "Cerebras", + provider: "cerebras", + icon: "cerebras.png", + description: + "Cerebras Inference is a custom silicon for fast inference of LLM models.", + longDescription: + "Get your API key [here](https://cloud.cerebras.ai/).", + tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], + collectInputFor: [ + { + inputType: "text", + key: "apiKey", + label: "API Key", + placeholder: "Enter your Cerebras API key", + required: true, + }, + ], + packages: [ + models.llama3170bChat, + models.llama318bChat, + { + ...models.AUTODETECT, + params: { + ...models.AUTODETECT.params, + title: "Cerebras", + }, + }, + ], + apiKeyUrl: "https://cloud.cerebras.ai/", + }, }; From 0cd2399d1b92a0446a281f4c711f6a12fe0f5a64 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 18:03:22 -0700 Subject: [PATCH 106/255] improve jetbrains logging --- .../auth/ContinueAuthService.kt | 29 +++++++++++++------ .../continue/IdeProtocolClient.kt | 4 +-- extensions/vscode/package-lock.json | 4 +-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt index 9c83e67fc..da6d74b43 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt @@ -100,7 +100,7 @@ class ContinueAuthService { updateRefreshToken(refreshToken) } - kotlinx.coroutines.delay(30 * 60 * 1000) + kotlinx.coroutines.delay(15 * 60 * 1000) // 15 minutes in milliseconds } } } @@ -140,19 +140,30 @@ class ContinueAuthService { } private fun retrieveSecret(key: String): String? { - val attributes = createCredentialAttributes(key, CREDENTIALS_USER) - val passwordSafe: PasswordSafe = PasswordSafe.instance + return try { + val attributes = createCredentialAttributes(key, CREDENTIALS_USER) + val passwordSafe: PasswordSafe = PasswordSafe.instance - val credentials: Credentials? = passwordSafe[attributes!!] - return credentials?.getPasswordAsString() + val credentials: Credentials? = passwordSafe[attributes!!] + credentials?.getPasswordAsString() + } catch (e: Exception) { + // Log the exception or handle it as needed + println("Error retrieving secret for key $key: ${e.message}") + null + } } private fun storeSecret(key: String, secret: String) { - val attributes = createCredentialAttributes(key, CREDENTIALS_USER) - val passwordSafe: PasswordSafe = PasswordSafe.instance + try { + val attributes = createCredentialAttributes(key, CREDENTIALS_USER) + val passwordSafe: PasswordSafe = PasswordSafe.instance - val credentials = Credentials(CREDENTIALS_USER, secret) - passwordSafe.set(attributes!!, credentials) + val credentials = Credentials(CREDENTIALS_USER, secret) + passwordSafe.set(attributes!!, credentials) + } catch (e: Exception) { + // Log the exception or handle it as needed + println("Error storing secret for key $key: ${e.message}") + } } private fun getAccessToken(): String? { 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 7f0697772..350a96bdd 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 @@ -730,9 +730,7 @@ class IdeProtocolClient( respond(File.separator) } - else -> { - println("Unknown messageType: $messageType") - } + else -> {} } } catch (error: Exception) { showToast("error", "Error handling message of type $messageType: $error") diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5bfd16377..bf3982055 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.214", + "version": "0.9.215", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.214", + "version": "0.9.215", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", From 73e75f87e91d5661d86c72da443770c515793590 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 18:28:06 -0700 Subject: [PATCH 107/255] add note about autocomplete models in azure --- docs/docs/customize/model-providers/top-level/azure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/top-level/azure.md b/docs/docs/customize/model-providers/top-level/azure.md index f6e54137f..338a3772b 100644 --- a/docs/docs/customize/model-providers/top-level/azure.md +++ b/docs/docs/customize/model-providers/top-level/azure.md @@ -22,7 +22,7 @@ We recommend configuring **GPT-4o** as your chat model. ## Autocomplete model -We recommend configuring **Codestral** as your autocomplete model. +We recommend configuring **Codestral** as your autocomplete model. There are not currently any other models in Azure that are capable of autocomplete. ```json title="config.json" "tabAutocompleteModel": [{ From 1493192072f2f2be3fbd436719d2493d027e6156 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Oct 2024 21:29:57 -0700 Subject: [PATCH 108/255] bump gradle version --- 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 dd4a1c1a0..613ecad77 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.74 +pluginVersion=0.0.75 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 #pluginUntilBuild = 232.* From 640f2b48a29df47e956fb9a26094e03155288638 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 9 Oct 2024 13:16:03 +0200 Subject: [PATCH 109/255] Toggle full screen mode --- core/protocol/ideWebview.ts | 2 +- extensions/vscode/package.json | 16 +++++++++++----- extensions/vscode/src/commands.ts | 31 ++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 523ba4995..1f0d0e85e 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -22,7 +22,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { toggleDevTools: [undefined, void]; reloadWindow: [undefined, void]; focusEditor: [undefined, void]; - toggleFullScreen: [undefined, void]; + toggleFullScreen: [undefined, void, { newWindow?: boolean } | undefined]; insertAtCursor: [{ text: string }, void]; copyText: [{ text: string }, void]; "jetbrains/editorInsetHeight": [{ height: number }, void]; diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 6473fd504..ffa27b831 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -189,6 +189,12 @@ "icon": "$(fullscreen)", "group": "Continue" }, + { + "command": "continue.toggleNewWindow", + "category": "Continue", + "title": "Open New Window", + "icon": "$(link-external)" + }, { "command": "continue.openConfigJson", "category": "Continue", @@ -452,6 +458,11 @@ "command": "continue.toggleFullScreen", "group": "navigation@3", "when": "view == continue.continueGUIView" + }, + { + "command": "continue.toggleNewWindow", + "group": "navigation@4", + "when": "view == continue.continueGUIView" } ], "editor/title": [ @@ -464,11 +475,6 @@ "command": "continue.viewHistory", "group": "navigation@2", "when": "activeWebviewPanelId == continue.continueGUIView" - }, - { - "command": "continue.toggleFullScreen", - "group": "navigation@3", - "when": "activeWebviewPanelId == continue.continueGUIView" } ], "terminal/context": [ diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b49e9a184..961e1c25d 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -483,7 +483,11 @@ const commandsMap: ( "continue.applyCodeFromChat": () => { sidebar.webviewProtocol.request("applyCodeFromChat", undefined); }, - "continue.toggleFullScreen": () => { + "continue.toggleFullScreen": ({ + newWindow, + }: { newWindow?: boolean } = {}) => { + focusGUI(); + // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); @@ -532,6 +536,18 @@ const commandsMap: ( null, extensionContext.subscriptions, ); + + if (newWindow) { + vscode.commands.executeCommand( + "workbench.action.copyEditorToNewWindow", + ); + } + }, + "continue.toggleNewWindow": () => { + focusGUI(); + vscode.commands.executeCommand("continue.toggleFullScreen", { + newWindow: true, + }); }, "continue.openConfigJson": () => { ide.openFile(getConfigJsonPath()); @@ -654,6 +670,9 @@ const commandsMap: ( { label: "$(screen-full) Open full screen chat (Cmd+K Cmd+M)", }, + { + label: "$(link-external) Open chat in a new window", + }, { label: quickPickStatusText(targetStatus), }, @@ -705,9 +724,15 @@ const commandsMap: ( "$(screen-full) Open full screen chat (Cmd+K Cmd+M)" ) { vscode.commands.executeCommand("continue.toggleFullScreen"); + } else if ( + selectedOption === "$(link-external) Open chat in a new window" + ) { + vscode.commands.executeCommand("continue.toggleNewWindow"); } else if (selectedOption === "$(question) Open help center") { - focusGUI(); - vscode.commands.executeCommand("continue.navigateTo", "/more"); + vscode.commands.executeCommand("continue.toggleFullScreen"); + vscode.commands.executeCommand("continue.toggleNewWindow"); + // focusGUI(); + // vscode.commands.executeCommand("continue.navigateTo", "/more"); } quickPick.dispose(); }); From 1786bfb4aed8bcce42fffdbdda837929a86d00c8 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 9 Oct 2024 14:54:43 +0200 Subject: [PATCH 110/255] Restore help center shortcut --- extensions/vscode/src/commands.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 961e1c25d..36245b6ab 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -729,10 +729,8 @@ const commandsMap: ( ) { vscode.commands.executeCommand("continue.toggleNewWindow"); } else if (selectedOption === "$(question) Open help center") { - vscode.commands.executeCommand("continue.toggleFullScreen"); - vscode.commands.executeCommand("continue.toggleNewWindow"); - // focusGUI(); - // vscode.commands.executeCommand("continue.navigateTo", "/more"); + focusGUI(); + vscode.commands.executeCommand("continue.navigateTo", "/more"); } quickPick.dispose(); }); From af509ef1ae2e0265c3ea1f73c72c4aa20973bd3b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 9 Oct 2024 15:00:10 +0200 Subject: [PATCH 111/255] Widen 4xl breakpoint --- gui/tailwind.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 63e0c2810..49d569e78 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -18,7 +18,7 @@ module.exports = { xl: "720px", "2xl": "860px", "3xl": "1000px", - "4xl": "1140px", + "4xl": "1180px", }, extend: { animation: { From 1fddcd0d9a167e7c11ebcde83eb93fd7dde5bc9c Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 9 Oct 2024 14:12:11 -0700 Subject: [PATCH 112/255] bump platformVersion in 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 613ecad77..37e02f543 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -9,7 +9,7 @@ pluginSinceBuild=223 #pluginUntilBuild = 232.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType=IC -platformVersion=2022.3.3 +platformVersion=2023.2 #platformVersion = LATEST-EAP-SNAPSHOT # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 From b6b39dbf0abfca128cb0a7199a153cb78c710c77 Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 9 Oct 2024 14:22:17 -0700 Subject: [PATCH 113/255] update diff accept/reject logi --- .../editor/DiffStreamHandler.kt | 149 ++- .../editor/DiffStreamService.kt | 6 +- .../editor/EditorComponentInlaysManager.kt | 2 - .../editor/VerticalDiffActionButtons.kt | 95 ++ .../vscode/src/diff/vertical/handler.ts | 7 +- gui/src/components/mainInput/InputToolbar.tsx | 2 +- gui/src/pages/gui.tsx | 940 +++++++++--------- 7 files changed, 707 insertions(+), 494 deletions(-) create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffActionButtons.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index f26a80f5f..15ff0689d 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -26,6 +26,13 @@ enum class DiffLineType { SAME, NEW, OLD } +data class VerticalDiffBlock( + val start: Int, + val numRed: Int, + val numGreen: Int, + val buttons: VerticalDiffActionButtons +) + class DiffStreamHandler( private val project: Project, private val editor: Editor, @@ -70,11 +77,13 @@ class DiffStreamHandler( private var currentLineHighlighter: RangeHighlighter? = null private val unfinishedHighlighters: MutableList = mutableListOf() private var changeCount: Int = 0 // Kept track of so we can count steps to undo when cancelling + private var insertedInCurrentBlock: Int = 0; private var running: Boolean = false - private var deletionBufferStartLine: Int = -1 private val deletionsBuffer: MutableList = mutableListOf() private val deletionInlays: MutableList = mutableListOf() + private val verticalDiffBlocks: MutableList = mutableListOf() + private fun removeDeletionInlays() { deletionInlays.forEach { @@ -102,8 +111,45 @@ class DiffStreamHandler( } private fun insertDeletionBuffer() { + if (deletionsBuffer.isNotEmpty() || insertedInCurrentBlock > 0) { + val start = currentLine - insertedInCurrentBlock + val numGreen = insertedInCurrentBlock + val numRed = deletionsBuffer.size + val buttons = VerticalDiffActionButtons( + editor, + start, + onClickAccept = { + acceptRejectBlock(true, start, numGreen, numRed) + }, + onClickReject = { + acceptRejectBlock(false, start, numGreen, numRed) + } + ) + + verticalDiffBlocks.add( + VerticalDiffBlock( + start = start, + numRed = deletionsBuffer.size, + numGreen = insertedInCurrentBlock, + buttons = buttons + ) + ) + + editor.contentComponent.add(buttons.acceptButton) + editor.contentComponent.add(buttons.rejectButton) + editor.contentComponent.revalidate() + editor.contentComponent.repaint() + } + + if (deletionsBuffer.isEmpty()) { + insertedInCurrentBlock = 0; + return; + } + + // TODO: Handle decoration updates according to insertedInCurrentBlock + // Insert red highlighted code between the real lines in the editor - if (deletionBufferStartLine != -1 && deletionsBuffer.isNotEmpty()) { + if (deletionBufferStartLine != -1) { val component = JTextArea().apply { text = deletionsBuffer.joinToString("\n") isEditable = false @@ -125,6 +171,8 @@ class DiffStreamHandler( deletionsBuffer.clear() deletionBufferStartLine = -1 } + + insertedInCurrentBlock = 0; } private fun handleDiffLine(type: DiffLineType, line: String) { @@ -137,28 +185,25 @@ class DiffStreamHandler( } DiffLineType.NEW -> { - // Insert new line if (currentLine == editor.document.lineCount) { editor.document.insertString(editor.document.textLength, "\n") } + val offset = editor.document.getLineStartOffset(currentLine) editor.document.insertString(offset, line + "\n") - - // Highlight the new line green editor.markupModel.addLineHighlighter(greenKey, currentLine, HighlighterLayer.LAST) insertDeletionBuffer() currentLine++ changeCount++ + insertedInCurrentBlock++; } DiffLineType.OLD -> { - // Remove old line deleteLineAt(currentLine) - - // Add to deletions buffer deletionsBuffer.add(line) + if (deletionBufferStartLine == -1) { deletionBufferStartLine = currentLine } @@ -171,6 +216,7 @@ class DiffStreamHandler( if (currentLineHighlighter != null) { editor.markupModel.removeHighlighter(currentLineHighlighter!!) } + currentLineHighlighter = editor.markupModel.addLineHighlighter( currentLineKey, min(currentLine, editor.document.lineCount - 1), @@ -188,6 +234,64 @@ class DiffStreamHandler( } } + private fun acceptRejectBlock( + accept: Boolean, + startLine: Int, + numGreen: Int, + numRed: Int + ) { + // TODO: We use virtual lines for red so we should shouldnt be doing numRed addition + if (numGreen > 0) { + val highlightersToRemove = editor.markupModel.allHighlighters.filter { highlighter -> + val highlighterLine = editor.document.getLineNumber(highlighter.startOffset) + highlighterLine in startLine until (startLine + numRed) + } + + if (highlightersToRemove.isNotEmpty()) { + editor.markupModel.removeHighlighter(highlightersToRemove.first()) + } + + if (!accept) { + // Delete the actual lines + WriteCommandAction.runWriteCommandAction(project) { + for (i in 0 until numGreen) { + deleteLineAt(startLine + numRed) + } + } + } + } + + if (numRed > 0 && accept) { + // Delete the actual lines + WriteCommandAction.runWriteCommandAction(project) { + for (i in 0 until numRed) { + deleteLineAt(startLine) + } + } + } + + // Shift everything below upward + val offset = -(if (accept) numRed else numGreen) + + // Update the positions of the vertical diff blocks + verticalDiffBlocks.forEach { block -> + if (block.start > startLine) { + block.buttons.updatePosition(block.start + offset) + } + } + + // Remove the processed block + verticalDiffBlocks.removeAll { it.start == startLine } + + if (verticalDiffBlocks.isEmpty()) { + onClose() + } + + // Refresh the editor + editor.contentComponent.revalidate() + editor.contentComponent.repaint() + } + private fun resetState() { // Remove all highlighters editor.markupModel.removeAllHighlighters() @@ -212,29 +316,36 @@ class DiffStreamHandler( } } - fun accept() { + private fun removeDiffBlock(block: VerticalDiffBlock) { + editor.contentComponent.remove(block.buttons.acceptButton) + editor.contentComponent.remove(block.buttons.rejectButton) + + verticalDiffBlocks.remove(block) + + editor.contentComponent.revalidate() + editor.contentComponent.repaint() + } + + private fun removeAllDiffBlocks() { + verticalDiffBlocks.forEach(::removeDiffBlock) + } + + fun acceptAll() { // Accept the changes editor.markupModel.removeAllHighlighters() removeDeletionInlays() onClose() running = false + removeAllDiffBlocks() } - fun reject() { + fun rejectAll() { // Reject the changes resetState() removeDeletionInlays() onClose() running = false - } - - fun toggleFocus() { - if (textArea.hasFocus()) { - textArea.transferFocus() - editor.contentComponent.requestFocus() - } else { - textArea.requestFocus() - } + removeAllDiffBlocks() } fun run(input: String, prefix: String, highlighted: String, suffix: String, modelTitle: String) { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamService.kt index 48aba76b8..222e6a71c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamService.kt @@ -9,19 +9,19 @@ class DiffStreamService { fun register(handler: DiffStreamHandler, editor: Editor) { if (handlers.containsKey(editor)) { - handlers[editor]?.reject() + handlers[editor]?.rejectAll() } handlers[editor] = handler println("Registered handler for editor") } fun reject(editor: Editor) { - handlers[editor]?.reject() + handlers[editor]?.rejectAll() handlers.remove(editor) } fun accept(editor: Editor) { - handlers[editor]?.accept() + handlers[editor]?.acceptAll() handlers.remove(editor) } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt index 20d31a519..e8f24f972 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorComponentInlaysManager.kt @@ -14,10 +14,8 @@ import com.intellij.util.concurrency.annotations.RequiresEdt import com.intellij.util.ui.JBUI import java.awt.Dimension import java.awt.Font -import java.awt.Insets import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent -import javax.swing.BorderFactory import javax.swing.JComponent import javax.swing.ScrollPaneConstants import kotlin.math.ceil diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffActionButtons.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffActionButtons.kt new file mode 100644 index 000000000..101799549 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffActionButtons.kt @@ -0,0 +1,95 @@ +package com.github.continuedev.continueintellijextension.editor + +import com.github.continuedev.continueintellijextension.utils.getAltKeyLabel +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.LogicalPosition +import com.intellij.ui.JBColor +import java.awt.* +import javax.swing.JButton + +class VerticalDiffActionButtons( + private val editor: Editor, + private var lineNumber: Int, + private val onClickAccept: () -> Unit, + private val onClickReject: () -> Unit +) { + val acceptButton: JButton + val rejectButton: JButton + + private fun removeButtons() { + editor.contentComponent.remove(acceptButton) + editor.contentComponent.remove(rejectButton) + } + + init { + acceptButton = createButton("${getAltKeyLabel()}⇧Y", JBColor(0x9900FF00.toInt(), 0x9900FF00.toInt())) + rejectButton = createButton("${getAltKeyLabel()}⇧N", JBColor(0x99FF0000.toInt(), 0x99FF0000.toInt())) + + acceptButton.addActionListener { + removeButtons() + onClickAccept() + } + + rejectButton.addActionListener { + removeButtons() + onClickReject() + } + + // Position the buttons + val visibleArea = editor.scrollingModel.visibleArea + val lineStartPosition = editor.logicalPositionToXY(LogicalPosition(lineNumber, 0)) + val xPosition = + visibleArea.x + visibleArea.width - acceptButton.preferredSize.width - rejectButton.preferredSize.width - 20 + val yPosition = lineStartPosition.y + + acceptButton.setBounds( + xPosition, + yPosition, + acceptButton.preferredSize.width, + acceptButton.preferredSize.height + ) + rejectButton.setBounds( + xPosition + acceptButton.preferredSize.width + 5, + yPosition, + rejectButton.preferredSize.width, + rejectButton.preferredSize.height + ) + } + + private fun createButton(text: String, backgroundColor: JBColor): JButton { + return object : JButton(text) { + override fun paintComponent(g: Graphics) { + val g2 = g.create() as Graphics2D + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) + g2.color = backgroundColor + g2.fillRoundRect(0, 0, width - 1, height - 1, 8, 8) + super.paintComponent(g2) + g2.dispose() + } + }.apply { + // This isn't working currently, font color is transparent + foreground = JBColor.WHITE + font = Font("Arial", Font.BOLD, 9) + isContentAreaFilled = false + isOpaque = false + border = null + preferredSize = Dimension(preferredSize.width, 16) + cursor = Cursor(Cursor.HAND_CURSOR) + } + } + + fun updatePosition(newLineNumber: Int) { + this.lineNumber = newLineNumber + val visibleArea = editor.scrollingModel.visibleArea + val lineStartPosition = editor.logicalPositionToXY(LogicalPosition(lineNumber, 0)) + val xPosition = + visibleArea.x + visibleArea.width - acceptButton.width - rejectButton.width - 40 + val yPosition = lineStartPosition.y + + acceptButton.location = Point(xPosition, yPosition) + rejectButton.location = Point(xPosition + acceptButton.width + 5, yPosition) + + // Refresh the editor to reflect the changes + editor.component.repaint() + } +} diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index a1efbd1df..37cb1badf 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -90,6 +90,7 @@ export class VerticalDiffHandler implements vscode.Disposable { private async insertDeletionBuffer() { // Don't remove trailing whitespace line const totalDeletedContent = this.deletionBuffer.join("\n"); + if ( totalDeletedContent === "" && this.currentLineIndex >= this.endLine + this.newLinesAdded && @@ -100,11 +101,13 @@ export class VerticalDiffHandler implements vscode.Disposable { if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) { const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + blocks.push({ start: this.currentLineIndex - this.insertedInCurrentBlock, numRed: this.deletionBuffer.length, numGreen: this.insertedInCurrentBlock, }); + this.editorToVerticalDiffCodeLens.set(this.filepath, blocks); } @@ -118,10 +121,12 @@ export class VerticalDiffHandler implements vscode.Disposable { this.currentLineIndex - this.insertedInCurrentBlock, totalDeletedContent, ); + this.redDecorationManager.addLines( this.currentLineIndex - this.insertedInCurrentBlock, this.deletionBuffer.length, ); + // Shift green decorations downward this.greenDecorationManager.shiftDownAfterLine( this.currentLineIndex - this.insertedInCurrentBlock, @@ -132,9 +137,9 @@ export class VerticalDiffHandler implements vscode.Disposable { for (let i = 0; i < this.deletionBuffer.length; i++) { this.incrementCurrentLineIndex(); } + this.deletionBuffer = []; this.insertedInCurrentBlock = 0; - this.refreshCodeLens(); } diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index da255e86d..544ccfa23 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -152,7 +152,7 @@ function InputToolbar(props: InputToolbarProps) { } > - @codebase + {getMetaKeyLabel()}⏎ @codebase Submit with the codebase as context ({getMetaKeyLabel()}⏎) diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index 156c0b3b2..02c7d2ec4 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -1,532 +1,536 @@ import { - ArrowLeftIcon, - ChatBubbleOvalLeftIcon, - CodeBracketSquareIcon, - ExclamationTriangleIcon, + ArrowLeftIcon, + ChatBubbleOvalLeftIcon, + CodeBracketSquareIcon, + ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; -import { JSONContent } from "@tiptap/react"; -import { InputModifiers } from "core"; -import { usePostHog } from "posthog-js/react"; +import {JSONContent} from "@tiptap/react"; +import {InputModifiers} from "core"; +import {usePostHog} from "posthog-js/react"; import { - Fragment, - useCallback, - useContext, - useEffect, - useRef, - useState, + Fragment, + useCallback, + useContext, + useEffect, + useRef, + useState, } from "react"; -import { ErrorBoundary } from "react-error-boundary"; -import { useDispatch, useSelector } from "react-redux"; +import {ErrorBoundary} from "react-error-boundary"; +import {useDispatch, useSelector} from "react-redux"; import styled from "styled-components"; import { - Button, - defaultBorderRadius, - lightGray, - vscBackground, - vscForeground, + Button, + defaultBorderRadius, + lightGray, + vscBackground, + vscForeground, } from "../components"; -import { ChatScrollAnchor } from "../components/ChatScrollAnchor"; +import {ChatScrollAnchor} from "../components/ChatScrollAnchor"; import StepContainer from "../components/gui/StepContainer"; import TimelineItem from "../components/gui/TimelineItem"; import ContinueInputBox from "../components/mainInput/ContinueInputBox"; -import { defaultInputModifiers } from "../components/mainInput/inputModifiers"; -import { TutorialCard } from "../components/mainInput/TutorialCard"; +import {defaultInputModifiers} from "../components/mainInput/inputModifiers"; +import {TutorialCard} from "../components/mainInput/TutorialCard"; import { - OnboardingCard, - useOnboardingCard, + OnboardingCard, + useOnboardingCard, } from "../components/OnboardingCard"; -import { IdeMessengerContext } from "../context/IdeMessenger"; +import {IdeMessengerContext} from "../context/IdeMessenger"; import useChatHandler from "../hooks/useChatHandler"; import useHistory from "../hooks/useHistory"; -import { useTutorialCard } from "../hooks/useTutorialCard"; -import { useWebviewListener } from "../hooks/useWebviewListener"; -import { defaultModelSelector } from "../redux/selectors/modelSelectors"; +import {useTutorialCard} from "../hooks/useTutorialCard"; +import {useWebviewListener} from "../hooks/useWebviewListener"; +import {defaultModelSelector} from "../redux/selectors/modelSelectors"; import { - clearLastResponse, - deleteMessage, - newSession, - setInactive, + clearLastResponse, + deleteMessage, + newSession, + setInactive, } from "../redux/slices/stateSlice"; import { - setDialogEntryOn, - setDialogMessage, - setShowDialog, + setDialogEntryOn, + setDialogMessage, + setShowDialog, } from "../redux/slices/uiStateSlice"; -import { RootState } from "../redux/store"; +import {RootState} from "../redux/store"; import { - getFontSize, - getMetaKeyLabel, - isJetBrains, - isMetaEquivalentKeyPressed, + getFontSize, + getMetaKeyLabel, + isJetBrains, + isMetaEquivalentKeyPressed, } from "../util"; -import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial"; -import { getLocalStorage, setLocalStorage } from "../util/localStorage"; +import {FREE_TRIAL_LIMIT_REQUESTS} from "../util/freeTrial"; +import {getLocalStorage, setLocalStorage} from "../util/localStorage"; const TopGuiDiv = styled.div<{ - showScrollbar?: boolean; + showScrollbar?: boolean; }>` - overflow-y: auto; - height: 100%; - scrollbar-width: ${(props) => (props.showScrollbar ? "thin" : "none")}; + overflow-y: auto; + height: 100%; + scrollbar-width: ${(props) => (props.showScrollbar ? "thin" : "none")}; - &::-webkit-scrollbar { - display: ${(props) => (props.showScrollbar ? "block" : "none")}; - } + &::-webkit-scrollbar { + display: ${(props) => (props.showScrollbar ? "block" : "none")}; + } `; const StopButton = styled.div` - width: fit-content; - margin-right: auto; - margin-left: auto; - font-size: ${getFontSize() - 2}px; - border: 0.5px solid ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 4px 8px; - color: ${lightGray}; - cursor: pointer; - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08); - transition: box-shadow 0.3s ease; + width: fit-content; + margin-right: auto; + margin-left: auto; + font-size: ${getFontSize() - 2}px; + border: 0.5px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + padding: 4px 8px; + color: ${lightGray}; + cursor: pointer; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08); + transition: box-shadow 0.3s ease; - &:hover { - box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1); - } + &:hover { + box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1); + } `; const StepsDiv = styled.div` - position: relative; - background-color: transparent; - - & > * { position: relative; - } + background-color: transparent; - .thread-message { - margin: 8px 4px 0 4px; - } + & > * { + position: relative; + } + + .thread-message { + margin: 8px 4px 0 4px; + } `; const NewSessionButton = styled.div` - width: fit-content; - margin-right: auto; - margin-left: 6px; - margin-top: 2px; - margin-bottom: 8px; - font-size: ${getFontSize() - 2}px; + width: fit-content; + margin-right: auto; + margin-left: 6px; + margin-top: 2px; + margin-bottom: 8px; + font-size: ${getFontSize() - 2}px; - border-radius: ${defaultBorderRadius}; - padding: 2px 6px; - color: ${lightGray}; + border-radius: ${defaultBorderRadius}; + padding: 2px 6px; + color: ${lightGray}; - &:hover { - background-color: ${lightGray}33; - color: ${vscForeground}; - } + &:hover { + background-color: ${lightGray}33; + color: ${vscForeground}; + } - cursor: pointer; + cursor: pointer; `; -function fallbackRender({ error, resetErrorBoundary }: any) { - // Call resetErrorBoundary() to reset the error boundary and retry the render. +function fallbackRender({error, resetErrorBoundary}: any) { + // Call resetErrorBoundary() to reset the error boundary and retry the render. - return ( -
-

Something went wrong:

-
{error.message}
-
- -
-
- ); + return ( +
+

Something went wrong:

+
{error.message}
+ +
+ +
+
+ ); } function GUI() { - const posthog = usePostHog(); - const dispatch = useDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - const { streamResponse } = useChatHandler(dispatch, ideMessenger); - const onboardingCard = useOnboardingCard(); - const { showTutorialCard, closeTutorialCard } = useTutorialCard(); - const sessionState = useSelector((state: RootState) => state.state); - const defaultModel = useSelector(defaultModelSelector); - const ttsActive = useSelector((state: RootState) => state.state.ttsActive); - const active = useSelector((state: RootState) => state.state.active); - const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]); - const mainTextInputRef = useRef(null); - const topGuiDivRef = useRef(null); - const [isAtBottom, setIsAtBottom] = useState(false); - const state = useSelector((state: RootState) => state.state); - const { saveSession, getLastSessionId, loadLastSession } = - useHistory(dispatch); + const posthog = usePostHog(); + const dispatch = useDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const {streamResponse} = useChatHandler(dispatch, ideMessenger); + const onboardingCard = useOnboardingCard(); + const {showTutorialCard, closeTutorialCard} = useTutorialCard(); + const sessionState = useSelector((state: RootState) => state.state); + const defaultModel = useSelector(defaultModelSelector); + const ttsActive = useSelector((state: RootState) => state.state.ttsActive); + const active = useSelector((state: RootState) => state.state.active); + const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]); + const mainTextInputRef = useRef(null); + const topGuiDivRef = useRef(null); + const [isAtBottom, setIsAtBottom] = useState(false); + const state = useSelector((state: RootState) => state.state); + const {saveSession, getLastSessionId, loadLastSession} = + useHistory(dispatch); - useEffect(() => { - if (!active || !topGuiDivRef.current) return; + useEffect(() => { + if (!active || !topGuiDivRef.current) return; - const scrollAreaElement = topGuiDivRef.current; + const scrollAreaElement = topGuiDivRef.current; - scrollAreaElement.scrollTop = - scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight; + scrollAreaElement.scrollTop = + scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight; - setIsAtBottom(true); - }, [active]); + setIsAtBottom(true); + }, [active]); - useEffect(() => { - // Cmd + Backspace to delete current step - const listener = (e: any) => { - if ( - e.key === "Backspace" && - isMetaEquivalentKeyPressed(e) && - !e.shiftKey - ) { - dispatch(setInactive()); - } + useEffect(() => { + // Cmd + Backspace to delete current step + const listener = (e: any) => { + if ( + e.key === "Backspace" && + isMetaEquivalentKeyPressed(e) && + !e.shiftKey + ) { + dispatch(setInactive()); + } + }; + window.addEventListener("keydown", listener); + + return () => { + window.removeEventListener("keydown", listener); + }; + }, [active]); + + const handleScroll = () => { + // Temporary fix to account for additional height when code blocks are added + const OFFSET_HERUISTIC = 300; + if (!topGuiDivRef.current) return; + + const {scrollTop, scrollHeight, clientHeight} = topGuiDivRef.current; + const atBottom = + scrollHeight - clientHeight <= scrollTop + OFFSET_HERUISTIC; + + setIsAtBottom(atBottom); }; - window.addEventListener("keydown", listener); - return () => { - window.removeEventListener("keydown", listener); - }; - }, [active]); + const sendInput = useCallback( + (editorState: JSONContent, modifiers: InputModifiers) => { + if (defaultModel?.provider === "free-trial") { + const u = getLocalStorage("ftc"); + if (u) { + setLocalStorage("ftc", u + 1); - const handleScroll = () => { - // Temporary fix to account for additional height when code blocks are added - const OFFSET_HERUISTIC = 300; - if (!topGuiDivRef.current) return; - - const { scrollTop, scrollHeight, clientHeight } = topGuiDivRef.current; - const atBottom = - scrollHeight - clientHeight <= scrollTop + OFFSET_HERUISTIC; - - setIsAtBottom(atBottom); - }; - - const sendInput = useCallback( - (editorState: JSONContent, modifiers: InputModifiers) => { - if (defaultModel?.provider === "free-trial") { - const u = getLocalStorage("ftc"); - if (u) { - setLocalStorage("ftc", u + 1); - - if (u >= FREE_TRIAL_LIMIT_REQUESTS) { - onboardingCard.open("Best"); - posthog?.capture("ftc_reached"); - ideMessenger.ide.showToast( - "info", - "You've reached the free trial limit. Please configure a model to continue.", - ); - return; - } - } else { - setLocalStorage("ftc", 1); - } - } - - streamResponse(editorState, modifiers, ideMessenger); - - // Increment localstorage counter for popup - const currentCount = getLocalStorage("mainTextEntryCounter"); - if (currentCount) { - setLocalStorage("mainTextEntryCounter", currentCount + 1); - if (currentCount === 300) { - dispatch( - setDialogMessage( -
- 👋 Thanks for using Continue. We are always trying to improve - and love hearing from users. If you're interested in speaking, - enter your name and email. We won't use this information for - anything other than reaching out. -
-
-
{ - e.preventDefault(); - posthog?.capture("user_interest_form", { - name: e.target.elements[0].value, - email: e.target.elements[1].value, - }); - dispatch( - setDialogMessage( -
- Thanks! We'll be in touch soon. -
, - ), - ); - }} - style={{ - display: "flex", - flexDirection: "column", - gap: "10px", - }} - > - - - -
-
, - ), - ); - dispatch(setDialogEntryOn(false)); - dispatch(setShowDialog(true)); - } - } else { - setLocalStorage("mainTextEntryCounter", 1); - } - }, - [ - sessionState.history, - sessionState.contextItems, - defaultModel, - state, - streamResponse, - ], - ); - - useWebviewListener( - "newSession", - async () => { - saveSession(); - mainTextInputRef.current?.focus?.(); - }, - [saveSession], - ); - - const isLastUserInput = useCallback( - (index: number): boolean => { - return !state.history - .slice(index + 1) - .some((entry) => entry.message.role === "user"); - }, - [state.history], - ); - - return ( - <> - -
- - {state.history.map((item, index: number) => ( - - { - dispatch(newSession()); - }} - > - {item.message.role === "user" ? ( - { - streamResponse( - editorState, - modifiers, - ideMessenger, - index, + if (u >= FREE_TRIAL_LIMIT_REQUESTS) { + onboardingCard.open("Best"); + posthog?.capture("ftc_reached"); + ideMessenger.ide.showToast( + "info", + "You've reached the free trial limit. Please configure a model to continue.", ); - }} - isLastUserInput={isLastUserInput(index)} - isMainInput={false} - editorState={item.editorState} - contextItems={item.contextItems} + return; + } + } else { + setLocalStorage("ftc", 1); + } + } + + streamResponse(editorState, modifiers, ideMessenger); + + // Increment localstorage counter for popup + const currentCount = getLocalStorage("mainTextEntryCounter"); + if (currentCount) { + setLocalStorage("mainTextEntryCounter", currentCount + 1); + if (currentCount === 300) { + dispatch( + setDialogMessage( +
+ 👋 Thanks for using Continue. We are always trying to improve + and love hearing from users. If you're interested in speaking, + enter your name and email. We won't use this information for + anything other than reaching out. +
+
+
{ + e.preventDefault(); + posthog?.capture("user_interest_form", { + name: e.target.elements[0].value, + email: e.target.elements[1].value, + }); + dispatch( + setDialogMessage( +
+ Thanks! We'll be in touch soon. +
, + ), + ); + }} + style={{ + display: "flex", + flexDirection: "column", + gap: "10px", + }} + > + + + +
+
, + ), + ); + dispatch(setDialogEntryOn(false)); + dispatch(setShowDialog(true)); + } + } else { + setLocalStorage("mainTextEntryCounter", 1); + } + }, + [ + sessionState.history, + sessionState.contextItems, + defaultModel, + state, + streamResponse, + ], + ); + + useWebviewListener( + "newSession", + async () => { + saveSession(); + mainTextInputRef.current?.focus?.(); + }, + [saveSession], + ); + + const isLastUserInput = useCallback( + (index: number): boolean => { + return !state.history + .slice(index + 1) + .some((entry) => entry.message.role === "user"); + }, + [state.history], + ); + + return ( + <> + +
+ + {state.history.map((item, index: number) => ( + + { + dispatch(newSession()); + }} + > + {item.message.role === "user" ? ( + { + streamResponse( + editorState, + modifiers, + ideMessenger, + index, + ); + }} + isLastUserInput={isLastUserInput(index)} + isMainInput={false} + editorState={item.editorState} + contextItems={item.contextItems} + /> + ) : ( +
+ + ) : false ? ( + + ) : ( + + ) + } + open={ + typeof stepsOpen[index] === "undefined" + ? false + ? false + : true + : stepsOpen[index]! + } + onToggle={() => { + }} + > + { + }} + item={item} + onReverse={() => { + }} + onRetry={() => { + streamResponse( + state.history[index - 1].editorState, + state.history[index - 1].modifiers ?? + defaultInputModifiers, + ideMessenger, + index - 1, + ); + }} + onContinueGeneration={() => { + window.postMessage( + { + messageType: "userInput", + data: { + input: + "Continue your response exactly where you left off:", + }, + }, + "*", + ); + }} + onDelete={() => { + dispatch(deleteMessage(index)); + }} + modelTitle={item.promptLogs?.[0]?.modelTitle ?? ""} + /> + +
+ )} +
+
+ ))} +
+ +
- ) : null} - - {onboardingCard.show && ( -
- -
- )} - - {showTutorialCard !== false && !onboardingCard.open && ( -
- -
- )} - - )} -
- - -
- - {ttsActive && ( - { - ideMessenger.post("tts/kill", undefined); - }} - > - ■ Stop TTS - - )} - {active && ( - { - dispatch(setInactive()); - if ( - state.history[state.history.length - 1]?.message.content - .length === 0 - ) { - dispatch(clearLastResponse()); - } - }} - > - {getMetaKeyLabel()} ⌫ Cancel - - )} - - ); + > + ■ Stop TTS + + )} + {active && ( + { + dispatch(setInactive()); + if ( + state.history[state.history.length - 1]?.message.content + .length === 0 + ) { + dispatch(clearLastResponse()); + } + }} + > + {getMetaKeyLabel()} ⌫ Cancel + + )} + + ); } export default GUI; From c6ac7874ba46d3d0e40fca960de914e46d4c4604 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 9 Oct 2024 14:51:34 -0700 Subject: [PATCH 114/255] remove /so from config_schema --- docs/static/schemas/config.json | 26 +++---------------- .../src/main/resources/config_schema.json | 6 ++--- extensions/vscode/config_schema.json | 6 ++--- extensions/vscode/continue_rc_schema.json | 24 +++-------------- 4 files changed, 11 insertions(+), 51 deletions(-) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index c1b80c901..c1458bfc9 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -246,7 +246,7 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "anyOf":[ + "anyOf": [ { "enum": [ "us-east-1", @@ -258,7 +258,8 @@ "ap-southeast-1", "ap-northeast-1", "ap-south-1" - ] + ], + "type": "string" }, { "type": "string" @@ -1406,7 +1407,6 @@ "enum": [ "issue", "share", - "so", "cmd", "edit", "comment", @@ -1418,7 +1418,6 @@ "markdownEnumDescriptions": [ "Generate a link to a drafted GitHub issue", "Export the current chat session to markdown", - "Reference StackOverflow to answer the question", "Generate a terminal command and paste it into the terminal", "Edit the highlighted code with given instructions", "Add comments to the highlighted code", @@ -2202,24 +2201,7 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "anyOf":[ - { - "enum": [ - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", - "eu-west-1", - "eu-central-1", - "ap-southeast-1", - "ap-northeast-1", - "ap-south-1" - ] - }, - { - "type": "string" - } - ] + "$ref": "#/definitions/ModelDescription/properties/region" }, "profile": { "title": "Profile", diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 16321df00..c1458bfc9 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -246,7 +246,7 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "anyOf":[ + "anyOf": [ { "enum": [ "us-east-1", @@ -259,7 +259,7 @@ "ap-northeast-1", "ap-south-1" ], - "type" : "string" + "type": "string" }, { "type": "string" @@ -1407,7 +1407,6 @@ "enum": [ "issue", "share", - "so", "cmd", "edit", "comment", @@ -1419,7 +1418,6 @@ "markdownEnumDescriptions": [ "Generate a link to a drafted GitHub issue", "Export the current chat session to markdown", - "Reference StackOverflow to answer the question", "Generate a terminal command and paste it into the terminal", "Edit the highlighted code with given instructions", "Add comments to the highlighted code", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 16321df00..c1458bfc9 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -246,7 +246,7 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "anyOf":[ + "anyOf": [ { "enum": [ "us-east-1", @@ -259,7 +259,7 @@ "ap-northeast-1", "ap-south-1" ], - "type" : "string" + "type": "string" }, { "type": "string" @@ -1407,7 +1407,6 @@ "enum": [ "issue", "share", - "so", "cmd", "edit", "comment", @@ -1419,7 +1418,6 @@ "markdownEnumDescriptions": [ "Generate a link to a drafted GitHub issue", "Export the current chat session to markdown", - "Reference StackOverflow to answer the question", "Generate a terminal command and paste it into the terminal", "Edit the highlighted code with given instructions", "Add comments to the highlighted code", diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 7dba9328e..7acf7d709 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -261,7 +261,8 @@ "ap-southeast-1", "ap-northeast-1", "ap-south-1" - ] + ], + "type": "string" }, { "type": "string" @@ -1560,7 +1561,6 @@ "enum": [ "issue", "share", - "so", "cmd", "edit", "comment", @@ -1572,7 +1572,6 @@ "markdownEnumDescriptions": [ "Generate a link to a drafted GitHub issue", "Export the current chat session to markdown", - "Reference StackOverflow to answer the question", "Generate a terminal command and paste it into the terminal", "Edit the highlighted code with given instructions", "Add comments to the highlighted code", @@ -2448,24 +2447,7 @@ "region": { "title": "Region", "description": "The region where the model is hosted", - "anyOf": [ - { - "enum": [ - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", - "eu-west-1", - "eu-central-1", - "ap-southeast-1", - "ap-northeast-1", - "ap-south-1" - ] - }, - { - "type": "string" - } - ] + "$ref": "#/definitions/ModelDescription/properties/region" }, "profile": { "title": "Profile", From 6a075813585cc2c9605c2ca0765276fceaa091b4 Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 9 Oct 2024 18:00:44 -0700 Subject: [PATCH 115/255] WIP --- .idea/gradle.xml | 1 - .../editor/DiffStreamHandler.kt | 475 +++++++++--------- .../editor/InlineEditAction.kt | 14 +- .../editor/VerticalDiffActionButtons.kt | 63 +-- .../vscode/src/diff/vertical/handler.ts | 11 +- manual-testing-sandbox/.idea/vcs.xml | 6 + 6 files changed, 286 insertions(+), 284 deletions(-) create mode 100644 manual-testing-sandbox/.idea/vcs.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6733405f9..1d937028b 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -5,7 +5,6 @@
+

Config Errors

Please resolve the following errors in your config.json file.

- {configError && configError.errors.length > 0 ? ( + {configError && configError.length > 0 ? (