diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts index c04696d10..b0941932b 100644 --- a/core/config/migrateSharedConfig.ts +++ b/core/config/migrateSharedConfig.ts @@ -7,12 +7,16 @@ import { SharedConfigSchema } from "./sharedConfig"; import { GlobalContext } from "../util/GlobalContext"; import { editConfigJson } from "../util/paths"; import { resolveSerializedConfig } from "./load"; +import { deduplicateArray } from "../util"; /* This migration function eliminates deprecated values from the json file And writes them to the shared config */ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { + const globalContext = new GlobalContext(); + const currentSharedConfig = globalContext.getSharedConfig(); // for merging security concerns + try { let config = resolveSerializedConfig(filepath); const shareConfigUpdates: SharedConfigSchema = {}; @@ -21,21 +25,30 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { const { allowAnonymousTelemetry, ...withoutAllowTelemetry } = config; if (allowAnonymousTelemetry !== undefined) { - shareConfigUpdates.allowAnonymousTelemetry = allowAnonymousTelemetry; + if (currentSharedConfig.allowAnonymousTelemetry !== false) { + // safe merge for security + shareConfigUpdates.allowAnonymousTelemetry = allowAnonymousTelemetry; + } config = withoutAllowTelemetry; effected = true; } const { disableIndexing, ...withoutDisableIndexing } = config; if (disableIndexing !== undefined) { - shareConfigUpdates.disableIndexing = disableIndexing; + if (currentSharedConfig.disableIndexing !== true) { + // safe merge for security + shareConfigUpdates.disableIndexing = disableIndexing; + } config = withoutDisableIndexing; effected = true; } const { disableSessionTitles, ...withoutDisableSessionTitles } = config; if (config.disableSessionTitles !== undefined) { - shareConfigUpdates.disableSessionTitles = config.disableSessionTitles; + if (currentSharedConfig.disableSessionTitles !== true) { + // safe merge for security + shareConfigUpdates.disableSessionTitles = config.disableSessionTitles; + } config = withoutDisableSessionTitles; effected = true; } @@ -62,15 +75,31 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { const { disableInFiles, ...withoutDisableInFiles } = migratedAutocomplete; if (disableInFiles !== undefined) { + if (currentSharedConfig.disableAutocompleteInFiles !== undefined) { + // safe merge for security + shareConfigUpdates.disableAutocompleteInFiles = deduplicateArray( + [ + ...currentSharedConfig.disableAutocompleteInFiles, + ...disableInFiles, + ], + (a, b) => a === b, + ); + } else { + shareConfigUpdates.disableAutocompleteInFiles = disableInFiles; + } shareConfigUpdates.disableAutocompleteInFiles = disableInFiles; migratedAutocomplete = withoutDisableInFiles; effected = true; } - config = { - ...withoutAutocompleteOptions, - tabAutocompleteOptions: migratedAutocomplete, - }; + if (Object.keys(migratedAutocomplete).length > 0) { + config = { + ...withoutAutocompleteOptions, + tabAutocompleteOptions: migratedAutocomplete, + }; + } else { + config = withoutAutocompleteOptions; + } } const { experimental, ...withoutExperimental } = config; @@ -99,10 +128,14 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { effected = true; } - config = { - ...withoutExperimental, - experimental: migratedExperimental, - }; + if (Object.keys(migratedExperimental).length > 0) { + config = { + ...withoutExperimental, + experimental: migratedExperimental, + }; + } else { + config = withoutExperimental; + } } const { ui, ...withoutUI } = config; @@ -145,10 +178,14 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { effected = true; } - config = { - ...withoutUI, - ui: migratedUI, - }; + if (Object.keys(migratedUI).length > 0) { + config = { + ...withoutUI, + ui: migratedUI, + }; + } else { + config = withoutUI; + } } if (effected) { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 38d0db7c8..c9d9e1741 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.254", + "version": "0.9.255", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.254", + "version": "0.9.255", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/gui/NumberInput.tsx b/gui/src/components/gui/NumberInput.tsx new file mode 100644 index 000000000..ce27c1cf8 --- /dev/null +++ b/gui/src/components/gui/NumberInput.tsx @@ -0,0 +1,61 @@ +import React from "react"; + +interface NumberInputProps { + value: number; + onChange: (value: number) => void; + max: number; + min: number; +} + +const NumberInput: React.FC = ({ + value, + onChange, + max, + min, +}) => { + const handleIncrement = () => { + if (value < max) { + onChange(value + 1); + } + }; + + const handleDecrement = () => { + if (value > min) { + onChange(value - 1); + } + }; + + return ( +
+ +
+ + +
+
+ ); +}; + +export default NumberInput; diff --git a/gui/src/components/gui/Select.tsx b/gui/src/components/gui/Select.tsx new file mode 100644 index 000000000..01ec79242 --- /dev/null +++ b/gui/src/components/gui/Select.tsx @@ -0,0 +1,48 @@ +// export const Select = styled.select` +// padding: 8px 12px; +// border-radius: ${defaultBorderRadius}; +// border: 1px solid ${vscInputBorder}; +// background-color: ${vscBackground}; +// color: ${vscForeground}; + +import { vscBackground, vscForeground, vscInputBorder } from ".."; + +// appearance: none; +// -webkit-appearance: none; +// -moz-appearance: none; +// padding-right: 30px; +// background: url('data:image/svg+xml;utf8,') +// no-repeat right 10px center; +// background-size: 10px 10px; +// `; + +// // gui/src/components/gui/Select.tsx +// import React from 'react'; + +export const Select: React.FC> = ( + props, +) => ( +
+ +
+); diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx index ab71510f2..9ca52e5d3 100644 --- a/gui/src/components/gui/Switch.tsx +++ b/gui/src/components/gui/Switch.tsx @@ -12,14 +12,10 @@ const ToggleSwitch: React.FC = ({ text, }) => { return ( - + ); }; diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 071900b51..8f1455c67 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -154,6 +154,13 @@ export const Button = styled.button` } `; +type NumberInputProps = { + value: number; + onChange: (value: number) => void; + max?: number; + min?: number; +}; + export const SecondaryButton = styled.button` padding: 10px 12px; margin: 8px 0; @@ -250,17 +257,6 @@ export const Input = styled.input` } `; -export const Select = styled.select` - padding: 8px 12px; - margin: 8px 0; - box-sizing: border-box; - border-radius: ${defaultBorderRadius}; - outline: 1px solid ${lightGray}; - border: none; - background-color: ${vscBackground}; - color: ${vscForeground}; -`; - export const Label = styled.label<{ fontSize?: number }>` font-size: ${(props) => props.fontSize || getFontSize()}px; `; diff --git a/gui/src/components/modelSelection/ModelSettings.tsx b/gui/src/components/modelSelection/ModelSettings.tsx deleted file mode 100644 index 4198ffba1..000000000 --- a/gui/src/components/modelSelection/ModelSettings.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { useState } from "react"; -import { useFormContext } from "react-hook-form"; -import styled from "styled-components"; -import { Input, Label, Select, defaultBorderRadius, lightGray } from ".."; -import { getFontSize } from "../../util"; - -const Div = styled.div<{ dashed: boolean }>` - border: 1px ${(props) => (props.dashed ? "dashed" : "solid")} ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 8px; - margin-bottom: 16px; -`; - -type ModelOption = "apiKey" | "model" | "contextLength"; - -const DefaultModelOptions: { - [key: string]: { [key in ModelOption]?: string }; -} = { - OpenAI: { - apiKey: "", - model: "gpt-4", - }, - OpenAIFreeTrial: { - apiKey: "", - model: "gpt-4", - }, - Anthropic: { - apiKey: "", - model: "claude-2", - }, - default: { - apiKey: "", - model: "gpt-4", - }, -}; - -function ModelSettings(props: { llm: any | undefined; role: string }) { - const [modelOptions, setModelOptions] = useState<{ - [key in ModelOption]?: string; - }>(DefaultModelOptions[props.llm?.class_name || "default"]); - - const { register, setValue, getValues } = useFormContext(); - - return ( -
- {props.llm ? ( - <> - {props.role}: {props.llm?.class_name || "gpt-4"} -
- {typeof modelOptions.apiKey !== undefined && ( - <> - - - - )} - {modelOptions.model && ( - <> - - - - )} -
- - ) : ( -
- Add Model -
- -
-
- )} -
- ); -} - -export default ModelSettings; diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 67e38dee4..62d5df8d2 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -8,11 +8,13 @@ import { modifyContinueConfigWithSharedConfig, SharedConfigSchema, } from "core/config/sharedConfig"; -import { Switch } from "@headlessui/react"; import { updateConfig } from "../../redux/slices/configSlice"; import ToggleSwitch from "../../components/gui/Switch"; import { useAuth } from "../../context/Auth"; import { Button } from "../../components"; +import { getFontSize } from "../../util"; +import NumberInput from "../../components/gui/NumberInput"; +import { Select } from "../../components/gui/Select"; function ConfigPage() { useNavigationListener(); @@ -37,6 +39,8 @@ function ConfigPage() { } // Account for default values + // TODO - duplicate defaults here, should consolidate defaults to one place + // And write defaults earlier in the config process const codeWrap = config.ui?.codeWrap ?? false; const showChatScrollbar = config.ui?.showChatScrollbar ?? false; const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; @@ -49,6 +53,11 @@ function ConfigPage() { const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false; const useChromiumForDocsCrawling = config.experimental?.useChromiumForDocsCrawling ?? false; + const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top"; + const useAutocompleteMultilineCompletions = + config.tabAutocompleteOptions?.multilineCompletions ?? "auto"; + + const fontSize = getFontSize(); function handleOpenConfig() { if (!selectedProfile) { @@ -62,117 +71,161 @@ function ConfigPage() { return (
navigate("/")} title="Chat" /> -

Continue Configuration

+

Continue Config

{!selectedProfile ? (

No config profile selected

) : ( -
- +
+
+ +

Other Settings

- - handleUpdate({ - codeWrap: !codeWrap, - }) - } - text="Wrap Codeblocks" - > - - handleUpdate({ - displayRawMarkdown: !displayRawMarkdown, - }) - } - text="Display Raw Markdown" - > - - handleUpdate({ - allowAnonymousTelemetry: !allowAnonymousTelemetry, - }) - } - text="Allow Anonymous Telemetry" - > - - handleUpdate({ - disableIndexing: !disableIndexing, - }) - } - text="Disable Indexing" - > +
+ + handleUpdate({ + codeWrap: !codeWrap, + }) + } + text="Wrap Codeblocks" + /> + + handleUpdate({ + displayRawMarkdown: !displayRawMarkdown, + }) + } + text="Display Raw Markdown" + /> + + handleUpdate({ + allowAnonymousTelemetry: !allowAnonymousTelemetry, + }) + } + text="Allow Anonymous Telemetry" + /> + + handleUpdate({ + disableIndexing: !disableIndexing, + }) + } + text="Disable Indexing" + /> - - handleUpdate({ - disableSessionTitles: !disableSessionTitles, - }) - } - text="Disable Session Titles" - > + + handleUpdate({ + disableSessionTitles: !disableSessionTitles, + }) + } + text="Disable Session Titles" + /> + + handleUpdate({ + readResponseTTS: !readResponseTTS, + }) + } + text="Response Text to Speech" + /> - - handleUpdate({ - readResponseTTS: !readResponseTTS, - }) - } - text="Read Response TTS" - > + + handleUpdate({ + showChatScrollbar: !showChatScrollbar, + }) + } + text="Show Chat Scrollbar" + /> - - handleUpdate({ - showChatScrollbar: !showChatScrollbar, - }) - } - text="Show Chat Scrollbar" - > + {/* disableAutocompleteInFiles: z.array(z.string()), */} - {/* */} + {/* promptPath: z.string(), */} - {/* codeBlockToolbarPosition: z.enum(["top", "bottom"]), */} + {/* Other */} + + handleUpdate({ + useAutocompleteCache: !useAutocompleteCache, + }) + } + text="Use Autocomplete Cache" + /> - {/* disableAutocompleteInFiles: z.array(z.string()), */} + {/* Other */} + + handleUpdate({ + useChromiumForDocsCrawling: !useChromiumForDocsCrawling, + }) + } + text="Use Chromium for Docs Crawling" + /> - {/* promptPath: z.string(), */} + - {/* useAutocompleteMultilineCompletions: z.enum(["always", "never", "auto"]), */} + - {/* Other */} - - handleUpdate({ - useAutocompleteCache: !useAutocompleteCache, - }) - } - text="Use Chromium for Docs Crawling" - > - - {/* Other */} - - handleUpdate({ - useChromiumForDocsCrawling: !useChromiumForDocsCrawling, - }) - } - text="Use Chromium for Docs Crawling" - > + +
)}