diff --git a/.continue/prompts/core-unit-test.prompt b/.continue/prompts/core-unit-test.prompt index 42ecef7bb..1a08945b4 100644 --- a/.continue/prompts/core-unit-test.prompt +++ b/.continue/prompts/core-unit-test.prompt @@ -4,7 +4,7 @@ description: Generate unit tests for core utilities Write jest tests for the provided code. Use jest version ^29 (e.g. jest 29.7.0) -Use best practices. Be clear and consise. +Use best practices. Be clear and concise. Aim for 100% code coverage where reasonable. Multiple tests can be written, split up tests for best clarity and readability. Only use typescript, and if the file/code is not typescript, warn the user. @@ -15,7 +15,7 @@ Use double quotes (or backticks if needed) for strings The code being tested is used in IDE extensions, and it: - accesses code workspaces through the IDE ("workspace directories") - persists extension-related data to the the local machine of the user ("global directory"), and -- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accesed via a remote "control plane" using the `ControlPlaneClient` +- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accessed via a remote "control plane" using the `ControlPlaneClient` Jest testing setup includes - @core/test/jest.global-setup.ts initializes a temporary global directory, which is where files that store persisted extension data live. @@ -31,7 +31,7 @@ Jest testing setup includes Do NOT write tests for any files in `core/test`, only use them as helpers for testing other files. If no other files are provided, warn the user and write no tests. -IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible. +IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible. Instead, generate actual mock files and data for operations Pure mocks should only be used to emulate specific network responses/error or hard-to-duplicate errors, or to prevent long-duration tests diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 84ee4e60f..e40d9d054 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -71,7 +71,27 @@ } ] }, - // Build the React app. It gets bundled into the extension as a file resource and has a seprate build step + { + "label": "vscode-extension:package", + "dependsOn": ["vscode-extension:esbuild"], + "type": "npm", + "script": "package", + "path": "extensions/vscode", + "problemMatcher": [ + { + "pattern": [ + { + "regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] + }, { "label": "vscode-extension:continue-ui:build", "type": "shell", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b69b1fd44..4f7e1634f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,7 +128,7 @@ nvm use 1. The new VS Code window with the extension is referred to as the _Host VS Code_ 2. The window you started debugging from is referred to as the _Main VS Code_ -3. To package the extension, run `npm run package` in the `extensions/vscode` directory. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX". +3. To package the extension, run `npm run package` in the `extensions/vscode` directory, select `Tasks: Run Task` and then select `vscode-extension:package`. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX". ##### Debugging diff --git a/core/autocomplete/constants/AutocompleteLanguageInfo.ts b/core/autocomplete/constants/AutocompleteLanguageInfo.ts index d51fe1f1f..82b169677 100644 --- a/core/autocomplete/constants/AutocompleteLanguageInfo.ts +++ b/core/autocomplete/constants/AutocompleteLanguageInfo.ts @@ -240,6 +240,14 @@ export const Solidity = { endOfLine: [";"], }; +// Lua +export const Lua = { + name: "Lua", + topLevelKeywords: ["function"], + singleLineComment: "--", + endOfLine: [], +}; + // YAML export const YAML: AutocompleteLanguageInfo = { name: "YAML", @@ -367,6 +375,8 @@ export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = { yaml: YAML, yml: YAML, md: Markdown, + lua: Lua, + luau: Lua, }; export function languageForFilepath(fileUri: string): AutocompleteLanguageInfo { diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts index 7f5366df0..2c8b12a31 100644 --- a/core/autocomplete/templating/AutocompleteTemplate.ts +++ b/core/autocomplete/templating/AutocompleteTemplate.ts @@ -399,7 +399,8 @@ export function getTemplateForModel(model: string): AutocompleteTemplate { lowerCaseModel.includes("gpt") || lowerCaseModel.includes("davinci-002") || lowerCaseModel.includes("claude") || - lowerCaseModel.includes("granite3") + lowerCaseModel.includes("granite3") || + lowerCaseModel.includes("granite-3") ) { return holeFillerTemplate; } diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index e4360b761..659584056 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -92,6 +92,17 @@ export class ConfigHandler { }); } + /** + * Retrieves the titles of additional context providers that are of type "submenu". + * + * @returns {string[]} An array of titles of the additional context providers that have a description type of "submenu". + */ + getAdditionalSubmenuContextProviders(): string[] { + return this.additionalContextProviders + .filter(provider => provider.description.type === "submenu") + .map(provider => provider.description.title); + } + private async init() { try { await this.fetchControlPlaneProfiles(); diff --git a/core/core.ts b/core/core.ts index 7d1fe5e51..bc767598f 100644 --- a/core/core.ts +++ b/core/core.ts @@ -128,6 +128,14 @@ export class Core { profileId: this.configHandler.currentProfile?.profileDescription.id ?? null, }); + + // update additional submenu context providers registered via VSCode API + const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders(); + if (additionalProviders.length > 0) { + this.messenger.send("refreshSubmenuItems", { + providers: additionalProviders, + }); + } }); this.configHandler.onDidChangeAvailableProfiles( diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index 428bae967..aba1da6b0 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -139,24 +139,35 @@ export async function htmlPageToArticleWithChunks( return undefined; } + const title = readability.title || subpath; + const titles = Array.from(dom.window.document.querySelectorAll("h2")); - const article_components = titles.map((titleElement) => { - const title = titleElement.textContent || ""; - let body = ""; - let nextSibling = titleElement.nextElementSibling; - while (nextSibling && nextSibling.tagName !== "H2") { - body += nextSibling.textContent || ""; - nextSibling = nextSibling.nextElementSibling; - } + const article_components = + titles.length > 0 + ? titles.map((titleElement) => { + const title = titleElement.textContent || ""; + let body = ""; + let nextSibling = titleElement.nextElementSibling; - return { title, body }; - }); + while (nextSibling && nextSibling.tagName !== "H2") { + body += nextSibling.textContent || ""; + nextSibling = nextSibling.nextElementSibling; + } + + return { title, body }; + }) + : [ + { + title: title, + body: readability.textContent, + }, + ]; const article = { url, subpath, - title: readability.title, + title: title, article_components, }; return { diff --git a/core/indexing/docs/preIndexedDocs.ts b/core/indexing/docs/preIndexedDocs.ts index 4b0c12fee..5342396fd 100644 --- a/core/indexing/docs/preIndexedDocs.ts +++ b/core/indexing/docs/preIndexedDocs.ts @@ -358,6 +358,11 @@ const preIndexedDocs: Record< startUrl: "https://angular.dev/", rootUrl: "https://angular.dev/", }, + "https://docs.djangoproject.com/": { + title: "Django", + startUrl: "https://docs.djangoproject.com/", + rootUrl: "https://docs.djangoproject.com/", + } }; export default preIndexedDocs; diff --git a/core/llm/llms/VertexAI.ts b/core/llm/llms/VertexAI.ts index 8d20c3212..4d52e5c43 100644 --- a/core/llm/llms/VertexAI.ts +++ b/core/llm/llms/VertexAI.ts @@ -445,7 +445,7 @@ class VertexAI extends BaseLLM { } const resp = await this.fetch( - new URL(this.apiBase + `/publishers/google/models/${this.model}:predict`), + new URL(`publishers/google/models/${this.model}:predict`, this.apiBase), { method: "POST", body: JSON.stringify({ diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index 067445994..df1296e0c 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -93,6 +93,7 @@ export const supportedLanguages: { [key: string]: LanguageName } = { htm: LanguageName.HTML, java: LanguageName.JAVA, lua: LanguageName.LUA, + luau: LanguageName.LUA, ocaml: LanguageName.OCAML, ml: LanguageName.OCAML, mli: LanguageName.OCAML, diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/CancelAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/CancelAutocompleteAction.kt index 93eb805b3..8b5159d4d 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/CancelAutocompleteAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/CancelAutocompleteAction.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.autocomplete +import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys @@ -27,4 +28,8 @@ class CancelAutocompleteAction : AnAction() { val editor: Editor? = e.getData(CommonDataKeys.EDITOR) return project != null && editor != null && editor.contentComponent.hasFocus() } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } } 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 8fcaf590a..faaf7d058 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 @@ -137,7 +137,10 @@ fun openInlineEdit(project: Project?, editor: Editor) { modelTitles.addAll(models.map { it["title"] as String }) } - val maxWaitTime = 200 + // This is a hacky way to not complicate getting model titles with coroutines + // 1500 feels like way upper limit of "would be weird if panel showed up after that long" + // And should always allow enough time to load config + val maxWaitTime = 1500 val startTime = System.currentTimeMillis() while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < maxWaitTime) { Thread.sleep(20) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt index e121e5687..035c52db8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt @@ -192,10 +192,12 @@ class VerticalDiffBlock( private fun revertDiff() { WriteCommandAction.runWriteCommandAction(project) { - // Delete the added lines val startOffset = editor.document.getLineStartOffset(startLine) - val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1 - editor.document.deleteString(startOffset, endOffset) + // Delete the added lines + if (addedLines.isNotEmpty()) { + val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1 + editor.document.deleteString(startOffset, endOffset) + } // Add the deleted lines back if (deletedLines.isNotEmpty()) { diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index 2254bb1f3..c4d392cfa 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -504,21 +504,11 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { async function copyScripts() { process.chdir(path.join(continueDir, "extensions", "vscode")); console.log("[info] Copying scripts from core"); - await new Promise((resolve, reject) => { - ncp( - path.join(__dirname, "../../../core/scripts"), - path.join(__dirname, "../out"), - { dereference: true }, - (error) => { - if (error) { - console.warn("[error] Error copying script files", error); - reject(error); - } else { - resolve(); - } - }, - ); - }); + fs.copyFileSync( + path.join(__dirname, "../../../core/util/start_ollama.sh"), + path.join(__dirname, "../out/start_ollama.sh"), + ); + console.log("[info] Copied script files"); } module.exports = { diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 60a14bdff..e08fe9027 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -1054,7 +1054,7 @@ export function registerAllCommands( core: Core, editDecorationManager: EditDecorationManager, ) { - // registerCopyBufferSpy(context, core); + registerCopyBufferSpy(context, core); for (const [command, callback] of Object.entries( getCommandsMap( diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index bdfe15ba6..69264eb35 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -109,7 +109,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) { hideImageUpload: false, hideUseCodebase: true, hideSelectModel: false, - hideTools: true, enterText: editModeState.editStatus === "accepting" ? "Retry" : "Edit", } : {}; diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index a6b92ab90..2f7c6a3b1 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -67,7 +67,6 @@ export interface ToolbarOptions { hideAddContext?: boolean; enterText?: string; hideSelectModel?: boolean; - hideTools?: boolean; } interface InputToolbarProps { @@ -91,10 +90,7 @@ function InputToolbar(props: InputToolbarProps) { const hasCodeToEdit = useAppSelector(selectHasCodeToEdit); const isEditModeAndNoCodeToEdit = isInEditMode && !hasCodeToEdit; const isEnterDisabled = props.disabled || isEditModeAndNoCodeToEdit; - const toolsSupported = - defaultModel && - modelSupportsTools(defaultModel) && - !props.toolbarOptions?.hideTools; + const toolsSupported = defaultModel && modelSupportsTools(defaultModel); const supportsImages = defaultModel && @@ -110,7 +106,6 @@ function InputToolbar(props: InputToolbarProps) {
diff --git a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx index 3265b2778..20dae9160 100644 --- a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx +++ b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx @@ -14,6 +14,7 @@ import InfoHover from "../../InfoHover"; import HoverItem from "./HoverItem"; import PopoverTransition from "./PopoverTransition"; import ToolDropdownItem from "./ToolDropdownItem"; +import { selectIsInEditMode } from "../../../redux/slices/sessionSlice"; interface ToolDropdownProps { disabled: boolean; @@ -28,6 +29,7 @@ export default function ToolDropdown(props: ToolDropdownProps) { const useTools = useAppSelector((state) => state.ui.useTools); const availableTools = useAppSelector((state) => state.config.config.tools); const [showAbove, setShowAbove] = useState(false); + const isInEditMode = useAppSelector(selectIsInEditMode); const ToolsIcon = useTools ? WrenchScrewdriverIconSolid @@ -48,33 +50,37 @@ export default function ToolDropdown(props: ToolDropdownProps) { } }, [isDropdownOpen]); + const isDisabled = props.disabled || isInEditMode; + return ( - !props.disabled && dispatch(toggleUseTools())}> + !isDisabled && dispatch(toggleUseTools())}>
!props.disabled && setIsHovered(true)} - onMouseLeave={() => !props.disabled && setIsHovered(false)} + onMouseEnter={() => !isDisabled && setIsHovered(true)} + onMouseLeave={() => !isDisabled && setIsHovered(false)} /> - {props.disabled && ( + {isDisabled && ( - This model does not support tool use + {isInEditMode + ? "Tool use not supported in edit mode" + : "This model does not support tool use"} )} - {!useTools && !props.disabled && ( + {!useTools && !isDisabled && ( Enable tool usage )} - {useTools && !props.disabled && ( + {useTools && !isDisabled && ( <> Tools @@ -84,7 +90,7 @@ export default function ToolDropdown(props: ToolDropdownProps) { onChange={() => {}} as="div" onClick={(e) => e.stopPropagation()} - disabled={props.disabled} + disabled={isDisabled} > {({ open }) => ( <> @@ -95,7 +101,7 @@ export default function ToolDropdown(props: ToolDropdownProps) { setDropdownOpen(!isDropdownOpen); }} className="text-lightgray flex cursor-pointer items-center border-none bg-transparent px-0 outline-none" - aria-disabled={props.disabled} + aria-disabled={isDisabled} > @@ -147,7 +153,7 @@ export default function ToolDropdown(props: ToolDropdownProps) { />
-
+
{availableTools.map((tool: any) => ( { if (queryInputRef.current) { queryInputRef.current.focus(); } - }, [querySubmenuItem]); + }, [querySubmenuItem, queryInputRef]); const selectItem = (index: number) => { const item = allItems[index]; @@ -378,6 +378,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { {querySubmenuItem ? ( { + e.stopPropagation(); + }} rows={1} ref={queryInputRef} placeholder={querySubmenuItem.description} @@ -436,7 +439,10 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { ref={(el) => (itemRefs.current[index] = el)} className={`item cursor-pointer ${isSelected ? "is-selected" : ""}`} key={index} - onClick={() => selectItem(index)} + onClick={(e) => { + e.stopPropagation(); + selectItem(index); + }} onMouseEnter={() => setSelectedIndex(index)} data-testid="context-provider-dropdown-item" > diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 51fb3e91f..35e993a54 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -591,11 +591,12 @@ function TipTapEditor(props: TipTapEditorProps) { useEffect(() => { if (editor) { const handleFocus = () => { - debouncedShouldHideToolbar(false); + setShouldHideToolbar(false); }; const handleBlur = () => { - debouncedShouldHideToolbar(true); + // TODO - make toolbar auto-hiding work without breaking tool dropdown focus + // debouncedShouldHideToolbar(true); }; editor.on("focus", handleFocus); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index dd8f0b5bb..c70de4035 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -53,7 +53,6 @@ type SessionState = { streamAborter: AbortController; codeToEdit: CodeToEdit[]; curCheckpointIndex: number; - currentMainEditorContent?: JSONContent; mainEditorContentTrigger?: JSONContent | undefined; symbols: FileSymbolMap; mode: MessageModes; diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index 8cfb8f937..f137cbe7b 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -33,9 +33,24 @@ const rootReducer = combineReducers({ const saveSubsetFilters = [ createFilter("session", [ "history", - "sessionId", "selectedOrganizationId", "selectedProfile", + "id", + "lastSessionId", + "title", + + // Persist edit mode in case closes in middle + "mode", + "codeToEdit", + + // TODO consider removing persisted profiles/orgs + "availableProfiles", + "organizations", + + // higher risk to persist + // codeBlockApplyStates + // symbols + // curCheckpointIndex ]), // Don't persist any of the edit state for now createFilter("editModeState", []), diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 1bd82a030..fe20fa550 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -27,7 +27,10 @@ export const streamNormalInput = createAsyncThunk< throw new Error("Default model not defined"); } - const includeTools = useTools && modelSupportsTools(defaultModel); + const includeTools = + useTools && + modelSupportsTools(defaultModel) && + state.session.mode === "chat"; // Send request const gen = extra.ideMessenger.llmStreamChat( diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 44f05cc9a..b6de2b8a1 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.34", + "version": "1.0.35", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/interfaces/index.ts b/packages/config-yaml/src/interfaces/index.ts index 264a2d376..d57dbf587 100644 --- a/packages/config-yaml/src/interfaces/index.ts +++ b/packages/config-yaml/src/interfaces/index.ts @@ -76,7 +76,7 @@ export function getLocationsToLook( return locationsToLook; } -export async function listAvailableSecrets( +export function listAvailableSecrets( userSecretNames: string[], orgSecretNames: string[], assistantSecretNames: string[], @@ -84,7 +84,7 @@ export async function listAvailableSecrets( assistantSlug: PackageSlug, blockSlug: PackageSlug | undefined, currentUserSlug: string, -): Promise { +): SecretLocation[] { // Create a set of all secret names const allSecretNames = new Set([ ...userSecretNames,