BROKEN - config progress

This commit is contained in:
Dallin Romney 2025-02-18 11:15:18 -08:00
parent e6c4f8bc84
commit 58ae1f7995
14 changed files with 514 additions and 419 deletions

View file

@ -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<Config> {
// 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<BrowserSerializedContinueConfig> {
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<ModelRole, ModelDescription[]>, // 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);

View file

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

View file

@ -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<ModelRole, string | null> = {
apply: null,
autocomplete: null,
chat: null,
edit: null,
embed: null,
rerank: null,
summarize: null,
};
configCopy.selectedModelByRole = selectedModelsForProfile;
return configCopy;
}

View file

@ -957,8 +957,6 @@ declare global {
}
interface ExperimentalModelRoles {
inlineEdit?: string;
applyCodeBlock?: string;
repoMapFileSelection?: string;
}

View file

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

View file

@ -16,7 +16,7 @@ function isSupportedModel(
config: ContinueConfig,
modelTitle?: string,
): boolean {
if (config.experimental?.modelRoles?.applyCodeBlock) {
if (config.experimental?.modelRoles?.repoMapFileSelection) {
return true;
}

52
core/index.d.ts vendored
View file

@ -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<TabAutocompleteOptions>;
/** UI styles customization */
@ -1222,6 +1222,8 @@ export interface ContinueConfig {
analytics?: AnalyticsConfig;
docs?: SiteIndexingConfig[];
tools: Tool[];
modelsByRole: Record<ModelRole, ILLM[]>;
selectedModelByRole: Record<ModelRole, string | null>;
}
export interface BrowserSerializedContinueConfig {
@ -1244,6 +1246,8 @@ export interface BrowserSerializedContinueConfig {
tools: Tool[];
usePlatform: boolean;
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
modelsByRole: Record<ModelRole, ModelDescription[]>;
selectedModelByRole: Record<ModelRole, string | null>;
}
// 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;

View file

@ -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": [
{

View file

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

View file

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

View file

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

View file

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

View file

@ -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<SharedConfigSchema>) {
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 (
<div className="flex flex-col gap-4 py-6">
<div>
<h2 className="mb-2 mt-0">User settings</h2>
</div>
<div className="flex flex-col gap-4">
<ToggleSwitch
isToggled={codeWrap}
onToggle={() =>
handleUpdate({
codeWrap: !codeWrap,
})
}
text="Wrap Codeblocks"
/>
<ToggleSwitch
isToggled={displayRawMarkdown}
onToggle={() =>
handleUpdate({
displayRawMarkdown: !displayRawMarkdown,
})
}
text="Display Raw Markdown"
/>
<ToggleSwitch
isToggled={allowAnonymousTelemetry}
onToggle={() =>
handleUpdate({
allowAnonymousTelemetry: !allowAnonymousTelemetry,
})
}
text="Allow Anonymous Telemetry"
/>
<ToggleSwitch
isToggled={disableIndexing}
onToggle={() =>
handleUpdate({
disableIndexing: !disableIndexing,
})
}
text="Disable Indexing"
/>
<ToggleSwitch
isToggled={disableSessionTitles}
onToggle={() =>
handleUpdate({
disableSessionTitles: !disableSessionTitles,
})
}
text="Disable Session Titles"
/>
<ToggleSwitch
isToggled={readResponseTTS}
onToggle={() =>
handleUpdate({
readResponseTTS: !readResponseTTS,
})
}
text="Response Text to Speech"
/>
<ToggleSwitch
isToggled={showChatScrollbar}
onToggle={() =>
handleUpdate({
showChatScrollbar: !showChatScrollbar,
})
}
text="Show Chat Scrollbar"
/>
<ToggleSwitch
isToggled={useAutocompleteCache}
onToggle={() =>
handleUpdate({
useAutocompleteCache: !useAutocompleteCache,
})
}
text="Use Autocomplete Cache"
/>
<ToggleSwitch
isToggled={useChromiumForDocsCrawling}
onToggle={() =>
handleUpdate({
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
})
}
text="Use Chromium for Docs Crawling"
/>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Codeblock Actions Position</span>
<Select
value={codeBlockToolbarPosition}
onChange={(e) =>
handleUpdate({
codeBlockToolbarPosition: e.target.value as "top" | "bottom",
})
}
>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</Select>
</label>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Multiline Autocompletions</span>
<Select
value={useAutocompleteMultilineCompletions}
onChange={(e) =>
handleUpdate({
useAutocompleteMultilineCompletions: e.target.value as
| "auto"
| "always"
| "never",
})
}
>
<option value="auto">Auto</option>
<option value="always">Always</option>
<option value="never">Never</option>
</Select>
</label>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Font Size</span>
<NumberInput
value={fontSize}
onChange={(val) =>
handleUpdate({
fontSize: val,
})
}
min={7}
max={50}
/>
</label>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleSubmitPromptPath();
}}
>
<div className="flex items-center justify-between">
<span>Workspace prompts path</span>
<div className="flex items-center gap-2">
<Input
value={formPromptPath}
className="max-w-[100px]"
onChange={(e) => {
setFormPromptPath(e.target.value);
}}
/>
<div className="flex h-full flex-col">
{formPromptPath !== promptPath ? (
<>
<div
onClick={handleSubmitPromptPath}
className="cursor-pointer"
>
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
</div>
<div
onClick={cancelChangePromptPath}
className="cursor-pointer"
>
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
</div>
</>
) : (
<div>
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
</div>
)}
</div>
</div>
</div>
</form>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleDisableAutocompleteSubmit();
}}
>
<div className="flex items-center justify-between">
<span>Disable autocomplete in files</span>
<div className="flex items-center gap-2">
<Input
value={formDisableAutocomplete}
className="max-w-[100px]"
onChange={(e) => {
setFormDisableAutocomplete(e.target.value);
}}
/>
<div className="flex h-full flex-col">
{formDisableAutocomplete !== disableAutocompleteInFiles ? (
<>
<div
onClick={handleDisableAutocompleteSubmit}
className="cursor-pointer"
>
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
</div>
<div
onClick={cancelChangeDisableAutocomplete}
className="cursor-pointer"
>
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
</div>
</>
) : (
<div>
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
</div>
)}
</div>
</div>
</div>
<span className="text-vsc-foreground-muted self-end text-xs">
Comma-separated list of path matchers
</span>
</form>
</div>
</div>
);
}
export default UserSettingsUI;

View file

@ -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 (
<div className="overflow-y-scroll">
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
@ -166,12 +251,247 @@ function ConfigPage() {
: "Open Workspace"}
</SecondaryButton>
)}
<h2 className="text-sm">Model Roles</h2>
</div>
</div>
{!controlServerBetaEnabled || hubEnabled ? (
<div className="flex flex-col">
<div className="flex max-w-[400px] flex-col">
<UserSettingsUI />
<div className="flex flex-col gap-4 py-6">
<div>
<h2 className="mb-2 mt-0">User settings</h2>
</div>
<div className="flex flex-col gap-4">
<ToggleSwitch
isToggled={codeWrap}
onToggle={() =>
handleUpdate({
codeWrap: !codeWrap,
})
}
text="Wrap Codeblocks"
/>
<ToggleSwitch
isToggled={displayRawMarkdown}
onToggle={() =>
handleUpdate({
displayRawMarkdown: !displayRawMarkdown,
})
}
text="Display Raw Markdown"
/>
<ToggleSwitch
isToggled={allowAnonymousTelemetry}
onToggle={() =>
handleUpdate({
allowAnonymousTelemetry: !allowAnonymousTelemetry,
})
}
text="Allow Anonymous Telemetry"
/>
<ToggleSwitch
isToggled={disableIndexing}
onToggle={() =>
handleUpdate({
disableIndexing: !disableIndexing,
})
}
text="Disable Indexing"
/>
<ToggleSwitch
isToggled={disableSessionTitles}
onToggle={() =>
handleUpdate({
disableSessionTitles: !disableSessionTitles,
})
}
text="Disable Session Titles"
/>
<ToggleSwitch
isToggled={readResponseTTS}
onToggle={() =>
handleUpdate({
readResponseTTS: !readResponseTTS,
})
}
text="Response Text to Speech"
/>
<ToggleSwitch
isToggled={showChatScrollbar}
onToggle={() =>
handleUpdate({
showChatScrollbar: !showChatScrollbar,
})
}
text="Show Chat Scrollbar"
/>
<ToggleSwitch
isToggled={useAutocompleteCache}
onToggle={() =>
handleUpdate({
useAutocompleteCache: !useAutocompleteCache,
})
}
text="Use Autocomplete Cache"
/>
<ToggleSwitch
isToggled={useChromiumForDocsCrawling}
onToggle={() =>
handleUpdate({
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
})
}
text="Use Chromium for Docs Crawling"
/>
<label className="flex items-center justify-between gap-3">
<span className="text-right">
Codeblock Actions Position
</span>
<Select
value={codeBlockToolbarPosition}
onChange={(e) =>
handleUpdate({
codeBlockToolbarPosition: e.target.value as
| "top"
| "bottom",
})
}
>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</Select>
</label>
<label className="flex items-center justify-between gap-3">
<span className="text-right">
Multiline Autocompletions
</span>
<Select
value={useAutocompleteMultilineCompletions}
onChange={(e) =>
handleUpdate({
useAutocompleteMultilineCompletions: e.target
.value as "auto" | "always" | "never",
})
}
>
<option value="auto">Auto</option>
<option value="always">Always</option>
<option value="never">Never</option>
</Select>
</label>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Font Size</span>
<NumberInput
value={fontSize}
onChange={(val) =>
handleUpdate({
fontSize: val,
})
}
min={7}
max={50}
/>
</label>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleSubmitPromptPath();
}}
>
<div className="flex items-center justify-between">
<span>Workspace prompts path</span>
<div className="flex items-center gap-2">
<Input
value={formPromptPath}
className="max-w-[100px]"
onChange={(e) => {
setFormPromptPath(e.target.value);
}}
/>
<div className="flex h-full flex-col">
{formPromptPath !== promptPath ? (
<>
<div
onClick={handleSubmitPromptPath}
className="cursor-pointer"
>
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
</div>
<div
onClick={cancelChangePromptPath}
className="cursor-pointer"
>
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
</div>
</>
) : (
<div>
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
</div>
)}
</div>
</div>
</div>
</form>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleDisableAutocompleteSubmit();
}}
>
<div className="flex items-center justify-between">
<span>Disable autocomplete in files</span>
<div className="flex items-center gap-2">
<Input
value={formDisableAutocomplete}
className="max-w-[100px]"
onChange={(e) => {
setFormDisableAutocomplete(e.target.value);
}}
/>
<div className="flex h-full flex-col">
{formDisableAutocomplete !==
disableAutocompleteInFiles ? (
<>
<div
onClick={handleDisableAutocompleteSubmit}
className="cursor-pointer"
>
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
</div>
<div
onClick={cancelChangeDisableAutocomplete}
className="cursor-pointer"
>
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
</div>
</>
) : (
<div>
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
</div>
)}
</div>
</div>
</div>
<span className="text-vsc-foreground-muted self-end text-xs">
Comma-separated list of path matchers
</span>
</form>
</div>
</div>
</div>
</div>
) : null}