From 1c1ab88effbf46ae83c4c7e97cd185bf8f1c5e68 Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 21 Dec 2024 23:23:09 +0800 Subject: [PATCH 01/42] refactor: Adjust inlay rendering and improve completion logic - Replace `ContinueCustomElementRenderer` and `ContinueMultilineCustomElementRenderer` with `ContinueInlayRenderer`. - Add `Editor.addInlayElement` to handle inline and block inlay elements. - Refactor `AutocompleteService` to use new inlay renderer and improve completion rendering conditions. - Update `AcceptAutocompleteAction` to match new changes. --- .../autocomplete/AcceptAutocompleteAction.kt | 2 +- .../autocomplete/AutocompleteService.kt | 92 ++++++++++--------- .../ContinueCustomElementRenderer.kt | 45 --------- .../autocomplete/ContinueInlayRenderer.kt | 58 ++++++++++++ .../ContinueMultilineCustomElementRenderer.kt | 81 ---------------- 5 files changed, 107 insertions(+), 171 deletions(-) delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt index 45fb3b597..03b91e87c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt @@ -22,4 +22,4 @@ class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { && autocompleteService.pendingCompletion?.text != null return enabled } -}) {} \ No newline at end of file +}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 6279e03f7..8be92742c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -10,8 +10,10 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.service import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.InlayProperties +import com.intellij.openapi.editor.impl.EditorImpl import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project +import com.intellij.openapi.util.TextRange import com.intellij.openapi.wm.WindowManager import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement @@ -32,9 +34,24 @@ fun PsiElement.isInjectedText(): Boolean { return false } +fun Editor.addInlayElement( + lines: List, + offset: Int, + properties: InlayProperties +) { + if (this is EditorImpl) { + if (lines[0].isNotEmpty()) { + inlayModel.addInlineElement(offset, properties, ContinueInlayRenderer(listOf(lines[0]))) + } + if (lines.size > 1) { + inlayModel.addBlockElement(offset, properties, ContinueInlayRenderer(lines.drop(1))) + } + } +} + @Service(Service.Level.PROJECT) class AutocompleteService(private val project: Project) { - var pendingCompletion: PendingCompletion? = null; + var pendingCompletion: PendingCompletion? = null private val autocompleteLookupListener = project.service() private var widget: AutocompleteSpinnerWidget? = null @@ -66,12 +83,13 @@ class AutocompleteService(private val project: Project) { // Request a completion from the core val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) + val line = editor.caretModel.primaryCaret.logicalPosition.line val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.url, + "filepath" to virtualFile?.path, "pos" to mapOf( - "line" to editor.caretModel.primaryCaret.logicalPosition.line, + "line" to line, "character" to column ), "recentlyEditedFiles" to emptyList(), @@ -79,10 +97,6 @@ class AutocompleteService(private val project: Project) { "clipboardText" to "" ) - val lineStart = editor.document.getLineStartOffset(editor.caretModel.primaryCaret.logicalPosition.line) - val lineEnd = editor.document.getLineEndOffset(editor.caretModel.primaryCaret.logicalPosition.line) - val lineLength = lineEnd - lineStart - project.service().coreMessenger?.request( "autocomplete/complete", input, @@ -95,9 +109,8 @@ class AutocompleteService(private val project: Project) { val completion = completions[0].toString() val finalTextToInsert = deduplicateCompletion(editor, offset, completion) - if (shouldRenderCompletion(finalTextToInsert, column, lineLength, editor)) { + if (shouldRenderCompletion(finalTextToInsert, offset, line, editor)) { renderCompletion(editor, offset, finalTextToInsert) - pendingCompletion = PendingCompletion(editor, offset, completionId, finalTextToInsert) // Hide auto-popup // AutoPopupController.getInstance(project).cancelAllRequests() } @@ -106,13 +119,19 @@ class AutocompleteService(private val project: Project) { ) } - private fun shouldRenderCompletion(completion: String, column: Int, lineLength: Int, editor: Editor): Boolean { - if (completion.isEmpty()) { + private fun shouldRenderCompletion(completion: String, offset: Int, line: Int, editor: Editor): Boolean { + if (completion.isEmpty() || runReadAction { offset != editor.caretModel.offset }) { return false } + if (completion.lines().size == 1) { + return true + } + + val endOffset = editor.document.getLineEndOffset(line) + // Do not render if completion is multi-line and caret is in middle of line - return !(completion.lines().size > 1 && column < lineLength) + return offset <= endOffset && editor.document.getText(TextRange(offset, endOffset)).isBlank() } private fun deduplicateCompletion(editor: Editor, offset: Int, completion: String): String { @@ -122,9 +141,9 @@ class AutocompleteService(private val project: Project) { val caretOffset = editor.caretModel.offset val N = 10 var textAfterCursor = if (caretOffset + N <= document.textLength) { - document.getText(com.intellij.openapi.util.TextRange(caretOffset, caretOffset + N)) + document.getText(TextRange(caretOffset, caretOffset + N)) } else { - document.getText(com.intellij.openapi.util.TextRange(caretOffset, document.textLength)) + document.getText(TextRange(caretOffset, document.textLength)) } // Determine the index of a newline character within the text following the cursor. @@ -164,19 +183,9 @@ class AutocompleteService(private val project: Project) { properties.relatesToPrecedingText(true) properties.disableSoftWrapping(true) - if (completion.lines().size > 1) { - editor.inlayModel.addBlockElement( - offset, - properties, - ContinueMultilineCustomElementRenderer(editor, completion) - ) - } else { - editor.inlayModel.addInlineElement( - offset, - properties, - ContinueCustomElementRenderer(editor, completion) - ) - } + val lines = completion.lines() + pendingCompletion = pendingCompletion?.copy(text = lines.joinToString("\n")) + editor.addInlayElement(lines, offset, properties) // val attributes = TextAttributes().apply { // backgroundColor = JBColor.GREEN @@ -204,7 +213,7 @@ class AutocompleteService(private val project: Project) { ({}) ) invokeLater { - clearCompletions(editor) + clearCompletions(editor, completion) } } @@ -267,23 +276,14 @@ class AutocompleteService(private val project: Project) { project.service().coreMessenger?.request("autocomplete/cancel", null, null, ({})) } - fun clearCompletions(editor: Editor) { + fun clearCompletions(editor: Editor, completion: PendingCompletion? = pendingCompletion) { if (isInjectedFile(editor)) return - if (pendingCompletion != null) { - cancelCompletion(pendingCompletion!!) - pendingCompletion = null - } - editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueCustomElementRenderer) { - it.dispose() - } - } - editor.inlayModel.getBlockElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueMultilineCustomElementRenderer) { - it.dispose() - } + if (completion != null) { + cancelCompletion(completion) + if (completion.completionId == pendingCompletion?.completionId) pendingCompletion = null } + disposeInlayRenderer(editor) } private fun isInjectedFile(editor: Editor): Boolean { @@ -298,13 +298,17 @@ class AutocompleteService(private val project: Project) { fun hideCompletions(editor: Editor) { if (isInjectedFile(editor)) return + disposeInlayRenderer(editor) + } + + private fun disposeInlayRenderer(editor: Editor) { editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueCustomElementRenderer) { + if (it.renderer is ContinueInlayRenderer) { it.dispose() } } editor.inlayModel.getBlockElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueMultilineCustomElementRenderer) { + if (it.renderer is ContinueInlayRenderer) { it.dispose() } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt deleted file mode 100644 index bfaeedb2d..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.EditorCustomElementRenderer -import com.intellij.openapi.editor.Inlay -import com.intellij.openapi.editor.colors.EditorFontType -import com.intellij.openapi.editor.impl.EditorImpl -import com.intellij.openapi.editor.impl.FontInfo -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.ui.JBColor -import com.intellij.util.ui.UIUtil -import java.awt.Font -import java.awt.Graphics -import java.awt.Rectangle -import kotlin.math.ceil - -class ContinueCustomElementRenderer( - val editor: Editor, - val text: String, -) : EditorCustomElementRenderer { - override fun calcWidthInPixels(inlay: Inlay<*>): Int { - val width = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(this.text) - return width - } - - private fun font(editor: Editor): Font { - val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) - return UIUtil.getFontWithFallbackIfNeeded(editorFont, text).deriveFont(editor.colorsScheme.editorFontSize) - } - - private fun offsetY(editor: Editor): Int { - val metrics = - FontInfo.getFontMetrics(font(editor), FontInfo.getFontRenderContext(editor.contentComponent)) - val fontHeight = - font(editor).createGlyphVector(metrics.fontRenderContext, text).visualBounds.height - val height = (editor.lineHeight + fontHeight) / 2 - return ceil(height).toInt() - } - - override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { - g.color = JBColor.GRAY - g.font = font(inlay.editor) - g.drawString(this.text, targetRegion.x, targetRegion.y + inlay.editor.ascent) - } -} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt new file mode 100644 index 000000000..bcf37fa20 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt @@ -0,0 +1,58 @@ +package com.github.continuedev.continueintellijextension.autocomplete + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.EditorCustomElementRenderer +import com.intellij.openapi.editor.Inlay +import com.intellij.openapi.editor.colors.EditorFontType +import com.intellij.openapi.editor.impl.EditorImpl +import com.intellij.openapi.editor.markup.TextAttributes +import com.intellij.ui.JBColor +import com.intellij.util.ui.UIUtil +import java.awt.Font +import java.awt.Graphics +import java.awt.Rectangle + +/** + * The `ContinueInlayRenderer` class is responsible for rendering custom inlay elements within an editor. + * It implements the [EditorCustomElementRenderer] interface to provide custom rendering logic for inlays. + * + * This renderer is designed to display a list of text lines (`lines`) within the editor, calculating the + * necessary width and height based on the content and rendering each line with appropriate font and color. + * + * @author lk + */ +class ContinueInlayRenderer(val lines: List) : EditorCustomElementRenderer { + override fun calcWidthInPixels(inlay: Inlay<*>): Int { + var maxLen = 0; + for (line in lines) { + val len = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(line) + if (len > maxLen) { + maxLen = len + } + } + return maxLen + } + + override fun calcHeightInPixels(inlay: Inlay<*>): Int { + return (inlay.editor as EditorImpl).lineHeight * lines.size + } + + private fun font(editor: Editor): Font { + val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) + return UIUtil.getFontWithFallbackIfNeeded(editorFont, lines.joinToString("\n")) + .deriveFont(editor.colorsScheme.editorFontSize) + } + + override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { + val editor = inlay.editor + g.color = JBColor.GRAY + g.font = font(editor) + var additionalYOffset = 0 + val ascent = editor.ascent + val lineHeight = editor.lineHeight + for (line in lines) { + g.drawString(line, targetRegion.x, targetRegion.y + ascent + additionalYOffset) + additionalYOffset += lineHeight + } + } +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt deleted file mode 100644 index a24b2453a..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.EditorCustomElementRenderer -import com.intellij.openapi.editor.Inlay -import com.intellij.openapi.editor.colors.EditorFontType -import com.intellij.openapi.editor.impl.EditorImpl -import com.intellij.openapi.editor.impl.FontInfo -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.ui.JBColor -import com.intellij.util.ui.UIUtil -import java.awt.Font -import java.awt.Graphics -import java.awt.Rectangle -import kotlin.math.ceil -import kotlin.math.max - -class ContinueMultilineCustomElementRenderer( - val editor: Editor, - val text: String, -) : EditorCustomElementRenderer { - override fun calcWidthInPixels(inlay: Inlay<*>): Int { - val lines = text.lines() - var maxLen = 0; - for (line in lines) { - val len = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(line) - if (len > maxLen) { - maxLen = len - } - } - return maxLen - } - - override fun calcHeightInPixels(inlay: Inlay<*>): Int { - return (inlay.editor as EditorImpl).lineHeight * text.lines().size - } - - protected val font: Font - get() { - val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) - return UIUtil.getFontWithFallbackIfNeeded(editorFont, text).deriveFont(editor.colorsScheme.editorFontSize) - } - - private fun offsetY(): Int { - val metrics = - FontInfo.getFontMetrics(font, FontInfo.getFontRenderContext(editor.contentComponent)) - val fontHeight = - font.createGlyphVector(metrics.fontRenderContext, text).visualBounds.height - val height = (editor.lineHeight + fontHeight) / 2 - return ceil(height).toInt() - } - - private fun offsetX(): Int { - val currentLine = editor.caretModel.primaryCaret.logicalPosition.line - val currentColumn = editor.caretModel.primaryCaret.logicalPosition.column - val metrics = - FontInfo.getFontMetrics(font, FontInfo.getFontRenderContext(editor.contentComponent)) - val fontWidth = - font.createGlyphVector(metrics.fontRenderContext, text).visualBounds.width - val widthBeforeCaret = (editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth( - text.substring(0, minOf(currentColumn, text.length)) - ) - return max(0, widthBeforeCaret - (editor as EditorImpl).scrollingModel.horizontalScrollOffset) - } - - override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { - g.color = JBColor.GRAY - g.font = font - var additionalYOffset = -editor.lineHeight; - var isFirstLine = true - for (line in text.lines()) { - g.drawString( - line, - if (isFirstLine) targetRegion.x + offsetX() else targetRegion.x, - targetRegion.y + inlay.editor.ascent + additionalYOffset - ) - additionalYOffset += editor.lineHeight - isFirstLine = false - } - } -} \ No newline at end of file From 3df34b725e873fcd42058474d83ef634e21d5cad Mon Sep 17 00:00:00 2001 From: liuk Date: Wed, 25 Dec 2024 01:11:38 +0800 Subject: [PATCH 02/42] fix: Revert filepath changes --- .../autocomplete/AutocompleteService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 8be92742c..e7a1fb830 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -87,7 +87,7 @@ class AutocompleteService(private val project: Project) { val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.path, + "filepath" to virtualFile?.url, "pos" to mapOf( "line" to line, "character" to column From 0a7da2067e8d8567084d05f69038b7ca95464d1f Mon Sep 17 00:00:00 2001 From: liuk Date: Thu, 26 Dec 2024 19:46:53 +0800 Subject: [PATCH 03/42] fix: Resolved errors related to incorrect URIs --- .../activities/ContinuePluginStartupActivity.kt | 8 ++++---- .../autocomplete/AutocompleteService.kt | 6 +++++- .../continue/IdeProtocolClient.kt | 14 ++++++++------ .../continue/IntelliJIde.kt | 13 +++++++------ .../continueintellijextension/utils/Utils.kt | 5 ++++- 5 files changed, 28 insertions(+), 18 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 facc89424..72819421a 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 @@ -10,7 +10,7 @@ import com.github.continuedev.continueintellijextension.listeners.ContinuePlugin import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.github.continuedev.continueintellijextension.services.SettingsListener -import com.intellij.openapi.Disposable +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.intellij.openapi.actionSystem.KeyboardShortcut import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationNamesInfo @@ -162,7 +162,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { override fun after(events: List) { // Collect all relevant URIs for deletions val deletedURIs = events.filterIsInstance() - .map { event -> event.file.url } + .mapNotNull { event -> event.file.toUriOrNull() } // Send "files/deleted" message if there are any deletions if (deletedURIs.isNotEmpty()) { @@ -172,7 +172,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { // Collect all relevant URIs for content changes val changedURIs = events.filterIsInstance() - .map { event -> event.file.url } + .mapNotNull { event -> event.file.toUriOrNull() } // Send "files/changed" message if there are any content changes if (changedURIs.isNotEmpty()) { @@ -220,7 +220,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { // Reload the WebView continuePluginService?.let { pluginService -> val allModulePaths = ModuleManager.getInstance(project).modules - .flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.map { it.url } } + .flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.mapNotNull { it.toUriOrNull() } } val topLevelModulePaths = allModulePaths .filter { modulePath -> allModulePaths.none { it != modulePath && modulePath.startsWith(it) } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index e7a1fb830..2941aae8e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.autocomplete import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.github.continuedev.continueintellijextension.utils.uuid import com.intellij.injected.editor.VirtualFileWindow import com.intellij.openapi.application.* @@ -83,11 +84,14 @@ class AutocompleteService(private val project: Project) { // Request a completion from the core val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) + + val uri = virtualFile?.toUriOrNull() ?: return + val line = editor.caretModel.primaryCaret.logicalPosition.line val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.url, + "filepath" to uri, "pos" to mapOf( "line" to line, "character" to column 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 69e06e89e..43ee85e29 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 @@ -546,12 +546,14 @@ class IdeProtocolClient( val startChar = startOffset - document.getLineStartOffset(startLine) val endChar = endOffset - document.getLineStartOffset(endLine) - return@runReadAction RangeInFileWithContents( - virtualFile.url, Range( - Position(startLine, startChar), - Position(endLine, endChar) - ), selectedText - ) + return@runReadAction virtualFile.toUriOrNull()?.let { + RangeInFileWithContents( + it, Range( + Position(startLine, startChar), + Position(endLine, endChar) + ), selectedText + ) + } } return result diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 154476f5e..39d7b3681 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -5,6 +5,7 @@ import com.github.continuedev.continueintellijextension.services.ContinuePluginS import com.github.continuedev.continueintellijextension.utils.OS import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID import com.github.continuedev.continueintellijextension.utils.getOS +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil @@ -180,7 +181,7 @@ class IntelliJIDE( for (workspaceDir in workspaceDirs) { val dir = VirtualFileManager.getInstance().findFileByUrl(workspaceDir) if (dir != null) { - val contents = dir.children.map { it.url } + val contents = dir.children.mapNotNull { it.toUriOrNull() } // Find any .continuerc.json files for (file in contents) { @@ -307,16 +308,16 @@ class IntelliJIDE( override suspend fun getOpenFiles(): List { val fileEditorManager = FileEditorManager.getInstance(project) - return fileEditorManager.openFiles.map { it.url }.toList() + return fileEditorManager.openFiles.mapNotNull { it.toUriOrNull() }.toList() } override suspend fun getCurrentFile(): Map? { val fileEditorManager = FileEditorManager.getInstance(project) val editor = fileEditorManager.selectedTextEditor val virtualFile = editor?.document?.let { FileDocumentManager.getInstance().getFile(it) } - return virtualFile?.let { + return virtualFile?.toUriOrNull()?.let { mapOf( - "path" to it.url, + "path" to it, "contents" to editor.document.text, "isUntitled" to false ) @@ -382,7 +383,7 @@ class IntelliJIDE( problems.add( Problem( - filepath = psiFile.virtualFile?.url ?: "", + filepath = psiFile.virtualFile?.toUriOrNull() ?: "", range = Range( start = Position( line = startLineNumber, @@ -561,6 +562,6 @@ class IntelliJIDE( return dirs } - return listOfNotNull(project.guessProjectDir()?.url).toTypedArray() + return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray() } } \ No newline at end of file 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 fe29b6235..7e90ba99e 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 @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.utils +import com.intellij.openapi.vfs.VirtualFile import java.net.NetworkInterface import java.util.* import java.awt.event.KeyEvent.* @@ -77,4 +78,6 @@ fun getMachineUniqueID(): String { fun uuid(): String { return UUID.randomUUID().toString() -} \ No newline at end of file +} + +fun VirtualFile.toUriOrNull(): String? = fileSystem.getNioPath(this)?.toUri()?.toString()?.removeSuffix("/") \ No newline at end of file From d597e6fe5ea632f2bdf762ad2555c056fd736ba8 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 26 Dec 2024 15:53:35 -0600 Subject: [PATCH 04/42] feat: create RecentFilesService --- .../context/ContextRetrievalService.ts | 7 ++ .../context/RecentFilesService.ts | 119 ++++++++++++++++++ core/autocomplete/snippets/getAllSnippets.ts | 5 + 3 files changed, 131 insertions(+) create mode 100644 core/autocomplete/context/RecentFilesService.ts diff --git a/core/autocomplete/context/ContextRetrievalService.ts b/core/autocomplete/context/ContextRetrievalService.ts index 72e061fed..f372456be 100644 --- a/core/autocomplete/context/ContextRetrievalService.ts +++ b/core/autocomplete/context/ContextRetrievalService.ts @@ -7,11 +7,13 @@ import { HelperVars } from "../util/HelperVars"; import { ImportDefinitionsService } from "./ImportDefinitionsService"; import { getSymbolsForSnippet } from "./ranking"; +import { RecentFilesService } from "./RecentFilesService"; import { RootPathContextService } from "./root-path-context/RootPathContextService"; export class ContextRetrievalService { private importDefinitionsService: ImportDefinitionsService; private rootPathContextService: RootPathContextService; + private recentFilesService: RecentFilesService; constructor(private readonly ide: IDE) { this.importDefinitionsService = new ImportDefinitionsService(this.ide); @@ -19,6 +21,7 @@ export class ContextRetrievalService { this.importDefinitionsService, this.ide, ); + this.recentFilesService = new RecentFilesService(this.ide); } public async getSnippetsFromImportDefinitions( @@ -70,4 +73,8 @@ export class ContextRetrievalService { helper.treePath, ); } + + public async getRecentFileSnippets(): Promise { + return this.recentFilesService.getSnippets(); + } } diff --git a/core/autocomplete/context/RecentFilesService.ts b/core/autocomplete/context/RecentFilesService.ts new file mode 100644 index 000000000..b5a8f34c6 --- /dev/null +++ b/core/autocomplete/context/RecentFilesService.ts @@ -0,0 +1,119 @@ +import { LRUCache } from "lru-cache"; +import Parser from "web-tree-sitter"; + +import { IDE } from "../.."; +import { + getFullLanguageName, + getParserForFile, + getQueryForFile, +} from "../../util/treeSitter"; +import { + AutocompleteCodeSnippet, + AutocompleteSnippetType, +} from "../snippets/types"; + +const DEFAULT_NUM_RECENT_FILES = 5; + +export class RecentFilesService { + private cache: LRUCache; + private numRecentFiles: number; + + constructor( + private readonly ide: IDE, + numRecentFiles = DEFAULT_NUM_RECENT_FILES, + ) { + this.numRecentFiles = numRecentFiles; + this.cache = new LRUCache({ + max: this.numRecentFiles, + }); + + this.ide.onDidChangeActiveTextEditor((filepath) => { + void this.onFileOpened(filepath); + }); + } + + private async onFileOpened(filepath: string) { + // Remove from cache if already present to update its position + if (this.cache.has(filepath)) { + this.cache.delete(filepath); + } + + // Get function signatures from the file + const snippets = await this.getFunctionSignatures(filepath); + + if (snippets.length > 0) { + // Store in cache + this.cache.set(filepath, snippets); + } + } + + private async getFunctionSignatures( + filepath: string, + ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; + + const parser = await getParserForFile(filepath); + if (!parser) { + return snippets; + } + + let fileContents: string; + try { + fileContents = await this.ide.readFile(filepath); + } catch (err) { + // File might have been deleted or inaccessible + return snippets; + } + + const ast = parser.parse(fileContents); + const language = getFullLanguageName(filepath); + const query = await getQueryForFile( + filepath, + `code-snippet-queries/${language}.scm`, + ); + + if (!query) { + return snippets; + } + + const matches = query.matches(ast.rootNode); + if (!matches) { + return snippets; + } + + return matches + .map((match) => this.getSnippetFromMatch(match, filepath)) + .filter( + (snippet): snippet is AutocompleteCodeSnippet => snippet !== null, + ); + } + + private getSnippetFromMatch( + match: Parser.QueryMatch, + filepath: string, + ): AutocompleteCodeSnippet | null { + // We only care about the function signature/declaration, not the body + for (const { name, node } of match.captures) { + // Skip function bodies, we only want the signature + // if (name.includes("body") || node.type.includes("body")) { + // continue; + // } + + return { + filepath, + content: node.text.trim(), + type: AutocompleteSnippetType.Code, + }; + } + + return null; + } + + public getSnippets(): AutocompleteCodeSnippet[] { + const allSnippets: AutocompleteCodeSnippet[] = []; + for (const snippets of this.cache.values()) { + allSnippets.push(...snippets); + } + return allSnippets; + } +} diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts index 5ff4a7d60..a663c0dde 100644 --- a/core/autocomplete/snippets/getAllSnippets.ts +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -3,6 +3,7 @@ import { findUriInDirs } from "../../util/uri"; import { ContextRetrievalService } from "../context/ContextRetrievalService"; import { GetLspDefinitionsFunction } from "../types"; import { HelperVars } from "../util/HelperVars"; + import { AutocompleteClipboardSnippet, AutocompleteCodeSnippet, @@ -17,6 +18,7 @@ export interface SnippetPayload { recentlyEditedRangeSnippets: AutocompleteCodeSnippet[]; diffSnippets: AutocompleteDiffSnippet[]; clipboardSnippets: AutocompleteClipboardSnippet[]; + recentFileSnippets: AutocompleteCodeSnippet[]; } function racePromise(promise: Promise): Promise { @@ -118,6 +120,7 @@ export const getAllSnippets = async ({ ideSnippets, diffSnippets, clipboardSnippets, + recentFileSnippets, ] = await Promise.all([ racePromise(contextRetrievalService.getRootPathSnippets(helper)), racePromise( @@ -126,6 +129,7 @@ export const getAllSnippets = async ({ racePromise(getIdeSnippets(helper, ide, getDefinitionsFromLsp)), racePromise(getDiffSnippets(ide)), racePromise(getClipboardSnippets(ide)), + racePromise(contextRetrievalService.getRecentFileSnippets()), ]); return { @@ -135,5 +139,6 @@ export const getAllSnippets = async ({ recentlyEditedRangeSnippets, diffSnippets, clipboardSnippets, + recentFileSnippets, }; }; From a005aa78ac75ac47be3e647e9e23b45eab7dafaf Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 27 Dec 2024 14:48:23 -0600 Subject: [PATCH 05/42] fix: disable indexing for unsupported CPUs --- core/config/load.ts | 11 ++++- core/config/util.ts | 76 +++++++++++++++++++++++++++++ core/util/GlobalContext.ts | 1 + extensions/vscode/package-lock.json | 4 +- 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 99c701141..4e21a7c60 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -46,6 +46,8 @@ import CustomLLMClass from "../llm/llms/CustomLLM"; import FreeTrial from "../llm/llms/FreeTrial"; import { LLMReranker } from "../llm/llms/llm"; import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider"; +import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile"; +import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles"; import { allTools } from "../tools"; import { copyOf } from "../util"; import { GlobalContext } from "../util/GlobalContext"; @@ -61,8 +63,6 @@ import { getEsbuildBinaryPath, } from "../util/paths"; -import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile"; -import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles"; import { defaultContextProvidersJetBrains, defaultContextProvidersVsCode, @@ -70,6 +70,7 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; +import { isSupportedLanceDbCpuTarget } from "./util"; import { ConfigValidationError, validateConfig } from "./validation.js"; export interface ConfigResult { @@ -112,6 +113,7 @@ function loadSerializedConfig( ideSettings: IdeSettings, ideType: IdeType, overrideConfigJson: SerializedContinueConfig | undefined, + ide: IDE ): ConfigResult { const configPath = getConfigJsonPath(ideType); let config: SerializedContinueConfig = overrideConfigJson!; @@ -174,6 +176,10 @@ function loadSerializedConfig( ? [...defaultSlashCommandsVscode] : [...defaultSlashCommandsJetBrains]; + if (!isSupportedLanceDbCpuTarget(ide)) { + config.disableIndexing = true; + } + return { config, errors, configLoadInterrupted: false }; } @@ -767,6 +773,7 @@ async function loadFullConfigNode( ideSettings, ideType, overrideConfigJson, + ide ); if (!serialized || configLoadInterrupted) { diff --git a/core/config/util.ts b/core/config/util.ts index 0247aa25d..100773f4b 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -1,10 +1,15 @@ +import { execSync } from "child_process"; +import os from "os"; + import { ContextProviderWithParams, ContinueConfig, + IDE, ILLM, ModelDescription, ModelRoles, } from "../"; +import { GlobalContext } from "../util/GlobalContext"; import { editConfigJson } from "../util/paths"; function stringify(obj: any, indentation?: number): string { @@ -96,3 +101,74 @@ export function getModelByRole( return matchingModel; } + +// https://github.com/continuedev/continue/issues/940 +export async function isSupportedLanceDbCpuTarget(ide: IDE) { + const globalContext = new GlobalContext(); + const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget"); + + // If we've already checked the CPU target, return the cached value + if (globalContextVal !== undefined) { + return globalContextVal; + } + + const arch = os.arch(); + const platform = os.platform(); + + //https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311 + // Only applies to x64 + if (arch !== "x64") { + return true; + } + + try { + const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const; + + const cpuFlags = (() => { + switch (platform) { + case "darwin": + return execSync("sysctl -n machdep.cpu.features") + .toString() + .toLowerCase(); + case "linux": + return execSync("cat /proc/cpuinfo").toString().toLowerCase(); + case "win32": + return execSync("wmic cpu get caption /format:list") + .toString() + .toLowerCase(); + default: + return ""; + } + })(); + + // TODO: Remvoe ! + const isSupportedLanceDbCpuTarget = cpuFlags + ? !CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature)) + : true; + + // If it's not a supported CPU target, and it's the first time we are checking, + // show a toast to inform the user that we are going to disable indexing. + if (!isSupportedLanceDbCpuTarget) { + const shouldOpenLink = await ide.showToast( + "warning", + "Cdoebase indexing is disabled due to CPU incompatibility", + "View details", + ); + + if (shouldOpenLink) { + // TODO + void ide.openUrl("https://continue.dev"); + } + } + + globalContext.update( + "isSupportedLanceDbCpuTarget", + isSupportedLanceDbCpuTarget, + ); + + return isSupportedLanceDbCpuTarget; + } catch (error) { + // If we can't determine CPU features, default to true + return true; + } +} diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 1095234d8..a4eb66f81 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -16,6 +16,7 @@ export type GlobalContextType = { hasDismissedConfigTsNoticeJetBrains: boolean; hasAlreadyCreatedAPromptFile: boolean; showConfigUpdateToast: boolean; + isSupportedLanceDbCpuTarget: boolean; }; /** diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8f5cad8a0..0a2dd8330 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", From 5d95b62e683c0ea50eb519f7cc2851736e8ee64b Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 27 Dec 2024 15:34:49 -0600 Subject: [PATCH 06/42] feat: show disableIndexing in More --- core/config/load.ts | 8 +--- core/config/util.ts | 44 ++++++++++++------- .../indexing/DocsIndexingStatus.tsx | 19 ++++---- .../indexing/DocsIndexingStatuses.tsx | 4 +- .../IndexingProgress/IndexingProgress.tsx | 2 +- .../IndexingProgressIndicator.tsx | 9 ++-- gui/src/pages/More/More.tsx | 14 +++++- 7 files changed, 59 insertions(+), 41 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 4e21a7c60..37e707bd4 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -113,7 +113,7 @@ function loadSerializedConfig( ideSettings: IdeSettings, ideType: IdeType, overrideConfigJson: SerializedContinueConfig | undefined, - ide: IDE + ide: IDE, ): ConfigResult { const configPath = getConfigJsonPath(ideType); let config: SerializedContinueConfig = overrideConfigJson!; @@ -135,10 +135,6 @@ function loadSerializedConfig( }; } - if (config.allowAnonymousTelemetry === undefined) { - config.allowAnonymousTelemetry = true; - } - if (config.ui?.getChatTitles === undefined) { config.ui = { ...config.ui, @@ -773,7 +769,7 @@ async function loadFullConfigNode( ideSettings, ideType, overrideConfigJson, - ide + ide, ); if (!serialized || configLoadInterrupted) { diff --git a/core/config/util.ts b/core/config/util.ts index 100773f4b..a118fd001 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -102,8 +102,15 @@ export function getModelByRole( return matchingModel; } -// https://github.com/continuedev/continue/issues/940 -export async function isSupportedLanceDbCpuTarget(ide: IDE) { +/** + * This check is to determine if the user is on an unsupported CPU + * target for our Lance DB binaries. + * + * See here for details: https://github.com/continuedev/continue/issues/940 + */ +export function isSupportedLanceDbCpuTarget(ide: IDE) { + const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const; + const globalContext = new GlobalContext(); const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget"); @@ -115,15 +122,14 @@ export async function isSupportedLanceDbCpuTarget(ide: IDE) { const arch = os.arch(); const platform = os.platform(); + // This check only applies to x64 //https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311 - // Only applies to x64 if (arch !== "x64") { + globalContext.update("isSupportedLanceDbCpuTarget", true); return true; } try { - const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const; - const cpuFlags = (() => { switch (platform) { case "darwin": @@ -141,24 +147,16 @@ export async function isSupportedLanceDbCpuTarget(ide: IDE) { } })(); - // TODO: Remvoe ! const isSupportedLanceDbCpuTarget = cpuFlags - ? !CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature)) + ? CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature)) : true; // If it's not a supported CPU target, and it's the first time we are checking, // show a toast to inform the user that we are going to disable indexing. if (!isSupportedLanceDbCpuTarget) { - const shouldOpenLink = await ide.showToast( - "warning", - "Cdoebase indexing is disabled due to CPU incompatibility", - "View details", - ); - - if (shouldOpenLink) { - // TODO - void ide.openUrl("https://continue.dev"); - } + // We offload our async toast to `showUnsupportedCpuToast` to prevent making + // our config loading async upstream of `isSupportedLanceDbCpuTarget` + void showUnsupportedCpuToast(ide); } globalContext.update( @@ -172,3 +170,15 @@ export async function isSupportedLanceDbCpuTarget(ide: IDE) { return true; } } + +async function showUnsupportedCpuToast(ide: IDE) { + const shouldOpenLink = await ide.showToast( + "warning", + "Codebase indexing is disabled due to CPU incompatibility", + "Learn more", + ); + + if (shouldOpenLink) { + void ide.openUrl("https://github.com/continuedev/continue/pull/3551"); + } +} diff --git a/gui/src/components/indexing/DocsIndexingStatus.tsx b/gui/src/components/indexing/DocsIndexingStatus.tsx index 12627dff5..b1b0f1df7 100644 --- a/gui/src/components/indexing/DocsIndexingStatus.tsx +++ b/gui/src/components/indexing/DocsIndexingStatus.tsx @@ -78,10 +78,11 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) { if (!status) { return 0; } - return Math.min(100, Math.max(0, status.progress * 100)); + return Math.min(100, Math.max(0, status.progress * 100)).toFixed(0); }, [status?.progress]); const Icon = STATUS_TO_ICON[status?.status]; + const showProgressPercentage = progressPercentage !== "100"; if (hasDeleted) return null; @@ -115,7 +116,15 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
Pending...
) : (
- {progressPercentage.toFixed(0)}% + {showProgressPercentage && ( + {progressPercentage}% + )} + {status?.status !== "indexing" ? ( + + ) : null} {Icon ? ( ) : null} - {status?.status !== "indexing" ? ( - - ) : null}
)} diff --git a/gui/src/components/indexing/DocsIndexingStatuses.tsx b/gui/src/components/indexing/DocsIndexingStatuses.tsx index 445c4db93..dabbe0032 100644 --- a/gui/src/components/indexing/DocsIndexingStatuses.tsx +++ b/gui/src/components/indexing/DocsIndexingStatuses.tsx @@ -13,10 +13,10 @@ function DocsIndexingStatuses() { return (
-

@docs indexes

+

@docs indexes

{configDocs.length ? ( { dispatch(setShowDialog(true)); dispatch(setDialogMessage()); diff --git a/gui/src/pages/More/IndexingProgress/IndexingProgress.tsx b/gui/src/pages/More/IndexingProgress/IndexingProgress.tsx index 6f39c84cd..7b80f7dde 100644 --- a/gui/src/pages/More/IndexingProgress/IndexingProgress.tsx +++ b/gui/src/pages/More/IndexingProgress/IndexingProgress.tsx @@ -107,7 +107,7 @@ function IndexingProgress() { } return ( -
+
{update.status !== "loading" && ( diff --git a/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx b/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx index 83abeed11..2b271c837 100644 --- a/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx +++ b/gui/src/pages/More/IndexingProgress/IndexingProgressIndicator.tsx @@ -21,16 +21,15 @@ const STATUS_TO_ICON: Record = { }; function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) { - const progressPercentage = getProgressPercentage(update.progress); + const progressPercentage = getProgressPercentage(update.progress).toFixed(0); const Icon = STATUS_TO_ICON[update.status]; const animateIcon = update.status === "indexing"; - const showProgress = update.status !== "disabled"; + const showProgress = + update.status !== "disabled" && progressPercentage !== "100"; return (
- {showProgress && ( - {progressPercentage.toFixed(0)}% - )} + {showProgress && {progressPercentage}%} {Icon && (
diff --git a/gui/src/pages/More/More.tsx b/gui/src/pages/More/More.tsx index cc399a3fd..b543353b7 100644 --- a/gui/src/pages/More/More.tsx +++ b/gui/src/pages/More/More.tsx @@ -13,7 +13,7 @@ import MoreHelpRow from "./MoreHelpRow"; import IndexingProgress from "./IndexingProgress"; import DocsIndexingStatuses from "../../components/indexing/DocsIndexingStatuses"; import PageHeader from "../../components/PageHeader"; -import { useAppDispatch } from "../../redux/hooks"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { saveCurrentSession } from "../../redux/thunks/session"; function MorePage() { @@ -21,6 +21,9 @@ function MorePage() { const dispatch = useAppDispatch(); const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); + const disableIndexing = useAppSelector( + (state) => state.config.config.disableIndexing, + ); return (
@@ -34,8 +37,15 @@ function MorePage() { Local embeddings of your codebase
- + {disableIndexing ? ( +
+ Indexing is disabled +
+ ) : ( + + )}
+
From 43e76f8aa21a9c937ca1c1a834ae16c74e1cb32b Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 27 Dec 2024 18:31:54 -0500 Subject: [PATCH 07/42] fixed fullscreen bug --- extensions/vscode/src/commands.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b83d3d380..3c9dc2d90 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -37,6 +37,7 @@ import { Battery } from "./util/battery"; import { VsCodeIde } from "./VsCodeIde"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; +import { Disposable } from "vscode-languageclient"; let fullScreenPanel: vscode.WebviewPanel | undefined; @@ -767,14 +768,17 @@ const getCommandsMap: ( true, ); - panel.onDidChangeViewState(() => { - vscode.commands.executeCommand("continue.newSession"); - if (sessionId) { - vscode.commands.executeCommand( - "continue.focusContinueSessionId", - sessionId, - ); + const sessionLoader = panel.onDidChangeViewState(() => { + if(!fullScreenTab){ + vscode.commands.executeCommand("continue.newSession"); + if (sessionId) { + vscode.commands.executeCommand( + "continue.focusContinueSessionId", + sessionId, + ); + } } + sessionLoader.dispose() }); // When panel closes, reset the webview and focus From 9451f0e7bb71731bc794cf757cbc018e59908605 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 27 Dec 2024 23:52:33 -0500 Subject: [PATCH 08/42] removed if statement i forgot about --- extensions/vscode/src/commands.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 3c9dc2d90..d3fe2eb43 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -769,14 +769,12 @@ const getCommandsMap: ( ); const sessionLoader = panel.onDidChangeViewState(() => { - if(!fullScreenTab){ - vscode.commands.executeCommand("continue.newSession"); - if (sessionId) { - vscode.commands.executeCommand( - "continue.focusContinueSessionId", - sessionId, - ); - } + vscode.commands.executeCommand("continue.newSession"); + if (sessionId) { + vscode.commands.executeCommand( + "continue.focusContinueSessionId", + sessionId, + ); } sessionLoader.dispose() }); From 79736c3108313204184bb7d833ac21e23341354f Mon Sep 17 00:00:00 2001 From: liuk Date: Wed, 1 Jan 2025 00:25:18 +0800 Subject: [PATCH 09/42] fix: Add directory checks and optimize token usage - Added check to skip directories when reading file content. - Optimized token usage by removing unnecessary `\r` characters. --- .../continueintellijextension/continue/IntelliJIde.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 39d7b3681..d304e8a02 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -262,7 +262,7 @@ class IntelliJIDE( content } else { val file = File(URI(filepath)) - if (!file.exists()) return "" + if (!file.exists() || file.isDirectory) return "" withContext(Dispatchers.IO) { FileInputStream(file).use { fis -> val sizeToRead = minOf(100000, file.length()).toInt() @@ -270,6 +270,8 @@ class IntelliJIDE( val bytesRead = fis.read(buffer, 0, sizeToRead) if (bytesRead <= 0) return@use "" String(buffer, 0, bytesRead, Charset.forName("UTF-8")) + // `\r` takes up unnecessary tokens + .lineSequence().joinToString("\n") } } } From 0cadb9f958765a702ad177c76ef98b024d6bfc41 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 3 Jan 2025 00:13:01 -0600 Subject: [PATCH 10/42] removed unused import --- extensions/vscode/src/commands.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d3fe2eb43..d1b41b53b 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -37,7 +37,6 @@ import { Battery } from "./util/battery"; import { VsCodeIde } from "./VsCodeIde"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; -import { Disposable } from "vscode-languageclient"; let fullScreenPanel: vscode.WebviewPanel | undefined; From 193dc6929b9f46ad7b332d3240f5bce8e4389363 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 17:19:38 +0100 Subject: [PATCH 11/42] context providers audit p1 --- core/config/types.ts | 1 - core/index.d.ts | 3 ++- extensions/vscode/config_schema.json | 5 ++++- extensions/vscode/package-lock.json | 4 ++-- gui/src/components/mainInput/MentionList.tsx | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/config/types.ts b/core/config/types.ts index 6c7e580dd..aa1873894 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -717,7 +717,6 @@ declare global { type ContextProviderName = | "diff" - | "github" | "terminal" | "debugger" | "open" diff --git a/core/index.d.ts b/core/index.d.ts index 2d7622895..dcf575608 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -724,7 +724,6 @@ export type StepName = export type ContextProviderName = | "diff" - | "github" | "terminal" | "debugger" | "open" @@ -751,6 +750,8 @@ export type ContextProviderName = | "issue" | "repo-map" | "url" + | "web" + | "discord" | string; export type TemplateType = diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c0ffddd3a..c7746af07 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1864,7 +1864,10 @@ "os", "repo-map", "greptile", - "web" + "web", + "gitlab-mr", + "discord", + "jira" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c6db7f103..389aeae95 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.248", + "version": "0.9.250", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.248", + "version": "0.9.250", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index f0f328a8d..e7bb859c8 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -57,7 +57,6 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { folder: FolderIcon, docs: BookOpenIcon, issue: ExclamationCircleIcon, - trash: TrashIcon, web: GlobeAltIcon, "prompt-files": DocumentTextIcon, "repo-map": FolderIcon, From 06e98ac8a4df4a569a6472f94a38399e59483a9f Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 7 Jan 2025 10:34:36 -0800 Subject: [PATCH 12/42] docs updates --- CONTRIBUTING.md | 4 +-- docs/docs/chat/context-selection.md | 2 +- docs/docs/chat/model-setup.mdx | 26 +------------------ docs/docs/customize/tutorials/llama3.1.md | 22 ---------------- .../current/chat/model-setup.mdx | 2 +- .../current/customize/tutorials/llama3.1.md | 21 --------------- .../pages/AddNewModel/configs/providers.ts | 14 +++++----- 7 files changed, 12 insertions(+), 79 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eddf7b45b..ca26d38fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -188,7 +188,7 @@ After you've written your context provider, make sure to complete the following: ### Adding an LLM Provider -Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita AI, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: +Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: 1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example. @@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue, 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. -- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), [Replicate](https://replicate.com/collections/streaming-language-models). +- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. ### Adding Pre-indexed Documentation diff --git a/docs/docs/chat/context-selection.md b/docs/docs/chat/context-selection.md index 4ec425e81..e4c35ddc5 100644 --- a/docs/docs/chat/context-selection.md +++ b/docs/docs/chat/context-selection.md @@ -15,7 +15,7 @@ The highlighted code you’ve selected by pressing cmd/ctrl + L< ## Active file -You can include the currently open file as context by pressing cmd + opt + enter (Mac) or alt + enter (Windows) when you send your request at Chat window(Prompt can't be empty). +You can include the currently open file as context by pressing opt + enter (Mac) or alt + enter (Windows) when you send your request at Chat window(Prompt can't be empty). ## Specific file diff --git a/docs/docs/chat/model-setup.mdx b/docs/docs/chat/model-setup.mdx index 832f2f837..eb7dc5430 100644 --- a/docs/docs/chat/model-setup.mdx +++ b/docs/docs/chat/model-setup.mdx @@ -33,7 +33,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz ### Llama 3.1 405B from Meta -If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita AI](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). +If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). @@ -48,18 +48,6 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your ] ``` - - ```json title="config.json" - "models": [ - { - "title": "Llama 3.1 405B", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "[NOVITA_API_KEY]" - } - ] - ``` - ```json title="config.json" "models": [ @@ -94,18 +82,6 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your ] ``` - - ```json title="config.json" - "models": [ - { - "title": "Llama 3.1 405B", - "provider": "nebius", - "model": "llama3.1-405b", - "apiKey": "[NEBIUS_API_KEY]" - } - ] - ``` - ### GPT-4o from OpenAI diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index 38e90bee9..e2ac72986 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -71,28 +71,6 @@ Together AI provides fast and reliable inference of open-source models. You'll b } ``` - -## Novita AI - -[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today! - -1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) -2. Copy your API key that appears on the welcome screen -3. Update your Continue config file like this: - -```json title="config.json" -{ - "models": [ - { - "title": "Llama 3.1 405b", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "" - } - ] -} -``` - ## Replicate Replicate makes it easy to host and run open-source AI with an API. diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx index 4ef37a41e..cbbef8761 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -33,7 +33,7 @@ import TabItem from "@theme/TabItem"; ### 来自 Meta 的 Llama 3.1 405B -如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita AI](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 +如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index dc285627a..e02ba6741 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -71,27 +71,6 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良 } ``` -## Novita AI - -[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。 - -1. 创建账号 [在这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) -2. 复制[Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)中的你的 API key -3. 更新你的 Continue 配置文件,像这样: - -```json title="config.json" -{ - "models": [ - { - "title": "Llama 3.1 405b", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "" - } - ] -} -``` - ## Replicate Replicate 让使用 API 托管和运行开源 AI 变得简单。 diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index d1efcd262..4890d5c2b 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -165,7 +165,8 @@ export const providers: Partial> = { title: "Scaleway", provider: "scaleway", refPage: "scaleway", - description: "Use the Scaleway Generative APIs to instantly access leading open models", + description: + "Use the Scaleway Generative APIs to instantly access leading open models", longDescription: `Hosted in European data centers, ideal for developers requiring low latency, full data privacy, and compliance with EU AI Act. You can generate your API key in [Scaleway's console](https://console.scaleway.com/generative-api/models). Get started:\n1. Create an API key [here](https://console.scaleway.com/iam/api-keys/)\n2. Paste below\n3. Select a model preset`, params: { apiKey: "", @@ -426,13 +427,12 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n }, ...completionParamsInputsConfigs, ], - packages: [ - models.llama318BChat, models.mistralChat - ].map((p) => { + packages: [models.llama318BChat, models.mistralChat].map((p) => { p.params.contextLength = 4096; return p; }), - apiKeyUrl: "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link", + apiKeyUrl: + "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link", }, gemini: { title: "Google Gemini API", @@ -670,8 +670,8 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo provider: "free-trial", refPage: "freetrial", description: - "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita AI using our API key", - longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita AI using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, + "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key", + longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, icon: "openai.png", tags: [ModelProviderTags.Free], packages: [ From c7b80d346f0850019a8660eb0d9d1505c0e420b7 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 15:57:14 -0600 Subject: [PATCH 13/42] fix fullscreen bug --- extensions/vscode/src/commands.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b83d3d380..1c26bb45e 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -733,6 +733,10 @@ const getCommandsMap: ( "getCurrentSessionId", undefined, ); + + // Clear the sidebar to prevent overwriting changes made in fullscreen + vscode.commands.executeCommand("continue.newSession") + // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); From 326132f18dc3574adc12a53f3b7f2778bb1295dd Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 16:46:06 -0600 Subject: [PATCH 14/42] stopped fullscreen refresh --- extensions/vscode/src/commands.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 1c26bb45e..daf3d4991 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -734,19 +734,18 @@ const getCommandsMap: ( undefined, ); - // Clear the sidebar to prevent overwriting changes made in fullscreen - vscode.commands.executeCommand("continue.newSession") - // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); if (fullScreenTab && fullScreenPanel) { // Full screen open, but not focused - focus it fullScreenPanel.reveal(); - vscode.commands.executeCommand("continue.focusContinueInput"); return; } + // Clear the sidebar to prevent overwriting changes made in fullscreen + vscode.commands.executeCommand("continue.newSession") + // Full screen not open - open it captureCommandTelemetry("openFullScreen"); From bd03c85c1cbf98e0c4f5699d9d132b780b4c3b7a Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 16:57:45 -0600 Subject: [PATCH 15/42] removed accidentally added whitespace --- extensions/vscode/src/commands.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index daf3d4991..ac4a86984 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -733,7 +733,6 @@ const getCommandsMap: ( "getCurrentSessionId", undefined, ); - // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); From ce0d750e8c391692d9b063aacd19f8bf8ac667a2 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 8 Jan 2025 15:25:07 +0100 Subject: [PATCH 16/42] context provider config schema updates --- core/context/providers/DocsContextProvider.ts | 6 ++- extensions/vscode/config_schema.json | 47 ++++++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 9ee50c256..00e193354 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -80,6 +80,8 @@ class DocsContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { + const useReranking = this.options?.useReranking ?? true; + // Get docs service const docsService = DocsService.getSingleton(); if (!docsService) { @@ -101,8 +103,8 @@ class DocsContextProvider extends BaseContextProvider { // We found chunks, so check if there's a favicon for the docs page const favicon = await docsService.getFavicon(query); - // Rerank if there's a rerankder - if (extras.reranker) { + // Rerank if there's a reranker + if (useReranking && extras.reranker) { chunks = await this._rerankChunks( chunks, extras.reranker, diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c7746af07..3cb55057b 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2044,6 +2044,51 @@ } } }, + { + "if": { + "properties": { + "name": { + "enum": ["debugger"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "stackDepth": { + "title": "Stack Depth", + "description": "Stack trace depth to include in context", + "default": 3, + "type": "integer" + } + } + } + } + } + }, + { + "if": { + "properties": { + "name": { + "enum": ["diff"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "description": "Include diff from unstaged files", + "default": true + } + } + } + } + } + }, { "if": { "properties": { @@ -2278,7 +2323,7 @@ "if": { "properties": { "name": { - "enum": ["codebase", "folder"] + "enum": ["codebase", "folder", "docs"] } } }, From 75b26ae9c0de58a7d0ae0ce8aab1d470773b78e0 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 8 Jan 2025 19:14:03 +0100 Subject: [PATCH 17/42] more icons, also jetbrains stuff --- core/context/providers/DiffContextProvider.ts | 4 ++- docs/docs/customize/context-providers.md | 7 ++++- .../intellij/.run/Run Extension.run.xml | 2 +- .../.run/Start Core Dev Server (CE).run.xml | 5 ++-- .../.run/Start GUI Dev Server.run.xml | 2 +- extensions/vscode/config_schema.json | 10 ++++--- gui/src/components/mainInput/MentionList.tsx | 11 +++++--- gui/src/components/svg/GitlabIcon.tsx | 26 +++++++++++++++++++ gui/src/components/svg/GoogleIcon.tsx | 26 +++++++++++++++++++ 9 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 gui/src/components/svg/GitlabIcon.tsx create mode 100644 gui/src/components/svg/GoogleIcon.tsx diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index ef5823580..cbb9cf530 100644 --- a/core/context/providers/DiffContextProvider.ts +++ b/core/context/providers/DiffContextProvider.ts @@ -17,7 +17,9 @@ class DiffContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { - const diff = await extras.ide.getDiff(this.options.includeUnstaged ?? true); + const diff = await extras.ide.getDiff( + this.options?.includeUnstaged ?? true, + ); return [ { description: "The current git diff", diff --git a/docs/docs/customize/context-providers.md b/docs/docs/customize/context-providers.md index 991a16f32..6e4b8cd35 100644 --- a/docs/docs/customize/context-providers.md +++ b/docs/docs/customize/context-providers.md @@ -123,11 +123,16 @@ Reference the contents of all of your open files. Set `onlyPinned` to `true` to Reference relevant pages from across the web, automatically determined from your input. +Optionally, set "n" to limit the number of results returned (default 6). + ```json title="config.json" { "contextProviders": [ { - "name": "web" + "name": "web", + "params": { + "n": 5 + } } ] } diff --git a/extensions/intellij/.run/Run Extension.run.xml b/extensions/intellij/.run/Run Extension.run.xml index fd9562480..b63167cde 100644 --- a/extensions/intellij/.run/Run Extension.run.xml +++ b/extensions/intellij/.run/Run Extension.run.xml @@ -9,7 +9,7 @@