Merge branch 'main' into pe/unsupported-cpu-check-pt-2

This commit is contained in:
Patrick Erichsen 2025-02-07 17:18:16 -08:00
commit fcd22d6c48
17 changed files with 280 additions and 44 deletions

View file

@ -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
@ -21,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:
@ -197,6 +204,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
if: github.event.inputs.publish_build == 'true'
permissions:
contents: write
steps:

View file

@ -90,7 +90,12 @@ const getClipboardSnippets = async (
const getDiffSnippets = async (
ide: IDE,
): Promise<AutocompleteDiffSnippet[]> => {
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 {

View file

@ -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();
}
}

View file

@ -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,
};

View file

@ -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<TemplateType, any> = {
const mapping: Record<
TemplateType,
null | ((msg: ChatMessage[]) => string)
> = {
llama2: llama2TemplateMessages,
alpaca: templateAlpacaMessages,
phi2: phi2TemplateMessages,

View file

@ -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;
}

View file

@ -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<string, string> = {
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(

View file

@ -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:

View file

@ -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"
]
}
}

View file

@ -580,7 +580,8 @@
{
"type": "webview",
"id": "continue.continueGUIView",
"name": "",
"name": "Continue",
"icon": "media/sidebar-icon.png",
"visibility": "visible"
}
]

View file

@ -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 (
<AuthProvider>
<LayoutTopDiv>
<OSRContextMenu />
<div
style={{
scrollbarGutter: "stable both-edges",

View file

@ -0,0 +1,222 @@
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;
left?: number;
bottom?: number;
right?: number;
}
const OSRContextMenu = () => {
const ideMessenger = useContext(IdeMessengerContext);
const isOSREnabled = useIsOSREnabled();
const platform = useRef(getPlatform());
const [position, setPosition] = useState<Position | null>(null);
const [canCopy, setCanCopy] = useState(false);
const [canCut, setCanCut] = useState(false);
const [canPaste, setCanPaste] = useState(false);
const menuRef = React.useRef<HTMLDivElement>(null);
const selectedTextRef = useRef<string | null>(null);
const selectedRangeRef = useRef<Range | null>(null);
function onMenuItemClick(
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
) {
event.preventDefault();
// restore selection
if (selectedRangeRef.current) {
const selection = window.getSelection();
selection?.removeAllRanges();
selection?.addRange(selectedRangeRef.current);
}
// Hide menu
setPosition(null);
}
useEffect(() => {
function leaveWindowHandler() {
setPosition(null);
}
function contextMenuHandler(event: MouseEvent) {
event.preventDefault();
}
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();
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) {
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,
});
}
}
}
}
setPosition(null);
if (isOSREnabled && platform.current !== "mac") {
document.addEventListener("mousedown", clickHandler);
document.addEventListener("mouseleave", leaveWindowHandler);
document.addEventListener("contextmenu", contextMenuHandler);
}
return () => {
document.removeEventListener("mousedown", clickHandler);
document.removeEventListener("mouseleave", leaveWindowHandler);
document.removeEventListener("contextmenu", contextMenuHandler);
};
}, [isOSREnabled]);
if (platform.current === "mac" || !isOSREnabled || !position) {
return null;
}
return (
<div
className="bg-vsc-editor-background absolute flex flex-col gap-1.5 overflow-hidden rounded-md border border-solid border-gray-500 px-3 py-1.5"
style={{
...position,
zIndex: 9999,
}}
ref={menuRef}
>
{canCopy && (
<div
className="cursor-pointer hover:opacity-90"
onClick={(e) => {
onMenuItemClick(e);
document.execCommand("copy");
}}
>
Copy
</div>
)}
{canCut && (
<div
className="cursor-pointer hover:opacity-90"
onClick={(e) => {
onMenuItemClick(e);
document.execCommand("cut");
}}
>
Cut
</div>
)}
{/* PASTING is currently broken, can't get the clipboard text */}
{/* {canPaste && (
<div
className="cursor-pointer hover:opacity-90"
onClick={async (e) => {
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
</div>
)} */}
<div
className="cursor-pointer hover:opacity-90"
onClick={(e) => {
onMenuItemClick(e);
ideMessenger.post("toggleDevTools", undefined);
}}
>
Open Dev Tools
</div>
</div>
);
};
export default OSRContextMenu;

View file

@ -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 && (
<CloseButton onClick={() => onboardingCard.close()}>
<XMarkIcon className="mt-1.5 hidden h-5 w-5 hover:brightness-125 sm:flex" />
</CloseButton>

View file

@ -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,

View file

@ -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 (
<StyledCard className="xs:py-4 xs:px-4 relative px-2 py-3">
{!isDialog && (
{!isDialog && !!config.models.length && (
<CloseButton onClick={() => onboardingCard.close()}>
<XMarkIcon className="mt-1.5 hidden h-5 w-5 hover:brightness-125 sm:flex" />
</CloseButton>

View file

@ -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<string, () => 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;

View file

@ -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)) {