From d072af95b440ffa3f76e0a24ac7c71211d7286dd Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Tue, 4 Feb 2025 19:07:39 -0500 Subject: [PATCH 01/16] Specify name and icon for GUI view --- extensions/vscode/package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index c688eda3f..a2dafa82d 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -580,7 +580,8 @@ { "type": "webview", "id": "continue.continueGUIView", - "name": "", + "name": "Continue", + "icon": "media/sidebar-icon.png", "visibility": "visible" } ] @@ -702,6 +703,7 @@ "ncp": "^2.0.0", "node-fetch": "^3.3.2", "node-machine-id": "^1.1.12", + "partial-json": "^0.1.7", "posthog-node": "^3.6.3", "react-markdown": "^8.0.7", "react-redux": "^8.0.5", @@ -718,6 +720,7 @@ "vectordb": "^0.4.20", "vscode-languageclient": "^8.0.2", "ws": "^8.13.0", - "yarn": "^1.22.21" + "yarn": "^1.22.21", + "zod": "^3.24.1" } } From f7e4e34ac52511d15c60409ed50c2e3fb304af4b Mon Sep 17 00:00:00 2001 From: Piotr Czekaj Date: Wed, 5 Feb 2025 11:08:57 +0100 Subject: [PATCH 02/16] Fix contradictory instruction in .continuerules docs --- docs/docs/customize/deep-dives/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/deep-dives/rules.md b/docs/docs/customize/deep-dives/rules.md index f53135b50..ae8347f29 100644 --- a/docs/docs/customize/deep-dives/rules.md +++ b/docs/docs/customize/deep-dives/rules.md @@ -12,7 +12,7 @@ You can create a project-specific system message by adding a `.continuerules` fi - If you want concise answers: ```title=.continuerules -Please provide concise answers. Do explain obvious concepts. You can assume that I am knowledgable about most programming topics. +Please provide concise answers. Don't explain obvious concepts. You can assume that I am knowledgable about most programming topics. ``` - If you want to ensure certain practices are followed, for example in React: From bcf2ac9ebf68f11e3705b96c6d9575e7b8d74216 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 5 Feb 2025 13:32:35 -0800 Subject: [PATCH 03/16] revert package.json dep changes --- extensions/vscode/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index a2dafa82d..35d360a67 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -703,7 +703,6 @@ "ncp": "^2.0.0", "node-fetch": "^3.3.2", "node-machine-id": "^1.1.12", - "partial-json": "^0.1.7", "posthog-node": "^3.6.3", "react-markdown": "^8.0.7", "react-redux": "^8.0.5", @@ -720,7 +719,6 @@ "vectordb": "^0.4.20", "vscode-languageclient": "^8.0.2", "ws": "^8.13.0", - "yarn": "^1.22.21", - "zod": "^3.24.1" + "yarn": "^1.22.21" } } From b8098c8ff159076e3338f2dbbf43e641041f6220 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 14:02:33 -0800 Subject: [PATCH 04/16] osr context menu --- gui/src/components/Layout.tsx | 2 + gui/src/components/OSRContextMenu.tsx | 100 ++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 gui/src/components/OSRContextMenu.tsx diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 747c2ddab..94a9fb616 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -23,6 +23,7 @@ import { AuthProvider } from "../context/Auth"; import { exitEditMode } from "../redux/thunks"; import { loadLastSession, saveCurrentSession } from "../redux/thunks/session"; import { incrementFreeTrialCount } from "../util/freeTrial"; +import OSRContextMenu from "./OSRContextMenu"; const LayoutTopDiv = styled(CustomScrollbarDiv)` height: 100%; @@ -261,6 +262,7 @@ const Layout = () => { return ( +
{ + const ideMessenger = useContext(IdeMessengerContext); + + const [position, setPosition] = useState<{ + top?: number; + left?: number; + bottom?: number; + right?: number; + } | null>(null); + const menuRef = React.useRef(null); + + const isOSREnabled = useIsOSREnabled(); + useEffect(() => { + function leaveWindowHandler(event: MouseEvent) { + setPosition(null); + } + function contextMenuHandler(event: MouseEvent) { + event.preventDefault(); + } + function rightClickHandler(event: MouseEvent) { + if (!menuRef.current?.contains(event.target as Node)) { + setPosition(null); + } + if (event.button === 2) { + event.preventDefault(); + + // always open towards inside of window from click + const toRight = event.clientX > window.innerWidth / 2; + const toBottom = event.clientY > window.innerHeight / 2; + if (toRight) { + if (toBottom) { + setPosition({ + bottom: window.innerHeight - event.clientY, + right: window.innerWidth - event.clientX, + }); + } else { + setPosition({ + top: event.clientY, + right: window.innerWidth - event.clientX, + }); + } + } else { + if (toBottom) { + setPosition({ + bottom: window.innerHeight - event.clientY, + left: event.clientX, + }); + } else { + setPosition({ + top: event.clientY, + left: event.clientX, + }); + } + } + } + } + + if (isOSREnabled) { + document.addEventListener("mouseleave", leaveWindowHandler); + document.addEventListener("contextmenu", contextMenuHandler); + document.addEventListener("mousedown", rightClickHandler); + } + + return () => { + document.removeEventListener("mouseleave", leaveWindowHandler); + document.removeEventListener("contextmenu", contextMenuHandler); + document.removeEventListener("mousedown", rightClickHandler); + }; + }, [isOSREnabled, menuRef]); + + if (!position) { + return null; + } + return ( +
+
{ + e.stopPropagation(); + ideMessenger.post("toggleDevTools", undefined); + }} + > + Toggle Dev Tools +
+
+ ); +}; + +export default OSRContextMenu; From 008afdaf0a8a995d0976b6e5e50c1454e5fff518 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 17:17:07 -0800 Subject: [PATCH 05/16] add copy cut paste --- gui/src/components/OSRContextMenu.tsx | 156 +++++++++++++++++++++++--- 1 file changed, 138 insertions(+), 18 deletions(-) diff --git a/gui/src/components/OSRContextMenu.tsx b/gui/src/components/OSRContextMenu.tsx index 063e3de25..a8dd53037 100644 --- a/gui/src/components/OSRContextMenu.tsx +++ b/gui/src/components/OSRContextMenu.tsx @@ -1,34 +1,112 @@ -import React, { useContext, useEffect, useState } from "react"; +import React, { useContext, useEffect, useRef, useState } from "react"; import useIsOSREnabled from "../hooks/useIsOSREnabled"; import { IdeMessengerContext } from "../context/IdeMessenger"; +interface Position { + top?: number; + left?: number; + bottom?: number; + right?: number; +} + const OSRContextMenu = () => { const ideMessenger = useContext(IdeMessengerContext); - const [position, setPosition] = useState<{ - top?: number; - left?: number; - bottom?: number; - right?: number; - } | null>(null); + const [position, setPosition] = useState(null); + const [canCopy, setCanCopy] = useState(false); + const [canCut, setCanCut] = useState(false); + const [canPaste, setCanPaste] = useState(false); + const menuRef = React.useRef(null); + const selectedTextRef = useRef(null); + const selectedRangeRef = useRef(null); + + function onMenuItemClick( + event: React.MouseEvent, + ) { + event.preventDefault(); + + // restore selection + if (selectedRangeRef.current) { + const selection = window.getSelection(); + selection?.removeAllRanges(); + selection?.addRange(selectedRangeRef.current); + } + + // Hide menu + setPosition(null); + } const isOSREnabled = useIsOSREnabled(); useEffect(() => { - function leaveWindowHandler(event: MouseEvent) { + function leaveWindowHandler() { setPosition(null); } function contextMenuHandler(event: MouseEvent) { event.preventDefault(); } - function rightClickHandler(event: MouseEvent) { + function clickHandler(event: MouseEvent) { + // If clicked outside of menu, close menu if (!menuRef.current?.contains(event.target as Node)) { setPosition(null); } + if (event.button === 2) { + // Prevent default context menu event.preventDefault(); - // always open towards inside of window from click + selectedRangeRef.current = null; + selectedTextRef.current = null; + + const selection = window.getSelection(); + let isClickWithinSelection = false; + if (selection && selection.rangeCount > 0) { + const range = selection.getRangeAt(0); + const selectedText = range.toString(); + selectedRangeRef.current = range.cloneRange(); + + if (selectedText.length > 0) { + if (selectedText) { + selectedTextRef.current = selectedText; + const rects = range.getClientRects(); + for (let i = 0; i < rects.length; i++) { + const rect = rects[i]; + if ( + event.clientX >= rect.left && + event.clientX <= rect.right && + event.clientY >= rect.top && + event.clientY <= rect.bottom + ) { + isClickWithinSelection = true; + break; + } + } + } + } + } + + // Check if right clicked on editable content (allows paste/cut) + let isEditable = false; + if ( + event.target && + "isContentEditable" in event.target && + typeof event.target.isContentEditable === "boolean" + ) { + isEditable = event.target.isContentEditable; + } + + setCanCopy(!!selectedTextRef.current && isClickWithinSelection); + setCanCut( + !!(isEditable && selectedTextRef.current && isClickWithinSelection), + ); + + // TODO only can paste if there is text in clipboard? + setCanPaste(isEditable); + // navigator.clipboard.readText().then((text) => { + // setCanPaste(text || null); + // }); + + // Open towards inside of window from click const toRight = event.clientX > window.innerWidth / 2; const toBottom = event.clientY > window.innerHeight / 2; if (toRight) { @@ -59,39 +137,81 @@ const OSRContextMenu = () => { } } + setPosition(null); if (isOSREnabled) { document.addEventListener("mouseleave", leaveWindowHandler); document.addEventListener("contextmenu", contextMenuHandler); - document.addEventListener("mousedown", rightClickHandler); + document.addEventListener("mousedown", clickHandler); } return () => { document.removeEventListener("mouseleave", leaveWindowHandler); document.removeEventListener("contextmenu", contextMenuHandler); - document.removeEventListener("mousedown", rightClickHandler); + document.removeEventListener("mousedown", clickHandler); }; - }, [isOSREnabled, menuRef]); + }, [isOSREnabled]); if (!position) { return null; } return (
+ {canCopy && ( +
{ + onMenuItemClick(e); + document.execCommand("copy"); + }} + > + Copy +
+ )} + {canCut && ( +
{ + onMenuItemClick(e); + document.execCommand("cut"); + }} + > + Cut +
+ )} + {/* PASTING is currently broken, can't get the clipboard text */} + {/* {canPaste && ( +
{ + onMenuItemClick(e); + const clipboardText = await navigator.clipboard.readText(); + // const out = await navigator.clipboard.read(); + if (clipboardText) { + selectedRangeRef.current?.deleteContents(); + selectedRangeRef.current?.insertNode( + document.createTextNode(clipboardText), + ); + } + }} + > + Paste +
+ )} */}
{ - e.stopPropagation(); + onMenuItemClick(e); ideMessenger.post("toggleDevTools", undefined); }} > - Toggle Dev Tools + Open Dev Tools
); From c0e728ad644355ef7a1a1b8598fa7770f4052b8c Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 17:27:06 -0800 Subject: [PATCH 06/16] don't show for mac --- gui/src/components/OSRContextMenu.tsx | 8 +++++++- gui/src/components/mainInput/handleMetaKeyIssues.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gui/src/components/OSRContextMenu.tsx b/gui/src/components/OSRContextMenu.tsx index a8dd53037..5fcfafefe 100644 --- a/gui/src/components/OSRContextMenu.tsx +++ b/gui/src/components/OSRContextMenu.tsx @@ -1,6 +1,7 @@ import React, { useContext, useEffect, useRef, useState } from "react"; import useIsOSREnabled from "../hooks/useIsOSREnabled"; import { IdeMessengerContext } from "../context/IdeMessenger"; +import { getPlatform } from "../util"; interface Position { top?: number; @@ -11,6 +12,7 @@ interface Position { const OSRContextMenu = () => { const ideMessenger = useContext(IdeMessengerContext); + const platform = useRef(getPlatform()); const [position, setPosition] = useState(null); const [canCopy, setCanCopy] = useState(false); @@ -39,6 +41,10 @@ const OSRContextMenu = () => { const isOSREnabled = useIsOSREnabled(); useEffect(() => { + if (platform.current === "mac") { + return; + } + function leaveWindowHandler() { setPosition(null); } @@ -151,7 +157,7 @@ const OSRContextMenu = () => { }; }, [isOSREnabled]); - if (!position) { + if (platform.current === "mac" || !isOSREnabled || !position) { return null; } return ( diff --git a/gui/src/components/mainInput/handleMetaKeyIssues.ts b/gui/src/components/mainInput/handleMetaKeyIssues.ts index 14bf3f792..1adf5593a 100644 --- a/gui/src/components/mainInput/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/handleMetaKeyIssues.ts @@ -3,7 +3,6 @@ import { KeyboardEvent } from "react"; import { getPlatform, isWebEnvironment } from "../../util"; const isWebEnv = isWebEnvironment(); -const platform = getPlatform(); /** * This handles various keypress issues when OSR is enabled @@ -14,6 +13,7 @@ export const handleJetBrainsOSRMetaKeyIssues = ( ) => { const selection = window.getSelection(); const alter = e.shiftKey ? "extend" : "move"; + const platform = getPlatform(); const handlers: Record void> = { Backspace: () => handleJetBrainsMetaBackspace(editor), @@ -108,6 +108,7 @@ export const handleJetBrainsMetaBackspace = (editor: Editor) => { } // For Linux/Windows, only delete the word to the left of the cursor + const platform = getPlatform(); if (platform !== "mac") { deleteSingleWord(editor); break; From d840d48b7900a50797d515375feaf6b193abdef5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 17:30:52 -0800 Subject: [PATCH 07/16] fix platform logic for custom context menu --- gui/src/components/OSRContextMenu.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gui/src/components/OSRContextMenu.tsx b/gui/src/components/OSRContextMenu.tsx index 5fcfafefe..f6cf6e33c 100644 --- a/gui/src/components/OSRContextMenu.tsx +++ b/gui/src/components/OSRContextMenu.tsx @@ -12,6 +12,7 @@ interface Position { const OSRContextMenu = () => { const ideMessenger = useContext(IdeMessengerContext); + const isOSREnabled = useIsOSREnabled(); const platform = useRef(getPlatform()); const [position, setPosition] = useState(null); @@ -39,12 +40,7 @@ const OSRContextMenu = () => { setPosition(null); } - const isOSREnabled = useIsOSREnabled(); useEffect(() => { - if (platform.current === "mac") { - return; - } - function leaveWindowHandler() { setPosition(null); } @@ -144,16 +140,16 @@ const OSRContextMenu = () => { } setPosition(null); - if (isOSREnabled) { + if (isOSREnabled && platform.current !== "mac") { + document.addEventListener("mousedown", clickHandler); document.addEventListener("mouseleave", leaveWindowHandler); document.addEventListener("contextmenu", contextMenuHandler); - document.addEventListener("mousedown", clickHandler); } return () => { + document.removeEventListener("mousedown", clickHandler); document.removeEventListener("mouseleave", leaveWindowHandler); document.removeEventListener("contextmenu", contextMenuHandler); - document.removeEventListener("mousedown", clickHandler); }; }, [isOSREnabled]); From 0e70ff083ea4cdad70e56b303b6e740fc0f816b8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 17:38:09 -0800 Subject: [PATCH 08/16] remove default chat and autocomplete models --- core/config/default.ts | 20 ++----------------- .../components/BestExperienceConfigForm.tsx | 4 ---- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/core/config/default.ts b/core/config/default.ts index 8662be678..23e709603 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -5,20 +5,6 @@ import { SlashCommandDescription, } from "../"; -export const DEFAULT_CHAT_MODEL_CONFIG: ModelDescription = { - model: "claude-3-5-sonnet-latest", - provider: "anthropic", - apiKey: "", - title: "Claude 3.5 Sonnet", -}; - -export const DEFAULT_AUTOCOMPLETE_MODEL_CONFIG: ModelDescription = { - title: "Codestral", - provider: "mistral", - model: "codestral-latest", - apiKey: "", -}; - export const FREE_TRIAL_MODELS: ModelDescription[] = [ { title: "Claude 3.5 Sonnet (Free Trial)", @@ -93,15 +79,13 @@ export const defaultSlashCommandsJetBrains = [ ]; export const defaultConfig: SerializedContinueConfig = { - models: [DEFAULT_CHAT_MODEL_CONFIG], - tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG, + models: [], contextProviders: defaultContextProvidersVsCode, slashCommands: defaultSlashCommandsVscode, }; export const defaultConfigJetBrains: SerializedContinueConfig = { - models: [DEFAULT_CHAT_MODEL_CONFIG], - tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG, + models: [], contextProviders: defaultContextProvidersJetBrains, slashCommands: defaultSlashCommandsJetBrains, }; diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index 86e7cd693..98f71cce2 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -1,5 +1,4 @@ import { CubeIcon } from "@heroicons/react/24/outline"; -import { DEFAULT_CHAT_MODEL_CONFIG } from "core/config/default"; import { FormEventHandler, useContext, useState } from "react"; import { useDispatch } from "react-redux"; import { Button, Input, InputSubtext, lightGray } from "../.."; @@ -57,9 +56,6 @@ function BestExperienceConfigForm({ apiKey: autocompleteApiKey, }; - ideMessenger.post("config/deleteModel", { - title: DEFAULT_CHAT_MODEL_CONFIG.title, - }); ideMessenger.post("config/addModel", { model: chatModelConfig }); ideMessenger.post("config/addModel", { model: repoMapConfig, From dac8bae2ba3541fd976249e28d53fd5b3a53b08a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 17:52:37 -0800 Subject: [PATCH 09/16] hide onboarding close X's if no models in config --- gui/src/components/OnboardingCard/OnboardingCard.tsx | 4 +++- .../OnboardingCard/platform/PlatformOnboardingCard.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gui/src/components/OnboardingCard/OnboardingCard.tsx b/gui/src/components/OnboardingCard/OnboardingCard.tsx index eebbfb2bc..f48e2939d 100644 --- a/gui/src/components/OnboardingCard/OnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/OnboardingCard.tsx @@ -5,6 +5,7 @@ import styled from "styled-components"; import { CloseButton, defaultBorderRadius, vscInputBackground } from "../"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; import { useOnboardingCard } from "./hooks/useOnboardingCard"; +import { useAppSelector } from "../../redux/hooks"; const StyledCard = styled.div` margin: auto; @@ -26,6 +27,7 @@ interface OnboardingCardProps { export function OnboardingCard({ isDialog }: OnboardingCardProps) { const onboardingCard = useOnboardingCard(); + const config = useAppSelector((store) => store.config.config); function renderTabContent() { switch (onboardingCard.activeTab) { @@ -53,7 +55,7 @@ export function OnboardingCard({ isDialog }: OnboardingCardProps) { activeTab={onboardingCard.activeTab || "Best"} onTabClick={onboardingCard.setActiveTab} /> - {!isDialog && ( + {!isDialog && !!config.models.length && ( onboardingCard.close()}> diff --git a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx index ede9295b3..51e951497 100644 --- a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx @@ -8,6 +8,7 @@ import { TabTitle } from "../components/OnboardingCardTabs"; import { useOnboardingCard } from "../hooks"; import OnboardingLocalTab from "../tabs/OnboardingLocalTab"; import MainTab from "./tabs/main"; +import { useAppSelector } from "../../../redux/hooks"; const StyledCard = styled.div` margin: auto; @@ -29,6 +30,7 @@ interface OnboardingCardProps { export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) { const onboardingCard = useOnboardingCard(); + const config = useAppSelector((store) => store.config.config); if (getLocalStorage("onboardingStatus") === undefined) { setLocalStorage("onboardingStatus", "Started"); @@ -38,7 +40,7 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) { return ( - {!isDialog && ( + {!isDialog && !!config.models.length && ( onboardingCard.close()}> From 85fbf451ffc0d5465112de8494c2220f6018d4d8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 18:51:59 -0800 Subject: [PATCH 10/16] handle git diff errors and logic --- core/autocomplete/snippets/getAllSnippets.ts | 7 ++++++- .../v1/slashCommandFromPromptFile.ts | 17 +++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts index 198bf16c6..fc6538b41 100644 --- a/core/autocomplete/snippets/getAllSnippets.ts +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -90,7 +90,12 @@ const getClipboardSnippets = async ( const getDiffSnippets = async ( ide: IDE, ): Promise => { - const diff = await ide.getDiff(true); + let diff: string[] = []; + try { + diff = await ide.getDiff(true); + } catch (e) { + console.error("Error getting diff for autocomplete", e); + } return diff.map((item) => { return { diff --git a/core/promptFiles/v1/slashCommandFromPromptFile.ts b/core/promptFiles/v1/slashCommandFromPromptFile.ts index d89ee1082..b0dc0f881 100644 --- a/core/promptFiles/v1/slashCommandFromPromptFile.ts +++ b/core/promptFiles/v1/slashCommandFromPromptFile.ts @@ -25,15 +25,20 @@ async function renderPromptV1( ) { const helpers = getContextProviderHelpers(context); - // A few context providers that don't need to be in config.json to work in .prompt files - const diff = await context.ide.getDiff(true); - const currentFile = await context.ide.getCurrentFile(); const inputData: Record = { - diff: diff.join("\n"), input: userInput, }; - if (currentFile) { - inputData.currentFile = currentFile.path; + + // A few context providers that don't need to be in config.json to work in .prompt files + if (helpers?.find((helper) => helper[0] === "diff")) { + const diff = await context.ide.getDiff(true); + inputData.diff = diff.join("\n"); + } + if (helpers?.find((helper) => helper[0] === "currentFile")) { + const currentFile = await context.ide.getCurrentFile(); + if (currentFile) { + inputData.currentFile = currentFile.path; + } } return renderTemplatedString( From f2c6c9f4cb4ffedb0b8468f35546b2d654ec034f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 5 Feb 2025 18:58:04 -0800 Subject: [PATCH 11/16] check for HTTP at beginning of error message --- gui/src/pages/gui/StreamError.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/src/pages/gui/StreamError.tsx b/gui/src/pages/gui/StreamError.tsx index ca3bc04bc..2a8465c30 100644 --- a/gui/src/pages/gui/StreamError.tsx +++ b/gui/src/pages/gui/StreamError.tsx @@ -51,7 +51,8 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => { typeof error["message"] === "string" ) { message = error["message"]; - const status = message?.split(" ")[0]; + const parts = message?.split(" ") ?? []; + const status = parts[0] === "HTTP" ? parts[1] : parts[0]; if (status) { const code = Number(status); if (!Number.isNaN(statusCode)) { From 9fafa83ba19aead93947219e1294f20da7a33d42 Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Thu, 6 Feb 2025 11:51:31 +0800 Subject: [PATCH 12/16] Add gemini-2.0-flash to schema --- extensions/vscode/config_schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 827662dd2..d9dab076b 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -936,7 +936,8 @@ "gemini-1.5-flash-latest", "gemini-1.5-flash", "gemini-1.5-flash-8b", - "gemini-2.0-flash-exp" + "gemini-2.0-flash-exp", + "gemini-2.0-flash" ] } } From a1ff2f57419ecc700dd9d435c597f3f1c749fb8f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 6 Feb 2025 12:25:06 -0800 Subject: [PATCH 13/16] fix templateMessages null logic --- core/llm/autodetect.ts | 7 +++++-- core/llm/index.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 8232f8288..ed1901641 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -1,4 +1,4 @@ -import { ModelCapability, TemplateType } from "../index.js"; +import { ChatMessage, ModelCapability, TemplateType } from "../index.js"; import { anthropicTemplateMessages, @@ -257,7 +257,10 @@ function autodetectTemplateFunction( const templateType = explicitTemplate ?? autodetectTemplateType(model); if (templateType) { - const mapping: Record = { + const mapping: Record< + TemplateType, + null | ((msg: ChatMessage[]) => string) + > = { llama2: llama2TemplateMessages, alpaca: templateAlpacaMessages, phi2: phi2TemplateMessages, diff --git a/core/llm/index.ts b/core/llm/index.ts index da1825407..4989f14fa 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -191,7 +191,8 @@ export abstract class BaseLLM implements ILLM { options.model, this.providerName, options.template, - ); + ) ?? + undefined; this.writeLog = options.writeLog; this.llmRequestHook = options.llmRequestHook; this.apiKey = options.apiKey; @@ -957,7 +958,9 @@ export abstract class BaseLLM implements ILLM { this.providerName, autodetectTemplateType(this.model), ); - return templateMessages(rendered); + if (templateMessages) { + return templateMessages(rendered); + } } return rendered; } From 9140c1ea81f06f9e0756d4226b9d6bb87e3858c5 Mon Sep 17 00:00:00 2001 From: Adam Shedivy Date: Thu, 6 Feb 2025 16:47:48 -0600 Subject: [PATCH 14/16] Refactor reloadConfig method to use class property for additional context providers --- core/config/ConfigHandler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 4ad045d30..4638613b9 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -365,11 +365,11 @@ export class ConfigHandler { this.updateListeners.push(listener); } - async reloadConfig(additionalContextProviders: IContextProvider[] = []) { + async reloadConfig() { // TODO: this isn't right, there are two different senses in which you want to "reload" const { config, errors, configLoadInterrupted } = - await this.currentProfile.reloadConfig(additionalContextProviders); + await this.currentProfile.reloadConfig(this.additionalContextProviders); if (config) { this.inactiveProfiles.forEach((profile) => profile.clearConfig()); @@ -419,6 +419,6 @@ export class ConfigHandler { registerCustomContextProvider(contextProvider: IContextProvider) { this.additionalContextProviders.push(contextProvider); - void this.reloadConfig(this.additionalContextProviders); + void this.reloadConfig(); } } From f41cdd58d096ced9a8d6e76c9011187231a1cb7d Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 7 Feb 2025 07:22:14 -0800 Subject: [PATCH 15/16] Update preview.yaml --- .github/workflows/preview.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index bd5f4b7ac..b35e7d203 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -4,6 +4,13 @@ on: release: types: [prereleased] + workflow_dispatch: + inputs: + publish_build: + description: "Whether or not to publish the built extension to the VS Code marketplace" + required: true + default: false + jobs: check_release_name: runs-on: ubuntu-latest From d3d5e470e9436188d008753c0d3959708b3f6ae9 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 7 Feb 2025 09:41:38 -0800 Subject: [PATCH 16/16] Update preview.yaml --- .github/workflows/preview.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index b35e7d203..945f8d84b 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -28,7 +28,7 @@ jobs: build: needs: check_release_name - if: needs.check_release_name.outputs.should_run == 'true' + if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' strategy: matrix: include: @@ -204,6 +204,7 @@ jobs: runs-on: ubuntu-latest needs: - build + if: github.event.inputs.publish_build == 'true' permissions: contents: write steps: