diff --git a/core/config/load.ts b/core/config/load.ts index c8499dc8b..41507b200 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -62,7 +62,11 @@ import { getEsbuildBinaryPath, } from "../util/paths"; -import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; +import { + ConfigResult, + ConfigValidationError, + ModelRole, +} from "@continuedev/config-yaml"; import { useHub } from "../control-plane/env"; import { localPathToUri } from "../util/pathToUri"; import { @@ -72,7 +76,7 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; -import { modifyContinueConfigWithSharedConfig } from "./sharedConfig"; +import { modifyAnyConfigWithSharedConfig } from "./sharedConfig"; import { validateConfig } from "./validation.js"; export function resolveSerializedConfig( @@ -178,7 +182,7 @@ async function serializedToIntermediateConfig( initial: SerializedContinueConfig, ide: IDE, ): Promise { - // DEPRECATED - load custom slash commands + // DEPRECATED - load cuastom slash commands const slashCommands: SlashCommand[] = []; for (const command of initial.slashCommands || []) { const newCommand = slashCommandFromDescription(command); @@ -497,6 +501,24 @@ async function intermediateToFinalConfig( tabAutocompleteModels, reranker: config.reranker as any, tools: allTools, + modelsByRole: { + chat: [], + edit: [], + apply: [], + embed: [], + autocomplete: [], + rerank: [], + summarize: [], + }, + selectedModelByRole: { + chat: null, + edit: null, + apply: null, + embed: null, + autocomplete: null, + rerank: null, + summarize: null, + }, }; // Apply MCP if specified @@ -541,27 +563,31 @@ async function intermediateToFinalConfig( return { config: continueConfig, errors }; } +function llmToSerializedModelDescription(llm: ILLM): ModelDescription { + return { + provider: llm.providerName, + model: llm.model, + title: llm.title ?? llm.model, + apiKey: llm.apiKey, + apiBase: llm.apiBase, + contextLength: llm.contextLength, + template: llm.template, + completionOptions: llm.completionOptions, + systemMessage: llm.systemMessage, + requestOptions: llm.requestOptions, + promptTemplates: llm.promptTemplates as any, + capabilities: llm.capabilities, + roles: llm.roles, + }; +} + async function finalToBrowserConfig( final: ContinueConfig, ide: IDE, ): Promise { return { allowAnonymousTelemetry: final.allowAnonymousTelemetry, - models: final.models.map((m) => ({ - provider: m.providerName, - model: m.model, - title: m.title ?? m.model, - apiKey: m.apiKey, - apiBase: m.apiBase, - contextLength: m.contextLength, - template: m.template, - completionOptions: m.completionOptions, - systemMessage: m.systemMessage, - requestOptions: m.requestOptions, - promptTemplates: m.promptTemplates as any, - capabilities: m.capabilities, - roles: m.roles, - })), + models: final.models.map(llmToSerializedModelDescription), systemMessage: final.systemMessage, completionOptions: final.completionOptions, slashCommands: final.slashCommands?.map((s) => ({ @@ -580,6 +606,13 @@ async function finalToBrowserConfig( tools: final.tools, tabAutocompleteOptions: final.tabAutocompleteOptions, usePlatform: await useHub(ide.getIdeSettings()), + modelsByRole: Object.fromEntries( + Object.entries(final.modelsByRole).map(([k, v]) => [ + k, + v.map(llmToSerializedModelDescription), + ]), + ) as unknown as Record, // TODO better types here + selectedModelByRole: final.selectedModelByRole, }; } @@ -798,10 +831,7 @@ async function loadContinueConfigFromJson( // Apply shared config // TODO: override several of these values with user/org shared config const sharedConfig = new GlobalContext().getSharedConfig(); - const withShared = modifyContinueConfigWithSharedConfig( - serialized, - sharedConfig, - ); + const withShared = modifyAnyConfigWithSharedConfig(serialized, sharedConfig); // Convert serialized to intermediate config let intermediate = await serializedToIntermediateConfig(withShared, ide); diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts index 189bb21ed..6586c604b 100644 --- a/core/config/migrateSharedConfig.ts +++ b/core/config/migrateSharedConfig.ts @@ -124,6 +124,46 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { effected = true; } + const { modelRoles, ...withoutModelRoles } = migratedExperimental; + if (modelRoles !== undefined) { + let migratedModelRoles = { ...modelRoles }; + + const { applyCodeBlock, ...rest90 } = migratedModelRoles; + if (applyCodeBlock !== undefined) { + shareConfigUpdates.selectedModels = { + ...currentSharedConfig.selectedModels, + local: { + ...currentSharedConfig.selectedModels?.["local"], + apply: applyCodeBlock, + }, + }; + migratedModelRoles = rest90; + effected = true; + } + + const { inlineEdit, ...rest91 } = migratedModelRoles; + if (inlineEdit !== undefined) { + shareConfigUpdates.selectedModels = { + ...currentSharedConfig.selectedModels, + local: { + ...currentSharedConfig.selectedModels?.["local"], + edit: inlineEdit, + }, + }; + migratedModelRoles = rest91; + effected = true; + } + + if (Object.keys(migratedModelRoles).length > 0) { + migratedExperimental = { + ...migratedExperimental, + modelRoles: migratedModelRoles, + }; + } else { + migratedExperimental = withoutModelRoles; + } + } + if (Object.keys(migratedExperimental).length > 0) { config = { ...withoutExperimental, diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts index 9f2335243..9ac797841 100644 --- a/core/config/sharedConfig.ts +++ b/core/config/sharedConfig.ts @@ -5,9 +5,19 @@ import { Config, SerializedContinueConfig, } from ".."; +import { + ModelRole, + modelRolesSchema, +} from "@continuedev/config-yaml/dist/schemas/models"; export const sharedConfigSchema = z .object({ + selectedModels: z.record( + z.string(), + z.record(modelRolesSchema, z.string()), + ), + + // boolean fields in config.json allowAnonymousTelemetry: z.boolean(), disableIndexing: z.boolean(), disableSessionTitles: z.boolean(), @@ -65,7 +75,19 @@ export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema { return salvagedConfig; } -export function modifyContinueConfigWithSharedConfig< +// Apply shared config to all forms of config +// - SerializedContinueConfig (config.json) +// - Config ("intermediate") - passed to config.ts +// - ContinueConfig +// - BrowserSerializedContinueConfig (final converted to be passed to GUI) + +// This modify function is split into two steps +// - modifyAnyConfigWithSharedConfig - includes boolean flags like allowAnonymousTelemetry which +// must be added BEFORE config.ts and remote server config apply for JSON +// for security reasons +// - modifyFinalConfigWithSharedConfig - exists because of selectedModelsByRole +// Which don't exist on SerializedContinueConfig/Config types, so must be added after the fact +export function modifyAnyConfigWithSharedConfig< T extends | ContinueConfig | BrowserSerializedContinueConfig @@ -92,6 +114,7 @@ export function modifyContinueConfigWithSharedConfig< configCopy.ui = { ...configCopy.ui, }; + if (sharedConfig.codeBlockToolbarPosition !== undefined) { configCopy.ui.codeBlockToolbarPosition = sharedConfig.codeBlockToolbarPosition; @@ -136,27 +159,23 @@ export function modifyContinueConfigWithSharedConfig< return configCopy; } -// continueConfig.tabAutocompleteOptions = { -// ...continueConfig.tabAutocompleteOptions, -// useCache: sharedConfig.useAutocompleteCache, -// disableInFiles: sharedConfig.disableAutocompleteInFiles, -// multilineCompletions: sharedConfig.useAutocompleteMultilineCompletions, -// }; -// continueConfig.ui = { -// ...continueConfig.ui, -// codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition, -// fontSize: sharedConfig.fontSize, -// codeWrap: sharedConfig.codeWrap, -// displayRawMarkdown: sharedConfig.displayRawMarkdown, -// showChatScrollbar: sharedConfig.showChatScrollbar, -// }; -// continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; -// continueConfig.disableIndexing = sharedConfig.disableIndexing; -// continueConfig.disableIndexing = sharedConfig.disableIndexing; -// continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles; -// continueConfig.experimental = { -// ...continueConfig.experimental, -// useChromiumForDocsCrawling: sharedConfig.useChromiumForDocsCrawling, -// readResponseTTS: sharedConfig.readResponseTTS, -// promptPath: sharedConfig.promptPath, -// }; +export function modifyFinalConfigWithSharedConfig< + T extends ContinueConfig | BrowserSerializedContinueConfig, +>( + continueConfig: T, + sharedConfig: SharedConfigSchema, + selectedProfileId: string | null, +): T { + const configCopy = { ...continueConfig }; + const selectedModelsForProfile: Record = { + apply: null, + autocomplete: null, + chat: null, + edit: null, + embed: null, + rerank: null, + summarize: null, + }; + configCopy.selectedModelByRole = selectedModelsForProfile; + return configCopy; +} diff --git a/core/config/types.ts b/core/config/types.ts index 2a68c4c35..5b2f124c0 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -957,8 +957,6 @@ declare global { } interface ExperimentalModelRoles { - inlineEdit?: string; - applyCodeBlock?: string; repoMapFileSelection?: string; } diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 37abaf83e..1da57ba81 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -37,7 +37,7 @@ import { GlobalContext } from "../../util/GlobalContext"; import { getConfigYamlPath } from "../../util/paths"; import { getSystemPromptDotFile } from "../getSystemPromptDotFile"; import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; -import { modifyContinueConfigWithSharedConfig } from "../sharedConfig"; +import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { llmsFromModelConfig } from "./models"; @@ -132,12 +132,30 @@ async function configYamlToContinueConfig( faviconUrl: doc.faviconUrl, })), contextProviders: [], + modelsByRole: { + chat: [], + edit: [], + apply: [], + embed: [], + autocomplete: [], + rerank: [], + summarize: [], + }, + selectedModelByRole: { + chat: null, // not currently used - defaultModel on GUI is used + edit: null, // not currently used + apply: null, + embed: null, + autocomplete: null, + rerank: null, + summarize: null, + }, }; // Models const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"]; for (const model of config.models ?? []) { - model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified + model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 roles if not specified if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { // Main model array const llms = await llmsFromModelConfig( @@ -392,7 +410,7 @@ export async function loadContinueConfigFromYaml( // Apply shared config // TODO: override several of these values with user/org shared config const sharedConfig = new GlobalContext().getSharedConfig(); - const withShared = modifyContinueConfigWithSharedConfig( + const withShared = modifyAnyConfigWithSharedConfig( continueConfig, sharedConfig, ); diff --git a/core/context/retrieval/repoMapRequest.ts b/core/context/retrieval/repoMapRequest.ts index 39223321b..7115b2d18 100644 --- a/core/context/retrieval/repoMapRequest.ts +++ b/core/context/retrieval/repoMapRequest.ts @@ -16,7 +16,7 @@ function isSupportedModel( config: ContinueConfig, modelTitle?: string, ): boolean { - if (config.experimental?.modelRoles?.applyCodeBlock) { + if (config.experimental?.modelRoles?.repoMapFileSelection) { return true; } diff --git a/core/index.d.ts b/core/index.d.ts index 7d882cb27..6c2b3ed23 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -43,13 +43,13 @@ export interface IndexingProgressUpdate { desc: string; shouldClearIndexes?: boolean; status: - | "loading" - | "indexing" - | "done" - | "failed" - | "paused" - | "disabled" - | "cancelled"; + | "loading" + | "indexing" + | "done" + | "failed" + | "paused" + | "disabled" + | "cancelled"; debugInfo?: string; } @@ -667,10 +667,10 @@ export interface IDE { getCurrentFile(): Promise< | undefined | { - isUntitled: boolean; - path: string; - contents: string; - } + isUntitled: boolean; + path: string; + contents: string; + } >; getLastFileSaveTimestamp?(): number; @@ -853,11 +853,11 @@ export interface CustomCommand { export interface Prediction { type: "content"; content: - | string - | { - type: "text"; - text: string; - }[]; + | string + | { + type: "text"; + text: string; + }[]; } export interface ToolExtras { @@ -1028,9 +1028,9 @@ export interface ContextMenuConfig { } export interface ExperimentalModelRoles { - inlineEdit?: string; - applyCodeBlock?: string; repoMapFileSelection?: string; + inlineEdit?: string; // DEPRECATED - this is removed from config.json if detected + applyCodeBlock?: string; // DEPRECATED - this removed from config.json if detected } export type EditStatus = @@ -1186,9 +1186,9 @@ export interface Config { embeddingsProvider?: EmbeddingsProviderDescription | ILLM; /** The model that Continue will use for tab autocompletions. */ tabAutocompleteModel?: - | CustomLLM - | ModelDescription - | (CustomLLM | ModelDescription)[]; + | CustomLLM + | ModelDescription + | (CustomLLM | ModelDescription)[]; /** Options for tab autocomplete */ tabAutocompleteOptions?: Partial; /** UI styles customization */ @@ -1222,6 +1222,8 @@ export interface ContinueConfig { analytics?: AnalyticsConfig; docs?: SiteIndexingConfig[]; tools: Tool[]; + modelsByRole: Record; + selectedModelByRole: Record; } export interface BrowserSerializedContinueConfig { @@ -1244,6 +1246,8 @@ export interface BrowserSerializedContinueConfig { tools: Tool[]; usePlatform: boolean; tabAutocompleteOptions?: Partial; + modelsByRole: Record; + selectedModelByRole: Record; } // DOCS SUGGESTIONS AND PACKAGE INFO @@ -1279,9 +1283,9 @@ export type PackageDetailsSuccess = PackageDetails & { export type PackageDocsResult = { packageInfo: ParsedPackageInfo; } & ( - | { error: string; details?: never } - | { details: PackageDetailsSuccess; error?: never } - ); + | { error: string; details?: never } + | { details: PackageDetailsSuccess; error?: never } +); export interface TerminalOptions { reuseTerminal?: boolean; diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 4d09d4ac6..9e28b79e1 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -354,8 +354,6 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: - - `inlineEdit`: Model title for inline edits. - - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `quickActions`: Array of custom quick actions - `title` (**required**): Display title for the quick action. @@ -374,7 +372,7 @@ Example { "experimental": { "modelRoles": { - "inlineEdit": "Edit Model" + "repoMapFileSelection": "My Favorite Repo Map Selection Model" }, "quickActions": [ { diff --git a/docs/docs/yaml-migration.md b/docs/docs/yaml-migration.md index 04f1b4e15..38583f868 100644 --- a/docs/docs/yaml-migration.md +++ b/docs/docs/yaml-migration.md @@ -145,7 +145,7 @@ models: - apply ``` -Note that the `repoMapFileSelection` experimental model role has been deprecated. +Note that the `repoMapFileSelection` experimental model role has been deprecated and is only available in `config.json`. ### Context Providers diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 98addf212..56acacca6 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -399,8 +399,6 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: - - `inlineEdit`: Model title for inline edits. - - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `readResponseTTS`: If `true`, reads LLM responses aloud with TTS. Default is `true`. - `promptPath`: Change the path to custom prompt files from the default ".prompts" diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 259d3e7c8..cb0ce8c20 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3211,14 +3211,6 @@ "modelRoles": { "type": "object", "properties": { - "inlineEdit": { - "description": "The 'title' property of the model you wish to use for inline edits", - "type": "string" - }, - "applyCodeBlock": { - "description": "The 'title' property of the model you wish to use for applying code blocks", - "type": "string" - }, "repoMapFileSelection": { "description": "The 'title' property of the model you wish to use for repo map file selections", "type": "string" diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5372a9c97..57f283f76 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/pages/config/UserSettings.tsx b/gui/src/pages/config/UserSettings.tsx deleted file mode 100644 index 6912cd031..000000000 --- a/gui/src/pages/config/UserSettings.tsx +++ /dev/null @@ -1,322 +0,0 @@ -import { useContext, useEffect, useState } from "react"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../redux/hooks"; - -import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; -import { - SharedConfigSchema, - modifyContinueConfigWithSharedConfig, -} from "core/config/sharedConfig"; -import { Input } from "../../components"; -import NumberInput from "../../components/gui/NumberInput"; -import { Select } from "../../components/gui/Select"; -import ToggleSwitch from "../../components/gui/Switch"; -import { updateConfig } from "../../redux/slices/configSlice"; -import { getFontSize } from "../../util"; - -function UserSettingsUI() { - const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - - const config = useAppSelector((state) => state.config.config); - - function handleUpdate(sharedConfig: Partial) { - dispatch( - updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)), - ); - ideMessenger.post("config/updateSharedConfig", sharedConfig); - } - - // TODO defaults are in multiple places, should be consolidated and probably not explicit here - const codeWrap = config.ui?.codeWrap ?? false; - const showChatScrollbar = config.ui?.showChatScrollbar ?? false; - const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; - const disableSessionTitles = config.disableSessionTitles ?? false; - const readResponseTTS = config.experimental?.readResponseTTS ?? false; - - const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true; - const disableIndexing = config.disableIndexing ?? false; - - 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(); - - // Disable autocomplete - const disableAutocompleteInFiles = ( - config.tabAutocompleteOptions?.disableInFiles ?? [] - ).join(", "); - const [formDisableAutocomplete, setFormDisableAutocomplete] = useState( - disableAutocompleteInFiles, - ); - const cancelChangeDisableAutocomplete = () => { - setFormDisableAutocomplete(disableAutocompleteInFiles); - }; - const handleDisableAutocompleteSubmit = () => { - handleUpdate({ - disableAutocompleteInFiles: formDisableAutocomplete - .split(",") - .map((val) => val.trim()) - .filter((val) => !!val), - }); - }; - - useEffect(() => { - // Necessary so that reformatted/trimmed values don't cause dirty state - setFormDisableAutocomplete(disableAutocompleteInFiles); - }, [disableAutocompleteInFiles]); - - // Workspace prompts - const promptPath = config.experimental?.promptPath || ""; - const [formPromptPath, setFormPromptPath] = useState(promptPath); - const cancelChangePromptPath = () => { - setFormPromptPath(promptPath); - }; - const handleSubmitPromptPath = () => { - handleUpdate({ - promptPath: formPromptPath || "", - }); - }; - - useEffect(() => { - // Necessary so that reformatted/trimmed values don't cause dirty state - setFormPromptPath(promptPath); - }, [promptPath]); - - return ( -
-
-

User 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({ - disableSessionTitles: !disableSessionTitles, - }) - } - text="Disable Session Titles" - /> - - handleUpdate({ - readResponseTTS: !readResponseTTS, - }) - } - text="Response Text to Speech" - /> - - - handleUpdate({ - showChatScrollbar: !showChatScrollbar, - }) - } - text="Show Chat Scrollbar" - /> - - - handleUpdate({ - useAutocompleteCache: !useAutocompleteCache, - }) - } - text="Use Autocomplete Cache" - /> - - - handleUpdate({ - useChromiumForDocsCrawling: !useChromiumForDocsCrawling, - }) - } - text="Use Chromium for Docs Crawling" - /> - - - - - - - -
{ - e.preventDefault(); - handleSubmitPromptPath(); - }} - > -
- Workspace prompts path -
- { - setFormPromptPath(e.target.value); - }} - /> -
- {formPromptPath !== promptPath ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
-
-
{ - e.preventDefault(); - handleDisableAutocompleteSubmit(); - }} - > -
- Disable autocomplete in files -
- { - setFormDisableAutocomplete(e.target.value); - }} - /> -
- {formDisableAutocomplete !== disableAutocompleteInFiles ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
- - Comma-separated list of path matchers - -
-
-
- ); -} - -export default UserSettingsUI; diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 6a00aa8cc..a482ad8cb 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -3,14 +3,28 @@ import { useNavigate } from "react-router-dom"; import PageHeader from "../../components/PageHeader"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { useAppDispatch } from "../../redux/hooks"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { SecondaryButton } from "../../components"; import { useAuth } from "../../context/Auth"; import { ScopeSelect } from "./ScopeSelect"; -import UserSettingsUI from "./UserSettings"; import { Listbox, Transition } from "@headlessui/react"; -import { ChevronUpDownIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; +import { + CheckIcon, + XMarkIcon, + ChevronUpDownIcon, + PlusCircleIcon, +} from "@heroicons/react/24/outline"; import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; +import { + SharedConfigSchema, + modifyAnyConfigWithSharedConfig, +} from "core/config/sharedConfig"; +import { Input } from "../../components"; +import NumberInput from "../../components/gui/NumberInput"; +import { Select } from "../../components/gui/Select"; +import ToggleSwitch from "../../components/gui/Switch"; +import { updateConfig } from "../../redux/slices/configSlice"; +import { getFontSize } from "../../util"; function ConfigPage() { useNavigationListener(); @@ -51,6 +65,77 @@ function ConfigPage() { // NOTE Hub takes priority over Continue for Teams // Since teams will be moving to hub, not vice versa + /////// User settings section ////// + const config = useAppSelector((state) => state.config.config); + + function handleUpdate(sharedConfig: SharedConfigSchema) { + // Optimistic update + dispatch( + updateConfig(modifyAnyConfigWithSharedConfig(config, sharedConfig)), + ); + // Actual update to core which propogates back with config update event + ideMessenger.post("config/updateSharedConfig", sharedConfig); + } + + // TODO defaults are in multiple places, should be consolidated and probably not explicit here + const codeWrap = config.ui?.codeWrap ?? false; + const showChatScrollbar = config.ui?.showChatScrollbar ?? false; + const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; + const disableSessionTitles = config.disableSessionTitles ?? false; + const readResponseTTS = config.experimental?.readResponseTTS ?? false; + + const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true; + const disableIndexing = config.disableIndexing ?? false; + + 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(); + + // Disable autocomplete + const disableAutocompleteInFiles = ( + config.tabAutocompleteOptions?.disableInFiles ?? [] + ).join(", "); + const [formDisableAutocomplete, setFormDisableAutocomplete] = useState( + disableAutocompleteInFiles, + ); + const cancelChangeDisableAutocomplete = () => { + setFormDisableAutocomplete(disableAutocompleteInFiles); + }; + const handleDisableAutocompleteSubmit = () => { + handleUpdate({ + disableAutocompleteInFiles: formDisableAutocomplete + .split(",") + .map((val) => val.trim()) + .filter((val) => !!val), + }); + }; + + useEffect(() => { + // Necessary so that reformatted/trimmed values don't cause dirty state + setFormDisableAutocomplete(disableAutocompleteInFiles); + }, [disableAutocompleteInFiles]); + + // Workspace prompts + const promptPath = config.experimental?.promptPath || ""; + const [formPromptPath, setFormPromptPath] = useState(promptPath); + const cancelChangePromptPath = () => { + setFormPromptPath(promptPath); + }; + const handleSubmitPromptPath = () => { + handleUpdate({ + promptPath: formPromptPath || "", + }); + }; + + useEffect(() => { + // Necessary so that reformatted/trimmed values don't cause dirty state + setFormPromptPath(promptPath); + }, [promptPath]); + return (
navigate("/")} title="Chat" /> @@ -166,12 +251,247 @@ function ConfigPage() { : "Open Workspace"} )} +

Model Roles

+
{!controlServerBetaEnabled || hubEnabled ? (
- +
+
+

User 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({ + disableSessionTitles: !disableSessionTitles, + }) + } + text="Disable Session Titles" + /> + + handleUpdate({ + readResponseTTS: !readResponseTTS, + }) + } + text="Response Text to Speech" + /> + + + handleUpdate({ + showChatScrollbar: !showChatScrollbar, + }) + } + text="Show Chat Scrollbar" + /> + + + handleUpdate({ + useAutocompleteCache: !useAutocompleteCache, + }) + } + text="Use Autocomplete Cache" + /> + + + handleUpdate({ + useChromiumForDocsCrawling: !useChromiumForDocsCrawling, + }) + } + text="Use Chromium for Docs Crawling" + /> + + + + + + + +
{ + e.preventDefault(); + handleSubmitPromptPath(); + }} + > +
+ Workspace prompts path +
+ { + setFormPromptPath(e.target.value); + }} + /> +
+ {formPromptPath !== promptPath ? ( + <> +
+ +
+
+ +
+ + ) : ( +
+ +
+ )} +
+
+
+
+
{ + e.preventDefault(); + handleDisableAutocompleteSubmit(); + }} + > +
+ Disable autocomplete in files +
+ { + setFormDisableAutocomplete(e.target.value); + }} + /> +
+ {formDisableAutocomplete !== + disableAutocompleteInFiles ? ( + <> +
+ +
+
+ +
+ + ) : ( +
+ +
+ )} +
+
+
+ + Comma-separated list of path matchers + +
+
+
) : null}